czmq-4.1.0/0000775000372000037200000000000013222211351013360 5ustar00travistravis00000000000000czmq-4.1.0/README.md0000664000372000037200000131667013222211156014660 0ustar00travistravis00000000000000 [![GitHub release](https://img.shields.io/github/release/zeromq/czmq.svg)](https://github.com/zeromq/czmq/releases) [![OBS draft](https://img.shields.io/badge/OBS%20master-draft-yellow.svg)](http://software.opensuse.org/download.html?project=network%3Amessaging%3Azeromq%3Agit-draft&package=czmq) [![OBS stable](https://img.shields.io/badge/OBS%20master-stable-yellow.svg)](http://software.opensuse.org/download.html?project=network%3Amessaging%3Azeromq%3Agit-stable&package=czmq) [![license](https://img.shields.io/github/license/zeromq/czmq.svg)](https://github.com/zeromq/czmq/blob/master/LICENSE) # CZMQ - High-level C binding for ØMQ | Linux & MacOSX | Windows | |:--------------:|:--------:| |[![Build Status](https://travis-ci.org/zeromq/czmq.png?branch=master)](https://travis-ci.org/zeromq/czmq)|[![Build status](https://ci.appveyor.com/api/projects/status/q7y22juu3pnl5wq6?svg=true)](https://ci.appveyor.com/project/zeromq/czmq)| ## Contents **[Overview](#overview)** **[Scope and Goals](#scope-and-goals)** **[Ownership and License](#ownership-and-license)** **[Using CZMQ](#using-czmq)** **[Building and Installing](#building-and-installing)** **[Building on Windows](#building-on-windows)** **[Linking with an Application](#linking-with-an-application)** **[Use from Other Languages](#use-from-other-languages)** **[API v3 Summary](#api-v3-summary)** * [zactor - simple actor framework](#zactor---simple-actor-framework) * [zauth - authentication for ZeroMQ security mechanisms](#zauth---authentication-for-zeromq-security-mechanisms) * [zbeacon - LAN discovery and presence](#zbeacon---lan-discovery-and-presence) * [zcert - work with CURVE security certificates](#zcert---work-with-curve-security-certificates) * [zcertstore - work with CURVE security certificate stores](#zcertstore---work-with-curve-security-certificate-stores) * [zchunk - work with memory chunks](#zchunk---work-with-memory-chunks) * [zclock - millisecond clocks and delays](#zclock---millisecond-clocks-and-delays) * [zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL.](#zconfig---work-with-config-files-written-in-rfczeromqorgspec4zpl) * [zdigest - provides hashing functions (SHA-1 at present)](#zdigest---provides-hashing-functions-sha-1-at-present) * [zdir - work with file-system directories](#zdir---work-with-file-system-directories) * [zdir_patch - work with directory patches](#zdir_patch---work-with-directory-patches) * [zfile - provides methods to work with files in a portable fashion.](#zfile---provides-methods-to-work-with-files-in-a-portable-fashion) * [zframe - working with single message frames](#zframe---working-with-single-message-frames) * [zgossip - decentralized configuration management](#zgossip---decentralized-configuration-management) * [zhash - simple generic hash container](#zhash---simple-generic-hash-container) * [zhashx - extended generic hash container](#zhashx---extended-generic-hash-container) * [ziflist - list of network interfaces available on system](#ziflist---list-of-network-interfaces-available-on-system) * [zlist - simple generic list container](#zlist---simple-generic-list-container) * [zlistx - extended generic list container](#zlistx---extended-generic-list-container) * [zloop - event-driven reactor](#zloop---event-driven-reactor) * [zmonitor - socket event monitor](#zmonitor---socket-event-monitor) * [zmsg - working with multipart messages](#zmsg---working-with-multipart-messages) * [zpoller - trivial socket poller class](#zpoller---trivial-socket-poller-class) * [zproc - process configuration and status](#zproc---process-configuration-and-status) * [zproxy - run a steerable proxy in the background](#zproxy---run-a-steerable-proxy-in-the-background) * [zrex - work with regular expressions](#zrex---work-with-regular-expressions) * [zsock - high-level socket API that hides libzmq contexts and sockets](#zsock---high-level-socket-api-that-hides-libzmq-contexts-and-sockets) * [zstr - sending and receiving strings](#zstr---sending-and-receiving-strings) * [zsys - system-level methods](#zsys---system-level-methods) * [ztimerset - timer set](#ztimerset---timer-set) * [ztrie - simple trie for tokenizable strings](#ztrie---simple-trie-for-tokenizable-strings) * [zuuid - UUID support class](#zuuid---uuid-support-class) **[Error Handling](#error-handling)** **[CZMQ Actors](#czmq-actors)** **[Under the Hood](#under-the-hood)** **[Adding a New Class](#adding-a-new-class)** **[Documentation](#documentation)** **[Development](#development)** **[Porting CZMQ](#porting-czmq)** **[Hints to Contributors](#hints-to-contributors)** **[Code Generation](#code-generation)** **[This Document](#this-document)** ## Overview ### Scope and Goals CZMQ has these goals: * To wrap the ØMQ core API in semantics that lead to shorter, more readable applications. * To hide as far as possible the differences between different versions of ØMQ (2.x, 3.x, 4.x). * To provide a space for development of more sophisticated API semantics. * To wrap the ØMQ security features with high-level tools and APIs. * To become the basis for other language bindings built on top of CZMQ. CZMQ grew out of concepts developed in [ØMQ - The Guide](http://zguide.zeromq.org).
1
### Ownership and License The contributors are listed in AUTHORS. This project uses the MPL v2 license, see LICENSE. CZMQ uses the [C4.1 (Collective Code Construction Contract)](http://rfc.zeromq.org/spec:22) process for contributions. CZMQ uses the [CLASS (C Language Style for Scalabilty)](http://rfc.zeromq.org/spec:21) guide for code style. To report an issue, use the [CZMQ issue tracker](https://github.com/zeromq/czmq/issues) at github.com. ## Using CZMQ ### Building and Installing To start with, you need at least these packages: * {{git-all}} -- git is how we share code with other people. * {{build-essential}}, {{libtool}}, {{pkg-config}} - the C compiler and related tools. * {{autotools-dev}}, {{autoconf}}, {{automake}} - the GNU autoconf makefile generators. * {{cmake}} - the CMake makefile generators (an alternative to autoconf). Plus some others: * {{uuid-dev}}, {{libpcre3-dev}} - utility libraries. * {{valgrind}} - a useful tool for checking your code. * {{pkg-config}} - an optional useful tool to make building with dependencies easier. Which we install like this (using the Debian-style apt-get package manager): sudo apt-get update sudo apt-get install -y \ git-all build-essential libtool \ pkg-config autotools-dev autoconf automake cmake \ uuid-dev libpcre3-dev valgrind # only execute this next line if interested in updating the man pages as well (adds to build time): sudo apt-get install -y asciidoc Here's how to build CZMQ from GitHub (building from packages is very similar, you don't clone a repo but unpack a tarball), including the libzmq (ZeroMQ core) library (NOTE: skip ldconfig on OSX): git clone git://github.com/zeromq/libzmq.git cd libzmq ./autogen.sh # do not specify "--with-libsodium" if you prefer to use internal tweetnacl security implementation (recommended for development) ./configure --with-libsodium make check sudo make install sudo ldconfig cd .. git clone git://github.com/zeromq/czmq.git cd czmq ./autogen.sh && ./configure && make check sudo make install sudo ldconfig cd .. In general CZMQ works best with the latest libzmq master. If you already have an older version of libzmq installed on your system, e.g. in /usr/, then you can install libzmq master to your home directory ($HOME/local): # Building libzmq in our home directory ./configure --prefix=$HOME/local And then to build CZMQ against this installation of libzmq: export CFLAGS=-I$HOME/local/include export LDFLAGS=-L$HOME/local/lib64 export PKG_CONFIG_PATH=$HOME/local/lib64/pkgconfig ./configure NOTE: the PKG_CONFIG_PATH is not mandatory, and the actual directory might be different. If you cannot or do not want to use pkg-config, please make sure to MANUALLY add all the necessary CFLAGS and LDFLAGS from all dependencies (for example -DZMQ_BUILD_DRAFT_API=1 if you want the DRAFT APIs). You will need the pkg-config, libtool, and autoreconf packages. After building, run the CZMQ selftests: make check ### Building on Windows To start with, you need MS Visual Studio (C/C++). The free community edition works well. Then, install git, and make sure it works from a DevStudio command prompt: ``` git ``` Now let's build CZMQ from GitHub: ``` git clone --depth 1 -b stable https://github.com/jedisct1/libsodium.git cd libsodium\builds\msvc\build buildall.bat cd ..\..\..\.. :: if libsodium is on disk, the Windows build of libzmq will automatically use it git clone git://github.com/zeromq/libzmq.git cd libzmq\builds\msvc configure.bat cd build buildall.bat cd ..\..\..\.. git clone git://github.com/zeromq/czmq.git cd czmq\builds\msvc configure.bat cd build buildall.bat cd ..\..\..\.. ``` Let's test by running `czmq_selftest`: ``` czmq>dir/s/b czmq_selftest.exe czmq\builds\msvc\vs2013\DebugDEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\DebugLEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\DebugSEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\ReleaseDEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\ReleaseLEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\ReleaseSEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\x64\DebugDEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\x64\DebugLEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\x64\DebugSEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\x64\ReleaseDEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\x64\ReleaseLEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\x64\ReleaseSEXE\czmq_selftest.exe :: select your choice and run it czmq\builds\msvc\vs2013\x64\ReleaseDEXE\czmq_selftest.exe ``` ### Linking with an Application Include `czmq.h` in your application and link with libczmq. Here is a typical gcc link command: gcc myapp.c -o myapp -lczmq -lzmq ### Use from Other Languages This is a list of auto-generated bindings: * https://github.com/zeromq/czmq/tree/master/bindings/jni - Java * https://github.com/zeromq/czmq/tree/master/bindings/nodejs - NodeJS * https://github.com/zeromq/czmq/tree/master/bindings/python - Python * https://github.com/zeromq/czmq/tree/master/bindings/python_cffi - Python (cffi) * https://github.com/zeromq/czmq/tree/master/bindings/qml - QML * https://github.com/zeromq/czmq/tree/master/bindings/qt - Qt * https://github.com/zeromq/czmq/tree/master/bindings/ruby - Ruby (FFI) This is a list of known higher-level wrappers around CZMQ: * https://github.com/1100110/CZMQ - D bindings * https://github.com/methodmissing/rbczmq - Ruby * https://github.com/paddor/cztop - Ruby, based on generated FFI binding * https://github.com/zeromq/pyczmq - Python * https://github.com/lhope/cl-czmq - Common Lisp * https://github.com/fmp88/ocaml-czmq - Ocaml * https://github.com/gar1t/erlang-czmq - Erlang * https://github.com/mtortonesi/ruby-czmq-ffi - Ruby FFI * https://github.com/zeromq/goczmq - Go ### API v3 Summary This is the API provided by CZMQ v3.x, in alphabetical order. #### zactor - simple actor framework The zactor class provides a simple actor framework. It replaces the CZMQ zthread class, which had a complex API that did not fit the CLASS standard. A CZMQ actor is implemented as a thread plus a PAIR-PAIR pipe. The constructor and destructor are always synchronized, so the caller can be sure all resources are created, and destroyed, when these calls complete. (This solves a major problem with zthread, that a caller could not be sure when a child thread had finished.) A zactor_t instance acts like a zsock_t and you can pass it to any CZMQ method that would take a zsock_t argument, including methods in zframe, zmsg, zstr, and zpoller. (zloop somehow escaped and needs catching.) An actor function MUST call zsock_signal (pipe) when initialized and MUST listen to pipe and exit on $TERM command. Please add '@discuss' section in './../src/zactor.c'. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Actors get a pipe and arguments from caller typedef void (zactor_fn) ( zsock_t *pipe, void *args); // Create a new actor passing arbitrary arguments reference. CZMQ_EXPORT zactor_t * zactor_new (zactor_fn task, void *args); // Destroy an actor. CZMQ_EXPORT void zactor_destroy (zactor_t **self_p); // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. CZMQ_EXPORT int zactor_send (zactor_t *self, zmsg_t **msg_p); // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zmsg_t * zactor_recv (zactor_t *self); // Probe the supplied object, and report if it looks like a zactor_t. CZMQ_EXPORT bool zactor_is (void *self); // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. CZMQ_EXPORT void * zactor_resolve (void *self); // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. CZMQ_EXPORT zsock_t * zactor_sock (zactor_t *self); // Self test of this class. CZMQ_EXPORT void zactor_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // Function to be called on zactor_destroy. Default behavior is to send zmsg_t with string "$TERM" in a first frame. // // An example - to send $KTHXBAI string // // if (zstr_send (self->pipe, "$KTHXBAI") == 0) // zsock_wait (self->pipe); typedef void (zactor_destructor_fn) ( zactor_t *self); // *** Draft method, for development use, may change without warning *** // Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. CZMQ_EXPORT void zactor_set_destructor (zactor_t *self, zactor_destructor_fn destructor); #endif // CZMQ_BUILD_DRAFT_API ``` Please add '@interface' section in './../src/zactor.c'. This is the class self test code: ```c zactor_t *actor = zactor_new (echo_actor, "Hello, World"); assert (actor); zstr_sendx (actor, "ECHO", "This is a string", NULL); char *string = zstr_recv (actor); assert (streq (string, "This is a string")); free (string); zactor_destroy (&actor); // custom destructor // KTHXBAI_actor ends on "$KTHXBAI" string zactor_t *KTHXBAI = zactor_new (KTHXBAI_actor, NULL); assert (KTHXBAI); // which is the one sent by KTHXBAI_destructor zactor_set_destructor (KTHXBAI, KTHXBAI_destructor); zactor_destroy (&KTHXBAI); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zauth - authentication for ZeroMQ security mechanisms A zauth actor takes over authentication for all incoming connections in its context. You can whitelist or blacklist peers based on IP address, and define policies for securing PLAIN, CURVE, and GSSAPI connections. This class replaces zauth_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). This is the class interface: ```h #define CURVE_ALLOW_ANY "*" // CZMQ v3 API (for use with zsock, not zsocket, which is deprecated). // // Create new zauth actor instance. This installs authentication on all // zsock sockets. Until you add policies, all incoming NULL connections are // allowed (classic ZeroMQ behaviour), and all PLAIN and CURVE connections // are denied: // // zactor_t *auth = zactor_new (zauth, NULL); // // Destroy zauth instance. This removes authentication and allows all // connections to pass, without authentication: // // zactor_destroy (&auth); // // Note that all zauth commands are synchronous, so your application always // waits for a signal from the actor after each command. // // Enable verbose logging of commands and activity. Verbose logging can help // debug non-trivial authentication policies: // // zstr_send (auth, "VERBOSE"); // zsock_wait (auth); // // Allow (whitelist) a list of IP addresses. For NULL, all clients from // these addresses will be accepted. For PLAIN and CURVE, they will be // allowed to continue with authentication. You can call this method // multiple times to whitelist more IP addresses. If you whitelist one // or more addresses, any non-whitelisted addresses are treated as // blacklisted: // // zstr_sendx (auth, "ALLOW", "127.0.0.1", "127.0.0.2", NULL); // zsock_wait (auth); // // Deny (blacklist) a list of IP addresses. For all security mechanisms, // this rejects the connection without any further authentication. Use // either a whitelist, or a blacklist, not not both. If you define both // a whitelist and a blacklist, only the whitelist takes effect: // // zstr_sendx (auth, "DENY", "192.168.0.1", "192.168.0.2", NULL); // zsock_wait (auth); // // Configure PLAIN authentication using a plain-text password file. You can // modify the password file at any time; zauth will reload it automatically // if modified externally: // // zstr_sendx (auth, "PLAIN", filename, NULL); // zsock_wait (auth); // // Configure CURVE authentication, using a directory that holds all public // client certificates, i.e. their public keys. The certificates must be in // zcert_save format. You can add and remove certificates in that directory // at any time. To allow all client keys without checking, specify // CURVE_ALLOW_ANY for the directory name: // // zstr_sendx (auth, "CURVE", directory, NULL); // zsock_wait (auth); // // Configure GSSAPI authentication, using an underlying mechanism (usually // Kerberos) to establish a secure context and perform mutual authentication: // // zstr_sendx (auth, "GSSAPI", NULL); // zsock_wait (auth); // // This is the zauth constructor as a zactor_fn: CZMQ_EXPORT void zauth (zsock_t *pipe, void *certstore); // Selftest CZMQ_EXPORT void zauth_test (bool verbose); ``` Please add '@interface' section in './../src/zauth.c'. This is the class self test code: ```c // Create temporary directory for test files # define TESTDIR ".test_zauth" zsys_dir_create (TESTDIR); // Check there's no authentication zsock_t *server = zsock_new (ZMQ_PULL); assert (server); zsock_t *client = zsock_new (ZMQ_PUSH); assert (client); bool success = s_can_connect (&server, &client, true); assert (success); // Install the authenticator zactor_t *auth = zactor_new (zauth, NULL); assert (auth); if (verbose) { zstr_sendx (auth, "VERBOSE", NULL); zsock_wait (auth); } // Check there's no authentication on a default NULL server success = s_can_connect (&server, &client, true); assert (success); // When we set a domain on the server, we switch on authentication // for NULL sockets, but with no policies, the client connection // will be allowed. zsock_set_zap_domain (server, "global"); success = s_can_connect (&server, &client, true); assert (success); // Blacklist 127.0.0.1, connection should fail zsock_set_zap_domain (server, "global"); zstr_sendx (auth, "DENY", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&server, &client, true); assert (!success); // Whitelist our address, which overrides the blacklist zsock_set_zap_domain (server, "global"); zstr_sendx (auth, "ALLOW", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&server, &client, true); assert (success); // Try PLAIN authentication zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Password"); success = s_can_connect (&server, &client, true); assert (!success); FILE *password = fopen (TESTDIR "/password-file", "w"); assert (password); fprintf (password, "admin=Password\n"); fclose (password); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Password"); zstr_sendx (auth, "PLAIN", TESTDIR "/password-file", NULL); zsock_wait (auth); success = s_can_connect (&server, &client, true); assert (success); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Bogus"); success = s_can_connect (&server, &client, true); assert (!success); if (zsys_has_curve ()) { // Try CURVE authentication // We'll create two new certificates and save the client public // certificate on disk; in a real case we'd transfer this securely // from the client machine to the server machine. zcert_t *server_cert = zcert_new (); assert (server_cert); zcert_t *client_cert = zcert_new (); assert (client_cert); const char *server_key = zcert_public_txt (server_cert); // Test without setting-up any authentication zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); success = s_can_connect (&server, &client, true); assert (!success); // Test CURVE_ALLOW_ANY zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zstr_sendx (auth, "CURVE", CURVE_ALLOW_ANY, NULL); zsock_wait (auth); success = s_can_connect (&server, &client, true); assert (success); // Test full client authentication using certificates zcert_set_meta (client_cert, "Hello", "%s", "World!"); zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zcert_save_public (client_cert, TESTDIR "/mycert.txt"); zstr_sendx (auth, "CURVE", TESTDIR, NULL); zsock_wait (auth); success = s_can_connect (&server, &client, false); assert (success); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (4, 1, 0)) // Test send/recv certificate metadata zframe_t *frame = zframe_recv (server); assert (frame != NULL); const char *meta = zframe_meta (frame, "Hello"); assert (meta != NULL); assert (streq (meta, "World!")); zframe_destroy (&frame); s_renew_sockets(&server, &client); #endif zcert_destroy (&server_cert); zcert_destroy (&client_cert); // Test custom zcertstore zcertstore_t *certstore = zcertstore_new (NULL); zcertstore_set_loader (certstore, s_test_loader, NULL, NULL); zactor_destroy(&auth); auth = zactor_new (zauth, certstore); assert (auth); if (verbose) { zstr_sendx (auth, "VERBOSE", NULL); zsock_wait (auth); } byte public_key [32] = { 105, 76, 150, 58, 214, 191, 218, 65, 50, 172, 131, 188, 247, 211, 136, 170, 227, 26, 57, 170, 185, 63, 246, 225, 177, 230, 12, 8, 134, 136, 105, 106 }; byte secret_key [32] = { 245, 217, 172, 73, 106, 28, 195, 17, 218, 132, 135, 209, 99, 240, 98, 232, 7, 137, 244, 100, 242, 23, 29, 114, 70, 223, 83, 1, 113, 207, 132, 149 }; zcert_t *shared_cert = zcert_new_from (public_key, secret_key); assert (shared_cert); zcert_apply (shared_cert, server); zcert_apply (shared_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, "x?T*N/1Y{8goubv{Ts}#&#f}TXJ//DVe#D2HkoLU"); success = s_can_connect (&server, &client, true); assert (success); zcert_destroy (&shared_cert); } // Remove the authenticator and check a normal connection works zactor_destroy (&auth); success = s_can_connect (&server, &client, true); assert (success); zsock_destroy (&client); zsock_destroy (&server); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zbeacon - LAN discovery and presence The zbeacon class implements a peer-to-peer discovery service for local networks. A beacon can broadcast and/or capture service announcements using UDP messages on the local area network. This implementation uses IPv4 UDP broadcasts. You can define the format of your outgoing beacons, and set a filter that validates incoming beacons. Beacons are sent and received asynchronously in the background. This class replaces zbeacon_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). This is the class interface: ```h // Create new zbeacon actor instance: // // zactor_t *beacon = zactor_new (zbeacon, NULL); // // Destroy zbeacon instance: // // zactor_destroy (&beacon); // // Enable verbose logging of commands and activity: // // zstr_send (beacon, "VERBOSE"); // // Configure beacon to run on specified UDP port, and return the name of // the host, which can be used as endpoint for incoming connections. To // force the beacon to operate on a given interface, set the environment // variable ZSYS_INTERFACE, or call zsys_set_interface() before creating // the beacon. If the system does not support UDP broadcasts (lacking a // workable interface), returns an empty hostname: // // // Pictures: 's' = C string, 'i' = int // zsock_send (beacon, "si", "CONFIGURE", port_number); // char *hostname = zstr_recv (beacon); // // Start broadcasting a beacon at a specified interval in msec. The beacon // data can be at most UDP_FRAME_MAX bytes; this constant is defined in // zsys.h to be 255: // // // Pictures: 'b' = byte * data + size_t size // zsock_send (beacon, "sbi", "PUBLISH", data, size, interval); // // Stop broadcasting the beacon: // // zstr_sendx (beacon, "SILENCE", NULL); // // Start listening to beacons from peers. The filter is used to do a prefix // match on received beacons, to remove junk. Note that any received data // that is identical to our broadcast beacon_data is discarded in any case. // If the filter size is zero, we get all peer beacons: // // zsock_send (beacon, "sb", "SUBSCRIBE", filter_data, filter_size); // // Stop listening to other peers // // zstr_sendx (beacon, "UNSUBSCRIBE", NULL); // // Receive next beacon from a peer. Received beacons are always a 2-frame // message containing the ipaddress of the sender, and then the binary // beacon data as published by the sender: // // zmsg_t *msg = zmsg_recv (beacon); // // This is the zbeacon constructor as a zactor_fn: CZMQ_EXPORT void zbeacon (zsock_t *pipe, void *unused); // Self test of this class CZMQ_EXPORT void zbeacon_test (bool verbose); ``` Please add '@interface' section in './../src/zbeacon.c'. This is the class self test code: ```c // Test 1 - two beacons, one speaking, one listening // Create speaker beacon to broadcast our service zactor_t *speaker = zactor_new (zbeacon, NULL); assert (speaker); if (verbose) zstr_sendx (speaker, "VERBOSE", NULL); zsock_send (speaker, "si", "CONFIGURE", 9999); char *hostname = zstr_recv (speaker); if (!*hostname) { printf ("OK (skipping test, no UDP broadcasting)\n"); zactor_destroy (&speaker); free (hostname); return; } free (hostname); // Create listener beacon on port 9999 to lookup service zactor_t *listener = zactor_new (zbeacon, NULL); assert (listener); if (verbose) zstr_sendx (listener, "VERBOSE", NULL); zsock_send (listener, "si", "CONFIGURE", 9999); hostname = zstr_recv (listener); assert (*hostname); free (hostname); // We will broadcast the magic value 0xCAFE byte announcement [2] = { 0xCA, 0xFE }; zsock_send (speaker, "sbi", "PUBLISH", announcement, 2, 100); // We will listen to anything (empty subscription) zsock_send (listener, "sb", "SUBSCRIBE", "", 0); // Wait for at most 1/2 second if there's no broadcasting zsock_set_rcvtimeo (listener, 500); char *ipaddress = zstr_recv (listener); if (ipaddress) { zframe_t *content = zframe_recv (listener); assert (zframe_size (content) == 2); assert (zframe_data (content) [0] == 0xCA); assert (zframe_data (content) [1] == 0xFE); zframe_destroy (&content); zstr_free (&ipaddress); zstr_sendx (speaker, "SILENCE", NULL); } zactor_destroy (&listener); zactor_destroy (&speaker); // Test subscription filter using a 3-node setup zactor_t *node1 = zactor_new (zbeacon, NULL); assert (node1); zsock_send (node1, "si", "CONFIGURE", 5670); hostname = zstr_recv (node1); assert (*hostname); free (hostname); zactor_t *node2 = zactor_new (zbeacon, NULL); assert (node2); zsock_send (node2, "si", "CONFIGURE", 5670); hostname = zstr_recv (node2); assert (*hostname); free (hostname); zactor_t *node3 = zactor_new (zbeacon, NULL); assert (node3); zsock_send (node3, "si", "CONFIGURE", 5670); hostname = zstr_recv (node3); assert (*hostname); free (hostname); zsock_send (node1, "sbi", "PUBLISH", "NODE/1", 6, 250); zsock_send (node2, "sbi", "PUBLISH", "NODE/2", 6, 250); zsock_send (node3, "sbi", "PUBLISH", "RANDOM", 6, 250); zsock_send (node1, "sb", "SUBSCRIBE", "NODE", 4); // Poll on three API sockets at once zpoller_t *poller = zpoller_new (node1, node2, node3, NULL); assert (poller); int64_t stop_at = zclock_mono () + 1000; while (zclock_mono () < stop_at) { long timeout = (long) (stop_at - zclock_mono ()); if (timeout < 0) timeout = 0; void *which = zpoller_wait (poller, timeout * ZMQ_POLL_MSEC); if (which) { assert (which == node1); char *ipaddress, *received; zstr_recvx (node1, &ipaddress, &received, NULL); assert (streq (received, "NODE/2")); zstr_free (&ipaddress); zstr_free (&received); } } zpoller_destroy (&poller); // Stop listening zstr_sendx (node1, "UNSUBSCRIBE", NULL); // Stop all node broadcasts zstr_sendx (node1, "SILENCE", NULL); zstr_sendx (node2, "SILENCE", NULL); zstr_sendx (node3, "SILENCE", NULL); // Destroy the test nodes zactor_destroy (&node1); zactor_destroy (&node2); zactor_destroy (&node3); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zcert - work with CURVE security certificates The zcert class provides a way to create and work with security certificates for the ZMQ CURVE mechanism. A certificate contains a public + secret key pair, plus metadata. It can be used as a temporary object in memory, or persisted to disk. On disk, a certificate is stored as two files. One is public and contains only the public key. The second is secret and contains both keys. The two have the same filename, with the secret file adding "_secret". To exchange certificates, send the public file via some secure route. Certificates are not signed but are text files that can be verified by eye. Certificates are stored in the ZPL (ZMQ RFC 4) format. They have two sections, "metadata" and "curve". The first contains a list of 'name = value' pairs, one per line. Values may be enclosed in quotes. The curve section has a 'public-key = keyvalue' and, for secret certificates, a 'secret-key = keyvalue' line. The keyvalue is a Z85-encoded CURVE key. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Create and initialize a new certificate in memory CZMQ_EXPORT zcert_t * zcert_new (void); // Accepts public/secret key pair from caller CZMQ_EXPORT zcert_t * zcert_new_from (const byte *public_key, const byte *secret_key); // Load certificate from file CZMQ_EXPORT zcert_t * zcert_load (const char *filename); // Destroy a certificate in memory CZMQ_EXPORT void zcert_destroy (zcert_t **self_p); // Return public part of key pair as 32-byte binary string CZMQ_EXPORT const byte * zcert_public_key (zcert_t *self); // Return secret part of key pair as 32-byte binary string CZMQ_EXPORT const byte * zcert_secret_key (zcert_t *self); // Return public part of key pair as Z85 armored string CZMQ_EXPORT const char * zcert_public_txt (zcert_t *self); // Return secret part of key pair as Z85 armored string CZMQ_EXPORT const char * zcert_secret_txt (zcert_t *self); // Set certificate metadata from formatted string. CZMQ_EXPORT void zcert_set_meta (zcert_t *self, const char *name, const char *format, ...) CHECK_PRINTF (3); // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. CZMQ_EXPORT const char * zcert_meta (zcert_t *self, const char *name); // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. CZMQ_EXPORT zlist_t * zcert_meta_keys (zcert_t *self); // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). CZMQ_EXPORT int zcert_save (zcert_t *self, const char *filename); // Save public certificate only to file for persistent storage CZMQ_EXPORT int zcert_save_public (zcert_t *self, const char *filename); // Save secret certificate only to file for persistent storage CZMQ_EXPORT int zcert_save_secret (zcert_t *self, const char *filename); // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. CZMQ_EXPORT void zcert_apply (zcert_t *self, void *socket); // Return copy of certificate; if certificate is NULL or we exhausted // heap memory, returns NULL. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zcert_t * zcert_dup (zcert_t *self); // Return true if two certificates have the same keys CZMQ_EXPORT bool zcert_eq (zcert_t *self, zcert_t *compare); // Print certificate contents to stdout CZMQ_EXPORT void zcert_print (zcert_t *self); // Self test of this class CZMQ_EXPORT void zcert_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Unset certificate metadata. CZMQ_EXPORT void zcert_unset_meta (zcert_t *self, const char *name); #endif // CZMQ_BUILD_DRAFT_API ``` Please add '@interface' section in './../src/zcert.c'. This is the class self test code: ```c // Create temporary directory for test files # define TESTDIR ".test_zcert" zsys_dir_create (TESTDIR); // Create a simple certificate with metadata zcert_t *cert = zcert_new (); assert (cert); zcert_set_meta (cert, "email", "ph@imatix.com"); zcert_set_meta (cert, "name", "Pieter Hintjens"); zcert_set_meta (cert, "organization", "iMatix Corporation"); zcert_set_meta (cert, "version", "%d", 1); zcert_set_meta (cert, "delete_me", "now"); zcert_unset_meta (cert, "delete_me"); assert (streq (zcert_meta (cert, "email"), "ph@imatix.com")); zlist_t *keys = zcert_meta_keys (cert); assert (zlist_size (keys) == 4); zlist_destroy (&keys); // Check the dup and eq methods zcert_t *shadow = zcert_dup (cert); assert (zcert_eq (cert, shadow)); zcert_destroy (&shadow); // Check we can save and load certificate zcert_save (cert, TESTDIR "/mycert.txt"); assert (zsys_file_exists (TESTDIR "/mycert.txt")); assert (zsys_file_exists (TESTDIR "/mycert.txt_secret")); // Load certificate, will in fact load secret one shadow = zcert_load (TESTDIR "/mycert.txt"); assert (shadow); assert (zcert_eq (cert, shadow)); zcert_destroy (&shadow); // Delete secret certificate, load public one int rc = zsys_file_delete (TESTDIR "/mycert.txt_secret"); assert (rc == 0); shadow = zcert_load (TESTDIR "/mycert.txt"); // 32-byte null key encodes as 40 '0' characters assert (streq (zcert_secret_txt (shadow), FORTY_ZEROES)); zcert_destroy (&shadow); zcert_destroy (&cert); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zcertstore - work with CURVE security certificate stores To authenticate new clients using the ZeroMQ CURVE security mechanism, we have to check that the client's public key matches a key we know and accept. There are numerous ways to store accepted client public keys. The mechanism CZMQ implements is "certificates" (plain text files) held in a "certificate store" (a disk directory). This class works with such certificate stores, and lets you easily load them from disk, and check if a given client public key is known or not. The zcert class does the work of managing a single certificate. The certificate store can be memory-only, in which case you can load it yourself by inserting certificate objects one by one, or it can be loaded from disk, in which case you can add, modify, or remove certificates on disk at any time, and the store will detect such changes and refresh itself automatically. In most applications you won't use this class directly but through the zauth class, which provides a high-level API for authentication (and manages certificate stores for you). To actually create certificates on disk, use the zcert class in code, or the tools/zmakecert.c command line tool, or any text editor. The format of a certificate file is defined in the zcert man page. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. CZMQ_EXPORT zcertstore_t * zcertstore_new (const char *location); // Destroy a certificate store object in memory. Does not affect anything // stored on disk. CZMQ_EXPORT void zcertstore_destroy (zcertstore_t **self_p); // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. CZMQ_EXPORT zcert_t * zcertstore_lookup (zcertstore_t *self, const char *public_key); // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. CZMQ_EXPORT void zcertstore_insert (zcertstore_t *self, zcert_t **cert_p); // Print list of certificates in store to logging facility CZMQ_EXPORT void zcertstore_print (zcertstore_t *self); // Self test of this class CZMQ_EXPORT void zcertstore_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // Loaders retrieve certificates from an arbitrary source. typedef void (zcertstore_loader) ( zcertstore_t *self); // Destructor for loader state. typedef void (zcertstore_destructor) ( void **self_p); // *** Draft method, for development use, may change without warning *** // Override the default disk loader with a custom loader fn. CZMQ_EXPORT void zcertstore_set_loader (zcertstore_t *self, zcertstore_loader loader, zcertstore_destructor destructor, void *state); // *** Draft method, for development use, may change without warning *** // Empty certificate hashtable. This wrapper exists to be friendly to bindings, // which don't usually have access to struct internals. CZMQ_EXPORT void zcertstore_empty (zcertstore_t *self); #endif // CZMQ_BUILD_DRAFT_API ``` Please add '@interface' section in './../src/zcertstore.c'. This is the class self test code: ```c // Create temporary directory for test files # define TESTDIR ".test_zcertstore" zsys_dir_create (TESTDIR); // Load certificate store from disk; it will be empty zcertstore_t *certstore = zcertstore_new (TESTDIR); assert (certstore); // Create a single new certificate and save to disk zcert_t *cert = zcert_new (); assert (cert); char *client_key = strdup (zcert_public_txt (cert)); assert (client_key); zcert_set_meta (cert, "name", "John Doe"); zcert_save (cert, TESTDIR "/mycert.txt"); zcert_destroy (&cert); // Check that certificate store refreshes as expected cert = zcertstore_lookup (certstore, client_key); assert (cert); assert (streq (zcert_meta (cert, "name"), "John Doe")); // Test custom loader test_loader_state *state = (test_loader_state *) zmalloc (sizeof (test_loader_state)); state->index = 0; zcertstore_set_loader (certstore, s_test_loader, s_test_destructor, (void *)state); #if (ZMQ_VERSION_MAJOR >= 4) cert = zcertstore_lookup (certstore, client_key); assert (cert == NULL); cert = zcertstore_lookup (certstore, "abcdefghijklmnopqrstuvwxyzabcdefghijklmn"); assert (cert); #endif free (client_key); if (verbose) zcertstore_print (certstore); zcertstore_destroy (&certstore); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zchunk - work with memory chunks The zchunk class works with variable sized blobs. Not as efficient as ZeroMQ's messages but they do less weirdness and so are easier to understand. The chunk class has methods to read and write chunks from disk. Please add '@discuss' section in './../src/zchunk.c'. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. CZMQ_EXPORT zchunk_t * zchunk_new (const void *data, size_t size); // Destroy a chunk CZMQ_EXPORT void zchunk_destroy (zchunk_t **self_p); // Resizes chunk max_size as requested; chunk_cur size is set to zero CZMQ_EXPORT void zchunk_resize (zchunk_t *self, size_t size); // Return chunk cur size CZMQ_EXPORT size_t zchunk_size (zchunk_t *self); // Return chunk max size CZMQ_EXPORT size_t zchunk_max_size (zchunk_t *self); // Return chunk data CZMQ_EXPORT byte * zchunk_data (zchunk_t *self); // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk CZMQ_EXPORT size_t zchunk_set (zchunk_t *self, const void *data, size_t size); // Fill chunk data from user-supplied octet CZMQ_EXPORT size_t zchunk_fill (zchunk_t *self, byte filler, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, it is truncated. If you want to // grow the chunk to accommodate new data, use the zchunk_extend method. CZMQ_EXPORT size_t zchunk_append (zchunk_t *self, const void *data, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, the chunk grows in size. CZMQ_EXPORT size_t zchunk_extend (zchunk_t *self, const void *data, size_t size); // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. CZMQ_EXPORT size_t zchunk_consume (zchunk_t *self, zchunk_t *source); // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. CZMQ_EXPORT bool zchunk_exhausted (zchunk_t *self); // Read chunk from an open file descriptor // Caller owns return value and must destroy it when done. CZMQ_EXPORT zchunk_t * zchunk_read (FILE *handle, size_t bytes); // Write chunk to an open file descriptor CZMQ_EXPORT int zchunk_write (zchunk_t *self, FILE *handle); // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zchunk_t * zchunk_slurp (const char *filename, size_t maxsize); // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // returns null. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zchunk_t * zchunk_dup (zchunk_t *self); // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zchunk_strhex (zchunk_t *self); // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zchunk_strdup (zchunk_t *self); // Return TRUE if chunk body is equal to string, excluding terminator CZMQ_EXPORT bool zchunk_streq (zchunk_t *self, const char *string); // Transform zchunk into a zframe that can be sent in a message. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zchunk_pack (zchunk_t *self); // Transform a zframe into a zchunk. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zchunk_t * zchunk_unpack (zframe_t *frame); // Calculate SHA1 digest for chunk, using zdigest class. CZMQ_EXPORT const char * zchunk_digest (zchunk_t *self); // Dump chunk to FILE stream, for debugging and tracing. CZMQ_EXPORT void zchunk_fprint (zchunk_t *self, FILE *file); // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details CZMQ_EXPORT void zchunk_print (zchunk_t *self); // Probe the supplied object, and report if it looks like a zchunk_t. CZMQ_EXPORT bool zchunk_is (void *self); // Self test of this class. CZMQ_EXPORT void zchunk_test (bool verbose); ``` Please add '@interface' section in './../src/zchunk.c'. This is the class self test code: ```c zchunk_t *chunk = zchunk_new ("1234567890", 10); assert (chunk); assert (zchunk_size (chunk) == 10); assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0); zchunk_destroy (&chunk); chunk = zchunk_new (NULL, 10); assert (chunk); zchunk_append (chunk, "12345678", 8); zchunk_append (chunk, "90ABCDEF", 8); zchunk_append (chunk, "GHIJKLMN", 8); assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0); assert (zchunk_size (chunk) == 10); assert (zchunk_streq (chunk, "1234567890")); assert (streq (zchunk_digest (chunk), "01B307ACBA4F54F55AAFC33BB06BBBF6CA803E9A")); char *string = zchunk_strdup (chunk); assert (streq (string, "1234567890")); free (string); string = zchunk_strhex (chunk); assert (streq (string, "31323334353637383930")); free (string); zframe_t *frame = zchunk_pack (chunk); assert (frame); zchunk_t *chunk2 = zchunk_unpack (frame); assert (chunk2); assert (memcmp (zchunk_data (chunk2), "1234567890", 10) == 0); zframe_destroy (&frame); zchunk_destroy (&chunk2); zchunk_t *copy = zchunk_dup (chunk); assert (copy); assert (memcmp (zchunk_data (copy), "1234567890", 10) == 0); assert (zchunk_size (copy) == 10); zchunk_destroy (©); zchunk_destroy (&chunk); chunk = zchunk_new (NULL, 0); zchunk_extend (chunk, "12345678", 8); zchunk_extend (chunk, "90ABCDEF", 8); zchunk_extend (chunk, "GHIJKLMN", 8); assert (zchunk_size (chunk) == 24); assert (zchunk_streq (chunk, "1234567890ABCDEFGHIJKLMN")); zchunk_destroy (&chunk); copy = zchunk_new ("1234567890abcdefghij", 20); assert (copy); chunk = zchunk_new (NULL, 8); assert (chunk); zchunk_consume (chunk, copy); assert (!zchunk_exhausted (copy)); assert (memcmp (zchunk_data (chunk), "12345678", 8) == 0); zchunk_set (chunk, NULL, 0); zchunk_consume (chunk, copy); assert (!zchunk_exhausted (copy)); assert (memcmp (zchunk_data (chunk), "90abcdef", 8) == 0); zchunk_set (chunk, NULL, 0); zchunk_consume (chunk, copy); assert (zchunk_exhausted (copy)); assert (zchunk_size (chunk) == 4); assert (memcmp (zchunk_data (chunk), "ghij", 4) == 0); zchunk_destroy (©); zchunk_destroy (&chunk); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zclock - millisecond clocks and delays The zclock class provides essential sleep and system time functions, used to slow down threads for testing, and calculate timers for polling. Wraps the non-portable system calls in a simple portable API. The Win32 Sleep() call defaults to 16ms resolution unless the system timer resolution is increased with a call to timeBeginPeriod() permitting 1ms granularity. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Sleep for a number of milliseconds CZMQ_EXPORT void zclock_sleep (int msecs); // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. CZMQ_EXPORT int64_t zclock_time (void); // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. CZMQ_EXPORT int64_t zclock_mono (void); // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. CZMQ_EXPORT int64_t zclock_usecs (void); // Return formatted date/time as fresh string. Free using zstr_free(). // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zclock_timestr (void); // Self test of this class. CZMQ_EXPORT void zclock_test (bool verbose); ``` Please add '@interface' section in './../src/zclock.c'. This is the class self test code: ```c int64_t start = zclock_time (); zclock_sleep (10); assert ((zclock_time () - start) >= 10); start = zclock_mono (); int64_t usecs = zclock_usecs (); zclock_sleep (10); assert ((zclock_mono () - start) >= 10); assert ((zclock_usecs () - usecs) >= 10000); char *timestr = zclock_timestr (); if (verbose) puts (timestr); free (timestr); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL. Lets applications load, work with, and save configuration files. This implements rfc.zeromq.org/spec:4/ZPL, which is a simple structured text format for configuration files. Here is an example ZPL stream and corresponding config structure: context iothreads = 1 verbose = 1 # Ask for a trace main type = zqueue # ZMQ_DEVICE type frontend option hwm = 1000 swap = 25000000 # 25MB bind = 'inproc://addr1' bind = 'ipc://addr2' backend bind = inproc://addr3 root Down = child | Across = next v context-->main | | | v | type=queue-->frontend-->backend | | | | | v | | bind=inproc://addr3 | v | option-->bind=inproc://addr1-->bind=ipc://addr2 | | | v | hwm=1000-->swap=25000000 v iothreads=1-->verbose=false This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // typedef int (zconfig_fct) ( zconfig_t *self, void *arg, int level); // Create new config item CZMQ_EXPORT zconfig_t * zconfig_new (const char *name, zconfig_t *parent); // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. CZMQ_EXPORT zconfig_t * zconfig_load (const char *filename); // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. CZMQ_EXPORT zconfig_t * zconfig_loadf (const char *format, ...) CHECK_PRINTF (1); // Destroy a config item and all its children CZMQ_EXPORT void zconfig_destroy (zconfig_t **self_p); // Return name of config item CZMQ_EXPORT char * zconfig_name (zconfig_t *self); // Return value of config item CZMQ_EXPORT char * zconfig_value (zconfig_t *self); // Insert or update configuration key with value CZMQ_EXPORT void zconfig_put (zconfig_t *self, const char *path, const char *value); // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. CZMQ_EXPORT void zconfig_putf (zconfig_t *self, const char *path, const char *format, ...) CHECK_PRINTF (3); // Get value for config item into a string value; leading slash is optional // and ignored. CZMQ_EXPORT char * zconfig_get (zconfig_t *self, const char *path, const char *default_value); // Set config item name, name may be NULL CZMQ_EXPORT void zconfig_set_name (zconfig_t *self, const char *name); // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. CZMQ_EXPORT void zconfig_set_value (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2); // Find our first child, if any CZMQ_EXPORT zconfig_t * zconfig_child (zconfig_t *self); // Find our first sibling, if any CZMQ_EXPORT zconfig_t * zconfig_next (zconfig_t *self); // Find a config item along a path; leading slash is optional and ignored. CZMQ_EXPORT zconfig_t * zconfig_locate (zconfig_t *self, const char *path); // Locate the last config item at a specified depth CZMQ_EXPORT zconfig_t * zconfig_at_depth (zconfig_t *self, int level); // Execute a callback for each config item in the tree; returns zero if // successful, else -1. CZMQ_EXPORT int zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg); // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. CZMQ_EXPORT void zconfig_set_comment (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2); // Return comments of config item, as zlist. CZMQ_EXPORT zlist_t * zconfig_comments (zconfig_t *self); // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. CZMQ_EXPORT int zconfig_save (zconfig_t *self, const char *filename); // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. CZMQ_EXPORT int zconfig_savef (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2); // Report filename used during zconfig_load, or NULL if none CZMQ_EXPORT const char * zconfig_filename (zconfig_t *self); // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). CZMQ_EXPORT int zconfig_reload (zconfig_t **self_p); // Load a config tree from a memory chunk CZMQ_EXPORT zconfig_t * zconfig_chunk_load (zchunk_t *chunk); // Save a config tree to a new memory chunk CZMQ_EXPORT zchunk_t * zconfig_chunk_save (zconfig_t *self); // Load a config tree from a null-terminated string // Caller owns return value and must destroy it when done. CZMQ_EXPORT zconfig_t * zconfig_str_load (const char *string); // Save a config tree to a new null terminated string // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zconfig_str_save (zconfig_t *self); // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. CZMQ_EXPORT bool zconfig_has_changed (zconfig_t *self); // Print the config file to open stream CZMQ_EXPORT void zconfig_fprint (zconfig_t *self, FILE *file); // Print properties of object CZMQ_EXPORT void zconfig_print (zconfig_t *self); // Self test of this class CZMQ_EXPORT void zconfig_test (bool verbose); ``` Please add '@interface' section in './../src/zconfig.c'. This is the class self test code: ```c // Create temporary directory for test files # define TESTDIR ".test_zconfig" zsys_dir_create (TESTDIR); zconfig_t *root = zconfig_new ("root", NULL); assert (root); zconfig_t *section, *item; section = zconfig_new ("headers", root); assert (section); item = zconfig_new ("email", section); assert (item); zconfig_set_value (item, "some@random.com"); item = zconfig_new ("name", section); assert (item); zconfig_set_value (item, "Justin Kayce"); zconfig_putf (root, "/curve/secret-key", "%s", "Top Secret"); zconfig_set_comment (root, " CURVE certificate"); zconfig_set_comment (root, " -----------------"); assert (zconfig_comments (root)); zconfig_save (root, TESTDIR "/test.cfg"); zconfig_destroy (&root); root = zconfig_load (TESTDIR "/test.cfg"); if (verbose) zconfig_save (root, "-"); assert (streq (zconfig_filename (root), TESTDIR "/test.cfg")); char *email = zconfig_get (root, "/headers/email", NULL); assert (email); assert (streq (email, "some@random.com")); char *passwd = zconfig_get (root, "/curve/secret-key", NULL); assert (passwd); assert (streq (passwd, "Top Secret")); zconfig_savef (root, "%s/%s", TESTDIR, "test.cfg"); assert (!zconfig_has_changed (root)); int rc = zconfig_reload (&root); assert (rc == 0); assert (!zconfig_has_changed (root)); zconfig_destroy (&root); // Test chunk load/save root = zconfig_new ("root", NULL); assert (root); section = zconfig_new ("section", root); assert (section); item = zconfig_new ("value", section); assert (item); zconfig_set_value (item, "somevalue"); zconfig_t *search = zconfig_locate (root, "section/value"); assert (search == item); zchunk_t *chunk = zconfig_chunk_save (root); assert (strlen ((char *) zchunk_data (chunk)) == 32); char *string = zconfig_str_save (root); assert (string); assert (streq (string, (char *) zchunk_data (chunk))); free (string); assert (chunk); zconfig_destroy (&root); root = zconfig_chunk_load (chunk); assert (root); char *value = zconfig_get (root, "/section/value", NULL); assert (value); assert (streq (value, "somevalue")); // Test config can't be saved to a file in a path that doesn't // exist or isn't writable rc = zconfig_savef (root, "%s/path/that/doesnt/exist/%s", TESTDIR, "test.cfg"); assert (rc == -1); zconfig_destroy (&root); zchunk_destroy (&chunk); // Test str_load zconfig_t *config = zconfig_str_load ( "malamute\n" " endpoint = ipc://@/malamute\n" " producer = STREAM\n" " consumer\n" " STREAM2 = .*\n" " STREAM3 = HAM\n" "server\n" " verbose = true\n" ); assert (config); assert (streq (zconfig_get (config, "malamute/endpoint", NULL), "ipc://@/malamute")); assert (streq (zconfig_get (config, "malamute/producer", NULL), "STREAM")); assert (zconfig_locate (config, "malamute/consumer")); zconfig_t *c = zconfig_child (zconfig_locate (config, "malamute/consumer")); assert (c); assert (streq (zconfig_name (c), "STREAM2")); assert (streq (zconfig_value (c), ".*")); c = zconfig_next (c); assert (c); assert (streq (zconfig_name (c), "STREAM3")); assert (streq (zconfig_value (c), "HAM")); c = zconfig_next (c); assert (!c); assert (streq (zconfig_get (config, "server/verbose", NULL), "true")); zconfig_destroy (&config); // Delete all test files zdir_t *dir = zdir_new (TESTDIR, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zdigest - provides hashing functions (SHA-1 at present) The zdigest class generates a hash from zchunks of data. The current algorithm is SHA-1, chosen for speed. We are aiming to generate a unique digest for a file, and there are no security issues in this use case. The current code depends on OpenSSL, which might be replaced by hard coded SHA-1 implementation to reduce build dependencies. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. CZMQ_EXPORT zdigest_t * zdigest_new (void); // Destroy a digest object CZMQ_EXPORT void zdigest_destroy (zdigest_t **self_p); // Add buffer into digest calculation CZMQ_EXPORT void zdigest_update (zdigest_t *self, const byte *buffer, size_t length); // Return final digest hash data. If built without crypto support, // returns NULL. CZMQ_EXPORT const byte * zdigest_data (zdigest_t *self); // Return final digest hash size CZMQ_EXPORT size_t zdigest_size (zdigest_t *self); // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. CZMQ_EXPORT char * zdigest_string (zdigest_t *self); // Self test of this class. CZMQ_EXPORT void zdigest_test (bool verbose); ``` Please add '@interface' section in './../src/zdigest.c'. This is the class self test code: ```c byte *buffer = (byte *) zmalloc (1024); memset (buffer, 0xAA, 1024); zdigest_t *digest = zdigest_new (); assert (digest); zdigest_update (digest, buffer, 1024); const byte *data = zdigest_data (digest); assert (data [0] == 0xDE); assert (data [1] == 0xB2); assert (data [2] == 0x38); assert (data [3] == 0x07); assert (streq (zdigest_string (digest), "DEB23807D4FE025E900FE9A9C7D8410C3DDE9671")); zdigest_destroy (&digest); free (buffer); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zdir - work with file-system directories The zdir class gives access to the file system index. It will load a directory tree (a directory plus all child directories) into a zdir structure and then let you navigate that structure. It exists mainly to wrap non-portable OS functions to do this. Please add '@discuss' section in './../src/zdir.c'. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. CZMQ_EXPORT zdir_t * zdir_new (const char *path, const char *parent); // Destroy a directory tree and all children it contains. CZMQ_EXPORT void zdir_destroy (zdir_t **self_p); // Return directory path CZMQ_EXPORT const char * zdir_path (zdir_t *self); // Return last modification time for directory. CZMQ_EXPORT time_t zdir_modified (zdir_t *self); // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. CZMQ_EXPORT off_t zdir_cursize (zdir_t *self); // Return directory count CZMQ_EXPORT size_t zdir_count (zdir_t *self); // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlist_t * zdir_list (zdir_t *self); // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. CZMQ_EXPORT void zdir_remove (zdir_t *self, bool force); // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlist_t * zdir_diff (zdir_t *older, zdir_t *newer, const char *alias); // Return full contents of directory as a zdir_patch list. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlist_t * zdir_resync (zdir_t *self, const char *alias); // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zhash_t * zdir_cache (zdir_t *self); // Print contents of directory to open stream CZMQ_EXPORT void zdir_fprint (zdir_t *self, FILE *file, int indent); // Print contents of directory to stdout CZMQ_EXPORT void zdir_print (zdir_t *self, int indent); // Create a new zdir_watch actor instance: // // zactor_t *watch = zactor_new (zdir_watch, NULL); // // Destroy zdir_watch instance: // // zactor_destroy (&watch); // // Enable verbose logging of commands and activity: // // zstr_send (watch, "VERBOSE"); // // Subscribe to changes to a directory path: // // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); // // Unsubscribe from changes to a directory path: // // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); // // Receive directory changes: // zsock_recv (watch, "sp", &path, &patches); // // // Delete the received data. // free (path); // zlist_destroy (&patches); CZMQ_EXPORT void zdir_watch (zsock_t *pipe, void *unused); // Self test of this class. CZMQ_EXPORT void zdir_test (bool verbose); ``` Please add '@interface' section in './../src/zdir.c'. This is the class self test code: ```c // need to create a file in the test directory we're watching // in order to ensure the directory exists zfile_t *initfile = zfile_new ("./zdir-test-dir", "initial_file"); assert (initfile); zfile_output (initfile); fprintf (zfile_handle (initfile), "initial file\n"); zfile_close (initfile); zfile_destroy (&initfile); zdir_t *older = zdir_new ("zdir-test-dir", NULL); assert (older); if (verbose) { printf ("\n"); zdir_dump (older, 0); } zdir_t *newer = zdir_new (".", NULL); assert (newer); zlist_t *patches = zdir_diff (older, newer, "/"); assert (patches); while (zlist_size (patches)) { zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches); zdir_patch_destroy (&patch); } zlist_destroy (&patches); zdir_destroy (&older); zdir_destroy (&newer); zdir_t *nosuch = zdir_new ("does-not-exist", NULL); assert (nosuch == NULL); // zdir_watch test: zactor_t *watch = zactor_new (zdir_watch, NULL); assert (watch); int synced; if (verbose) { zsock_send (watch, "s", "VERBOSE"); synced = zsock_wait(watch); assert ( synced == 0); } zclock_sleep (1001); // wait for initial file to become 'stable' zsock_send (watch, "si", "TIMEOUT", 100); synced = zsock_wait(watch); assert (synced == 0); zsock_send (watch, "ss", "SUBSCRIBE", "zdir-test-dir"); synced = zsock_wait(watch); assert(synced == 0); zsock_send (watch, "ss", "UNSUBSCRIBE", "zdir-test-dir"); synced = zsock_wait(watch); assert(synced == 0); zsock_send (watch, "ss", "SUBSCRIBE", "zdir-test-dir"); synced = zsock_wait(watch); assert(synced == 0); zfile_t *newfile = zfile_new ("zdir-test-dir", "test_abc"); zfile_output (newfile); fprintf (zfile_handle (newfile), "test file\n"); zfile_close (newfile); zpoller_t *watch_poll = zpoller_new (watch, NULL); // poll for a certain timeout before giving up and failing the test. void* polled = zpoller_wait(watch_poll, 1001); assert (polled == watch); // wait for notification of the file being added char *path; int rc = zsock_recv (watch, "sp", &path, &patches); assert (rc == 0); assert (streq (path, "zdir-test-dir")); free (path); assert (zlist_size (patches) == 1); zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches); assert (streq (zdir_patch_path (patch), "zdir-test-dir")); zfile_t *patch_file = zdir_patch_file (patch); assert (streq (zfile_filename (patch_file, ""), "zdir-test-dir/test_abc")); zdir_patch_destroy (&patch); zlist_destroy (&patches); // remove the file zfile_remove (newfile); zfile_destroy (&newfile); // poll for a certain timeout before giving up and failing the test. polled = zpoller_wait(watch_poll, 1001); assert (polled == watch); // wait for notification of the file being removed rc = zsock_recv (watch, "sp", &path, &patches); assert (rc == 0); assert (streq (path, "zdir-test-dir")); free (path); assert (zlist_size (patches) == 1); patch = (zdir_patch_t *) zlist_pop (patches); assert (streq (zdir_patch_path (patch), "zdir-test-dir")); patch_file = zdir_patch_file (patch); assert (streq (zfile_filename (patch_file, ""), "zdir-test-dir/test_abc")); zdir_patch_destroy (&patch); zlist_destroy (&patches); zpoller_destroy (&watch_poll); zactor_destroy (&watch); // clean up by removing the test directory. zdir_t *testdir = zdir_new ("zdir-test-dir", NULL); zdir_remove (testdir, true); zdir_destroy (&testdir); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zdir_patch - work with directory patches The zdir_patch class works with one patch, which says "create this file" or "delete this file" (referring to a zfile item each time). Please add '@discuss' section in './../src/zdir_patch.c'. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. #define ZDIR_PATCH_CREATE 1 // Creates a new file #define ZDIR_PATCH_DELETE 2 // Delete a file // Create new patch CZMQ_EXPORT zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, int op, const char *alias); // Destroy a patch CZMQ_EXPORT void zdir_patch_destroy (zdir_patch_t **self_p); // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zdir_patch_t * zdir_patch_dup (zdir_patch_t *self); // Return patch file directory path CZMQ_EXPORT const char * zdir_patch_path (zdir_patch_t *self); // Return patch file item CZMQ_EXPORT zfile_t * zdir_patch_file (zdir_patch_t *self); // Return operation CZMQ_EXPORT int zdir_patch_op (zdir_patch_t *self); // Return patch virtual file path CZMQ_EXPORT const char * zdir_patch_vpath (zdir_patch_t *self); // Calculate hash digest for file (create only) CZMQ_EXPORT void zdir_patch_digest_set (zdir_patch_t *self); // Return hash digest for patch file CZMQ_EXPORT const char * zdir_patch_digest (zdir_patch_t *self); // Self test of this class. CZMQ_EXPORT void zdir_patch_test (bool verbose); ``` Please add '@interface' section in './../src/zdir_patch.c'. This is the class self test code: ```c zfile_t *file = zfile_new (".", "bilbo"); assert (file); zdir_patch_t *patch = zdir_patch_new (".", file, patch_create, "/"); assert (patch); zfile_destroy (&file); file = zdir_patch_file (patch); assert (file); assert (streq (zfile_filename (file, "."), "bilbo")); assert (streq (zdir_patch_vpath (patch), "/bilbo")); zdir_patch_destroy (&patch); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zfile - provides methods to work with files in a portable fashion. The zfile class provides methods to work with disk files. A file object provides the modified date, current size, and type of the file. You can create a file object for a filename that does not yet exist. To read or write data from the file, use the input and output methods, and then read and write chunks. The output method lets you both read and write chunks, at any offset. Finally, this class provides portable symbolic links. If a filename ends in ".ln", the first line of text in the file is read, and used as the underlying file for read/write operations. This lets you manipulate (e.g.) copy symbolic links without copying the perhaps very large files they point to. This class is a new API, deprecating the old zfile class (which still exists but is implemented in zsys now). This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. CZMQ_EXPORT zfile_t * zfile_new (const char *path, const char *name); // Destroy a file item CZMQ_EXPORT void zfile_destroy (zfile_t **self_p); // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zfile_t * zfile_dup (zfile_t *self); // Return file name, remove path if provided CZMQ_EXPORT const char * zfile_filename (zfile_t *self, const char *path); // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. CZMQ_EXPORT void zfile_restat (zfile_t *self); // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. CZMQ_EXPORT time_t zfile_modified (zfile_t *self); // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. CZMQ_EXPORT off_t zfile_cursize (zfile_t *self); // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. CZMQ_EXPORT bool zfile_is_directory (zfile_t *self); // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. CZMQ_EXPORT bool zfile_is_regular (zfile_t *self); // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. CZMQ_EXPORT bool zfile_is_readable (zfile_t *self); // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. CZMQ_EXPORT bool zfile_is_writeable (zfile_t *self); // Check if file has stopped changing and can be safely processed. // Updates the file statistics from disk at every call. CZMQ_EXPORT bool zfile_is_stable (zfile_t *self); // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. CZMQ_EXPORT bool zfile_has_changed (zfile_t *self); // Remove the file from disk CZMQ_EXPORT void zfile_remove (zfile_t *self); // Open file for reading // Returns 0 if OK, -1 if not found or not accessible CZMQ_EXPORT int zfile_input (zfile_t *self); // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. CZMQ_EXPORT int zfile_output (zfile_t *self); // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zchunk_t * zfile_read (zfile_t *self, size_t bytes, off_t offset); // Returns true if zfile_read() just read the last chunk in the file. CZMQ_EXPORT bool zfile_eof (zfile_t *self); // Write chunk to file at specified position // Return 0 if OK, else -1 CZMQ_EXPORT int zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset); // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. CZMQ_EXPORT const char * zfile_readln (zfile_t *self); // Close file, if open CZMQ_EXPORT void zfile_close (zfile_t *self); // Return file handle, if opened CZMQ_EXPORT FILE * zfile_handle (zfile_t *self); // Calculate SHA1 digest for file, using zdigest class. CZMQ_EXPORT const char * zfile_digest (zfile_t *self); // Self test of this class. CZMQ_EXPORT void zfile_test (bool verbose); // These methods are deprecated, and now moved to zsys class. CZMQ_EXPORT bool zfile_exists (const char *filename); CZMQ_EXPORT ssize_t zfile_size (const char *filename); CZMQ_EXPORT mode_t zfile_mode (const char *filename); CZMQ_EXPORT int zfile_delete (const char *filename); CZMQ_EXPORT bool zfile_stable (const char *filename); CZMQ_EXPORT int zfile_mkdir (const char *pathname); CZMQ_EXPORT int zfile_rmdir (const char *pathname); CZMQ_EXPORT void zfile_mode_private (void); CZMQ_EXPORT void zfile_mode_default (void); ``` Please add '@interface' section in './../src/zfile.c'. This is the class self test code: ```c zfile_t *file = zfile_new (NULL, "bilbo"); assert (file); assert (streq (zfile_filename (file, "."), "bilbo")); assert (zfile_is_readable (file) == false); zfile_destroy (&file); // Create a test file in some random subdirectory file = zfile_new ("./this/is/a/test", "bilbo"); assert (file); int rc = zfile_output (file); assert (rc == 0); zchunk_t *chunk = zchunk_new (NULL, 100); assert (chunk); zchunk_fill (chunk, 0, 100); // Write 100 bytes at position 1,000,000 in the file rc = zfile_write (file, chunk, 1000000); assert (rc == 0); zchunk_destroy (&chunk); zfile_close (file); assert (zfile_is_readable (file)); assert (zfile_cursize (file) == 1000100); assert (!zfile_is_stable (file)); assert (zfile_digest (file)); // Now truncate file from outside int handle = open ("./this/is/a/test/bilbo", O_WRONLY | O_TRUNC | O_BINARY, 0); assert (handle >= 0); rc = write (handle, "Hello, World\n", 13); assert (rc == 13); close (handle); assert (zfile_has_changed (file)); zclock_sleep (1001); assert (zfile_has_changed (file)); assert (!zfile_is_stable (file)); zfile_restat (file); assert (zfile_is_stable (file)); assert (streq (zfile_digest (file), "4AB299C8AD6ED14F31923DD94F8B5F5CB89DFB54")); // Check we can read from file rc = zfile_input (file); assert (rc == 0); chunk = zfile_read (file, 1000100, 0); assert (chunk); assert (zchunk_size (chunk) == 13); zchunk_destroy (&chunk); zfile_close (file); // Check we can read lines from file rc = zfile_input (file); assert (rc == 0); const char *line = zfile_readln (file); assert (streq (line, "Hello, World")); line = zfile_readln (file); assert (line == NULL); zfile_close (file); // Try some fun with symbolic links zfile_t *link = zfile_new ("./this/is/a/test", "bilbo.ln"); assert (link); rc = zfile_output (link); assert (rc == 0); fprintf (zfile_handle (link), "./this/is/a/test/bilbo\n"); zfile_destroy (&link); link = zfile_new ("./this/is/a/test", "bilbo.ln"); assert (link); rc = zfile_input (link); assert (rc == 0); chunk = zfile_read (link, 1000100, 0); assert (chunk); assert (zchunk_size (chunk) == 13); zchunk_destroy (&chunk); zfile_destroy (&link); // Remove file and directory zdir_t *dir = zdir_new ("./this", NULL); assert (dir); assert (zdir_cursize (dir) == 26); zdir_remove (dir, true); assert (zdir_cursize (dir) == 0); zdir_destroy (&dir); // Check we can no longer read from file assert (zfile_is_readable (file)); zfile_restat (file); assert (!zfile_is_readable (file)); rc = zfile_input (file); assert (rc == -1); zfile_destroy (&file); file = zfile_new ("./", "eof_checkfile"); assert (file); // 1. Write something first rc = zfile_output (file); assert (rc == 0); chunk = zchunk_new ("123456789", 9); assert (chunk); rc = zfile_write (file, chunk, 0); assert (rc == 0); zchunk_destroy (&chunk); zfile_close (file); assert (zfile_cursize (file) == 9); // 2. Read the written something rc = zfile_input (file); assert (rc != -1); // try to read more bytes than there is in the file chunk = zfile_read (file, 1000, 0); assert (zfile_eof(file)); assert (zchunk_streq (chunk, "123456789")); zchunk_destroy (&chunk); // reading is ok chunk = zfile_read (file, 5, 0); assert (!zfile_eof(file)); assert (zchunk_streq (chunk, "12345")); zchunk_destroy (&chunk); // read from non zero offset until the end chunk = zfile_read (file, 5, 5); assert (zfile_eof(file)); assert (zchunk_streq (chunk, "6789")); zchunk_destroy (&chunk); zfile_remove (file); zfile_close (file); zfile_destroy (&file); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zframe - working with single message frames The zframe class provides methods to send and receive single message frames across ØMQ sockets. A 'frame' corresponds to one zmq_msg_t. When you read a frame from a socket, the zframe_more() method indicates if the frame is part of an unfinished multipart message. The zframe_send method normally destroys the frame, but with the ZFRAME_REUSE flag, you can send the same frame many times. Frames are binary, and this class has no special support for text data. Please add '@discuss' section in './../src/zframe.c'. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. #define ZFRAME_MORE 1 // #define ZFRAME_REUSE 2 // #define ZFRAME_DONTWAIT 4 // // Create a new frame. If size is not null, allocates the frame data // to the specified size. If additionally, data is not null, copies // size octets from the specified data into the frame body. CZMQ_EXPORT zframe_t * zframe_new (const void *data, size_t size); // Create an empty (zero-sized) frame CZMQ_EXPORT zframe_t * zframe_new_empty (void); // Create a frame with a specified string content. CZMQ_EXPORT zframe_t * zframe_from (const char *string); // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. CZMQ_EXPORT zframe_t * zframe_recv (void *source); // Destroy a frame CZMQ_EXPORT void zframe_destroy (zframe_t **self_p); // Send a frame to a socket, destroy frame after sending. // Return -1 on error, 0 on success. CZMQ_EXPORT int zframe_send (zframe_t **self_p, void *dest, int flags); // Return number of bytes in frame data CZMQ_EXPORT size_t zframe_size (zframe_t *self); // Return address of frame data CZMQ_EXPORT byte * zframe_data (zframe_t *self); // Return meta data property for frame // The caller shall not modify or free the returned value, which shall be // owned by the message. CZMQ_EXPORT const char * zframe_meta (zframe_t *self, const char *property); // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zframe_dup (zframe_t *self); // Return frame data encoded as printable hex string, useful for ØMQ UUIDs. // Caller must free string when finished with it. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zframe_strhex (zframe_t *self); // Return frame data copied into freshly allocated string // Caller must free string when finished with it. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zframe_strdup (zframe_t *self); // Return TRUE if frame body is equal to string, excluding terminator CZMQ_EXPORT bool zframe_streq (zframe_t *self, const char *string); // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method CZMQ_EXPORT int zframe_more (zframe_t *self); // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. CZMQ_EXPORT void zframe_set_more (zframe_t *self, int more); // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false. CZMQ_EXPORT bool zframe_eq (zframe_t *self, zframe_t *other); // Set new contents for frame CZMQ_EXPORT void zframe_reset (zframe_t *self, const void *data, size_t size); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. CZMQ_EXPORT void zframe_print (zframe_t *self, const char *prefix); // Probe the supplied object, and report if it looks like a zframe_t. CZMQ_EXPORT bool zframe_is (void *self); // Self test of this class. CZMQ_EXPORT void zframe_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Return frame routing ID, if the frame came from a ZMQ_SERVER socket. // Else returns zero. CZMQ_EXPORT uint32_t zframe_routing_id (zframe_t *self); // *** Draft method, for development use, may change without warning *** // Set routing ID on frame. This is used if/when the frame is sent to a // ZMQ_SERVER socket. CZMQ_EXPORT void zframe_set_routing_id (zframe_t *self, uint32_t routing_id); // *** Draft method, for development use, may change without warning *** // Return frame group of radio-dish pattern. CZMQ_EXPORT const char * zframe_group (zframe_t *self); // *** Draft method, for development use, may change without warning *** // Set group on frame. This is used if/when the frame is sent to a // ZMQ_RADIO socket. // Return -1 on error, 0 on success. CZMQ_EXPORT int zframe_set_group (zframe_t *self, const char *group); #endif // CZMQ_BUILD_DRAFT_API ``` Please add '@interface' section in './../src/zframe.c'. This is the class self test code: ```c // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@tcp://127.0.0.1:9001"); assert (output); zsock_t *input = zsock_new_pair (">tcp://127.0.0.1:9001"); assert (input); // Send five different frames, test ZFRAME_MORE int frame_nbr; for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) { frame = zframe_new ("Hello", 5); assert (frame); rc = zframe_send (&frame, output, ZFRAME_MORE); assert (rc == 0); } // Send same frame five times, test ZFRAME_REUSE frame = zframe_new ("Hello", 5); assert (frame); for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) { rc = zframe_send (&frame, output, ZFRAME_MORE + ZFRAME_REUSE); assert (rc == 0); } assert (frame); zframe_t *copy = zframe_dup (frame); assert (zframe_eq (frame, copy)); zframe_destroy (&frame); assert (!zframe_eq (frame, copy)); assert (zframe_size (copy) == 5); zframe_destroy (©); assert (!zframe_eq (frame, copy)); // Test zframe_new_empty frame = zframe_new_empty (); assert (frame); assert (zframe_size (frame) == 0); zframe_destroy (&frame); // Send END frame frame = zframe_new ("NOT", 3); assert (frame); zframe_reset (frame, "END", 3); char *string = zframe_strhex (frame); assert (streq (string, "454E44")); free (string); string = zframe_strdup (frame); assert (streq (string, "END")); free (string); rc = zframe_send (&frame, output, 0); assert (rc == 0); // Read and count until we receive END frame_nbr = 0; for (frame_nbr = 0;; frame_nbr++) { zframe_t *frame = zframe_recv (input); if (zframe_streq (frame, "END")) { zframe_destroy (&frame); break; } assert (zframe_more (frame)); zframe_set_more (frame, 0); assert (zframe_more (frame) == 0); zframe_destroy (&frame); } assert (frame_nbr == 10); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (4, 1, 0)) // Test zframe_meta frame = zframe_new ("Hello", 5); assert (frame); rc = zframe_send (&frame, output, 0); assert (rc == 0); frame = zframe_recv (input); const char *meta = zframe_meta (frame, "Socket-Type"); assert (meta != NULL); assert (streq (meta, "PAIR")); assert (zframe_meta (frame, "nonexistent") == NULL); zframe_destroy (&frame); #endif zsock_destroy (&input); zsock_destroy (&output); #if defined (ZMQ_SERVER) // Create server and client sockets and connect over inproc zsock_t *server = zsock_new_server ("inproc://zframe-test-routing"); assert (server); zsock_t *client = zsock_new_client ("inproc://zframe-test-routing"); assert (client); // Send request from client to server zframe_t *request = zframe_new ("Hello", 5); assert (request); rc = zframe_send (&request, client, 0); assert (rc == 0); assert (!request); // Read request and send reply request = zframe_recv (server); assert (request); assert (zframe_streq (request, "Hello")); assert (zframe_routing_id (request)); zframe_t *reply = zframe_new ("World", 5); assert (reply); zframe_set_routing_id (reply, zframe_routing_id (request)); rc = zframe_send (&reply, server, 0); assert (rc == 0); zframe_destroy (&request); // Read reply reply = zframe_recv (client); assert (zframe_streq (reply, "World")); assert (zframe_routing_id (reply) == 0); zframe_destroy (&reply); // Client and server disallow multipart frame = zframe_new ("Hello", 5); rc = zframe_send (&frame, client, ZFRAME_MORE); assert (rc == -1); rc = zframe_send (&frame, server, ZFRAME_MORE); assert (rc == -1); zframe_destroy (&frame); zsock_destroy (&client); zsock_destroy (&server); #endif #ifdef ZMQ_RADIO // Create radio and dish sockets and connect over inproc zsock_t *radio = zsock_new_radio ("inproc://zframe-test-radio"); assert (radio); zsock_t *dish = zsock_new_dish ("inproc://zframe-test-radio"); assert (dish); // Join the group rc = zsock_join (dish, "World"); assert (rc == 0); // Publish message from radio zframe_t *message = zframe_new ("Hello", 5); assert (message); rc = zframe_set_group (message, "World"); assert (rc == 0); rc = zframe_send (&message, radio, 0); assert (rc == 0); assert (!message); // Receive the message from dish message = zframe_recv (dish); assert (message); assert (zframe_streq (message, "Hello")); assert (strcmp("World", zframe_group (message)) == 0); zframe_destroy (&message); zsock_destroy (&dish); zsock_destroy (&radio); #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zgossip - decentralized configuration management Implements a gossip protocol for decentralized configuration management. Your applications nodes form a loosely connected network (which can have cycles), and publish name/value tuples. Each node re-distributes the new tuples it receives, so that the entire network eventually achieves a consistent state. The current design does not expire tuples. Provides these commands (sent as multipart strings to the actor): * BIND endpoint -- binds the gossip service to specified endpoint * PORT -- returns the last TCP port, if any, used for binding * LOAD configfile -- load configuration from specified file * SET configpath value -- set configuration path = value * SAVE configfile -- save configuration to specified file * CONNECT endpoint -- connect the gossip service to the specified peer * PUBLISH key value -- publish a key/value pair to the gossip cluster * STATUS -- return number of key/value pairs held by gossip service Returns these messages: * PORT number -- reply to PORT command * STATUS number -- reply to STATUS command * DELIVER key value -- new tuple delivered from network The gossip protocol distributes information around a loosely-connected network of gossip services. The information consists of name/value pairs published by applications at any point in the network. The goal of the gossip protocol is to create eventual consistency between all the using applications. The name/value pairs (tuples) can be used for configuration data, for status updates, for presence, or for discovery. When used for discovery, the gossip protocol works as an alternative to e.g. UDP beaconing. The gossip network consists of a set of loosely-coupled nodes that exchange tuples. Nodes can be connected across arbitrary transports, so the gossip network can have nodes that communicate over inproc, over IPC, and/or over TCP, at the same time. Each node runs the same stack, which is a server-client hybrid using a modified Harmony pattern (from Chapter 8 of the Guide): http://zguide.zeromq.org/page:all#True-Peer-Connectivity-Harmony-Pattern Each node provides a ROUTER socket that accepts client connections on an key defined by the application via a BIND command. The state machine for these connections is in zgossip.xml, and the generated code is in zgossip_engine.inc. Each node additionally creates outbound connections via DEALER sockets to a set of servers ("remotes"), and under control of the calling app, which sends CONNECT commands for each configured remote. The messages between client and server are defined in zgossip_msg.xml. We built this stack using the zeromq/zproto toolkit. To join the gossip network, a node connects to one or more peers. Each peer acts as a forwarder. This loosely-coupled network can scale to thousands of nodes. However the gossip protocol is NOT designed to be efficient, and should not be used for application data, as the same tuples may be sent many times across the network. The basic logic of the gossip service is to accept PUBLISH messages from its owning application, and to forward these to every remote, and every client it talks to. When a node gets a duplicate tuple, it throws it away. When a node gets a new tuple, it stores it, and forwards it as just described. At present there is no way to expire tuples from the network. The assumptions in this design are: * The data set is slow-changing. Thus, the cost of the gossip protocol is irrelevant with respect to other traffic. This is the class interface: ```h // To work with zgossip, use the CZMQ zactor API: // // Create new zgossip instance, passing logging prefix: // // zactor_t *zgossip = zactor_new (zgossip, "myname"); // // Destroy zgossip instance // // zactor_destroy (&zgossip); // // Enable verbose logging of commands and activity: // // zstr_send (zgossip, "VERBOSE"); // // Bind zgossip to specified endpoint. TCP endpoints may specify // the port number as "*" to aquire an ephemeral port: // // zstr_sendx (zgossip, "BIND", endpoint, NULL); // // Return assigned port number, specifically when BIND was done using an // an ephemeral port: // // zstr_sendx (zgossip, "PORT", NULL); // char *command, *port_str; // zstr_recvx (zgossip, &command, &port_str, NULL); // assert (streq (command, "PORT")); // // Specify configuration file to load, overwriting any previous loaded // configuration file or options: // // zstr_sendx (zgossip, "LOAD", filename, NULL); // // Set configuration path value: // // zstr_sendx (zgossip, "SET", path, value, NULL); // // Save configuration data to config file on disk: // // zstr_sendx (zgossip, "SAVE", filename, NULL); // // Send zmsg_t instance to zgossip: // // zactor_send (zgossip, &msg); // // Receive zmsg_t instance from zgossip: // // zmsg_t *msg = zactor_recv (zgossip); // // This is the zgossip constructor as a zactor_fn: // CZMQ_EXPORT void zgossip (zsock_t *pipe, void *args); // Self test of this class CZMQ_EXPORT void zgossip_test (bool verbose); ``` Please add '@interface' section in './../src/zgossip.c'. This is the class self test code: ```c // Test basic client-to-server operation of the protocol zactor_t *server = zactor_new (zgossip, "server"); assert (server); if (verbose) zstr_send (server, "VERBOSE"); zstr_sendx (server, "BIND", "inproc://zgossip", NULL); zsock_t *client = zsock_new (ZMQ_DEALER); assert (client); zsock_set_rcvtimeo (client, 2000); int rc = zsock_connect (client, "inproc://zgossip"); assert (rc == 0); // Send HELLO, which gets no message zgossip_msg_t *message = zgossip_msg_new (); zgossip_msg_set_id (message, ZGOSSIP_MSG_HELLO); zgossip_msg_send (message, client); // Send PING, expect PONG back zgossip_msg_set_id (message, ZGOSSIP_MSG_PING); zgossip_msg_send (message, client); zgossip_msg_recv (message, client); assert (zgossip_msg_id (message) == ZGOSSIP_MSG_PONG); zgossip_msg_destroy (&message); zactor_destroy (&server); zsock_destroy (&client); // Test peer-to-peer operations zactor_t *base = zactor_new (zgossip, "base"); assert (base); if (verbose) zstr_send (base, "VERBOSE"); // Set a 100msec timeout on clients so we can test expiry zstr_sendx (base, "SET", "server/timeout", "100", NULL); zstr_sendx (base, "BIND", "inproc://base", NULL); zactor_t *alpha = zactor_new (zgossip, "alpha"); assert (alpha); zstr_sendx (alpha, "CONNECT", "inproc://base", NULL); zstr_sendx (alpha, "PUBLISH", "inproc://alpha-1", "service1", NULL); zstr_sendx (alpha, "PUBLISH", "inproc://alpha-2", "service2", NULL); zactor_t *beta = zactor_new (zgossip, "beta"); assert (beta); zstr_sendx (beta, "CONNECT", "inproc://base", NULL); zstr_sendx (beta, "PUBLISH", "inproc://beta-1", "service1", NULL); zstr_sendx (beta, "PUBLISH", "inproc://beta-2", "service2", NULL); // got nothing zclock_sleep (200); zstr_send (alpha, "STATUS"); char *command, *status, *key, *value; zstr_recvx (alpha, &command, &key, &value, NULL); assert (streq (command, "DELIVER")); assert (streq (key, "inproc://alpha-1")); assert (streq (value, "service1")); zstr_free (&command); zstr_free (&key); zstr_free (&value); zstr_recvx (alpha, &command, &key, &value, NULL); assert (streq (command, "DELIVER")); assert (streq (key, "inproc://alpha-2")); assert (streq (value, "service2")); zstr_free (&command); zstr_free (&key); zstr_free (&value); zstr_recvx (alpha, &command, &key, &value, NULL); assert (streq (command, "DELIVER")); assert (streq (key, "inproc://beta-1")); assert (streq (value, "service1")); zstr_free (&command); zstr_free (&key); zstr_free (&value); zstr_recvx (alpha, &command, &key, &value, NULL); assert (streq (command, "DELIVER")); assert (streq (key, "inproc://beta-2")); assert (streq (value, "service2")); zstr_free (&command); zstr_free (&key); zstr_free (&value); zstr_recvx (alpha, &command, &status, NULL); assert (streq (command, "STATUS")); assert (atoi (status) == 4); zstr_free (&command); zstr_free (&status); zactor_destroy (&base); zactor_destroy (&alpha); zactor_destroy (&beta); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zhash - simple generic hash container zhash is an expandable hash table container. This is a simple container. For heavy-duty applications we recommend using zhashx. Note that it's relatively slow (~50K insertions/deletes per second), so don't do inserts/updates on the critical path for message I/O. It can do ~2.5M lookups per second for 16-char keys. Timed on a 1.6GHz CPU. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Callback function for zhash_freefn method typedef void (zhash_free_fn) ( void *data); // Create a new, empty hash container CZMQ_EXPORT zhash_t * zhash_new (void); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. CZMQ_EXPORT zhash_t * zhash_unpack (zframe_t *frame); // Destroy a hash container and all items in it CZMQ_EXPORT void zhash_destroy (zhash_t **self_p); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. CZMQ_EXPORT int zhash_insert (zhash_t *self, const char *key, void *item); // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. CZMQ_EXPORT void zhash_update (zhash_t *self, const char *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. CZMQ_EXPORT void zhash_delete (zhash_t *self, const char *key); // Return the item at the specified key, or null CZMQ_EXPORT void * zhash_lookup (zhash_t *self, const char *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. CZMQ_EXPORT int zhash_rename (zhash_t *self, const char *old_key, const char *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn); // Return the number of keys/items in the hash table CZMQ_EXPORT size_t zhash_size (zhash_t *self); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zhash_t * zhash_dup (zhash_t *self); // Return keys for items in table // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlist_t * zhash_keys (zhash_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhash_cursor(). NOTE: do NOT modify the table while iterating. CZMQ_EXPORT void * zhash_first (zhash_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). To // access the key for this item use zhash_cursor(). NOTE: do NOT modify // the table while iterating. CZMQ_EXPORT void * zhash_next (zhash_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. CZMQ_EXPORT const char * zhash_cursor (zhash_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. CZMQ_EXPORT void zhash_comment (zhash_t *self, const char *format, ...) CHECK_PRINTF (2); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zhash_pack (zhash_t *self); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. CZMQ_EXPORT int zhash_save (zhash_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. CZMQ_EXPORT int zhash_load (zhash_t *self, const char *filename); // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. CZMQ_EXPORT int zhash_refresh (zhash_t *self); // Set hash for automatic value destruction. Note that this assumes that // values are NULL-terminated strings. Do not use with different types. CZMQ_EXPORT void zhash_autofree (zhash_t *self); // Self test of this class. CZMQ_EXPORT void zhash_test (bool verbose); ``` Please add '@interface' section in './../src/zhash.c'. This is the class self test code: ```c zhash_t *hash = zhash_new (); assert (hash); assert (zhash_size (hash) == 0); assert (zhash_first (hash) == NULL); assert (zhash_cursor (hash) == NULL); // Insert some items int rc; rc = zhash_insert (hash, "DEADBEEF", "dead beef"); char *item = (char *) zhash_first (hash); assert (streq (zhash_cursor (hash), "DEADBEEF")); assert (streq (item, "dead beef")); assert (rc == 0); rc = zhash_insert (hash, "ABADCAFE", "a bad cafe"); assert (rc == 0); rc = zhash_insert (hash, "C0DEDBAD", "coded bad"); assert (rc == 0); rc = zhash_insert (hash, "DEADF00D", "dead food"); assert (rc == 0); assert (zhash_size (hash) == 4); // Look for existing items item = (char *) zhash_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); item = (char *) zhash_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); item = (char *) zhash_lookup (hash, "C0DEDBAD"); assert (streq (item, "coded bad")); item = (char *) zhash_lookup (hash, "DEADF00D"); assert (streq (item, "dead food")); // Look for non-existent items item = (char *) zhash_lookup (hash, "foo"); assert (item == NULL); // Try to insert duplicate items rc = zhash_insert (hash, "DEADBEEF", "foo"); assert (rc == -1); item = (char *) zhash_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); // Some rename tests // Valid rename, key is now LIVEBEEF rc = zhash_rename (hash, "DEADBEEF", "LIVEBEEF"); assert (rc == 0); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an unknown item to a non-existent key rc = zhash_rename (hash, "WHATBEEF", "NONESUCH"); assert (rc == -1); // Trying to rename an unknown item to an existing key rc = zhash_rename (hash, "WHATBEEF", "LIVEBEEF"); assert (rc == -1); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an existing item to another existing item rc = zhash_rename (hash, "LIVEBEEF", "ABADCAFE"); assert (rc == -1); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); item = (char *) zhash_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); // Test keys method zlist_t *keys = zhash_keys (hash); assert (zlist_size (keys) == 4); zlist_destroy (&keys); // Test dup method zhash_t *copy = zhash_dup (hash); assert (zhash_size (copy) == 4); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); // Test pack/unpack methods zframe_t *frame = zhash_pack (hash); copy = zhash_unpack (frame); zframe_destroy (&frame); assert (zhash_size (copy) == 4); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); // Test save and load zhash_comment (hash, "This is a test file"); zhash_comment (hash, "Created by %s", "czmq_selftest"); zhash_save (hash, ".cache"); copy = zhash_new (); assert (copy); zhash_load (copy, ".cache"); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); zsys_file_delete (".cache"); // Delete a item zhash_delete (hash, "LIVEBEEF"); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (item == NULL); assert (zhash_size (hash) == 3); // Check that the queue is robust against random usage struct { char name [100]; bool exists; } testset [200]; memset (testset, 0, sizeof (testset)); int testmax = 200, testnbr, iteration; srandom ((unsigned) time (NULL)); for (iteration = 0; iteration < 25000; iteration++) { testnbr = randof (testmax); assert (testnbr != testmax); assert (testnbr < testmax); if (testset [testnbr].exists) { item = (char *) zhash_lookup (hash, testset [testnbr].name); assert (item); zhash_delete (hash, testset [testnbr].name); testset [testnbr].exists = false; } else { sprintf (testset [testnbr].name, "%x-%x", rand (), rand ()); if (zhash_insert (hash, testset [testnbr].name, "") == 0) testset [testnbr].exists = true; } } // Test 10K lookups for (iteration = 0; iteration < 10000; iteration++) item = (char *) zhash_lookup (hash, "DEADBEEFABADCAFE"); // Destructor should be safe to call twice zhash_destroy (&hash); zhash_destroy (&hash); assert (hash == NULL); // Test autofree; automatically copies and frees string values hash = zhash_new (); assert (hash); zhash_autofree (hash); char value [255]; strcpy (value, "This is a string"); rc = zhash_insert (hash, "key1", value); assert (rc == 0); strcpy (value, "Inserting with the same key will fail"); rc = zhash_insert (hash, "key1", value); assert (rc == -1); strcpy (value, "Ring a ding ding"); rc = zhash_insert (hash, "key2", value); assert (rc == 0); assert (streq ((char *) zhash_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhash_lookup (hash, "key2"), "Ring a ding ding")); zhash_destroy (&hash); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zhashx - extended generic hash container zhashx is an extended hash table container with more functionality than zhash, its simpler cousin. The hash table always has a size that is prime and roughly doubles its size when 75% full. In case of hash collisions items are chained in a linked list. The hash table size is increased slightly (up to 5 times before roughly doubling the size) when an overly long chain (between 1 and 63 items depending on table size) is detected. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Destroy an item typedef void (zhashx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zhashx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zhashx_comparator_fn) ( const void *item1, const void *item2); // Destroy an item. typedef void (zhashx_free_fn) ( void *data); // Hash function for keys. typedef size_t (zhashx_hash_fn) ( const void *key); // Serializes an item to a longstr. // The caller takes ownership of the newly created object. typedef char * (zhashx_serializer_fn) ( const void *item); // Deserializes a longstr into an item. // The caller takes ownership of the newly created object. typedef void * (zhashx_deserializer_fn) ( const char *item_str); // Create a new, empty hash container CZMQ_EXPORT zhashx_t * zhashx_new (void); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. CZMQ_EXPORT zhashx_t * zhashx_unpack (zframe_t *frame); // Destroy a hash container and all items in it CZMQ_EXPORT void zhashx_destroy (zhashx_t **self_p); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. CZMQ_EXPORT int zhashx_insert (zhashx_t *self, const void *key, void *item); // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. CZMQ_EXPORT void zhashx_update (zhashx_t *self, const void *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. CZMQ_EXPORT void zhashx_delete (zhashx_t *self, const void *key); // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. CZMQ_EXPORT void zhashx_purge (zhashx_t *self); // Return the item at the specified key, or null CZMQ_EXPORT void * zhashx_lookup (zhashx_t *self, const void *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. CZMQ_EXPORT int zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn free_fn); // Return the number of keys/items in the hash table CZMQ_EXPORT size_t zhashx_size (zhashx_t *self); // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlistx_t * zhashx_keys (zhashx_t *self); // Return a zlistx_t containing the values for the items in the // table. Uses the duplicator to duplicate all items and sets the // destructor as destructor for the list. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlistx_t * zhashx_values (zhashx_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhashx_cursor(). NOTE: do NOT modify the table while iterating. CZMQ_EXPORT void * zhashx_first (zhashx_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). To // access the key for this item use zhashx_cursor(). NOTE: do NOT modify // the table while iterating. CZMQ_EXPORT void * zhashx_next (zhashx_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. CZMQ_EXPORT const void * zhashx_cursor (zhashx_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. CZMQ_EXPORT void zhashx_comment (zhashx_t *self, const char *format, ...) CHECK_PRINTF (2); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. CZMQ_EXPORT int zhashx_save (zhashx_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. CZMQ_EXPORT int zhashx_load (zhashx_t *self, const char *filename); // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. CZMQ_EXPORT int zhashx_refresh (zhashx_t *self); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zhashx_pack (zhashx_t *self); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zhashx_t * zhashx_dup (zhashx_t *self); // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. CZMQ_EXPORT void zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. CZMQ_EXPORT void zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined deallocator for keys; by default keys are freed // when the hash is destroyed using free(). CZMQ_EXPORT void zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for keys; by default keys are duplicated // using strdup. CZMQ_EXPORT void zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined comparator for keys; by default keys are // compared using strcmp. CZMQ_EXPORT void zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator); // Set a user-defined comparator for keys; by default keys are // compared using strcmp. CZMQ_EXPORT void zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. CZMQ_EXPORT zhashx_t * zhashx_dup_v2 (zhashx_t *self); // Self test of this class. CZMQ_EXPORT void zhashx_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Same as unpack but uses a user-defined deserializer function to convert // a longstr back into item format. CZMQ_EXPORT zhashx_t * zhashx_unpack_own (zframe_t *frame, zhashx_deserializer_fn deserializer); // *** Draft method, for development use, may change without warning *** // Same as pack but uses a user-defined serializer function to convert items // into longstr. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zhashx_pack_own (zhashx_t *self, zhashx_serializer_fn serializer); #endif // CZMQ_BUILD_DRAFT_API ``` Please add '@interface' section in './../src/zhashx.c'. This is the class self test code: ```c zhashx_t *hash = zhashx_new (); assert (hash); assert (zhashx_size (hash) == 0); assert (zhashx_first (hash) == NULL); assert (zhashx_cursor (hash) == NULL); // Insert some items int rc; rc = zhashx_insert (hash, "DEADBEEF", "dead beef"); char *item = (char *) zhashx_first (hash); assert (streq ((char *) zhashx_cursor (hash), "DEADBEEF")); assert (streq (item, "dead beef")); assert (rc == 0); rc = zhashx_insert (hash, "ABADCAFE", "a bad cafe"); assert (rc == 0); rc = zhashx_insert (hash, "C0DEDBAD", "coded bad"); assert (rc == 0); rc = zhashx_insert (hash, "DEADF00D", "dead food"); assert (rc == 0); assert (zhashx_size (hash) == 4); // Look for existing items item = (char *) zhashx_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); item = (char *) zhashx_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); item = (char *) zhashx_lookup (hash, "C0DEDBAD"); assert (streq (item, "coded bad")); item = (char *) zhashx_lookup (hash, "DEADF00D"); assert (streq (item, "dead food")); // Look for non-existent items item = (char *) zhashx_lookup (hash, "foo"); assert (item == NULL); // Try to insert duplicate items rc = zhashx_insert (hash, "DEADBEEF", "foo"); assert (rc == -1); item = (char *) zhashx_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); // Some rename tests // Valid rename, key is now LIVEBEEF rc = zhashx_rename (hash, "DEADBEEF", "LIVEBEEF"); assert (rc == 0); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an unknown item to a non-existent key rc = zhashx_rename (hash, "WHATBEEF", "NONESUCH"); assert (rc == -1); // Trying to rename an unknown item to an existing key rc = zhashx_rename (hash, "WHATBEEF", "LIVEBEEF"); assert (rc == -1); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an existing item to another existing item rc = zhashx_rename (hash, "LIVEBEEF", "ABADCAFE"); assert (rc == -1); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); item = (char *) zhashx_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); // Test keys method zlistx_t *keys = zhashx_keys (hash); assert (zlistx_size (keys) == 4); zlistx_destroy (&keys); zlistx_t *values = zhashx_values(hash); assert (zlistx_size (values) == 4); zlistx_destroy (&values); // Test dup method zhashx_t *copy = zhashx_dup (hash); assert (zhashx_size (copy) == 4); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); // Test pack/unpack methods zframe_t *frame = zhashx_pack (hash); copy = zhashx_unpack (frame); zframe_destroy (&frame); assert (zhashx_size (copy) == 4); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); #ifdef CZMQ_BUILD_DRAFT_API // Test own pack/unpack methods zhashx_t *own_hash = zhashx_new (); zhashx_set_destructor (own_hash, s_test_destroy_int); assert (own_hash); int *val1 = (int *) zmalloc (sizeof (int)); int *val2 = (int *) zmalloc (sizeof (int)); *val1 = 25; *val2 = 100; zhashx_insert (own_hash, "val1", val1); zhashx_insert (own_hash, "val2", val2); frame = zhashx_pack_own (own_hash, s_test_serialize_int); copy = zhashx_unpack_own (frame, s_test_deserialze_int); zhashx_set_destructor (copy, s_test_destroy_int); zframe_destroy (&frame); assert (zhashx_size (copy) == 2); assert (*((int *) zhashx_lookup (copy, "val1")) == 25); assert (*((int *) zhashx_lookup (copy, "val2")) == 100); zhashx_destroy (©); zhashx_destroy (&own_hash); #endif // CZMQ_BUILD_DRAFT_API // Test save and load zhashx_comment (hash, "This is a test file"); zhashx_comment (hash, "Created by %s", "czmq_selftest"); zhashx_save (hash, ".cache"); copy = zhashx_new (); assert (copy); zhashx_load (copy, ".cache"); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); zsys_file_delete (".cache"); // Delete a item zhashx_delete (hash, "LIVEBEEF"); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (item == NULL); assert (zhashx_size (hash) == 3); // Check that the queue is robust against random usage struct { char name [100]; bool exists; } testset [200]; memset (testset, 0, sizeof (testset)); int testmax = 200, testnbr, iteration; srandom ((unsigned) time (NULL)); for (iteration = 0; iteration < 25000; iteration++) { testnbr = randof (testmax); if (testset [testnbr].exists) { item = (char *) zhashx_lookup (hash, testset [testnbr].name); assert (item); zhashx_delete (hash, testset [testnbr].name); testset [testnbr].exists = false; } else { sprintf (testset [testnbr].name, "%x-%x", rand (), rand ()); if (zhashx_insert (hash, testset [testnbr].name, "") == 0) testset [testnbr].exists = true; } } // Test 10K lookups for (iteration = 0; iteration < 10000; iteration++) item = (char *) zhashx_lookup (hash, "DEADBEEFABADCAFE"); // Destructor should be safe to call twice zhashx_destroy (&hash); zhashx_destroy (&hash); assert (hash == NULL); // Test destructor; automatically copies and frees string values hash = zhashx_new (); assert (hash); zhashx_set_destructor (hash, (zhashx_destructor_fn *) zstr_free); zhashx_set_duplicator (hash, (zhashx_duplicator_fn *) strdup); char value [255]; strcpy (value, "This is a string"); rc = zhashx_insert (hash, "key1", value); assert (rc == 0); strcpy (value, "Ring a ding ding"); rc = zhashx_insert (hash, "key2", value); assert (rc == 0); assert (streq ((char *) zhashx_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhashx_lookup (hash, "key2"), "Ring a ding ding")); zhashx_destroy (&hash); // Test purger and shrinker: no data should end up unreferenced in valgrind hash = zhashx_new (); assert (hash); zhashx_set_destructor (hash, (zhashx_destructor_fn *) zstr_free); zhashx_set_duplicator (hash, (zhashx_duplicator_fn *) strdup); char valuep [255]; strcpy (valuep, "This is a string"); rc = zhashx_insert (hash, "key1", valuep); assert (rc == 0); strcpy (valuep, "Ring a ding ding"); rc = zhashx_insert (hash, "key2", valuep); assert (rc == 0); strcpy (valuep, "Cartahena delenda est"); rc = zhashx_insert (hash, "key3", valuep); assert (rc == 0); strcpy (valuep, "So say we all!"); rc = zhashx_insert (hash, "key4", valuep); assert (rc == 0); assert (streq ((char *) zhashx_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhashx_lookup (hash, "key2"), "Ring a ding ding")); assert (streq ((char *) zhashx_lookup (hash, "key3"), "Cartahena delenda est")); assert (streq ((char *) zhashx_lookup (hash, "key4"), "So say we all!")); zhashx_purge (hash); zhashx_destroy (&hash); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### ziflist - list of network interfaces available on system The ziflist class takes a snapshot of the network interfaces that the system currently supports (this can change arbitrarily, especially on mobile devices). The caller can then access the network interface information using an iterator that works like zlistx. Only stores those interfaces with broadcast capability, and ignores the loopback interface. Please add '@discuss' section in './../src/ziflist.c'. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Get a list of network interfaces currently defined on the system CZMQ_EXPORT ziflist_t * ziflist_new (void); // Destroy a ziflist instance CZMQ_EXPORT void ziflist_destroy (ziflist_t **self_p); // Reload network interfaces from system CZMQ_EXPORT void ziflist_reload (ziflist_t *self); // Return the number of network interfaces on system CZMQ_EXPORT size_t ziflist_size (ziflist_t *self); // Get first network interface, return NULL if there are none CZMQ_EXPORT const char * ziflist_first (ziflist_t *self); // Get next network interface, return NULL if we hit the last one CZMQ_EXPORT const char * ziflist_next (ziflist_t *self); // Return the current interface IP address as a printable string CZMQ_EXPORT const char * ziflist_address (ziflist_t *self); // Return the current interface broadcast address as a printable string CZMQ_EXPORT const char * ziflist_broadcast (ziflist_t *self); // Return the current interface network mask as a printable string CZMQ_EXPORT const char * ziflist_netmask (ziflist_t *self); // Return the list of interfaces. CZMQ_EXPORT void ziflist_print (ziflist_t *self); // Self test of this class. CZMQ_EXPORT void ziflist_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Get a list of network interfaces currently defined on the system // Includes IPv6 interfaces // Caller owns return value and must destroy it when done. CZMQ_EXPORT ziflist_t * ziflist_new_ipv6 (void); // *** Draft method, for development use, may change without warning *** // Reload network interfaces from system, including IPv6 CZMQ_EXPORT void ziflist_reload_ipv6 (ziflist_t *self); // *** Draft method, for development use, may change without warning *** // Return true if the current interface uses IPv6 CZMQ_EXPORT bool ziflist_is_ipv6 (ziflist_t *self); #endif // CZMQ_BUILD_DRAFT_API ``` Please add '@interface' section in './../src/ziflist.c'. This is the class self test code: ```c ziflist_t *iflist = ziflist_new (); assert (iflist); size_t items = ziflist_size (iflist); if (verbose) { printf ("ziflist: interfaces=%zu\n", ziflist_size (iflist)); const char *name = ziflist_first (iflist); while (name) { printf (" - name=%s address=%s netmask=%s broadcast=%s\n", name, ziflist_address (iflist), ziflist_netmask (iflist), ziflist_broadcast (iflist)); name = ziflist_next (iflist); } } ziflist_reload (iflist); assert (items == ziflist_size (iflist)); ziflist_destroy (&iflist); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zlist - simple generic list container Provides a generic container implementing a fast singly-linked list. You can use this to construct multi-dimensional lists, and other structures together with other generic containers like zhash. This is a simple class. For demanding applications we recommend using zlistx. To iterate through a list, use zlist_first to get the first item, then loop while not null, and do zlist_next at the end of each iteration. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Comparison function e.g. for sorting and removing. typedef int (zlist_compare_fn) ( void *item1, void *item2); // Callback function for zlist_freefn method typedef void (zlist_free_fn) ( void *data); // Create a new list container CZMQ_EXPORT zlist_t * zlist_new (void); // Destroy a list container CZMQ_EXPORT void zlist_destroy (zlist_t **self_p); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_first (zlist_t *self); // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. CZMQ_EXPORT void * zlist_next (zlist_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_last (zlist_t *self); // Return first item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlist_head (zlist_t *self); // Return last item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlist_tail (zlist_t *self); // Return the current item of list. If the list is empty, returns NULL. // Leaves cursor pointing at the current item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_item (zlist_t *self); // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. CZMQ_EXPORT int zlist_append (zlist_t *self, void *item); // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. CZMQ_EXPORT int zlist_push (zlist_t *self, void *item); // Pop the item off the start of the list, if any CZMQ_EXPORT void * zlist_pop (zlist_t *self); // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. CZMQ_EXPORT bool zlist_exists (zlist_t *self, void *item); // Remove the specified item from the list if present CZMQ_EXPORT void zlist_remove (zlist_t *self, void *item); // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlist_t * zlist_dup (zlist_t *self); // Purge all items from list CZMQ_EXPORT void zlist_purge (zlist_t *self); // Return number of items in the list CZMQ_EXPORT size_t zlist_size (zlist_t *self); // Sort the list. If the compare function is null, sorts the list by // ascending key value using a straight ASCII comparison. If you specify // a compare function, this decides how items are sorted. The sort is not // stable, so may reorder items with the same keys. The algorithm used is // combsort, a compromise between performance and simplicity. CZMQ_EXPORT void zlist_sort (zlist_t *self, zlist_compare_fn compare); // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. CZMQ_EXPORT void zlist_autofree (zlist_t *self); // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. CZMQ_EXPORT void zlist_comparefn (zlist_t *self, zlist_compare_fn fn); // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zlist_freefn (zlist_t *self, void *item, zlist_free_fn fn, bool at_tail); // Self test of this class. CZMQ_EXPORT void zlist_test (bool verbose); ``` Please add '@interface' section in './../src/zlist.c'. This is the class self test code: ```c zlist_t *list = zlist_new (); assert (list); assert (zlist_size (list) == 0); // Three items we'll use as test data // List items are void *, not particularly strings char *cheese = "boursin"; char *bread = "baguette"; char *wine = "bordeaux"; zlist_append (list, cheese); assert (zlist_size (list) == 1); assert ( zlist_exists (list, cheese)); assert (!zlist_exists (list, bread)); assert (!zlist_exists (list, wine)); zlist_append (list, bread); assert (zlist_size (list) == 2); assert ( zlist_exists (list, cheese)); assert ( zlist_exists (list, bread)); assert (!zlist_exists (list, wine)); zlist_append (list, wine); assert (zlist_size (list) == 3); assert ( zlist_exists (list, cheese)); assert ( zlist_exists (list, bread)); assert ( zlist_exists (list, wine)); assert (zlist_head (list) == cheese); assert (zlist_next (list) == cheese); assert (zlist_first (list) == cheese); assert (zlist_tail (list) == wine); assert (zlist_next (list) == bread); assert (zlist_first (list) == cheese); assert (zlist_next (list) == bread); assert (zlist_next (list) == wine); assert (zlist_next (list) == NULL); // After we reach end of list, next wraps around assert (zlist_next (list) == cheese); assert (zlist_size (list) == 3); zlist_remove (list, wine); assert (zlist_size (list) == 2); assert (zlist_first (list) == cheese); zlist_remove (list, cheese); assert (zlist_size (list) == 1); assert (zlist_first (list) == bread); zlist_remove (list, bread); assert (zlist_size (list) == 0); zlist_append (list, cheese); zlist_append (list, bread); assert (zlist_last (list) == bread); zlist_remove (list, bread); assert (zlist_last (list) == cheese); zlist_remove (list, cheese); assert (zlist_last (list) == NULL); zlist_push (list, cheese); assert (zlist_size (list) == 1); assert (zlist_first (list) == cheese); zlist_push (list, bread); assert (zlist_size (list) == 2); assert (zlist_first (list) == bread); assert (zlist_item (list) == bread); zlist_append (list, wine); assert (zlist_size (list) == 3); assert (zlist_first (list) == bread); zlist_t *sub_list = zlist_dup (list); assert (sub_list); assert (zlist_size (sub_list) == 3); zlist_sort (list, NULL); char *item; item = (char *) zlist_pop (list); assert (item == bread); item = (char *) zlist_pop (list); assert (item == wine); item = (char *) zlist_pop (list); assert (item == cheese); assert (zlist_size (list) == 0); assert (zlist_size (sub_list) == 3); zlist_push (list, sub_list); zlist_t *sub_list_2 = zlist_dup (sub_list); zlist_append (list, sub_list_2); assert (zlist_freefn (list, sub_list, &s_zlist_free, false) == sub_list); assert (zlist_freefn (list, sub_list_2, &s_zlist_free, true) == sub_list_2); zlist_destroy (&list); // Test autofree functionality list = zlist_new (); assert (list); zlist_autofree (list); // Set equals function otherwise equals will not work as autofree copies strings zlist_comparefn (list, (zlist_compare_fn *) strcmp); zlist_push (list, bread); zlist_append (list, cheese); assert (zlist_size (list) == 2); zlist_append (list, wine); assert (zlist_exists (list, wine)); zlist_remove (list, wine); assert (!zlist_exists (list, wine)); assert (streq ((const char *) zlist_first (list), bread)); item = (char *) zlist_pop (list); assert (streq (item, bread)); free (item); item = (char *) zlist_pop (list); assert (streq (item, cheese)); free (item); zlist_destroy (&list); assert (list == NULL); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zlistx - extended generic list container Provides a generic doubly-linked list container. This container provides hooks for duplicator, comparator, and destructor functions. These tie into CZMQ and standard C semantics, so e.g. for string items you can use strdup, strcmp, and zstr_free. To store custom objects, define your own duplicator and comparator, and use the standard object destructor. This is a reworking of the simpler zlist container. It is faster to insert and delete items anywhere in the list, and to keep ordered lists. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Destroy an item typedef void (zlistx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zlistx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zlistx_comparator_fn) ( const void *item1, const void *item2); // Create a new, empty list. CZMQ_EXPORT zlistx_t * zlistx_new (void); // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. CZMQ_EXPORT void zlistx_destroy (zlistx_t **self_p); // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. CZMQ_EXPORT void * zlistx_add_start (zlistx_t *self, void *item); // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. CZMQ_EXPORT void * zlistx_add_end (zlistx_t *self, void *item); // Return the number of items in the list CZMQ_EXPORT size_t zlistx_size (zlistx_t *self); // Return first item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlistx_head (zlistx_t *self); // Return last item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlistx_tail (zlistx_t *self); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. CZMQ_EXPORT void * zlistx_first (zlistx_t *self); // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). CZMQ_EXPORT void * zlistx_next (zlistx_t *self); // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). CZMQ_EXPORT void * zlistx_prev (zlistx_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. CZMQ_EXPORT void * zlistx_last (zlistx_t *self); // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. CZMQ_EXPORT void * zlistx_item (zlistx_t *self); // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. CZMQ_EXPORT void * zlistx_cursor (zlistx_t *self); // Returns the item associated with the given list handle, or NULL if passed // in handle is NULL. Asserts that the passed in handle points to a list element. CZMQ_EXPORT void * zlistx_handle_item (void *handle); // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. CZMQ_EXPORT void * zlistx_find (zlistx_t *self, void *item); // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. CZMQ_EXPORT void * zlistx_detach (zlistx_t *self, void *handle); // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. CZMQ_EXPORT void * zlistx_detach_cur (zlistx_t *self); // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. CZMQ_EXPORT int zlistx_delete (zlistx_t *self, void *handle); // Move an item to the start of the list, via its handle. CZMQ_EXPORT void zlistx_move_start (zlistx_t *self, void *handle); // Move an item to the end of the list, via its handle. CZMQ_EXPORT void zlistx_move_end (zlistx_t *self, void *handle); // Remove all items from the list, and destroy them if the item destructor // is set. CZMQ_EXPORT void zlistx_purge (zlistx_t *self); // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. CZMQ_EXPORT void zlistx_sort (zlistx_t *self); // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. CZMQ_EXPORT void * zlistx_insert (zlistx_t *self, void *item, bool low_value); // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. CZMQ_EXPORT void zlistx_reorder (zlistx_t *self, void *handle, bool low_value); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. CZMQ_EXPORT zlistx_t * zlistx_dup (zlistx_t *self); // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. CZMQ_EXPORT void zlistx_set_destructor (zlistx_t *self, zlistx_destructor_fn destructor); // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. CZMQ_EXPORT void zlistx_set_duplicator (zlistx_t *self, zlistx_duplicator_fn duplicator); // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. CZMQ_EXPORT void zlistx_set_comparator (zlistx_t *self, zlistx_comparator_fn comparator); // Self test of this class. CZMQ_EXPORT void zlistx_test (bool verbose); ``` Please add '@interface' section in './../src/zlistx.c'. This is the class self test code: ```c zlistx_t *list = zlistx_new (); assert (list); assert (zlistx_size (list) == 0); // Test operations on an empty list assert (zlistx_first (list) == NULL); assert (zlistx_last (list) == NULL); assert (zlistx_next (list) == NULL); assert (zlistx_prev (list) == NULL); assert (zlistx_find (list, "hello") == NULL); assert (zlistx_delete (list, NULL) == -1); assert (zlistx_detach (list, NULL) == NULL); assert (zlistx_delete (list, NULL) == -1); assert (zlistx_detach (list, NULL) == NULL); zlistx_purge (list); zlistx_sort (list); // Use item handlers zlistx_set_destructor (list, (zlistx_destructor_fn *) zstr_free); zlistx_set_duplicator (list, (zlistx_duplicator_fn *) strdup); zlistx_set_comparator (list, (zlistx_comparator_fn *) strcmp); // Try simple insert/sort/delete/next assert (zlistx_next (list) == NULL); zlistx_add_end (list, "world"); assert (streq ((char *) zlistx_next (list), "world")); zlistx_add_end (list, "hello"); assert (streq ((char *) zlistx_prev (list), "hello")); zlistx_sort (list); assert (zlistx_size (list) == 2); void *handle = zlistx_find (list, "hello"); char *item1 = (char *) zlistx_item (list); char *item2 = (char *) zlistx_handle_item (handle); assert (item1 == item2); assert (streq (item1, "hello")); zlistx_delete (list, handle); assert (zlistx_size (list) == 1); char *string = (char *) zlistx_detach (list, NULL); assert (streq (string, "world")); free (string); assert (zlistx_size (list) == 0); // Check next/back work // Now populate the list with items zlistx_add_start (list, "five"); zlistx_add_end (list, "six"); zlistx_add_start (list, "four"); zlistx_add_end (list, "seven"); zlistx_add_start (list, "three"); zlistx_add_end (list, "eight"); zlistx_add_start (list, "two"); zlistx_add_end (list, "nine"); zlistx_add_start (list, "one"); zlistx_add_end (list, "ten"); // Test our navigation skills assert (zlistx_size (list) == 10); assert (streq ((char *) zlistx_last (list), "ten")); assert (streq ((char *) zlistx_prev (list), "nine")); assert (streq ((char *) zlistx_prev (list), "eight")); assert (streq ((char *) zlistx_prev (list), "seven")); assert (streq ((char *) zlistx_prev (list), "six")); assert (streq ((char *) zlistx_prev (list), "five")); assert (streq ((char *) zlistx_first (list), "one")); assert (streq ((char *) zlistx_next (list), "two")); assert (streq ((char *) zlistx_next (list), "three")); assert (streq ((char *) zlistx_next (list), "four")); // Sort by alphabetical order zlistx_sort (list); assert (streq ((char *) zlistx_first (list), "eight")); assert (streq ((char *) zlistx_last (list), "two")); // Moving items around handle = zlistx_find (list, "six"); zlistx_move_start (list, handle); assert (streq ((char *) zlistx_first (list), "six")); zlistx_move_end (list, handle); assert (streq ((char *) zlistx_last (list), "six")); zlistx_sort (list); assert (streq ((char *) zlistx_last (list), "two")); // Copying a list zlistx_t *copy = zlistx_dup (list); assert (copy); assert (zlistx_size (copy) == 10); assert (streq ((char *) zlistx_first (copy), "eight")); assert (streq ((char *) zlistx_last (copy), "two")); zlistx_destroy (©); // Delete items while iterating string = (char *) zlistx_first (list); assert (streq (string, "eight")); string = (char *) zlistx_next (list); assert (streq (string, "five")); zlistx_delete (list, zlistx_cursor (list)); string = (char *) zlistx_next (list); assert (streq (string, "four")); zlistx_purge (list); zlistx_destroy (&list); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zloop - event-driven reactor The zloop class provides an event-driven reactor pattern. The reactor handles zmq_pollitem_t items (pollers or writers, sockets or fds), and once-off or repeated timers. Its resolution is 1 msec. It uses a tickless timer to reduce CPU interrupts in inactive processes. Please add '@discuss' section in './../src/zloop.c'. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Callback function for reactor socket activity typedef int (zloop_reader_fn) ( zloop_t *loop, zsock_t *reader, void *arg); // Callback function for reactor events (low-level) typedef int (zloop_fn) ( zloop_t *loop, zmq_pollitem_t *item, void *arg); // Callback for reactor timer events typedef int (zloop_timer_fn) ( zloop_t *loop, int timer_id, void *arg); // Create a new zloop reactor CZMQ_EXPORT zloop_t * zloop_new (void); // Destroy a reactor CZMQ_EXPORT void zloop_destroy (zloop_t **self_p); // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. CZMQ_EXPORT int zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg); // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. CZMQ_EXPORT void zloop_reader_end (zloop_t *self, zsock_t *sock); // Configure a registered reader to ignore errors. If you do not set this, // then readers that have errors are removed from the reactor silently. CZMQ_EXPORT void zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock); // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. CZMQ_EXPORT int zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg); // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. CZMQ_EXPORT void zloop_poller_end (zloop_t *self, zmq_pollitem_t *item); // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. CZMQ_EXPORT void zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item); // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. CZMQ_EXPORT int zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg); // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer). CZMQ_EXPORT int zloop_timer_end (zloop_t *self, int timer_id); // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. CZMQ_EXPORT void * zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg); // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. CZMQ_EXPORT void zloop_ticket_reset (zloop_t *self, void *handle); // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. CZMQ_EXPORT void zloop_ticket_delete (zloop_t *self, void *handle); // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. CZMQ_EXPORT void zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay); // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. CZMQ_EXPORT void zloop_set_max_timers (zloop_t *self, size_t max_timers); // Set verbose tracing of reactor on/off. The default verbose setting is // off (false). CZMQ_EXPORT void zloop_set_verbose (zloop_t *self, bool verbose); // By default the reactor stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). CZMQ_EXPORT void zloop_set_nonstop (zloop_t *self, bool nonstop); // Start the reactor. Takes control of the thread and returns when the ØMQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. CZMQ_EXPORT int zloop_start (zloop_t *self); // Self test of this class. CZMQ_EXPORT void zloop_test (bool verbose); ``` Please add '@interface' section in './../src/zloop.c'. This is the class self test code: ```c // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new (ZMQ_PAIR); assert (output); zsock_bind (output, "inproc://zloop.test"); zsock_t *input = zsock_new (ZMQ_PAIR); assert (input); zsock_connect (input, "inproc://zloop.test"); zloop_t *loop = zloop_new (); assert (loop); zloop_set_verbose (loop, verbose); // Create a timer that will be cancelled int timer_id = zloop_timer (loop, 1000, 1, s_timer_event, NULL); zloop_timer (loop, 5, 1, s_cancel_timer_event, &timer_id); // After 20 msecs, send a ping message to output3 zloop_timer (loop, 20, 1, s_timer_event, output); // Set up some tickets that will never expire zloop_set_ticket_delay (loop, 10000); void *ticket1 = zloop_ticket (loop, s_timer_event, NULL); void *ticket2 = zloop_ticket (loop, s_timer_event, NULL); void *ticket3 = zloop_ticket (loop, s_timer_event, NULL); // When we get the ping message, end the reactor rc = zloop_reader (loop, input, s_socket_event, NULL); assert (rc == 0); zloop_reader_set_tolerant (loop, input); zloop_start (loop); zloop_ticket_delete (loop, ticket1); zloop_ticket_delete (loop, ticket2); zloop_ticket_delete (loop, ticket3); // Check whether loop properly ignores zsys_interrupted flag // when asked to zloop_destroy (&loop); loop = zloop_new (); bool timer_event_called = false; zloop_timer (loop, 1, 1, s_timer_event3, &timer_event_called); zsys_interrupted = 1; zloop_start (loop); // zloop returns immediately without giving any handler a chance to run assert (!timer_event_called); zloop_set_nonstop (loop, true); zloop_start (loop); // zloop runs the handler which will terminate the loop assert (timer_event_called); zsys_interrupted = 0; // Check if reader removed in timer is not called zloop_destroy (&loop); loop = zloop_new (); bool socket_event_called = false; zloop_reader (loop, output, s_socket_event1, &socket_event_called); zloop_timer (loop, 0, 1, s_timer_event5, output); zstr_send (input, "PING"); zloop_start (loop); assert (!socket_event_called); // cleanup zloop_destroy (&loop); assert (loop == NULL); zsock_destroy (&input); zsock_destroy (&output); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zmonitor - socket event monitor The zmonitor actor provides an API for obtaining socket events such as connected, listen, disconnected, etc. Socket events are only available for sockets connecting or bound to ipc:// and tcp:// endpoints. This class wraps the ZMQ socket monitor API, see zmq_socket_monitor for details. Works on all versions of libzmq from 3.2 onwards. This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). This is the class interface: ```h // Create new zmonitor actor instance to monitor a zsock_t socket: // // zactor_t *monitor = zactor_new (zmonitor, mysocket); // // Destroy zmonitor instance. // // zactor_destroy (&monitor); // // Enable verbose logging of commands and activity. // // zstr_send (monitor, "VERBOSE"); // // Listen to monitor event type (zero or types, ending in NULL): // zstr_sendx (monitor, "LISTEN", type, ..., NULL); // // Events: // CONNECTED // CONNECT_DELAYED // CONNECT_RETRIED // LISTENING // BIND_FAILED // ACCEPTED // ACCEPT_FAILED // CLOSED // CLOSE_FAILED // DISCONNECTED // MONITOR_STOPPED // ALL // // Start monitor; after this, any further LISTEN commands are ignored. // // zstr_send (monitor, "START"); // zsock_wait (monitor); // // Receive next monitor event: // // zmsg_t *msg = zmsg_recv (monitor); // // This is the zmonitor constructor as a zactor_fn; the argument can be // a zactor_t, zsock_t, or libzmq void * socket: CZMQ_EXPORT void zmonitor (zsock_t *pipe, void *sock); // Selftest CZMQ_EXPORT void zmonitor_test (bool verbose); ``` Please add '@interface' section in './../src/zmonitor.c'. This is the class self test code: ```c zsock_t *client = zsock_new (ZMQ_DEALER); assert (client); zactor_t *clientmon = zactor_new (zmonitor, client); assert (clientmon); if (verbose) zstr_sendx (clientmon, "VERBOSE", NULL); zstr_sendx (clientmon, "LISTEN", "LISTENING", "ACCEPTED", NULL); #if defined (ZMQ_EVENT_HANDSHAKE_SUCCEED) zstr_sendx (clientmon, "LISTEN", "HANDSHAKE_SUCCEED", NULL); #endif zstr_sendx (clientmon, "START", NULL); zsock_wait (clientmon); zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); zactor_t *servermon = zactor_new (zmonitor, server); assert (servermon); if (verbose) zstr_sendx (servermon, "VERBOSE", NULL); zstr_sendx (servermon, "LISTEN", "CONNECTED", "DISCONNECTED", NULL); zstr_sendx (servermon, "START", NULL); zsock_wait (servermon); // Allow a brief time for the message to get there... zmq_poll (NULL, 0, 200); // Check client is now listening int port_nbr = zsock_bind (client, "tcp://127.0.0.1:*"); assert (port_nbr != -1); s_assert_event (clientmon, "LISTENING"); // Check server connected to client zsock_connect (server, "tcp://127.0.0.1:%d", port_nbr); s_assert_event (servermon, "CONNECTED"); // Check client accepted connection s_assert_event (clientmon, "ACCEPTED"); #if defined (ZMQ_EVENT_HANDSHAKE_SUCCEED) s_assert_event (clientmon, "HANDSHAKE_SUCCEED"); #endif zactor_destroy (&clientmon); zactor_destroy (&servermon); zsock_destroy (&client); zsock_destroy (&server); #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zmsg - working with multipart messages The zmsg class provides methods to send and receive multipart messages across ØMQ sockets. This class provides a list-like container interface, with methods to work with the overall container. zmsg_t messages are composed of zero or more zframe_t frames. Please add '@discuss' section in './../src/zmsg.c'. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Create a new empty message object CZMQ_EXPORT zmsg_t * zmsg_new (void); // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted. Does a blocking recv. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving. CZMQ_EXPORT zmsg_t * zmsg_recv (void *source); // Load/append an open file into new message, return the message. // Returns NULL if the message could not be loaded. CZMQ_EXPORT zmsg_t * zmsg_load (FILE *file); // Decodes a serialized message frame created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the frame was badly formatted or // there was insufficient memory to work. CZMQ_EXPORT zmsg_t * zmsg_decode (zframe_t *frame); // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. CZMQ_EXPORT zmsg_t * zmsg_new_signal (byte status); // Destroy a message object and all frames it contains CZMQ_EXPORT void zmsg_destroy (zmsg_t **self_p); // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). CZMQ_EXPORT int zmsg_send (zmsg_t **self_p, void *dest); // Send message to destination socket as part of a multipart sequence, and // destroy the message after sending it successfully. Note that after a // zmsg_sendm, you must call zmsg_send or another method that sends a final // message part. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). CZMQ_EXPORT int zmsg_sendm (zmsg_t **self_p, void *dest); // Return size of message, i.e. number of frames (0 or more). CZMQ_EXPORT size_t zmsg_size (zmsg_t *self); // Return total size of all frames in message. CZMQ_EXPORT size_t zmsg_content_size (zmsg_t *self); // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. CZMQ_EXPORT int zmsg_prepend (zmsg_t *self, zframe_t **frame_p); // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Deprecates zmsg_add, which did not nullify the // caller's frame reference. CZMQ_EXPORT int zmsg_append (zmsg_t *self, zframe_t **frame_p); // Remove first frame from message, if any. Returns frame, or NULL. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zmsg_pop (zmsg_t *self); // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushmem (zmsg_t *self, const void *data, size_t size); // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addmem (zmsg_t *self, const void *data, size_t size); // Push string as new frame to front of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushstr (zmsg_t *self, const char *string); // Push string as new frame to end of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addstr (zmsg_t *self, const char *string); // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zmsg_popstr (zmsg_t *self); // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. CZMQ_EXPORT int zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p); // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not successful. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zmsg_t * zmsg_popmsg (zmsg_t *self); // Remove specified frame from list, if present. Does not destroy frame. CZMQ_EXPORT void zmsg_remove (zmsg_t *self, zframe_t *frame); // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. CZMQ_EXPORT zframe_t * zmsg_first (zmsg_t *self); // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. CZMQ_EXPORT zframe_t * zmsg_next (zmsg_t *self); // Return the last frame. If there are no frames, returns NULL. CZMQ_EXPORT zframe_t * zmsg_last (zmsg_t *self); // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. CZMQ_EXPORT int zmsg_save (zmsg_t *self, FILE *file); // Serialize multipart message to a single message frame. Use this method // to send structured messages across transports that do not support // multipart data. Allocates and returns a new frame containing the // serialized message. To decode a serialized message frame, use // zmsg_decode (). // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zmsg_encode (zmsg_t *self); // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zmsg_t * zmsg_dup (zmsg_t *self); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). CZMQ_EXPORT void zmsg_print (zmsg_t *self); // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. CZMQ_EXPORT bool zmsg_eq (zmsg_t *self, zmsg_t *other); // Return signal value, 0 or greater, if message is a signal, -1 if not. CZMQ_EXPORT int zmsg_signal (zmsg_t *self); // Probe the supplied object, and report if it looks like a zmsg_t. CZMQ_EXPORT bool zmsg_is (void *self); // Self test of this class. CZMQ_EXPORT void zmsg_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Return message routing ID, if the message came from a ZMQ_SERVER socket. // Else returns zero. CZMQ_EXPORT uint32_t zmsg_routing_id (zmsg_t *self); // *** Draft method, for development use, may change without warning *** // Set routing ID on message. This is used if/when the message is sent to a // ZMQ_SERVER socket. CZMQ_EXPORT void zmsg_set_routing_id (zmsg_t *self, uint32_t routing_id); #endif // CZMQ_BUILD_DRAFT_API ``` Please add '@interface' section in './../src/zmsg.c'. This is the class self test code: ```c // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zmsg.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zmsg.test"); assert (input); // Test send and receive of single-frame message zmsg_t *msg = zmsg_new (); assert (msg); zframe_t *frame = zframe_new ("Hello", 5); assert (frame); zmsg_prepend (msg, &frame); assert (zmsg_size (msg) == 1); assert (zmsg_content_size (msg) == 5); rc = zmsg_send (&msg, output); assert (msg == NULL); assert (rc == 0); msg = zmsg_recv (input); assert (msg); assert (zmsg_size (msg) == 1); assert (zmsg_content_size (msg) == 5); zmsg_destroy (&msg); // Test send and receive of multi-frame message msg = zmsg_new (); assert (msg); rc = zmsg_addmem (msg, "Frame0", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame1", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame2", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame3", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame4", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame5", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame6", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame7", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame8", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame9", 6); assert (rc == 0); zmsg_t *copy = zmsg_dup (msg); assert (copy); rc = zmsg_send (©, output); assert (rc == 0); rc = zmsg_send (&msg, output); assert (rc == 0); copy = zmsg_recv (input); assert (copy); assert (zmsg_size (copy) == 10); assert (zmsg_content_size (copy) == 60); zmsg_destroy (©); msg = zmsg_recv (input); assert (msg); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); // Save to a file, read back FILE *file = fopen ("zmsg.test", "w"); assert (file); rc = zmsg_save (msg, file); assert (rc == 0); fclose (file); file = fopen ("zmsg.test", "r"); rc = zmsg_save (msg, file); assert (rc == -1); fclose (file); zmsg_destroy (&msg); file = fopen ("zmsg.test", "r"); msg = zmsg_load (file); assert (msg); fclose (file); remove ("zmsg.test"); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); // Remove all frames except first and last int frame_nbr; for (frame_nbr = 0; frame_nbr < 8; frame_nbr++) { zmsg_first (msg); frame = zmsg_next (msg); zmsg_remove (msg, frame); zframe_destroy (&frame); } // Test message frame manipulation assert (zmsg_size (msg) == 2); frame = zmsg_last (msg); assert (zframe_streq (frame, "Frame9")); assert (zmsg_content_size (msg) == 12); frame = zframe_new ("Address", 7); assert (frame); zmsg_prepend (msg, &frame); assert (zmsg_size (msg) == 3); rc = zmsg_addstr (msg, "Body"); assert (rc == 0); assert (zmsg_size (msg) == 4); frame = zmsg_pop (msg); zframe_destroy (&frame); assert (zmsg_size (msg) == 3); char *body = zmsg_popstr (msg); assert (streq (body, "Frame0")); free (body); zmsg_destroy (&msg); // Test encoding/decoding msg = zmsg_new (); assert (msg); byte *blank = (byte *) zmalloc (100000); assert (blank); rc = zmsg_addmem (msg, blank, 0); assert (rc == 0); rc = zmsg_addmem (msg, blank, 1); assert (rc == 0); rc = zmsg_addmem (msg, blank, 253); assert (rc == 0); rc = zmsg_addmem (msg, blank, 254); assert (rc == 0); rc = zmsg_addmem (msg, blank, 255); assert (rc == 0); rc = zmsg_addmem (msg, blank, 256); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65535); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65536); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65537); assert (rc == 0); free (blank); assert (zmsg_size (msg) == 9); frame = zmsg_encode (msg); zmsg_destroy (&msg); msg = zmsg_decode (frame); assert (msg); zmsg_destroy (&msg); zframe_destroy (&frame); // Test submessages msg = zmsg_new (); assert (msg); zmsg_t *submsg = zmsg_new (); zmsg_pushstr (msg, "matr"); zmsg_pushstr (submsg, "joska"); rc = zmsg_addmsg (msg, &submsg); assert (rc == 0); assert (submsg == NULL); submsg = zmsg_popmsg (msg); assert (submsg == NULL); // string "matr" is not encoded zmsg_t, so was discarded submsg = zmsg_popmsg (msg); assert (submsg); body = zmsg_popstr (submsg); assert (streq (body, "joska")); free (body); zmsg_destroy (&submsg); frame = zmsg_pop (msg); assert (frame == NULL); zmsg_destroy (&msg); // Test comparison of two messages msg = zmsg_new (); zmsg_addstr (msg, "One"); zmsg_addstr (msg, "Two"); zmsg_addstr (msg, "Three"); zmsg_t *msg_other = zmsg_new (); zmsg_addstr (msg_other, "One"); zmsg_addstr (msg_other, "Two"); zmsg_addstr (msg_other, "One-Hundred"); zmsg_t *msg_dup = zmsg_dup (msg); zmsg_t *empty_msg = zmsg_new (); zmsg_t *empty_msg_2 = zmsg_new (); assert (zmsg_eq (msg, msg_dup)); assert (!zmsg_eq (msg, msg_other)); assert (zmsg_eq (empty_msg, empty_msg_2)); assert (!zmsg_eq (msg, NULL)); assert (!zmsg_eq (NULL, empty_msg)); assert (!zmsg_eq (NULL, NULL)); zmsg_destroy (&msg); zmsg_destroy (&msg_other); zmsg_destroy (&msg_dup); zmsg_destroy (&empty_msg); zmsg_destroy (&empty_msg_2); // Test signal messages msg = zmsg_new_signal (0); assert (zmsg_signal (msg) == 0); zmsg_destroy (&msg); msg = zmsg_new_signal (-1); assert (zmsg_signal (msg) == 255); zmsg_destroy (&msg); // Now try methods on an empty message msg = zmsg_new (); assert (msg); assert (zmsg_size (msg) == 0); assert (zmsg_unwrap (msg) == NULL); assert (zmsg_first (msg) == NULL); assert (zmsg_last (msg) == NULL); assert (zmsg_next (msg) == NULL); assert (zmsg_pop (msg) == NULL); // Sending an empty message is valid and destroys the message assert (zmsg_send (&msg, output) == 0); assert (!msg); zsock_destroy (&input); zsock_destroy (&output); #if defined (ZMQ_SERVER) // Create server and client sockets and connect over inproc zsock_t *server = zsock_new_server ("inproc://zmsg-test-routing"); assert (server); zsock_t *client = zsock_new_client ("inproc://zmsg-test-routing"); assert (client); // Send request from client to server zmsg_t *request = zmsg_new (); assert (request); zmsg_addstr (request, "Hello"); rc = zmsg_send (&request, client); assert (rc == 0); assert (!request); // Read request and send reply request = zmsg_recv (server); assert (request); char *string = zmsg_popstr (request); assert (streq (string, "Hello")); assert (zmsg_routing_id (request)); zstr_free (&string); zmsg_t *reply = zmsg_new (); assert (reply); zmsg_addstr (reply, "World"); zmsg_set_routing_id (reply, zmsg_routing_id (request)); rc = zmsg_send (&reply, server); assert (rc == 0); zmsg_destroy (&request); // Read reply reply = zmsg_recv (client); string = zmsg_popstr (reply); assert (streq (string, "World")); assert (zmsg_routing_id (reply) == 0); zmsg_destroy (&reply); zstr_free (&string); // Client and server disallow multipart msg = zmsg_new (); zmsg_addstr (msg, "One"); zmsg_addstr (msg, "Two"); rc = zmsg_send (&msg, client); assert (rc == -1); assert (zmsg_size (msg) == 2); rc = zmsg_send (&msg, server); assert (rc == -1); assert (zmsg_size (msg) == 2); zmsg_destroy (&msg); zsock_destroy (&client); zsock_destroy (&server); #endif // Test message length calculation after removal msg = zmsg_new (); zmsg_addstr (msg, "One"); zmsg_addstr (msg, "Two"); size_t size_before = zmsg_content_size (msg); frame = zframe_new ("Three", strlen ("Three")); assert (frame); zmsg_remove (msg, frame); size_t size_after = zmsg_content_size (msg); assert (size_before == size_after); zframe_destroy (&frame); zmsg_destroy (&msg); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zpoller - trivial socket poller class The zpoller class provides a minimalist interface to ZeroMQ's zmq_poll API, for the very common case of reading from a number of sockets. It does not provide polling for output, nor polling on file handles. If you need either of these, use the zmq_poll API directly. The class implements the poller using the zmq_poller API if that exists, else does the work itself. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Create new poller, specifying zero or more readers. The list of // readers ends in a NULL. Each reader can be a zsock_t instance, a // zactor_t instance, a libzmq socket (void *), or a file handle. CZMQ_EXPORT zpoller_t * zpoller_new (void *reader, ...); // Destroy a poller CZMQ_EXPORT void zpoller_destroy (zpoller_t **self_p); // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. CZMQ_EXPORT int zpoller_add (zpoller_t *self, void *reader); // Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader // must have been passed during construction, or in an zpoller_add () call. CZMQ_EXPORT int zpoller_remove (zpoller_t *self, void *reader); // By default the poller stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). CZMQ_EXPORT void zpoller_set_nonstop (zpoller_t *self, bool nonstop); // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. CZMQ_EXPORT void * zpoller_wait (zpoller_t *self, int timeout); // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. CZMQ_EXPORT bool zpoller_expired (zpoller_t *self); // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. CZMQ_EXPORT bool zpoller_terminated (zpoller_t *self); // Self test of this class. CZMQ_EXPORT void zpoller_test (bool verbose); ``` Please add '@interface' section in './../src/zpoller.c'. This is the class self test code: ```c // Create a few sockets zsock_t *vent = zsock_new (ZMQ_PUSH); assert (vent); int port_nbr = zsock_bind (vent, "tcp://127.0.0.1:*"); assert (port_nbr != -1); zsock_t *sink = zsock_new (ZMQ_PULL); assert (sink); int rc = zsock_connect (sink, "tcp://127.0.0.1:%d", port_nbr); assert (rc != -1); zsock_t *bowl = zsock_new (ZMQ_PULL); assert (bowl); zsock_t *dish = zsock_new (ZMQ_PULL); assert (dish); // Set up poller zpoller_t *poller = zpoller_new (bowl, dish, NULL); assert (poller); // Add a reader to the existing poller rc = zpoller_add (poller, sink); assert (rc == 0); zstr_send (vent, "Hello, World"); // We expect a message only on the sink zsock_t *which = (zsock_t *) zpoller_wait (poller, -1); assert (which == sink); assert (zpoller_expired (poller) == false); assert (zpoller_terminated (poller) == false); char *message = zstr_recv (which); assert (streq (message, "Hello, World")); zstr_free (&message); // Stop polling reader rc = zpoller_remove (poller, sink); assert (rc == 0); // Removing a non-existent reader shall fail rc = zpoller_remove (poller, sink); assert (rc == -1); assert (errno == EINVAL); // Check we can poll an FD rc = zsock_connect (bowl, "tcp://127.0.0.1:%d", port_nbr); assert (rc != -1); SOCKET fd = zsock_fd (bowl); rc = zpoller_add (poller, (void *) &fd); assert (rc != -1); zstr_send (vent, "Hello again, world"); assert (zpoller_wait (poller, 500) == &fd); // Check zpoller_set_nonstop () zsys_interrupted = 1; zpoller_wait (poller, 0); assert (zpoller_terminated (poller)); zpoller_set_nonstop (poller, true); zpoller_wait (poller, 0); assert (!zpoller_terminated (poller)); zsys_interrupted = 0; zpoller_destroy (&poller); zsock_destroy (&vent); zsock_destroy (&sink); zsock_destroy (&bowl); zsock_destroy (&dish); #ifdef ZMQ_SERVER // Check thread safe sockets zpoller_destroy (&poller); zsock_t *client = zsock_new (ZMQ_CLIENT); assert (client); zsock_t *server = zsock_new (ZMQ_SERVER); assert (server); poller = zpoller_new (client, server, NULL); assert (poller); port_nbr = zsock_bind (server, "tcp://127.0.0.1:*"); assert (port_nbr != -1); rc = zsock_connect (client, "tcp://127.0.0.1:%d", port_nbr); assert (rc != -1); zstr_send (client, "Hello, World"); // We expect a message only on the server which = (zsock_t *) zpoller_wait (poller, -1); assert (which == server); assert (zpoller_expired (poller) == false); assert (zpoller_terminated (poller) == false); message = zstr_recv (which); assert (streq (message, "Hello, World")); zstr_free (&message); zpoller_destroy (&poller); zsock_destroy (&client); zsock_destroy (&server); #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zproc - process configuration and status zproc - process configuration and status, plus unix pipes on steroids WARNING: zproc class have several limitations atm * is tested on zmq4 on Linux and OSX. * does not work on Windows, where you get empty stubs for most of the methods * does not work on libzmq3 and libzmq2. We have experienced stalls and timeouts when running tests against such old version Note: zproc is not yet stable, so there are no guarantees regarding API stability. Some methods can have weird semantics or strange API. Class zproc run an external process and to use ZeroMQ sockets to communicate with it. In other words standard input and outputs MAY be connected with appropriate zeromq socket and data flow is managed by zproc itself. This makes zproc the best in class way how to run and manage sub processes. Data are sent and received as zframes (zframe_t), so zproc does not try to interpret content of the messages in any way. See test example on how to use it. +----------------------------------------+ | /bin/cat cat /etc/passwd | | stdin | stdout | stderr | |------||--------||---------------||-----| | fd1 fd2 fd3 | | ^ v v | |zmq://stdin |zmq://stdout |zmq://stderr | | [zproc supervisor] | +----------------------------------------+ ----------> zeromq magic here <----------- +----------------------------------------+ |zmq://stdin |zmq://stdout |zmq://stderr | | | | consumer | | | | | +----------------------------------------+ Please add '@discuss' section in './../src/zproc.c'. This is the class interface: ```h // This is a draft class, and may change without notice. It is disabled in // stable builds by default. If you use this in applications, please ask // for it to be pushed to stable state. Use --enable-drafts to enable. #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Create a new zproc. // NOTE: On Windows and with libzmq3 and libzmq2 this function // returns NULL. Code needs to be ported there. CZMQ_EXPORT zproc_t * zproc_new (void); // *** Draft method, for development use, may change without warning *** // Destroy zproc, wait until process ends. CZMQ_EXPORT void zproc_destroy (zproc_t **self_p); // *** Draft method, for development use, may change without warning *** // Setup the command line arguments, the first item must be an (absolute) filename // to run. CZMQ_EXPORT void zproc_set_args (zproc_t *self, zlistx_t *args); // *** Draft method, for development use, may change without warning *** // Setup the environment variables for the process. CZMQ_EXPORT void zproc_set_env (zproc_t *self, zhashx_t *args); // *** Draft method, for development use, may change without warning *** // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The writable one is then accessbile via zproc_stdin method. CZMQ_EXPORT void zproc_set_stdin (zproc_t *self, void *socket); // *** Draft method, for development use, may change without warning *** // Connects process stdout with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stdout method. CZMQ_EXPORT void zproc_set_stdout (zproc_t *self, void *socket); // *** Draft method, for development use, may change without warning *** // Connects process stderr with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stderr method. CZMQ_EXPORT void zproc_set_stderr (zproc_t *self, void *socket); // *** Draft method, for development use, may change without warning *** // Return subprocess stdin writable socket. NULL for // not initialized or external sockets. CZMQ_EXPORT void * zproc_stdin (zproc_t *self); // *** Draft method, for development use, may change without warning *** // Return subprocess stdout readable socket. NULL for // not initialized or external sockets. CZMQ_EXPORT void * zproc_stdout (zproc_t *self); // *** Draft method, for development use, may change without warning *** // Return subprocess stderr readable socket. NULL for // not initialized or external sockets. CZMQ_EXPORT void * zproc_stderr (zproc_t *self); // *** Draft method, for development use, may change without warning *** // Starts the process. CZMQ_EXPORT int zproc_run (zproc_t *self); // *** Draft method, for development use, may change without warning *** // process exit code CZMQ_EXPORT int zproc_returncode (zproc_t *self); // *** Draft method, for development use, may change without warning *** // PID of the process CZMQ_EXPORT int zproc_pid (zproc_t *self); // *** Draft method, for development use, may change without warning *** // return true if process is running, false if not yet started or finished CZMQ_EXPORT bool zproc_running (zproc_t *self); // *** Draft method, for development use, may change without warning *** // wait or poll process status, return return code CZMQ_EXPORT int zproc_wait (zproc_t *self, bool hang); // *** Draft method, for development use, may change without warning *** // return internal actor, usefull for the polling if process died CZMQ_EXPORT void * zproc_actor (zproc_t *self); // *** Draft method, for development use, may change without warning *** // send a signal to the subprocess CZMQ_EXPORT void zproc_kill (zproc_t *self, int signal); // *** Draft method, for development use, may change without warning *** // set verbose mode CZMQ_EXPORT void zproc_set_verbose (zproc_t *self, bool verbose); // *** Draft method, for development use, may change without warning *** // Returns CZMQ version as a single 6-digit integer encoding the major // version (x 10000), the minor version (x 100) and the patch. CZMQ_EXPORT int zproc_czmq_version (void); // *** Draft method, for development use, may change without warning *** // Returns true if the process received a SIGINT or SIGTERM signal. // It is good practice to use this method to exit any infinite loop // processing messages. CZMQ_EXPORT bool zproc_interrupted (void); // *** Draft method, for development use, may change without warning *** // Returns true if the underlying libzmq supports CURVE security. CZMQ_EXPORT bool zproc_has_curve (void); // *** Draft method, for development use, may change without warning *** // Return current host name, for use in public tcp:// endpoints. // If the host name is not resolvable, returns NULL. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zproc_hostname (void); // *** Draft method, for development use, may change without warning *** // Move the current process into the background. The precise effect // depends on the operating system. On POSIX boxes, moves to a specified // working directory (if specified), closes all file handles, reopens // stdin, stdout, and stderr to the null device, and sets the process to // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there // was an error. CZMQ_EXPORT void zproc_daemonize (const char *workdir); // *** Draft method, for development use, may change without warning *** // Drop the process ID into the lockfile, with exclusive lock, and // switch the process to the specified group and/or user. Any of the // arguments may be null, indicating a no-op. Returns 0 on success, // -1 on failure. Note if you combine this with zsys_daemonize, run // after, not before that method, or the lockfile will hold the wrong // process ID. CZMQ_EXPORT void zproc_run_as (const char *lockfile, const char *group, const char *user); // *** Draft method, for development use, may change without warning *** // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zproc_set_io_threads (size_t io_threads); // *** Draft method, for development use, may change without warning *** // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zproc_set_max_sockets (size_t max_sockets); // *** Draft method, for development use, may change without warning *** // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". CZMQ_EXPORT void zproc_set_biface (const char *value); // *** Draft method, for development use, may change without warning *** // Return network interface to use for broadcasts, or "" if none was set. CZMQ_EXPORT const char * zproc_biface (void); // *** Draft method, for development use, may change without warning *** // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. CZMQ_EXPORT void zproc_set_log_ident (const char *value); // *** Draft method, for development use, may change without warning *** // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. CZMQ_EXPORT void zproc_set_log_sender (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. CZMQ_EXPORT void zproc_set_log_system (bool logsystem); // *** Draft method, for development use, may change without warning *** // Log error condition - highest priority CZMQ_EXPORT void zproc_log_error (const char *format, ...) CHECK_PRINTF (1); // *** Draft method, for development use, may change without warning *** // Log warning condition - high priority CZMQ_EXPORT void zproc_log_warning (const char *format, ...) CHECK_PRINTF (1); // *** Draft method, for development use, may change without warning *** // Log normal, but significant, condition - normal priority CZMQ_EXPORT void zproc_log_notice (const char *format, ...) CHECK_PRINTF (1); // *** Draft method, for development use, may change without warning *** // Log informational message - low priority CZMQ_EXPORT void zproc_log_info (const char *format, ...) CHECK_PRINTF (1); // *** Draft method, for development use, may change without warning *** // Log debug-level message - lowest priority CZMQ_EXPORT void zproc_log_debug (const char *format, ...) CHECK_PRINTF (1); // *** Draft method, for development use, may change without warning *** // Self test of this class. CZMQ_EXPORT void zproc_test (bool verbose); #endif // CZMQ_BUILD_DRAFT_API ``` Please add '@interface' section in './../src/zproc.c'. This is the class self test code: ```c #if defined (__WINDOWS__) printf ("SKIPPED (on Windows)\n"); return; #endif #if ZMQ_VERSION_MAJOR < 4 printf ("SKIPPED (on zmq pre-4)\n"); return; #endif int major, minor, patch; zsys_version (&major, &minor, &patch); if (major < 4) { printf ("SKIPPED (on zmq pre-4)\n"); return; } // @selftest // 0. initialization // find the right binary char *file = "src/zsp"; if (zsys_file_exists ("_build/../src/zsp")) file = "_build/../src/zsp"; else if (zsys_file_exists ("zsp")) file = "./zsp"; if (!zsys_file_exists (file)) { zsys_warning ("cannot detect zsp binary, %s does not exists", file); printf ("SKIPPED (zsp not found"); return; } // Create new subproc instance zproc_t *self = zproc_new (); zproc_set_verbose (self, verbose); assert (self); // join stdout of the process to zeromq socket // all data will be readable from zproc_stdout socket zproc_set_stdout (self, NULL); zlistx_t *args = zlistx_new (); zlistx_add_end (args, file); zlistx_add_end (args, "--stdout"); zproc_set_args (self, args); zhashx_t *env = zhashx_new (); zhashx_insert (env, "ZSP_MESSAGE", "czmq is great\n"); zproc_set_env (self, env); // execute the binary. It runs in own actor, which monitor the process and // pass data accross pipes and zeromq sockets zproc_run (self); zpoller_t *poller = zpoller_new (zproc_stdout (self), NULL); // kill the binary, it never ends, but the test must zclock_sleep (800); zproc_kill (self, SIGTERM); zproc_wait (self, true); // read the content from zproc_stdout - use zpoller and a loop bool stdout_read = false; while (!zsys_interrupted) { void *which = zpoller_wait (poller, 800); if (!which) break; if (which == zproc_stdout (self)) { stdout_read = true; zframe_t *frame; zsock_brecv (zproc_stdout (self), "f", &frame); assert (!strncmp( "czmq is great\n", (char*) zframe_data (frame), 14)); if (verbose) zframe_print (frame, "zproc_test"); zframe_destroy (&frame); continue; } // should not get there assert (false); } assert (stdout_read); zpoller_destroy (&poller); zproc_destroy (&self); ``` #### zproxy - run a steerable proxy in the background A zproxy actor switches messages between a frontend and a backend socket. It acts much like the zmq_proxy_steerable method, though it makes benefit of CZMQ's facilities, to be somewhat simpler to set-up. This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). This is the class interface: ```h // Create new zproxy actor instance. The proxy switches messages between // a frontend socket and a backend socket; use the FRONTEND and BACKEND // commands to configure these: // // zactor_t *proxy = zactor_new (zproxy, NULL); // // Destroy zproxy instance. This destroys the two sockets and stops any // message flow between them: // // zactor_destroy (&proxy); // // Note that all zproxy commands are synchronous, so your application always // waits for a signal from the actor after each command. // // Enable verbose logging of commands and activity: // // zstr_send (proxy, "VERBOSE"); // zsock_wait (proxy); // // Specify frontend socket type -- see zsock_type_str () -- and attach to // endpoints, see zsock_attach (). Note that a proxy socket is always // serverish: // // zstr_sendx (proxy, "FRONTEND", "XSUB", endpoints, NULL); // zsock_wait (proxy); // // Specify backend socket type -- see zsock_type_str () -- and attach to // endpoints, see zsock_attach (). Note that a proxy socket is always // serverish: // // zstr_sendx (proxy, "BACKEND", "XPUB", endpoints, NULL); // zsock_wait (proxy); // // Capture all proxied messages; these are delivered to the application // via an inproc PULL socket that you have already bound to the specified // endpoint: // // zstr_sendx (proxy, "CAPTURE", endpoint, NULL); // zsock_wait (proxy); // // Pause the proxy. A paused proxy will cease processing messages, causing // them to be queued up and potentially hit the high-water mark on the // frontend or backend socket, causing messages to be dropped, or writing // applications to block: // // zstr_sendx (proxy, "PAUSE", NULL); // zsock_wait (proxy); // // Resume the proxy. Note that the proxy starts automatically as soon as it // has a properly attached frontend and backend socket: // // zstr_sendx (proxy, "RESUME", NULL); // zsock_wait (proxy); // // Configure an authentication domain for the "FRONTEND" or "BACKEND" proxy // socket -- see zsock_set_zap_domain (). Call before binding socket: // // zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); // zsock_wait (proxy); // // Configure PLAIN authentication for the "FRONTEND" or "BACKEND" proxy // socket -- see zsock_set_plain_server (). Call before binding socket: // // zstr_sendx (proxy, "PLAIN", "BACKEND", NULL); // zsock_wait (proxy); // // Configure CURVE authentication for the "FRONTEND" or "BACKEND" proxy // socket -- see zsock_set_curve_server () -- specifying both the public and // secret keys of a certificate as Z85 armored strings -- see // zcert_public_txt () and zcert_secret_txt (). Call before binding socket: // // zstr_sendx (proxy, "CURVE", "FRONTEND", public_txt, secret_txt, NULL); // zsock_wait (proxy); // // This is the zproxy constructor as a zactor_fn; the argument is a // character string specifying frontend and backend socket types as two // uppercase strings separated by a hyphen: CZMQ_EXPORT void zproxy (zsock_t *pipe, void *unused); // Selftest CZMQ_EXPORT void zproxy_test (bool verbose); ``` Please add '@interface' section in './../src/zproxy.c'. This is the class self test code: ```c // Create and configure our proxy zactor_t *proxy = zactor_new (zproxy, NULL); assert (proxy); if (verbose) { zstr_sendx (proxy, "VERBOSE", NULL); zsock_wait (proxy); } zstr_sendx (proxy, "FRONTEND", "PULL", "inproc://frontend", NULL); zsock_wait (proxy); zstr_sendx (proxy, "BACKEND", "PUSH", "inproc://backend", NULL); zsock_wait (proxy); // Connect application sockets to proxy zsock_t *faucet = zsock_new_push (">inproc://frontend"); assert (faucet); zsock_t *sink = zsock_new_pull (">inproc://backend"); assert (sink); // Send some messages and check they arrived char *hello, *world; zstr_sendx (faucet, "Hello", "World", NULL); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); // Test pause/resume functionality zstr_sendx (proxy, "PAUSE", NULL); zsock_wait (proxy); zstr_sendx (faucet, "Hello", "World", NULL); zsock_set_rcvtimeo (sink, 100); zstr_recvx (sink, &hello, &world, NULL); assert (!hello && !world); zstr_sendx (proxy, "RESUME", NULL); zsock_wait (proxy); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); // Test capture functionality zsock_t *capture = zsock_new_pull ("inproc://capture"); assert (capture); // Switch on capturing, check that it works zstr_sendx (proxy, "CAPTURE", "inproc://capture", NULL); zsock_wait (proxy); zstr_sendx (faucet, "Hello", "World", NULL); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); zstr_recvx (capture, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); zsock_destroy (&faucet); zsock_destroy (&sink); zsock_destroy (&capture); zactor_destroy (&proxy); // Test socket creation dependency proxy = zactor_new (zproxy, NULL); assert (proxy); #ifdef WIN32 sink = zsock_new_sub(">inproc://backend", "whatever"); #else sink = zsock_new_sub (">ipc://backend", "whatever"); #endif // WIN32 assert (sink); #ifdef WIN32 zstr_sendx (proxy, "BACKEND", "XPUB", "inproc://backend", NULL); #else zstr_sendx(proxy, "BACKEND", "XPUB", "ipc://backend", NULL); #endif zsock_wait (proxy); zsock_destroy(&sink); zactor_destroy(&proxy); #if (ZMQ_VERSION_MAJOR == 4) // Test authentication functionality # define TESTDIR ".test_zproxy" // Create temporary directory for test files zsys_dir_create (TESTDIR); char *frontend = NULL; char *backend = NULL; // Check there's no authentication s_create_test_sockets (&proxy, &faucet, &sink, verbose); s_bind_test_sockets (proxy, &frontend, &backend); bool success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // Install the authenticator zactor_t *auth = zactor_new (zauth, NULL); assert (auth); if (verbose) { zstr_sendx (auth, "VERBOSE", NULL); zsock_wait (auth); } // Check there's no authentication on a default NULL server s_bind_test_sockets (proxy, &frontend, &backend); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // When we set a domain on the server, we switch on authentication // for NULL sockets, but with no policies, the client connection // will be allowed. zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // Blacklist 127.0.0.1, connection should fail zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zstr_sendx (auth, "DENY", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, false); assert (!success); // Whitelist our address, which overrides the blacklist zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); zsock_wait (proxy); zstr_sendx (proxy, "DOMAIN", "BACKEND", "global", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zstr_sendx (auth, "ALLOW", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // Try PLAIN authentication // Test negative case (no server-side passwords defined) zstr_sendx (proxy, "PLAIN", "FRONTEND", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zsock_set_plain_username (faucet, "admin"); zsock_set_plain_password (faucet, "Password"); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, false); assert (!success); // Test positive case (server-side passwords defined) FILE *password = fopen (TESTDIR "/password-file", "w"); assert (password); fprintf (password, "admin=Password\n"); fclose (password); zstr_sendx (proxy, "PLAIN", "FRONTEND", NULL); zsock_wait (proxy); zstr_sendx (proxy, "PLAIN", "BACKEND", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zsock_set_plain_username (faucet, "admin"); zsock_set_plain_password (faucet, "Password"); zsock_set_plain_username (sink, "admin"); zsock_set_plain_password (sink, "Password"); zstr_sendx (auth, "PLAIN", TESTDIR "/password-file", NULL); zsock_wait (auth); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // Test negative case (bad client password) zstr_sendx (proxy, "PLAIN", "FRONTEND", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zsock_set_plain_username (faucet, "admin"); zsock_set_plain_password (faucet, "Bogus"); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, false); assert (!success); if (zsys_has_curve ()) { // We'll create two new certificates and save the client public // certificate on disk zcert_t *server_cert = zcert_new (); assert (server_cert); zcert_t *client_cert = zcert_new (); assert (client_cert); const char *public_key = zcert_public_txt (server_cert); const char *secret_key = zcert_secret_txt (server_cert); // Try CURVE authentication // Test without setting-up any authentication zstr_sendx (proxy, "CURVE", "FRONTEND", public_key, secret_key, NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zcert_apply (client_cert, faucet); zsock_set_curve_serverkey (faucet, public_key); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, false); assert (!success); // Test CURVE_ALLOW_ANY zstr_sendx (proxy, "CURVE", "FRONTEND", public_key, secret_key, NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zcert_apply (client_cert, faucet); zsock_set_curve_serverkey (faucet, public_key); zstr_sendx (auth, "CURVE", CURVE_ALLOW_ANY, NULL); zsock_wait (auth); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // Test with client certificate file in authentication folder zstr_sendx (proxy, "CURVE", "FRONTEND", public_key, secret_key, NULL); zsock_wait (proxy); zstr_sendx (proxy, "CURVE", "BACKEND", public_key, secret_key, NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zcert_apply (client_cert, faucet); zsock_set_curve_serverkey (faucet, public_key); zcert_apply (client_cert, sink); zsock_set_curve_serverkey (sink, public_key); zcert_save_public (client_cert, TESTDIR "/mycert.txt"); zstr_sendx (auth, "CURVE", TESTDIR, NULL); zsock_wait (auth); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); zcert_destroy (&server_cert); zcert_destroy (&client_cert); } // Remove the authenticator and check a normal connection works zactor_destroy (&auth); s_bind_test_sockets (proxy, &frontend, &backend); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // Cleanup zsock_destroy (&faucet); zsock_destroy (&sink); zactor_destroy (&proxy); zstr_free (&frontend); zstr_free (&backend); // Delete temporary directory and test files zsys_file_delete (TESTDIR "/password-file"); zsys_file_delete (TESTDIR "/mycert.txt"); zsys_dir_delete (TESTDIR); #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zrex - work with regular expressions Wraps a very simple regular expression library (SLRE) as a CZMQ class. Supports this syntax: ^ Match beginning of a buffer $ Match end of a buffer () Grouping and substring capturing [...] Match any character from set [^...] Match any character but ones from set . Match any character \s Match whitespace \S Match non-whitespace \d Match decimal digit \D Match non decimal digit \a Match alphabetic character \A Match non-alphabetic character \w Match alphanumeric character \W Match non-alphanumeric character \r Match carriage return \n Match newline + Match one or more times (greedy) +? Match one or more times (non-greedy) * Match zero or more times (greedy) *? Match zero or more times (non-greedy) ? Match zero or once \xDD Match byte with hex value 0xDD \meta Match one of the meta character: ^$().[*+?\ Please add '@discuss' section in './../src/zrex.c'. This is the class interface: ```h // Constructor. Optionally, sets an expression against which we can match // text and capture hits. If there is an error in the expression, reports // zrex_valid() as false and provides the error in zrex_strerror(). If you // set a pattern, you can call zrex_matches() to test it against text. CZMQ_EXPORT zrex_t * zrex_new (const char *expression); // Destructor CZMQ_EXPORT void zrex_destroy (zrex_t **self_p); // Return true if the expression was valid and compiled without errors. CZMQ_EXPORT bool zrex_valid (zrex_t *self); // Return the error message generated during compilation of the expression. CZMQ_EXPORT const char * zrex_strerror (zrex_t *self); // Returns true if the text matches the previously compiled expression. // Use this method to compare one expression against many strings. CZMQ_EXPORT bool zrex_matches (zrex_t *self, const char *text); // Returns true if the text matches the supplied expression. Use this // method to compare one string against several expressions. CZMQ_EXPORT bool zrex_eq (zrex_t *self, const char *text, const char *expression); // Returns number of hits from last zrex_matches or zrex_eq. If the text // matched, returns 1 plus the number of capture groups. If the text did // not match, returns zero. To retrieve individual capture groups, call // zrex_hit (). CZMQ_EXPORT int zrex_hits (zrex_t *self); // Returns the Nth capture group from the last expression match, where // N is 0 to the value returned by zrex_hits(). Capture group 0 is the // whole matching string. Sequence 1 is the first capture group, if any, // and so on. CZMQ_EXPORT const char * zrex_hit (zrex_t *self, uint index); // Fetches hits into string variables provided by caller; this makes for // nicer code than accessing hits by index. Caller should not modify nor // free the returned values. Returns number of strings returned. This // method starts at hit 1, i.e. first capture group, as hit 0 is always // the original matched string. CZMQ_EXPORT int zrex_fetch (zrex_t *self, const char **string_p, ...); // Self test of this class CZMQ_EXPORT void zrex_test (bool verbose); ``` Please add '@interface' section in './../src/zrex.c'. This is the class self test code: ```c // This shows the pattern of matching many lines to a single pattern zrex_t *rex = zrex_new ("\\d+-\\d+-\\d+"); assert (rex); assert (zrex_valid (rex)); bool matches = zrex_matches (rex, "123-456-789"); assert (matches); assert (zrex_hits (rex) == 1); assert (streq (zrex_hit (rex, 0), "123-456-789")); assert (zrex_hit (rex, 1) == NULL); zrex_destroy (&rex); // Here we pick out hits using capture groups rex = zrex_new ("(\\d+)-(\\d+)-(\\d+)"); assert (rex); assert (zrex_valid (rex)); matches = zrex_matches (rex, "123-456-ABC"); assert (!matches); matches = zrex_matches (rex, "123-456-789"); assert (matches); assert (zrex_hits (rex) == 4); assert (streq (zrex_hit (rex, 0), "123-456-789")); assert (streq (zrex_hit (rex, 1), "123")); assert (streq (zrex_hit (rex, 2), "456")); assert (streq (zrex_hit (rex, 3), "789")); zrex_destroy (&rex); // This shows the pattern of matching one line against many // patterns and then handling the case when it hits rex = zrex_new (NULL); // No initial pattern assert (rex); char *input = "Mechanism: CURVE"; matches = zrex_eq (rex, input, "Version: (.+)"); assert (!matches); assert (zrex_hits (rex) == 0); matches = zrex_eq (rex, input, "Mechanism: (.+)"); assert (matches); assert (zrex_hits (rex) == 2); const char *mechanism; zrex_fetch (rex, &mechanism, NULL); assert (streq (zrex_hit (rex, 1), "CURVE")); assert (streq (mechanism, "CURVE")); zrex_destroy (&rex); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zsock - high-level socket API that hides libzmq contexts and sockets The zsock class wraps the libzmq socket handle (a void *) with a proper structure that follows the CLASS rules for construction and destruction. Some zsock methods take a void * "polymorphic" reference, which can be either a zsock_t or a zactor_t reference, or a libzmq void *. Please add '@discuss' section in './../src/zsock.c'. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Create a new socket. Returns the new socket, or NULL if the new socket // could not be created. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection. This can have // performance implications if you use a LOT of sockets. To turn off this // redirection behaviour, define ZSOCK_NOCHECK. CZMQ_EXPORT zsock_t * zsock_new (int type); // Create a PUB socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_pub (const char *endpoint); // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. CZMQ_EXPORT zsock_t * zsock_new_sub (const char *endpoint, const char *subscribe); // Create a REQ socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_req (const char *endpoint); // Create a REP socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_rep (const char *endpoint); // Create a DEALER socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_dealer (const char *endpoint); // Create a ROUTER socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_router (const char *endpoint); // Create a PUSH socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_push (const char *endpoint); // Create a PULL socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_pull (const char *endpoint); // Create an XPUB socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_xpub (const char *endpoint); // Create an XSUB socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_xsub (const char *endpoint); // Create a PAIR socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_pair (const char *endpoint); // Create a STREAM socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_stream (const char *endpoint); // Destroy the socket. You must use this for any socket created via the // zsock_new method. CZMQ_EXPORT void zsock_destroy (zsock_t **self_p); // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. CZMQ_EXPORT int zsock_bind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Returns last bound endpoint, if any. CZMQ_EXPORT const char * zsock_endpoint (zsock_t *self); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsock_unbind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. CZMQ_EXPORT int zsock_connect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsock_disconnect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). CZMQ_EXPORT int zsock_attach (zsock_t *self, const char *endpoints, bool serverish); // Returns socket type as printable constant string. CZMQ_EXPORT const char * zsock_type_str (zsock_t *self); // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. CZMQ_EXPORT int zsock_send (void *self, const char *picture, ...); // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. CZMQ_EXPORT int zsock_vsend (void *self, const char *picture, va_list argptr); // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // U = zuuid_t * (creates a zuuid with the data) // h = zhashx_t ** (creates zhashx) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. CZMQ_EXPORT int zsock_recv (void *self, const char *picture, ...); // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. CZMQ_EXPORT int zsock_vrecv (void *self, const char *picture, va_list argptr); // Send a binary encoded 'picture' message to the socket (or actor). This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations. The pattern argument is a string that defines the // type of each argument. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0-255 chars type = "string" // S char *, 0-2^32-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // u zuuid_t * type = "uuid" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments. Returns 0 if // successful, -1 if sending failed for any reason. CZMQ_EXPORT int zsock_bsend (void *self, const char *picture, ...); // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. // For types 1, 2, 4 and 8 the caller must allocate the memory itself before // calling zsock_brecv. // For types S, the caller must free the value once finished with it, as // zsock_brecv will allocate the buffer. // For type s, the caller must not free the value as it is stored in a // local cache for performance purposes. // For types c, f, u and m the caller must call the appropriate destructor // depending on the object as zsock_brecv will create new objects. // For type p the caller must coordinate with the sender, as it is just a // pointer value being passed. CZMQ_EXPORT int zsock_brecv (void *self, const char *picture, ...); // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. CZMQ_EXPORT void zsock_set_unbounded (void *self); // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zsock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. CZMQ_EXPORT int zsock_signal (void *self, byte status); // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. CZMQ_EXPORT int zsock_wait (void *self); // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. CZMQ_EXPORT void zsock_flush (void *self); // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. CZMQ_EXPORT bool zsock_is (void *self); // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. CZMQ_EXPORT void * zsock_resolve (void *self); // Get socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_heartbeat_ivl (void *self); // Set socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl); // Get socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_heartbeat_ttl (void *self); // Set socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl); // Get socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_heartbeat_timeout (void *self); // Set socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout); // Get socket option `use_fd`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_use_fd (void *self); // Set socket option `use_fd`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_use_fd (void *self, int use_fd); // Set socket option `xpub_manual`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_xpub_manual (void *self, int xpub_manual); // Set socket option `xpub_welcome_msg`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_xpub_welcome_msg (void *self, const char *xpub_welcome_msg); // Set socket option `stream_notify`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_stream_notify (void *self, int stream_notify); // Get socket option `invert_matching`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_invert_matching (void *self); // Set socket option `invert_matching`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_invert_matching (void *self, int invert_matching); // Set socket option `xpub_verboser`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_xpub_verboser (void *self, int xpub_verboser); // Get socket option `connect_timeout`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_connect_timeout (void *self); // Set socket option `connect_timeout`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_connect_timeout (void *self, int connect_timeout); // Get socket option `tcp_maxrt`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_tcp_maxrt (void *self); // Set socket option `tcp_maxrt`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_tcp_maxrt (void *self, int tcp_maxrt); // Get socket option `thread_safe`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_thread_safe (void *self); // Get socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_multicast_maxtpdu (void *self); // Set socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu); // Get socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_vmci_buffer_size (void *self); // Set socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size); // Get socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_vmci_buffer_min_size (void *self); // Set socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size); // Get socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_vmci_buffer_max_size (void *self); // Set socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size); // Get socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_vmci_connect_timeout (void *self); // Set socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout); // Get socket option `tos`. // Available from libzmq 4.1.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_tos (void *self); // Set socket option `tos`. // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_tos (void *self, int tos); // Set socket option `router_handover`. // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_router_handover (void *self, int router_handover); // Set socket option `connect_rid`. // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_connect_rid (void *self, const char *connect_rid); // Set socket option `connect_rid` from 32-octet binary // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_connect_rid_bin (void *self, const byte *connect_rid); // Get socket option `handshake_ivl`. // Available from libzmq 4.1.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_handshake_ivl (void *self); // Set socket option `handshake_ivl`. // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_handshake_ivl (void *self, int handshake_ivl); // Get socket option `socks_proxy`. // Available from libzmq 4.1.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_socks_proxy (void *self); // Set socket option `socks_proxy`. // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_socks_proxy (void *self, const char *socks_proxy); // Set socket option `xpub_nodrop`. // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_xpub_nodrop (void *self, int xpub_nodrop); // Set socket option `router_mandatory`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_router_mandatory (void *self, int router_mandatory); // Set socket option `probe_router`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_probe_router (void *self, int probe_router); // Set socket option `req_relaxed`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_req_relaxed (void *self, int req_relaxed); // Set socket option `req_correlate`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_req_correlate (void *self, int req_correlate); // Set socket option `conflate`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_conflate (void *self, int conflate); // Get socket option `zap_domain`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_zap_domain (void *self); // Set socket option `zap_domain`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_zap_domain (void *self, const char *zap_domain); // Get socket option `mechanism`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_mechanism (void *self); // Get socket option `plain_server`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_plain_server (void *self); // Set socket option `plain_server`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_plain_server (void *self, int plain_server); // Get socket option `plain_username`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_plain_username (void *self); // Set socket option `plain_username`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_plain_username (void *self, const char *plain_username); // Get socket option `plain_password`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_plain_password (void *self); // Set socket option `plain_password`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_plain_password (void *self, const char *plain_password); // Get socket option `curve_server`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_curve_server (void *self); // Set socket option `curve_server`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_server (void *self, int curve_server); // Get socket option `curve_publickey`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_curve_publickey (void *self); // Set socket option `curve_publickey`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_publickey (void *self, const char *curve_publickey); // Set socket option `curve_publickey` from 32-octet binary // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey); // Get socket option `curve_secretkey`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_curve_secretkey (void *self); // Set socket option `curve_secretkey`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_secretkey (void *self, const char *curve_secretkey); // Set socket option `curve_secretkey` from 32-octet binary // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey); // Get socket option `curve_serverkey`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_curve_serverkey (void *self); // Set socket option `curve_serverkey`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_serverkey (void *self, const char *curve_serverkey); // Set socket option `curve_serverkey` from 32-octet binary // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey); // Get socket option `gssapi_server`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_gssapi_server (void *self); // Set socket option `gssapi_server`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_gssapi_server (void *self, int gssapi_server); // Get socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_gssapi_plaintext (void *self); // Set socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext); // Get socket option `gssapi_principal`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_gssapi_principal (void *self); // Set socket option `gssapi_principal`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_gssapi_principal (void *self, const char *gssapi_principal); // Get socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_gssapi_service_principal (void *self); // Set socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_gssapi_service_principal (void *self, const char *gssapi_service_principal); // Get socket option `ipv6`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_ipv6 (void *self); // Set socket option `ipv6`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_ipv6 (void *self, int ipv6); // Get socket option `immediate`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_immediate (void *self); // Set socket option `immediate`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_immediate (void *self, int immediate); // Get socket option `sndhwm`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_sndhwm (void *self); // Set socket option `sndhwm`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_sndhwm (void *self, int sndhwm); // Get socket option `rcvhwm`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_rcvhwm (void *self); // Set socket option `rcvhwm`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_rcvhwm (void *self, int rcvhwm); // Get socket option `maxmsgsize`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_maxmsgsize (void *self); // Set socket option `maxmsgsize`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_maxmsgsize (void *self, int maxmsgsize); // Get socket option `multicast_hops`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_multicast_hops (void *self); // Set socket option `multicast_hops`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_multicast_hops (void *self, int multicast_hops); // Set socket option `xpub_verbose`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_xpub_verbose (void *self, int xpub_verbose); // Get socket option `tcp_keepalive`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_tcp_keepalive (void *self); // Set socket option `tcp_keepalive`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); // Get socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_tcp_keepalive_idle (void *self); // Set socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); // Get socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_tcp_keepalive_cnt (void *self); // Set socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); // Get socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_tcp_keepalive_intvl (void *self); // Set socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); // Get socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_tcp_accept_filter (void *self); // Set socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_tcp_accept_filter (void *self, const char *tcp_accept_filter); // Get socket option `last_endpoint`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_last_endpoint (void *self); // Set socket option `router_raw`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_router_raw (void *self, int router_raw); // Get socket option `ipv4only`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_ipv4only (void *self); // Set socket option `ipv4only`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_ipv4only (void *self, int ipv4only); // Set socket option `delay_attach_on_connect`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); // Get socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_hwm (void *self); // Set socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. CZMQ_EXPORT void zsock_set_hwm (void *self, int hwm); // Get socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_swap (void *self); // Set socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. CZMQ_EXPORT void zsock_set_swap (void *self, int swap); // Get socket option `affinity`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_affinity (void *self); // Set socket option `affinity`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); // Get socket option `identity`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_identity (void *self); // Set socket option `identity`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_identity (void *self, const char *identity); // Get socket option `rate`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_rate (void *self); // Set socket option `rate`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_rate (void *self, int rate); // Get socket option `recovery_ivl`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_recovery_ivl (void *self); // Set socket option `recovery_ivl`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); // Get socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_recovery_ivl_msec (void *self); // Set socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. CZMQ_EXPORT void zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec); // Get socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_mcast_loop (void *self); // Set socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. CZMQ_EXPORT void zsock_set_mcast_loop (void *self, int mcast_loop); // Get socket option `rcvtimeo`. // Available from libzmq 2.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_rcvtimeo (void *self); // Set socket option `rcvtimeo`. // Available from libzmq 2.2.0. CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); // Get socket option `sndtimeo`. // Available from libzmq 2.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_sndtimeo (void *self); // Set socket option `sndtimeo`. // Available from libzmq 2.2.0. CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); // Get socket option `sndbuf`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_sndbuf (void *self); // Set socket option `sndbuf`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); // Get socket option `rcvbuf`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_rcvbuf (void *self); // Set socket option `rcvbuf`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); // Get socket option `linger`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_linger (void *self); // Set socket option `linger`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_linger (void *self, int linger); // Get socket option `reconnect_ivl`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_reconnect_ivl (void *self); // Set socket option `reconnect_ivl`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); // Get socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); // Set socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); // Get socket option `backlog`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_backlog (void *self); // Set socket option `backlog`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); // Set socket option `subscribe`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_subscribe (void *self, const char *subscribe); // Set socket option `unsubscribe`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char *unsubscribe); // Get socket option `type`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_type (void *self); // Get socket option `rcvmore`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_rcvmore (void *self); // Get socket option `fd`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT SOCKET zsock_fd (void *self); // Get socket option `events`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_events (void *self); // Self test of this class. CZMQ_EXPORT void zsock_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Create a SERVER socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_server (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Create a CLIENT socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_client (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Create a RADIO socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_radio (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Create a DISH socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_dish (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Create a GATHER socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_gather (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Create a SCATTER socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_scatter (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Return socket routing ID if any. This returns 0 if the socket is not // of type ZMQ_SERVER or if no request was already received on it. CZMQ_EXPORT uint32_t zsock_routing_id (zsock_t *self); // *** Draft method, for development use, may change without warning *** // Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. // This will be used when sending messages on the socket via the zsock API. CZMQ_EXPORT void zsock_set_routing_id (zsock_t *self, uint32_t routing_id); // *** Draft method, for development use, may change without warning *** // Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. CZMQ_EXPORT int zsock_join (void *self, const char *group); // *** Draft method, for development use, may change without warning *** // Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. CZMQ_EXPORT int zsock_leave (void *self, const char *group); #endif // CZMQ_BUILD_DRAFT_API ``` Please add '@interface' section in './../src/zsock.c'. This is the class self test code: ```c zsock_t *writer = zsock_new_push ("@tcp://127.0.0.1:5560"); assert (writer); assert (zsock_resolve (writer) != writer); assert (streq (zsock_type_str (writer), "PUSH")); int rc; #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Check unbind rc = zsock_unbind (writer, "tcp://127.0.0.1:%d", 5560); assert (rc == 0); // In some cases and especially when running under Valgrind, doing // a bind immediately after an unbind causes an EADDRINUSE error. // Even a short sleep allows the OS to release the port for reuse. zclock_sleep (100); // Bind again rc = zsock_bind (writer, "tcp://127.0.0.1:%d", 5560); assert (rc == 5560); assert (streq (zsock_endpoint (writer), "tcp://127.0.0.1:5560")); #endif zsock_t *reader = zsock_new_pull (">tcp://127.0.0.1:5560"); assert (reader); assert (zsock_resolve (reader) != reader); assert (streq (zsock_type_str (reader), "PULL")); // Basic Hello, World zstr_send (writer, "Hello, World"); zmsg_t *msg = zmsg_recv (reader); assert (msg); char *string = zmsg_popstr (msg); assert (streq (string, "Hello, World")); free (string); zmsg_destroy (&msg); // Test resolve libzmq socket #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) void *zmq_ctx = zmq_ctx_new (); #else void *zmq_ctx = zmq_ctx_new (1); #endif assert (zmq_ctx); void *zmq_sock = zmq_socket (zmq_ctx, ZMQ_PUB); assert (zmq_sock); assert (zsock_resolve (zmq_sock) == zmq_sock); zmq_close (zmq_sock); zmq_ctx_term (zmq_ctx); // Test resolve zsock zsock_t *resolve = zsock_new_pub("@tcp://127.0.0.1:5561"); assert (resolve); assert (zsock_resolve (resolve) == resolve->handle); zsock_destroy (&resolve); // Test resolve FD SOCKET fd = zsock_fd (reader); assert (zsock_resolve ((void *) &fd) == NULL); // Test binding to ephemeral ports, sequential and random int port = zsock_bind (writer, "tcp://127.0.0.1:*"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:*[50000-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:*[-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127.0.0.1:*[60000-60050]"); assert (port >= 60000 && port <= 60050); port = zsock_bind (writer, "tcp://127.0.0.1:!"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:![50000-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:![-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127.0.0.1:![60000-60050]"); assert (port >= 60000 && port <= 60050); // Test zsock_attach method zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); rc = zsock_attach (server, "@inproc://myendpoint,tcp://127.0.0.1:5556,inproc://others", true); assert (rc == 0); rc = zsock_attach (server, "", false); assert (rc == 0); rc = zsock_attach (server, NULL, true); assert (rc == 0); rc = zsock_attach (server, ">a,@b, c,, ", false); assert (rc == -1); zsock_destroy (&server); // Test zsock_endpoint method rc = zsock_bind (writer, "inproc://test.%s", "writer"); assert (rc == 0); assert (streq (zsock_endpoint (writer), "inproc://test.writer")); // Test error state when connecting to an invalid socket type // ('txp://' instead of 'tcp://', typo intentional) rc = zsock_connect (reader, "txp://127.0.0.1:5560"); assert (rc == -1); // Test signal/wait methods rc = zsock_signal (writer, 123); assert (rc == 0); rc = zsock_wait (reader); assert (rc == 123); // Test zsock_send/recv pictures uint8_t number1 = 123; uint16_t number2 = 123 * 123; uint32_t number4 = 123 * 123; number4 *= 123; uint32_t number4_MAX = UINT32_MAX; uint64_t number8 = 123 * 123; number8 *= 123; number8 *= 123; uint64_t number8_MAX = UINT64_MAX; zchunk_t *chunk = zchunk_new ("HELLO", 5); assert (chunk); zframe_t *frame = zframe_new ("WORLD", 5); assert (frame); zhashx_t *hash = zhashx_new (); assert (hash); zuuid_t *uuid = zuuid_new (); assert (uuid); zhashx_set_destructor (hash, (zhashx_destructor_fn *) zstr_free); zhashx_set_duplicator (hash, (zhashx_duplicator_fn *) strdup); zhashx_insert (hash, "1", "value A"); zhashx_insert (hash, "2", "value B"); char *original = "pointer"; // Test zsock_recv into each supported type zsock_send (writer, "i124488zsbcfUhp", -12345, number1, number2, number4, number4_MAX, number8, number8_MAX, "This is a string", "ABCDE", 5, chunk, frame, uuid, hash, original); char *uuid_str = strdup (zuuid_str (uuid)); zchunk_destroy (&chunk); zframe_destroy (&frame); zuuid_destroy (&uuid); zhashx_destroy (&hash); int integer; byte *data; size_t size; char *pointer; number8_MAX = number8 = number4_MAX = number4 = number2 = number1 = 0ULL; rc = zsock_recv (reader, "i124488zsbcfUhp", &integer, &number1, &number2, &number4, &number4_MAX, &number8, &number8_MAX, &string, &data, &size, &chunk, &frame, &uuid, &hash, &pointer); assert (rc == 0); assert (integer == -12345); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number4_MAX == UINT32_MAX); assert (number8 == 123 * 123 * 123 * 123); assert (number8_MAX == UINT64_MAX); assert (streq (string, "This is a string")); assert (memcmp (data, "ABCDE", 5) == 0); assert (size == 5); assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0); assert (zchunk_size (chunk) == 5); assert (streq (uuid_str, zuuid_str (uuid))); assert (memcmp (zframe_data (frame), "WORLD", 5) == 0); assert (zframe_size (frame) == 5); char *value = (char *) zhashx_lookup (hash, "1"); assert (streq (value, "value A")); value = (char *) zhashx_lookup (hash, "2"); assert (streq (value, "value B")); assert (original == pointer); free (string); free (data); free (uuid_str); zframe_destroy (&frame); zchunk_destroy (&chunk); zhashx_destroy (&hash); zuuid_destroy (&uuid); // Test zsock_recv of short message; this lets us return a failure // with a status code and then nothing else; the receiver will get // the status code and NULL/zero for all other values zsock_send (writer, "i", -1); zsock_recv (reader, "izsbcfp", &integer, &string, &data, &size, &chunk, &frame, &pointer); assert (integer == -1); assert (string == NULL); assert (data == NULL); assert (size == 0); assert (chunk == NULL); assert (frame == NULL); assert (pointer == NULL); msg = zmsg_new (); zmsg_addstr (msg, "frame 1"); zmsg_addstr (msg, "frame 2"); zsock_send (writer, "szm", "header", msg); zmsg_destroy (&msg); zsock_recv (reader, "szm", &string, &msg); assert (streq ("header", string)); assert (zmsg_size (msg) == 2); assert (zframe_streq (zmsg_first (msg), "frame 1")); assert (zframe_streq (zmsg_next (msg), "frame 2")); zstr_free (&string); zmsg_destroy (&msg); // Test zsock_recv with null arguments chunk = zchunk_new ("HELLO", 5); assert (chunk); frame = zframe_new ("WORLD", 5); assert (frame); zsock_send (writer, "izsbcfp", -12345, "This is a string", "ABCDE", 5, chunk, frame, original); zframe_destroy (&frame); zchunk_destroy (&chunk); zsock_recv (reader, "izsbcfp", &integer, NULL, NULL, NULL, &chunk, NULL, NULL); assert (integer == -12345); assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0); assert (zchunk_size (chunk) == 5); zchunk_destroy (&chunk); // Test zsock_bsend/brecv pictures with binary encoding frame = zframe_new ("Hello", 5); chunk = zchunk_new ("World", 5); msg = zmsg_new (); zmsg_addstr (msg, "Hello"); zmsg_addstr (msg, "World"); zsock_bsend (writer, "1248sSpcfm", number1, number2, number4, number8, "Hello, World", "Goodbye cruel World!", original, chunk, frame, msg); zchunk_destroy (&chunk); zframe_destroy (&frame); zmsg_destroy (&msg); number8 = number4 = number2 = number1 = 0; char *longstr; zsock_brecv (reader, "1248sSpcfm", &number1, &number2, &number4, &number8, &string, &longstr, &pointer, &chunk, &frame, &msg); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "Hello, World")); assert (streq (longstr, "Goodbye cruel World!")); assert (pointer == original); zstr_free (&longstr); zchunk_destroy (&chunk); zframe_destroy (&frame); zmsg_destroy (&msg); #ifdef ZMQ_SERVER // Test zsock_bsend/brecv pictures with binary encoding on SERVER and CLIENT sockets server = zsock_new_server ("tcp://127.0.0.1:5561"); assert (server); zsock_t* client = zsock_new_client ("tcp://127.0.0.1:5561"); assert (client); // From client to server chunk = zchunk_new ("World", 5); zsock_bsend (client, "1248sSpc", number1, number2, number4, number8, "Hello, World", "Goodbye cruel World!", original, chunk); zchunk_destroy (&chunk); number8 = number4 = number2 = number1 = 0; zsock_brecv (server, "1248sSpc", &number1, &number2, &number4, &number8, &string, &longstr, &pointer, &chunk); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "Hello, World")); assert (streq (longstr, "Goodbye cruel World!")); assert (pointer == original); assert (zsock_routing_id (server)); zstr_free (&longstr); zchunk_destroy (&chunk); // From server to client chunk = zchunk_new ("World", 5); zsock_bsend (server, "1248sSpc", number1, number2, number4, number8, "Hello, World", "Goodbye cruel World!", original, chunk); zchunk_destroy (&chunk); number8 = number4 = number2 = number1 = 0; zsock_brecv (client, "1248sSpc", &number1, &number2, &number4, &number8, &string, &longstr, &pointer, &chunk); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "Hello, World")); assert (streq (longstr, "Goodbye cruel World!")); assert (pointer == original); assert (zsock_routing_id (client) == 0); zstr_free (&longstr); zchunk_destroy (&chunk); zsock_destroy (&client); zsock_destroy (&server); #endif #ifdef ZMQ_SCATTER zsock_t* gather = zsock_new_gather ("inproc://test-gather-scatter"); assert (gather); zsock_t* scatter = zsock_new_scatter ("inproc://test-gather-scatter"); assert (scatter); rc = zstr_send (scatter, "HELLO"); assert (rc == 0); char* message; message = zstr_recv (gather); assert (streq(message, "HELLO")); zstr_free (&message); zsock_destroy (&gather); zsock_destroy (&scatter); #endif // Check that we can send a zproto format message zsock_bsend (writer, "1111sS4", 0xAA, 0xA0, 0x02, 0x01, "key", "value", 1234); zgossip_msg_t *gossip = zgossip_msg_new (); zgossip_msg_recv (gossip, reader); assert (zgossip_msg_id (gossip) == ZGOSSIP_MSG_PUBLISH); zgossip_msg_destroy (&gossip); zsock_destroy (&reader); zsock_destroy (&writer); ``` #### zstr - sending and receiving strings The zstr class provides utility functions for sending and receiving C strings across ØMQ sockets. It sends strings without a terminating null, and appends a null byte on received strings. This class is for simple message sending. Memory Wire +-------------+---+ +---+-------------+ Send | S t r i n g | 0 | ----> | 6 | S t r i n g | +-------------+---+ +---+-------------+ Wire Heap +---+-------------+ +-------------+---+ Recv | 6 | S t r i n g | ----> | S t r i n g | 0 | +---+-------------+ +-------------+---+ This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zstr_recv (void *source); // Receive a series of strings (until NULL) from multipart data. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL. // Returns -1 if the message could not be read, else returns the // number of strings filled, zero or more. Free each returned string // using zstr_free(). If not enough strings are provided, remaining // multipart frames in the message are dropped. CZMQ_EXPORT int zstr_recvx (void *source, char **string_p, ...); // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". CZMQ_EXPORT int zstr_send (void *dest, const char *string); // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. CZMQ_EXPORT int zstr_sendm (void *dest, const char *string); // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). CZMQ_EXPORT int zstr_sendf (void *dest, const char *format, ...) CHECK_PRINTF (2); // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. CZMQ_EXPORT int zstr_sendfm (void *dest, const char *format, ...) CHECK_PRINTF (2); // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or -1 on error. CZMQ_EXPORT int zstr_sendx (void *dest, const char *string, ...); // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. CZMQ_EXPORT void zstr_free (char **string_p); // Self test of this class. CZMQ_EXPORT void zstr_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Accepts a void pointer and returns a fresh character string. If source // is null, returns an empty string. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zstr_str (void *source); #endif // CZMQ_BUILD_DRAFT_API ``` Please add '@interface' section in './../src/zstr.c'. This is the class self test code: ```c // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zstr.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zstr.test"); assert (input); // Send ten strings, five strings with MORE flag and then END int string_nbr; for (string_nbr = 0; string_nbr < 10; string_nbr++) zstr_sendf (output, "this is string %d", string_nbr); zstr_sendx (output, "This", "is", "almost", "the", "very", "END", NULL); // Read and count until we receive END string_nbr = 0; for (string_nbr = 0;; string_nbr++) { char *string = zstr_recv (input); assert (string); if (streq (string, "END")) { zstr_free (&string); break; } zstr_free (&string); } assert (string_nbr == 15); zsock_destroy (&input); zsock_destroy (&output); #if defined (ZMQ_SERVER) // Test SERVER/CLIENT over zstr zsock_t *server = zsock_new_server ("inproc://zstr-test-routing"); zsock_t *client = zsock_new_client ("inproc://zstr-test-routing");; assert (server); assert (client); // Try normal ping-pong to check reply routing ID int rc = zstr_send (client, "Hello"); assert (rc == 0); char *request = zstr_recv (server); assert (streq (request, "Hello")); assert (zsock_routing_id (server)); free (request); rc = zstr_send (server, "World"); assert (rc == 0); char *reply = zstr_recv (client); assert (streq (reply, "World")); free (reply); rc = zstr_sendf (server, "%s", "World"); assert (rc == 0); reply = zstr_recv (client); assert (streq (reply, "World")); free (reply); // Try ping-pong using sendx and recx rc = zstr_sendx (client, "Hello", NULL); assert (rc == 0); rc = zstr_recvx (server, &request, NULL); assert (rc >= 0); assert (streq (request, "Hello")); free (request); rc = zstr_sendx (server, "World", NULL); assert (rc == 0); rc = zstr_recvx (client, &reply, NULL); assert (rc >= 0); assert (streq (reply, "World")); free (reply); // Client and server disallow multipart rc = zstr_sendm (client, "Hello"); assert (rc == -1); rc = zstr_sendm (server, "World"); assert (rc == -1); zsock_destroy (&client); zsock_destroy (&server); #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zsys - system-level methods The zsys class provides a portable wrapper for system calls. We collect them here to reduce the number of weird #ifdefs in other classes. As far as possible, the bulk of CZMQ classes are fully portable. Please add '@discuss' section in './../src/zsys.c'. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Callback for interrupt signal handler typedef void (zsys_handler_fn) ( int signal_value); // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. CZMQ_EXPORT void * zsys_init (void); // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls. CZMQ_EXPORT void zsys_shutdown (void); // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void * zsys_socket (int type, const char *filename, size_t line_nbr); // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_close (void *handle, const char *filename, size_t line_nbr); // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT char * zsys_sockname (int socktype); // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. CZMQ_EXPORT zsock_t * zsys_create_pipe (zsock_t **backend_p); // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. CZMQ_EXPORT void zsys_handler_set (zsys_handler_fn *handler_fn); // Reset interrupt handler, call this at exit if needed CZMQ_EXPORT void zsys_handler_reset (void); // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void zsys_catch_interrupts (void); // Return 1 if file exists, else zero CZMQ_EXPORT bool zsys_file_exists (const char *filename); // Return file modification time. Returns 0 if the file does not exist. CZMQ_EXPORT time_t zsys_file_modified (const char *filename); // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. CZMQ_EXPORT int zsys_file_mode (const char *filename); // Delete file. Does not complain if the file is absent CZMQ_EXPORT int zsys_file_delete (const char *filename); // Check if file is 'stable' CZMQ_EXPORT bool zsys_file_stable (const char *filename); // Create a file path if it doesn't exist. The file path is treated as // printf format. CZMQ_EXPORT int zsys_dir_create (const char *pathname, ...); // Remove a file path if empty; the pathname is treated as printf format. CZMQ_EXPORT int zsys_dir_delete (const char *pathname, ...); // Move to a specified working directory. Returns 0 if OK, -1 if this failed. CZMQ_EXPORT int zsys_dir_change (const char *pathname); // Set private file creation mode; all files created from here will be // readable/writable by the owner only. CZMQ_EXPORT void zsys_file_mode_private (void); // Reset default file creation mode; all files created from here will use // process file mode defaults. CZMQ_EXPORT void zsys_file_mode_default (void); // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. CZMQ_EXPORT void zsys_version (int *major, int *minor, int *patch); // Format a string using printf formatting, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). CZMQ_EXPORT char * zsys_sprintf (const char *format, ...); // Format a string with a va_list argument, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). CZMQ_EXPORT char * zsys_vprintf (const char *format, va_list argptr); // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT SOCKET zsys_udp_new (bool routable); // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_udp_close (SOCKET handle); // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address, int addrlen); // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or // NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername, int peerlen); // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void zsys_socket_error (const char *reason); // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. CZMQ_EXPORT char * zsys_hostname (void); // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. CZMQ_EXPORT int zsys_daemonize (const char *workdir); // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. CZMQ_EXPORT int zsys_run_as (const char *lockfile, const char *group, const char *user); // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. CZMQ_EXPORT bool zsys_has_curve (void); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_io_threads (size_t io_threads); // Configure the scheduling policy of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY // is defined, that provides the default. // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_thread_sched_policy (int policy); // Configure the scheduling priority of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_PRIORITY is // defined, that provides the default. // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_thread_priority (int priority); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_max_sockets (size_t max_sockets); // Return maximum number of ZeroMQ sockets that the system will support. CZMQ_EXPORT size_t zsys_socket_limit (void); // Configure the maximum allowed size of a message sent. // The default is INT_MAX. CZMQ_EXPORT void zsys_set_max_msgsz (int max_msgsz); // Return maximum message size. CZMQ_EXPORT int zsys_max_msgsz (void); // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. CZMQ_EXPORT void zsys_set_linger (size_t linger); // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_sndhwm (size_t sndhwm); // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_rcvhwm (size_t rcvhwm); // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_pipehwm (size_t pipehwm); // Return the HWM for zactor internal pipes. CZMQ_EXPORT size_t zsys_pipehwm (void); // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. CZMQ_EXPORT void zsys_set_ipv6 (int ipv6); // Return use of IPv6 for zsock instances. CZMQ_EXPORT int zsys_ipv6 (void); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". CZMQ_EXPORT void zsys_set_interface (const char *value); // Return network interface to use for broadcasts, or "" if none was set. CZMQ_EXPORT const char * zsys_interface (void); // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses // on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, // use that as the default IPv6 address. CZMQ_EXPORT void zsys_set_ipv6_address (const char *value); // Return IPv6 address to use for zbeacon reception, or "" if none was set. CZMQ_EXPORT const char * zsys_ipv6_address (void); // Set IPv6 milticast address to use for sending zbeacon messages. This needs // to be set if IPv6 is enabled. If the environment variable // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast // address. CZMQ_EXPORT void zsys_set_ipv6_mcast_address (const char *value); // Return IPv6 multicast address to use for sending zbeacon, or "" if none was // set. CZMQ_EXPORT const char * zsys_ipv6_mcast_address (void); // Configure the automatic use of pre-allocated FDs when creating new sockets. // If 0 (default), nothing will happen. Else, when a new socket is bound, the // system API will be used to check if an existing pre-allocated FD with a // matching port (if TCP) or path (if IPC) exists, and if it does it will be // set via the ZMQ_USE_FD socket option so that the library will use it // instead of creating a new socket. CZMQ_EXPORT void zsys_set_auto_use_fd (int auto_use_fd); // Return use of automatic pre-allocated FDs for zsock instances. CZMQ_EXPORT int zsys_auto_use_fd (void); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. CZMQ_EXPORT void zsys_set_logident (const char *value); // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). CZMQ_EXPORT void zsys_set_logstream (FILE *stream); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. CZMQ_EXPORT void zsys_set_logsender (const char *endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. CZMQ_EXPORT void zsys_set_logsystem (bool logsystem); // Log error condition - highest priority CZMQ_EXPORT void zsys_error (const char *format, ...); // Log warning condition - high priority CZMQ_EXPORT void zsys_warning (const char *format, ...); // Log normal, but significant, condition - normal priority CZMQ_EXPORT void zsys_notice (const char *format, ...); // Log informational message - low priority CZMQ_EXPORT void zsys_info (const char *format, ...); // Log debug-level message - lowest priority CZMQ_EXPORT void zsys_debug (const char *format, ...); // Self test of this class. CZMQ_EXPORT void zsys_test (bool verbose); ``` Please add '@interface' section in './../src/zsys.c'. This is the class self test code: ```c zsys_catch_interrupts (); // Check capabilities without using the return value int rc = zsys_has_curve (); if (verbose) { char *hostname = zsys_hostname (); zsys_info ("host name is %s", hostname); free (hostname); zsys_info ("system limit is %zu ZeroMQ sockets", zsys_socket_limit ()); } zsys_set_linger (0); zsys_set_sndhwm (1000); zsys_set_rcvhwm (1000); zsys_set_pipehwm (2500); assert (zsys_pipehwm () == 2500); zsys_set_ipv6 (0); zsys_set_thread_priority (-1); zsys_set_thread_sched_policy (-1); // Test pipe creation zsock_t *pipe_back; zsock_t *pipe_front = zsys_create_pipe (&pipe_back); zstr_send (pipe_front, "Hello"); char *string = zstr_recv (pipe_back); assert (streq (string, "Hello")); free (string); zsock_destroy (&pipe_back); zsock_destroy (&pipe_front); // Test file manipulation rc = zsys_file_delete ("nosuchfile"); assert (rc == -1); bool rc_bool = zsys_file_exists ("nosuchfile"); assert (rc_bool != true); rc = (int) zsys_file_size ("nosuchfile"); assert (rc == -1); time_t when = zsys_file_modified ("."); assert (when > 0); int mode = zsys_file_mode ("."); assert (S_ISDIR (mode)); assert (mode & S_IRUSR); assert (mode & S_IWUSR); zsys_file_mode_private (); rc = zsys_dir_create ("%s/%s", ".", ".testsys/subdir"); assert (rc == 0); when = zsys_file_modified ("./.testsys/subdir"); assert (when > 0); assert (!zsys_file_stable ("./.testsys/subdir")); rc = zsys_dir_delete ("%s/%s", ".", ".testsys/subdir"); assert (rc == 0); rc = zsys_dir_delete ("%s/%s", ".", ".testsys"); assert (rc == 0); zsys_file_mode_default (); assert (zsys_dir_change (".") == 0); int major, minor, patch; zsys_version (&major, &minor, &patch); assert (major == CZMQ_VERSION_MAJOR); assert (minor == CZMQ_VERSION_MINOR); assert (patch == CZMQ_VERSION_PATCH); string = zsys_sprintf ("%s %02x", "Hello", 16); assert (streq (string, "Hello 10")); free (string); char *str64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,."; int num10 = 1234567890; string = zsys_sprintf ("%s%s%s%s%d", str64, str64, str64, str64, num10); assert (strlen (string) == (4 * 64 + 10)); free (string); // Test logging system zsys_set_logident ("czmq_selftest"); zsys_set_logsender ("inproc://logging"); void *logger = zsys_socket (ZMQ_SUB, NULL, 0); assert (logger); rc = zmq_connect (logger, "inproc://logging"); assert (rc == 0); rc = zmq_setsockopt (logger, ZMQ_SUBSCRIBE, "", 0); assert (rc == 0); if (verbose) { zsys_error ("This is an %s message", "error"); zsys_warning ("This is a %s message", "warning"); zsys_notice ("This is a %s message", "notice"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); zsys_set_logident ("hello, world"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); // Check that logsender functionality is working char *received = zstr_recv (logger); assert (received); zstr_free (&received); } zsys_close (logger, NULL, 0); ``` #### ztimerset - timer set ztimerset - timer set Please add '@discuss' section in './../src/ztimerset.c'. This is the class interface: ```h // This is a draft class, and may change without notice. It is disabled in // stable builds by default. If you use this in applications, please ask // for it to be pushed to stable state. Use --enable-drafts to enable. #ifdef CZMQ_BUILD_DRAFT_API // Callback function for timer event. typedef void (ztimerset_fn) ( int timer_id, void *arg); // *** Draft method, for development use, may change without warning *** // Create new timer set. CZMQ_EXPORT ztimerset_t * ztimerset_new (void); // *** Draft method, for development use, may change without warning *** // Destroy a timer set CZMQ_EXPORT void ztimerset_destroy (ztimerset_t **self_p); // *** Draft method, for development use, may change without warning *** // Add a timer to the set. Returns timer id if OK, -1 on failure. CZMQ_EXPORT int ztimerset_add (ztimerset_t *self, size_t interval, ztimerset_fn handler, void *arg); // *** Draft method, for development use, may change without warning *** // Cancel a timer. Returns 0 if OK, -1 on failure. CZMQ_EXPORT int ztimerset_cancel (ztimerset_t *self, int timer_id); // *** Draft method, for development use, may change without warning *** // Set timer interval. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. CZMQ_EXPORT int ztimerset_set_interval (ztimerset_t *self, int timer_id, size_t interval); // *** Draft method, for development use, may change without warning *** // Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. CZMQ_EXPORT int ztimerset_reset (ztimerset_t *self, int timer_id); // *** Draft method, for development use, may change without warning *** // Return the time until the next interval. // Should be used as timeout parameter for the zpoller wait method. // The timeout is in msec. CZMQ_EXPORT int ztimerset_timeout (ztimerset_t *self); // *** Draft method, for development use, may change without warning *** // Invoke callback function of all timers which their interval has elapsed. // Should be call after zpoller wait method. // Returns 0 if OK, -1 on failure. CZMQ_EXPORT int ztimerset_execute (ztimerset_t *self); // *** Draft method, for development use, may change without warning *** // Self test of this class. CZMQ_EXPORT void ztimerset_test (bool verbose); #endif // CZMQ_BUILD_DRAFT_API ``` Please add '@interface' section in './../src/ztimerset.c'. This is the class self test code: ```c // Simple create/destroy test ztimerset_t *self = ztimerset_new (); assert (self); // Adding timer bool timer_invoked = false; int timer_id = ztimerset_add (self, 100, handler, &timer_invoked); assert (timer_id != -1); int rc = ztimerset_execute (self); assert (rc == 0); assert (!timer_invoked); int timeout = ztimerset_timeout (self); assert (timeout > 0); zclock_sleep (timeout); rc = ztimerset_execute (self); assert (rc == 0); assert (timer_invoked); // Cancel timer timeout = ztimerset_timeout (self); assert (timeout > 0); rc = ztimerset_cancel (self, timer_id); assert (rc == 0); timeout = ztimerset_timeout (self); assert(timeout == -1); // Reset a timer timer_id = ztimerset_add (self, 100, handler, &timer_invoked); assert (timer_id != -1); timeout = ztimerset_timeout (self); assert (timeout > 0); zclock_sleep (timeout / 2); timeout = ztimerset_timeout (self); rc = ztimerset_reset(self, timer_id); assert (rc == 0); int timeout2 = ztimerset_timeout (self); assert (timeout2 > timeout); rc = ztimerset_cancel (self, timer_id); assert (rc == 0); // Set interval timer_id = ztimerset_add (self, 100, handler, &timer_invoked); assert (timer_id != -1); timeout = ztimerset_timeout (self); rc = ztimerset_set_interval(self, timer_id, 200); timeout2 = ztimerset_timeout (self); assert (timeout2 > timeout); ztimerset_destroy (&self); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### ztrie - simple trie for tokenizable strings This is a variant of a trie or prefix tree where all the descendants of a node have a common prefix of the string associated with that node. This implementation is specialized for strings that can be tokenized by a delimiter like a URL, URI or URN. Routes in the tree can be matched by regular expressions and by using capturing groups parts of a matched route can be easily obtained. Note that the performance for pure string based matching is okay but on short strings zhash and zhashx are 3-4 times faster. This is the class interface: ```h // This is a draft class, and may change without notice. It is disabled in // stable builds by default. If you use this in applications, please ask // for it to be pushed to stable state. Use --enable-drafts to enable. #ifdef CZMQ_BUILD_DRAFT_API // Callback function for ztrie_node to destroy node data. typedef void (ztrie_destroy_data_fn) ( void **data); // *** Draft method, for development use, may change without warning *** // Creates a new ztrie. CZMQ_EXPORT ztrie_t * ztrie_new (char delimiter); // *** Draft method, for development use, may change without warning *** // Destroy the ztrie. CZMQ_EXPORT void ztrie_destroy (ztrie_t **self_p); // *** Draft method, for development use, may change without warning *** // Inserts a new route into the tree and attaches the data. Returns -1 // if the route already exists, otherwise 0. This method takes ownership of // the provided data if a destroy_data_fn is provided. CZMQ_EXPORT int ztrie_insert_route (ztrie_t *self, const char *path, void *data, ztrie_destroy_data_fn destroy_data_fn); // *** Draft method, for development use, may change without warning *** // Removes a route from the trie and destroys its data. Returns -1 if the // route does not exists, otherwise 0. // the start of the list call zlist_first (). Advances the cursor. CZMQ_EXPORT int ztrie_remove_route (ztrie_t *self, const char *path); // *** Draft method, for development use, may change without warning *** // Returns true if the path matches a route in the tree, otherwise false. CZMQ_EXPORT bool ztrie_matches (ztrie_t *self, const char *path); // *** Draft method, for development use, may change without warning *** // Returns the data of a matched route from last ztrie_matches. If the path // did not match, returns NULL. Do not delete the data as it's owned by // ztrie. CZMQ_EXPORT void * ztrie_hit_data (ztrie_t *self); // *** Draft method, for development use, may change without warning *** // Returns the count of parameters that a matched route has. CZMQ_EXPORT size_t ztrie_hit_parameter_count (ztrie_t *self); // *** Draft method, for development use, may change without warning *** // Returns the parameters of a matched route with named regexes from last // ztrie_matches. If the path did not match or the route did not contain any // named regexes, returns NULL. CZMQ_EXPORT zhashx_t * ztrie_hit_parameters (ztrie_t *self); // *** Draft method, for development use, may change without warning *** // Returns the asterisk matched part of a route, if there has been no match // or no asterisk match, returns NULL. CZMQ_EXPORT const char * ztrie_hit_asterisk_match (ztrie_t *self); // *** Draft method, for development use, may change without warning *** // Print the trie CZMQ_EXPORT void ztrie_print (ztrie_t *self); // *** Draft method, for development use, may change without warning *** // Self test of this class. CZMQ_EXPORT void ztrie_test (bool verbose); #endif // CZMQ_BUILD_DRAFT_API ``` Please add '@interface' section in './../src/ztrie.c'. This is the class self test code: ```c // Create a new trie for matching strings that can be tokenized by a slash // (e.g. URLs minus the protocol, address and port). ztrie_t *self = ztrie_new ('/'); assert (self); int ret = 0; // Let's start by inserting a couple of routes into the trie. // This one is for the route '/foo/bar' the slash at the beginning of the // route is important because everything before the first delimiter will be // discarded. A slash at the end of a route is optional though. The data // associated with this node is passed without destroy function which means // it must be destroyed by the caller. int foo_bar_data = 10; ret = ztrie_insert_route (self, "/foo/bar", &foo_bar_data, NULL); assert (ret == 0); // Now suppose we like to match all routes with two tokens that start with // '/foo/' but aren't '/foo/bar'. This is possible by using regular // expressions which are enclosed in an opening and closing curly bracket. // Tokens that contain regular expressions are always match after string // based tokens. // Note: There is no order in which regular expressions are sorted thus // if you enter multiple expressions for a route you will have to make // sure they don't have overlapping results. For example '/foo/{[^/]+}' // and '/foo/{\d+} having could turn out badly. int foo_other_data = 100; ret = ztrie_insert_route (self, "/foo/{[^/]+}", &foo_other_data, NULL); assert (ret == 0); // Regular expression are only matched against tokens of the same level. // This allows us to append to are route with a regular expression as if // it were a string. ret = ztrie_insert_route (self, "/foo/{[^/]+}/gulp", NULL, NULL); assert (ret == 0); // Routes are identified by their endpoint, which is the last token of the route. // It is possible to insert routes for a node that already exists but isn't an // endpoint yet. The delimiter at the end of a route is optional and has no effect. ret = ztrie_insert_route (self, "/foo/", NULL, NULL); assert (ret == 0); // If you try to insert a route which already exists the method will return -1. ret = ztrie_insert_route (self, "/foo", NULL, NULL); assert (ret == -1); // It is not allowed to insert routes with empty tokens. ret = ztrie_insert_route (self, "//foo", NULL, NULL); assert (ret == -1); // Everything before the first delimiter is ignored so 'foo/bar/baz' is equivalent // to '/bar/baz'. ret = ztrie_insert_route (self, "foo/bar/baz", NULL, NULL); assert (ret == 0); ret = ztrie_insert_route (self, "/bar/baz", NULL, NULL); assert (ret == -1); // Of course you are allowed to remove routes, in case there is data associated with a // route and a destroy data function has been supplied that data will be destroyed. ret = ztrie_remove_route (self, "/foo"); assert (ret == 0); // Removing a non existent route will as well return -1. ret = ztrie_remove_route (self, "/foo"); assert (ret == -1); // Removing a route with a regular expression must exactly match the entered one. ret = ztrie_remove_route (self, "/foo/{[^/]+}"); assert (ret == 0); // Next we like to match a path by regular expressions and also extract matched // parts of a route. This can be done by naming the regular expression. The name of a // regular expression is entered at the beginning of the curly brackets and separated // by a colon from the regular expression. The first one in this examples is named // 'name' and names the expression '[^/]'. If there is no capturing group defined in // the expression the whole matched string will be associated with this parameter. In // case you don't like the get the whole matched string use a capturing group, like // it has been done for the 'id' parameter. This is nice but you can even match as // many parameter for a token as you like. Therefore simply put the parameter names // separated by colons in front of the regular expression and make sure to add a // capturing group for each parameter. The first parameter will be associated with // the first capturing and so on. char *data = (char *) malloc (80); sprintf (data, "%s", "Hello World!"); ret = ztrie_insert_route (self, "/baz/{name:[^/]+}/{id:--(\\d+)}/{street:nr:(\\a+)(\\d+)}", data, NULL); assert (ret == 0); // There is a lot you can do with regular expression but matching routes // of arbitrary length wont work. Therefore we make use of the asterisk // operator. Just place it at the end of your route, e.g. '/config/bar/*'. ret = ztrie_insert_route (self, "/config/bar/*", NULL, NULL); assert (ret == 0); // Appending to an asterisk as you would to with a regular expression // isn't valid. ret = ztrie_insert_route (self, "/config/bar/*/bar", NULL, NULL); assert (ret == -1); // The asterisk operator will only work as a leaf in the tree. If you // enter an asterisk in the middle of your route it will simply be // interpreted as a string. ret = ztrie_insert_route (self, "/test/*/bar", NULL, NULL); assert (ret == 0); // If a parent has an asterisk as child it is not allowed to have // other siblings. ret = ztrie_insert_route (self, "/config/bar/foo/glup", NULL, NULL); assert (ret != 0); // Test matches bool hasMatch = false; // The route '/bar/foo' will fail to match as this route has never been inserted. hasMatch = ztrie_matches (self, "/bar/foo"); assert (!hasMatch); // The route '/foo/bar' will match and we can obtain the data associated with it. hasMatch = ztrie_matches (self, "/foo/bar"); assert (hasMatch); int foo_bar_hit_data = *((int *) ztrie_hit_data (self)); assert (foo_bar_data == foo_bar_hit_data); // This route is part of another but is no endpoint itself thus the matches will fail. hasMatch = ztrie_matches (self, "/baz/blub"); assert (!hasMatch); // This route will match our named regular expressions route. Thus we can extract data // from the route by their names. hasMatch = ztrie_matches (self, "/baz/blub/--11/abc23"); assert (hasMatch); char *match_data = (char *) ztrie_hit_data (self); assert (streq ("Hello World!", match_data)); zhashx_t *parameters = ztrie_hit_parameters (self); assert (zhashx_size (parameters) == 4); assert (streq ("blub", (char *) zhashx_lookup (parameters, "name"))); assert (streq ("11", (char *) zhashx_lookup (parameters, "id"))); assert (streq ("abc", (char *) zhashx_lookup (parameters, "street"))); assert (streq ("23", (char *) zhashx_lookup (parameters, "nr"))); zhashx_destroy (¶meters); // This will match our asterisk route '/config/bar/*'. As the result we // can obtain the asterisk matched part of the route. hasMatch = ztrie_matches (self, "/config/bar/foo/bar"); assert (hasMatch); assert (streq (ztrie_hit_asterisk_match (self), "foo/bar")); zstr_free (&data); ztrie_destroy (&self); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` #### zuuid - UUID support class The zuuid class generates UUIDs and provides methods for working with them. If you build CZMQ with libuuid, on Unix/Linux, it will use that library. On Windows it will use UuidCreate(). Otherwise it will use a random number generator to produce convincing imitations of UUIDs. Please add '@discuss' section in './../src/zuuid.c'. This is the class interface: ```h // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Create a new UUID object. CZMQ_EXPORT zuuid_t * zuuid_new (void); // Create UUID object from supplied ZUUID_LEN-octet value. CZMQ_EXPORT zuuid_t * zuuid_new_from (const byte *source); // Destroy a specified UUID object. CZMQ_EXPORT void zuuid_destroy (zuuid_t **self_p); // Set UUID to new supplied ZUUID_LEN-octet value. CZMQ_EXPORT void zuuid_set (zuuid_t *self, const byte *source); // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. CZMQ_EXPORT int zuuid_set_str (zuuid_t *self, const char *source); // Return UUID binary data. CZMQ_EXPORT const byte * zuuid_data (zuuid_t *self); // Return UUID binary size CZMQ_EXPORT size_t zuuid_size (zuuid_t *self); // Returns UUID as string CZMQ_EXPORT const char * zuuid_str (zuuid_t *self); // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier CZMQ_EXPORT const char * zuuid_str_canonical (zuuid_t *self); // Store UUID blob in target array CZMQ_EXPORT void zuuid_export (zuuid_t *self, byte *target); // Check if UUID is same as supplied value CZMQ_EXPORT bool zuuid_eq (zuuid_t *self, const byte *compare); // Check if UUID is different from supplied value CZMQ_EXPORT bool zuuid_neq (zuuid_t *self, const byte *compare); // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. CZMQ_EXPORT zuuid_t * zuuid_dup (zuuid_t *self); // Self test of this class. CZMQ_EXPORT void zuuid_test (bool verbose); ``` Please add '@interface' section in './../src/zuuid.c'. This is the class self test code: ```c // Simple create/destroy test assert (ZUUID_LEN == 16); assert (ZUUID_STR_LEN == 32); zuuid_t *uuid = zuuid_new (); assert (uuid); assert (zuuid_size (uuid) == ZUUID_LEN); assert (strlen (zuuid_str (uuid)) == ZUUID_STR_LEN); zuuid_t *copy = zuuid_dup (uuid); assert (streq (zuuid_str (uuid), zuuid_str (copy))); // Check set/set_str/export methods const char *myuuid = "8CB3E9A9649B4BEF8DE225E9C2CEBB38"; const char *myuuid2 = "8CB3E9A9-649B-4BEF-8DE2-25E9C2CEBB38"; const char *myuuid3 = "{8CB3E9A9-649B-4BEF-8DE2-25E9C2CEBB38}"; const char *myuuid4 = "8CB3E9A9649B4BEF8DE225E9C2CEBB3838"; int rc = zuuid_set_str (uuid, myuuid); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid2); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid3); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid4); assert (rc == -1); byte copy_uuid [ZUUID_LEN]; zuuid_export (uuid, copy_uuid); zuuid_set (uuid, copy_uuid); assert (streq (zuuid_str (uuid), myuuid)); // Check the canonical string format assert (streq (zuuid_str_canonical (uuid), "8cb3e9a9-649b-4bef-8de2-25e9c2cebb38")); zuuid_destroy (&uuid); zuuid_destroy (©); #if defined (__WINDOWS__) zsys_shutdown(); #endif ``` ## Error Handling The CZMQ policy is to reduce the error flow to 0/-1 where possible. libzmq still does a lot of errno setting. CZMQ does not do that, as it creates a fuzzy API. Things either work as expected, or they fail, and the application's best strategy is usually to assert on non-zero return codes. Some older libraries still return plethora of error codes, to indicate different types of failure. This ironically makes both library and application more likely to be buggy. The reason is simply that it needs more code on both sides of the API, and the more code, the more bugs. The use of black/white error handling fits the CLASS style for APIs where each call is explicit and without side effects of any kind, and where damage is either impossible, or fatal. The one exception is running out of resources (memory, sockets). In that case, there are two strategies that work, for different types of app. One is to assert, to force better sizing of the machine and/or limits such as max connections. Two is to degrade carefully, e.g. refuse new connections, however that is considerably harder to do correctly and probably unrealistic for most developers. Some CZMQ methods used to actually assert, e.g. in zsocket_bind, if the action failed, instead of returning -1. That was just closer to the majority case where the action MUST work, or nothing can continue. However there's a small slice of cases where failure means something positive, and for these cases, such calls return -1 on failure. 99% of calling code simply asserts the return value is not -1. There are a few cases where the return value is overloaded to return -1, 0, or other values. These are somewhat confusing special cases and we aim to eliminate them over time. The overall goal with this strategy is robustness, and absolute minimal and predictable expression in the code. You can see that it works: the CZMQ code is generally very simple and clear, with a few exceptions of places where people have used their old C style (we fix these over time). ## CZMQ Actors The v2 API had a zthread class that let you create "attached threads" connected to their parent by an inproc:// PIPE socket. In v3 this has been simplified and better wrapped as the zactor class. CZMQ actors are in effect threads with a socket interface. A zactor_t instance works like a socket, and the CZMQ classes that deal with sockets (like zmsg and zpoller) all accept zactor_t references as well as zsock_t and libzmq void * socket handles. To write an actor, use this template. Note that your actor is a single function "void myname (zsock_t *pipe, void *args)" function: /* ========================================================================= someclass - some description Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for ØMQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Please take e.g. include/zmonitor.h as basis for your public API. And delete this text, and write your own, when you create an actor :-) @discuss @end */ #include "../include/czmq.h" // -------------------------------------------------------------------------- // The self_t structure holds the state for one actor instance typedef struct { zsock_t *pipe; // Actor command pipe zpoller_t *poller; // Socket poller // ... you'll be adding other stuff here bool terminated; // Did caller ask us to quit? bool verbose; // Verbose logging enabled? } self_t; static self_t * s_self_new (zsock_t *pipe) { self_t *self = (self_t *) zmalloc (sizeof (self_t)); self->pipe = pipe; // ... initialize your own state including any other // sockets, which you can add to the poller: self->poller = zpoller_new (self->pipe, NULL); return self; } static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; zpoller_destroy (&self->poller); // ... destroy your own state here free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Handle a command from calling application static int s_self_handle_pipe (self_t *self) { // Get the whole message off the pipe in one go zmsg_t *request = zmsg_recv (self->pipe); if (!request) return -1; // Interrupted char *command = zmsg_popstr (request); if (self->verbose) zsys_info ("zxxx: API command=%s", command); if (streq (command, "VERBOSE")) self->verbose = true; else // An example of a command that the caller would wait for // via a signal, so that the two threads synchronize if (streq (command, "WAIT")) zsock_signal (self->pipe, 0); else if (streq (command, "$TERM")) self->terminated = true; else { zsys_error ("zxxx: - invalid command: %s", command); assert (false); } zstr_free (&command); zmsg_destroy (&request); return 0; } // -------------------------------------------------------------------------- // zxxx() implements the zxxx actor interface void zxxx (zsock_t *pipe, void *args) { self_t *self = s_self_new (pipe); // Signal successful initialization zsock_signal (pipe, 0); while (!self->terminated) { zsock_t *which = (zsock_t *) zpoller_wait (self->poller, -1); if (which == self->pipe) s_self_handle_pipe (self); else if (zpoller_terminated (self->poller)) break; // Interrupted } s_self_destroy (&self); } // -------------------------------------------------------------------------- // Selftest void zxxx_test (bool verbose) { printf (" * zxxx: "); if (verbose) printf ("\n"); // @selftest zactor_t *xxx = zactor_new (zxxx, NULL); assert (xxx); if (verbose) zstr_sendx (xxx, "VERBOSE", NULL); zactor_destroy (&xxx); // @end printf ("OK\n"); } The selftest code shows how to create, talk to, and destroy an actor. ## Under the Hood ### Adding a New Class If you define a new CZMQ class `myclass` you need to: * Write the `zmyclass.c` and `zmyclass.h` source files, in `src` and `include` respectively. * Add`#include ` to `include/czmq.h`. * Add the myclass header and test call to `src/czmq_selftest.c`. * Add a reference documentation to 'doc/zmyclass.txt'. * Add myclass to 'model/projects.xml` and read model/README.txt. * Add a section to README.txt. ### Documentation Man pages are generated from the class header and source files via the doc/mkman tool, and similar functionality in the gitdown tool (http://github.com/imatix/gitdown). The header file for a class must wrap its interface as follows (example is from include/zclock.h): // @interface // Sleep for a number of milliseconds void zclock_sleep (int msecs); // Return current system clock as milliseconds int64_t zclock_time (void); // Self test of this class int zclock_test (Bool verbose); // @end The source file for a class must provide documentation as follows: /* @header ...short explanation of class... @discuss ...longer discussion of how it works... @end */ The source file for a class then provides the self test example as follows: // @selftest int64_t start = zclock_time (); zclock_sleep (10); assert ((zclock_time () - start) >= 10); // @end The template for man pages is in doc/mkman. ### Development CZMQ is developed through a test-driven process that guarantees no memory violations or leaks in the code: * Modify a class or method. * Update the test method for that class. * Run the 'selftest' script, which uses the Valgrind memcheck tool. * Repeat until perfect. ### Porting CZMQ When you try CZMQ on an OS that it's not been used on (ever, or for a while), you will hit code that does not compile. In some cases the patches are trivial, in other cases (usually when porting to Windows), the work needed to build equivalent functionality may be non-trivial. In any case, the benefit is that once ported, the functionality is available to all applications. Before attempting to patch code for portability, please read the `czmq_prelude.h` header file. There are several typical types of changes you may need to make to get functionality working on a specific operating system: * Defining typedefs which are missing on that specific compiler: do this in czmq_prelude.h. * Defining macros that rename exotic library functions to more conventional names: do this in czmq_prelude.h. * Reimplementing specific methods to use a non-standard API: this is typically needed on Windows. Do this in the relevant class, using #ifdefs to properly differentiate code for different platforms. ### Hints to Contributors CZMQ is a nice, neat library, and you may not immediately appreciate why. Read the CLASS style guide please, and write your code to make it indistinguishable from the rest of the code in the library. That is the only real criteria for good style: it's invisible. Don't include system headers in source files. The right place for these is czmq_prelude.h. If you need to check against configured libraries and/or headers, include platform.h in the source before including czmq.h. Do read your code after you write it and ask, "Can I make this simpler?" We do use a nice minimalist and yet readable style. Learn it, adopt it, use it. Before opening a pull request read our [contribution guidelines](https://github.com/zeromq/czmq/blob/master/CONTRIBUTING.md). Thanks! ### Code Generation We generate the zsockopt class using [GSL](https://github.com/imatix/gsl), using a code generator script in scripts/sockopts.gsl. We also generate the project files. ### This Document This document is originally at README.txt and is built using [gitdown](http://github.com/imatix/gitdown). _This documentation was generated from czmq/README.txt using [Gitdown](https://github.com/zeromq/gitdown)_ czmq-4.1.0/doc/0000775000372000037200000000000013222211351014125 5ustar00travistravis00000000000000czmq-4.1.0/doc/Makefile.am0000664000372000037200000002004413222211156016164 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ # Default target all-local: doc # Public programs ("main" tags in project.xml), auto-regenerated: MAN1 = zmakecert.1 # Public classes ("class" tags in project.xml), auto-regenerated: MAN3 = zactor.3 zargs.3 zarmour.3 zcert.3 zcertstore.3 zchunk.3 zclock.3 zconfig.3 zdigest.3 zdir.3 zdir_patch.3 zfile.3 zframe.3 zhash.3 zhashx.3 ziflist.3 zlist.3 zlistx.3 zloop.3 zmsg.3 zpoller.3 zproc.3 zsock.3 zstr.3 zsys.3 ztimerset.3 ztrie.3 zuuid.3 zauth.3 zbeacon.3 zgossip.3 zmonitor.3 zproxy.3 zrex.3 # Project overview, written by a human after initial skeleton: # NOTE: stub doc/czmq.adoc is generated by GSL from project.xml # and then comitted to SCM and maintained manually to describe the # project (section 7 = Overview, conventions, and miscellaneous). MAN7 = czmq.7 MAN_DOC = $(MAN1) $(MAN3) $(MAN7) # Assumption: the single .7 page only covers the project and is maintained # manually. The SCM-tracked text source file name uses an .adoc extension # so as not to conflict with generated .txt files (in cases when a "class" # or a "main" name is same as overall project name). MAN_TXT = $(MAN7:%.7=%.adoc) EXTRA_DIST = asciidoc.conf mkman if INSTALL_MAN dist_man_MANS = $(MAN_DOC) endif if BUILD_DOC MAN_TXT += $(MAN1:%.1=%.txt) MAN_TXT += $(MAN3:%.3=%.txt) DISTCLEANFILES = $(MAN_DOC) dist-hook : $(MAN_DOC) SUFFIXES=.txt .adoc .xml .xml7 .1 .3 .7 .txt.xml: asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \ -aczmq_version=@PACKAGE_VERSION@ -o$@ $< .xml.1: xmlto man $< .xml.3: xmlto man $< # Special handling for project overview whose basename may collide # with a main or class name .adoc.xml7: asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \ -aczmq_version=@PACKAGE_VERSION@ -o$@ $< .xml7.7: xmlto man $< # List of *.txt and *.doc files generated during build from comments # in project program source files and further processed into manpages. GENERATED_DOCS = # No-op, docs and texts are generated by mkman in one shot - just # make a dependency that can not parallelize and break stuff. # Also, to be validly processed, the dependency must have SOME payload .txt.doc: @true GENERATED_DOCS += zactor.txt zactor.doc zactor.txt: $(top_srcdir)/src/zactor.c "$(srcdir)/mkman" "zactor" "$(builddir)/zactor.txt" "$(srcdir)/.." GENERATED_DOCS += zargs.txt zargs.doc zargs.txt: $(top_srcdir)/src/zargs.c "$(srcdir)/mkman" "zargs" "$(builddir)/zargs.txt" "$(srcdir)/.." GENERATED_DOCS += zarmour.txt zarmour.doc zarmour.txt: $(top_srcdir)/src/zarmour.c "$(srcdir)/mkman" "zarmour" "$(builddir)/zarmour.txt" "$(srcdir)/.." GENERATED_DOCS += zcert.txt zcert.doc zcert.txt: $(top_srcdir)/src/zcert.c "$(srcdir)/mkman" "zcert" "$(builddir)/zcert.txt" "$(srcdir)/.." GENERATED_DOCS += zcertstore.txt zcertstore.doc zcertstore.txt: $(top_srcdir)/src/zcertstore.c "$(srcdir)/mkman" "zcertstore" "$(builddir)/zcertstore.txt" "$(srcdir)/.." GENERATED_DOCS += zchunk.txt zchunk.doc zchunk.txt: $(top_srcdir)/src/zchunk.c "$(srcdir)/mkman" "zchunk" "$(builddir)/zchunk.txt" "$(srcdir)/.." GENERATED_DOCS += zclock.txt zclock.doc zclock.txt: $(top_srcdir)/src/zclock.c "$(srcdir)/mkman" "zclock" "$(builddir)/zclock.txt" "$(srcdir)/.." GENERATED_DOCS += zconfig.txt zconfig.doc zconfig.txt: $(top_srcdir)/src/zconfig.c "$(srcdir)/mkman" "zconfig" "$(builddir)/zconfig.txt" "$(srcdir)/.." GENERATED_DOCS += zdigest.txt zdigest.doc zdigest.txt: $(top_srcdir)/src/zdigest.c "$(srcdir)/mkman" "zdigest" "$(builddir)/zdigest.txt" "$(srcdir)/.." GENERATED_DOCS += zdir.txt zdir.doc zdir.txt: $(top_srcdir)/src/zdir.c "$(srcdir)/mkman" "zdir" "$(builddir)/zdir.txt" "$(srcdir)/.." GENERATED_DOCS += zdir_patch.txt zdir_patch.doc zdir_patch.txt: $(top_srcdir)/src/zdir_patch.c "$(srcdir)/mkman" "zdir_patch" "$(builddir)/zdir_patch.txt" "$(srcdir)/.." GENERATED_DOCS += zfile.txt zfile.doc zfile.txt: $(top_srcdir)/src/zfile.c "$(srcdir)/mkman" "zfile" "$(builddir)/zfile.txt" "$(srcdir)/.." GENERATED_DOCS += zframe.txt zframe.doc zframe.txt: $(top_srcdir)/src/zframe.c "$(srcdir)/mkman" "zframe" "$(builddir)/zframe.txt" "$(srcdir)/.." GENERATED_DOCS += zhash.txt zhash.doc zhash.txt: $(top_srcdir)/src/zhash.c "$(srcdir)/mkman" "zhash" "$(builddir)/zhash.txt" "$(srcdir)/.." GENERATED_DOCS += zhashx.txt zhashx.doc zhashx.txt: $(top_srcdir)/src/zhashx.c "$(srcdir)/mkman" "zhashx" "$(builddir)/zhashx.txt" "$(srcdir)/.." GENERATED_DOCS += ziflist.txt ziflist.doc ziflist.txt: $(top_srcdir)/src/ziflist.c "$(srcdir)/mkman" "ziflist" "$(builddir)/ziflist.txt" "$(srcdir)/.." GENERATED_DOCS += zlist.txt zlist.doc zlist.txt: $(top_srcdir)/src/zlist.c "$(srcdir)/mkman" "zlist" "$(builddir)/zlist.txt" "$(srcdir)/.." GENERATED_DOCS += zlistx.txt zlistx.doc zlistx.txt: $(top_srcdir)/src/zlistx.c "$(srcdir)/mkman" "zlistx" "$(builddir)/zlistx.txt" "$(srcdir)/.." GENERATED_DOCS += zloop.txt zloop.doc zloop.txt: $(top_srcdir)/src/zloop.c "$(srcdir)/mkman" "zloop" "$(builddir)/zloop.txt" "$(srcdir)/.." GENERATED_DOCS += zmsg.txt zmsg.doc zmsg.txt: $(top_srcdir)/src/zmsg.c "$(srcdir)/mkman" "zmsg" "$(builddir)/zmsg.txt" "$(srcdir)/.." GENERATED_DOCS += zpoller.txt zpoller.doc zpoller.txt: $(top_srcdir)/src/zpoller.c "$(srcdir)/mkman" "zpoller" "$(builddir)/zpoller.txt" "$(srcdir)/.." GENERATED_DOCS += zproc.txt zproc.doc zproc.txt: $(top_srcdir)/src/zproc.c "$(srcdir)/mkman" "zproc" "$(builddir)/zproc.txt" "$(srcdir)/.." GENERATED_DOCS += zsock.txt zsock.doc zsock.txt: $(top_srcdir)/src/zsock.c "$(srcdir)/mkman" "zsock" "$(builddir)/zsock.txt" "$(srcdir)/.." GENERATED_DOCS += zstr.txt zstr.doc zstr.txt: $(top_srcdir)/src/zstr.c "$(srcdir)/mkman" "zstr" "$(builddir)/zstr.txt" "$(srcdir)/.." GENERATED_DOCS += zsys.txt zsys.doc zsys.txt: $(top_srcdir)/src/zsys.c "$(srcdir)/mkman" "zsys" "$(builddir)/zsys.txt" "$(srcdir)/.." GENERATED_DOCS += ztimerset.txt ztimerset.doc ztimerset.txt: $(top_srcdir)/src/ztimerset.c "$(srcdir)/mkman" "ztimerset" "$(builddir)/ztimerset.txt" "$(srcdir)/.." GENERATED_DOCS += ztrie.txt ztrie.doc ztrie.txt: $(top_srcdir)/src/ztrie.c "$(srcdir)/mkman" "ztrie" "$(builddir)/ztrie.txt" "$(srcdir)/.." GENERATED_DOCS += zuuid.txt zuuid.doc zuuid.txt: $(top_srcdir)/src/zuuid.c "$(srcdir)/mkman" "zuuid" "$(builddir)/zuuid.txt" "$(srcdir)/.." GENERATED_DOCS += zauth.txt zauth.doc zauth.txt: $(top_srcdir)/src/zauth.c "$(srcdir)/mkman" "zauth" "$(builddir)/zauth.txt" "$(srcdir)/.." GENERATED_DOCS += zbeacon.txt zbeacon.doc zbeacon.txt: $(top_srcdir)/src/zbeacon.c "$(srcdir)/mkman" "zbeacon" "$(builddir)/zbeacon.txt" "$(srcdir)/.." GENERATED_DOCS += zgossip.txt zgossip.doc zgossip.txt: $(top_srcdir)/src/zgossip.c "$(srcdir)/mkman" "zgossip" "$(builddir)/zgossip.txt" "$(srcdir)/.." GENERATED_DOCS += zmonitor.txt zmonitor.doc zmonitor.txt: $(top_srcdir)/src/zmonitor.c "$(srcdir)/mkman" "zmonitor" "$(builddir)/zmonitor.txt" "$(srcdir)/.." GENERATED_DOCS += zproxy.txt zproxy.doc zproxy.txt: $(top_srcdir)/src/zproxy.c "$(srcdir)/mkman" "zproxy" "$(builddir)/zproxy.txt" "$(srcdir)/.." GENERATED_DOCS += zrex.txt zrex.doc zrex.txt: $(top_srcdir)/src/zrex.c "$(srcdir)/mkman" "zrex" "$(builddir)/zrex.txt" "$(srcdir)/.." GENERATED_DOCS += zmakecert.txt zmakecert.doc zmakecert.txt: $(top_srcdir)/src/zmakecert.c "$(srcdir)/mkman" "zmakecert" "$(builddir)/zmakecert.txt" "$(srcdir)/.." clean-local: rm -f *.1 *.3 *.7 $(GENERATED_DOCS) doc: $(GENERATED_DOCS) else doc: @echo "SKIPPING documentation generation and formatting (BUILD_DOC was not required and/or tools are missing)" >&2 endif EXTRA_DIST += $(MAN_TXT) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/doc/Makefile.in0000664000372000037200000007040113222211333016174 0ustar00travistravis00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @BUILD_DOC_TRUE@am__append_1 = $(MAN1:%.1=%.txt) $(MAN3:%.3=%.txt) subdir = doc DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(dist_man_MANS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/config/libtool.m4 \ $(top_srcdir)/config/ltoptions.m4 \ $(top_srcdir)/config/ltsugar.m4 \ $(top_srcdir)/config/ltversion.m4 \ $(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/src/platform.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man1dir = $(mandir)/man1 am__installdirs = "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man3dir)" \ "$(DESTDIR)$(man7dir)" man3dir = $(mandir)/man3 man7dir = $(mandir)/man7 NROFF = nroff MANS = $(dist_man_MANS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_ARCH = @BUILD_ARCH@ BUILD_DATE = @BUILD_DATE@ BUILD_HOST = @BUILD_HOST@ BUILD_USER = @BUILD_USER@ BUILD_VERSION = @BUILD_VERSION@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LTVER = @LTVER@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ czmq_have_asciidoc = @czmq_have_asciidoc@ czmq_have_xmlto = @czmq_have_xmlto@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ libzmq_CFLAGS = @libzmq_CFLAGS@ libzmq_LIBS = @libzmq_LIBS@ localedir = @localedir@ localstatedir = @localstatedir@ lz4_CFLAGS = @lz4_CFLAGS@ lz4_LIBS = @lz4_LIBS@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkg_config_defines = @pkg_config_defines@ pkg_config_libs_private = @pkg_config_libs_private@ pkgconfig_name_liblz4 = @pkgconfig_name_liblz4@ pkgconfig_name_libsystemd = @pkgconfig_name_libsystemd@ pkgconfig_name_libzmq = @pkgconfig_name_libzmq@ pkgconfig_name_uuid = @pkgconfig_name_uuid@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ systemd_CFLAGS = @systemd_CFLAGS@ systemd_LIBS = @systemd_LIBS@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ uuid_CFLAGS = @uuid_CFLAGS@ uuid_LIBS = @uuid_LIBS@ # Public programs ("main" tags in project.xml), auto-regenerated: MAN1 = zmakecert.1 # Public classes ("class" tags in project.xml), auto-regenerated: MAN3 = zactor.3 zargs.3 zarmour.3 zcert.3 zcertstore.3 zchunk.3 zclock.3 zconfig.3 zdigest.3 zdir.3 zdir_patch.3 zfile.3 zframe.3 zhash.3 zhashx.3 ziflist.3 zlist.3 zlistx.3 zloop.3 zmsg.3 zpoller.3 zproc.3 zsock.3 zstr.3 zsys.3 ztimerset.3 ztrie.3 zuuid.3 zauth.3 zbeacon.3 zgossip.3 zmonitor.3 zproxy.3 zrex.3 # Project overview, written by a human after initial skeleton: # NOTE: stub doc/czmq.adoc is generated by GSL from project.xml # and then comitted to SCM and maintained manually to describe the # project (section 7 = Overview, conventions, and miscellaneous). MAN7 = czmq.7 MAN_DOC = $(MAN1) $(MAN3) $(MAN7) # Assumption: the single .7 page only covers the project and is maintained # manually. The SCM-tracked text source file name uses an .adoc extension # so as not to conflict with generated .txt files (in cases when a "class" # or a "main" name is same as overall project name). MAN_TXT = $(MAN7:%.7=%.adoc) $(am__append_1) EXTRA_DIST = asciidoc.conf mkman $(MAN_TXT) @INSTALL_MAN_TRUE@dist_man_MANS = $(MAN_DOC) @BUILD_DOC_TRUE@DISTCLEANFILES = $(MAN_DOC) @BUILD_DOC_TRUE@SUFFIXES = .txt .adoc .xml .xml7 .1 .3 .7 # List of *.txt and *.doc files generated during build from comments # in project program source files and further processed into manpages. @BUILD_DOC_TRUE@GENERATED_DOCS = zactor.txt zactor.doc zargs.txt \ @BUILD_DOC_TRUE@ zargs.doc zarmour.txt zarmour.doc zcert.txt \ @BUILD_DOC_TRUE@ zcert.doc zcertstore.txt zcertstore.doc \ @BUILD_DOC_TRUE@ zchunk.txt zchunk.doc zclock.txt zclock.doc \ @BUILD_DOC_TRUE@ zconfig.txt zconfig.doc zdigest.txt \ @BUILD_DOC_TRUE@ zdigest.doc zdir.txt zdir.doc zdir_patch.txt \ @BUILD_DOC_TRUE@ zdir_patch.doc zfile.txt zfile.doc zframe.txt \ @BUILD_DOC_TRUE@ zframe.doc zhash.txt zhash.doc zhashx.txt \ @BUILD_DOC_TRUE@ zhashx.doc ziflist.txt ziflist.doc zlist.txt \ @BUILD_DOC_TRUE@ zlist.doc zlistx.txt zlistx.doc zloop.txt \ @BUILD_DOC_TRUE@ zloop.doc zmsg.txt zmsg.doc zpoller.txt \ @BUILD_DOC_TRUE@ zpoller.doc zproc.txt zproc.doc zsock.txt \ @BUILD_DOC_TRUE@ zsock.doc zstr.txt zstr.doc zsys.txt zsys.doc \ @BUILD_DOC_TRUE@ ztimerset.txt ztimerset.doc ztrie.txt \ @BUILD_DOC_TRUE@ ztrie.doc zuuid.txt zuuid.doc zauth.txt \ @BUILD_DOC_TRUE@ zauth.doc zbeacon.txt zbeacon.doc zgossip.txt \ @BUILD_DOC_TRUE@ zgossip.doc zmonitor.txt zmonitor.doc \ @BUILD_DOC_TRUE@ zproxy.txt zproxy.doc zrex.txt zrex.doc \ @BUILD_DOC_TRUE@ zmakecert.txt zmakecert.doc all: all-am .SUFFIXES: .SUFFIXES: .txt .adoc .xml .xml7 .1 .3 .7 .doc $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign doc/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-man1: $(dist_man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(dist_man_MANS)'; \ test -n "$(man1dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.1[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.1[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) install-man3: $(dist_man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(dist_man_MANS)'; \ test -n "$(man3dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.3[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \ done; } uninstall-man3: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man3dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.3[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir) install-man7: $(dist_man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(dist_man_MANS)'; \ test -n "$(man7dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man7dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man7dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.7[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^7][0-9a-z]*$$,7,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man7dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man7dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man7dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man7dir)" || exit $$?; }; \ done; } uninstall-man7: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man7dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.7[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^7][0-9a-z]*$$,7,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man7dir)'; $(am__uninstall_files_from_dir) tags TAGS: ctags CTAGS: cscope cscopelist: @BUILD_DOC_FALSE@dist-hook: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook check-am: all-am check: check-am all-am: Makefile $(MANS) all-local installdirs: for dir in "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(man7dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." @BUILD_DOC_FALSE@clean-local: clean: clean-am clean-am: clean-generic clean-libtool clean-local mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-man install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man1 install-man3 install-man7 install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-man uninstall-man: uninstall-man1 uninstall-man3 uninstall-man7 .MAKE: install-am install-strip .PHONY: all all-am all-local check check-am clean clean-generic \ clean-libtool clean-local cscopelist-am ctags-am dist-hook \ distclean distclean-generic distclean-libtool distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-man1 \ install-man3 install-man7 install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ uninstall-am uninstall-man uninstall-man1 uninstall-man3 \ uninstall-man7 ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ # Default target all-local: doc @BUILD_DOC_TRUE@dist-hook : $(MAN_DOC) @BUILD_DOC_TRUE@.txt.xml: @BUILD_DOC_TRUE@ asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \ @BUILD_DOC_TRUE@ -aczmq_version=@PACKAGE_VERSION@ -o$@ $< @BUILD_DOC_TRUE@.xml.1: @BUILD_DOC_TRUE@ xmlto man $< @BUILD_DOC_TRUE@.xml.3: @BUILD_DOC_TRUE@ xmlto man $< # Special handling for project overview whose basename may collide # with a main or class name @BUILD_DOC_TRUE@.adoc.xml7: @BUILD_DOC_TRUE@ asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \ @BUILD_DOC_TRUE@ -aczmq_version=@PACKAGE_VERSION@ -o$@ $< @BUILD_DOC_TRUE@.xml7.7: @BUILD_DOC_TRUE@ xmlto man $< # No-op, docs and texts are generated by mkman in one shot - just # make a dependency that can not parallelize and break stuff. # Also, to be validly processed, the dependency must have SOME payload @BUILD_DOC_TRUE@.txt.doc: @BUILD_DOC_TRUE@ @true @BUILD_DOC_TRUE@zactor.txt: $(top_srcdir)/src/zactor.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zactor" "$(builddir)/zactor.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zargs.txt: $(top_srcdir)/src/zargs.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zargs" "$(builddir)/zargs.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zarmour.txt: $(top_srcdir)/src/zarmour.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zarmour" "$(builddir)/zarmour.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zcert.txt: $(top_srcdir)/src/zcert.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zcert" "$(builddir)/zcert.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zcertstore.txt: $(top_srcdir)/src/zcertstore.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zcertstore" "$(builddir)/zcertstore.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zchunk.txt: $(top_srcdir)/src/zchunk.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zchunk" "$(builddir)/zchunk.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zclock.txt: $(top_srcdir)/src/zclock.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zclock" "$(builddir)/zclock.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zconfig.txt: $(top_srcdir)/src/zconfig.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zconfig" "$(builddir)/zconfig.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zdigest.txt: $(top_srcdir)/src/zdigest.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zdigest" "$(builddir)/zdigest.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zdir.txt: $(top_srcdir)/src/zdir.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zdir" "$(builddir)/zdir.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zdir_patch.txt: $(top_srcdir)/src/zdir_patch.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zdir_patch" "$(builddir)/zdir_patch.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zfile.txt: $(top_srcdir)/src/zfile.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zfile" "$(builddir)/zfile.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zframe.txt: $(top_srcdir)/src/zframe.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zframe" "$(builddir)/zframe.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zhash.txt: $(top_srcdir)/src/zhash.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zhash" "$(builddir)/zhash.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zhashx.txt: $(top_srcdir)/src/zhashx.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zhashx" "$(builddir)/zhashx.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@ziflist.txt: $(top_srcdir)/src/ziflist.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "ziflist" "$(builddir)/ziflist.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zlist.txt: $(top_srcdir)/src/zlist.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zlist" "$(builddir)/zlist.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zlistx.txt: $(top_srcdir)/src/zlistx.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zlistx" "$(builddir)/zlistx.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zloop.txt: $(top_srcdir)/src/zloop.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zloop" "$(builddir)/zloop.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zmsg.txt: $(top_srcdir)/src/zmsg.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zmsg" "$(builddir)/zmsg.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zpoller.txt: $(top_srcdir)/src/zpoller.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zpoller" "$(builddir)/zpoller.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zproc.txt: $(top_srcdir)/src/zproc.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zproc" "$(builddir)/zproc.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zsock.txt: $(top_srcdir)/src/zsock.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zsock" "$(builddir)/zsock.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zstr.txt: $(top_srcdir)/src/zstr.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zstr" "$(builddir)/zstr.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zsys.txt: $(top_srcdir)/src/zsys.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zsys" "$(builddir)/zsys.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@ztimerset.txt: $(top_srcdir)/src/ztimerset.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "ztimerset" "$(builddir)/ztimerset.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@ztrie.txt: $(top_srcdir)/src/ztrie.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "ztrie" "$(builddir)/ztrie.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zuuid.txt: $(top_srcdir)/src/zuuid.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zuuid" "$(builddir)/zuuid.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zauth.txt: $(top_srcdir)/src/zauth.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zauth" "$(builddir)/zauth.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zbeacon.txt: $(top_srcdir)/src/zbeacon.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zbeacon" "$(builddir)/zbeacon.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zgossip.txt: $(top_srcdir)/src/zgossip.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zgossip" "$(builddir)/zgossip.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zmonitor.txt: $(top_srcdir)/src/zmonitor.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zmonitor" "$(builddir)/zmonitor.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zproxy.txt: $(top_srcdir)/src/zproxy.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zproxy" "$(builddir)/zproxy.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zrex.txt: $(top_srcdir)/src/zrex.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zrex" "$(builddir)/zrex.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@zmakecert.txt: $(top_srcdir)/src/zmakecert.c @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zmakecert" "$(builddir)/zmakecert.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@clean-local: @BUILD_DOC_TRUE@ rm -f *.1 *.3 *.7 $(GENERATED_DOCS) @BUILD_DOC_TRUE@doc: $(GENERATED_DOCS) @BUILD_DOC_FALSE@doc: @BUILD_DOC_FALSE@ @echo "SKIPPING documentation generation and formatting (BUILD_DOC was not required and/or tools are missing)" >&2 ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: czmq-4.1.0/doc/czmq.adoc0000664000372000037200000000276513222211156015744 0ustar00travistravis00000000000000Name(7) ======= NAME ---- czmq - Overview of The high-level C binding for 0MQ SYNOPSIS -------- Project czmq aims to ... (short marketing pitch) It delivers several programs with their respective man pages: zmakecert.1 and public classes in a shared library: zactor.3 zarmour.3 zcert.3 zcertstore.3 zchunk.3 zclock.3 zconfig.3 zdigest.3 zdir.3 zdir_patch.3 zfile.3 zframe.3 zhash.3 zhashx.3 ziflist.3 zlist.3 zlistx.3 zloop.3 zmsg.3 zpoller.3 zproc.3 zsock.3 zstr.3 ztimerset.3 ztrie.3 zuuid.3 zauth.3 zbeacon.3 zgossip.3 zmonitor.3 zproxy.3 zrex.3 zsys.3 Generally you can compile and link against it like this: ---- #include cc ['flags'] 'files' -lczmq ['libraries'] ---- DESCRIPTION ----------- This is a skeleton document created by zproject, which will not be regenerated automatically (by Makefiles nor project.xml re-parsing). You should add hand-written text here to detail whatever applies to Linux standard manpage Section 7 (note that other OSes may follow a different standard with similar concepts, and extend the recipes to package this document into a different section number): ---- 7 Overview, conventions, and miscellaneous : Overviews or descriptions of various topics, conventions and protocols, character set standards, the standard filesystem layout, and miscellaneous other things. ---- Classes ~~~~~~~ Something for developers to consider. Note there are separate man pages generated for public classes during build with contents taken from source code comments. czmq-4.1.0/doc/mkman0000775000372000037200000001505213222211156015164 0ustar00travistravis00000000000000#! /usr/bin/perl # # mkman - Generates man pages from C source and header files. # # Syntax: './mkman srcname [outp rootsrcdir]' # Must be executed in doc/ subdirectory under build workspace root. # srcname - basename of .c or .cc source file located directly in the # $rootsrcdir/src/ directory. For classes (MAN3) also implies # a header (.h) file located directly in $rootsrcdir/include/. # outp - (optional) filename without extension (will be chopped if # provided) of the resulting TXT and DOC files; may be a # slash-separated path e.g. for out-of-tree builds (distcheck). # Defaults to: "$srcname" # rootsrcdir - (optional) location of project source root (may differ # from build root) where to look for input source-code files. # Defaults to: ".." (good for in-tree builds) # # Copyright (c) 1996-2016 iMatix Corporation # Copyright (c) 2016-2017 zproject community # # This is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation; either version 3 of the License, or (at your option) any later # version. # # This software is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABIL- # ITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public # License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # use File::Basename; use Cwd; sub pull { local ($_) = @_; if (/^(.*)(@[a-zA-Z0-9]+)(,(\w*)\s*)?/) { $file = $1; $tag = $2; $opts = $4; $text = ""; $ext = (fileparse("$file", qr/[^.]*/))[2]; die "Can't read '$file': $!" unless open (SOURCE, $file); while () { if (/$tag/) { while () { last if /\@discuss/ || /\@end/ || /\@ignore/ || /\@header/; $_ = " $_" if ($opts eq "code"); s/^ // if ($opts eq "left"); $_ = " $_" if ($opts eq "test"); s/^ / / if ($opts eq "test"); $text .= $_; } } } close (SOURCE); # Add code fences for markdown highlighting $text = "```$ext\n$text```\n" if (length $text) and ($opts eq "code" or $opts eq "test"); $text = "Please add '$tag' section in '$file'.\n" unless $text; return $text; } else { print "E: bad pull request: $_\n"; } } sub generate_manpage { local ($name, $outp, $rootsrcdir) = @_; $name = $1 if $name =~ /(\w+)\.\w+/; # Chop off extensions $outp = $1 if $outp =~ /^(.+)\.[^\.\/]+$/; $outp_basename = basename ($outp); $outp_basename = $2 if $outp =~ /^(.*\/)?(\w+)$/; if ($ENV{"V"} == "1") { printf "D: generate_manpage() got name='$name' outp='$outp' outp_basename='$outp_basename' rootsrcdir='$rootsrcdir'\n"; } # Check if we're making the man page for a main program, or a class $cat = 0; # Unknown category $cat_text = ""; die "Can't open '" . cwd() . "/Makefile'" unless open (MAKEFILE, "Makefile"); while () { if (/MAN1.*$outp_basename\.1/) { $source = "$rootsrcdir/src/$name.c"; $header = "$rootsrcdir/src/$name.c"; $cat = 1; $cat_text = "Program for "; last; } elsif (/MAN3.*$name\.3/) { $source = "$rootsrcdir/src/$name.c"; $header = "$rootsrcdir/include/$name.h"; $cat = 3; $cat_text = "Class for "; last; } } close MAKEFILE; die "The Makefile defined no manpage category for $outp_basename.1 or $name.3" unless ($source ne ""); # Look for class title in 2nd line of source # If there's no class file, leave hand-written man page alone if (! open (SOURCE, $source)) { # Support mixed-source projects (named C in config, # but having both .c and .cc files in reality) printf "Can't open C '$source', retry for C++\n"; if ($header eq $source) { $header .= "c"; } $source .= "c"; # Retry for a *.cc filename } die "Can't open '$source'" unless open (SOURCE, $source); # NOTE: This duplication of lines is needed for proper work: $_ = ; $_ = ; $title = "no title found"; $title = $1 if (/ \w+ - (.*)/); close (SOURCE); printf " MKMAN[txt]\t$source "; if ($source ne $header) { printf "+ $header "; } printf "\t=> $outp.txt\n"; # Open output file die "Can't create '$outp.txt': $!" unless open (OUTPUT, ">$outp.txt"); $underline = "=" x (length ($name) + 3); $template = <<"END"; $name($cat) $underline NAME ---- $outp_basename - $cat_text$title SYNOPSIS -------- ---- pull $header\@interface pull $source\@interface,left ---- DESCRIPTION ----------- pull $source\@header,left pull $source\@discuss,left EXAMPLE ------- .From $name\_test method ---- pull $source\@selftest,left ---- END # Now process template for (split /^/, $template) { if (/^pull (.*)$/) { print OUTPUT pull ($1); } else { print OUTPUT $_; } } close OUTPUT; # Generate a simple text documentation for README.txt printf " MKMAN[doc]\t$source "; if ($source ne $header) { printf "+ $header "; } printf "\t=> $outp.doc\n"; die "Can't create '$outp.doc': $!" unless open (OUTPUT, ">$outp.doc"); print OUTPUT "#### $outp_basename - $title\n\n"; print OUTPUT pull ("$source\@header,left"); print OUTPUT "\n"; print OUTPUT pull ("$source\@discuss,left"); print OUTPUT "\nThis is the class interface:\n\n"; print OUTPUT pull ("$header\@interface,code"); print OUTPUT pull ("$source\@interface,left"); print OUTPUT "\nThis is the class self test code:\n\n"; print OUTPUT pull ("$source\@selftest,test"); print OUTPUT "\n"; close OUTPUT; } $name = shift (@ARGV); $outp = shift (@ARGV); if (!$outp) { $outp=$name; } $rootsrcdir = shift (@ARGV); if (!$rootsrcdir) { $rootsrcdir=".."; } if ($ENV{"V"} == "1") { printf "D: got name='$name' outp='$outp' rootsrcdir='$rootsrcdir' from the start\n"; } generate_manpage ($name, $outp, $rootsrcdir); czmq-4.1.0/doc/asciidoc.conf0000664000372000037200000000422413222211156016557 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ [paradef-default] literal-style=template="literalparagraph" [macros] (?su)[\\]?(?Plinkczmq):(?P\S*?)\[(?P.*?)\]= ifdef::backend-docbook[] [linkczmq-inlinemacro] {0%{target}} {0#} {0#{target}{0}} {0#} endif::backend-docbook[] ifdef::backend-xhtml11[] [linkczmq-inlinemacro] {target}{0?({0})} endif::backend-xhtml11[] ifdef::doctype-manpage[] ifdef::backend-docbook[] [header] template::[header-declarations] {mantitle} {manvolnum} CZMQ {czmq_version} CZMQ Manual {manname} {manpurpose} [footer] AUTHORS The czmq manual was written by the authors in the AUTHORS file. RESOURCES Main web site: Report bugs to the email <zeromq-dev@lists.zeromq.org> COPYRIGHT Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. LICENSE included with the czmq distribution. endif::backend-docbook[] endif::doctype-manpage[] czmq-4.1.0/aclocal.m40000664000372000037200000013724513222211331015232 0ustar00travistravis00000000000000# generated automatically by aclocal 1.14.1 -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) # only at the first occurence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])# PKG_CHECK_MODULES # Copyright (C) 2002-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.14' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.14.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.14.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_COND_IF -*- Autoconf -*- # Copyright (C) 2008-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_COND_IF # _AM_COND_ELSE # _AM_COND_ENDIF # -------------- # These macros are only used for tracing. m4_define([_AM_COND_IF]) m4_define([_AM_COND_ELSE]) m4_define([_AM_COND_ENDIF]) # AM_COND_IF(COND, [IF-TRUE], [IF-FALSE]) # --------------------------------------- # If the shell condition COND is true, execute IF-TRUE, otherwise execute # IF-FALSE. Allow automake to learn about conditional instantiating macros # (the AC_CONFIG_FOOS). AC_DEFUN([AM_COND_IF], [m4_ifndef([_AM_COND_VALUE_$1], [m4_fatal([$0: no such condition "$1"])])dnl _AM_COND_IF([$1])dnl if test -z "$$1_TRUE"; then : m4_n([$2])[]dnl m4_ifval([$3], [_AM_COND_ELSE([$1])dnl else $3 ])dnl _AM_COND_ENDIF([$1])dnl fi[]dnl ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each '.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([config/libtool.m4]) m4_include([config/ltoptions.m4]) m4_include([config/ltsugar.m4]) m4_include([config/ltversion.m4]) m4_include([config/lt~obsolete.m4]) m4_include([acinclude.m4]) czmq-4.1.0/Makefile.am0000664000372000037200000000401313222211156015415 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ ACLOCAL_AMFLAGS = -I config AM_CFLAGS = \ -Werror=format-security AM_CPPFLAGS = \ ${libzmq_CFLAGS} \ ${uuid_CFLAGS} \ ${systemd_CFLAGS} \ ${lz4_CFLAGS} \ -I$(srcdir)/include project_libs = ${libzmq_LIBS} ${uuid_LIBS} ${systemd_LIBS} ${lz4_LIBS} SUBDIRS = doc DIST_SUBDIRS = doc lib_LTLIBRARIES = bin_PROGRAMS = noinst_PROGRAMS = check_PROGRAMS = noinst_LTLIBRARIES = TESTS = # Prepare variables that can be populated (appended) in generated Makefiles or # manually maintained src/Makemodule-local.am EXTRA_DIST = CLEANFILES = DISTCLEANFILES = if ENABLE_DIST_CMAKEFILES EXTRA_DIST += \ Findlibzmq.cmake \ Finduuid.cmake \ Findsystemd.cmake \ Findlz4.cmake \ src/CMakeLists-local.txt \ CMakeLists.txt endif EXTRA_DIST += \ bindings \ src/zsock_option.inc \ src/zgossip_engine.inc \ src/zhash_primes.inc \ src/foreign/sha1/sha1.inc_c \ src/foreign/sha1/sha1.h \ src/foreign/slre/slre.inc_c \ src/foreign/slre/slre.h \ src/foreign/slre/readme.txt \ src/zgossip_msg.h \ LICENSE \ README.txt \ README.md \ CONTRIBUTING.md \ src/czmq_classes.h # NOTE: this "include" syntax is not a "make" but an "autotools" keyword, # see https://www.gnu.org/software/automake/manual/html_node/Include.html include $(srcdir)/src/Makemodule.am include $(srcdir)/src/Makemodule-local.am # Optional project-local hook ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/NEWS0000664000372000037200000007042213222211156014067 0ustar00travistravis00000000000000CZMQ version 4.1.0 stable, released on 2017/12/31 ================================================= * New STABLE APIs have been added to wrap new libzmq context options: - zsys_set_thread_sched_policy - zsys_set_thread_priority See zsys manpage for more details. * New DRAFT class to parse command line arguments in a platform independent way: zargs. See zargs manpage for more info. * New DRAFT APIs have been added to the zproc class to manage subprocesses in a platform-independent unified API. See the zproc manpage for more details. * New DRAFT APIs have been added to the zactor class to override the default destructor: - zactor_destructor_fn - zactor_set_destructor See zactor manpage for more info. * New DRAFT APIs have been added to the zcertstore class to return a zlistx of all the certificates in the store: - zcertstore_certs See zcertstore manpage for more info. * New DRAFT APIs have been added to the zcert class to create a new zcert from public/secret keypair in text form: - zcert_new_from_txt See zcert manpage for more info. * New DRAFT APIs have been added to the zsys class to get/set the default "stable" age value of files in zfile: - zsys_file_stable_age_msec - zsys_set_file_stable_age_msec See zsys and zfile manpages for more info. * New DRAFT APIs have been added to the zstr class to send and receive compressed strings: - zstr_recv_compress - zstr_send_compress - zstr_sendm_compress To enable them, build with the new (optional) lz4 dependency. See zstr manpage for more info. * New DRAFT APIs have been added to the zgossip class to support CURVE security: - "ZAP DOMAIN" actor message to set the ZAP domain for authentication - "SET PUBLICKEY" actor message to set the local public key - "SET SECRETKEY" actor message to set the local secret key - new optional parameter appended to "CONNECT" actor message, public key of the server See zgossip manpage for more info. * New DRAFT APIs have been added to the zfile class to support managing temporary files in a platform independent way: - zfile_tmp See zfile manpage for more info. * New DRAFT APIs have been added to the zconfig class to support removing a node and its subtrees or only the subtrees: - zconfig_remove_subtree - zconfig_remove See zconfig manpage for more info. * Added new FFI Python and Ruby bindings. * Add support for new ZMQ socket monitoring events to the zmonitor class: - HANDSHAKE_SUCCEEDED - HANDSHAKE_FAILED_NO_DETAIL - HANDSHAKE_FAILED_PROTOCOL - HANDSHAKE_FAILED_AUTH Requires libzmq version 4.2.3 or higher with DRAFT APIs enabled. * Fixed #1811 - add CZMQ_BUILD_SHARED/STATIC options to CMake to control whether to build shared/static libraries. Default to ON. The minimum required CMake version has been bumped from 2.8 to 2.8.8. * Fixed #1802 - fix using ziflist in a VirtualBox VM running on OSX. * Fixed #1798 - fix build on Cygwin. * Fixed #1773 - fix zfile_restat on Windows XP with newer MSVC++. * Fixed #1765 - fix build on OpenBSD. * Fixed #1755 - improve reliability of zproxy selftest in slower environments. * Fixed #1753 - fix zloop_set_nonstop to actually use the parameter passed by the user rather than always setting nonstop to true. * Fixed #1747 - check for OOM condition in zstr_send* functions. * Fixed #1730 - improve the internal usage of system random generator APIs to be more reliable. * Fixed #1728 - chomp all leading "/" in zfile_filename. * Fixed #1726 - do not bind to hard-coded TCP ports in self tests. * Fixed #1722 - define the PRI* types if not available on Windows. * Fixed #1715 - document ZSYS_SIGHANDLER behaviour w.r.t. the zsys_catch_interrupts API. * Fixed #1712 - clarify zsock_brecv documentation w.r.t buffers. * Fixed #1711 - set User-Id field in ZAP responses. * Fixed #1710 - clarify documentation of zframe_meta - the caller must not modify the returned value. * Fixed #1702 - clarify documentation of zhashx_set_key_comparator and zhashx_set_key_hasher. * Fixed #1675 - fix zhashx_purge memory leak when shrinking. * Fixed #1672 - fix compile error 'sockaddr_in': undeclared identifier on MSVC. * Fixed #1671 - add support for new (DRAFT) socket types in zframe_recv_nowait and zmsg_recv_nowait. * Fixed #1671 - correctly complete multipart receives in zmsg_recv_nowait. * Fixed #1667 - if ZSYS_IPV6_ADDRESS is link-local but does not have the %interface suffix, append it from ZSYS_INTERFACE. * Fixed #1659 - reset all CZMQ internal state in zsys_shutdown to facilitate use with fork without exec. * Fixed #1649 - set static pointers to NULL to fix restarting CZMQ via zsys_shutdown -> zsys_init. * Fixed #1644 - zbeacon on Windows only sends on one interfaces with INADDR_BROADCAST set (interface option "*"). * Fixed #1634 - zloop is using reader callback after zloop_reader_end. * Fixed #1632 - NULL pointer exception in ziflist on Windows if network adapters are added/removed whilst being enumerated. * Fixed #1623 - remove mentions of retired APIs from manpages. * Fixed #1618 - fix build with GCC 7. * Fixed #1616 - zsys_udp_recv will now return NULL when failing to retrieve the peer's address instead of silently failing. * Fixed #1616 - zsys_udp_recv's parameter peername must now be at least NI_MAXHOST long when IPv6 is enabled. * Fixed #1616 - add IPv6 support to zbeacon using, by default, link-local all-node address fe02::1 in lieu of broadcast (which does not exist on v6). The multicast address can be specified via zsys so, theoretically, it should work across multiple networks as well (untested!). * Fixed #1615 - add link-local all-node fe02::1 as the default zsys IPv6 multicast address. * Fixed #1615 - add IPv6 support to ziflist on *nix through new (DRAFT) APIs to avoid changing the output of old ones: ziflist_new_ipv6, ziflist_reload_ipv6 and ziflist_is_ipv6. * Fixed #1603 - generated socket options, and public API/ABI, were changing depending on the version of libzmq used at build time. Keep all the symbols stable instead and add additional runtime checks. Socket options APIs will now be built as empty stubs if unavailable in the libzmq version used at build time, and will return an error if not available in the libzmq version used at runtime. * Fixed #1609 - fix zdir selftest on Windows. * Fixed #1608 - document that on Windows it is necessary to call zsys_shutdown manually as DLLs do not support atexit() callbacks, and manually call it from all unit tests. * Fixed #1606 - use inproc instead of ipc in zproxy selftest to fix failure on Windows. * Fixed #1602 - ZSYS_INTERFACE: if the value is a single digit, interpret it as an index. Facilitates using it on Windows with complicated interface names. * Fixed #1599 - correctly handle CTRL_CLOSE_EVENT in Windows. * Fixed #1597 - added czmq_private_selftest to test private classes without exporting their symbols in the shared library. * Fixed #1597 - declare some internal-only helper functions as static to avoid exporting their symbols. * Fixed #1594 - correctly return -1 and set errno to EINVAL from zpoller_remove if the reader does not exist * Fixed #1590 - zsys_shutdown does not call zmq_term when it closes sockets which results in dangling sockets warnings. * Fixed #1588 - fix debian/kfreebsd build and always use external UUID library, if available, regardless of the OS. * Fixed #1459 - clarify zgossip documentation. * Fixed #1026 - zmsg_remove decreased count of frames even when it failed. * Fixed #1032 - clarify documentation of zhash_autofree and zhashx callbacks. CZMQ version 4.0.2 stable, released on 2016/12/31 ================================================= * Fixed #1559 - DRAFT zsock_new_*_checked symbols leak * Fixed #1560 - zsock options could be available at build time but not at runtime. Added runtime check, an error will be printed if the option is not available. * Fixed #1565 - improved compatibility with Solaris/Illumos * Fixed #1573 - memory leak when message send fails in internal usage CZMQ version 4.0.1 stable, released on 2016/11/10 ================================================= * Version 4.0.0 introduced the DRAFT mechanism, but it had a flaw: the internally defined DRAFT symbols were leaking as global in the shared library. This meant that although the API was stable, the ABI could in some cases not be. This has now been fixed using compiler's visibility attribute to avoid this problem. CZMQ version 4.0.0 stable, released on 2016/11/04 ================================================= * v4.0.0 breaks API and ABI compatibility with v3.0.2. The ABI version has been bumped to 4. * The v2 API, which have been declared DEPRECATED in v3.0.0 released on 2014/10/15, have now been declared RETIRED and removed from this release. The following classes are gone: - zauth_v2, use zauth - zbeacon_v2, use zbeacon - zctx, use zsock - zmonitor_v2, use zmonitor - zmutex - zproxy_v2, use zproxy - zsocket, use zsock - zsockopt, use zsock - zthread, use zactor The following DEPRECATED methods have also been declared RETIRED and removed from their STABLE classes: - zcert_fprint, use zcert_print - zcertstore_fprint, use zcertstore_print - zhash_foreach (and callback), use zhash_first/next - zhashx_foreach (and callback), use zhashx_first/next - zhashx_autofree, use zhashx_set_destructor - zloop_ignore_interrupts, use zloop_set_nonstop - zpoller_ignore_interrupts, use zpoller_set_nonstop * Some STABLE APIs unfortunately had to be slightly changed to fix critical issues. From v4.0.0 we commit to avoid incompatible changes to STABLE APIs. The following signatures have changed: - v3.0.2: byte * zarmour_decode (zarmour_t *self, const char *data, size_t *decode_size) v4.0.0: zchunk_t * zarmour_decode (zarmour_t *self, const char *data) - v3.0.2: zarmour_mode_t zarmour_mode (zarmour_t *self) v4.0.0: int zarmour_mode (zarmour_t *self) - v3.0.2: int zarmour_test (bool verbose) v4.0.0: void zarmour_test (bool verbose) - v3.0.2: zcert_t * zcert_new_from (byte *public_key, byte *secret_key) v4.0.0: zcert_t * zcert_new_from (const byte *public_key, const byte *secret_key) - v3.0.2: byte * zcert_public_key (zcert_t *self) v4.0.0: const byte * zcert_public_key (zcert_t *self) - v3.0.2: byte * zcert_secret_key (zcert_t *self) v4.0.0: const byte * zcert_secret_key (zcert_t *self) - v3.0.2: char * zcert_public_txt (zcert_t *self) v4.0.0: const * zcert_public_txt (zcert_t *self) - v3.0.2: char * zcert_secret_txt (zcert_t *self) v4.0.0: const * zcert_secret_txt (zcert_t *self) - v3.0.2: char * zcert_meta (zcert_t *self, const char *name) v4.0.0: const * zcert_meta (zcert_t *self, const char *name) - v3.0.2: void zdigest_update (zdigest_t *self, byte *buffer, size_t length) v4.0.0: void zdigest_update (zdigest_t *self, const byte *buffer, size_t length) - v3.0.2: byte * zdigest_data (zdigest_t *self) v4.0.0: const byte * zdigest_data (zdigest_t *self) - v3.0.2: enum zdir_patch_op_t {ZDIR_PATCH_CREATE, ZDIR_PATCH_DELETE} v4.0.0: define ZDIR_PATCH_CREATE ZDIR_PATCH_DELETE - v3.0.2: zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, zdir_patch_op_t op, const char *alias) v4.0.0: zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, int op, const char *alias) - v3.0.2: zdir_patch_op_t zdir_patch_op (zdir_patch_t *self) v4.0.0: int zdir_patch_op (zdir_patch_t *self) - v3.0.2: void zhash_test (int verbose) v4.0.0: void zhash_test (bool verbose) - v3.0.2: void zlist_test (int verbose) v4.0.0: void zlist_test (bool verbose) - v3.0.2: void zlistx_set_destructor (zlistx_t *self, czmq_destructor destructor) v4.0.0: void zlistx_set_destructor (zlistx_t *self, zlistx_destructor_fn destructor) - v3.0.2: void zlistx_set_duplicator (zlistx_t *self, czmq_duplicator duplicator) v4.0.0: void zlistx_set_duplicator (zlistx_t *self, zlistx_duplicator_fn duplicator) - v3.0.2: void zlistx_set_comparator (zlistx_t *self, czmq_comparator comparator) v4.0.0: void zlistx_set_comparator (zlistx_t *self, zlistx_comparator_fn comparator) - v3.0.2: void zlistx_test (int verbose) v4.0.0: void zlistx_test (bool verbose) - v3.0.2: zmsg_t * zmsg_load (zmsg_t *self, FILE *file) v4.0.0: zmsg_t * zmsg_load (FILE *file) - v3.0.2: zmsg_t * zmsg_decode (const byte *buffer, size_t buffer_size) v4.0.0: zmsg_t * zmsg_decode (zframe_t *frame) - v3.0.2: size_t zmsg_encode (zmsg_t *self, byte **buffer) v4.0.0: zframe_t * zmsg_encode (zmsg_t *self) - v3.0.2: int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address) v4.0.0: int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address, int addrlen) - v3.0.2: zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername) v4.0.0: zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername, int peerlen) * The following new STABLE methods were added to STABLE classes: - zarmour_mode_str, zarmour_print (see doc/zarmour.txt for details) - zconfig_test (see doc/zconfig.txt for details) - zframe_meta (see doc/zframe.txt for details) - zlistx_head zlistx_tail, zlistx_destructor_fn, zlistx_destructor_fn, zlistx_comparator_fn (see doc/zlistx.txt for details) - zloop_set_nonstop (see doc/zloop.txt for details) - zpoller_set_nonstop (see doc/zpoller.txt for details) - zsys_set_max_msgsz, zsys_max_msgsz, zsys_set_ipv6_address, zsys_ipv6_address, zsys_set_ipv6_mcast_address, zsys_ipv6_mcast_address, zsys_set_auto_use_fd, zsys_auto_use_fd (see doc/zsys.txt for details) * New DRAFT APIs early-release mechanism. New APIs will be introduced early in public releases, and until they are stabilized and guaranteed not to change anymore they will be unavailable unless the new build flag --enable-drafts is used. This will allow developers and early adopters to test new APIs before they are finalized. NOTE: as the name implies, NO GUARANTEE is made on the stability of these APIs. They might change or disappear entirely. Distributions are recommended NOT to build with them. The following DRAFT classes were added: - zproc - ztimerset - ztrie The following DRAFT methods were added to their respective STABLE class: - zcert_unset_meta - zcertstore_set_loader, zcertstore_empty - zframe_routing_id, zframe_set_routing_id, zframe_group, zframe_set_group - zhashx_unpack_own, zhashx_pack_own, zhashx_serializer_fn, zhashx_deserializer_fn - zmsg_routing_id, zmsg_set_routing_id - zstr_str * Support for new libzmq DRAFT socket types was added to zsock. See libzmq 4.2.0 release notes and doc/zsock.txt for more details. NOTE: until libzmq declares these as STABLE, the CZMQ support will be in DRAFT state as well. * Support for all new libzmq socket and context options was added to zsock. See libzmq 4.2.0 release notes and doc/zsock.txt for more details. * Many, many bug fixes. Check git log for the complete set of changes. CZMQ version 4.0.0 (rc1), released on 2016/11/01 ================================================= Release candidate 1 for 4.0.0. Changelog TBD. CZMQ version 3.0.2 stable, released on 2015/06/08 ================================================= Added LICENSE, README, and CONTRIBUTING. CZMQ version 3.0.1 stable, released on 2015/06/02 ================================================= CZMQ version 3.0.0 (rc1), released on 2014/10/15 ================================================ CZMQ version 2.2.0 stable, released on 2014/04/23 ================================================= CZMQ version 2.1.0 stable, released on 2014/03/20 ================================================= CZMQ version 2.0.3 stable, released on 2013/11/16 ================================================= Fixed to support ZeroMQ 3.2; was causing a build error due to use of ZMQ_STREAM in zsockopt.c. CZMQ version 2.0.2 stable, released on 2013/10/08 ================================================= * Fixed builds on MSVC and FreeBSD. * Fixed minor build issues in RC2. CZMQ version 2.0.1 (rc2), released on 2013/09/21 ================================================ Updated to support ZeroMQ v4.x. If you are using an older version of CZMQ it will not build correctly with ZeroMQ v4.x. Sorry about that. Added support for the new socket options: * zsocket_set_req_relaxed () * zsocket_set_req_correlate () * zsocket_set_conflate () CZMQ version 2.0.0 (rc1), released on 2013/09/19 ================================================ The changes are mainly tools to support encryption via the libzmq CURVE mechanism, but also some new API constructs to make it simpler to do common messaging work. Bug fixes and cleanups of codebase: * zconfig_load () failed if the ZPL file contained a blank line. * zconfig_locate () allows and ignores initial '/' on pathname. * Added zsys_vprintf () to centralize all variable string formatting; this code was duplicated many times across the project. * Updated zmsg interface documentation to be more detailed. * Removed deprecated zstr_sendfm () method. * Removed deprecated zstr_sendf () method. * Removed definition of ZMQ_IGNERR and added zloop_set_tolerant () to configure a specific poller as error-tolerant. * Removed deprecated zframe and zmsg zero-copy methods; this API was too complex and split over several classes, and IMO if we want this optimization it should be in a new zero-copy class with a clean API. * Removed deprecated zsocket zero-copy methods, for above reason. * Removed deprecated zlist_copy method. * Renamed zframe_print_to_stream to zframe_fprint and kept old name as deprecated macro. * Removed (not deprecated) zctx_set_hwm () as its semantics were not consistent, and confusing to people. * Removed (not deprecated) zctx_hwm (). We now have separate HWMs for normal socket SND and RCV, and for inter-thread pipes. There is no need to provide accessor methods for these. New API methods to simplify common messaging tasks: * Added zpoller class to provide new minimalist interface to zmq_poll. This class makes it very simple to read off a set of sockets, which is an 80% usecase. * Added zstr_sendx () to send multiple strings in one call. Inspired by PyZMQ's multipart send method. * Added zstr_recvx () to receive multiple strings in one call. We do a lot of multipart string reads; this makes it simpler for simple cases. * Added zclock_timestr () to provide date/time as printable string. * Added zmsg_append () that nullifies caller's frame reference; this is more consistent with the API style than zmsg_add (), which is deprecated. New classes used for security infrastructure: * Added zchunk class (from FileMQ), for managing memory blocks. This is a simpler model than zframes, which are optimized for message data. * Added zhash_comment () to add comments to a serialized zhash file. * Added zhash_refresh () to reload a backing file if modified on disk. * Added zconfig_comment () to add comments to saved config file, and added code to save such comments from file when loading it. * Moved zfile (char *filename) methods to zsys, to make place for a new zfile class based on the CLASS object model. The old methods are still provided but are deprecated. * Added zfile class (from FileMQ), for managing files. This provides a rich file class with metadata and operations. This is a component for directory management (zdir). * Added zdir class (from FileMQ), for managing directories. This lets us work with filesystem directories. I wanted this to be able to load certificates for security authentication. * The zdir and zfile classes are slightly stripped down from their FileMQ originals; no symbolic links, no directory difference tools. * Unfortunately to keep the old zfile_size and zfile_time methods, I had to use zfile_cursize and zfile_modified in the new class. This is a little clumsy. * Added zsys_file_modified () to return timestamp for a filename. * Added zcert class to work with Curve certificates. A certificate is a public + secret key pair, plus metadata like name, email, etc. and is saved as two files, a public text file and a secret text file. Certificates are stored in ZPL (ZMQ RFC 4) configuration file format. * Added zauth class to automate ZAP authenticators. This class does a simple plug and play authentication of clients against certificates stored in the $HOME/.curve directory. This can be extended over time with other designs. * Added zcertstore class to work with Curve certificate stores. This is a directory or in-memory store holding a set of certificates. * Extended zsockopt generation to allow use of binary keys in CURVE key options (e.g. zsocket_set_curve_secretkey_bin ()). * Added addons/makecert.c tool to generate CURVE certificates. * Added examples/security directory with several examples. For full details, see git log. CZMQ version 1.4.1 (stable), released on 2013/05/01 =================================================== Changes ------- * Fixed assertion in zbeacon on sendto error. * Fixed packaging of platform scripts in /builds. * See git log for rest. CZMQ version 1.4.0 (stable), released on 2013/04/30 =================================================== Changes ------- * Added zbeacon class. * See git log for rest. CZMQ version 1.3.2 (stable), released on 2012/12/22 =================================================== Changes ------- * See git log. CZMQ version 1.3.1 (stable), released on 2012/10/27 =================================================== Changes ------- * See git log. CZMQ version 1.3.0 (rc), not released ===================================== CZMQ version 1.2.0 (stable), released on 2012/08/06 =================================================== Changes ------- * zsockopt_ functions renamed to zsocket_, for clarity. Old names are still provided for compatibility. * SUB sockets are no longer subscribed to everything. * Fixed issue CZMQ-7, wrong name used for CZMQ man page. * Changed zsocket_connect() to return 0 or -1, since zmq_connect() now checks endpoints properly (issue LIBZMQ-207). * All classes handle memory exhaustion correctly by returning an error instead of asserting. * zsocket_identity implemented correctly. * Added zctx_underlying() to provide access to low-level 0MQ context object, to allow manipulation for extreme cases and tests. * For the rest, check the git history :-) CZMQ version 1.1.0 (stable), released on 2011/08/30 =================================================== Changes ------- * Fixed issue CZMQ-2. (https://zeromq.jira.com/browse/CZMQ-2) * Removed unused ctx argument from zthread_new() call. * zloop works with zmq_pollitem_t * instead of void * sockets; allows use of native FDs in reactor as well as 0MQ sockets. * zloop_reader renamed to zloop_poller. * zloop_cancel renamed to zloop_poller_end, and API changed to work with zmq_pollitem_t * instead of a single 0MQ socket void *. * Added zloop_timer_end, taking same argument as for zloop_timer. * zloop_poller_end cancels ALL handlers for the socket or FD. * Added zmsg_content_size method to report full content size of message. * zmsg_save returns 0/-1 depending on success/failure (previously returned void). * zmsg_dump limited to first 10 frames, to allow mix of large and small messages in applications. * zframe_print truncates output at 70 chars to prevent over-long output. * Added ability for zsocket_bind to bind to ephemeral port in range 0xc000 to 0xffff. * zmq_bind always returns port number bound to, if successful. * Added zfile class with minimal helper functions. * Added zfile_size method to return file size, as ssize_t. * Added socket multipart flush to zctx_destroy to work around libzmq issue 134, which asserts if a fair-queuing socket still has input at close. * Added zframe_eq method to compare two frames' size and content. * Changed zmsg_load to append to an optional existing message. * Fixed zloop to allow timers to be added after reactor was started. Without this fix, the reactor would spin at max speed instead of properly calculating the timer. (Luc Heinrich) * Modified zmsg_pushstr and zmsg_addstr to accept variable argument list and do vsnprintf formatting of provided string. * Added zhash_rename function to allow soft renaming of item keys. * Added tblsize and tbllast macros, so very useful when you need them. * Added zmsg_encode and zmsg_decode functions to serialize messages to and from a byte buffer. * Added zframe_recv_nowait method to read frame without blocking. CZMQ version 1.0.0 (stable), released on 2011/04/26 =================================================== Changes ------- * At build time, reports error if libzmq version isn't at least 2.1. * Renamed project to CZMQ for coherence with other language bindings. libzapi version 1.3.2 (beta), released on 2011/04/15 ==================================================== Changes ------- * Added zsocket_type_str method to return printable socket type. * Added zloop_set_verbose method to enable/disable reactor activity. * Fixed zloop to call right handlers even if handlers register/cancel other handlers. * Fixed zloop to not call handlers when interrupted. * Added zsocket_set_hwm method to emulate 2.x option (sets both send and recv high-water marks). * Several parts of the 3.0 porting didn't work properly - fixed. * Added macro set to aid portability from 2.1 to 3.0: ZMQ_POLL_MSEC, ZMQ_DONTWAIT, zmq_sendmsg, zmq_recvmsg. libzapi version 1.3.1 (beta), released on 2011/04/09 ==================================================== Changes ------- * Added compatibility for new libzmq/3.0 API. libzapi version 1.3.0 (beta), released on 2011/04/08 ==================================================== Changes ------- * Ported to win32, all selftests pass successfully. * New zsockopt class provides API to set/get socket options. * New zsocket class provides API to connect and bind sockets using printf semantics to format endpoints. * Threading API now supports detached and attached threads via zthread class, and zthread_new and zthread_fork methods. * Pipes to attached threads have HWM of 1 (each side) to block runaway writers. * In zframe class, added print, reset, strdup, streq, strhex, dup methods. * In zmsg class, added last, wrap, unwrap, popstr, pushstr, addstr, dup methods. * In zclock class, added log method. * In zstr class, added sendm and recv_nowait methods. * Added Valgrind suppression file for libzmq. Bug Fixes --------- * Fixed error in thread pipe handling which sometimes provoked libzmq assertion failure at shutdown. libzapi version 1.2.1 (beta), released on 2011/04/01 ==================================================== Changes ------- * Rewrote zctx class, which was wrongly working with sockets in two threads. Much simpler, and properly stable now. * Project renamed to 'libzapi' for consistency with 'libzmq'. * Expanded main documentation page significantly. zapi version 1.2.0 (beta), released on 2011/03/24 ================================================= Changes ------- * Added zclock class for portable millisecond timers and delays. * Expanded documentation significantly. zapi version 1.1.0 (beta), released on 2011/03/23 ================================================= Changes ------- * Added zctx_thread_new method to create child threads with a PAIR pipe to talk to them. * Made zapi threadsafe, specifically multiple threads can share the same context and thus talk to each other. zapi version 1.0.0 (beta), released on 2011/03/22 ================================================= Changes ------- * Initial version of library finished, tested, documented, and packaged. czmq-4.1.0/include/0000775000372000037200000000000013222211351015003 5ustar00travistravis00000000000000czmq-4.1.0/include/ztrie.h0000664000372000037200000000761213222211156016322 0ustar00travistravis00000000000000/* ========================================================================= ztrie - simple trie for tokenizable strings Copyright (c) 1991-2012 iMatix Corporation -- http://www.imatix.com Copyright other contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef ZTRIE_H_INCLUDED #define ZTRIE_H_INCLUDED #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/ztrie.api" to make changes. // @interface // This is a draft class, and may change without notice. It is disabled in // stable builds by default. If you use this in applications, please ask // for it to be pushed to stable state. Use --enable-drafts to enable. #ifdef CZMQ_BUILD_DRAFT_API // Callback function for ztrie_node to destroy node data. typedef void (ztrie_destroy_data_fn) ( void **data); // *** Draft method, for development use, may change without warning *** // Creates a new ztrie. CZMQ_EXPORT ztrie_t * ztrie_new (char delimiter); // *** Draft method, for development use, may change without warning *** // Destroy the ztrie. CZMQ_EXPORT void ztrie_destroy (ztrie_t **self_p); // *** Draft method, for development use, may change without warning *** // Inserts a new route into the tree and attaches the data. Returns -1 // if the route already exists, otherwise 0. This method takes ownership of // the provided data if a destroy_data_fn is provided. CZMQ_EXPORT int ztrie_insert_route (ztrie_t *self, const char *path, void *data, ztrie_destroy_data_fn destroy_data_fn); // *** Draft method, for development use, may change without warning *** // Removes a route from the trie and destroys its data. Returns -1 if the // route does not exists, otherwise 0. // the start of the list call zlist_first (). Advances the cursor. CZMQ_EXPORT int ztrie_remove_route (ztrie_t *self, const char *path); // *** Draft method, for development use, may change without warning *** // Returns true if the path matches a route in the tree, otherwise false. CZMQ_EXPORT bool ztrie_matches (ztrie_t *self, const char *path); // *** Draft method, for development use, may change without warning *** // Returns the data of a matched route from last ztrie_matches. If the path // did not match, returns NULL. Do not delete the data as it's owned by // ztrie. CZMQ_EXPORT void * ztrie_hit_data (ztrie_t *self); // *** Draft method, for development use, may change without warning *** // Returns the count of parameters that a matched route has. CZMQ_EXPORT size_t ztrie_hit_parameter_count (ztrie_t *self); // *** Draft method, for development use, may change without warning *** // Returns the parameters of a matched route with named regexes from last // ztrie_matches. If the path did not match or the route did not contain any // named regexes, returns NULL. CZMQ_EXPORT zhashx_t * ztrie_hit_parameters (ztrie_t *self); // *** Draft method, for development use, may change without warning *** // Returns the asterisk matched part of a route, if there has been no match // or no asterisk match, returns NULL. CZMQ_EXPORT const char * ztrie_hit_asterisk_match (ztrie_t *self); // *** Draft method, for development use, may change without warning *** // Print the trie CZMQ_EXPORT void ztrie_print (ztrie_t *self); // *** Draft method, for development use, may change without warning *** // Self test of this class. CZMQ_EXPORT void ztrie_test (bool verbose); #endif // CZMQ_BUILD_DRAFT_API // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zargs.h0000664000372000037200000001151713222211156016312 0ustar00travistravis00000000000000/* ========================================================================= zargs - Platform independent command line argument parsing helpers There are two kind of elements provided by this class foo --named-parameter --parameter with_value positional arguments -a gain-parameter zargs keeps poision only for arguments, parameters are to be accessed like hash. It DOES: * provide easy to use CLASS compatible API for accessing argv * is platform independent * provide getopt_long style -- argument, which delimits parameters from arguments * makes parameters positon independent * hides several formats of command line to one (-Idir, --include=dir, --include dir are the same from API pov) It does NOT * change argv * provide a "declarative" way to define command line interface Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef ZARGS_H_INCLUDED #define ZARGS_H_INCLUDED #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zargs.api" to make changes. // @interface // This is a draft class, and may change without notice. It is disabled in // stable builds by default. If you use this in applications, please ask // for it to be pushed to stable state. Use --enable-drafts to enable. #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Create a new zargs from command line arguments. CZMQ_EXPORT zargs_t * zargs_new (int argc, char **argv); // *** Draft method, for development use, may change without warning *** // Destroy zargs instance. CZMQ_EXPORT void zargs_destroy (zargs_t **self_p); // *** Draft method, for development use, may change without warning *** // Return program name (argv[0]) CZMQ_EXPORT const char * zargs_progname (zargs_t *self); // *** Draft method, for development use, may change without warning *** // Return number of positional arguments CZMQ_EXPORT size_t zargs_arguments (zargs_t *self); // *** Draft method, for development use, may change without warning *** // Return first positional argument or NULL CZMQ_EXPORT const char * zargs_first (zargs_t *self); // *** Draft method, for development use, may change without warning *** // Return next positional argument or NULL CZMQ_EXPORT const char * zargs_next (zargs_t *self); // *** Draft method, for development use, may change without warning *** // Return first named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. CZMQ_EXPORT const char * zargs_param_first (zargs_t *self); // *** Draft method, for development use, may change without warning *** // Return next named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. CZMQ_EXPORT const char * zargs_param_next (zargs_t *self); // *** Draft method, for development use, may change without warning *** // Return current parameter name, or NULL if there are no named // parameters. CZMQ_EXPORT const char * zargs_param_name (zargs_t *self); // *** Draft method, for development use, may change without warning *** // Return value of named parameter, NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. CZMQ_EXPORT const char * zargs_param_lookup (zargs_t *self, const char *keys); // *** Draft method, for development use, may change without warning *** // Return value of named parameter(s), NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. CZMQ_EXPORT const char * zargs_param_lookupx (zargs_t *self, const char *keys, ...); // *** Draft method, for development use, may change without warning *** // Returns true if there are --help -h arguments CZMQ_EXPORT bool zargs_has_help (zargs_t *self); // *** Draft method, for development use, may change without warning *** // Returns true if parameter did not have a value CZMQ_EXPORT bool zargs_param_empty (const char *arg); // *** Draft method, for development use, may change without warning *** // Print an instance of zargs. CZMQ_EXPORT void zargs_print (zargs_t *self); // *** Draft method, for development use, may change without warning *** // Self test of this class. CZMQ_EXPORT void zargs_test (bool verbose); #endif // CZMQ_BUILD_DRAFT_API // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zhashx.h0000664000372000037200000002530213222211156016466 0ustar00travistravis00000000000000/* ========================================================================= zhashx - extended generic type-free hash container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZHASHX_H_INCLUDED__ #define __ZHASHX_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zhashx.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Destroy an item typedef void (zhashx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zhashx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zhashx_comparator_fn) ( const void *item1, const void *item2); // Destroy an item. typedef void (zhashx_free_fn) ( void *data); // Hash function for keys. typedef size_t (zhashx_hash_fn) ( const void *key); // Serializes an item to a longstr. // The caller takes ownership of the newly created object. typedef char * (zhashx_serializer_fn) ( const void *item); // Deserializes a longstr into an item. // The caller takes ownership of the newly created object. typedef void * (zhashx_deserializer_fn) ( const char *item_str); // Create a new, empty hash container CZMQ_EXPORT zhashx_t * zhashx_new (void); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. CZMQ_EXPORT zhashx_t * zhashx_unpack (zframe_t *frame); // Destroy a hash container and all items in it CZMQ_EXPORT void zhashx_destroy (zhashx_t **self_p); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. CZMQ_EXPORT int zhashx_insert (zhashx_t *self, const void *key, void *item); // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. CZMQ_EXPORT void zhashx_update (zhashx_t *self, const void *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. CZMQ_EXPORT void zhashx_delete (zhashx_t *self, const void *key); // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. CZMQ_EXPORT void zhashx_purge (zhashx_t *self); // Return the item at the specified key, or null CZMQ_EXPORT void * zhashx_lookup (zhashx_t *self, const void *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. CZMQ_EXPORT int zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn free_fn); // Return the number of keys/items in the hash table CZMQ_EXPORT size_t zhashx_size (zhashx_t *self); // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlistx_t * zhashx_keys (zhashx_t *self); // Return a zlistx_t containing the values for the items in the // table. Uses the duplicator to duplicate all items and sets the // destructor as destructor for the list. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlistx_t * zhashx_values (zhashx_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhashx_cursor(). NOTE: do NOT modify the table while iterating. CZMQ_EXPORT void * zhashx_first (zhashx_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). To // access the key for this item use zhashx_cursor(). NOTE: do NOT modify // the table while iterating. CZMQ_EXPORT void * zhashx_next (zhashx_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. CZMQ_EXPORT const void * zhashx_cursor (zhashx_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. CZMQ_EXPORT void zhashx_comment (zhashx_t *self, const char *format, ...) CHECK_PRINTF (2); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. CZMQ_EXPORT int zhashx_save (zhashx_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. CZMQ_EXPORT int zhashx_load (zhashx_t *self, const char *filename); // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. CZMQ_EXPORT int zhashx_refresh (zhashx_t *self); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zhashx_pack (zhashx_t *self); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zhashx_t * zhashx_dup (zhashx_t *self); // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. CZMQ_EXPORT void zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. CZMQ_EXPORT void zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined deallocator for keys; by default keys are freed // when the hash is destroyed using free(). CZMQ_EXPORT void zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for keys; by default keys are duplicated // using strdup. CZMQ_EXPORT void zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined comparator for keys; by default keys are // compared using strcmp. // The callback function should return zero (0) on matching // items. CZMQ_EXPORT void zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator); // Set a user-defined hash function for keys; by default keys are // hashed by a modified Bernstein hashing function. CZMQ_EXPORT void zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. CZMQ_EXPORT zhashx_t * zhashx_dup_v2 (zhashx_t *self); // Self test of this class. CZMQ_EXPORT void zhashx_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Same as unpack but uses a user-defined deserializer function to convert // a longstr back into item format. CZMQ_EXPORT zhashx_t * zhashx_unpack_own (zframe_t *frame, zhashx_deserializer_fn deserializer); // *** Draft method, for development use, may change without warning *** // Same as pack but uses a user-defined serializer function to convert items // into longstr. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zhashx_pack_own (zhashx_t *self, zhashx_serializer_fn serializer); #endif // CZMQ_BUILD_DRAFT_API // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zdir_patch.h0000664000372000037200000000447513222211156017320 0ustar00travistravis00000000000000/* ========================================================================= zdir_patch - work with directory patches Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZDIR_PATCH_H_INCLUDED__ #define __ZDIR_PATCH_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // un-namespaced enumeration values #define patch_create ZDIR_PATCH_CREATE #define patch_delete ZDIR_PATCH_DELETE // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zdir_patch.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. #define ZDIR_PATCH_CREATE 1 // Creates a new file #define ZDIR_PATCH_DELETE 2 // Delete a file // Create new patch CZMQ_EXPORT zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, int op, const char *alias); // Destroy a patch CZMQ_EXPORT void zdir_patch_destroy (zdir_patch_t **self_p); // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zdir_patch_t * zdir_patch_dup (zdir_patch_t *self); // Return patch file directory path CZMQ_EXPORT const char * zdir_patch_path (zdir_patch_t *self); // Return patch file item CZMQ_EXPORT zfile_t * zdir_patch_file (zdir_patch_t *self); // Return operation CZMQ_EXPORT int zdir_patch_op (zdir_patch_t *self); // Return patch virtual file path CZMQ_EXPORT const char * zdir_patch_vpath (zdir_patch_t *self); // Calculate hash digest for file (create only) CZMQ_EXPORT void zdir_patch_digest_set (zdir_patch_t *self); // Return hash digest for patch file CZMQ_EXPORT const char * zdir_patch_digest (zdir_patch_t *self); // Self test of this class. CZMQ_EXPORT void zdir_patch_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zsock.h0000664000372000037200000012315213222211156016314 0ustar00travistravis00000000000000/* ========================================================================= zsock - high-level socket API that hides libzmq contexts and sockets Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZSOCK_H_INCLUDED__ #define __ZSOCK_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // This interface includes some smart constructors, which create sockets with // additional set-up. In all of these, the endpoint is NULL, or starts with // '@' (bind) or '>' (connect). Multiple endpoints are allowed, separated by // commas. If endpoint does not start with '@' or '>', default action depends // on socket type. // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zsock.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Create a new socket. Returns the new socket, or NULL if the new socket // could not be created. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection. This can have // performance implications if you use a LOT of sockets. To turn off this // redirection behaviour, define ZSOCK_NOCHECK. CZMQ_EXPORT zsock_t * zsock_new (int type); // Create a PUB socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_pub (const char *endpoint); // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. CZMQ_EXPORT zsock_t * zsock_new_sub (const char *endpoint, const char *subscribe); // Create a REQ socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_req (const char *endpoint); // Create a REP socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_rep (const char *endpoint); // Create a DEALER socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_dealer (const char *endpoint); // Create a ROUTER socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_router (const char *endpoint); // Create a PUSH socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_push (const char *endpoint); // Create a PULL socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_pull (const char *endpoint); // Create an XPUB socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_xpub (const char *endpoint); // Create an XSUB socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_xsub (const char *endpoint); // Create a PAIR socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_pair (const char *endpoint); // Create a STREAM socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_stream (const char *endpoint); // Destroy the socket. You must use this for any socket created via the // zsock_new method. CZMQ_EXPORT void zsock_destroy (zsock_t **self_p); // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. CZMQ_EXPORT int zsock_bind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Returns last bound endpoint, if any. CZMQ_EXPORT const char * zsock_endpoint (zsock_t *self); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsock_unbind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. CZMQ_EXPORT int zsock_connect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. CZMQ_EXPORT int zsock_disconnect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2); // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). CZMQ_EXPORT int zsock_attach (zsock_t *self, const char *endpoints, bool serverish); // Returns socket type as printable constant string. CZMQ_EXPORT const char * zsock_type_str (zsock_t *self); // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. CZMQ_EXPORT int zsock_send (void *self, const char *picture, ...); // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. CZMQ_EXPORT int zsock_vsend (void *self, const char *picture, va_list argptr); // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // U = zuuid_t * (creates a zuuid with the data) // h = zhashx_t ** (creates zhashx) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. CZMQ_EXPORT int zsock_recv (void *self, const char *picture, ...); // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. CZMQ_EXPORT int zsock_vrecv (void *self, const char *picture, va_list argptr); // Send a binary encoded 'picture' message to the socket (or actor). This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations. The pattern argument is a string that defines the // type of each argument. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0-255 chars type = "string" // S char *, 0-2^32-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // u zuuid_t * type = "uuid" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments. Returns 0 if // successful, -1 if sending failed for any reason. CZMQ_EXPORT int zsock_bsend (void *self, const char *picture, ...); // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. // For types 1, 2, 4 and 8 the caller must allocate the memory itself before // calling zsock_brecv. // For types S, the caller must free the value once finished with it, as // zsock_brecv will allocate the buffer. // For type s, the caller must not free the value as it is stored in a // local cache for performance purposes. // For types c, f, u and m the caller must call the appropriate destructor // depending on the object as zsock_brecv will create new objects. // For type p the caller must coordinate with the sender, as it is just a // pointer value being passed. CZMQ_EXPORT int zsock_brecv (void *self, const char *picture, ...); // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. CZMQ_EXPORT void zsock_set_unbounded (void *self); // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zsock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. CZMQ_EXPORT int zsock_signal (void *self, byte status); // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. CZMQ_EXPORT int zsock_wait (void *self); // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. CZMQ_EXPORT void zsock_flush (void *self); // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. CZMQ_EXPORT bool zsock_is (void *self); // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. CZMQ_EXPORT void * zsock_resolve (void *self); // Get socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_heartbeat_ivl (void *self); // Set socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl); // Get socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_heartbeat_ttl (void *self); // Set socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl); // Get socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_heartbeat_timeout (void *self); // Set socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout); // Get socket option `use_fd`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_use_fd (void *self); // Set socket option `use_fd`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_use_fd (void *self, int use_fd); // Set socket option `xpub_manual`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_xpub_manual (void *self, int xpub_manual); // Set socket option `xpub_welcome_msg`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_xpub_welcome_msg (void *self, const char *xpub_welcome_msg); // Set socket option `stream_notify`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_stream_notify (void *self, int stream_notify); // Get socket option `invert_matching`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_invert_matching (void *self); // Set socket option `invert_matching`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_invert_matching (void *self, int invert_matching); // Set socket option `xpub_verboser`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_xpub_verboser (void *self, int xpub_verboser); // Get socket option `connect_timeout`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_connect_timeout (void *self); // Set socket option `connect_timeout`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_connect_timeout (void *self, int connect_timeout); // Get socket option `tcp_maxrt`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_tcp_maxrt (void *self); // Set socket option `tcp_maxrt`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_tcp_maxrt (void *self, int tcp_maxrt); // Get socket option `thread_safe`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_thread_safe (void *self); // Get socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_multicast_maxtpdu (void *self); // Set socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu); // Get socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_vmci_buffer_size (void *self); // Set socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size); // Get socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_vmci_buffer_min_size (void *self); // Set socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size); // Get socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_vmci_buffer_max_size (void *self); // Set socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size); // Get socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_vmci_connect_timeout (void *self); // Set socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. CZMQ_EXPORT void zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout); // Get socket option `tos`. // Available from libzmq 4.1.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_tos (void *self); // Set socket option `tos`. // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_tos (void *self, int tos); // Set socket option `router_handover`. // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_router_handover (void *self, int router_handover); // Set socket option `connect_rid`. // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_connect_rid (void *self, const char *connect_rid); // Set socket option `connect_rid` from 32-octet binary // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_connect_rid_bin (void *self, const byte *connect_rid); // Get socket option `handshake_ivl`. // Available from libzmq 4.1.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_handshake_ivl (void *self); // Set socket option `handshake_ivl`. // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_handshake_ivl (void *self, int handshake_ivl); // Get socket option `socks_proxy`. // Available from libzmq 4.1.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_socks_proxy (void *self); // Set socket option `socks_proxy`. // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_socks_proxy (void *self, const char *socks_proxy); // Set socket option `xpub_nodrop`. // Available from libzmq 4.1.0. CZMQ_EXPORT void zsock_set_xpub_nodrop (void *self, int xpub_nodrop); // Set socket option `router_mandatory`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_router_mandatory (void *self, int router_mandatory); // Set socket option `probe_router`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_probe_router (void *self, int probe_router); // Set socket option `req_relaxed`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_req_relaxed (void *self, int req_relaxed); // Set socket option `req_correlate`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_req_correlate (void *self, int req_correlate); // Set socket option `conflate`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_conflate (void *self, int conflate); // Get socket option `zap_domain`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_zap_domain (void *self); // Set socket option `zap_domain`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_zap_domain (void *self, const char *zap_domain); // Get socket option `mechanism`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_mechanism (void *self); // Get socket option `plain_server`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_plain_server (void *self); // Set socket option `plain_server`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_plain_server (void *self, int plain_server); // Get socket option `plain_username`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_plain_username (void *self); // Set socket option `plain_username`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_plain_username (void *self, const char *plain_username); // Get socket option `plain_password`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_plain_password (void *self); // Set socket option `plain_password`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_plain_password (void *self, const char *plain_password); // Get socket option `curve_server`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_curve_server (void *self); // Set socket option `curve_server`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_server (void *self, int curve_server); // Get socket option `curve_publickey`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_curve_publickey (void *self); // Set socket option `curve_publickey`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_publickey (void *self, const char *curve_publickey); // Set socket option `curve_publickey` from 32-octet binary // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey); // Get socket option `curve_secretkey`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_curve_secretkey (void *self); // Set socket option `curve_secretkey`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_secretkey (void *self, const char *curve_secretkey); // Set socket option `curve_secretkey` from 32-octet binary // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey); // Get socket option `curve_serverkey`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_curve_serverkey (void *self); // Set socket option `curve_serverkey`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_serverkey (void *self, const char *curve_serverkey); // Set socket option `curve_serverkey` from 32-octet binary // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey); // Get socket option `gssapi_server`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_gssapi_server (void *self); // Set socket option `gssapi_server`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_gssapi_server (void *self, int gssapi_server); // Get socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_gssapi_plaintext (void *self); // Set socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext); // Get socket option `gssapi_principal`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_gssapi_principal (void *self); // Set socket option `gssapi_principal`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_gssapi_principal (void *self, const char *gssapi_principal); // Get socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_gssapi_service_principal (void *self); // Set socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_gssapi_service_principal (void *self, const char *gssapi_service_principal); // Get socket option `ipv6`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_ipv6 (void *self); // Set socket option `ipv6`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_ipv6 (void *self, int ipv6); // Get socket option `immediate`. // Available from libzmq 4.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_immediate (void *self); // Set socket option `immediate`. // Available from libzmq 4.0.0. CZMQ_EXPORT void zsock_set_immediate (void *self, int immediate); // Get socket option `sndhwm`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_sndhwm (void *self); // Set socket option `sndhwm`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_sndhwm (void *self, int sndhwm); // Get socket option `rcvhwm`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_rcvhwm (void *self); // Set socket option `rcvhwm`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_rcvhwm (void *self, int rcvhwm); // Get socket option `maxmsgsize`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_maxmsgsize (void *self); // Set socket option `maxmsgsize`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_maxmsgsize (void *self, int maxmsgsize); // Get socket option `multicast_hops`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_multicast_hops (void *self); // Set socket option `multicast_hops`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_multicast_hops (void *self, int multicast_hops); // Set socket option `xpub_verbose`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_xpub_verbose (void *self, int xpub_verbose); // Get socket option `tcp_keepalive`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_tcp_keepalive (void *self); // Set socket option `tcp_keepalive`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); // Get socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_tcp_keepalive_idle (void *self); // Set socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); // Get socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_tcp_keepalive_cnt (void *self); // Set socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); // Get socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_tcp_keepalive_intvl (void *self); // Set socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); // Get socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_tcp_accept_filter (void *self); // Set socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_tcp_accept_filter (void *self, const char *tcp_accept_filter); // Get socket option `last_endpoint`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_last_endpoint (void *self); // Set socket option `router_raw`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_router_raw (void *self, int router_raw); // Get socket option `ipv4only`. // Available from libzmq 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_ipv4only (void *self); // Set socket option `ipv4only`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_ipv4only (void *self, int ipv4only); // Set socket option `delay_attach_on_connect`. // Available from libzmq 3.0.0. CZMQ_EXPORT void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); // Get socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_hwm (void *self); // Set socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. CZMQ_EXPORT void zsock_set_hwm (void *self, int hwm); // Get socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_swap (void *self); // Set socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. CZMQ_EXPORT void zsock_set_swap (void *self, int swap); // Get socket option `affinity`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_affinity (void *self); // Set socket option `affinity`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_affinity (void *self, int affinity); // Get socket option `identity`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zsock_identity (void *self); // Set socket option `identity`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_identity (void *self, const char *identity); // Get socket option `rate`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_rate (void *self); // Set socket option `rate`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_rate (void *self, int rate); // Get socket option `recovery_ivl`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_recovery_ivl (void *self); // Set socket option `recovery_ivl`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_recovery_ivl (void *self, int recovery_ivl); // Get socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_recovery_ivl_msec (void *self); // Set socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. CZMQ_EXPORT void zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec); // Get socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_mcast_loop (void *self); // Set socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. CZMQ_EXPORT void zsock_set_mcast_loop (void *self, int mcast_loop); // Get socket option `rcvtimeo`. // Available from libzmq 2.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_rcvtimeo (void *self); // Set socket option `rcvtimeo`. // Available from libzmq 2.2.0. CZMQ_EXPORT void zsock_set_rcvtimeo (void *self, int rcvtimeo); // Get socket option `sndtimeo`. // Available from libzmq 2.2.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_sndtimeo (void *self); // Set socket option `sndtimeo`. // Available from libzmq 2.2.0. CZMQ_EXPORT void zsock_set_sndtimeo (void *self, int sndtimeo); // Get socket option `sndbuf`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_sndbuf (void *self); // Set socket option `sndbuf`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_sndbuf (void *self, int sndbuf); // Get socket option `rcvbuf`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_rcvbuf (void *self); // Set socket option `rcvbuf`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_rcvbuf (void *self, int rcvbuf); // Get socket option `linger`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_linger (void *self); // Set socket option `linger`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_linger (void *self, int linger); // Get socket option `reconnect_ivl`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_reconnect_ivl (void *self); // Set socket option `reconnect_ivl`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); // Get socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_reconnect_ivl_max (void *self); // Set socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); // Get socket option `backlog`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_backlog (void *self); // Set socket option `backlog`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_backlog (void *self, int backlog); // Set socket option `subscribe`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_subscribe (void *self, const char *subscribe); // Set socket option `unsubscribe`. // Available from libzmq 2.0.0. CZMQ_EXPORT void zsock_set_unsubscribe (void *self, const char *unsubscribe); // Get socket option `type`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_type (void *self); // Get socket option `rcvmore`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_rcvmore (void *self); // Get socket option `fd`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT SOCKET zsock_fd (void *self); // Get socket option `events`. // Available from libzmq 2.0.0. // Caller owns return value and must destroy it when done. CZMQ_EXPORT int zsock_events (void *self); // Self test of this class. CZMQ_EXPORT void zsock_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Create a SERVER socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_server (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Create a CLIENT socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_client (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Create a RADIO socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_radio (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Create a DISH socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_dish (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Create a GATHER socket. Default action is bind. CZMQ_EXPORT zsock_t * zsock_new_gather (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Create a SCATTER socket. Default action is connect. CZMQ_EXPORT zsock_t * zsock_new_scatter (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Return socket routing ID if any. This returns 0 if the socket is not // of type ZMQ_SERVER or if no request was already received on it. CZMQ_EXPORT uint32_t zsock_routing_id (zsock_t *self); // *** Draft method, for development use, may change without warning *** // Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. // This will be used when sending messages on the socket via the zsock API. CZMQ_EXPORT void zsock_set_routing_id (zsock_t *self, uint32_t routing_id); // *** Draft method, for development use, may change without warning *** // Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. CZMQ_EXPORT int zsock_join (void *self, const char *group); // *** Draft method, for development use, may change without warning *** // Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. CZMQ_EXPORT int zsock_leave (void *self, const char *group); #endif // CZMQ_BUILD_DRAFT_API // @end // zsock leak detection - not a part of the official interface to zsock. This // enables CZMQ to report socket leaks intelligently. #if defined ZSOCK_NOCHECK // no checking active - use the above interface methods directly. #else # define zsock_new(t) zsock_new_checked((t), __FILE__, __LINE__) # define zsock_new_pub(e) zsock_new_pub_checked((e), __FILE__, __LINE__) # define zsock_new_sub(e,s) zsock_new_sub_checked((e), (s), __FILE__, __LINE__) # define zsock_new_req(e) zsock_new_req_checked((e), __FILE__, __LINE__) # define zsock_new_rep(e) zsock_new_rep_checked((e), __FILE__, __LINE__) # define zsock_new_dealer(e) zsock_new_dealer_checked((e), __FILE__, __LINE__) # define zsock_new_router(e) zsock_new_router_checked((e), __FILE__, __LINE__) # define zsock_new_pull(e) zsock_new_pull_checked((e), __FILE__, __LINE__) # define zsock_new_push(e) zsock_new_push_checked((e), __FILE__, __LINE__) # define zsock_new_xpub(e) zsock_new_xpub_checked((e), __FILE__, __LINE__) # define zsock_new_xsub(e) zsock_new_xsub_checked((e), __FILE__, __LINE__) # define zsock_new_pair(e) zsock_new_pair_checked((e), __FILE__, __LINE__) # define zsock_new_stream(e) zsock_new_stream_checked((e), __FILE__, __LINE__) # define zsock_destroy(t) zsock_destroy_checked((t), __FILE__, __LINE__) #endif CZMQ_EXPORT zsock_t * zsock_new_checked (int type, const char *filename, size_t line_nbr); CZMQ_EXPORT void zsock_destroy_checked (zsock_t **self_p, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_pub_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_sub_checked (const char *endpoint, const char *subscribe, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_req_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_rep_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_dealer_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_router_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_push_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_pull_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_xpub_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_xsub_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_pair_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_stream_checked (const char *endpoint, const char *filename, size_t line_nbr); #ifdef CZMQ_BUILD_DRAFT_API CZMQ_EXPORT zsock_t * zsock_new_server_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_client_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_radio_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_dish_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_gather_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_EXPORT zsock_t * zsock_new_scatter_checked (const char *endpoint, const char *filename, size_t line_nbr); #endif // CZMQ_BUILD_DRAFT_API #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/ztimerset.h0000664000372000037200000000646013222211156017213 0ustar00travistravis00000000000000/* ========================================================================= ztimerset - timer set Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef ZTIMERSET_H_INCLUDED #define ZTIMERSET_H_INCLUDED #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/ztimerset.api" to make changes. // @interface // This is a draft class, and may change without notice. It is disabled in // stable builds by default. If you use this in applications, please ask // for it to be pushed to stable state. Use --enable-drafts to enable. #ifdef CZMQ_BUILD_DRAFT_API // Callback function for timer event. typedef void (ztimerset_fn) ( int timer_id, void *arg); // *** Draft method, for development use, may change without warning *** // Create new timer set. CZMQ_EXPORT ztimerset_t * ztimerset_new (void); // *** Draft method, for development use, may change without warning *** // Destroy a timer set CZMQ_EXPORT void ztimerset_destroy (ztimerset_t **self_p); // *** Draft method, for development use, may change without warning *** // Add a timer to the set. Returns timer id if OK, -1 on failure. CZMQ_EXPORT int ztimerset_add (ztimerset_t *self, size_t interval, ztimerset_fn handler, void *arg); // *** Draft method, for development use, may change without warning *** // Cancel a timer. Returns 0 if OK, -1 on failure. CZMQ_EXPORT int ztimerset_cancel (ztimerset_t *self, int timer_id); // *** Draft method, for development use, may change without warning *** // Set timer interval. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. CZMQ_EXPORT int ztimerset_set_interval (ztimerset_t *self, int timer_id, size_t interval); // *** Draft method, for development use, may change without warning *** // Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. CZMQ_EXPORT int ztimerset_reset (ztimerset_t *self, int timer_id); // *** Draft method, for development use, may change without warning *** // Return the time until the next interval. // Should be used as timeout parameter for the zpoller wait method. // The timeout is in msec. CZMQ_EXPORT int ztimerset_timeout (ztimerset_t *self); // *** Draft method, for development use, may change without warning *** // Invoke callback function of all timers which their interval has elapsed. // Should be call after zpoller wait method. // Returns 0 if OK, -1 on failure. CZMQ_EXPORT int ztimerset_execute (ztimerset_t *self); // *** Draft method, for development use, may change without warning *** // Self test of this class. CZMQ_EXPORT void ztimerset_test (bool verbose); #endif // CZMQ_BUILD_DRAFT_API // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zlist.h0000664000372000037200000001337513222211156016335 0ustar00travistravis00000000000000/* ========================================================================= zlist - simple generic list container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZLIST_H_INCLUDED__ #define __ZLIST_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zlist.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Comparison function e.g. for sorting and removing. typedef int (zlist_compare_fn) ( void *item1, void *item2); // Callback function for zlist_freefn method typedef void (zlist_free_fn) ( void *data); // Create a new list container CZMQ_EXPORT zlist_t * zlist_new (void); // Destroy a list container CZMQ_EXPORT void zlist_destroy (zlist_t **self_p); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_first (zlist_t *self); // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. CZMQ_EXPORT void * zlist_next (zlist_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_last (zlist_t *self); // Return first item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlist_head (zlist_t *self); // Return last item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlist_tail (zlist_t *self); // Return the current item of list. If the list is empty, returns NULL. // Leaves cursor pointing at the current item, or NULL if the list is empty. CZMQ_EXPORT void * zlist_item (zlist_t *self); // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. CZMQ_EXPORT int zlist_append (zlist_t *self, void *item); // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. CZMQ_EXPORT int zlist_push (zlist_t *self, void *item); // Pop the item off the start of the list, if any CZMQ_EXPORT void * zlist_pop (zlist_t *self); // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. CZMQ_EXPORT bool zlist_exists (zlist_t *self, void *item); // Remove the specified item from the list if present CZMQ_EXPORT void zlist_remove (zlist_t *self, void *item); // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlist_t * zlist_dup (zlist_t *self); // Purge all items from list CZMQ_EXPORT void zlist_purge (zlist_t *self); // Return number of items in the list CZMQ_EXPORT size_t zlist_size (zlist_t *self); // Sort the list. If the compare function is null, sorts the list by // ascending key value using a straight ASCII comparison. If you specify // a compare function, this decides how items are sorted. The sort is not // stable, so may reorder items with the same keys. The algorithm used is // combsort, a compromise between performance and simplicity. CZMQ_EXPORT void zlist_sort (zlist_t *self, zlist_compare_fn compare); // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. CZMQ_EXPORT void zlist_autofree (zlist_t *self); // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. CZMQ_EXPORT void zlist_comparefn (zlist_t *self, zlist_compare_fn fn); // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zlist_freefn (zlist_t *self, void *item, zlist_free_fn fn, bool at_tail); // Self test of this class. CZMQ_EXPORT void zlist_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zmsg.h0000664000372000037200000002467313222211156016153 0ustar00travistravis00000000000000/* ========================================================================= zmsg - working with multipart messages Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZMSG_H_INCLUDED__ #define __ZMSG_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zmsg.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Create a new empty message object CZMQ_EXPORT zmsg_t * zmsg_new (void); // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted. Does a blocking recv. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving. CZMQ_EXPORT zmsg_t * zmsg_recv (void *source); // Load/append an open file into new message, return the message. // Returns NULL if the message could not be loaded. CZMQ_EXPORT zmsg_t * zmsg_load (FILE *file); // Decodes a serialized message frame created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the frame was badly formatted or // there was insufficient memory to work. CZMQ_EXPORT zmsg_t * zmsg_decode (zframe_t *frame); // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. CZMQ_EXPORT zmsg_t * zmsg_new_signal (byte status); // Destroy a message object and all frames it contains CZMQ_EXPORT void zmsg_destroy (zmsg_t **self_p); // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). CZMQ_EXPORT int zmsg_send (zmsg_t **self_p, void *dest); // Send message to destination socket as part of a multipart sequence, and // destroy the message after sending it successfully. Note that after a // zmsg_sendm, you must call zmsg_send or another method that sends a final // message part. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). CZMQ_EXPORT int zmsg_sendm (zmsg_t **self_p, void *dest); // Return size of message, i.e. number of frames (0 or more). CZMQ_EXPORT size_t zmsg_size (zmsg_t *self); // Return total size of all frames in message. CZMQ_EXPORT size_t zmsg_content_size (zmsg_t *self); // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. CZMQ_EXPORT int zmsg_prepend (zmsg_t *self, zframe_t **frame_p); // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Deprecates zmsg_add, which did not nullify the // caller's frame reference. CZMQ_EXPORT int zmsg_append (zmsg_t *self, zframe_t **frame_p); // Remove first frame from message, if any. Returns frame, or NULL. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zmsg_pop (zmsg_t *self); // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushmem (zmsg_t *self, const void *data, size_t size); // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addmem (zmsg_t *self, const void *data, size_t size); // Push string as new frame to front of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushstr (zmsg_t *self, const char *string); // Push string as new frame to end of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addstr (zmsg_t *self, const char *string); // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_pushstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_addstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zmsg_popstr (zmsg_t *self); // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. CZMQ_EXPORT int zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p); // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not successful. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zmsg_t * zmsg_popmsg (zmsg_t *self); // Remove specified frame from list, if present. Does not destroy frame. CZMQ_EXPORT void zmsg_remove (zmsg_t *self, zframe_t *frame); // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. CZMQ_EXPORT zframe_t * zmsg_first (zmsg_t *self); // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. CZMQ_EXPORT zframe_t * zmsg_next (zmsg_t *self); // Return the last frame. If there are no frames, returns NULL. CZMQ_EXPORT zframe_t * zmsg_last (zmsg_t *self); // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. CZMQ_EXPORT int zmsg_save (zmsg_t *self, FILE *file); // Serialize multipart message to a single message frame. Use this method // to send structured messages across transports that do not support // multipart data. Allocates and returns a new frame containing the // serialized message. To decode a serialized message frame, use // zmsg_decode (). // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zmsg_encode (zmsg_t *self); // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zmsg_t * zmsg_dup (zmsg_t *self); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). CZMQ_EXPORT void zmsg_print (zmsg_t *self); // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. CZMQ_EXPORT bool zmsg_eq (zmsg_t *self, zmsg_t *other); // Return signal value, 0 or greater, if message is a signal, -1 if not. CZMQ_EXPORT int zmsg_signal (zmsg_t *self); // Probe the supplied object, and report if it looks like a zmsg_t. CZMQ_EXPORT bool zmsg_is (void *self); // Self test of this class. CZMQ_EXPORT void zmsg_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Return message routing ID, if the message came from a ZMQ_SERVER socket. // Else returns zero. CZMQ_EXPORT uint32_t zmsg_routing_id (zmsg_t *self); // *** Draft method, for development use, may change without warning *** // Set routing ID on message. This is used if/when the message is sent to a // ZMQ_SERVER socket. CZMQ_EXPORT void zmsg_set_routing_id (zmsg_t *self, uint32_t routing_id); #endif // CZMQ_BUILD_DRAFT_API // @end // DEPRECATED as over-engineered, poor style // Pop frame off front of message, caller now owns frame // If next frame is empty, pops and destroys that empty frame. CZMQ_EXPORT zframe_t * zmsg_unwrap (zmsg_t *self); // DEPRECATED as poor style -- callers should use zloop or zpoller // Receive message from socket, returns zmsg_t object, or NULL either if // there was no input waiting, or the recv was interrupted. CZMQ_EXPORT zmsg_t * zmsg_recv_nowait (void *source); // DEPRECATED as unsafe -- does not nullify frame reference. // Push frame plus empty frame to front of message, before first frame. // Message takes ownership of frame, will destroy it when message is sent. CZMQ_EXPORT void zmsg_wrap (zmsg_t *self, zframe_t *frame); // DEPRECATED - will be removed for next + 1 stable release // Add frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. CZMQ_EXPORT int zmsg_push (zmsg_t *self, zframe_t *frame); // DEPRECATED - will be removed for next stable release CZMQ_EXPORT int zmsg_add (zmsg_t *self, zframe_t *frame); // DEPRECATED as inconsistent; breaks principle that logging should all go // to a single destination. // Print message to open stream // Truncates to first 10 frames, for readability. CZMQ_EXPORT void zmsg_fprint (zmsg_t *self, FILE *file); // Compiler hints CZMQ_EXPORT int zmsg_addstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); CZMQ_EXPORT int zmsg_pushstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2); #ifdef __cplusplus } #endif // Deprecated method aliases #define zmsg_dump(s) zmsg_print(s) #define zmsg_dump_to_stream(s,F) zmsg_fprint(s,F) #endif czmq-4.1.0/include/zloop.h0000664000372000037200000001477013222211156016333 0ustar00travistravis00000000000000/* ========================================================================= zloop - event-driven reactor Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZLOOP_H_INCLUDED__ #define __ZLOOP_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zloop.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Callback function for reactor socket activity typedef int (zloop_reader_fn) ( zloop_t *loop, zsock_t *reader, void *arg); // Callback function for reactor events (low-level) typedef int (zloop_fn) ( zloop_t *loop, zmq_pollitem_t *item, void *arg); // Callback for reactor timer events typedef int (zloop_timer_fn) ( zloop_t *loop, int timer_id, void *arg); // Create a new zloop reactor CZMQ_EXPORT zloop_t * zloop_new (void); // Destroy a reactor CZMQ_EXPORT void zloop_destroy (zloop_t **self_p); // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. CZMQ_EXPORT int zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg); // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. CZMQ_EXPORT void zloop_reader_end (zloop_t *self, zsock_t *sock); // Configure a registered reader to ignore errors. If you do not set this, // then readers that have errors are removed from the reactor silently. CZMQ_EXPORT void zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock); // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. CZMQ_EXPORT int zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg); // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. CZMQ_EXPORT void zloop_poller_end (zloop_t *self, zmq_pollitem_t *item); // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. CZMQ_EXPORT void zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item); // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. CZMQ_EXPORT int zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg); // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer). CZMQ_EXPORT int zloop_timer_end (zloop_t *self, int timer_id); // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. CZMQ_EXPORT void * zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg); // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. CZMQ_EXPORT void zloop_ticket_reset (zloop_t *self, void *handle); // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. CZMQ_EXPORT void zloop_ticket_delete (zloop_t *self, void *handle); // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. CZMQ_EXPORT void zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay); // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. CZMQ_EXPORT void zloop_set_max_timers (zloop_t *self, size_t max_timers); // Set verbose tracing of reactor on/off. The default verbose setting is // off (false). CZMQ_EXPORT void zloop_set_verbose (zloop_t *self, bool verbose); // By default the reactor stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). CZMQ_EXPORT void zloop_set_nonstop (zloop_t *self, bool nonstop); // Start the reactor. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. CZMQ_EXPORT int zloop_start (zloop_t *self); // Self test of this class. CZMQ_EXPORT void zloop_test (bool verbose); // @end // Deprecated method aliases #define zloop_set_tolerant(s,i) zloop_poller_set_tolerant(s,i) #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zgossip.h0000664000372000037200000000541013222211156016655 0ustar00travistravis00000000000000/* ========================================================================= zgossip - zgossip server ** WARNING ************************************************************* THIS SOURCE FILE IS 100% GENERATED. If you edit this file, you will lose your changes at the next build cycle. This is great for temporary printf statements. DO NOT MAKE ANY CHANGES YOU WISH TO KEEP. The correct places for commits are: * The XML model used for this code generation: zgossip.xml, or * The code generation script that built this file: zproto_server_c ************************************************************************ Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef ZGOSSIP_H_INCLUDED #define ZGOSSIP_H_INCLUDED #include "czmq.h" #ifdef __cplusplus extern "C" { #endif // @interface // To work with zgossip, use the CZMQ zactor API: // // Create new zgossip instance, passing logging prefix: // // zactor_t *zgossip = zactor_new (zgossip, "myname"); // // Destroy zgossip instance // // zactor_destroy (&zgossip); // // Enable verbose logging of commands and activity: // // zstr_send (zgossip, "VERBOSE"); // // Bind zgossip to specified endpoint. TCP endpoints may specify // the port number as "*" to aquire an ephemeral port: // // zstr_sendx (zgossip, "BIND", endpoint, NULL); // // Return assigned port number, specifically when BIND was done using an // an ephemeral port: // // zstr_sendx (zgossip, "PORT", NULL); // char *command, *port_str; // zstr_recvx (zgossip, &command, &port_str, NULL); // assert (streq (command, "PORT")); // // Specify configuration file to load, overwriting any previous loaded // configuration file or options: // // zstr_sendx (zgossip, "LOAD", filename, NULL); // // Set configuration path value: // // zstr_sendx (zgossip, "SET", path, value, NULL); // // Save configuration data to config file on disk: // // zstr_sendx (zgossip, "SAVE", filename, NULL); // // Send zmsg_t instance to zgossip: // // zactor_send (zgossip, &msg); // // Receive zmsg_t instance from zgossip: // // zmsg_t *msg = zactor_recv (zgossip); // // This is the zgossip constructor as a zactor_fn: // CZMQ_EXPORT void zgossip (zsock_t *pipe, void *args); // Self test of this class CZMQ_EXPORT void zgossip_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zdigest.h0000664000372000037200000000373013222211156016633 0ustar00travistravis00000000000000/* ========================================================================= zdigest - provides hashing functions (SHA-1 at present) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZDIGEST_H_INCLUDED__ #define __ZDIGEST_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zdigest.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. CZMQ_EXPORT zdigest_t * zdigest_new (void); // Destroy a digest object CZMQ_EXPORT void zdigest_destroy (zdigest_t **self_p); // Add buffer into digest calculation CZMQ_EXPORT void zdigest_update (zdigest_t *self, const byte *buffer, size_t length); // Return final digest hash data. If built without crypto support, // returns NULL. CZMQ_EXPORT const byte * zdigest_data (zdigest_t *self); // Return final digest hash size CZMQ_EXPORT size_t zdigest_size (zdigest_t *self); // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. CZMQ_EXPORT char * zdigest_string (zdigest_t *self); // Self test of this class. CZMQ_EXPORT void zdigest_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zconfig.h0000664000372000037200000001473013222211156016623 0ustar00travistravis00000000000000/* ========================================================================= zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL. Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZCONFIG_H_INCLUDED__ #define __ZCONFIG_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zconfig.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // typedef int (zconfig_fct) ( zconfig_t *self, void *arg, int level); // Create new config item CZMQ_EXPORT zconfig_t * zconfig_new (const char *name, zconfig_t *parent); // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. CZMQ_EXPORT zconfig_t * zconfig_load (const char *filename); // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. CZMQ_EXPORT zconfig_t * zconfig_loadf (const char *format, ...) CHECK_PRINTF (1); // Destroy a config item and all its children CZMQ_EXPORT void zconfig_destroy (zconfig_t **self_p); // Return name of config item CZMQ_EXPORT char * zconfig_name (zconfig_t *self); // Return value of config item CZMQ_EXPORT char * zconfig_value (zconfig_t *self); // Insert or update configuration key with value CZMQ_EXPORT void zconfig_put (zconfig_t *self, const char *path, const char *value); // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. CZMQ_EXPORT void zconfig_putf (zconfig_t *self, const char *path, const char *format, ...) CHECK_PRINTF (3); // Get value for config item into a string value; leading slash is optional // and ignored. CZMQ_EXPORT char * zconfig_get (zconfig_t *self, const char *path, const char *default_value); // Set config item name, name may be NULL CZMQ_EXPORT void zconfig_set_name (zconfig_t *self, const char *name); // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. CZMQ_EXPORT void zconfig_set_value (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2); // Find our first child, if any CZMQ_EXPORT zconfig_t * zconfig_child (zconfig_t *self); // Find our first sibling, if any CZMQ_EXPORT zconfig_t * zconfig_next (zconfig_t *self); // Find a config item along a path; leading slash is optional and ignored. CZMQ_EXPORT zconfig_t * zconfig_locate (zconfig_t *self, const char *path); // Locate the last config item at a specified depth CZMQ_EXPORT zconfig_t * zconfig_at_depth (zconfig_t *self, int level); // Execute a callback for each config item in the tree; returns zero if // successful, else -1. CZMQ_EXPORT int zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg); // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. CZMQ_EXPORT void zconfig_set_comment (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2); // Return comments of config item, as zlist. CZMQ_EXPORT zlist_t * zconfig_comments (zconfig_t *self); // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. CZMQ_EXPORT int zconfig_save (zconfig_t *self, const char *filename); // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. CZMQ_EXPORT int zconfig_savef (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2); // Report filename used during zconfig_load, or NULL if none CZMQ_EXPORT const char * zconfig_filename (zconfig_t *self); // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). CZMQ_EXPORT int zconfig_reload (zconfig_t **self_p); // Load a config tree from a memory chunk CZMQ_EXPORT zconfig_t * zconfig_chunk_load (zchunk_t *chunk); // Save a config tree to a new memory chunk CZMQ_EXPORT zchunk_t * zconfig_chunk_save (zconfig_t *self); // Load a config tree from a null-terminated string // Caller owns return value and must destroy it when done. CZMQ_EXPORT zconfig_t * zconfig_str_load (const char *string); // Save a config tree to a new null terminated string // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zconfig_str_save (zconfig_t *self); // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. CZMQ_EXPORT bool zconfig_has_changed (zconfig_t *self); // Print the config file to open stream CZMQ_EXPORT void zconfig_fprint (zconfig_t *self, FILE *file); // Print properties of object CZMQ_EXPORT void zconfig_print (zconfig_t *self); // Self test of this class CZMQ_EXPORT void zconfig_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Destroy subtree (all children) CZMQ_EXPORT void zconfig_remove_subtree (zconfig_t *self); // *** Draft method, for development use, may change without warning *** // Destroy node and subtree (all children) CZMQ_EXPORT void zconfig_remove (zconfig_t **self_p); #endif // CZMQ_BUILD_DRAFT_API // @end // Self test of this class CZMQ_EXPORT void zconfig_test (bool verbose); // Compiler hints CZMQ_EXPORT void zconfig_set_value (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2); #ifdef __cplusplus } #endif // Deprecated method aliases #define zconfig_dump(s) zconfig_print(s) #define zconfig_resolve(s,p,d) zconfig_get((s),(p),(d)) #endif czmq-4.1.0/include/zpoller.h0000664000372000037200000000633313222211156016653 0ustar00travistravis00000000000000/* ========================================================================= zpoller - trivial socket poller class Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __zpoller_H_INCLUDED__ #define __zpoller_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zpoller.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Create new poller, specifying zero or more readers. The list of // readers ends in a NULL. Each reader can be a zsock_t instance, a // zactor_t instance, a libzmq socket (void *), or a file handle. CZMQ_EXPORT zpoller_t * zpoller_new (void *reader, ...); // Destroy a poller CZMQ_EXPORT void zpoller_destroy (zpoller_t **self_p); // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. CZMQ_EXPORT int zpoller_add (zpoller_t *self, void *reader); // Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader // must have been passed during construction, or in an zpoller_add () call. CZMQ_EXPORT int zpoller_remove (zpoller_t *self, void *reader); // By default the poller stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). CZMQ_EXPORT void zpoller_set_nonstop (zpoller_t *self, bool nonstop); // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. CZMQ_EXPORT void * zpoller_wait (zpoller_t *self, int timeout); // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. CZMQ_EXPORT bool zpoller_expired (zpoller_t *self); // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. CZMQ_EXPORT bool zpoller_terminated (zpoller_t *self); // Self test of this class. CZMQ_EXPORT void zpoller_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zsys.h0000664000372000037200000004355013222211156016176 0ustar00travistravis00000000000000/* ========================================================================= zsys - system-level methods Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZSYS_H_INCLUDED__ #define __ZSYS_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif #define UDP_FRAME_MAX 255 // Max size of UDP frame // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zsys.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Callback for interrupt signal handler typedef void (zsys_handler_fn) ( int signal_value); // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. CZMQ_EXPORT void * zsys_init (void); // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls. CZMQ_EXPORT void zsys_shutdown (void); // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void * zsys_socket (int type, const char *filename, size_t line_nbr); // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_close (void *handle, const char *filename, size_t line_nbr); // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT char * zsys_sockname (int socktype); // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. CZMQ_EXPORT zsock_t * zsys_create_pipe (zsock_t **backend_p); // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. CZMQ_EXPORT void zsys_handler_set (zsys_handler_fn *handler_fn); // Reset interrupt handler, call this at exit if needed CZMQ_EXPORT void zsys_handler_reset (void); // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. // Can be supressed by ZSYS_SIGHANDLER=false // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void zsys_catch_interrupts (void); // Return 1 if file exists, else zero CZMQ_EXPORT bool zsys_file_exists (const char *filename); // Return file modification time. Returns 0 if the file does not exist. CZMQ_EXPORT time_t zsys_file_modified (const char *filename); // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. CZMQ_EXPORT int zsys_file_mode (const char *filename); // Delete file. Does not complain if the file is absent CZMQ_EXPORT int zsys_file_delete (const char *filename); // Check if file is 'stable' CZMQ_EXPORT bool zsys_file_stable (const char *filename); // Create a file path if it doesn't exist. The file path is treated as // printf format. CZMQ_EXPORT int zsys_dir_create (const char *pathname, ...); // Remove a file path if empty; the pathname is treated as printf format. CZMQ_EXPORT int zsys_dir_delete (const char *pathname, ...); // Move to a specified working directory. Returns 0 if OK, -1 if this failed. CZMQ_EXPORT int zsys_dir_change (const char *pathname); // Set private file creation mode; all files created from here will be // readable/writable by the owner only. CZMQ_EXPORT void zsys_file_mode_private (void); // Reset default file creation mode; all files created from here will use // process file mode defaults. CZMQ_EXPORT void zsys_file_mode_default (void); // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. CZMQ_EXPORT void zsys_version (int *major, int *minor, int *patch); // Format a string using printf formatting, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). CZMQ_EXPORT char * zsys_sprintf (const char *format, ...); // Format a string with a va_list argument, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). CZMQ_EXPORT char * zsys_vprintf (const char *format, va_list argptr); // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT SOCKET zsys_udp_new (bool routable); // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_udp_close (SOCKET handle); // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address, int addrlen); // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or // NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername, int peerlen); // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. // *** This is for CZMQ internal use only and may change arbitrarily *** CZMQ_EXPORT void zsys_socket_error (const char *reason); // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. CZMQ_EXPORT char * zsys_hostname (void); // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. CZMQ_EXPORT int zsys_daemonize (const char *workdir); // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. CZMQ_EXPORT int zsys_run_as (const char *lockfile, const char *group, const char *user); // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. CZMQ_EXPORT bool zsys_has_curve (void); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_io_threads (size_t io_threads); // Configure the scheduling policy of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY // is defined, that provides the default. // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_thread_sched_policy (int policy); // Configure the scheduling priority of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_PRIORITY is // defined, that provides the default. // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_thread_priority (int priority); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zsys_set_max_sockets (size_t max_sockets); // Return maximum number of ZeroMQ sockets that the system will support. CZMQ_EXPORT size_t zsys_socket_limit (void); // Configure the maximum allowed size of a message sent. // The default is INT_MAX. CZMQ_EXPORT void zsys_set_max_msgsz (int max_msgsz); // Return maximum message size. CZMQ_EXPORT int zsys_max_msgsz (void); // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. CZMQ_EXPORT void zsys_set_linger (size_t linger); // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_sndhwm (size_t sndhwm); // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_rcvhwm (size_t rcvhwm); // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. CZMQ_EXPORT void zsys_set_pipehwm (size_t pipehwm); // Return the HWM for zactor internal pipes. CZMQ_EXPORT size_t zsys_pipehwm (void); // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. CZMQ_EXPORT void zsys_set_ipv6 (int ipv6); // Return use of IPv6 for zsock instances. CZMQ_EXPORT int zsys_ipv6 (void); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". CZMQ_EXPORT void zsys_set_interface (const char *value); // Return network interface to use for broadcasts, or "" if none was set. CZMQ_EXPORT const char * zsys_interface (void); // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses // on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, // use that as the default IPv6 address. CZMQ_EXPORT void zsys_set_ipv6_address (const char *value); // Return IPv6 address to use for zbeacon reception, or "" if none was set. CZMQ_EXPORT const char * zsys_ipv6_address (void); // Set IPv6 milticast address to use for sending zbeacon messages. This needs // to be set if IPv6 is enabled. If the environment variable // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast // address. CZMQ_EXPORT void zsys_set_ipv6_mcast_address (const char *value); // Return IPv6 multicast address to use for sending zbeacon, or "" if none was // set. CZMQ_EXPORT const char * zsys_ipv6_mcast_address (void); // Configure the automatic use of pre-allocated FDs when creating new sockets. // If 0 (default), nothing will happen. Else, when a new socket is bound, the // system API will be used to check if an existing pre-allocated FD with a // matching port (if TCP) or path (if IPC) exists, and if it does it will be // set via the ZMQ_USE_FD socket option so that the library will use it // instead of creating a new socket. CZMQ_EXPORT void zsys_set_auto_use_fd (int auto_use_fd); // Return use of automatic pre-allocated FDs for zsock instances. CZMQ_EXPORT int zsys_auto_use_fd (void); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. CZMQ_EXPORT void zsys_set_logident (const char *value); // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). CZMQ_EXPORT void zsys_set_logstream (FILE *stream); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. CZMQ_EXPORT void zsys_set_logsender (const char *endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. CZMQ_EXPORT void zsys_set_logsystem (bool logsystem); // Log error condition - highest priority CZMQ_EXPORT void zsys_error (const char *format, ...); // Log warning condition - high priority CZMQ_EXPORT void zsys_warning (const char *format, ...); // Log normal, but significant, condition - normal priority CZMQ_EXPORT void zsys_notice (const char *format, ...); // Log informational message - low priority CZMQ_EXPORT void zsys_info (const char *format, ...); // Log debug-level message - lowest priority CZMQ_EXPORT void zsys_debug (const char *format, ...); // Self test of this class. CZMQ_EXPORT void zsys_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Configure the threshold value of filesystem object age per st_mtime // that should elapse until we consider that object "stable" at the // current zclock_time() moment. // The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c // which generally depends on host OS, with fallback value of 5000. CZMQ_EXPORT void zsys_set_file_stable_age_msec (int64_t file_stable_age_msec); // *** Draft method, for development use, may change without warning *** // Return current threshold value of file stable age in msec. // This can be used in code that chooses to wait for this timeout // before testing if a filesystem object is "stable" or not. CZMQ_EXPORT int64_t zsys_file_stable_age_msec (void); #endif // CZMQ_BUILD_DRAFT_API // @end // Return size of file, or -1 if not found CZMQ_EXPORT ssize_t zsys_file_size (const char *filename); // Global signal indicator, TRUE when user presses Ctrl-C or the process // gets a SIGTERM signal. CZMQ_EXPORT extern volatile int zsys_interrupted; // Deprecated name for this variable CZMQ_EXPORT extern volatile int zctx_interrupted; #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zmonitor.h0000664000372000037200000000354113222211156017043 0ustar00travistravis00000000000000/* ========================================================================= zmonitor - socket event monitor Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZMONITOR_H_INCLUDED__ #define __ZMONITOR_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create new zmonitor actor instance to monitor a zsock_t socket: // // zactor_t *monitor = zactor_new (zmonitor, mysocket); // // Destroy zmonitor instance. // // zactor_destroy (&monitor); // // Enable verbose logging of commands and activity. // // zstr_send (monitor, "VERBOSE"); // // Listen to monitor event type (zero or types, ending in NULL): // zstr_sendx (monitor, "LISTEN", type, ..., NULL); // // Events: // CONNECTED // CONNECT_DELAYED // CONNECT_RETRIED // LISTENING // BIND_FAILED // ACCEPTED // ACCEPT_FAILED // CLOSED // CLOSE_FAILED // DISCONNECTED // MONITOR_STOPPED // ALL // // Start monitor; after this, any further LISTEN commands are ignored. // // zstr_send (monitor, "START"); // zsock_wait (monitor); // // Receive next monitor event: // // zmsg_t *msg = zmsg_recv (monitor); // // This is the zmonitor constructor as a zactor_fn; the argument can be // a zactor_t, zsock_t, or libzmq void * socket: CZMQ_EXPORT void zmonitor (zsock_t *pipe, void *sock); // Selftest CZMQ_EXPORT void zmonitor_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zhash.h0000664000372000037200000001571513222211156016305 0ustar00travistravis00000000000000/* ========================================================================= zhash - generic type-free hash container (simple) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZHASH_H_INCLUDED__ #define __ZHASH_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zhash.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Callback function for zhash_freefn method typedef void (zhash_free_fn) ( void *data); // Create a new, empty hash container CZMQ_EXPORT zhash_t * zhash_new (void); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. CZMQ_EXPORT zhash_t * zhash_unpack (zframe_t *frame); // Destroy a hash container and all items in it CZMQ_EXPORT void zhash_destroy (zhash_t **self_p); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. CZMQ_EXPORT int zhash_insert (zhash_t *self, const char *key, void *item); // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. CZMQ_EXPORT void zhash_update (zhash_t *self, const char *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. CZMQ_EXPORT void zhash_delete (zhash_t *self, const char *key); // Return the item at the specified key, or null CZMQ_EXPORT void * zhash_lookup (zhash_t *self, const char *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. CZMQ_EXPORT int zhash_rename (zhash_t *self, const char *old_key, const char *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. CZMQ_EXPORT void * zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn); // Return the number of keys/items in the hash table CZMQ_EXPORT size_t zhash_size (zhash_t *self); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zhash_t * zhash_dup (zhash_t *self); // Return keys for items in table // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlist_t * zhash_keys (zhash_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhash_cursor(). NOTE: do NOT modify the table while iterating. CZMQ_EXPORT void * zhash_first (zhash_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). To // access the key for this item use zhash_cursor(). NOTE: do NOT modify // the table while iterating. CZMQ_EXPORT void * zhash_next (zhash_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. CZMQ_EXPORT const char * zhash_cursor (zhash_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. CZMQ_EXPORT void zhash_comment (zhash_t *self, const char *format, ...) CHECK_PRINTF (2); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zhash_pack (zhash_t *self); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. CZMQ_EXPORT int zhash_save (zhash_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. CZMQ_EXPORT int zhash_load (zhash_t *self, const char *filename); // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. CZMQ_EXPORT int zhash_refresh (zhash_t *self); // Set hash for automatic value destruction. Note that this assumes that // values are NULL-terminated strings. Do not use with different types. CZMQ_EXPORT void zhash_autofree (zhash_t *self); // Self test of this class. CZMQ_EXPORT void zhash_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zarmour.h0000664000372000037200000000672713222211156016672 0ustar00travistravis00000000000000/* ========================================================================= zarmour - armoured text encoding and decoding Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZARMOUR_H_INCLUDED__ #define __ZARMOUR_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zarmour.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. #define ZARMOUR_MODE_BASE64_STD 0 // Standard base 64 #define ZARMOUR_MODE_BASE64_URL 1 // URL and filename friendly base 64 #define ZARMOUR_MODE_BASE32_STD 2 // Standard base 32 #define ZARMOUR_MODE_BASE32_HEX 3 // Extended hex base 32 #define ZARMOUR_MODE_BASE16 4 // Standard base 16 #define ZARMOUR_MODE_Z85 5 // Z85 from ZeroMQ RFC 32 // Create a new zarmour CZMQ_EXPORT zarmour_t * zarmour_new (void); // Destroy the zarmour CZMQ_EXPORT void zarmour_destroy (zarmour_t **self_p); // Encode a stream of bytes into an armoured string. Returns the armoured // string, or NULL if there was insufficient memory available to allocate // a new string. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zarmour_encode (zarmour_t *self, const byte *data, size_t size); // Decode an armoured string into a chunk. The decoded output is // null-terminated, so it may be treated as a string, if that's what // it was prior to encoding. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zchunk_t * zarmour_decode (zarmour_t *self, const char *data); // Get the mode property. CZMQ_EXPORT int zarmour_mode (zarmour_t *self); // Get printable string for mode. CZMQ_EXPORT const char * zarmour_mode_str (zarmour_t *self); // Set the mode property. CZMQ_EXPORT void zarmour_set_mode (zarmour_t *self, int mode); // Return true if padding is turned on. CZMQ_EXPORT bool zarmour_pad (zarmour_t *self); // Turn padding on or off. Default is on. CZMQ_EXPORT void zarmour_set_pad (zarmour_t *self, bool pad); // Get the padding character. CZMQ_EXPORT char zarmour_pad_char (zarmour_t *self); // Set the padding character. CZMQ_EXPORT void zarmour_set_pad_char (zarmour_t *self, char pad_char); // Return if splitting output into lines is turned on. Default is off. CZMQ_EXPORT bool zarmour_line_breaks (zarmour_t *self); // Turn splitting output into lines on or off. CZMQ_EXPORT void zarmour_set_line_breaks (zarmour_t *self, bool line_breaks); // Get the line length used for splitting lines. CZMQ_EXPORT size_t zarmour_line_length (zarmour_t *self); // Set the line length used for splitting lines. CZMQ_EXPORT void zarmour_set_line_length (zarmour_t *self, size_t line_length); // Print properties of object CZMQ_EXPORT void zarmour_print (zarmour_t *self); // Self test of this class. CZMQ_EXPORT void zarmour_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zbeacon.h0000664000372000037200000000545013222211156016604 0ustar00travistravis00000000000000/* ========================================================================= zbeacon - LAN discovery and presence Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZBEACON_H_INCLUDED__ #define __ZBEACON_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create new zbeacon actor instance: // // zactor_t *beacon = zactor_new (zbeacon, NULL); // // Destroy zbeacon instance: // // zactor_destroy (&beacon); // // Enable verbose logging of commands and activity: // // zstr_send (beacon, "VERBOSE"); // // Configure beacon to run on specified UDP port, and return the name of // the host, which can be used as endpoint for incoming connections. To // force the beacon to operate on a given interface, set the environment // variable ZSYS_INTERFACE, or call zsys_set_interface() before creating // the beacon. If the system does not support UDP broadcasts (lacking a // workable interface), returns an empty hostname: // // // Pictures: 's' = C string, 'i' = int // zsock_send (beacon, "si", "CONFIGURE", port_number); // char *hostname = zstr_recv (beacon); // // Start broadcasting a beacon at a specified interval in msec. The beacon // data can be at most UDP_FRAME_MAX bytes; this constant is defined in // zsys.h to be 255: // // // Pictures: 'b' = byte * data + size_t size // zsock_send (beacon, "sbi", "PUBLISH", data, size, interval); // // Stop broadcasting the beacon: // // zstr_sendx (beacon, "SILENCE", NULL); // // Start listening to beacons from peers. The filter is used to do a prefix // match on received beacons, to remove junk. Note that any received data // that is identical to our broadcast beacon_data is discarded in any case. // If the filter size is zero, we get all peer beacons: // // zsock_send (beacon, "sb", "SUBSCRIBE", filter_data, filter_size); // // Stop listening to other peers // // zstr_sendx (beacon, "UNSUBSCRIBE", NULL); // // Receive next beacon from a peer. Received beacons are always a 2-frame // message containing the ipaddress of the sender, and then the binary // beacon data as published by the sender: // // zmsg_t *msg = zmsg_recv (beacon); // // This is the zbeacon constructor as a zactor_fn: CZMQ_EXPORT void zbeacon (zsock_t *pipe, void *unused); // Self test of this class CZMQ_EXPORT void zbeacon_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zstr.h0000664000372000037200000001257013222211156016166 0ustar00travistravis00000000000000/* ========================================================================= zstr - sending and receiving strings Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZSTR_H_INCLUDED__ #define __ZSTR_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zstr.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zstr_recv (void *source); // Receive a series of strings (until NULL) from multipart data. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL. // Returns -1 if the message could not be read, else returns the // number of strings filled, zero or more. Free each returned string // using zstr_free(). If not enough strings are provided, remaining // multipart frames in the message are dropped. CZMQ_EXPORT int zstr_recvx (void *source, char **string_p, ...); // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". CZMQ_EXPORT int zstr_send (void *dest, const char *string); // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. CZMQ_EXPORT int zstr_sendm (void *dest, const char *string); // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). CZMQ_EXPORT int zstr_sendf (void *dest, const char *format, ...) CHECK_PRINTF (2); // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. CZMQ_EXPORT int zstr_sendfm (void *dest, const char *format, ...) CHECK_PRINTF (2); // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or -1 on error. CZMQ_EXPORT int zstr_sendx (void *dest, const char *string, ...); // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. CZMQ_EXPORT void zstr_free (char **string_p); // Self test of this class. CZMQ_EXPORT void zstr_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // De-compress and receive C string from socket, received as a message // with two frames: size of the uncompressed string, and the string itself. // Caller must free returned string using zstr_free(). Returns NULL if the // context is being terminated or the process was interrupted. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zstr_recv_compress (void *source); // *** Draft method, for development use, may change without warning *** // Compress and send a C string to a socket, as a message with two frames: // size of the uncompressed string, and the string itself. The string is // sent without trailing null byte; to read this you can use // zstr_recv_compress, or a similar method that de-compresses and adds a // null terminator on the received string. CZMQ_EXPORT int zstr_send_compress (void *dest, const char *string); // *** Draft method, for development use, may change without warning *** // Compress and send a C string to a socket, as zstr_send_compress(), // with a MORE flag, so that you can send further strings in the same // multi-part message. CZMQ_EXPORT int zstr_sendm_compress (void *dest, const char *string); // *** Draft method, for development use, may change without warning *** // Accepts a void pointer and returns a fresh character string. If source // is null, returns an empty string. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zstr_str (void *source); #endif // CZMQ_BUILD_DRAFT_API // @end // DEPRECATED as poor style -- callers should use zloop or zpoller // Receive C string from socket, if socket had input ready. Caller must // free returned string using zstr_free. Returns NULL if there was no input // waiting, or if the context was terminated. Use zctx_interrupted to exit // any loop that relies on this method. CZMQ_EXPORT char * zstr_recv_nowait (void *source); // Compiler hints CZMQ_EXPORT int zstr_sendf (void *dest, const char *format, ...) CHECK_PRINTF (2); #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/czmq_library.h0000664000372000037200000001310613222211156017656 0ustar00travistravis00000000000000/* ========================================================================= czmq - generated layer of public API Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ ========================================================================= */ #ifndef CZMQ_LIBRARY_H_INCLUDED #define CZMQ_LIBRARY_H_INCLUDED // Set up environment for the application #include "czmq_prelude.h" // External dependencies #include // CZMQ version macros for compile-time API detection #define CZMQ_VERSION_MAJOR 4 #define CZMQ_VERSION_MINOR 1 #define CZMQ_VERSION_PATCH 0 #define CZMQ_MAKE_VERSION(major, minor, patch) \ ((major) * 10000 + (minor) * 100 + (patch)) #define CZMQ_VERSION \ CZMQ_MAKE_VERSION(CZMQ_VERSION_MAJOR, CZMQ_VERSION_MINOR, CZMQ_VERSION_PATCH) #if defined (__WINDOWS__) # if defined CZMQ_STATIC # define CZMQ_EXPORT # elif defined CZMQ_INTERNAL_BUILD # if defined DLL_EXPORT # define CZMQ_EXPORT __declspec(dllexport) # else # define CZMQ_EXPORT # endif # elif defined CZMQ_EXPORTS # define CZMQ_EXPORT __declspec(dllexport) # else # define CZMQ_EXPORT __declspec(dllimport) # endif # define CZMQ_PRIVATE #elif defined (__CYGWIN__) # define CZMQ_EXPORT # define CZMQ_PRIVATE #else # define CZMQ_EXPORT # if (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER # define CZMQ_PRIVATE __attribute__ ((visibility ("hidden"))) # else # define CZMQ_PRIVATE # endif #endif // Opaque class structures to allow forward references // These classes are stable or legacy and built in all releases typedef struct _zactor_t zactor_t; #define ZACTOR_T_DEFINED typedef struct _zarmour_t zarmour_t; #define ZARMOUR_T_DEFINED typedef struct _zcert_t zcert_t; #define ZCERT_T_DEFINED typedef struct _zcertstore_t zcertstore_t; #define ZCERTSTORE_T_DEFINED typedef struct _zchunk_t zchunk_t; #define ZCHUNK_T_DEFINED typedef struct _zclock_t zclock_t; #define ZCLOCK_T_DEFINED typedef struct _zconfig_t zconfig_t; #define ZCONFIG_T_DEFINED typedef struct _zdigest_t zdigest_t; #define ZDIGEST_T_DEFINED typedef struct _zdir_t zdir_t; #define ZDIR_T_DEFINED typedef struct _zdir_patch_t zdir_patch_t; #define ZDIR_PATCH_T_DEFINED typedef struct _zfile_t zfile_t; #define ZFILE_T_DEFINED typedef struct _zframe_t zframe_t; #define ZFRAME_T_DEFINED typedef struct _zhash_t zhash_t; #define ZHASH_T_DEFINED typedef struct _zhashx_t zhashx_t; #define ZHASHX_T_DEFINED typedef struct _ziflist_t ziflist_t; #define ZIFLIST_T_DEFINED typedef struct _zlist_t zlist_t; #define ZLIST_T_DEFINED typedef struct _zlistx_t zlistx_t; #define ZLISTX_T_DEFINED typedef struct _zloop_t zloop_t; #define ZLOOP_T_DEFINED typedef struct _zmsg_t zmsg_t; #define ZMSG_T_DEFINED typedef struct _zpoller_t zpoller_t; #define ZPOLLER_T_DEFINED typedef struct _zsock_t zsock_t; #define ZSOCK_T_DEFINED typedef struct _zstr_t zstr_t; #define ZSTR_T_DEFINED typedef struct _zsys_t zsys_t; #define ZSYS_T_DEFINED typedef struct _zuuid_t zuuid_t; #define ZUUID_T_DEFINED typedef struct _zauth_t zauth_t; #define ZAUTH_T_DEFINED typedef struct _zbeacon_t zbeacon_t; #define ZBEACON_T_DEFINED typedef struct _zgossip_t zgossip_t; #define ZGOSSIP_T_DEFINED typedef struct _zmonitor_t zmonitor_t; #define ZMONITOR_T_DEFINED typedef struct _zproxy_t zproxy_t; #define ZPROXY_T_DEFINED typedef struct _zrex_t zrex_t; #define ZREX_T_DEFINED // Draft classes are by default not built in stable releases #ifdef CZMQ_BUILD_DRAFT_API typedef struct _zargs_t zargs_t; #define ZARGS_T_DEFINED typedef struct _zproc_t zproc_t; #define ZPROC_T_DEFINED typedef struct _ztimerset_t ztimerset_t; #define ZTIMERSET_T_DEFINED typedef struct _ztrie_t ztrie_t; #define ZTRIE_T_DEFINED #endif // CZMQ_BUILD_DRAFT_API // Public classes, each with its own header file #include "zactor.h" #include "zarmour.h" #include "zcert.h" #include "zcertstore.h" #include "zchunk.h" #include "zclock.h" #include "zconfig.h" #include "zdigest.h" #include "zdir.h" #include "zdir_patch.h" #include "zfile.h" #include "zframe.h" #include "zhash.h" #include "zhashx.h" #include "ziflist.h" #include "zlist.h" #include "zlistx.h" #include "zloop.h" #include "zmsg.h" #include "zpoller.h" #include "zsock.h" #include "zstr.h" #include "zsys.h" #include "zuuid.h" #include "zauth.h" #include "zbeacon.h" #include "zgossip.h" #include "zmonitor.h" #include "zproxy.h" #include "zrex.h" #ifdef CZMQ_BUILD_DRAFT_API #include "zargs.h" #include "zproc.h" #include "ztimerset.h" #include "ztrie.h" #endif // CZMQ_BUILD_DRAFT_API #ifdef CZMQ_BUILD_DRAFT_API // Self test for private classes CZMQ_EXPORT void czmq_private_selftest (bool verbose); #endif // CZMQ_BUILD_DRAFT_API #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/include/ziflist.h0000664000372000037200000000605213222211156016646 0ustar00travistravis00000000000000/* ========================================================================= ziflist - List of network interfaces available on system Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZIFLIST_H_INCLUDED__ #define __ZIFLIST_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/ziflist.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Get a list of network interfaces currently defined on the system CZMQ_EXPORT ziflist_t * ziflist_new (void); // Destroy a ziflist instance CZMQ_EXPORT void ziflist_destroy (ziflist_t **self_p); // Reload network interfaces from system CZMQ_EXPORT void ziflist_reload (ziflist_t *self); // Return the number of network interfaces on system CZMQ_EXPORT size_t ziflist_size (ziflist_t *self); // Get first network interface, return NULL if there are none CZMQ_EXPORT const char * ziflist_first (ziflist_t *self); // Get next network interface, return NULL if we hit the last one CZMQ_EXPORT const char * ziflist_next (ziflist_t *self); // Return the current interface IP address as a printable string CZMQ_EXPORT const char * ziflist_address (ziflist_t *self); // Return the current interface broadcast address as a printable string CZMQ_EXPORT const char * ziflist_broadcast (ziflist_t *self); // Return the current interface network mask as a printable string CZMQ_EXPORT const char * ziflist_netmask (ziflist_t *self); // Return the list of interfaces. CZMQ_EXPORT void ziflist_print (ziflist_t *self); // Self test of this class. CZMQ_EXPORT void ziflist_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Get a list of network interfaces currently defined on the system // Includes IPv6 interfaces // Caller owns return value and must destroy it when done. CZMQ_EXPORT ziflist_t * ziflist_new_ipv6 (void); // *** Draft method, for development use, may change without warning *** // Reload network interfaces from system, including IPv6 CZMQ_EXPORT void ziflist_reload_ipv6 (ziflist_t *self); // *** Draft method, for development use, may change without warning *** // Return true if the current interface uses IPv6 CZMQ_EXPORT bool ziflist_is_ipv6 (ziflist_t *self); #endif // CZMQ_BUILD_DRAFT_API // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zactor.h0000664000372000037200000000614113222211156016463 0ustar00travistravis00000000000000/* ========================================================================= zactor - actor Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZACTOR_H_INCLUDED__ #define __ZACTOR_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zactor.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Actors get a pipe and arguments from caller typedef void (zactor_fn) ( zsock_t *pipe, void *args); // Create a new actor passing arbitrary arguments reference. CZMQ_EXPORT zactor_t * zactor_new (zactor_fn task, void *args); // Destroy an actor. CZMQ_EXPORT void zactor_destroy (zactor_t **self_p); // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. CZMQ_EXPORT int zactor_send (zactor_t *self, zmsg_t **msg_p); // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zmsg_t * zactor_recv (zactor_t *self); // Probe the supplied object, and report if it looks like a zactor_t. CZMQ_EXPORT bool zactor_is (void *self); // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. CZMQ_EXPORT void * zactor_resolve (void *self); // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. CZMQ_EXPORT zsock_t * zactor_sock (zactor_t *self); // Self test of this class. CZMQ_EXPORT void zactor_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // Function to be called on zactor_destroy. Default behavior is to send zmsg_t with string "$TERM" in a first frame. // // An example - to send $KTHXBAI string // // if (zstr_send (self->pipe, "$KTHXBAI") == 0) // zsock_wait (self->pipe); typedef void (zactor_destructor_fn) ( zactor_t *self); // *** Draft method, for development use, may change without warning *** // Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. CZMQ_EXPORT void zactor_set_destructor (zactor_t *self, zactor_destructor_fn destructor); #endif // CZMQ_BUILD_DRAFT_API // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zlistx.h0000664000372000037200000001714013222211156016517 0ustar00travistravis00000000000000/* ========================================================================= zlistx - extended generic list container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZLISTX_H_INCLUDED__ #define __ZLISTX_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zlistx.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Destroy an item typedef void (zlistx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zlistx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zlistx_comparator_fn) ( const void *item1, const void *item2); // Create a new, empty list. CZMQ_EXPORT zlistx_t * zlistx_new (void); // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. CZMQ_EXPORT void zlistx_destroy (zlistx_t **self_p); // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. CZMQ_EXPORT void * zlistx_add_start (zlistx_t *self, void *item); // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. CZMQ_EXPORT void * zlistx_add_end (zlistx_t *self, void *item); // Return the number of items in the list CZMQ_EXPORT size_t zlistx_size (zlistx_t *self); // Return first item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlistx_head (zlistx_t *self); // Return last item in the list, or null, leaves the cursor CZMQ_EXPORT void * zlistx_tail (zlistx_t *self); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. CZMQ_EXPORT void * zlistx_first (zlistx_t *self); // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). CZMQ_EXPORT void * zlistx_next (zlistx_t *self); // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). CZMQ_EXPORT void * zlistx_prev (zlistx_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. CZMQ_EXPORT void * zlistx_last (zlistx_t *self); // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. CZMQ_EXPORT void * zlistx_item (zlistx_t *self); // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. CZMQ_EXPORT void * zlistx_cursor (zlistx_t *self); // Returns the item associated with the given list handle, or NULL if passed // in handle is NULL. Asserts that the passed in handle points to a list element. CZMQ_EXPORT void * zlistx_handle_item (void *handle); // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. CZMQ_EXPORT void * zlistx_find (zlistx_t *self, void *item); // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. CZMQ_EXPORT void * zlistx_detach (zlistx_t *self, void *handle); // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. CZMQ_EXPORT void * zlistx_detach_cur (zlistx_t *self); // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. CZMQ_EXPORT int zlistx_delete (zlistx_t *self, void *handle); // Move an item to the start of the list, via its handle. CZMQ_EXPORT void zlistx_move_start (zlistx_t *self, void *handle); // Move an item to the end of the list, via its handle. CZMQ_EXPORT void zlistx_move_end (zlistx_t *self, void *handle); // Remove all items from the list, and destroy them if the item destructor // is set. CZMQ_EXPORT void zlistx_purge (zlistx_t *self); // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. CZMQ_EXPORT void zlistx_sort (zlistx_t *self); // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. CZMQ_EXPORT void * zlistx_insert (zlistx_t *self, void *item, bool low_value); // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. CZMQ_EXPORT void zlistx_reorder (zlistx_t *self, void *handle, bool low_value); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. CZMQ_EXPORT zlistx_t * zlistx_dup (zlistx_t *self); // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. CZMQ_EXPORT void zlistx_set_destructor (zlistx_t *self, zlistx_destructor_fn destructor); // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. CZMQ_EXPORT void zlistx_set_duplicator (zlistx_t *self, zlistx_duplicator_fn duplicator); // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. CZMQ_EXPORT void zlistx_set_comparator (zlistx_t *self, zlistx_comparator_fn comparator); // Self test of this class. CZMQ_EXPORT void zlistx_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zproc.h0000664000372000037200000002604613222211156016324 0ustar00travistravis00000000000000/* ========================================================================= zproc - process configuration and status Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef ZPROC_H_INCLUDED #define ZPROC_H_INCLUDED #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zproc.api" to make changes. // @interface // This is a draft class, and may change without notice. It is disabled in // stable builds by default. If you use this in applications, please ask // for it to be pushed to stable state. Use --enable-drafts to enable. #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Create a new zproc. // NOTE: On Windows and with libzmq3 and libzmq2 this function // returns NULL. Code needs to be ported there. CZMQ_EXPORT zproc_t * zproc_new (void); // *** Draft method, for development use, may change without warning *** // Destroy zproc, wait until process ends. CZMQ_EXPORT void zproc_destroy (zproc_t **self_p); // *** Draft method, for development use, may change without warning *** // Setup the command line arguments, the first item must be an (absolute) filename // to run. CZMQ_EXPORT void zproc_set_args (zproc_t *self, zlistx_t *args); // *** Draft method, for development use, may change without warning *** // Setup the environment variables for the process. CZMQ_EXPORT void zproc_set_env (zproc_t *self, zhashx_t *args); // *** Draft method, for development use, may change without warning *** // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The writable one is then accessbile via zproc_stdin method. CZMQ_EXPORT void zproc_set_stdin (zproc_t *self, void *socket); // *** Draft method, for development use, may change without warning *** // Connects process stdout with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stdout method. CZMQ_EXPORT void zproc_set_stdout (zproc_t *self, void *socket); // *** Draft method, for development use, may change without warning *** // Connects process stderr with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stderr method. CZMQ_EXPORT void zproc_set_stderr (zproc_t *self, void *socket); // *** Draft method, for development use, may change without warning *** // Return subprocess stdin writable socket. NULL for // not initialized or external sockets. CZMQ_EXPORT void * zproc_stdin (zproc_t *self); // *** Draft method, for development use, may change without warning *** // Return subprocess stdout readable socket. NULL for // not initialized or external sockets. CZMQ_EXPORT void * zproc_stdout (zproc_t *self); // *** Draft method, for development use, may change without warning *** // Return subprocess stderr readable socket. NULL for // not initialized or external sockets. CZMQ_EXPORT void * zproc_stderr (zproc_t *self); // *** Draft method, for development use, may change without warning *** // Starts the process. CZMQ_EXPORT int zproc_run (zproc_t *self); // *** Draft method, for development use, may change without warning *** // process exit code CZMQ_EXPORT int zproc_returncode (zproc_t *self); // *** Draft method, for development use, may change without warning *** // PID of the process CZMQ_EXPORT int zproc_pid (zproc_t *self); // *** Draft method, for development use, may change without warning *** // return true if process is running, false if not yet started or finished CZMQ_EXPORT bool zproc_running (zproc_t *self); // *** Draft method, for development use, may change without warning *** // wait or poll process status, return return code CZMQ_EXPORT int zproc_wait (zproc_t *self, bool hang); // *** Draft method, for development use, may change without warning *** // return internal actor, usefull for the polling if process died CZMQ_EXPORT void * zproc_actor (zproc_t *self); // *** Draft method, for development use, may change without warning *** // send a signal to the subprocess CZMQ_EXPORT void zproc_kill (zproc_t *self, int signal); // *** Draft method, for development use, may change without warning *** // set verbose mode CZMQ_EXPORT void zproc_set_verbose (zproc_t *self, bool verbose); // *** Draft method, for development use, may change without warning *** // Returns CZMQ version as a single 6-digit integer encoding the major // version (x 10000), the minor version (x 100) and the patch. CZMQ_EXPORT int zproc_czmq_version (void); // *** Draft method, for development use, may change without warning *** // Returns true if the process received a SIGINT or SIGTERM signal. // It is good practice to use this method to exit any infinite loop // processing messages. CZMQ_EXPORT bool zproc_interrupted (void); // *** Draft method, for development use, may change without warning *** // Returns true if the underlying libzmq supports CURVE security. CZMQ_EXPORT bool zproc_has_curve (void); // *** Draft method, for development use, may change without warning *** // Return current host name, for use in public tcp:// endpoints. // If the host name is not resolvable, returns NULL. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zproc_hostname (void); // *** Draft method, for development use, may change without warning *** // Move the current process into the background. The precise effect // depends on the operating system. On POSIX boxes, moves to a specified // working directory (if specified), closes all file handles, reopens // stdin, stdout, and stderr to the null device, and sets the process to // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there // was an error. CZMQ_EXPORT void zproc_daemonize (const char *workdir); // *** Draft method, for development use, may change without warning *** // Drop the process ID into the lockfile, with exclusive lock, and // switch the process to the specified group and/or user. Any of the // arguments may be null, indicating a no-op. Returns 0 on success, // -1 on failure. Note if you combine this with zsys_daemonize, run // after, not before that method, or the lockfile will hold the wrong // process ID. CZMQ_EXPORT void zproc_run_as (const char *lockfile, const char *group, const char *user); // *** Draft method, for development use, may change without warning *** // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zproc_set_io_threads (size_t io_threads); // *** Draft method, for development use, may change without warning *** // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. CZMQ_EXPORT void zproc_set_max_sockets (size_t max_sockets); // *** Draft method, for development use, may change without warning *** // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". CZMQ_EXPORT void zproc_set_biface (const char *value); // *** Draft method, for development use, may change without warning *** // Return network interface to use for broadcasts, or "" if none was set. CZMQ_EXPORT const char * zproc_biface (void); // *** Draft method, for development use, may change without warning *** // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. CZMQ_EXPORT void zproc_set_log_ident (const char *value); // *** Draft method, for development use, may change without warning *** // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. CZMQ_EXPORT void zproc_set_log_sender (const char *endpoint); // *** Draft method, for development use, may change without warning *** // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. CZMQ_EXPORT void zproc_set_log_system (bool logsystem); // *** Draft method, for development use, may change without warning *** // Log error condition - highest priority CZMQ_EXPORT void zproc_log_error (const char *format, ...) CHECK_PRINTF (1); // *** Draft method, for development use, may change without warning *** // Log warning condition - high priority CZMQ_EXPORT void zproc_log_warning (const char *format, ...) CHECK_PRINTF (1); // *** Draft method, for development use, may change without warning *** // Log normal, but significant, condition - normal priority CZMQ_EXPORT void zproc_log_notice (const char *format, ...) CHECK_PRINTF (1); // *** Draft method, for development use, may change without warning *** // Log informational message - low priority CZMQ_EXPORT void zproc_log_info (const char *format, ...) CHECK_PRINTF (1); // *** Draft method, for development use, may change without warning *** // Log debug-level message - lowest priority CZMQ_EXPORT void zproc_log_debug (const char *format, ...) CHECK_PRINTF (1); // *** Draft method, for development use, may change without warning *** // Self test of this class. CZMQ_EXPORT void zproc_test (bool verbose); #endif // CZMQ_BUILD_DRAFT_API // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zuuid.h0000664000372000037200000000523113222211156016320 0ustar00travistravis00000000000000/* ========================================================================= zuuid - UUID support class Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZUUID_H_INCLUDED__ #define __ZUUID_H_INCLUDED__ #define ZUUID_LEN 16 #define ZUUID_STR_LEN (ZUUID_LEN * 2) #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zuuid.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Create a new UUID object. CZMQ_EXPORT zuuid_t * zuuid_new (void); // Create UUID object from supplied ZUUID_LEN-octet value. CZMQ_EXPORT zuuid_t * zuuid_new_from (const byte *source); // Destroy a specified UUID object. CZMQ_EXPORT void zuuid_destroy (zuuid_t **self_p); // Set UUID to new supplied ZUUID_LEN-octet value. CZMQ_EXPORT void zuuid_set (zuuid_t *self, const byte *source); // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. CZMQ_EXPORT int zuuid_set_str (zuuid_t *self, const char *source); // Return UUID binary data. CZMQ_EXPORT const byte * zuuid_data (zuuid_t *self); // Return UUID binary size CZMQ_EXPORT size_t zuuid_size (zuuid_t *self); // Returns UUID as string CZMQ_EXPORT const char * zuuid_str (zuuid_t *self); // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier CZMQ_EXPORT const char * zuuid_str_canonical (zuuid_t *self); // Store UUID blob in target array CZMQ_EXPORT void zuuid_export (zuuid_t *self, byte *target); // Check if UUID is same as supplied value CZMQ_EXPORT bool zuuid_eq (zuuid_t *self, const byte *compare); // Check if UUID is different from supplied value CZMQ_EXPORT bool zuuid_neq (zuuid_t *self, const byte *compare); // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. CZMQ_EXPORT zuuid_t * zuuid_dup (zuuid_t *self); // Self test of this class. CZMQ_EXPORT void zuuid_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zclock.h0000664000372000037200000000455413222211156016454 0ustar00travistravis00000000000000/* ========================================================================= zclock - millisecond clocks and delays Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZCLOCK_H_INCLUDED__ #define __ZCLOCK_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zclock.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Sleep for a number of milliseconds CZMQ_EXPORT void zclock_sleep (int msecs); // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. CZMQ_EXPORT int64_t zclock_time (void); // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. CZMQ_EXPORT int64_t zclock_mono (void); // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. CZMQ_EXPORT int64_t zclock_usecs (void); // Return formatted date/time as fresh string. Free using zstr_free(). // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zclock_timestr (void); // Self test of this class. CZMQ_EXPORT void zclock_test (bool verbose); // @end // DEPRECATED in favor of zsys logging, see issue #519 // Print formatted string to stdout, prefixed by date/time and // terminated with a newline. CZMQ_EXPORT void zclock_log (const char *format, ...); // Compiler hints CZMQ_EXPORT void zclock_log (const char *format, ...) CHECK_PRINTF (1); #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zfile.h0000664000372000037200000001377613222211156016306 0ustar00travistravis00000000000000/* ========================================================================= zfile - helper functions for working with files. Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZFILE_H_INCLUDED__ #define __ZFILE_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zfile.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. CZMQ_EXPORT zfile_t * zfile_new (const char *path, const char *name); // Destroy a file item CZMQ_EXPORT void zfile_destroy (zfile_t **self_p); // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zfile_t * zfile_dup (zfile_t *self); // Return file name, remove path if provided CZMQ_EXPORT const char * zfile_filename (zfile_t *self, const char *path); // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. CZMQ_EXPORT void zfile_restat (zfile_t *self); // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. CZMQ_EXPORT time_t zfile_modified (zfile_t *self); // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. CZMQ_EXPORT off_t zfile_cursize (zfile_t *self); // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. CZMQ_EXPORT bool zfile_is_directory (zfile_t *self); // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. CZMQ_EXPORT bool zfile_is_regular (zfile_t *self); // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. CZMQ_EXPORT bool zfile_is_readable (zfile_t *self); // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. CZMQ_EXPORT bool zfile_is_writeable (zfile_t *self); // Check if file has stopped changing and can be safely processed. // Updates the file statistics from disk at every call. CZMQ_EXPORT bool zfile_is_stable (zfile_t *self); // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. CZMQ_EXPORT bool zfile_has_changed (zfile_t *self); // Remove the file from disk CZMQ_EXPORT void zfile_remove (zfile_t *self); // Open file for reading // Returns 0 if OK, -1 if not found or not accessible CZMQ_EXPORT int zfile_input (zfile_t *self); // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. CZMQ_EXPORT int zfile_output (zfile_t *self); // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zchunk_t * zfile_read (zfile_t *self, size_t bytes, off_t offset); // Returns true if zfile_read() just read the last chunk in the file. CZMQ_EXPORT bool zfile_eof (zfile_t *self); // Write chunk to file at specified position // Return 0 if OK, else -1 CZMQ_EXPORT int zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset); // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. CZMQ_EXPORT const char * zfile_readln (zfile_t *self); // Close file, if open CZMQ_EXPORT void zfile_close (zfile_t *self); // Return file handle, if opened CZMQ_EXPORT FILE * zfile_handle (zfile_t *self); // Calculate SHA1 digest for file, using zdigest class. CZMQ_EXPORT const char * zfile_digest (zfile_t *self); // Self test of this class. CZMQ_EXPORT void zfile_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Create new temporary file for writing via tmpfile. File is automaticaly // deleted on destroy CZMQ_EXPORT zfile_t * zfile_tmp (void); #endif // CZMQ_BUILD_DRAFT_API // @end // @interface // These methods are deprecated, and now moved to zsys class. CZMQ_EXPORT bool zfile_exists (const char *filename); CZMQ_EXPORT ssize_t zfile_size (const char *filename); CZMQ_EXPORT mode_t zfile_mode (const char *filename); CZMQ_EXPORT int zfile_delete (const char *filename); CZMQ_EXPORT bool zfile_stable (const char *filename); CZMQ_EXPORT int zfile_mkdir (const char *pathname); CZMQ_EXPORT int zfile_rmdir (const char *pathname); CZMQ_EXPORT void zfile_mode_private (void); CZMQ_EXPORT void zfile_mode_default (void); // @end #ifdef __cplusplus } #endif #endif // __ZFILE_H_INCLUDED__ czmq-4.1.0/include/zdir.h0000664000372000037200000001155513222211156016136 0ustar00travistravis00000000000000/* ========================================================================= zdir - work with file-system directories Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZDIR_H_INCLUDED__ #define __ZDIR_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zdir.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. CZMQ_EXPORT zdir_t * zdir_new (const char *path, const char *parent); // Destroy a directory tree and all children it contains. CZMQ_EXPORT void zdir_destroy (zdir_t **self_p); // Return directory path CZMQ_EXPORT const char * zdir_path (zdir_t *self); // Return last modification time for directory. CZMQ_EXPORT time_t zdir_modified (zdir_t *self); // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. CZMQ_EXPORT off_t zdir_cursize (zdir_t *self); // Return directory count CZMQ_EXPORT size_t zdir_count (zdir_t *self); // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlist_t * zdir_list (zdir_t *self); // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. CZMQ_EXPORT void zdir_remove (zdir_t *self, bool force); // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlist_t * zdir_diff (zdir_t *older, zdir_t *newer, const char *alias); // Return full contents of directory as a zdir_patch list. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlist_t * zdir_resync (zdir_t *self, const char *alias); // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zhash_t * zdir_cache (zdir_t *self); // Print contents of directory to open stream CZMQ_EXPORT void zdir_fprint (zdir_t *self, FILE *file, int indent); // Print contents of directory to stdout CZMQ_EXPORT void zdir_print (zdir_t *self, int indent); // Create a new zdir_watch actor instance: // // zactor_t *watch = zactor_new (zdir_watch, NULL); // // Destroy zdir_watch instance: // // zactor_destroy (&watch); // // Enable verbose logging of commands and activity: // // zstr_send (watch, "VERBOSE"); // // Subscribe to changes to a directory path: // // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); // // Unsubscribe from changes to a directory path: // // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); // // Receive directory changes: // zsock_recv (watch, "sp", &path, &patches); // // // Delete the received data. // free (path); // zlist_destroy (&patches); CZMQ_EXPORT void zdir_watch (zsock_t *pipe, void *unused); // Self test of this class. CZMQ_EXPORT void zdir_test (bool verbose); // @end // Returns a sorted array of zfile objects; returns a single block of memory, // that you destroy by calling zstr_free(). Each entry in the array is a pointer // to a zfile_t item already allocated in the zdir tree. The array ends with // a null pointer. Do not destroy the original zdir tree until you are done // with this array. CZMQ_EXPORT zfile_t ** zdir_flatten (zdir_t *self); // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. CZMQ_EXPORT void zdir_flatten_free (zfile_t ***files_p); #ifdef __cplusplus } #endif // Deprecated method aliases #define zdir_dump(s,i) zdir_print(s,i) #endif czmq-4.1.0/include/czmq_prelude.h0000664000372000037200000005641213222211156017661 0ustar00travistravis00000000000000/* ========================================================================= czmq_prelude.h - CZMQ environment Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __CZMQ_PRELUDE_H_INCLUDED__ #define __CZMQ_PRELUDE_H_INCLUDED__ //- Establish the compiler and computer system ------------------------------ /* * Defines zero or more of these symbols, for use in any non-portable * code (for pre-defined values see e.g. build-system headers as well * as output of GNU C preprocessor via `cpp -dM < /dev/null`): * * __WINDOWS__ Microsoft C/C++ with Windows calls * __MSDOS__ System is MS-DOS (set if __WINDOWS__ set) * __VMS__ System is VAX/VMS or Alpha/OpenVMS * __UNIX__ System is UNIX * __OS2__ System is OS/2 * * __IS_32BIT__ OS/compiler is 32 bits * __IS_64BIT__ OS/compiler is 64 bits * * When __UNIX__ is defined, we also define exactly one of these: * * __UTYPE_AUX Apple AUX * __UTYPE_BEOS BeOS * __UTYPE_BSDOS BSD/OS * __UTYPE_DECALPHA Digital UNIX (Alpha) * __UTYPE_IBMAIX IBM RS/6000 AIX * __UTYPE_FREEBSD FreeBSD * __UTYPE_HPUX HP/UX * __UTYPE_ANDROID Android * __UTYPE_LINUX Linux * __UTYPE_GNU GNU/Hurd * __UTYPE_MIPS MIPS (BSD 4.3/System V mixture) * __UTYPE_NETBSD NetBSD * __UTYPE_NEXT NeXT * __UTYPE_OPENBSD OpenBSD * __UTYPE_OSX Apple Macintosh OS X * __UTYPE_IOS Apple iOS * __UTYPE_QNX QNX * __UTYPE_IRIX Silicon Graphics IRIX * __UTYPE_SINIX SINIX-N (Siemens-Nixdorf Unix) * __UTYPE_SUNOS SunOS * __UTYPE_SUNSOLARIS Sun Solaris * __UTYPE_UNIXWARE SCO UnixWare * ... these are the ones I know about so far. * __UTYPE_GENERIC Any other UNIX * * When __VMS__ is defined, we may define one or more of these: * * __VMS_XOPEN Supports XOPEN functions */ #if (defined (__64BIT__) || defined (__x86_64__)) # define __IS_64BIT__ // May have 64-bit OS/compiler #else # define __IS_32BIT__ // Else assume 32-bit OS/compiler #endif #if (defined WIN32 || defined _WIN32) # undef __WINDOWS__ # define __WINDOWS__ # undef __MSDOS__ # define __MSDOS__ #endif #if (defined WINDOWS || defined _WINDOWS || defined __WINDOWS__) # undef __WINDOWS__ # define __WINDOWS__ # undef __MSDOS__ # define __MSDOS__ // Stop cheeky warnings about "deprecated" functions like fopen # if _MSC_VER >= 1500 # undef _CRT_SECURE_NO_DEPRECATE # define _CRT_SECURE_NO_DEPRECATE # pragma warning(disable: 4996) # endif #endif // MSDOS Microsoft C // _MSC_VER Microsoft C #if (defined (MSDOS) || defined (_MSC_VER)) # undef __MSDOS__ # define __MSDOS__ # if (defined (_DEBUG) && !defined (DEBUG)) # define DEBUG # endif #endif #if (defined (__EMX__) && defined (__i386__)) # undef __OS2__ # define __OS2__ #endif // VMS VAX C (VAX/VMS) // __VMS Dec C (Alpha/OpenVMS) // __vax__ gcc #if (defined (VMS) || defined (__VMS) || defined (__vax__)) # undef __VMS__ # define __VMS__ # if (__VMS_VER >= 70000000) # define __VMS_XOPEN # endif #endif // Try to define a __UTYPE_xxx symbol... // unix SunOS at least // __unix__ gcc // _POSIX_SOURCE is various UNIX systems, maybe also VAX/VMS #if (defined (unix) || defined (__unix__) || defined (_POSIX_SOURCE)) # if (!defined (__VMS__)) # undef __UNIX__ # define __UNIX__ # if (defined (__alpha)) // Digital UNIX is 64-bit # undef __IS_32BIT__ # define __IS_64BIT__ # define __UTYPE_DECALPHA # endif # endif #endif #if (defined (_AUX)) # define __UTYPE_AUX # define __UNIX__ #elif (defined (__BEOS__)) # define __UTYPE_BEOS # define __UNIX__ #elif (defined (__hpux)) # define __UTYPE_HPUX # define __UNIX__ # define _INCLUDE_HPUX_SOURCE # define _INCLUDE_XOPEN_SOURCE # define _INCLUDE_POSIX_SOURCE #elif (defined (_AIX) || defined (AIX)) # define __UTYPE_IBMAIX # define __UNIX__ #elif (defined (BSD) || defined (bsd)) # define __UTYPE_BSDOS # define __UNIX__ #elif (defined (__ANDROID__)) # define __UTYPE_ANDROID # define __UNIX__ #elif (defined (LINUX) || defined (linux) || defined (__linux__)) # define __UTYPE_LINUX # define __UNIX__ # ifndef __NO_CTYPE # define __NO_CTYPE // Suppress warnings on tolower() # endif # ifndef _DEFAULT_SOURCE # define _DEFAULT_SOURCE // Include stuff from 4.3 BSD Unix # endif #elif (defined (__GNU__)) # define __UTYPE_GNU # define __UNIX__ #elif (defined (Mips)) # define __UTYPE_MIPS # define __UNIX__ #elif (defined (FreeBSD) || defined (__FreeBSD__) || defined (__FreeBSD_kernel__)) # define __UTYPE_FREEBSD # define __UNIX__ #elif (defined (NetBSD) || defined (__NetBSD__)) # define __UTYPE_NETBSD # define __UNIX__ #elif (defined (OpenBSD) || defined (__OpenBSD__)) # define __UTYPE_OPENBSD # define __UNIX__ #elif (defined (APPLE) || defined (__APPLE__)) # include # define __UNIX__ # if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR # define __UTYPE_IOS # else # define __UTYPE_OSX # endif #elif (defined (NeXT)) # define __UTYPE_NEXT # define __UNIX__ #elif (defined (__QNX__)) # define __UTYPE_QNX # define __UNIX__ #elif (defined (sgi)) # define __UTYPE_IRIX # define __UNIX__ #elif (defined (sinix)) # define __UTYPE_SINIX # define __UNIX__ #elif (defined (SOLARIS) || defined (__SVR4) || defined (SVR4) || defined (__SVR4__) || defined (__svr4) || defined (svr4) || defined (__svr4__)) // Note: this rule and below should match legacy SunOS and Solaris // on builds without the GNU toolchain; with one you get __UTYPE_GNU # define __UTYPE_SUNSOLARIS # define __UNIX__ #elif (defined (SUNOS) || defined (SUN) || defined (sun) || defined (__sun) || defined (__sun__)) # define __UTYPE_SUNOS # define __UNIX__ #elif (defined (__USLC__) || defined (UnixWare)) # define __UTYPE_UNIXWARE # define __UNIX__ #elif (defined (__CYGWIN__)) # define __UTYPE_CYGWIN # define __UNIX__ #elif (defined (__UNIX__)) # define __UTYPE_GENERIC #endif //- Always include ZeroMQ headers ------------------------------------------- #include "zmq.h" #if (ZMQ_VERSION < ZMQ_MAKE_VERSION (4, 2, 0)) # include "zmq_utils.h" #endif //- Standard ANSI include files --------------------------------------------- #include #include #include #include #include #include #include #include #include #include #include #include #include #include //- System-specific include files ------------------------------------------- #if (defined (__MSDOS__)) # if (defined (__WINDOWS__)) # if (_WIN32_WINNT < 0x0600) # undef _WIN32_WINNT # define _WIN32_WINNT 0x0600 # endif # if (!defined (FD_SETSIZE)) # define FD_SETSIZE 1024 // Max. filehandles/sockets # endif # include # include # include # include # include // For getnameinfo () # include // For GetAdaptersAddresses () # endif # include # include # include # include # include # include # include # include #endif #if (defined (__UNIX__)) # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include // Let CZMQ build with libzmq/3.x # include // Must come before arpa/inet.h # if (!defined (__UTYPE_ANDROID)) && (!defined (__UTYPE_IBMAIX)) \ && (!defined (__UTYPE_HPUX)) # include # endif # if defined (__UTYPE_SUNSOLARIS) || defined (__UTYPE_SUNOS) # include # endif # if (!defined (__UTYPE_BEOS)) # include # if (!defined (TCP_NODELAY)) # include # endif # endif # if (defined (__UTYPE_IBMAIX) || defined(__UTYPE_QNX)) # include # endif # if (defined (__UTYPE_BEOS)) # include # endif # if ((defined (_XOPEN_REALTIME) && (_XOPEN_REALTIME >= 1)) \ || (defined (_POSIX_VERSION) && (_POSIX_VERSION >= 199309L))) # include # endif # if (defined (__UTYPE_OSX) || defined (__UTYPE_IOS)) # include # include // For monotonic clocks # endif # if (defined (__UTYPE_OSX)) # include // For _NSGetEnviron() # endif # if (defined (__UTYPE_ANDROID)) # include # endif # if (defined (__UTYPE_LINUX) && defined (HAVE_LIBSYSTEMD)) # include # endif #endif #if (defined (__VMS__)) # if (!defined (vaxc)) # include // Not provided by Vax C # endif # include # include # include # include # include # include # include # include # include # include # include # include # include # include #endif #if (defined (__OS2__)) # include // Required near top # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include // Must come before arpa/inet.h # include # include # if (!defined (TCP_NODELAY)) # include # endif #endif // Add missing defines for non-POSIX systems #ifndef S_IRUSR # define S_IRUSR S_IREAD #endif #ifndef S_IWUSR # define S_IWUSR S_IWRITE #endif #ifndef S_ISDIR # define S_ISDIR(m) (((m) & S_IFDIR) != 0) #endif #ifndef S_ISREG # define S_ISREG(m) (((m) & S_IFREG) != 0) #endif //- Check compiler data type sizes ------------------------------------------ #if (UCHAR_MAX != 0xFF) # error "Cannot compile: must change definition of 'byte'." #endif #if (USHRT_MAX != 0xFFFFU) # error "Cannot compile: must change definition of 'dbyte'." #endif #if (UINT_MAX != 0xFFFFFFFFU) # error "Cannot compile: must change definition of 'qbyte'." #endif //- Data types -------------------------------------------------------------- typedef unsigned char byte; // Single unsigned byte = 8 bits typedef unsigned short dbyte; // Double byte = 16 bits typedef unsigned int qbyte; // Quad byte = 32 bits typedef struct sockaddr_in inaddr_t; // Internet socket address structure typedef struct sockaddr_in6 in6addr_t; // Internet 6 socket address structure // Common structure to hold inaddr_t and in6addr_t with length typedef struct { union { inaddr_t __addr; // IPv4 address in6addr_t __addr6; // IPv6 address } __inaddr_u; #define ipv4addr __inaddr_u.__addr #define ipv6addr __inaddr_u.__addr6 int inaddrlen; } inaddr_storage_t; //- Inevitable macros ------------------------------------------------------- #define streq(s1,s2) (!strcmp ((s1), (s2))) #define strneq(s1,s2) (strcmp ((s1), (s2))) #define freen(x) do {free(x); x = NULL;} while(0) // randof(num) : Provide random number from 0..(num-1) // ASSUMES that "num" itself is at most an int (bit size no more than float // on the host platform), and non-negative; may be a "function()" token. // For practical reasons, "num" should be under 50M or so. // The math libraries on different platforms and capabilities in HW are a // nightmare. Seems we have to drown the code in casts to have reasonable // results... Also note that the 32-bit float has a hard time representing // values close to UINT32_MAX that we had before, so now limit to UINT16_MAX. // Platforms where RAND_MAX is comparable to even signed INT32_MAX were // rigged with problems here: even if the code used double-precision, the // corner-case factors (divident close to INT32_MAX and close to divisor) // were too close to 1.0, so the final product was "num" rather than "num-1". // Finally note that on some platforms RAND_MAX can be smallish, like 32767, // so we should use it if small enough. // Precision for our calculations impacts the MAX values we can use below // Still, say UINT64_MAX is overkill. But smaller MAXes can yield better // distribution of values with e.g. double. #if !defined (ZSYS_RANDOF_FLT) # define ZSYS_RANDOF_FLT float #endif // ZSYS_RANDOF_FLT is defined by caller... trust them or explode later // Implementations vary... Note that many will get __UTYPE_GNU nowadays. #if !defined (ZSYS_RANDOF_FUNC) # if defined (ZSYS_RANDOF_FUNC_BITS) # undef ZSYS_RANDOF_FUNC_BITS # endif # if (defined (__WINDOWS__)) || (defined (__UTYPE_IBMAIX)) \ || (defined (__UTYPE_HPUX)) || (defined (__UTYPE_SUNOS)) || (defined (__UTYPE_SOLARIS)) # define ZSYS_RANDOF_FUNC rand # define ZSYS_RANDOF_FUNC_BITS 15 # else # define ZSYS_RANDOF_FUNC random # define ZSYS_RANDOF_FUNC_BITS 32 # endif #endif // ZSYS_RANDOF_FUNC is defined by caller... trust them or explode later // Limits below were experimented for 32-bit floats on x86 with test_randof // Due to discrete rounding, greater values caused collisions with the // fraction s_randof_factor() defined below returning 1.0. #if !defined (ZSYS_RANDOF_MAX) # if (ZSYS_RANDOF_FUNC_BITS >= 26) // Assume that random() is at least 32-bit as it is on most platforms # define ZSYS_RANDOF_MAX (UINT32_MAX>>6) # else # if defined (RAND_MAX) # if (RAND_MAX > (UINT32_MAX>>6)) # define ZSYS_RANDOF_MAX (UINT32_MAX>>6) # else // RAND_MAX is small enough to not overflow our calculations # define ZSYS_RANDOF_MAX RAND_MAX # endif # else // No RAND_MAX - use a smaller safer limit, but with values too discrete # define ZSYS_RANDOF_MAX INT16_MAX # endif # endif // not random() #endif // ZSYS_RANDOF_MAX is defined by caller... trust them or explode later #define s_randof_factor() (ZSYS_RANDOF_FLT)( (ZSYS_RANDOF_FLT)(ZSYS_RANDOF_FUNC() % (ZSYS_RANDOF_MAX - 1)) / ( (ZSYS_RANDOF_FLT)(ZSYS_RANDOF_MAX) ) ) // Supplement the limited spectrum of ZSYS_RANDOF_MAX by stacking more random()s // Note this can still be too little for very large "num" > ZSYS_RANDOF_MAX // but we'd need a real randof() function to handle stacking in that case. // Fuzziness added below (division by slightly more than a whole number) solves // this wonderfully even for "num" ranges twice as big as the ZSYS_RANDOF_MAX. #if (ZSYS_RANDOF_MAX > UINT16_MAX) # define randof(num) (int) ( (ZSYS_RANDOF_FLT)(num) * s_randof_factor() / ( 1.0 + s_randof_factor() / 100.0 ) ) #else // boost dispersion # if (ZSYS_RANDOF_MAX > INT16_MAX) # define randof(num) (int) ( (ZSYS_RANDOF_FLT)(num) * ( s_randof_factor() + s_randof_factor() ) / ( 2.0 + s_randof_factor() / 2.0 ) ) # else # if (ZSYS_RANDOF_MAX > UINT8_MAX) # define randof(num) (int) ( (ZSYS_RANDOF_FLT)(num) * ( s_randof_factor() + s_randof_factor() + s_randof_factor() + s_randof_factor() ) / ( 4.0 + s_randof_factor() * 10.0 ) ) # else # define randof(num) (int) ( (ZSYS_RANDOF_FLT)(num) * ( s_randof_factor() + s_randof_factor() + s_randof_factor() + s_randof_factor() + s_randof_factor() + s_randof_factor() ) / ( 6.0 + s_randof_factor() * 100.0 ) ) # endif # endif #endif // That's it about the randof() macro definition... // Windows MSVS doesn't have stdbool #if (defined (_MSC_VER)) # if (!defined (__cplusplus) && (!defined (true))) # define true 1 # define false 0 typedef char bool; # endif #else # include #endif //- A number of POSIX and C99 keywords and data types ----------------------- // CZMQ uses uint for array indices; equivalent to unsigned int, but more // convenient in code. We define it in czmq_prelude.h on systems that do // not define it by default. #if (defined (__WINDOWS__)) # if (!defined (__cplusplus) && (!defined (inline))) # define inline __inline # endif # define strtoull _strtoui64 # define atoll _atoi64 # define srandom srand # define TIMEZONE _timezone # if (!defined (__MINGW32__)) # define snprintf _snprintf # define vsnprintf _vsnprintf # endif typedef unsigned long ulong; typedef unsigned int uint; # if (!defined (__MINGW32__)) typedef int mode_t; # if !defined (_SSIZE_T_DEFINED) typedef intptr_t ssize_t; # define _SSIZE_T_DEFINED # endif # endif # if ((!defined (__MINGW32__) \ || (defined (__MINGW32__) && defined (__IS_64BIT__))) \ && !defined (ZMQ_DEFINED_STDINT)) typedef __int8 int8_t; typedef __int16 int16_t; typedef __int32 int32_t; typedef __int64 int64_t; typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; # endif typedef uint32_t in_addr_t; # if (!defined (PRId8)) # define PRId8 "d" # endif # if (!defined (PRId16)) # define PRId16 "d" # endif # if (!defined (PRId32)) # define PRId32 "d" # endif # if (!defined (PRId64)) # define PRId64 "I64d" # endif # if (!defined (PRIi8)) # define PRIi8 "i" # endif # if (!defined (PRIi16)) # define PRIi16 "i" # endif # if (!defined (PRIi32)) # define PRIi32 "i" # endif # if (!defined (PRIi64)) # define PRIi64 "I64i" # endif # if (!defined (PRIu8)) # define PRIu8 "u" # endif # if (!defined (PRIu16)) # define PRIu16 "u" # endif # if (!defined (PRIu32)) # define PRIu32 "u" # endif # if (!defined (PRIu64)) # define PRIu64 "I64u" # endif # if (!defined (va_copy)) // MSVC does not support C99's va_copy so we use a regular assignment # define va_copy(dest,src) (dest) = (src) # endif #elif (defined (__UTYPE_OSX) || defined (__OpenBSD__)) typedef unsigned long ulong; typedef unsigned int uint; // This fixes header-order dependence problem with some Linux versions #elif (defined (__UTYPE_LINUX)) # if (__STDC_VERSION__ >= 199901L && !defined (__USE_MISC)) typedef unsigned int uint; # endif #endif //- Non-portable declaration specifiers ------------------------------------- // For thread-local storage #if defined (__WINDOWS__) # define CZMQ_THREADLS __declspec(thread) #else # define CZMQ_THREADLS __thread #endif // Replacement for malloc() which asserts if we run out of heap, and // which zeroes the allocated block. static inline void * safe_malloc (size_t size, const char *file, unsigned line) { // printf ("%s:%u %08d\n", file, line, (int) size); void *mem = calloc (1, size); if (mem == NULL) { fprintf (stderr, "FATAL ERROR at %s:%u\n", file, line); fprintf (stderr, "OUT OF MEMORY (malloc returned NULL)\n"); fflush (stderr); abort (); } return mem; } // Define _ZMALLOC_DEBUG if you need to trace memory leaks using e.g. mtrace, // otherwise all allocations will claim to come from czmq_prelude.h. For best // results, compile all classes so you see dangling object allocations. // _ZMALLOC_PEDANTIC does the same thing, but its intention is to propagate // out of memory condition back up the call stack. #if defined (_ZMALLOC_DEBUG) || defined (_ZMALLOC_PEDANTIC) # define zmalloc(size) calloc(1,(size)) #else # define zmalloc(size) safe_malloc((size), __FILE__, __LINE__) #endif // GCC supports validating format strings for functions that act like printf #if defined (__GNUC__) && (__GNUC__ >= 2) # define CHECK_PRINTF(a) __attribute__((format (printf, a, a + 1))) #else # define CHECK_PRINTF(a) #endif // Lets us write code that compiles both on Windows and normal platforms #if !defined (__WINDOWS__) typedef int SOCKET; # define closesocket close # define INVALID_SOCKET -1 # define SOCKET_ERROR -1 # if !defined O_BINARY # define O_BINARY 0 # endif #endif //- Include non-portable header files based on platform.h ------------------- #if defined (HAVE_LINUX_WIRELESS_H) # include // This would normally come from net/if.h unsigned int if_nametoindex (const char *ifname); char *if_indextoname (unsigned int ifindex, char *ifname); // 32 on Linux, 256 on Windows, pick largest to avoid overflows # define IF_NAMESIZE 256 #else # if defined (HAVE_NET_IF_H) # include # endif # if defined (HAVE_NET_IF_MEDIA_H) # include # endif #endif #if defined (__WINDOWS__) && !defined (HAVE_UUID) # define HAVE_UUID 1 #endif #if defined (__UTYPE_OSX) && !defined (HAVE_UUID) # define HAVE_UUID 1 #endif #if defined (HAVE_UUID) # if defined (__UTYPE_FREEBSD) || defined (__UTYPE_NETBSD) || defined(__UTYPE_OPENBSD) # include # elif defined __UTYPE_HPUX # include # elif defined (__UNIX__) # include # endif #endif // ZMQ compatibility macros #if ZMQ_VERSION_MAJOR == 4 # define ZMQ_POLL_MSEC 1 // zmq_poll is msec #elif ZMQ_VERSION_MAJOR == 3 # define ZMQ_POLL_MSEC 1 // zmq_poll is msec # if ZMQ_VERSION_MINOR < 2 # define zmq_ctx_new zmq_init # endif # define zmq_ctx_term zmq_term #elif ZMQ_VERSION_MAJOR == 2 # define ZMQ_POLL_MSEC 1000 // zmq_poll is usec # define zmq_sendmsg zmq_send // Smooth out 2.x changes # define zmq_recvmsg zmq_recv # define zmq_ctx_new zmq_init # define zmq_ctx_term zmq_term # define zmq_msg_send(m,s,f) zmq_sendmsg ((s),(m),(f)) # define zmq_msg_recv(m,s,f) zmq_recvmsg ((s),(m),(f)) // Older libzmq APIs may be missing some aspects of libzmq v3.0 # ifndef ZMQ_ROUTER # define ZMQ_ROUTER ZMQ_XREP # endif # ifndef ZMQ_DEALER # define ZMQ_DEALER ZMQ_XREQ # endif # ifndef ZMQ_DONTWAIT # define ZMQ_DONTWAIT ZMQ_NOBLOCK # endif # ifndef ZMQ_XSUB # error "please upgrade your libzmq from http://zeromq.org" # endif # if ZMQ_VERSION_MINOR == 0 \ || (ZMQ_VERSION_MINOR == 1 && ZMQ_VERSION_PATCH < 7) # error "CZMQ requires at least libzmq/2.1.7 stable" # endif #endif #endif czmq-4.1.0/include/zproxy.h0000664000372000037200000000746113222211156016542 0ustar00travistravis00000000000000/* ========================================================================= zproxy - run a steerable proxy in the background Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZPROXY_H_INCLUDED__ #define __ZPROXY_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Create new zproxy actor instance. The proxy switches messages between // a frontend socket and a backend socket; use the FRONTEND and BACKEND // commands to configure these: // // zactor_t *proxy = zactor_new (zproxy, NULL); // // Destroy zproxy instance. This destroys the two sockets and stops any // message flow between them: // // zactor_destroy (&proxy); // // Note that all zproxy commands are synchronous, so your application always // waits for a signal from the actor after each command. // // Enable verbose logging of commands and activity: // // zstr_send (proxy, "VERBOSE"); // zsock_wait (proxy); // // Specify frontend socket type -- see zsock_type_str () -- and attach to // endpoints, see zsock_attach (). Note that a proxy socket is always // serverish: // // zstr_sendx (proxy, "FRONTEND", "XSUB", endpoints, NULL); // zsock_wait (proxy); // // Specify backend socket type -- see zsock_type_str () -- and attach to // endpoints, see zsock_attach (). Note that a proxy socket is always // serverish: // // zstr_sendx (proxy, "BACKEND", "XPUB", endpoints, NULL); // zsock_wait (proxy); // // Capture all proxied messages; these are delivered to the application // via an inproc PULL socket that you have already bound to the specified // endpoint: // // zstr_sendx (proxy, "CAPTURE", endpoint, NULL); // zsock_wait (proxy); // // Pause the proxy. A paused proxy will cease processing messages, causing // them to be queued up and potentially hit the high-water mark on the // frontend or backend socket, causing messages to be dropped, or writing // applications to block: // // zstr_sendx (proxy, "PAUSE", NULL); // zsock_wait (proxy); // // Resume the proxy. Note that the proxy starts automatically as soon as it // has a properly attached frontend and backend socket: // // zstr_sendx (proxy, "RESUME", NULL); // zsock_wait (proxy); // // Configure an authentication domain for the "FRONTEND" or "BACKEND" proxy // socket -- see zsock_set_zap_domain (). Call before binding socket: // // zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); // zsock_wait (proxy); // // Configure PLAIN authentication for the "FRONTEND" or "BACKEND" proxy // socket -- see zsock_set_plain_server (). Call before binding socket: // // zstr_sendx (proxy, "PLAIN", "BACKEND", NULL); // zsock_wait (proxy); // // Configure CURVE authentication for the "FRONTEND" or "BACKEND" proxy // socket -- see zsock_set_curve_server () -- specifying both the public and // secret keys of a certificate as Z85 armored strings -- see // zcert_public_txt () and zcert_secret_txt (). Call before binding socket: // // zstr_sendx (proxy, "CURVE", "FRONTEND", public_txt, secret_txt, NULL); // zsock_wait (proxy); // // This is the zproxy constructor as a zactor_fn; the argument is a // character string specifying frontend and backend socket types as two // uppercase strings separated by a hyphen: CZMQ_EXPORT void zproxy (zsock_t *pipe, void *unused); // Selftest CZMQ_EXPORT void zproxy_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/czmq.h0000664000372000037200000000237313222211156016136 0ustar00travistravis00000000000000/* ========================================================================= CZMQ - a high-level binding in C for ZeroMQ Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= "Tell them I was a writer. A maker of software. A humanist. A father. And many things. But above all, a writer. Thank You. :) - Pieter Hintjens */ #ifndef __CZMQ_H_INCLUDED__ #define __CZMQ_H_INCLUDED__ // These are signatures for handler functions that customize the // behavior of CZMQ containers. These are shared between all CZMQ // container types. // -- destroy an item typedef void (czmq_destructor) (void **item); // -- duplicate an item typedef void *(czmq_duplicator) (const void *item); // - compare two items, for sorting typedef int (czmq_comparator) (const void *item1, const void *item2); // Include the project library file #include "czmq_library.h" #endif czmq-4.1.0/include/zrex.h0000664000372000037200000000552713222211156016160 0ustar00travistravis00000000000000/* ========================================================================= zrex - work with regular expressions Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZREX_H_INCLUDED__ #define __ZREX_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface // Constructor. Optionally, sets an expression against which we can match // text and capture hits. If there is an error in the expression, reports // zrex_valid() as false and provides the error in zrex_strerror(). If you // set a pattern, you can call zrex_matches() to test it against text. CZMQ_EXPORT zrex_t * zrex_new (const char *expression); // Destructor CZMQ_EXPORT void zrex_destroy (zrex_t **self_p); // Return true if the expression was valid and compiled without errors. CZMQ_EXPORT bool zrex_valid (zrex_t *self); // Return the error message generated during compilation of the expression. CZMQ_EXPORT const char * zrex_strerror (zrex_t *self); // Returns true if the text matches the previously compiled expression. // Use this method to compare one expression against many strings. CZMQ_EXPORT bool zrex_matches (zrex_t *self, const char *text); // Returns true if the text matches the supplied expression. Use this // method to compare one string against several expressions. CZMQ_EXPORT bool zrex_eq (zrex_t *self, const char *text, const char *expression); // Returns number of hits from last zrex_matches or zrex_eq. If the text // matched, returns 1 plus the number of capture groups. If the text did // not match, returns zero. To retrieve individual capture groups, call // zrex_hit (). CZMQ_EXPORT int zrex_hits (zrex_t *self); // Returns the Nth capture group from the last expression match, where // N is 0 to the value returned by zrex_hits(). Capture group 0 is the // whole matching string. Sequence 1 is the first capture group, if any, // and so on. CZMQ_EXPORT const char * zrex_hit (zrex_t *self, uint index); // Fetches hits into string variables provided by caller; this makes for // nicer code than accessing hits by index. Caller should not modify nor // free the returned values. Returns number of strings returned. This // method starts at hit 1, i.e. first capture group, as hit 0 is always // the original matched string. CZMQ_EXPORT int zrex_fetch (zrex_t *self, const char **string_p, ...); // Self test of this class CZMQ_EXPORT void zrex_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zcertstore.h0000664000372000037200000000742013222211156017366 0ustar00travistravis00000000000000/* ========================================================================= zcertstore - work with CURVE security certificate stores Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZCERTSTORE_H_INCLUDED__ #define __ZCERTSTORE_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zcertstore.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. CZMQ_EXPORT zcertstore_t * zcertstore_new (const char *location); // Destroy a certificate store object in memory. Does not affect anything // stored on disk. CZMQ_EXPORT void zcertstore_destroy (zcertstore_t **self_p); // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. CZMQ_EXPORT zcert_t * zcertstore_lookup (zcertstore_t *self, const char *public_key); // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. CZMQ_EXPORT void zcertstore_insert (zcertstore_t *self, zcert_t **cert_p); // Print list of certificates in store to logging facility CZMQ_EXPORT void zcertstore_print (zcertstore_t *self); // Self test of this class CZMQ_EXPORT void zcertstore_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // Loaders retrieve certificates from an arbitrary source. typedef void (zcertstore_loader) ( zcertstore_t *self); // Destructor for loader state. typedef void (zcertstore_destructor) ( void **self_p); // *** Draft method, for development use, may change without warning *** // Override the default disk loader with a custom loader fn. CZMQ_EXPORT void zcertstore_set_loader (zcertstore_t *self, zcertstore_loader loader, zcertstore_destructor destructor, void *state); // *** Draft method, for development use, may change without warning *** // Empty certificate hashtable. This wrapper exists to be friendly to bindings, // which don't usually have access to struct internals. CZMQ_EXPORT void zcertstore_empty (zcertstore_t *self); // *** Draft method, for development use, may change without warning *** // Return a list of all the certificates in the store. // The caller takes ownership of the zlistx_t object and is responsible // for destroying it. The caller does not take ownership of the zcert_t // objects. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zlistx_t * zcertstore_certs (zcertstore_t *self); #endif // CZMQ_BUILD_DRAFT_API // @end #ifdef __cplusplus } #endif // Deprecated method aliases #define zcertstore_dump(s) zcertstore_print(s) #endif czmq-4.1.0/include/zcert.h0000664000372000037200000001046413222211156016313 0ustar00travistravis00000000000000/* ========================================================================= zcert - work with CURVE security certificates Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZCERT_H_INCLUDED__ #define __ZCERT_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zcert.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. // Create and initialize a new certificate in memory CZMQ_EXPORT zcert_t * zcert_new (void); // Accepts public/secret key pair from caller CZMQ_EXPORT zcert_t * zcert_new_from (const byte *public_key, const byte *secret_key); // Load certificate from file CZMQ_EXPORT zcert_t * zcert_load (const char *filename); // Destroy a certificate in memory CZMQ_EXPORT void zcert_destroy (zcert_t **self_p); // Return public part of key pair as 32-byte binary string CZMQ_EXPORT const byte * zcert_public_key (zcert_t *self); // Return secret part of key pair as 32-byte binary string CZMQ_EXPORT const byte * zcert_secret_key (zcert_t *self); // Return public part of key pair as Z85 armored string CZMQ_EXPORT const char * zcert_public_txt (zcert_t *self); // Return secret part of key pair as Z85 armored string CZMQ_EXPORT const char * zcert_secret_txt (zcert_t *self); // Set certificate metadata from formatted string. CZMQ_EXPORT void zcert_set_meta (zcert_t *self, const char *name, const char *format, ...) CHECK_PRINTF (3); // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. CZMQ_EXPORT const char * zcert_meta (zcert_t *self, const char *name); // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. CZMQ_EXPORT zlist_t * zcert_meta_keys (zcert_t *self); // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). CZMQ_EXPORT int zcert_save (zcert_t *self, const char *filename); // Save public certificate only to file for persistent storage CZMQ_EXPORT int zcert_save_public (zcert_t *self, const char *filename); // Save secret certificate only to file for persistent storage CZMQ_EXPORT int zcert_save_secret (zcert_t *self, const char *filename); // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. CZMQ_EXPORT void zcert_apply (zcert_t *self, void *socket); // Return copy of certificate; if certificate is NULL or we exhausted // heap memory, returns NULL. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zcert_t * zcert_dup (zcert_t *self); // Return true if two certificates have the same keys CZMQ_EXPORT bool zcert_eq (zcert_t *self, zcert_t *compare); // Print certificate contents to stdout CZMQ_EXPORT void zcert_print (zcert_t *self); // Self test of this class CZMQ_EXPORT void zcert_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Accepts public/secret key text pair from caller CZMQ_EXPORT zcert_t * zcert_new_from_txt (const char *public_txt, const char *secret_txt); // *** Draft method, for development use, may change without warning *** // Unset certificate metadata. CZMQ_EXPORT void zcert_unset_meta (zcert_t *self, const char *name); #endif // CZMQ_BUILD_DRAFT_API // @end #ifdef __cplusplus } #endif // Deprecated method aliases #define zcert_dump(s) zcert_print(s) #endif czmq-4.1.0/include/zchunk.h0000664000372000037200000001304313222211156016462 0ustar00travistravis00000000000000/* ========================================================================= zchunk - work with memory chunks Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZCHUNK_H_INCLUDED__ #define __ZCHUNK_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zchunk.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. CZMQ_EXPORT zchunk_t * zchunk_new (const void *data, size_t size); // Destroy a chunk CZMQ_EXPORT void zchunk_destroy (zchunk_t **self_p); // Resizes chunk max_size as requested; chunk_cur size is set to zero CZMQ_EXPORT void zchunk_resize (zchunk_t *self, size_t size); // Return chunk cur size CZMQ_EXPORT size_t zchunk_size (zchunk_t *self); // Return chunk max size CZMQ_EXPORT size_t zchunk_max_size (zchunk_t *self); // Return chunk data CZMQ_EXPORT byte * zchunk_data (zchunk_t *self); // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk CZMQ_EXPORT size_t zchunk_set (zchunk_t *self, const void *data, size_t size); // Fill chunk data from user-supplied octet CZMQ_EXPORT size_t zchunk_fill (zchunk_t *self, byte filler, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, it is truncated. If you want to // grow the chunk to accommodate new data, use the zchunk_extend method. CZMQ_EXPORT size_t zchunk_append (zchunk_t *self, const void *data, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, the chunk grows in size. CZMQ_EXPORT size_t zchunk_extend (zchunk_t *self, const void *data, size_t size); // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. CZMQ_EXPORT size_t zchunk_consume (zchunk_t *self, zchunk_t *source); // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. CZMQ_EXPORT bool zchunk_exhausted (zchunk_t *self); // Read chunk from an open file descriptor // Caller owns return value and must destroy it when done. CZMQ_EXPORT zchunk_t * zchunk_read (FILE *handle, size_t bytes); // Write chunk to an open file descriptor CZMQ_EXPORT int zchunk_write (zchunk_t *self, FILE *handle); // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zchunk_t * zchunk_slurp (const char *filename, size_t maxsize); // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // returns null. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zchunk_t * zchunk_dup (zchunk_t *self); // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zchunk_strhex (zchunk_t *self); // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zchunk_strdup (zchunk_t *self); // Return TRUE if chunk body is equal to string, excluding terminator CZMQ_EXPORT bool zchunk_streq (zchunk_t *self, const char *string); // Transform zchunk into a zframe that can be sent in a message. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zchunk_pack (zchunk_t *self); // Transform a zframe into a zchunk. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zchunk_t * zchunk_unpack (zframe_t *frame); // Calculate SHA1 digest for chunk, using zdigest class. CZMQ_EXPORT const char * zchunk_digest (zchunk_t *self); // Dump chunk to FILE stream, for debugging and tracing. CZMQ_EXPORT void zchunk_fprint (zchunk_t *self, FILE *file); // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details CZMQ_EXPORT void zchunk_print (zchunk_t *self); // Probe the supplied object, and report if it looks like a zchunk_t. CZMQ_EXPORT bool zchunk_is (void *self); // Self test of this class. CZMQ_EXPORT void zchunk_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zauth.h0000664000372000037200000000703313222211156016315 0ustar00travistravis00000000000000/* ========================================================================= zauth - authentication for ZeroMQ security mechanisms Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZAUTH_H_INCLUDED__ #define __ZAUTH_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @interface #define CURVE_ALLOW_ANY "*" // CZMQ v3 API (for use with zsock, not zsocket, which is deprecated). // // Create new zauth actor instance. This installs authentication on all // zsock sockets. Until you add policies, all incoming NULL connections are // allowed (classic ZeroMQ behaviour), and all PLAIN and CURVE connections // are denied: // // zactor_t *auth = zactor_new (zauth, NULL); // // Destroy zauth instance. This removes authentication and allows all // connections to pass, without authentication: // // zactor_destroy (&auth); // // Note that all zauth commands are synchronous, so your application always // waits for a signal from the actor after each command. // // Enable verbose logging of commands and activity. Verbose logging can help // debug non-trivial authentication policies: // // zstr_send (auth, "VERBOSE"); // zsock_wait (auth); // // Allow (whitelist) a list of IP addresses. For NULL, all clients from // these addresses will be accepted. For PLAIN and CURVE, they will be // allowed to continue with authentication. You can call this method // multiple times to whitelist more IP addresses. If you whitelist one // or more addresses, any non-whitelisted addresses are treated as // blacklisted: // // zstr_sendx (auth, "ALLOW", "127.0.0.1", "127.0.0.2", NULL); // zsock_wait (auth); // // Deny (blacklist) a list of IP addresses. For all security mechanisms, // this rejects the connection without any further authentication. Use // either a whitelist, or a blacklist, not not both. If you define both // a whitelist and a blacklist, only the whitelist takes effect: // // zstr_sendx (auth, "DENY", "192.168.0.1", "192.168.0.2", NULL); // zsock_wait (auth); // // Configure PLAIN authentication using a plain-text password file. You can // modify the password file at any time; zauth will reload it automatically // if modified externally: // // zstr_sendx (auth, "PLAIN", filename, NULL); // zsock_wait (auth); // // Configure CURVE authentication, using a directory that holds all public // client certificates, i.e. their public keys. The certificates must be in // zcert_save format. You can add and remove certificates in that directory // at any time. To allow all client keys without checking, specify // CURVE_ALLOW_ANY for the directory name: // // zstr_sendx (auth, "CURVE", directory, NULL); // zsock_wait (auth); // // Configure GSSAPI authentication, using an underlying mechanism (usually // Kerberos) to establish a secure context and perform mutual authentication: // // zstr_sendx (auth, "GSSAPI", NULL); // zsock_wait (auth); // // This is the zauth constructor as a zactor_fn: CZMQ_EXPORT void zauth (zsock_t *pipe, void *certstore); // Selftest CZMQ_EXPORT void zauth_test (bool verbose); // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/include/zframe.h0000664000372000037200000001404213222211156016444 0ustar00travistravis00000000000000/* ========================================================================= zframe - working with single message frames Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZFRAME_H_INCLUDED__ #define __ZFRAME_H_INCLUDED__ #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zframe.api" to make changes. // @interface // This is a stable class, and may not change except for emergencies. It // is provided in stable builds. // This class has draft methods, which may change over time. They are not // in stable releases, by default. Use --enable-drafts to enable. #define ZFRAME_MORE 1 // #define ZFRAME_REUSE 2 // #define ZFRAME_DONTWAIT 4 // // Create a new frame. If size is not null, allocates the frame data // to the specified size. If additionally, data is not null, copies // size octets from the specified data into the frame body. CZMQ_EXPORT zframe_t * zframe_new (const void *data, size_t size); // Create an empty (zero-sized) frame CZMQ_EXPORT zframe_t * zframe_new_empty (void); // Create a frame with a specified string content. CZMQ_EXPORT zframe_t * zframe_from (const char *string); // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. CZMQ_EXPORT zframe_t * zframe_recv (void *source); // Destroy a frame CZMQ_EXPORT void zframe_destroy (zframe_t **self_p); // Send a frame to a socket, destroy frame after sending. // Return -1 on error, 0 on success. CZMQ_EXPORT int zframe_send (zframe_t **self_p, void *dest, int flags); // Return number of bytes in frame data CZMQ_EXPORT size_t zframe_size (zframe_t *self); // Return address of frame data CZMQ_EXPORT byte * zframe_data (zframe_t *self); // Return meta data property for frame // The caller shall not modify or free the returned value, which shall be // owned by the message. CZMQ_EXPORT const char * zframe_meta (zframe_t *self, const char *property); // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. // Caller owns return value and must destroy it when done. CZMQ_EXPORT zframe_t * zframe_dup (zframe_t *self); // Return frame data encoded as printable hex string, useful for 0MQ UUIDs. // Caller must free string when finished with it. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zframe_strhex (zframe_t *self); // Return frame data copied into freshly allocated string // Caller must free string when finished with it. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zframe_strdup (zframe_t *self); // Return TRUE if frame body is equal to string, excluding terminator CZMQ_EXPORT bool zframe_streq (zframe_t *self, const char *string); // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method CZMQ_EXPORT int zframe_more (zframe_t *self); // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. CZMQ_EXPORT void zframe_set_more (zframe_t *self, int more); // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false. CZMQ_EXPORT bool zframe_eq (zframe_t *self, zframe_t *other); // Set new contents for frame CZMQ_EXPORT void zframe_reset (zframe_t *self, const void *data, size_t size); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. CZMQ_EXPORT void zframe_print (zframe_t *self, const char *prefix); // Probe the supplied object, and report if it looks like a zframe_t. CZMQ_EXPORT bool zframe_is (void *self); // Self test of this class. CZMQ_EXPORT void zframe_test (bool verbose); #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** // Return frame routing ID, if the frame came from a ZMQ_SERVER socket. // Else returns zero. CZMQ_EXPORT uint32_t zframe_routing_id (zframe_t *self); // *** Draft method, for development use, may change without warning *** // Set routing ID on frame. This is used if/when the frame is sent to a // ZMQ_SERVER socket. CZMQ_EXPORT void zframe_set_routing_id (zframe_t *self, uint32_t routing_id); // *** Draft method, for development use, may change without warning *** // Return frame group of radio-dish pattern. CZMQ_EXPORT const char * zframe_group (zframe_t *self); // *** Draft method, for development use, may change without warning *** // Set group on frame. This is used if/when the frame is sent to a // ZMQ_RADIO socket. // Return -1 on error, 0 on success. CZMQ_EXPORT int zframe_set_group (zframe_t *self, const char *group); #endif // CZMQ_BUILD_DRAFT_API // @end // DEPRECATED as poor style -- callers should use zloop or zpoller // Receive a new frame off the socket. Returns newly allocated frame, or // NULL if there was no input waiting, or if the read was interrupted. CZMQ_EXPORT zframe_t * zframe_recv_nowait (void *source); // DEPRECATED as inconsistent; breaks principle that logging should all go // to a single destination. // Print contents of the frame to FILE stream. CZMQ_EXPORT void zframe_fprint (zframe_t *self, const char *prefix, FILE *file); // Deprecated method aliases #define zframe_print_to_stream(s,p,F) zframe_fprint(s,p,F) #ifdef __cplusplus } #endif #endif czmq-4.1.0/config/0000775000372000037200000000000013222211351014625 5ustar00travistravis00000000000000czmq-4.1.0/config/lt~obsolete.m40000644000372000037200000001375613222211330017450 0ustar00travistravis00000000000000# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) czmq-4.1.0/config/depcomp0000755000372000037200000005601613222211333016210 0ustar00travistravis00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2013-05-30.07; # UTC # Copyright (C) 1999-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: czmq-4.1.0/config/test-driver0000755000372000037200000001027713222211333017030 0ustar00travistravis00000000000000#! /bin/sh # test-driver - basic testsuite driver script. scriptversion=2013-07-13.22; # UTC # Copyright (C) 2011-2013 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . # Make unconditional expansion of undefined variables an error. This # helps a lot in preventing typo-related bugs. set -u usage_error () { echo "$0: $*" >&2 print_usage >&2 exit 2 } print_usage () { cat <$log_file 2>&1 estatus=$? if test $enable_hard_errors = no && test $estatus -eq 99; then estatus=1 fi case $estatus:$expect_failure in 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 0:*) col=$grn res=PASS recheck=no gcopy=no;; 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; *:*) col=$red res=FAIL recheck=yes gcopy=yes;; esac # Report outcome to console. echo "${col}${res}${std}: $test_name" # Register the test result, and other relevant metadata. echo ":test-result: $res" > $trs_file echo ":global-test-result: $res" >> $trs_file echo ":recheck: $recheck" >> $trs_file echo ":copy-in-global-log: $gcopy" >> $trs_file # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: czmq-4.1.0/config/ltsugar.m40000644000372000037200000001042413222211330016544 0ustar00travistravis00000000000000# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) czmq-4.1.0/config/compile0000755000372000037200000001624513222211333016211 0ustar00travistravis00000000000000#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-10-14.11; # UTC # Copyright (C) 1999-2013 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: czmq-4.1.0/config/missing0000755000372000037200000001533013222211333016224 0ustar00travistravis00000000000000#! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2013-10-28.13; # UTC # Copyright (C) 1996-2013 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=http://www.perl.org/ flex_URL=http://flex.sourceforge.net/ gnu_software_URL=http://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: czmq-4.1.0/config/config.guess0000755000372000037200000013036113222211333017147 0ustar00travistravis00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2013 Free Software Foundation, Inc. timestamp='2013-06-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches with a ChangeLog entry to config-patches@gnu.org. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; or1k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: czmq-4.1.0/config/ltversion.m40000644000372000037200000000126213222211330017110 0ustar00travistravis00000000000000# ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 3337 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.2]) m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.2' macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) czmq-4.1.0/config/ltmain.sh0000644000372000037200000105204413222211330016446 0ustar00travistravis00000000000000 # libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1" TIMESTAMP="" package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-warning|--no-warn) opt_warning=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; *) func_fatal_configuration "$modename: unknown library version type \`$version_type'" ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then # Remove ${wl} instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" func_resolve_sysroot "$deplib" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 czmq-4.1.0/config/config.sub0000755000372000037200000010535413222211333016616 0ustar00travistravis00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2013 Free Software Foundation, Inc. timestamp='2013-08-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches with a ChangeLog entry to config-patches@gnu.org. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 \ | or1k | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or1k-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: czmq-4.1.0/config/install-sh0000755000372000037200000003325513222211333016637 0ustar00travistravis00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-11-20.07; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: czmq-4.1.0/config/libtool.m40000644000372000037200000106011113222211330016526 0ustar00travistravis00000000000000# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 57 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG m4_ifndef([AC_PROG_GO], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ F* | *Sun*Fortran*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi _LT_TAGVAR(link_all_deplibs, $1)=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS czmq-4.1.0/config/ltoptions.m40000644000372000037200000003007313222211330017120 0ustar00travistravis00000000000000# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, # Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 7 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS ## --------------------------------- ## ## Macros to handle LT_INIT options. ## ## --------------------------------- ## # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) czmq-4.1.0/Findsystemd.cmake0000664000372000037200000000352313222211156016661 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ if (NOT MSVC) include(FindPkgConfig) pkg_check_modules(PC_SYSTEMD "libsystemd") if (NOT PC_SYSTEMD_FOUND) pkg_check_modules(PC_SYSTEMD "libsystemd") endif (NOT PC_SYSTEMD_FOUND) if (PC_SYSTEMD_FOUND) # add CFLAGS from pkg-config file, e.g. draft api. add_definitions(${PC_SYSTEMD_CFLAGS} ${PC_SYSTEMD_CFLAGS_OTHER}) # some libraries install the headers is a subdirectory of the include dir # returned by pkg-config, so use a wildcard match to improve chances of finding # headers and SOs. set(PC_SYSTEMD_INCLUDE_HINTS ${PC_SYSTEMD_INCLUDE_DIRS} ${PC_SYSTEMD_INCLUDE_DIRS}/*) set(PC_SYSTEMD_LIBRARY_HINTS ${PC_SYSTEMD_LIBRARY_DIRS} ${PC_SYSTEMD_LIBRARY_DIRS}/*) endif(PC_SYSTEMD_FOUND) endif (NOT MSVC) find_path ( SYSTEMD_INCLUDE_DIRS NAMES systemd/sd-daemon.h HINTS ${PC_SYSTEMD_INCLUDE_HINTS} ) find_library ( SYSTEMD_LIBRARIES NAMES libsystemd HINTS ${PC_SYSTEMD_LIBRARY_HINTS} ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args( SYSTEMD REQUIRED_VARS SYSTEMD_LIBRARIES SYSTEMD_INCLUDE_DIRS ) mark_as_advanced( SYSTEMD_FOUND SYSTEMD_LIBRARIES SYSTEMD_INCLUDE_DIRS ) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/LICENSE0000664000372000037200000004052513222211156014376 0ustar00travistravis00000000000000Mozilla Public License Version 2.0 ================================== 1. Definitions -------------- 1.1. "Contributor" means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. 1.2. "Contributor Version" means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor's Contribution. 1.3. "Contribution" means Covered Software of a particular Contributor. 1.4. "Covered Software" means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. 1.5. "Incompatible With Secondary Licenses" means (a) that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or (b) that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. 1.6. "Executable Form" means any form of the work other than Source Code Form. 1.7. "Larger Work" means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" means this document. 1.9. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. 1.10. "Modifications" means any of the following: (a) any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or (b) any new file in Source Code Form that contains any Covered Software. 1.11. "Patent Claims" of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. 1.12. "Secondary License" means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. 1.13. "Source Code Form" means the form of the work preferred for making modifications. 1.14. "You" (or "Your") means an individual or a legal entity exercising rights under this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants and Conditions -------------------------------- 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: (a) under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and (b) under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: (a) for any code that a Contributor has removed from Covered Software; or (b) for infringements caused by: (i) Your and any other third party's modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or (c) under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities ------------------- 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients' rights in the Source Code Form. 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: (a) such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and (b) You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients' rights in the Source Code Form under this License. 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation --------------------------------------------------- If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination -------------- 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. ************************************************************************ * * * 6. Disclaimer of Warranty * * ------------------------- * * * * Covered Software is provided under this License on an "as is" * * basis, without warranty of any kind, either expressed, implied, or * * statutory, including, without limitation, warranties that the * * Covered Software is free of defects, merchantable, fit for a * * particular purpose or non-infringing. The entire risk as to the * * quality and performance of the Covered Software is with You. * * Should any Covered Software prove defective in any respect, You * * (not any Contributor) assume the cost of any necessary servicing, * * repair, or correction. This disclaimer of warranty constitutes an * * essential part of this License. No use of any Covered Software is * * authorized under this License except under this disclaimer. * * * ************************************************************************ ************************************************************************ * * * 7. Limitation of Liability * * -------------------------- * * * * Under no circumstances and under no legal theory, whether tort * * (including negligence), contract, or otherwise, shall any * * Contributor, or anyone who distributes Covered Software as * * permitted above, be liable to You for any direct, indirect, * * special, incidental, or consequential damages of any character * * including, without limitation, damages for lost profits, loss of * * goodwill, work stoppage, computer failure or malfunction, or any * * and all other commercial damages or losses, even if such party * * shall have been informed of the possibility of such damages. This * * limitation of liability shall not apply to liability for death or * * personal injury resulting from such party's negligence to the * * extent applicable law prohibits such limitation. Some * * jurisdictions do not allow the exclusion or limitation of * * incidental or consequential damages, so this exclusion and * * limitation may not apply to You. * * * ************************************************************************ 8. Litigation ------------- Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party's ability to bring cross-claims or counter-claims. 9. Miscellaneous ---------------- This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License --------------------------- 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. Exhibit A - Source Code Form License Notice ------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. You may add additional accurate notices of copyright ownership. Exhibit B - "Incompatible With Secondary Licenses" Notice --------------------------------------------------------- This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. czmq-4.1.0/acinclude.m40000664000372000037200000000032613222211156015555 0ustar00travistravis00000000000000AC_DEFUN([AX_PROJECT_LOCAL_HOOK], [ AC_CHECK_HEADERS(pthread.h) AC_CHECK_LIB([pthread], [pthread_create], [CFLAGS="${CFLAGS} -pthread"], [AC_MSG_WARN([cannot link with -pthread.])] ) ]) czmq-4.1.0/Makefile.in0000664000372000037200000036712013222211333015436 0ustar00travistravis00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ # Project-local changes to auto-generated content VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = $(am__EXEEXT_1) noinst_PROGRAMS = $(am__EXEEXT_3) $(am__EXEEXT_4) $(am__EXEEXT_2) check_PROGRAMS = $(am__EXEEXT_2) TESTS = @ENABLE_DIST_CMAKEFILES_TRUE@am__append_1 = \ @ENABLE_DIST_CMAKEFILES_TRUE@ Findlibzmq.cmake \ @ENABLE_DIST_CMAKEFILES_TRUE@ Finduuid.cmake \ @ENABLE_DIST_CMAKEFILES_TRUE@ Findsystemd.cmake \ @ENABLE_DIST_CMAKEFILES_TRUE@ Findlz4.cmake \ @ENABLE_DIST_CMAKEFILES_TRUE@ src/CMakeLists-local.txt \ @ENABLE_DIST_CMAKEFILES_TRUE@ CMakeLists.txt DIST_COMMON = $(srcdir)/src/Makemodule.am \ $(srcdir)/src/Makemodule-local.am $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am $(top_srcdir)/configure \ $(am__configure_deps) $(top_srcdir)/src/platform.h.in \ $(top_srcdir)/src/libczmq.pc.in $(top_srcdir)/config/depcomp \ $(dist_api_DATA) $(am__include_HEADERS_DIST) \ $(top_srcdir)/config/test-driver AUTHORS NEWS config/compile \ config/config.guess config/config.sub config/depcomp \ config/install-sh config/missing config/ltmain.sh \ $(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \ $(top_srcdir)/config/config.sub \ $(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \ $(top_srcdir)/config/missing # Programs need to link the c++ runtime if everything was compiled statically. @ENABLE_SHARED_FALSE@am__append_2 = -lstdc++ -lm @ENABLE_DRAFTS_TRUE@am__append_3 = \ @ENABLE_DRAFTS_TRUE@ include/zargs.h \ @ENABLE_DRAFTS_TRUE@ include/zproc.h \ @ENABLE_DRAFTS_TRUE@ include/ztimerset.h \ @ENABLE_DRAFTS_TRUE@ include/ztrie.h @ENABLE_DRAFTS_TRUE@am__append_4 = src/zargs.c src/zproc.c \ @ENABLE_DRAFTS_TRUE@ src/ztimerset.c src/ztrie.c \ @ENABLE_DRAFTS_TRUE@ src/czmq_private_selftest.c @ON_MINGW_TRUE@am__append_5 = \ @ON_MINGW_TRUE@ -no-undefined \ @ON_MINGW_TRUE@ -avoid-version @ON_CYGWIN_TRUE@am__append_6 = \ @ON_CYGWIN_TRUE@ -no-undefined \ @ON_CYGWIN_TRUE@ -avoid-version @ENABLE_ZMAKECERT_TRUE@am__append_7 = src/zmakecert @ENABLE_ZSP_TRUE@am__append_8 = src/zsp @ENABLE_TEST_RANDOF_TRUE@am__append_9 = src/test_randof @ENABLE_CZMQ_SELFTEST_TRUE@am__append_10 = src/czmq_selftest @ENABLE_CZMQ_SELFTEST_TRUE@am__append_11 = src/czmq_selftest # Android-qt requires this special link dependency @ON_ANDROID_TRUE@am__append_12 = -llog subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/config/libtool.m4 \ $(top_srcdir)/config/ltoptions.m4 \ $(top_srcdir)/config/ltsugar.m4 \ $(top_srcdir)/config/ltversion.m4 \ $(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/src/platform.h CONFIG_CLEAN_FILES = src/libczmq.pc CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ "$(DESTDIR)$(apidir)" "$(DESTDIR)$(pkgconfigdir)" \ "$(DESTDIR)$(includedir)" LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) src_libczmq_la_DEPENDENCIES = $(am__DEPENDENCIES_2) \ $(am__DEPENDENCIES_1) am__src_libczmq_la_SOURCES_DIST = src/zactor.c src/zarmour.c \ src/zcert.c src/zcertstore.c src/zchunk.c src/zclock.c \ src/zconfig.c src/zdigest.c src/zdir.c src/zdir_patch.c \ src/zfile.c src/zframe.c src/zhash.c src/zhashx.c \ src/ziflist.c src/zlist.c src/zlistx.c src/zloop.c src/zmsg.c \ src/zpoller.c src/zsock.c src/zstr.c src/zsys.c src/zuuid.c \ src/zauth.c src/zbeacon.c src/zgossip.c src/zgossip_engine.inc \ src/zmonitor.c src/zproxy.c src/zrex.c src/zgossip_msg.c \ src/zsock_option.inc src/zhash_primes.inc \ src/foreign/sha1/sha1.inc_c src/foreign/sha1/sha1.h \ src/foreign/slre/slre.inc_c src/foreign/slre/slre.h \ src/foreign/slre/readme.txt src/platform.h src/zargs.c \ src/zproc.c src/ztimerset.c src/ztrie.c \ src/czmq_private_selftest.c am__dirstamp = $(am__leading_dot)dirstamp @ENABLE_DRAFTS_TRUE@am__objects_1 = src/src_libczmq_la-zargs.lo \ @ENABLE_DRAFTS_TRUE@ src/src_libczmq_la-zproc.lo \ @ENABLE_DRAFTS_TRUE@ src/src_libczmq_la-ztimerset.lo \ @ENABLE_DRAFTS_TRUE@ src/src_libczmq_la-ztrie.lo \ @ENABLE_DRAFTS_TRUE@ src/src_libczmq_la-czmq_private_selftest.lo am_src_libczmq_la_OBJECTS = src/src_libczmq_la-zactor.lo \ src/src_libczmq_la-zarmour.lo src/src_libczmq_la-zcert.lo \ src/src_libczmq_la-zcertstore.lo src/src_libczmq_la-zchunk.lo \ src/src_libczmq_la-zclock.lo src/src_libczmq_la-zconfig.lo \ src/src_libczmq_la-zdigest.lo src/src_libczmq_la-zdir.lo \ src/src_libczmq_la-zdir_patch.lo src/src_libczmq_la-zfile.lo \ src/src_libczmq_la-zframe.lo src/src_libczmq_la-zhash.lo \ src/src_libczmq_la-zhashx.lo src/src_libczmq_la-ziflist.lo \ src/src_libczmq_la-zlist.lo src/src_libczmq_la-zlistx.lo \ src/src_libczmq_la-zloop.lo src/src_libczmq_la-zmsg.lo \ src/src_libczmq_la-zpoller.lo src/src_libczmq_la-zsock.lo \ src/src_libczmq_la-zstr.lo src/src_libczmq_la-zsys.lo \ src/src_libczmq_la-zuuid.lo src/src_libczmq_la-zauth.lo \ src/src_libczmq_la-zbeacon.lo src/src_libczmq_la-zgossip.lo \ src/src_libczmq_la-zmonitor.lo src/src_libczmq_la-zproxy.lo \ src/src_libczmq_la-zrex.lo src/src_libczmq_la-zgossip_msg.lo \ $(am__objects_1) src_libczmq_la_OBJECTS = $(am_src_libczmq_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = src_libczmq_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(src_libczmq_la_LDFLAGS) $(LDFLAGS) -o \ $@ @ENABLE_ZMAKECERT_TRUE@am__EXEEXT_1 = src/zmakecert$(EXEEXT) @ENABLE_CZMQ_SELFTEST_TRUE@am__EXEEXT_2 = src/czmq_selftest$(EXEEXT) @ENABLE_ZSP_TRUE@am__EXEEXT_3 = src/zsp$(EXEEXT) @ENABLE_TEST_RANDOF_TRUE@am__EXEEXT_4 = src/test_randof$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) am__src_czmq_selftest_SOURCES_DIST = src/czmq_selftest.c @ENABLE_CZMQ_SELFTEST_TRUE@am_src_czmq_selftest_OBJECTS = src/src_czmq_selftest-czmq_selftest.$(OBJEXT) src_czmq_selftest_OBJECTS = $(am_src_czmq_selftest_OBJECTS) am__DEPENDENCIES_3 = src/libczmq.la $(am__DEPENDENCIES_2) \ $(am__DEPENDENCIES_1) @ENABLE_CZMQ_SELFTEST_TRUE@src_czmq_selftest_DEPENDENCIES = \ @ENABLE_CZMQ_SELFTEST_TRUE@ $(am__DEPENDENCIES_3) am__src_test_randof_SOURCES_DIST = src/test_randof.c @ENABLE_TEST_RANDOF_TRUE@am_src_test_randof_OBJECTS = src/src_test_randof-test_randof.$(OBJEXT) src_test_randof_OBJECTS = $(am_src_test_randof_OBJECTS) @ENABLE_TEST_RANDOF_TRUE@src_test_randof_DEPENDENCIES = \ @ENABLE_TEST_RANDOF_TRUE@ $(am__DEPENDENCIES_3) am__src_zmakecert_SOURCES_DIST = src/zmakecert.c @ENABLE_ZMAKECERT_TRUE@am_src_zmakecert_OBJECTS = \ @ENABLE_ZMAKECERT_TRUE@ src/src_zmakecert-zmakecert.$(OBJEXT) src_zmakecert_OBJECTS = $(am_src_zmakecert_OBJECTS) @ENABLE_ZMAKECERT_TRUE@src_zmakecert_DEPENDENCIES = \ @ENABLE_ZMAKECERT_TRUE@ $(am__DEPENDENCIES_3) am__src_zsp_SOURCES_DIST = src/zsp.c @ENABLE_ZSP_TRUE@am_src_zsp_OBJECTS = src/src_zsp-zsp.$(OBJEXT) src_zsp_OBJECTS = $(am_src_zsp_OBJECTS) @ENABLE_ZSP_TRUE@src_zsp_DEPENDENCIES = $(am__DEPENDENCIES_3) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(src_libczmq_la_SOURCES) $(src_czmq_selftest_SOURCES) \ $(src_test_randof_SOURCES) $(src_zmakecert_SOURCES) \ $(src_zsp_SOURCES) DIST_SOURCES = $(am__src_libczmq_la_SOURCES_DIST) \ $(am__src_czmq_selftest_SOURCES_DIST) \ $(am__src_test_randof_SOURCES_DIST) \ $(am__src_zmakecert_SOURCES_DIST) $(am__src_zsp_SOURCES_DIST) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac DATA = $(dist_api_DATA) $(pkgconfig_DATA) am__include_HEADERS_DIST = include/czmq_prelude.h include/czmq.h \ include/zactor.h include/zarmour.h include/zcert.h \ include/zcertstore.h include/zchunk.h include/zclock.h \ include/zconfig.h include/zdigest.h include/zdir.h \ include/zdir_patch.h include/zfile.h include/zframe.h \ include/zhash.h include/zhashx.h include/ziflist.h \ include/zlist.h include/zlistx.h include/zloop.h \ include/zmsg.h include/zpoller.h include/zsock.h \ include/zstr.h include/zsys.h include/zuuid.h include/zauth.h \ include/zbeacon.h include/zgossip.h include/zmonitor.h \ include/zproxy.h include/zrex.h include/czmq_library.h \ include/zargs.h include/zproc.h include/ztimerset.h \ include/ztrie.h HEADERS = $(include_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope check recheck distdir dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/config/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz $(distdir).zip GZIP_ENV = --best DIST_TARGETS = dist-gzip dist-zip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_ARCH = @BUILD_ARCH@ BUILD_DATE = @BUILD_DATE@ BUILD_HOST = @BUILD_HOST@ BUILD_USER = @BUILD_USER@ BUILD_VERSION = @BUILD_VERSION@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LTVER = @LTVER@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ czmq_have_asciidoc = @czmq_have_asciidoc@ czmq_have_xmlto = @czmq_have_xmlto@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ libzmq_CFLAGS = @libzmq_CFLAGS@ libzmq_LIBS = @libzmq_LIBS@ localedir = @localedir@ localstatedir = @localstatedir@ lz4_CFLAGS = @lz4_CFLAGS@ lz4_LIBS = @lz4_LIBS@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkg_config_defines = @pkg_config_defines@ pkg_config_libs_private = @pkg_config_libs_private@ pkgconfig_name_liblz4 = @pkgconfig_name_liblz4@ pkgconfig_name_libsystemd = @pkgconfig_name_libsystemd@ pkgconfig_name_libzmq = @pkgconfig_name_libzmq@ pkgconfig_name_uuid = @pkgconfig_name_uuid@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ systemd_CFLAGS = @systemd_CFLAGS@ systemd_LIBS = @systemd_LIBS@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ uuid_CFLAGS = @uuid_CFLAGS@ uuid_LIBS = @uuid_LIBS@ ACLOCAL_AMFLAGS = -I config AM_CFLAGS = \ -Werror=format-security AM_CPPFLAGS = \ ${libzmq_CFLAGS} \ ${uuid_CFLAGS} \ ${systemd_CFLAGS} \ ${lz4_CFLAGS} \ -I$(srcdir)/include project_libs = ${libzmq_LIBS} ${uuid_LIBS} ${systemd_LIBS} ${lz4_LIBS} SUBDIRS = doc DIST_SUBDIRS = doc lib_LTLIBRARIES = src/libczmq.la noinst_LTLIBRARIES = # Prepare variables that can be populated (appended) in generated Makefiles or # manually maintained src/Makemodule-local.am # Note that this syntax dists the whole directory - including subdirs (if any) EXTRA_DIST = $(am__append_1) bindings src/zsock_option.inc \ src/zgossip_engine.inc src/zhash_primes.inc \ src/foreign/sha1/sha1.inc_c src/foreign/sha1/sha1.h \ src/foreign/slre/slre.inc_c src/foreign/slre/slre.h \ src/foreign/slre/readme.txt src/zgossip_msg.h LICENSE \ README.txt README.md CONTRIBUTING.md src/czmq_classes.h \ $(SELFTEST_DIR_RO) CLEANFILES = $(top_builddir)/$(SELFTEST_DIR_RW)/* DISTCLEANFILES = ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ program_libs = src/libczmq.la ${project_libs} $(am__append_2) pkgconfig_DATA = src/libczmq.pc include_HEADERS = include/czmq_prelude.h include/czmq.h \ include/zactor.h include/zarmour.h include/zcert.h \ include/zcertstore.h include/zchunk.h include/zclock.h \ include/zconfig.h include/zdigest.h include/zdir.h \ include/zdir_patch.h include/zfile.h include/zframe.h \ include/zhash.h include/zhashx.h include/ziflist.h \ include/zlist.h include/zlistx.h include/zloop.h \ include/zmsg.h include/zpoller.h include/zsock.h \ include/zstr.h include/zsys.h include/zuuid.h include/zauth.h \ include/zbeacon.h include/zgossip.h include/zmonitor.h \ include/zproxy.h include/zrex.h include/czmq_library.h \ $(am__append_3) src_libczmq_la_SOURCES = src/zactor.c src/zarmour.c src/zcert.c \ src/zcertstore.c src/zchunk.c src/zclock.c src/zconfig.c \ src/zdigest.c src/zdir.c src/zdir_patch.c src/zfile.c \ src/zframe.c src/zhash.c src/zhashx.c src/ziflist.c \ src/zlist.c src/zlistx.c src/zloop.c src/zmsg.c src/zpoller.c \ src/zsock.c src/zstr.c src/zsys.c src/zuuid.c src/zauth.c \ src/zbeacon.c src/zgossip.c src/zgossip_engine.inc \ src/zmonitor.c src/zproxy.c src/zrex.c src/zgossip_msg.c \ src/zsock_option.inc src/zgossip_engine.inc \ src/zhash_primes.inc src/foreign/sha1/sha1.inc_c \ src/foreign/sha1/sha1.h src/foreign/slre/slre.inc_c \ src/foreign/slre/slre.h src/foreign/slre/readme.txt \ src/platform.h $(am__append_4) src_libczmq_la_CPPFLAGS = ${AM_CPPFLAGS} src_libczmq_la_LDFLAGS = -version-info @LTVER@ \ $(LIBTOOL_EXTRA_LDFLAGS) $(am__append_5) $(am__append_6) src_libczmq_la_LIBADD = ${project_libs} $(am__append_12) @ENABLE_ZMAKECERT_TRUE@src_zmakecert_CPPFLAGS = ${AM_CPPFLAGS} @ENABLE_ZMAKECERT_TRUE@src_zmakecert_LDADD = ${program_libs} @ENABLE_ZMAKECERT_TRUE@src_zmakecert_SOURCES = src/zmakecert.c @ENABLE_ZSP_TRUE@src_zsp_CPPFLAGS = ${AM_CPPFLAGS} @ENABLE_ZSP_TRUE@src_zsp_LDADD = ${program_libs} @ENABLE_ZSP_TRUE@src_zsp_SOURCES = src/zsp.c # Add a way to customize test_randof binary for quick recompiles, e.g. # gmake test_randof_macros="-DZSYS_RANDOF_FLT=double -DZSYS_RANDOF_MAX=INT8_MAX" src/test_randof @ENABLE_TEST_RANDOF_TRUE@src_test_randof_CPPFLAGS = ${AM_CPPFLAGS} \ @ENABLE_TEST_RANDOF_TRUE@ $(test_randof_macros) @ENABLE_TEST_RANDOF_TRUE@src_test_randof_LDADD = ${program_libs} @ENABLE_TEST_RANDOF_TRUE@src_test_randof_SOURCES = src/test_randof.c @ENABLE_CZMQ_SELFTEST_TRUE@src_czmq_selftest_CPPFLAGS = ${AM_CPPFLAGS} @ENABLE_CZMQ_SELFTEST_TRUE@src_czmq_selftest_LDADD = ${program_libs} @ENABLE_CZMQ_SELFTEST_TRUE@src_czmq_selftest_SOURCES = src/czmq_selftest.c # Install api files into /usr/local/share/zproject apidir = @datadir@/zproject/czmq dist_api_DATA = \ api/zactor.api \ api/zargs.api \ api/zarmour.api \ api/zcert.api \ api/zcertstore.api \ api/zchunk.api \ api/zclock.api \ api/zconfig.api \ api/zdigest.api \ api/zdir.api \ api/zdir_patch.api \ api/zfile.api \ api/zframe.api \ api/zhash.api \ api/zhashx.api \ api/ziflist.api \ api/zlist.api \ api/zlistx.api \ api/zloop.api \ api/zmsg.api \ api/zpoller.api \ api/zproc.api \ api/zsock_option.api \ api/zsock.api \ api/zstr.api \ api/zsys.api \ api/ztimerset.api \ api/ztrie.api \ api/zuuid.api \ api/zgossip_msg.api # Directories with test fixtures optionally provided by the project, # and with volatile RW data possibly created by a selftest program. # It is up to the project authors to populate the RO directory with # filenames called from the selftest methods, if any. They will be # EXTRA_DISTed by the recipes generated with with zproject, however, # and copied into builddir (if different from srcdir) to simplify # the "distcheck" and similar tests (so selftest can use same paths). # Note that the RO directory must exist to fulfill EXTRA_DIST, so we # add a stub file that can be committed to SCM by project developers. # The RW directory will be automatically wiped by "make distclean". SELFTEST_DIR_RO = src/selftest-ro SELFTEST_DIR_RW = src/selftest-rw all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/src/Makemodule.am $(srcdir)/src/Makemodule-local.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(srcdir)/src/Makemodule.am $(srcdir)/src/Makemodule-local.am: $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): src/platform.h: src/stamp-h1 @test -f $@ || rm -f src/stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) src/stamp-h1 src/stamp-h1: $(top_srcdir)/src/platform.h.in $(top_builddir)/config.status @rm -f src/stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status src/platform.h $(top_srcdir)/src/platform.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f src/stamp-h1 touch $@ distclean-hdr: -rm -f src/platform.h src/stamp-h1 src/libczmq.pc: $(top_builddir)/config.status $(top_srcdir)/src/libczmq.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } src/$(am__dirstamp): @$(MKDIR_P) src @: > src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) src/$(DEPDIR) @: > src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zactor.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zarmour.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zcert.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zcertstore.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zchunk.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zclock.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zconfig.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zdigest.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zdir.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zdir_patch.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zfile.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zframe.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zhash.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zhashx.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-ziflist.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zlist.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zlistx.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zloop.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zmsg.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zpoller.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zsock.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zstr.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zsys.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zuuid.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zauth.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zbeacon.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zgossip.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zmonitor.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zproxy.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zrex.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zgossip_msg.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zargs.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-zproc.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-ztimerset.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-ztrie.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/src_libczmq_la-czmq_private_selftest.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/libczmq.la: $(src_libczmq_la_OBJECTS) $(src_libczmq_la_DEPENDENCIES) $(EXTRA_src_libczmq_la_DEPENDENCIES) src/$(am__dirstamp) $(AM_V_CCLD)$(src_libczmq_la_LINK) -rpath $(libdir) $(src_libczmq_la_OBJECTS) $(src_libczmq_la_LIBADD) $(LIBS) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ || test -f $$p1 \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list src/src_czmq_selftest-czmq_selftest.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/czmq_selftest$(EXEEXT): $(src_czmq_selftest_OBJECTS) $(src_czmq_selftest_DEPENDENCIES) $(EXTRA_src_czmq_selftest_DEPENDENCIES) src/$(am__dirstamp) @rm -f src/czmq_selftest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(src_czmq_selftest_OBJECTS) $(src_czmq_selftest_LDADD) $(LIBS) src/src_test_randof-test_randof.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/test_randof$(EXEEXT): $(src_test_randof_OBJECTS) $(src_test_randof_DEPENDENCIES) $(EXTRA_src_test_randof_DEPENDENCIES) src/$(am__dirstamp) @rm -f src/test_randof$(EXEEXT) $(AM_V_CCLD)$(LINK) $(src_test_randof_OBJECTS) $(src_test_randof_LDADD) $(LIBS) src/src_zmakecert-zmakecert.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/zmakecert$(EXEEXT): $(src_zmakecert_OBJECTS) $(src_zmakecert_DEPENDENCIES) $(EXTRA_src_zmakecert_DEPENDENCIES) src/$(am__dirstamp) @rm -f src/zmakecert$(EXEEXT) $(AM_V_CCLD)$(LINK) $(src_zmakecert_OBJECTS) $(src_zmakecert_LDADD) $(LIBS) src/src_zsp-zsp.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/zsp$(EXEEXT): $(src_zsp_OBJECTS) $(src_zsp_DEPENDENCIES) $(EXTRA_src_zsp_DEPENDENCIES) src/$(am__dirstamp) @rm -f src/zsp$(EXEEXT) $(AM_V_CCLD)$(LINK) $(src_zsp_OBJECTS) $(src_zsp_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f src/*.$(OBJEXT) -rm -f src/*.lo distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-czmq_private_selftest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zactor.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zargs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zarmour.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zauth.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zbeacon.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zcert.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zcertstore.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zchunk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zclock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zconfig.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zdigest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zdir.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zdir_patch.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zfile.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zframe.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zgossip.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zgossip_msg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zhash.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zhashx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-ziflist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zlist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zlistx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zloop.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zmonitor.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zmsg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zpoller.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zproc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zproxy.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zrex.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zsock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zstr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zsys.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-ztimerset.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-ztrie.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_libczmq_la-zuuid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_test_randof-test_randof.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_zmakecert-zmakecert.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_zsp-zsp.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< src/src_libczmq_la-zactor.lo: src/zactor.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zactor.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zactor.Tpo -c -o src/src_libczmq_la-zactor.lo `test -f 'src/zactor.c' || echo '$(srcdir)/'`src/zactor.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zactor.Tpo src/$(DEPDIR)/src_libczmq_la-zactor.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zactor.c' object='src/src_libczmq_la-zactor.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zactor.lo `test -f 'src/zactor.c' || echo '$(srcdir)/'`src/zactor.c src/src_libczmq_la-zarmour.lo: src/zarmour.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zarmour.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zarmour.Tpo -c -o src/src_libczmq_la-zarmour.lo `test -f 'src/zarmour.c' || echo '$(srcdir)/'`src/zarmour.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zarmour.Tpo src/$(DEPDIR)/src_libczmq_la-zarmour.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zarmour.c' object='src/src_libczmq_la-zarmour.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zarmour.lo `test -f 'src/zarmour.c' || echo '$(srcdir)/'`src/zarmour.c src/src_libczmq_la-zcert.lo: src/zcert.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zcert.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zcert.Tpo -c -o src/src_libczmq_la-zcert.lo `test -f 'src/zcert.c' || echo '$(srcdir)/'`src/zcert.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zcert.Tpo src/$(DEPDIR)/src_libczmq_la-zcert.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zcert.c' object='src/src_libczmq_la-zcert.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zcert.lo `test -f 'src/zcert.c' || echo '$(srcdir)/'`src/zcert.c src/src_libczmq_la-zcertstore.lo: src/zcertstore.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zcertstore.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zcertstore.Tpo -c -o src/src_libczmq_la-zcertstore.lo `test -f 'src/zcertstore.c' || echo '$(srcdir)/'`src/zcertstore.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zcertstore.Tpo src/$(DEPDIR)/src_libczmq_la-zcertstore.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zcertstore.c' object='src/src_libczmq_la-zcertstore.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zcertstore.lo `test -f 'src/zcertstore.c' || echo '$(srcdir)/'`src/zcertstore.c src/src_libczmq_la-zchunk.lo: src/zchunk.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zchunk.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zchunk.Tpo -c -o src/src_libczmq_la-zchunk.lo `test -f 'src/zchunk.c' || echo '$(srcdir)/'`src/zchunk.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zchunk.Tpo src/$(DEPDIR)/src_libczmq_la-zchunk.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zchunk.c' object='src/src_libczmq_la-zchunk.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zchunk.lo `test -f 'src/zchunk.c' || echo '$(srcdir)/'`src/zchunk.c src/src_libczmq_la-zclock.lo: src/zclock.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zclock.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zclock.Tpo -c -o src/src_libczmq_la-zclock.lo `test -f 'src/zclock.c' || echo '$(srcdir)/'`src/zclock.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zclock.Tpo src/$(DEPDIR)/src_libczmq_la-zclock.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zclock.c' object='src/src_libczmq_la-zclock.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zclock.lo `test -f 'src/zclock.c' || echo '$(srcdir)/'`src/zclock.c src/src_libczmq_la-zconfig.lo: src/zconfig.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zconfig.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zconfig.Tpo -c -o src/src_libczmq_la-zconfig.lo `test -f 'src/zconfig.c' || echo '$(srcdir)/'`src/zconfig.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zconfig.Tpo src/$(DEPDIR)/src_libczmq_la-zconfig.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zconfig.c' object='src/src_libczmq_la-zconfig.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zconfig.lo `test -f 'src/zconfig.c' || echo '$(srcdir)/'`src/zconfig.c src/src_libczmq_la-zdigest.lo: src/zdigest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zdigest.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zdigest.Tpo -c -o src/src_libczmq_la-zdigest.lo `test -f 'src/zdigest.c' || echo '$(srcdir)/'`src/zdigest.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zdigest.Tpo src/$(DEPDIR)/src_libczmq_la-zdigest.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zdigest.c' object='src/src_libczmq_la-zdigest.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zdigest.lo `test -f 'src/zdigest.c' || echo '$(srcdir)/'`src/zdigest.c src/src_libczmq_la-zdir.lo: src/zdir.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zdir.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zdir.Tpo -c -o src/src_libczmq_la-zdir.lo `test -f 'src/zdir.c' || echo '$(srcdir)/'`src/zdir.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zdir.Tpo src/$(DEPDIR)/src_libczmq_la-zdir.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zdir.c' object='src/src_libczmq_la-zdir.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zdir.lo `test -f 'src/zdir.c' || echo '$(srcdir)/'`src/zdir.c src/src_libczmq_la-zdir_patch.lo: src/zdir_patch.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zdir_patch.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zdir_patch.Tpo -c -o src/src_libczmq_la-zdir_patch.lo `test -f 'src/zdir_patch.c' || echo '$(srcdir)/'`src/zdir_patch.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zdir_patch.Tpo src/$(DEPDIR)/src_libczmq_la-zdir_patch.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zdir_patch.c' object='src/src_libczmq_la-zdir_patch.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zdir_patch.lo `test -f 'src/zdir_patch.c' || echo '$(srcdir)/'`src/zdir_patch.c src/src_libczmq_la-zfile.lo: src/zfile.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zfile.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zfile.Tpo -c -o src/src_libczmq_la-zfile.lo `test -f 'src/zfile.c' || echo '$(srcdir)/'`src/zfile.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zfile.Tpo src/$(DEPDIR)/src_libczmq_la-zfile.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zfile.c' object='src/src_libczmq_la-zfile.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zfile.lo `test -f 'src/zfile.c' || echo '$(srcdir)/'`src/zfile.c src/src_libczmq_la-zframe.lo: src/zframe.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zframe.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zframe.Tpo -c -o src/src_libczmq_la-zframe.lo `test -f 'src/zframe.c' || echo '$(srcdir)/'`src/zframe.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zframe.Tpo src/$(DEPDIR)/src_libczmq_la-zframe.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zframe.c' object='src/src_libczmq_la-zframe.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zframe.lo `test -f 'src/zframe.c' || echo '$(srcdir)/'`src/zframe.c src/src_libczmq_la-zhash.lo: src/zhash.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zhash.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zhash.Tpo -c -o src/src_libczmq_la-zhash.lo `test -f 'src/zhash.c' || echo '$(srcdir)/'`src/zhash.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zhash.Tpo src/$(DEPDIR)/src_libczmq_la-zhash.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zhash.c' object='src/src_libczmq_la-zhash.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zhash.lo `test -f 'src/zhash.c' || echo '$(srcdir)/'`src/zhash.c src/src_libczmq_la-zhashx.lo: src/zhashx.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zhashx.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zhashx.Tpo -c -o src/src_libczmq_la-zhashx.lo `test -f 'src/zhashx.c' || echo '$(srcdir)/'`src/zhashx.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zhashx.Tpo src/$(DEPDIR)/src_libczmq_la-zhashx.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zhashx.c' object='src/src_libczmq_la-zhashx.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zhashx.lo `test -f 'src/zhashx.c' || echo '$(srcdir)/'`src/zhashx.c src/src_libczmq_la-ziflist.lo: src/ziflist.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-ziflist.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-ziflist.Tpo -c -o src/src_libczmq_la-ziflist.lo `test -f 'src/ziflist.c' || echo '$(srcdir)/'`src/ziflist.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-ziflist.Tpo src/$(DEPDIR)/src_libczmq_la-ziflist.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/ziflist.c' object='src/src_libczmq_la-ziflist.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-ziflist.lo `test -f 'src/ziflist.c' || echo '$(srcdir)/'`src/ziflist.c src/src_libczmq_la-zlist.lo: src/zlist.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zlist.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zlist.Tpo -c -o src/src_libczmq_la-zlist.lo `test -f 'src/zlist.c' || echo '$(srcdir)/'`src/zlist.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zlist.Tpo src/$(DEPDIR)/src_libczmq_la-zlist.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zlist.c' object='src/src_libczmq_la-zlist.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zlist.lo `test -f 'src/zlist.c' || echo '$(srcdir)/'`src/zlist.c src/src_libczmq_la-zlistx.lo: src/zlistx.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zlistx.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zlistx.Tpo -c -o src/src_libczmq_la-zlistx.lo `test -f 'src/zlistx.c' || echo '$(srcdir)/'`src/zlistx.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zlistx.Tpo src/$(DEPDIR)/src_libczmq_la-zlistx.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zlistx.c' object='src/src_libczmq_la-zlistx.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zlistx.lo `test -f 'src/zlistx.c' || echo '$(srcdir)/'`src/zlistx.c src/src_libczmq_la-zloop.lo: src/zloop.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zloop.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zloop.Tpo -c -o src/src_libczmq_la-zloop.lo `test -f 'src/zloop.c' || echo '$(srcdir)/'`src/zloop.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zloop.Tpo src/$(DEPDIR)/src_libczmq_la-zloop.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zloop.c' object='src/src_libczmq_la-zloop.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zloop.lo `test -f 'src/zloop.c' || echo '$(srcdir)/'`src/zloop.c src/src_libczmq_la-zmsg.lo: src/zmsg.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zmsg.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zmsg.Tpo -c -o src/src_libczmq_la-zmsg.lo `test -f 'src/zmsg.c' || echo '$(srcdir)/'`src/zmsg.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zmsg.Tpo src/$(DEPDIR)/src_libczmq_la-zmsg.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zmsg.c' object='src/src_libczmq_la-zmsg.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zmsg.lo `test -f 'src/zmsg.c' || echo '$(srcdir)/'`src/zmsg.c src/src_libczmq_la-zpoller.lo: src/zpoller.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zpoller.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zpoller.Tpo -c -o src/src_libczmq_la-zpoller.lo `test -f 'src/zpoller.c' || echo '$(srcdir)/'`src/zpoller.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zpoller.Tpo src/$(DEPDIR)/src_libczmq_la-zpoller.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zpoller.c' object='src/src_libczmq_la-zpoller.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zpoller.lo `test -f 'src/zpoller.c' || echo '$(srcdir)/'`src/zpoller.c src/src_libczmq_la-zsock.lo: src/zsock.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zsock.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zsock.Tpo -c -o src/src_libczmq_la-zsock.lo `test -f 'src/zsock.c' || echo '$(srcdir)/'`src/zsock.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zsock.Tpo src/$(DEPDIR)/src_libczmq_la-zsock.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zsock.c' object='src/src_libczmq_la-zsock.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zsock.lo `test -f 'src/zsock.c' || echo '$(srcdir)/'`src/zsock.c src/src_libczmq_la-zstr.lo: src/zstr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zstr.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zstr.Tpo -c -o src/src_libczmq_la-zstr.lo `test -f 'src/zstr.c' || echo '$(srcdir)/'`src/zstr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zstr.Tpo src/$(DEPDIR)/src_libczmq_la-zstr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zstr.c' object='src/src_libczmq_la-zstr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zstr.lo `test -f 'src/zstr.c' || echo '$(srcdir)/'`src/zstr.c src/src_libczmq_la-zsys.lo: src/zsys.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zsys.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zsys.Tpo -c -o src/src_libczmq_la-zsys.lo `test -f 'src/zsys.c' || echo '$(srcdir)/'`src/zsys.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zsys.Tpo src/$(DEPDIR)/src_libczmq_la-zsys.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zsys.c' object='src/src_libczmq_la-zsys.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zsys.lo `test -f 'src/zsys.c' || echo '$(srcdir)/'`src/zsys.c src/src_libczmq_la-zuuid.lo: src/zuuid.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zuuid.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zuuid.Tpo -c -o src/src_libczmq_la-zuuid.lo `test -f 'src/zuuid.c' || echo '$(srcdir)/'`src/zuuid.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zuuid.Tpo src/$(DEPDIR)/src_libczmq_la-zuuid.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zuuid.c' object='src/src_libczmq_la-zuuid.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zuuid.lo `test -f 'src/zuuid.c' || echo '$(srcdir)/'`src/zuuid.c src/src_libczmq_la-zauth.lo: src/zauth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zauth.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zauth.Tpo -c -o src/src_libczmq_la-zauth.lo `test -f 'src/zauth.c' || echo '$(srcdir)/'`src/zauth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zauth.Tpo src/$(DEPDIR)/src_libczmq_la-zauth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zauth.c' object='src/src_libczmq_la-zauth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zauth.lo `test -f 'src/zauth.c' || echo '$(srcdir)/'`src/zauth.c src/src_libczmq_la-zbeacon.lo: src/zbeacon.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zbeacon.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zbeacon.Tpo -c -o src/src_libczmq_la-zbeacon.lo `test -f 'src/zbeacon.c' || echo '$(srcdir)/'`src/zbeacon.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zbeacon.Tpo src/$(DEPDIR)/src_libczmq_la-zbeacon.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zbeacon.c' object='src/src_libczmq_la-zbeacon.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zbeacon.lo `test -f 'src/zbeacon.c' || echo '$(srcdir)/'`src/zbeacon.c src/src_libczmq_la-zgossip.lo: src/zgossip.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zgossip.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zgossip.Tpo -c -o src/src_libczmq_la-zgossip.lo `test -f 'src/zgossip.c' || echo '$(srcdir)/'`src/zgossip.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zgossip.Tpo src/$(DEPDIR)/src_libczmq_la-zgossip.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zgossip.c' object='src/src_libczmq_la-zgossip.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zgossip.lo `test -f 'src/zgossip.c' || echo '$(srcdir)/'`src/zgossip.c src/src_libczmq_la-zmonitor.lo: src/zmonitor.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zmonitor.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zmonitor.Tpo -c -o src/src_libczmq_la-zmonitor.lo `test -f 'src/zmonitor.c' || echo '$(srcdir)/'`src/zmonitor.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zmonitor.Tpo src/$(DEPDIR)/src_libczmq_la-zmonitor.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zmonitor.c' object='src/src_libczmq_la-zmonitor.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zmonitor.lo `test -f 'src/zmonitor.c' || echo '$(srcdir)/'`src/zmonitor.c src/src_libczmq_la-zproxy.lo: src/zproxy.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zproxy.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zproxy.Tpo -c -o src/src_libczmq_la-zproxy.lo `test -f 'src/zproxy.c' || echo '$(srcdir)/'`src/zproxy.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zproxy.Tpo src/$(DEPDIR)/src_libczmq_la-zproxy.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zproxy.c' object='src/src_libczmq_la-zproxy.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zproxy.lo `test -f 'src/zproxy.c' || echo '$(srcdir)/'`src/zproxy.c src/src_libczmq_la-zrex.lo: src/zrex.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zrex.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zrex.Tpo -c -o src/src_libczmq_la-zrex.lo `test -f 'src/zrex.c' || echo '$(srcdir)/'`src/zrex.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zrex.Tpo src/$(DEPDIR)/src_libczmq_la-zrex.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zrex.c' object='src/src_libczmq_la-zrex.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zrex.lo `test -f 'src/zrex.c' || echo '$(srcdir)/'`src/zrex.c src/src_libczmq_la-zgossip_msg.lo: src/zgossip_msg.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zgossip_msg.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zgossip_msg.Tpo -c -o src/src_libczmq_la-zgossip_msg.lo `test -f 'src/zgossip_msg.c' || echo '$(srcdir)/'`src/zgossip_msg.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zgossip_msg.Tpo src/$(DEPDIR)/src_libczmq_la-zgossip_msg.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zgossip_msg.c' object='src/src_libczmq_la-zgossip_msg.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zgossip_msg.lo `test -f 'src/zgossip_msg.c' || echo '$(srcdir)/'`src/zgossip_msg.c src/src_libczmq_la-zargs.lo: src/zargs.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zargs.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zargs.Tpo -c -o src/src_libczmq_la-zargs.lo `test -f 'src/zargs.c' || echo '$(srcdir)/'`src/zargs.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zargs.Tpo src/$(DEPDIR)/src_libczmq_la-zargs.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zargs.c' object='src/src_libczmq_la-zargs.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zargs.lo `test -f 'src/zargs.c' || echo '$(srcdir)/'`src/zargs.c src/src_libczmq_la-zproc.lo: src/zproc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-zproc.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-zproc.Tpo -c -o src/src_libczmq_la-zproc.lo `test -f 'src/zproc.c' || echo '$(srcdir)/'`src/zproc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-zproc.Tpo src/$(DEPDIR)/src_libczmq_la-zproc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zproc.c' object='src/src_libczmq_la-zproc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-zproc.lo `test -f 'src/zproc.c' || echo '$(srcdir)/'`src/zproc.c src/src_libczmq_la-ztimerset.lo: src/ztimerset.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-ztimerset.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-ztimerset.Tpo -c -o src/src_libczmq_la-ztimerset.lo `test -f 'src/ztimerset.c' || echo '$(srcdir)/'`src/ztimerset.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-ztimerset.Tpo src/$(DEPDIR)/src_libczmq_la-ztimerset.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/ztimerset.c' object='src/src_libczmq_la-ztimerset.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-ztimerset.lo `test -f 'src/ztimerset.c' || echo '$(srcdir)/'`src/ztimerset.c src/src_libczmq_la-ztrie.lo: src/ztrie.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-ztrie.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-ztrie.Tpo -c -o src/src_libczmq_la-ztrie.lo `test -f 'src/ztrie.c' || echo '$(srcdir)/'`src/ztrie.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-ztrie.Tpo src/$(DEPDIR)/src_libczmq_la-ztrie.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/ztrie.c' object='src/src_libczmq_la-ztrie.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-ztrie.lo `test -f 'src/ztrie.c' || echo '$(srcdir)/'`src/ztrie.c src/src_libczmq_la-czmq_private_selftest.lo: src/czmq_private_selftest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_libczmq_la-czmq_private_selftest.lo -MD -MP -MF src/$(DEPDIR)/src_libczmq_la-czmq_private_selftest.Tpo -c -o src/src_libczmq_la-czmq_private_selftest.lo `test -f 'src/czmq_private_selftest.c' || echo '$(srcdir)/'`src/czmq_private_selftest.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_libczmq_la-czmq_private_selftest.Tpo src/$(DEPDIR)/src_libczmq_la-czmq_private_selftest.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/czmq_private_selftest.c' object='src/src_libczmq_la-czmq_private_selftest.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libczmq_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_libczmq_la-czmq_private_selftest.lo `test -f 'src/czmq_private_selftest.c' || echo '$(srcdir)/'`src/czmq_private_selftest.c src/src_czmq_selftest-czmq_selftest.o: src/czmq_selftest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_czmq_selftest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_czmq_selftest-czmq_selftest.o -MD -MP -MF src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Tpo -c -o src/src_czmq_selftest-czmq_selftest.o `test -f 'src/czmq_selftest.c' || echo '$(srcdir)/'`src/czmq_selftest.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Tpo src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/czmq_selftest.c' object='src/src_czmq_selftest-czmq_selftest.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_czmq_selftest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_czmq_selftest-czmq_selftest.o `test -f 'src/czmq_selftest.c' || echo '$(srcdir)/'`src/czmq_selftest.c src/src_czmq_selftest-czmq_selftest.obj: src/czmq_selftest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_czmq_selftest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_czmq_selftest-czmq_selftest.obj -MD -MP -MF src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Tpo -c -o src/src_czmq_selftest-czmq_selftest.obj `if test -f 'src/czmq_selftest.c'; then $(CYGPATH_W) 'src/czmq_selftest.c'; else $(CYGPATH_W) '$(srcdir)/src/czmq_selftest.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Tpo src/$(DEPDIR)/src_czmq_selftest-czmq_selftest.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/czmq_selftest.c' object='src/src_czmq_selftest-czmq_selftest.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_czmq_selftest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_czmq_selftest-czmq_selftest.obj `if test -f 'src/czmq_selftest.c'; then $(CYGPATH_W) 'src/czmq_selftest.c'; else $(CYGPATH_W) '$(srcdir)/src/czmq_selftest.c'; fi` src/src_test_randof-test_randof.o: src/test_randof.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_test_randof_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_test_randof-test_randof.o -MD -MP -MF src/$(DEPDIR)/src_test_randof-test_randof.Tpo -c -o src/src_test_randof-test_randof.o `test -f 'src/test_randof.c' || echo '$(srcdir)/'`src/test_randof.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_test_randof-test_randof.Tpo src/$(DEPDIR)/src_test_randof-test_randof.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/test_randof.c' object='src/src_test_randof-test_randof.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_test_randof_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_test_randof-test_randof.o `test -f 'src/test_randof.c' || echo '$(srcdir)/'`src/test_randof.c src/src_test_randof-test_randof.obj: src/test_randof.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_test_randof_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_test_randof-test_randof.obj -MD -MP -MF src/$(DEPDIR)/src_test_randof-test_randof.Tpo -c -o src/src_test_randof-test_randof.obj `if test -f 'src/test_randof.c'; then $(CYGPATH_W) 'src/test_randof.c'; else $(CYGPATH_W) '$(srcdir)/src/test_randof.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_test_randof-test_randof.Tpo src/$(DEPDIR)/src_test_randof-test_randof.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/test_randof.c' object='src/src_test_randof-test_randof.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_test_randof_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_test_randof-test_randof.obj `if test -f 'src/test_randof.c'; then $(CYGPATH_W) 'src/test_randof.c'; else $(CYGPATH_W) '$(srcdir)/src/test_randof.c'; fi` src/src_zmakecert-zmakecert.o: src/zmakecert.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_zmakecert_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_zmakecert-zmakecert.o -MD -MP -MF src/$(DEPDIR)/src_zmakecert-zmakecert.Tpo -c -o src/src_zmakecert-zmakecert.o `test -f 'src/zmakecert.c' || echo '$(srcdir)/'`src/zmakecert.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_zmakecert-zmakecert.Tpo src/$(DEPDIR)/src_zmakecert-zmakecert.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zmakecert.c' object='src/src_zmakecert-zmakecert.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_zmakecert_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_zmakecert-zmakecert.o `test -f 'src/zmakecert.c' || echo '$(srcdir)/'`src/zmakecert.c src/src_zmakecert-zmakecert.obj: src/zmakecert.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_zmakecert_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_zmakecert-zmakecert.obj -MD -MP -MF src/$(DEPDIR)/src_zmakecert-zmakecert.Tpo -c -o src/src_zmakecert-zmakecert.obj `if test -f 'src/zmakecert.c'; then $(CYGPATH_W) 'src/zmakecert.c'; else $(CYGPATH_W) '$(srcdir)/src/zmakecert.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_zmakecert-zmakecert.Tpo src/$(DEPDIR)/src_zmakecert-zmakecert.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zmakecert.c' object='src/src_zmakecert-zmakecert.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_zmakecert_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_zmakecert-zmakecert.obj `if test -f 'src/zmakecert.c'; then $(CYGPATH_W) 'src/zmakecert.c'; else $(CYGPATH_W) '$(srcdir)/src/zmakecert.c'; fi` src/src_zsp-zsp.o: src/zsp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_zsp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_zsp-zsp.o -MD -MP -MF src/$(DEPDIR)/src_zsp-zsp.Tpo -c -o src/src_zsp-zsp.o `test -f 'src/zsp.c' || echo '$(srcdir)/'`src/zsp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_zsp-zsp.Tpo src/$(DEPDIR)/src_zsp-zsp.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zsp.c' object='src/src_zsp-zsp.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_zsp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_zsp-zsp.o `test -f 'src/zsp.c' || echo '$(srcdir)/'`src/zsp.c src/src_zsp-zsp.obj: src/zsp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_zsp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/src_zsp-zsp.obj -MD -MP -MF src/$(DEPDIR)/src_zsp-zsp.Tpo -c -o src/src_zsp-zsp.obj `if test -f 'src/zsp.c'; then $(CYGPATH_W) 'src/zsp.c'; else $(CYGPATH_W) '$(srcdir)/src/zsp.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_zsp-zsp.Tpo src/$(DEPDIR)/src_zsp-zsp.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/zsp.c' object='src/src_zsp-zsp.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_zsp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/src_zsp-zsp.obj `if test -f 'src/zsp.c'; then $(CYGPATH_W) 'src/zsp.c'; else $(CYGPATH_W) '$(srcdir)/src/zsp.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf src/.libs src/_libs distclean-libtool: -rm -f libtool config.lt install-dist_apiDATA: $(dist_api_DATA) @$(NORMAL_INSTALL) @list='$(dist_api_DATA)'; test -n "$(apidir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(apidir)'"; \ $(MKDIR_P) "$(DESTDIR)$(apidir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(apidir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(apidir)" || exit $$?; \ done uninstall-dist_apiDATA: @$(NORMAL_UNINSTALL) @list='$(dist_api_DATA)'; test -n "$(apidir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(apidir)'; $(am__uninstall_files_from_dir) install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ done uninstall-pkgconfigDATA: @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ else \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local check: check-recursive all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) $(HEADERS) install-binPROGRAMS: install-libLTLIBRARIES installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(apidir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f src/$(DEPDIR)/$(am__dirstamp) -rm -f src/$(am__dirstamp) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ clean-libLTLIBRARIES clean-libtool clean-local \ clean-noinstLTLIBRARIES clean-noinstPROGRAMS mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf src/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dist_apiDATA install-includeHEADERS \ install-pkgconfigDATA install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-binPROGRAMS install-libLTLIBRARIES install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf src/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-dist_apiDATA \ uninstall-includeHEADERS uninstall-libLTLIBRARIES \ uninstall-pkgconfigDATA .MAKE: $(am__recursive_targets) check-am install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-TESTS check-am check-local clean \ clean-binPROGRAMS clean-checkPROGRAMS clean-cscope \ clean-generic clean-libLTLIBRARIES clean-libtool clean-local \ clean-noinstLTLIBRARIES clean-noinstPROGRAMS cscope \ cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ distcheck distclean distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags distcleancheck \ distdir distuninstallcheck dvi dvi-am html html-am info \ info-am install install-am install-binPROGRAMS install-data \ install-data-am install-dist_apiDATA install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-includeHEADERS install-info \ install-info-am install-libLTLIBRARIES install-man install-pdf \ install-pdf-am install-pkgconfigDATA install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \ uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-dist_apiDATA uninstall-includeHEADERS \ uninstall-libLTLIBRARIES uninstall-pkgconfigDATA # define custom target for all products of /src src: \ src/zmakecert \ src/zsp \ src/test_randof \ src/czmq_selftest \ src/libczmq.la # Produce generated code from models in the src directory code: cd $(srcdir)/src; gsl -topdir:.. -zproject:1 -q sockopts.xml cd $(srcdir)/src; gsl -topdir:.. -zproject:1 -q zgossip.xml cd $(srcdir)/src; gsl -topdir:.. -zproject:1 -private:1 -q zgossip_msg.xml cd $(srcdir); gsl -target:- project.xml # This is recreated on every invocation (as a selftest dependency), # so tests run in a clean environment $(top_builddir)/$(SELFTEST_DIR_RW): rm -rf "$@" mkdir -p "$@" # Note: for some reason "$<" misfired in rule below on Travis, so be explicit @USING_VPATH_TRUE@$(abs_top_builddir)/$(SELFTEST_DIR_RO): $(abs_top_srcdir)/$(SELFTEST_DIR_RO) @USING_VPATH_TRUE@ @echo " COPYDIR $(SELFTEST_DIR_RO)"; \ @USING_VPATH_TRUE@ rm -rf "$@"; \ @USING_VPATH_TRUE@ cp -r "$(abs_top_srcdir)/$(SELFTEST_DIR_RO)" "$@" @USING_VPATH_TRUE@$(top_builddir)/$(SELFTEST_DIR_RO): $(abs_top_builddir)/$(SELFTEST_DIR_RO) $(SELFTEST_DIR_RO): $(top_builddir)/$(SELFTEST_DIR_RO) clean-local: clean-local-selftest-ro clean-local-selftest-rw .PHONY: clean-local-selftest-ro clean-local-selftest-ro: @if test "$(top_builddir)" != "$(top_srcdir)" ; then \ if test -d "$(top_builddir)/$(SELFTEST_DIR_RO)" ; then \ chmod -R u+w "$(top_builddir)/$(SELFTEST_DIR_RO)" ; \ rm -rf "$(top_builddir)/$(SELFTEST_DIR_RO)" ; \ fi; \ fi # Unlike CLEANFILES setting above, this one whould also wipe created subdirs .PHONY: clean-local-selftest-rw clean-local-selftest-rw: @if test "$(top_builddir)" != "$(top_srcdir)" ; then \ if test -d "$(top_builddir)/$(SELFTEST_DIR_RW)" ; then \ chmod -R u+w "$(top_builddir)/$(SELFTEST_DIR_RW)" ; \ rm -rf "$(top_builddir)/$(SELFTEST_DIR_RW)" ; \ fi; \ fi check-empty-selftest-rw: if test -e $(top_builddir)/$(SELFTEST_DIR_RW) ; then \ if test `find "$(top_builddir)/$(SELFTEST_DIR_RW)" | wc -l` -lt 1 ; then \ echo "FATAL: selftest did not tidy up the data it wrote" >&2 ; \ find "$(top_builddir)/$(SELFTEST_DIR_RW)" ; \ exit 2; \ else true ; fi; \ else true ; fi check-local: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute $(builddir)/src/czmq_selftest $(MAKE) check-empty-selftest-rw check-verbose: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute $(builddir)/src/czmq_selftest -v $(MAKE) check-empty-selftest-rw # Run the selftest binary under valgrind to check for memory leaks memcheck: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute valgrind --tool=memcheck \ --leak-check=full --show-reachable=yes --error-exitcode=1 \ --suppressions=$(srcdir)/src/.valgrind.supp \ $(VALGRIND_OPTIONS) \ $(builddir)/src/czmq_selftest $(MAKE) check-empty-selftest-rw memcheck-verbose: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute valgrind --tool=memcheck \ --leak-check=full --show-reachable=yes --error-exitcode=1 \ --suppressions=$(srcdir)/src/.valgrind.supp \ $(VALGRIND_OPTIONS) \ $(builddir)/src/czmq_selftest -v $(MAKE) check-empty-selftest-rw # Run the selftest binary under valgrind to check for performance leaks callcheck: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute valgrind --tool=callgrind \ $(VALGRIND_OPTIONS) \ $(builddir)/src/czmq_selftest $(MAKE) check-empty-selftest-rw callcheck-verbose: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute valgrind --tool=callgrind \ $(VALGRIND_OPTIONS) \ $(builddir)/src/czmq_selftest -v $(MAKE) check-empty-selftest-rw # Run the selftest binary under gdb for debugging debug: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute gdb -q \ $(builddir)/src/czmq_selftest $(MAKE) check-empty-selftest-rw debug-verbose: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute gdb -q \ $(builddir)/src/czmq_selftest -v $(MAKE) check-empty-selftest-rw # Run the selftest binary with verbose switch for tracing animate: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute $(builddir)/src/czmq_selftest -v $(MAKE) check-empty-selftest-rw animate-verbose: animate @WITH_GCOV_TRUE@coverage: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) @WITH_GCOV_TRUE@ @echo "you had called configure --with-gcov" @WITH_GCOV_TRUE@ lcov --base-directory . --directory . --zerocounters -q @WITH_GCOV_TRUE@ $(MAKE) check @WITH_GCOV_TRUE@ lcov --base-directory . --directory . --capture -o coverage.info @WITH_GCOV_TRUE@ lcov --remove coverage.info "/usr*" -o coverage.info @WITH_GCOV_TRUE@ lcov --remove coverage.info "czmq_selftest.c" -o coverage.info @WITH_GCOV_TRUE@ $(RM) -rf coverage/* @WITH_GCOV_TRUE@ genhtml -o coverage/ -t "czmq test coverage" --num-spaces 4 coverage.info @WITH_GCOV_FALSE@coverage: src/czmq_selftest @WITH_GCOV_FALSE@ @echo "call make clean && configure --with-gcov to enable code coverage" @WITH_GCOV_FALSE@ @exit 1 ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ check-py: src/libczmq.la $(LIBTOOL) --mode=execute -dlopen src/libczmq.la python bindings/python/test.py # NOTE: this "include" syntax is not a "make" but an "autotools" keyword, # see https://www.gnu.org/software/automake/manual/html_node/Include.html ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: czmq-4.1.0/README.txt0000664000372000037200000004774013222211156015075 0ustar00travistravis00000000000000.set GIT=https://github.com/zeromq/czmq .sub 0MQ=ØMQ [![GitHub release](https://img.shields.io/github/release/zeromq/czmq.svg)](https://github.com/zeromq/czmq/releases) [![OBS draft](https://img.shields.io/badge/OBS%20master-draft-yellow.svg)](http://software.opensuse.org/download.html?project=network%3Amessaging%3Azeromq%3Agit-draft&package=czmq) [![OBS stable](https://img.shields.io/badge/OBS%20master-stable-yellow.svg)](http://software.opensuse.org/download.html?project=network%3Amessaging%3Azeromq%3Agit-stable&package=czmq) [![license](https://img.shields.io/github/license/zeromq/czmq.svg)](https://github.com/zeromq/czmq/blob/master/LICENSE) # CZMQ - High-level C binding for 0MQ | Linux & MacOSX | Windows | |:--------------:|:--------:| |[![Build Status](https://travis-ci.org/zeromq/czmq.png?branch=master)](https://travis-ci.org/zeromq/czmq)|[![Build status](https://ci.appveyor.com/api/projects/status/q7y22juu3pnl5wq6?svg=true)](https://ci.appveyor.com/project/zeromq/czmq)| ## Contents .toc 3 ## Overview ### Scope and Goals CZMQ has these goals: * To wrap the 0MQ core API in semantics that lead to shorter, more readable applications. * To hide as far as possible the differences between different versions of 0MQ (2.x, 3.x, 4.x). * To provide a space for development of more sophisticated API semantics. * To wrap the 0MQ security features with high-level tools and APIs. * To become the basis for other language bindings built on top of CZMQ. CZMQ grew out of concepts developed in [ØMQ - The Guide](http://zguide.zeromq.org). [diagram] +---------------+ | | | C application | | | +-----+---+-----+ | | | | +------------+ | | | v | Open context +---------+ | Create sockets | | | Connect, bind sockets Close sockets | CZMQ | | get/set socket options Send/receive | cYEL | | Multithreading +----+----+ | Reactor pattern | | Hash container +------------+ | List container | | System clock v v Close context +---------+ | | | libzmq | | | +---------+ [/diagram] ### Ownership and License The contributors are listed in AUTHORS. This project uses the MPL v2 license, see LICENSE. CZMQ uses the [C4.1 (Collective Code Construction Contract)](http://rfc.zeromq.org/spec:22) process for contributions. CZMQ uses the [CLASS (C Language Style for Scalabilty)](http://rfc.zeromq.org/spec:21) guide for code style. To report an issue, use the [CZMQ issue tracker](https://github.com/zeromq/czmq/issues) at github.com. ## Using CZMQ ### Building and Installing To start with, you need at least these packages: * {{git-all}} -- git is how we share code with other people. * {{build-essential}}, {{libtool}}, {{pkg-config}} - the C compiler and related tools. * {{autotools-dev}}, {{autoconf}}, {{automake}} - the GNU autoconf makefile generators. * {{cmake}} - the CMake makefile generators (an alternative to autoconf). Plus some others: * {{uuid-dev}}, {{libpcre3-dev}} - utility libraries. * {{valgrind}} - a useful tool for checking your code. * {{pkg-config}} - an optional useful tool to make building with dependencies easier. Which we install like this (using the Debian-style apt-get package manager): sudo apt-get update sudo apt-get install -y \ git-all build-essential libtool \ pkg-config autotools-dev autoconf automake cmake \ uuid-dev libpcre3-dev valgrind # only execute this next line if interested in updating the man pages as well (adds to build time): sudo apt-get install -y asciidoc Here's how to build CZMQ from GitHub (building from packages is very similar, you don't clone a repo but unpack a tarball), including the libzmq (ZeroMQ core) library (NOTE: skip ldconfig on OSX): git clone git://github.com/zeromq/libzmq.git cd libzmq ./autogen.sh # do not specify "--with-libsodium" if you prefer to use internal tweetnacl security implementation (recommended for development) ./configure --with-libsodium make check sudo make install sudo ldconfig cd .. git clone git://github.com/zeromq/czmq.git cd czmq ./autogen.sh && ./configure && make check sudo make install sudo ldconfig cd .. In general CZMQ works best with the latest libzmq master. If you already have an older version of libzmq installed on your system, e.g. in /usr/, then you can install libzmq master to your home directory ($HOME/local): # Building libzmq in our home directory ./configure --prefix=$HOME/local And then to build CZMQ against this installation of libzmq: export CFLAGS=-I$HOME/local/include export LDFLAGS=-L$HOME/local/lib64 export PKG_CONFIG_PATH=$HOME/local/lib64/pkgconfig ./configure NOTE: the PKG_CONFIG_PATH is not mandatory, and the actual directory might be different. If you cannot or do not want to use pkg-config, please make sure to MANUALLY add all the necessary CFLAGS and LDFLAGS from all dependencies (for example -DZMQ_BUILD_DRAFT_API=1 if you want the DRAFT APIs). You will need the pkg-config, libtool, and autoreconf packages. After building, run the CZMQ selftests: make check ### Building on Windows To start with, you need MS Visual Studio (C/C++). The free community edition works well. Then, install git, and make sure it works from a DevStudio command prompt: ``` git ``` Now let's build CZMQ from GitHub: ``` git clone --depth 1 -b stable https://github.com/jedisct1/libsodium.git cd libsodium\builds\msvc\build buildall.bat cd ..\..\..\.. :: if libsodium is on disk, the Windows build of libzmq will automatically use it git clone git://github.com/zeromq/libzmq.git cd libzmq\builds\msvc configure.bat cd build buildall.bat cd ..\..\..\.. git clone git://github.com/zeromq/czmq.git cd czmq\builds\msvc configure.bat cd build buildall.bat cd ..\..\..\.. ``` Let's test by running `czmq_selftest`: ``` czmq>dir/s/b czmq_selftest.exe czmq\builds\msvc\vs2013\DebugDEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\DebugLEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\DebugSEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\ReleaseDEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\ReleaseLEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\ReleaseSEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\x64\DebugDEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\x64\DebugLEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\x64\DebugSEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\x64\ReleaseDEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\x64\ReleaseLEXE\czmq_selftest.exe czmq\builds\msvc\vs2013\x64\ReleaseSEXE\czmq_selftest.exe :: select your choice and run it czmq\builds\msvc\vs2013\x64\ReleaseDEXE\czmq_selftest.exe ``` ### Linking with an Application Include `czmq.h` in your application and link with libczmq. Here is a typical gcc link command: gcc myapp.c -o myapp -lczmq -lzmq ### Use from Other Languages This is a list of auto-generated bindings: * https://github.com/zeromq/czmq/tree/master/bindings/jni - Java * https://github.com/zeromq/czmq/tree/master/bindings/nodejs - NodeJS * https://github.com/zeromq/czmq/tree/master/bindings/python - Python * https://github.com/zeromq/czmq/tree/master/bindings/python_cffi - Python (cffi) * https://github.com/zeromq/czmq/tree/master/bindings/qml - QML * https://github.com/zeromq/czmq/tree/master/bindings/qt - Qt * https://github.com/zeromq/czmq/tree/master/bindings/ruby - Ruby (FFI) This is a list of known higher-level wrappers around CZMQ: * https://github.com/1100110/CZMQ - D bindings * https://github.com/methodmissing/rbczmq - Ruby * https://github.com/paddor/cztop - Ruby, based on generated FFI binding * https://github.com/zeromq/pyczmq - Python * https://github.com/lhope/cl-czmq - Common Lisp * https://github.com/fmp88/ocaml-czmq - Ocaml * https://github.com/gar1t/erlang-czmq - Erlang * https://github.com/mtortonesi/ruby-czmq-ffi - Ruby FFI * https://github.com/zeromq/goczmq - Go ### API v3 Summary This is the API provided by CZMQ v3.x, in alphabetical order. .pull doc/zactor.doc .pull doc/zauth.doc .pull doc/zbeacon.doc .pull doc/zcert.doc .pull doc/zcertstore.doc .pull doc/zchunk.doc .pull doc/zclock.doc .pull doc/zconfig.doc .pull doc/zdigest.doc .pull doc/zdir.doc .pull doc/zdir_patch.doc .pull doc/zfile.doc .pull doc/zframe.doc .pull doc/zgossip.doc .pull doc/zhash.doc .pull doc/zhashx.doc .pull doc/ziflist.doc .pull doc/zlist.doc .pull doc/zlistx.doc .pull doc/zloop.doc .pull doc/zmonitor.doc .pull doc/zmsg.doc .pull doc/zpoller.doc .pull doc/zproc.doc .pull doc/zproxy.doc .pull doc/zrex.doc .pull doc/zsock.doc .pull doc/zstr.doc .pull doc/zsys.doc .pull doc/ztimerset.doc .pull doc/ztrie.doc .pull doc/zuuid.doc ## Error Handling The CZMQ policy is to reduce the error flow to 0/-1 where possible. libzmq still does a lot of errno setting. CZMQ does not do that, as it creates a fuzzy API. Things either work as expected, or they fail, and the application's best strategy is usually to assert on non-zero return codes. Some older libraries still return plethora of error codes, to indicate different types of failure. This ironically makes both library and application more likely to be buggy. The reason is simply that it needs more code on both sides of the API, and the more code, the more bugs. The use of black/white error handling fits the CLASS style for APIs where each call is explicit and without side effects of any kind, and where damage is either impossible, or fatal. The one exception is running out of resources (memory, sockets). In that case, there are two strategies that work, for different types of app. One is to assert, to force better sizing of the machine and/or limits such as max connections. Two is to degrade carefully, e.g. refuse new connections, however that is considerably harder to do correctly and probably unrealistic for most developers. Some CZMQ methods used to actually assert, e.g. in zsocket_bind, if the action failed, instead of returning -1. That was just closer to the majority case where the action MUST work, or nothing can continue. However there's a small slice of cases where failure means something positive, and for these cases, such calls return -1 on failure. 99% of calling code simply asserts the return value is not -1. There are a few cases where the return value is overloaded to return -1, 0, or other values. These are somewhat confusing special cases and we aim to eliminate them over time. The overall goal with this strategy is robustness, and absolute minimal and predictable expression in the code. You can see that it works: the CZMQ code is generally very simple and clear, with a few exceptions of places where people have used their old C style (we fix these over time). ## CZMQ Actors The v2 API had a zthread class that let you create "attached threads" connected to their parent by an inproc:// PIPE socket. In v3 this has been simplified and better wrapped as the zactor class. CZMQ actors are in effect threads with a socket interface. A zactor_t instance works like a socket, and the CZMQ classes that deal with sockets (like zmsg and zpoller) all accept zactor_t references as well as zsock_t and libzmq void * socket handles. To write an actor, use this template. Note that your actor is a single function "void myname (zsock_t *pipe, void *args)" function: /* ========================================================================= someclass - some description Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Please take e.g. include/zmonitor.h as basis for your public API. And delete this text, and write your own, when you create an actor :-) @discuss @end */ #include "../include/czmq.h" // -------------------------------------------------------------------------- // The self_t structure holds the state for one actor instance typedef struct { zsock_t *pipe; // Actor command pipe zpoller_t *poller; // Socket poller // ... you'll be adding other stuff here bool terminated; // Did caller ask us to quit? bool verbose; // Verbose logging enabled? } self_t; static self_t * s_self_new (zsock_t *pipe) { self_t *self = (self_t *) zmalloc (sizeof (self_t)); self->pipe = pipe; // ... initialize your own state including any other // sockets, which you can add to the poller: self->poller = zpoller_new (self->pipe, NULL); return self; } static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; zpoller_destroy (&self->poller); // ... destroy your own state here free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Handle a command from calling application static int s_self_handle_pipe (self_t *self) { // Get the whole message off the pipe in one go zmsg_t *request = zmsg_recv (self->pipe); if (!request) return -1; // Interrupted char *command = zmsg_popstr (request); if (self->verbose) zsys_info ("zxxx: API command=%s", command); if (streq (command, "VERBOSE")) self->verbose = true; else // An example of a command that the caller would wait for // via a signal, so that the two threads synchronize if (streq (command, "WAIT")) zsock_signal (self->pipe, 0); else if (streq (command, "$TERM")) self->terminated = true; else { zsys_error ("zxxx: - invalid command: %s", command); assert (false); } zstr_free (&command); zmsg_destroy (&request); return 0; } // -------------------------------------------------------------------------- // zxxx() implements the zxxx actor interface void zxxx (zsock_t *pipe, void *args) { self_t *self = s_self_new (pipe); // Signal successful initialization zsock_signal (pipe, 0); while (!self->terminated) { zsock_t *which = (zsock_t *) zpoller_wait (self->poller, -1); if (which == self->pipe) s_self_handle_pipe (self); else if (zpoller_terminated (self->poller)) break; // Interrupted } s_self_destroy (&self); } // -------------------------------------------------------------------------- // Selftest void zxxx_test (bool verbose) { printf (" * zxxx: "); if (verbose) printf ("\n"); // @selftest zactor_t *xxx = zactor_new (zxxx, NULL); assert (xxx); if (verbose) zstr_sendx (xxx, "VERBOSE", NULL); zactor_destroy (&xxx); // @end printf ("OK\n"); } The selftest code shows how to create, talk to, and destroy an actor. ## Under the Hood ### Adding a New Class If you define a new CZMQ class `myclass` you need to: * Write the `zmyclass.c` and `zmyclass.h` source files, in `src` and `include` respectively. * Add`#include ` to `include/czmq.h`. * Add the myclass header and test call to `src/czmq_selftest.c`. * Add a reference documentation to 'doc/zmyclass.txt'. * Add myclass to 'model/projects.xml` and read model/README.txt. * Add a section to README.txt. ### Documentation Man pages are generated from the class header and source files via the doc/mkman tool, and similar functionality in the gitdown tool (http://github.com/imatix/gitdown). The header file for a class must wrap its interface as follows (example is from include/zclock.h): // @interface // Sleep for a number of milliseconds void zclock_sleep (int msecs); // Return current system clock as milliseconds int64_t zclock_time (void); // Self test of this class int zclock_test (Bool verbose); // @end The source file for a class must provide documentation as follows: /* @header ...short explanation of class... @discuss ...longer discussion of how it works... @end */ The source file for a class then provides the self test example as follows: // @selftest int64_t start = zclock_time (); zclock_sleep (10); assert ((zclock_time () - start) >= 10); // @end The template for man pages is in doc/mkman. ### Development CZMQ is developed through a test-driven process that guarantees no memory violations or leaks in the code: * Modify a class or method. * Update the test method for that class. * Run the 'selftest' script, which uses the Valgrind memcheck tool. * Repeat until perfect. ### Porting CZMQ When you try CZMQ on an OS that it's not been used on (ever, or for a while), you will hit code that does not compile. In some cases the patches are trivial, in other cases (usually when porting to Windows), the work needed to build equivalent functionality may be non-trivial. In any case, the benefit is that once ported, the functionality is available to all applications. Before attempting to patch code for portability, please read the `czmq_prelude.h` header file. There are several typical types of changes you may need to make to get functionality working on a specific operating system: * Defining typedefs which are missing on that specific compiler: do this in czmq_prelude.h. * Defining macros that rename exotic library functions to more conventional names: do this in czmq_prelude.h. * Reimplementing specific methods to use a non-standard API: this is typically needed on Windows. Do this in the relevant class, using #ifdefs to properly differentiate code for different platforms. ### Hints to Contributors CZMQ is a nice, neat library, and you may not immediately appreciate why. Read the CLASS style guide please, and write your code to make it indistinguishable from the rest of the code in the library. That is the only real criteria for good style: it's invisible. Don't include system headers in source files. The right place for these is czmq_prelude.h. If you need to check against configured libraries and/or headers, include platform.h in the source before including czmq.h. Do read your code after you write it and ask, "Can I make this simpler?" We do use a nice minimalist and yet readable style. Learn it, adopt it, use it. Before opening a pull request read our [contribution guidelines](https://github.com/zeromq/czmq/blob/master/CONTRIBUTING.md). Thanks! ### Code Generation We generate the zsockopt class using [GSL](https://github.com/imatix/gsl), using a code generator script in scripts/sockopts.gsl. We also generate the project files. ### This Document This document is originally at README.txt and is built using [gitdown](http://github.com/imatix/gitdown). czmq-4.1.0/bindings/0000775000372000037200000000000013222211156015160 5ustar00travistravis00000000000000czmq-4.1.0/bindings/nodejs/0000775000372000037200000000000013222211156016442 5ustar00travistravis00000000000000czmq-4.1.0/bindings/nodejs/README.md0000664000372000037200000026156113222211156017734 0ustar00travistravis00000000000000# Node.js Binding for CZMQ This is a development kit. Note: this README is generated automatically by zproject from project.xml. Please DO NOT modify by hand except for test purposes. ## Prerequisites ### Node.js * You need Python (v2.7 recommended, v3.x not supported) * You need (I recommend) nvm and Node.js. * If your Linux has an existing 'node' command, `sudo apt-get remove node`. * In every terminal, or .bashrc: `nvm use v5.5.0` To install the necessary Node tools: ``` sudo apt-get update sudo apt-get install build-essential libssl-dev curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash # close terminal, re-open nvm ls-remote nvm install v5.5.0 npm install -g nan npm install -g node-ninja npm install -g prebuild npm install -g bindings ``` To build: ``` mkdir -p $HOME/temp cd $HOME/temp git clone https://github.com/zeromq/czmq cd czmq/bindings/nodejs # Clones dependencies, builds everything ./build.sh ``` ## API This is a wrapping of the native C libczmq library. See binding.cc for the code. ### The Zargs class - Platform independent command line argument parsing helpers There are two kind of elements provided by this class foo --named-parameter --parameter with_value positional arguments -a gain-parameter zargs keeps poision only for arguments, parameters are to be accessed like hash. It DOES: * provide easy to use CLASS compatible API for accessing argv * is platform independent * provide getopt_long style -- argument, which delimits parameters from arguments * makes parameters positon independent It does NOT * change argv * provide a "declarative" way to define command line interface In future it SHALL * hide several formats of command line to one (-Idir, --include=dir, --include dir are the same from API pov) Constructor: ``` var czmq = require ('bindings')('czmq') var my_zargs = new czmq.Zargs (Number, String) ``` You *must* call the destructor on every Zargs instance: ``` my_zargs.destroy () ``` Methods: ``` string my_zargs.progname () ``` Return program name (argv[0]) ``` size my_zargs.arguments () ``` Return number of positional arguments ``` string my_zargs.first () ``` Return first positional argument or NULL ``` string my_zargs.next () ``` Return next positional argument or NULL ``` string my_zargs.paramFirst () ``` Return first named parameter value, or NULL if there are no named parameters, or value for which zargs_param_empty (arg) returns true. ``` string my_zargs.paramNext () ``` Return next named parameter value, or NULL if there are no named parameters, or value for which zargs_param_empty (arg) returns true. ``` string my_zargs.paramName () ``` Return current parameter name, or NULL if there are no named parameters. ``` string my_zargs.paramLookup (String) ``` Return value of named parameter, NULL if no given parameter has been specified, or special value for wich zargs_param_empty () returns true. ``` string my_zargs.paramLookupx (String) ``` Return value of named parameter(s), NULL if no given parameter has been specified, or special value for wich zargs_param_empty () returns true. ``` boolean my_zargs.hasHelp () ``` Returns true if there are --help -h arguments ``` boolean my_zargs.paramEmpty (String) ``` Returns true if parameter did not have a value ``` nothing my_zargs.print () ``` Print an instance of zargs. ``` nothing my_zargs.test (Boolean) ``` Self test of this class. ### The Zarmour class - armoured text encoding and decoding Constructor: ``` var czmq = require ('bindings')('czmq') var my_zarmour = new czmq.Zarmour () ``` You *must* call the destructor on every Zarmour instance: ``` my_zarmour.destroy () ``` Methods: ``` string my_zarmour.encode (String) ``` Encode a stream of bytes into an armoured string. Returns the armoured string, or NULL if there was insufficient memory available to allocate a new string. ``` zchunk my_zarmour.decode (String) ``` Decode an armoured string into a chunk. The decoded output is null-terminated, so it may be treated as a string, if that's what it was prior to encoding. ``` integer my_zarmour.mode () ``` Get the mode property. ``` string my_zarmour.modeStr () ``` Get printable string for mode. ``` nothing my_zarmour.setMode (Number) ``` Set the mode property. ``` boolean my_zarmour.pad () ``` Return true if padding is turned on. ``` nothing my_zarmour.setPad (Boolean) ``` Turn padding on or off. Default is on. ``` char my_zarmour.padChar () ``` Get the padding character. ``` nothing my_zarmour.setPadChar (String) ``` Set the padding character. ``` boolean my_zarmour.lineBreaks () ``` Return if splitting output into lines is turned on. Default is off. ``` nothing my_zarmour.setLineBreaks (Boolean) ``` Turn splitting output into lines on or off. ``` size my_zarmour.lineLength () ``` Get the line length used for splitting lines. ``` nothing my_zarmour.setLineLength () ``` Set the line length used for splitting lines. ``` nothing my_zarmour.print () ``` Print properties of object ``` nothing my_zarmour.test (Boolean) ``` Self test of this class. ### The Zcert class - work with CURVE security certificates Constructor: ``` var czmq = require ('bindings')('czmq') var my_zcert = new czmq.Zcert () ``` You *must* call the destructor on every Zcert instance: ``` my_zcert.destroy () ``` Methods: ``` buffer my_zcert.publicKey () ``` Return public part of key pair as 32-byte binary string ``` buffer my_zcert.secretKey () ``` Return secret part of key pair as 32-byte binary string ``` string my_zcert.publicTxt () ``` Return public part of key pair as Z85 armored string ``` string my_zcert.secretTxt () ``` Return secret part of key pair as Z85 armored string ``` nothing my_zcert.setMeta (String, String) ``` Set certificate metadata from formatted string. ``` nothing my_zcert.unsetMeta (String) ``` Unset certificate metadata. ``` string my_zcert.meta (String) ``` Get metadata value from certificate; if the metadata value doesn't exist, returns NULL. ``` zlist my_zcert.metaKeys () ``` Get list of metadata fields from certificate. Caller is responsible for destroying list. Caller should not modify the values of list items. ``` integer my_zcert.save (String) ``` Save full certificate (public + secret) to file for persistent storage This creates one public file and one secret file (filename + "_secret"). ``` integer my_zcert.savePublic (String) ``` Save public certificate only to file for persistent storage ``` integer my_zcert.saveSecret (String) ``` Save secret certificate only to file for persistent storage ``` nothing my_zcert.apply (Zsock) ``` Apply certificate to socket, i.e. use for CURVE security on socket. If certificate was loaded from public file, the secret key will be undefined, and this certificate will not work successfully. ``` zcert my_zcert.dup () ``` Return copy of certificate; if certificate is NULL or we exhausted heap memory, returns NULL. ``` boolean my_zcert.eq (Zcert) ``` Return true if two certificates have the same keys ``` nothing my_zcert.print () ``` Print certificate contents to stdout ``` nothing my_zcert.test (Boolean) ``` Self test of this class ### The Zcertstore class - work with CURVE security certificate stores Constructor: ``` var czmq = require ('bindings')('czmq') var my_zcertstore = new czmq.Zcertstore (String) ``` You *must* call the destructor on every Zcertstore instance: ``` my_zcertstore.destroy () ``` Methods: ``` zcert my_zcertstore.lookup (String) ``` Look up certificate by public key, returns zcert_t object if found, else returns NULL. The public key is provided in Z85 text format. ``` nothing my_zcertstore.insert (Zcert) ``` Insert certificate into certificate store in memory. Note that this does not save the certificate to disk. To do that, use zcert_save() directly on the certificate. Takes ownership of zcert_t object. ``` nothing my_zcertstore.empty () ``` Empty certificate hashtable. This wrapper exists to be friendly to bindings, which don't usually have access to struct internals. ``` nothing my_zcertstore.print () ``` Print list of certificates in store to logging facility ``` zlistx my_zcertstore.certs () ``` Return a list of all the certificates in the store. The caller takes ownership of the zlistx_t object and is responsible for destroying it. The caller does not take ownership of the zcert_t objects. ``` nothing my_zcertstore.test (Boolean) ``` Self test of this class ### The Zchunk class - work with memory chunks Constructor: ``` var czmq = require ('bindings')('czmq') var my_zchunk = new czmq.Zchunk (String) ``` You *must* call the destructor on every Zchunk instance: ``` my_zchunk.destroy () ``` Methods: ``` nothing my_zchunk.resize () ``` Resizes chunk max_size as requested; chunk_cur size is set to zero ``` size my_zchunk.size () ``` Return chunk cur size ``` size my_zchunk.maxSize () ``` Return chunk max size ``` buffer my_zchunk.data () ``` Return chunk data ``` size my_zchunk.set (String) ``` Set chunk data from user-supplied data; truncate if too large. Data may be null. Returns actual size of chunk ``` size my_zchunk.append (String) ``` Append user-supplied data to chunk, return resulting chunk size. If the data would exceeded the available space, it is truncated. If you want to grow the chunk to accommodate new data, use the zchunk_extend method. ``` size my_zchunk.extend (String) ``` Append user-supplied data to chunk, return resulting chunk size. If the data would exceeded the available space, the chunk grows in size. ``` size my_zchunk.consume (Zchunk) ``` Copy as much data from 'source' into the chunk as possible; returns the new size of chunk. If all data from 'source' is used, returns exhausted on the source chunk. Source can be consumed as many times as needed until it is exhausted. If source was already exhausted, does not change chunk. ``` boolean my_zchunk.exhausted () ``` Returns true if the chunk was exhausted by consume methods, or if the chunk has a size of zero. ``` zchunk my_zchunk.slurp (String) ``` Try to slurp an entire file into a chunk. Will read up to maxsize of the file. If maxsize is 0, will attempt to read the entire file and fail with an assertion if that cannot fit into memory. Returns a new chunk containing the file data, or NULL if the file could not be read. ``` zchunk my_zchunk.dup () ``` Create copy of chunk, as new chunk object. Returns a fresh zchunk_t object, or null if there was not enough heap memory. If chunk is null, returns null. ``` string my_zchunk.strhex () ``` Return chunk data encoded as printable hex string. Caller must free string when finished with it. ``` string my_zchunk.strdup () ``` Return chunk data copied into freshly allocated string Caller must free string when finished with it. ``` boolean my_zchunk.streq (String) ``` Return TRUE if chunk body is equal to string, excluding terminator ``` zframe my_zchunk.pack () ``` Transform zchunk into a zframe that can be sent in a message. ``` zchunk my_zchunk.unpack (Zframe) ``` Transform a zframe into a zchunk. ``` string my_zchunk.digest () ``` Calculate SHA1 digest for chunk, using zdigest class. ``` nothing my_zchunk.print () ``` Dump message to stderr, for debugging and tracing. See zchunk_fprint for details ``` nothing my_zchunk.test (Boolean) ``` Self test of this class. ### The Zclock class - millisecond clocks and delays Constructor: ``` var czmq = require ('bindings')('czmq') var my_zclock = new czmq.Zclock () ``` Methods: ``` nothing my_zclock.sleep (Number) ``` Sleep for a number of milliseconds ``` msecs my_zclock.time () ``` Return current system clock as milliseconds. Note that this clock can jump backwards (if the system clock is changed) so is unsafe to use for timers and time offsets. Use zclock_mono for that instead. ``` msecs my_zclock.mono () ``` Return current monotonic clock in milliseconds. Use this when you compute time offsets. The monotonic clock is not affected by system changes and so will never be reset backwards, unlike a system clock. ``` msecs my_zclock.usecs () ``` Return current monotonic clock in microseconds. Use this when you compute time offsets. The monotonic clock is not affected by system changes and so will never be reset backwards, unlike a system clock. ``` string my_zclock.timestr () ``` Return formatted date/time as fresh string. Free using zstr_free(). ``` nothing my_zclock.test (Boolean) ``` Self test of this class. ### The Zconfig class - work with config files written in rfc.zeromq.org/spec:4/ZPL. Constructor: ``` var czmq = require ('bindings')('czmq') var my_zconfig = new czmq.Zconfig (String, Zconfig) ``` You *must* call the destructor on every Zconfig instance: ``` my_zconfig.destroy () ``` Methods: ``` string my_zconfig.name () ``` Return name of config item ``` string my_zconfig.value () ``` Return value of config item ``` nothing my_zconfig.put (String, String) ``` Insert or update configuration key with value ``` nothing my_zconfig.putf (String, String) ``` Equivalent to zconfig_put, accepting a format specifier and variable argument list, instead of a single string value. ``` string my_zconfig.get (String, String) ``` Get value for config item into a string value; leading slash is optional and ignored. ``` nothing my_zconfig.setName (String) ``` Set config item name, name may be NULL ``` nothing my_zconfig.setValue (String) ``` Set new value for config item. The new value may be a string, a printf format, or NULL. Note that if string may possibly contain '%', or if it comes from an insecure source, you must use '%s' as the format, followed by the string. ``` zconfig my_zconfig.child () ``` Find our first child, if any ``` zconfig my_zconfig.next () ``` Find our first sibling, if any ``` zconfig my_zconfig.locate (String) ``` Find a config item along a path; leading slash is optional and ignored. ``` zconfig my_zconfig.atDepth (Number) ``` Locate the last config item at a specified depth ``` nothing my_zconfig.setComment (String) ``` Add comment to config item before saving to disk. You can add as many comment lines as you like. If you use a null format, all comments are deleted. ``` zlist my_zconfig.comments () ``` Return comments of config item, as zlist. ``` integer my_zconfig.save (String) ``` Save a config tree to a specified ZPL text file, where a filename "-" means dump to standard output. ``` integer my_zconfig.savef (String) ``` Equivalent to zconfig_save, taking a format string instead of a fixed filename. ``` string my_zconfig.filename () ``` Report filename used during zconfig_load, or NULL if none ``` integer my_zconfig.reload (Zconfig) ``` Reload config tree from same file that it was previously loaded from. Returns 0 if OK, -1 if there was an error (and then does not change existing data). ``` zconfig my_zconfig.chunkLoad (Zchunk) ``` Load a config tree from a memory chunk ``` zchunk my_zconfig.chunkSave () ``` Save a config tree to a new memory chunk ``` zconfig my_zconfig.strLoad (String) ``` Load a config tree from a null-terminated string ``` string my_zconfig.strSave () ``` Save a config tree to a new null terminated string ``` boolean my_zconfig.hasChanged () ``` Return true if a configuration tree was loaded from a file and that file has changed in since the tree was loaded. ``` nothing my_zconfig.removeSubtree () ``` Destroy subtree (all children) ``` nothing my_zconfig.remove (Zconfig) ``` Destroy node and subtree (all children) ``` nothing my_zconfig.print () ``` Print properties of object ``` nothing my_zconfig.test (Boolean) ``` Self test of this class ### The Zdigest class - provides hashing functions (SHA-1 at present) Constructor: ``` var czmq = require ('bindings')('czmq') var my_zdigest = new czmq.Zdigest () ``` You *must* call the destructor on every Zdigest instance: ``` my_zdigest.destroy () ``` Methods: ``` nothing my_zdigest.update (String) ``` Add buffer into digest calculation ``` buffer my_zdigest.data () ``` Return final digest hash data. If built without crypto support, returns NULL. ``` size my_zdigest.size () ``` Return final digest hash size ``` string my_zdigest.string () ``` Return digest as printable hex string; caller should not modify nor free this string. After calling this, you may not use zdigest_update() on the same digest. If built without crypto support, returns NULL. ``` nothing my_zdigest.test (Boolean) ``` Self test of this class. ### The Zdir class - work with file-system directories Constructor: ``` var czmq = require ('bindings')('czmq') var my_zdir = new czmq.Zdir (String, String) ``` You *must* call the destructor on every Zdir instance: ``` my_zdir.destroy () ``` Methods: ``` string my_zdir.path () ``` Return directory path ``` time my_zdir.modified () ``` Return last modification time for directory. ``` file_size my_zdir.cursize () ``` Return total hierarchy size, in bytes of data contained in all files in the directory tree. ``` size my_zdir.count () ``` Return directory count ``` zlist my_zdir.list () ``` Returns a sorted list of zfile objects; Each entry in the list is a pointer to a zfile_t item already allocated in the zdir tree. Do not destroy the original zdir tree until you are done with this list. ``` nothing my_zdir.remove (Boolean) ``` Remove directory, optionally including all files that it contains, at all levels. If force is false, will only remove the directory if empty. If force is true, will remove all files and all subdirectories. ``` zlist my_zdir.diff (Zdir, Zdir, String) ``` Calculate differences between two versions of a directory tree. Returns a list of zdir_patch_t patches. Either older or newer may be null, indicating the directory is empty/absent. If alias is set, generates virtual filename (minus path, plus alias). ``` zlist my_zdir.resync (String) ``` Return full contents of directory as a zdir_patch list. ``` zhash my_zdir.cache () ``` Load directory cache; returns a hash table containing the SHA-1 digests of every file in the tree. The cache is saved between runs in .cache. ``` nothing my_zdir.print (Number) ``` Print contents of directory to stdout ``` nothing my_zdir.test (Boolean) ``` Self test of this class. ### The ZdirPatch class - work with directory patches Constructor: ``` var czmq = require ('bindings')('czmq') var my_zdir_patch = new czmq.ZdirPatch (String, Zfile, Number, String) ``` You *must* call the destructor on every ZdirPatch instance: ``` my_zdir_patch.destroy () ``` Methods: ``` zdir_patch my_zdir_patch.dup () ``` Create copy of a patch. If the patch is null, or memory was exhausted, returns null. ``` string my_zdir_patch.path () ``` Return patch file directory path ``` zfile my_zdir_patch.file () ``` Return patch file item ``` integer my_zdir_patch.op () ``` Return operation ``` string my_zdir_patch.vpath () ``` Return patch virtual file path ``` nothing my_zdir_patch.digestSet () ``` Calculate hash digest for file (create only) ``` string my_zdir_patch.digest () ``` Return hash digest for patch file ``` nothing my_zdir_patch.test (Boolean) ``` Self test of this class. ### The Zfile class - helper functions for working with files. Constructor: ``` var czmq = require ('bindings')('czmq') var my_zfile = new czmq.Zfile (String, String) ``` You *must* call the destructor on every Zfile instance: ``` my_zfile.destroy () ``` Methods: ``` zfile my_zfile.dup () ``` Duplicate a file item, returns a newly constructed item. If the file is null, or memory was exhausted, returns null. ``` string my_zfile.filename (String) ``` Return file name, remove path if provided ``` nothing my_zfile.restat () ``` Refresh file properties from disk; this is not done automatically on access methods, otherwise it is not possible to compare directory snapshots. ``` time my_zfile.modified () ``` Return when the file was last modified. If you want this to reflect the current situation, call zfile_restat before checking this property. ``` file_size my_zfile.cursize () ``` Return the last-known size of the file. If you want this to reflect the current situation, call zfile_restat before checking this property. ``` boolean my_zfile.isDirectory () ``` Return true if the file is a directory. If you want this to reflect any external changes, call zfile_restat before checking this property. ``` boolean my_zfile.isRegular () ``` Return true if the file is a regular file. If you want this to reflect any external changes, call zfile_restat before checking this property. ``` boolean my_zfile.isReadable () ``` Return true if the file is readable by this process. If you want this to reflect any external changes, call zfile_restat before checking this property. ``` boolean my_zfile.isWriteable () ``` Return true if the file is writeable by this process. If you want this to reflect any external changes, call zfile_restat before checking this property. ``` boolean my_zfile.isStable () ``` Check if file has stopped changing and can be safely processed. Updates the file statistics from disk at every call. ``` boolean my_zfile.hasChanged () ``` Return true if the file was changed on disk since the zfile_t object was created, or the last zfile_restat() call made on it. ``` nothing my_zfile.remove () ``` Remove the file from disk ``` integer my_zfile.input () ``` Open file for reading Returns 0 if OK, -1 if not found or not accessible ``` integer my_zfile.output () ``` Open file for writing, creating directory if needed File is created if necessary; chunks can be written to file at any location. Returns 0 if OK, -1 if error. ``` zchunk my_zfile.read (, Number) ``` Read chunk from file at specified position. If this was the last chunk, sets the eof property. Returns a null chunk in case of error. ``` boolean my_zfile.eof () ``` Returns true if zfile_read() just read the last chunk in the file. ``` integer my_zfile.write (Zchunk, Number) ``` Write chunk to file at specified position Return 0 if OK, else -1 ``` string my_zfile.readln () ``` Read next line of text from file. Returns a pointer to the text line, or NULL if there was nothing more to read from the file. ``` nothing my_zfile.close () ``` Close file, if open ``` string my_zfile.digest () ``` Calculate SHA1 digest for file, using zdigest class. ``` nothing my_zfile.test (Boolean) ``` Self test of this class. ### The Zframe class - working with single message frames Constructor: ``` var czmq = require ('bindings')('czmq') var my_zframe = new czmq.Zframe (String) ``` You *must* call the destructor on every Zframe instance: ``` my_zframe.destroy () ``` Methods: ``` integer my_zframe.send (Zframe, Zsock, Number) ``` Send a frame to a socket, destroy frame after sending. Return -1 on error, 0 on success. ``` size my_zframe.size () ``` Return number of bytes in frame data ``` buffer my_zframe.data () ``` Return address of frame data ``` string my_zframe.meta (String) ``` Return meta data property for frame The caller shall not modify or free the returned value, which shall be owned by the message. ``` zframe my_zframe.dup () ``` Create a new frame that duplicates an existing frame. If frame is null, or memory was exhausted, returns null. ``` string my_zframe.strhex () ``` Return frame data encoded as printable hex string, useful for 0MQ UUIDs. Caller must free string when finished with it. ``` string my_zframe.strdup () ``` Return frame data copied into freshly allocated string Caller must free string when finished with it. ``` boolean my_zframe.streq (String) ``` Return TRUE if frame body is equal to string, excluding terminator ``` integer my_zframe.more () ``` Return frame MORE indicator (1 or 0), set when reading frame from socket or by the zframe_set_more() method ``` nothing my_zframe.setMore (Number) ``` Set frame MORE indicator (1 or 0). Note this is NOT used when sending frame to socket, you have to specify flag explicitly. ``` number my_zframe.routingId () ``` Return frame routing ID, if the frame came from a ZMQ_SERVER socket. Else returns zero. ``` nothing my_zframe.setRoutingId (Number) ``` Set routing ID on frame. This is used if/when the frame is sent to a ZMQ_SERVER socket. ``` string my_zframe.group () ``` Return frame group of radio-dish pattern. ``` integer my_zframe.setGroup (String) ``` Set group on frame. This is used if/when the frame is sent to a ZMQ_RADIO socket. Return -1 on error, 0 on success. ``` boolean my_zframe.eq (Zframe) ``` Return TRUE if two frames have identical size and data If either frame is NULL, equality is always false. ``` nothing my_zframe.reset (String) ``` Set new contents for frame ``` nothing my_zframe.print (String) ``` Send message to zsys log sink (may be stdout, or system facility as configured by zsys_set_logstream). Prefix shows before frame, if not null. ``` nothing my_zframe.test (Boolean) ``` Self test of this class. ### The Zhash class - generic type-free hash container (simple) Constructor: ``` var czmq = require ('bindings')('czmq') var my_zhash = new czmq.Zhash () ``` You *must* call the destructor on every Zhash instance: ``` my_zhash.destroy () ``` Methods: ``` nothing my_zhash.delete (String) ``` Remove an item specified by key from the hash table. If there was no such item, this function does nothing. ``` integer my_zhash.rename (String, String) ``` Reindexes an item from an old key to a new key. If there was no such item, does nothing. Returns 0 if successful, else -1. ``` size my_zhash.size () ``` Return the number of keys/items in the hash table ``` zhash my_zhash.dup () ``` Make copy of hash table; if supplied table is null, returns null. Does not copy items themselves. Rebuilds new table so may be slow on very large tables. NOTE: only works with item values that are strings since there's no other way to know how to duplicate the item value. ``` zlist my_zhash.keys () ``` Return keys for items in table ``` string my_zhash.cursor () ``` After a successful first/next method, returns the key for the item that was returned. This is a constant string that you may not modify or deallocate, and which lasts as long as the item in the hash. After an unsuccessful first/next, returns NULL. ``` nothing my_zhash.comment (String) ``` Add a comment to hash table before saving to disk. You can add as many comment lines as you like. These comment lines are discarded when loading the file. If you use a null format, all comments are deleted. ``` zframe my_zhash.pack () ``` Serialize hash table to a binary frame that can be sent in a message. The packed format is compatible with the 'dictionary' type defined in http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: ; A list of name/value pairs dictionary = dict-count *( dict-name dict-value ) dict-count = number-4 dict-value = longstr dict-name = string ; Strings are always length + text contents longstr = number-4 *VCHAR string = number-1 *VCHAR ; Numbers are unsigned integers in network byte order number-1 = 1OCTET number-4 = 4OCTET Comments are not included in the packed data. Item values MUST be strings. ``` integer my_zhash.save (String) ``` Save hash table to a text file in name=value format. Hash values must be printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file error occurred. ``` integer my_zhash.load (String) ``` Load hash table from a text file in name=value format; hash table must already exist. Hash values must printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file was not readable. ``` integer my_zhash.refresh () ``` When a hash table was loaded from a file by zhash_load, this method will reload the file if it has been modified since, and is "stable", i.e. not still changing. Returns 0 if OK, -1 if there was an error reloading the file. ``` nothing my_zhash.autofree () ``` Set hash for automatic value destruction. Note that this assumes that values are NULL-terminated strings. Do not use with different types. ``` nothing my_zhash.test (Boolean) ``` Self test of this class. ### The Zhashx class - extended generic type-free hash container Constructor: ``` var czmq = require ('bindings')('czmq') var my_zhashx = new czmq.Zhashx () ``` You *must* call the destructor on every Zhashx instance: ``` my_zhashx.destroy () ``` Methods: ``` nothing my_zhashx.purge () ``` Delete all items from the hash table. If the key destructor is set, calls it on every key. If the item destructor is set, calls it on every item. ``` size my_zhashx.size () ``` Return the number of keys/items in the hash table ``` zlistx my_zhashx.keys () ``` Return a zlistx_t containing the keys for the items in the table. Uses the key_duplicator to duplicate all keys and sets the key_destructor as destructor for the list. ``` zlistx my_zhashx.values () ``` Return a zlistx_t containing the values for the items in the table. Uses the duplicator to duplicate all items and sets the destructor as destructor for the list. ``` nothing my_zhashx.comment (String) ``` Add a comment to hash table before saving to disk. You can add as many comment lines as you like. These comment lines are discarded when loading the file. If you use a null format, all comments are deleted. ``` integer my_zhashx.save (String) ``` Save hash table to a text file in name=value format. Hash values must be printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file error occurred. ``` integer my_zhashx.load (String) ``` Load hash table from a text file in name=value format; hash table must already exist. Hash values must printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file was not readable. ``` integer my_zhashx.refresh () ``` When a hash table was loaded from a file by zhashx_load, this method will reload the file if it has been modified since, and is "stable", i.e. not still changing. Returns 0 if OK, -1 if there was an error reloading the file. ``` zframe my_zhashx.pack () ``` Serialize hash table to a binary frame that can be sent in a message. The packed format is compatible with the 'dictionary' type defined in http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: ; A list of name/value pairs dictionary = dict-count *( dict-name dict-value ) dict-count = number-4 dict-value = longstr dict-name = string ; Strings are always length + text contents longstr = number-4 *VCHAR string = number-1 *VCHAR ; Numbers are unsigned integers in network byte order number-1 = 1OCTET number-4 = 4OCTET Comments are not included in the packed data. Item values MUST be strings. ``` zhashx my_zhashx.dup () ``` Make a copy of the list; items are duplicated if you set a duplicator for the list, otherwise not. Copying a null reference returns a null reference. Note that this method's behavior changed slightly for CZMQ v3.x, as it does not set nor respect autofree. It does however let you duplicate any hash table safely. The old behavior is in zhashx_dup_v2. ``` zhashx my_zhashx.dupV2 () ``` Make copy of hash table; if supplied table is null, returns null. Does not copy items themselves. Rebuilds new table so may be slow on very large tables. NOTE: only works with item values that are strings since there's no other way to know how to duplicate the item value. ``` nothing my_zhashx.test (Boolean) ``` Self test of this class. ### The Ziflist class - List of network interfaces available on system Constructor: ``` var czmq = require ('bindings')('czmq') var my_ziflist = new czmq.Ziflist () ``` You *must* call the destructor on every Ziflist instance: ``` my_ziflist.destroy () ``` Methods: ``` nothing my_ziflist.reload () ``` Reload network interfaces from system ``` size my_ziflist.size () ``` Return the number of network interfaces on system ``` string my_ziflist.first () ``` Get first network interface, return NULL if there are none ``` string my_ziflist.next () ``` Get next network interface, return NULL if we hit the last one ``` string my_ziflist.address () ``` Return the current interface IP address as a printable string ``` string my_ziflist.broadcast () ``` Return the current interface broadcast address as a printable string ``` string my_ziflist.netmask () ``` Return the current interface network mask as a printable string ``` nothing my_ziflist.print () ``` Return the list of interfaces. ``` ziflist my_ziflist.newIpv6 () ``` Get a list of network interfaces currently defined on the system Includes IPv6 interfaces ``` nothing my_ziflist.reloadIpv6 () ``` Reload network interfaces from system, including IPv6 ``` boolean my_ziflist.isIpv6 () ``` Return true if the current interface uses IPv6 ``` nothing my_ziflist.test (Boolean) ``` Self test of this class. ### The Zlist class - simple generic list container Constructor: ``` var czmq = require ('bindings')('czmq') var my_zlist = new czmq.Zlist () ``` You *must* call the destructor on every Zlist instance: ``` my_zlist.destroy () ``` Methods: ``` zlist my_zlist.dup () ``` Make a copy of list. If the list has autofree set, the copied list will duplicate all items, which must be strings. Otherwise, the list will hold pointers back to the items in the original list. If list is null, returns NULL. ``` nothing my_zlist.purge () ``` Purge all items from list ``` size my_zlist.size () ``` Return number of items in the list ``` nothing my_zlist.autofree () ``` Set list for automatic item destruction; item values MUST be strings. By default a list item refers to a value held elsewhere. When you set this, each time you append or push a list item, zlist will take a copy of the string value. Then, when you destroy the list, it will free all item values automatically. If you use any other technique to allocate list values, you must free them explicitly before destroying the list. The usual technique is to pop list items and destroy them, until the list is empty. ``` nothing my_zlist.test (Boolean) ``` Self test of this class. ### The Zlistx class - extended generic list container Constructor: ``` var czmq = require ('bindings')('czmq') var my_zlistx = new czmq.Zlistx () ``` You *must* call the destructor on every Zlistx instance: ``` my_zlistx.destroy () ``` Methods: ``` size my_zlistx.size () ``` Return the number of items in the list ``` nothing my_zlistx.purge () ``` Remove all items from the list, and destroy them if the item destructor is set. ``` nothing my_zlistx.sort () ``` Sort the list. If an item comparator was set, calls that to compare items, otherwise compares on item value. The sort is not stable, so may reorder equal items. ``` zlistx my_zlistx.dup () ``` Make a copy of the list; items are duplicated if you set a duplicator for the list, otherwise not. Copying a null reference returns a null reference. ``` nothing my_zlistx.test (Boolean) ``` Self test of this class. ### The Zloop class - event-driven reactor Constructor: ``` var czmq = require ('bindings')('czmq') var my_zloop = new czmq.Zloop () ``` You *must* call the destructor on every Zloop instance: ``` my_zloop.destroy () ``` Methods: ``` nothing my_zloop.readerEnd (Zsock) ``` Cancel a socket reader from the reactor. If multiple readers exist for same socket, cancels ALL of them. ``` nothing my_zloop.readerSetTolerant (Zsock) ``` Configure a registered reader to ignore errors. If you do not set this, then readers that have errors are removed from the reactor silently. ``` integer my_zloop.timerEnd (Number) ``` Cancel a specific timer identified by a specific timer_id (as returned by zloop_timer). ``` nothing my_zloop.setTicketDelay () ``` Set the ticket delay, which applies to all tickets. If you lower the delay and there are already tickets created, the results are undefined. ``` nothing my_zloop.setMaxTimers () ``` Set hard limit on number of timers allowed. Setting more than a small number of timers (10-100) can have a dramatic impact on the performance of the reactor. For high-volume cases, use ticket timers. If the hard limit is reached, the reactor stops creating new timers and logs an error. ``` nothing my_zloop.setVerbose (Boolean) ``` Set verbose tracing of reactor on/off. The default verbose setting is off (false). ``` nothing my_zloop.setNonstop (Boolean) ``` By default the reactor stops if the process receives a SIGINT or SIGTERM signal. This makes it impossible to shut-down message based architectures like zactors. This method lets you switch off break handling. The default nonstop setting is off (false). ``` integer my_zloop.start () ``` Start the reactor. Takes control of the thread and returns when the 0MQ context is terminated or the process is interrupted, or any event handler returns -1. Event handlers may register new sockets and timers, and cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. ``` nothing my_zloop.test (Boolean) ``` Self test of this class. ### The Zmsg class - working with multipart messages Constructor: ``` var czmq = require ('bindings')('czmq') var my_zmsg = new czmq.Zmsg () ``` You *must* call the destructor on every Zmsg instance: ``` my_zmsg.destroy () ``` Methods: ``` integer my_zmsg.send (Zmsg, Zsock) ``` Send message to destination socket, and destroy the message after sending it successfully. If the message has no frames, sends nothing but destroys the message anyhow. Nullifies the caller's reference to the message (as it is a destructor). ``` integer my_zmsg.sendm (Zmsg, Zsock) ``` Send message to destination socket as part of a multipart sequence, and destroy the message after sending it successfully. Note that after a zmsg_sendm, you must call zmsg_send or another method that sends a final message part. If the message has no frames, sends nothing but destroys the message anyhow. Nullifies the caller's reference to the message (as it is a destructor). ``` size my_zmsg.size () ``` Return size of message, i.e. number of frames (0 or more). ``` size my_zmsg.contentSize () ``` Return total size of all frames in message. ``` number my_zmsg.routingId () ``` Return message routing ID, if the message came from a ZMQ_SERVER socket. Else returns zero. ``` nothing my_zmsg.setRoutingId (Number) ``` Set routing ID on message. This is used if/when the message is sent to a ZMQ_SERVER socket. ``` integer my_zmsg.prepend (Zframe) ``` Push frame to the front of the message, i.e. before all other frames. Message takes ownership of frame, will destroy it when message is sent. Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not nullify the caller's frame reference. ``` integer my_zmsg.append (Zframe) ``` Add frame to the end of the message, i.e. after all other frames. Message takes ownership of frame, will destroy it when message is sent. Returns 0 on success. Deprecates zmsg_add, which did not nullify the caller's frame reference. ``` zframe my_zmsg.pop () ``` Remove first frame from message, if any. Returns frame, or NULL. ``` integer my_zmsg.pushmem (String) ``` Push block of memory to front of message, as a new frame. Returns 0 on success, -1 on error. ``` integer my_zmsg.addmem (String) ``` Add block of memory to the end of the message, as a new frame. Returns 0 on success, -1 on error. ``` integer my_zmsg.pushstr (String) ``` Push string as new frame to front of message. Returns 0 on success, -1 on error. ``` integer my_zmsg.addstr (String) ``` Push string as new frame to end of message. Returns 0 on success, -1 on error. ``` integer my_zmsg.pushstrf (String) ``` Push formatted string as new frame to front of message. Returns 0 on success, -1 on error. ``` integer my_zmsg.addstrf (String) ``` Push formatted string as new frame to end of message. Returns 0 on success, -1 on error. ``` string my_zmsg.popstr () ``` Pop frame off front of message, return as fresh string. If there were no more frames in the message, returns NULL. ``` integer my_zmsg.addmsg (Zmsg) ``` Push encoded message as a new frame. Message takes ownership of submessage, so the original is destroyed in this call. Returns 0 on success, -1 on error. ``` zmsg my_zmsg.popmsg () ``` Remove first submessage from message, if any. Returns zmsg_t, or NULL if decoding was not successful. ``` nothing my_zmsg.remove (Zframe) ``` Remove specified frame from list, if present. Does not destroy frame. ``` zframe my_zmsg.first () ``` Set cursor to first frame in message. Returns frame, or NULL, if the message is empty. Use this to navigate the frames as a list. ``` zframe my_zmsg.next () ``` Return the next frame. If there are no more frames, returns NULL. To move to the first frame call zmsg_first(). Advances the cursor. ``` zframe my_zmsg.last () ``` Return the last frame. If there are no frames, returns NULL. ``` zframe my_zmsg.encode () ``` Serialize multipart message to a single message frame. Use this method to send structured messages across transports that do not support multipart data. Allocates and returns a new frame containing the serialized message. To decode a serialized message frame, use zmsg_decode (). ``` zmsg my_zmsg.dup () ``` Create copy of message, as new message object. Returns a fresh zmsg_t object. If message is null, or memory was exhausted, returns null. ``` nothing my_zmsg.print () ``` Send message to zsys log sink (may be stdout, or system facility as configured by zsys_set_logstream). ``` boolean my_zmsg.eq (Zmsg) ``` Return true if the two messages have the same number of frames and each frame in the first message is identical to the corresponding frame in the other message. As with zframe_eq, return false if either message is NULL. ``` integer my_zmsg.signal () ``` Return signal value, 0 or greater, if message is a signal, -1 if not. ``` nothing my_zmsg.test (Boolean) ``` Self test of this class. ### The Zpoller class - event-driven reactor Constructor: ``` var czmq = require ('bindings')('czmq') var my_zpoller = new czmq.Zpoller (Zsock) ``` You *must* call the destructor on every Zpoller instance: ``` my_zpoller.destroy () ``` Methods: ``` integer my_zpoller.add (Zsock) ``` Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. ``` nothing my_zpoller.setNonstop (Boolean) ``` By default the poller stops if the process receives a SIGINT or SIGTERM signal. This makes it impossible to shut-down message based architectures like zactors. This method lets you switch off break handling. The default nonstop setting is off (false). ``` boolean my_zpoller.expired () ``` Return true if the last zpoller_wait () call ended because the timeout expired, without any error. ``` boolean my_zpoller.terminated () ``` Return true if the last zpoller_wait () call ended because the process was interrupted, or the parent context was destroyed. ``` nothing my_zpoller.test (Boolean) ``` Self test of this class. ### The Zproc class - process configuration and status Constructor: ``` var czmq = require ('bindings')('czmq') var my_zproc = new czmq.Zproc () ``` You *must* call the destructor on every Zproc instance: ``` my_zproc.destroy () ``` Methods: ``` nothing my_zproc.setArgs (Zlistx) ``` Setup the command line arguments, the first item must be an (absolute) filename to run. ``` nothing my_zproc.setEnv (Zhashx) ``` Setup the environment variables for the process. ``` integer my_zproc.run () ``` Starts the process. ``` integer my_zproc.returncode () ``` process exit code ``` integer my_zproc.pid () ``` PID of the process ``` boolean my_zproc.running () ``` return true if process is running, false if not yet started or finished ``` integer my_zproc.wait (Boolean) ``` wait or poll process status, return return code ``` nothing my_zproc.kill (Number) ``` send a signal to the subprocess ``` nothing my_zproc.setVerbose (Boolean) ``` set verbose mode ``` integer my_zproc.czmqVersion () ``` Returns CZMQ version as a single 6-digit integer encoding the major version (x 10000), the minor version (x 100) and the patch. ``` boolean my_zproc.interrupted () ``` Returns true if the process received a SIGINT or SIGTERM signal. It is good practice to use this method to exit any infinite loop processing messages. ``` boolean my_zproc.hasCurve () ``` Returns true if the underlying libzmq supports CURVE security. ``` string my_zproc.hostname () ``` Return current host name, for use in public tcp:// endpoints. If the host name is not resolvable, returns NULL. ``` nothing my_zproc.daemonize (String) ``` Move the current process into the background. The precise effect depends on the operating system. On POSIX boxes, moves to a specified working directory (if specified), closes all file handles, reopens stdin, stdout, and stderr to the null device, and sets the process to ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there was an error. ``` nothing my_zproc.runAs (String, String, String) ``` Drop the process ID into the lockfile, with exclusive lock, and switch the process to the specified group and/or user. Any of the arguments may be null, indicating a no-op. Returns 0 on success, -1 on failure. Note if you combine this with zsys_daemonize, run after, not before that method, or the lockfile will hold the wrong process ID. ``` nothing my_zproc.setIoThreads () ``` Configure the number of I/O threads that ZeroMQ will use. A good rule of thumb is one thread per gigabit of traffic in or out. The default is 1, sufficient for most applications. If the environment variable ZSYS_IO_THREADS is defined, that provides the default. Note that this method is valid only before any socket is created. ``` nothing my_zproc.setMaxSockets () ``` Configure the number of sockets that ZeroMQ will allow. The default is 1024. The actual limit depends on the system, and you can query it by using zsys_socket_limit (). A value of zero means "maximum". Note that this method is valid only before any socket is created. ``` nothing my_zproc.setBiface (String) ``` Set network interface name to use for broadcasts, particularly zbeacon. This lets the interface be configured for test environments where required. For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is the default when there is no specified interface. If the environment variable ZSYS_INTERFACE is set, use that as the default interface name. Setting the interface to "*" means "use all available interfaces". ``` string my_zproc.biface () ``` Return network interface to use for broadcasts, or "" if none was set. ``` nothing my_zproc.setLogIdent (String) ``` Set log identity, which is a string that prefixes all log messages sent by this process. The log identity defaults to the environment variable ZSYS_LOGIDENT, if that is set. ``` nothing my_zproc.setLogSender (String) ``` Sends log output to a PUB socket bound to the specified endpoint. To collect such log output, create a SUB socket, subscribe to the traffic you care about, and connect to the endpoint. Log traffic is sent as a single string frame, in the same format as when sent to stdout. The log system supports a single sender; multiple calls to this method will bind the same sender to multiple endpoints. To disable the sender, call this method with a null argument. ``` nothing my_zproc.setLogSystem (Boolean) ``` Enable or disable logging to the system facility (syslog on POSIX boxes, event log on Windows). By default this is disabled. ``` nothing my_zproc.logError (String) ``` Log error condition - highest priority ``` nothing my_zproc.logWarning (String) ``` Log warning condition - high priority ``` nothing my_zproc.logNotice (String) ``` Log normal, but significant, condition - normal priority ``` nothing my_zproc.logInfo (String) ``` Log informational message - low priority ``` nothing my_zproc.logDebug (String) ``` Log debug-level message - lowest priority ``` nothing my_zproc.test (Boolean) ``` Self test of this class. ### The Zsock class - high-level socket API that hides libzmq contexts and sockets Constructor: ``` var czmq = require ('bindings')('czmq') var my_zsock = new czmq.Zsock (Number) ``` You *must* call the destructor on every Zsock instance: ``` my_zsock.destroy () ``` Methods: ``` integer my_zsock.bind (String) ``` Bind a socket to a formatted endpoint. For tcp:// endpoints, supports ephemeral ports, if you specify the port number as "*". By default zsock uses the IANA designated range from C000 (49152) to FFFF (65535). To override this range, follow the "*" with "[first-last]". Either or both first and last may be empty. To bind to a random port within the range, use "!" in place of "*". Examples: tcp://127.0.0.1:* bind to first free port from C000 up tcp://127.0.0.1:! bind to random port from C000 to FFFF tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 tcp://127.0.0.1:![55000-55999] bind to random port from 55000 to 55999 On success, returns the actual port number used, for tcp:// endpoints, and 0 for other transports. On failure, returns -1. Note that when using ephemeral ports, a port may be reused by different services without clients being aware. Protocols that run on ephemeral ports should take this into account. ``` string my_zsock.endpoint () ``` Returns last bound endpoint, if any. ``` integer my_zsock.unbind (String) ``` Unbind a socket from a formatted endpoint. Returns 0 if OK, -1 if the endpoint was invalid or the function isn't supported. ``` integer my_zsock.connect (String) ``` Connect a socket to a formatted endpoint Returns 0 if OK, -1 if the endpoint was invalid. ``` integer my_zsock.disconnect (String) ``` Disconnect a socket from a formatted endpoint Returns 0 if OK, -1 if the endpoint was invalid or the function isn't supported. ``` integer my_zsock.attach (String, Boolean) ``` Attach a socket to zero or more endpoints. If endpoints is not null, parses as list of ZeroMQ endpoints, separated by commas, and prefixed by '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all endpoints were valid, or -1 if there was a syntax error. If the endpoint does not start with '@' or '>', the serverish argument defines whether it is used to bind (serverish = true) or connect (serverish = false). ``` string my_zsock.typeStr () ``` Returns socket type as printable constant string. ``` integer my_zsock.send (String) ``` Send a 'picture' message to the socket (or actor). The picture is a string that defines the type of each frame. This makes it easy to send a complex multiframe message in one call. The picture can contain any of these characters, each corresponding to one or two arguments: i = int (signed) 1 = uint8_t 2 = uint16_t 4 = uint32_t 8 = uint64_t s = char * b = byte *, size_t (2 arguments) c = zchunk_t * f = zframe_t * h = zhashx_t * U = zuuid_t * p = void * (sends the pointer value, only meaningful over inproc) m = zmsg_t * (sends all frames in the zmsg) z = sends zero-sized frame (0 arguments) u = uint (deprecated) Note that s, b, c, and f are encoded the same way and the choice is offered as a convenience to the sender, which may or may not already have data in a zchunk or zframe. Does not change or take ownership of any arguments. Returns 0 if successful, -1 if sending failed for any reason. ``` integer my_zsock.recv (String) ``` Receive a 'picture' message to the socket (or actor). See zsock_send for the format and meaning of the picture. Returns the picture elements into a series of pointers as provided by the caller: i = int * (stores signed integer) 4 = uint32_t * (stores 32-bit unsigned integer) 8 = uint64_t * (stores 64-bit unsigned integer) s = char ** (allocates new string) b = byte **, size_t * (2 arguments) (allocates memory) c = zchunk_t ** (creates zchunk) f = zframe_t ** (creates zframe) U = zuuid_t * (creates a zuuid with the data) h = zhashx_t ** (creates zhashx) p = void ** (stores pointer) m = zmsg_t ** (creates a zmsg with the remaing frames) z = null, asserts empty frame (0 arguments) u = uint * (stores unsigned integer, deprecated) Note that zsock_recv creates the returned objects, and the caller must destroy them when finished with them. The supplied pointers do not need to be initialized. Returns 0 if successful, or -1 if it failed to recv a message, in which case the pointers are not modified. When message frames are truncated (a short message), sets return values to zero/null. If an argument pointer is NULL, does not store any value (skips it). An 'n' picture matches an empty frame; if the message does not match, the method will return -1. ``` integer my_zsock.bsend (String) ``` Send a binary encoded 'picture' message to the socket (or actor). This method is similar to zsock_send, except the arguments are encoded in a binary format that is compatible with zproto, and is designed to reduce memory allocations. The pattern argument is a string that defines the type of each argument. Supports these argument types: pattern C type zproto type: 1 uint8_t type = "number" size = "1" 2 uint16_t type = "number" size = "2" 4 uint32_t type = "number" size = "3" 8 uint64_t type = "number" size = "4" s char *, 0-255 chars type = "string" S char *, 0-2^32-1 chars type = "longstr" c zchunk_t * type = "chunk" f zframe_t * type = "frame" u zuuid_t * type = "uuid" m zmsg_t * type = "msg" p void *, sends pointer value, only over inproc Does not change or take ownership of any arguments. Returns 0 if successful, -1 if sending failed for any reason. ``` integer my_zsock.brecv (String) ``` Receive a binary encoded 'picture' message from the socket (or actor). This method is similar to zsock_recv, except the arguments are encoded in a binary format that is compatible with zproto, and is designed to reduce memory allocations. The pattern argument is a string that defines the type of each argument. See zsock_bsend for the supported argument types. All arguments must be pointers; this call sets them to point to values held on a per-socket basis. For types 1, 2, 4 and 8 the caller must allocate the memory itself before calling zsock_brecv. For types S, the caller must free the value once finished with it, as zsock_brecv will allocate the buffer. For type s, the caller must not free the value as it is stored in a local cache for performance purposes. For types c, f, u and m the caller must call the appropriate destructor depending on the object as zsock_brecv will create new objects. For type p the caller must coordinate with the sender, as it is just a pointer value being passed. ``` number my_zsock.routingId () ``` Return socket routing ID if any. This returns 0 if the socket is not of type ZMQ_SERVER or if no request was already received on it. ``` nothing my_zsock.setRoutingId (Number) ``` Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. This will be used when sending messages on the socket via the zsock API. ``` nothing my_zsock.setUnbounded () ``` Set socket to use unbounded pipes (HWM=0); use this in cases when you are totally certain the message volume can fit in memory. This method works across all versions of ZeroMQ. Takes a polymorphic socket reference. ``` integer my_zsock.wait () ``` Wait on a signal. Use this to coordinate between threads, over pipe pairs. Blocks until the signal is received. Returns -1 on error, 0 or greater on success. Accepts a zsock_t or a zactor_t as argument. Takes a polymorphic socket reference. ``` nothing my_zsock.flush () ``` If there is a partial message still waiting on the socket, remove and discard it. This is useful when reading partial messages, to get specific message types. ``` integer my_zsock.join (String) ``` Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. Returns 0 if OK, -1 if failed. ``` integer my_zsock.leave (String) ``` Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. Returns 0 if OK, -1 if failed. ``` integer my_zsock.heartbeatIvl () ``` Get socket option `heartbeat_ivl`. Available from libzmq 4.2.0. ``` nothing my_zsock.setHeartbeatIvl (Number) ``` Set socket option `heartbeat_ivl`. Available from libzmq 4.2.0. ``` integer my_zsock.heartbeatTtl () ``` Get socket option `heartbeat_ttl`. Available from libzmq 4.2.0. ``` nothing my_zsock.setHeartbeatTtl (Number) ``` Set socket option `heartbeat_ttl`. Available from libzmq 4.2.0. ``` integer my_zsock.heartbeatTimeout () ``` Get socket option `heartbeat_timeout`. Available from libzmq 4.2.0. ``` nothing my_zsock.setHeartbeatTimeout (Number) ``` Set socket option `heartbeat_timeout`. Available from libzmq 4.2.0. ``` integer my_zsock.useFd () ``` Get socket option `use_fd`. Available from libzmq 4.2.0. ``` nothing my_zsock.setUseFd (Number) ``` Set socket option `use_fd`. Available from libzmq 4.2.0. ``` nothing my_zsock.setXpubManual (Number) ``` Set socket option `xpub_manual`. Available from libzmq 4.2.0. ``` nothing my_zsock.setXpubWelcomeMsg (String) ``` Set socket option `xpub_welcome_msg`. Available from libzmq 4.2.0. ``` nothing my_zsock.setStreamNotify (Number) ``` Set socket option `stream_notify`. Available from libzmq 4.2.0. ``` integer my_zsock.invertMatching () ``` Get socket option `invert_matching`. Available from libzmq 4.2.0. ``` nothing my_zsock.setInvertMatching (Number) ``` Set socket option `invert_matching`. Available from libzmq 4.2.0. ``` nothing my_zsock.setXpubVerboser (Number) ``` Set socket option `xpub_verboser`. Available from libzmq 4.2.0. ``` integer my_zsock.connectTimeout () ``` Get socket option `connect_timeout`. Available from libzmq 4.2.0. ``` nothing my_zsock.setConnectTimeout (Number) ``` Set socket option `connect_timeout`. Available from libzmq 4.2.0. ``` integer my_zsock.tcpMaxrt () ``` Get socket option `tcp_maxrt`. Available from libzmq 4.2.0. ``` nothing my_zsock.setTcpMaxrt (Number) ``` Set socket option `tcp_maxrt`. Available from libzmq 4.2.0. ``` integer my_zsock.threadSafe () ``` Get socket option `thread_safe`. Available from libzmq 4.2.0. ``` integer my_zsock.multicastMaxtpdu () ``` Get socket option `multicast_maxtpdu`. Available from libzmq 4.2.0. ``` nothing my_zsock.setMulticastMaxtpdu (Number) ``` Set socket option `multicast_maxtpdu`. Available from libzmq 4.2.0. ``` integer my_zsock.vmciBufferSize () ``` Get socket option `vmci_buffer_size`. Available from libzmq 4.2.0. ``` nothing my_zsock.setVmciBufferSize (Number) ``` Set socket option `vmci_buffer_size`. Available from libzmq 4.2.0. ``` integer my_zsock.vmciBufferMinSize () ``` Get socket option `vmci_buffer_min_size`. Available from libzmq 4.2.0. ``` nothing my_zsock.setVmciBufferMinSize (Number) ``` Set socket option `vmci_buffer_min_size`. Available from libzmq 4.2.0. ``` integer my_zsock.vmciBufferMaxSize () ``` Get socket option `vmci_buffer_max_size`. Available from libzmq 4.2.0. ``` nothing my_zsock.setVmciBufferMaxSize (Number) ``` Set socket option `vmci_buffer_max_size`. Available from libzmq 4.2.0. ``` integer my_zsock.vmciConnectTimeout () ``` Get socket option `vmci_connect_timeout`. Available from libzmq 4.2.0. ``` nothing my_zsock.setVmciConnectTimeout (Number) ``` Set socket option `vmci_connect_timeout`. Available from libzmq 4.2.0. ``` integer my_zsock.tos () ``` Get socket option `tos`. Available from libzmq 4.1.0. ``` nothing my_zsock.setTos (Number) ``` Set socket option `tos`. Available from libzmq 4.1.0. ``` nothing my_zsock.setRouterHandover (Number) ``` Set socket option `router_handover`. Available from libzmq 4.1.0. ``` nothing my_zsock.setConnectRid (String) ``` Set socket option `connect_rid`. Available from libzmq 4.1.0. ``` nothing my_zsock.setConnectRidBin (String) ``` Set socket option `connect_rid` from 32-octet binary Available from libzmq 4.1.0. ``` integer my_zsock.handshakeIvl () ``` Get socket option `handshake_ivl`. Available from libzmq 4.1.0. ``` nothing my_zsock.setHandshakeIvl (Number) ``` Set socket option `handshake_ivl`. Available from libzmq 4.1.0. ``` string my_zsock.socksProxy () ``` Get socket option `socks_proxy`. Available from libzmq 4.1.0. ``` nothing my_zsock.setSocksProxy (String) ``` Set socket option `socks_proxy`. Available from libzmq 4.1.0. ``` nothing my_zsock.setXpubNodrop (Number) ``` Set socket option `xpub_nodrop`. Available from libzmq 4.1.0. ``` nothing my_zsock.setRouterMandatory (Number) ``` Set socket option `router_mandatory`. Available from libzmq 4.0.0. ``` nothing my_zsock.setProbeRouter (Number) ``` Set socket option `probe_router`. Available from libzmq 4.0.0. ``` nothing my_zsock.setReqRelaxed (Number) ``` Set socket option `req_relaxed`. Available from libzmq 4.0.0. ``` nothing my_zsock.setReqCorrelate (Number) ``` Set socket option `req_correlate`. Available from libzmq 4.0.0. ``` nothing my_zsock.setConflate (Number) ``` Set socket option `conflate`. Available from libzmq 4.0.0. ``` string my_zsock.zapDomain () ``` Get socket option `zap_domain`. Available from libzmq 4.0.0. ``` nothing my_zsock.setZapDomain (String) ``` Set socket option `zap_domain`. Available from libzmq 4.0.0. ``` integer my_zsock.mechanism () ``` Get socket option `mechanism`. Available from libzmq 4.0.0. ``` integer my_zsock.plainServer () ``` Get socket option `plain_server`. Available from libzmq 4.0.0. ``` nothing my_zsock.setPlainServer (Number) ``` Set socket option `plain_server`. Available from libzmq 4.0.0. ``` string my_zsock.plainUsername () ``` Get socket option `plain_username`. Available from libzmq 4.0.0. ``` nothing my_zsock.setPlainUsername (String) ``` Set socket option `plain_username`. Available from libzmq 4.0.0. ``` string my_zsock.plainPassword () ``` Get socket option `plain_password`. Available from libzmq 4.0.0. ``` nothing my_zsock.setPlainPassword (String) ``` Set socket option `plain_password`. Available from libzmq 4.0.0. ``` integer my_zsock.curveServer () ``` Get socket option `curve_server`. Available from libzmq 4.0.0. ``` nothing my_zsock.setCurveServer (Number) ``` Set socket option `curve_server`. Available from libzmq 4.0.0. ``` string my_zsock.curvePublickey () ``` Get socket option `curve_publickey`. Available from libzmq 4.0.0. ``` nothing my_zsock.setCurvePublickey (String) ``` Set socket option `curve_publickey`. Available from libzmq 4.0.0. ``` nothing my_zsock.setCurvePublickeyBin (String) ``` Set socket option `curve_publickey` from 32-octet binary Available from libzmq 4.0.0. ``` string my_zsock.curveSecretkey () ``` Get socket option `curve_secretkey`. Available from libzmq 4.0.0. ``` nothing my_zsock.setCurveSecretkey (String) ``` Set socket option `curve_secretkey`. Available from libzmq 4.0.0. ``` nothing my_zsock.setCurveSecretkeyBin (String) ``` Set socket option `curve_secretkey` from 32-octet binary Available from libzmq 4.0.0. ``` string my_zsock.curveServerkey () ``` Get socket option `curve_serverkey`. Available from libzmq 4.0.0. ``` nothing my_zsock.setCurveServerkey (String) ``` Set socket option `curve_serverkey`. Available from libzmq 4.0.0. ``` nothing my_zsock.setCurveServerkeyBin (String) ``` Set socket option `curve_serverkey` from 32-octet binary Available from libzmq 4.0.0. ``` integer my_zsock.gssapiServer () ``` Get socket option `gssapi_server`. Available from libzmq 4.0.0. ``` nothing my_zsock.setGssapiServer (Number) ``` Set socket option `gssapi_server`. Available from libzmq 4.0.0. ``` integer my_zsock.gssapiPlaintext () ``` Get socket option `gssapi_plaintext`. Available from libzmq 4.0.0. ``` nothing my_zsock.setGssapiPlaintext (Number) ``` Set socket option `gssapi_plaintext`. Available from libzmq 4.0.0. ``` string my_zsock.gssapiPrincipal () ``` Get socket option `gssapi_principal`. Available from libzmq 4.0.0. ``` nothing my_zsock.setGssapiPrincipal (String) ``` Set socket option `gssapi_principal`. Available from libzmq 4.0.0. ``` string my_zsock.gssapiServicePrincipal () ``` Get socket option `gssapi_service_principal`. Available from libzmq 4.0.0. ``` nothing my_zsock.setGssapiServicePrincipal (String) ``` Set socket option `gssapi_service_principal`. Available from libzmq 4.0.0. ``` integer my_zsock.ipv6 () ``` Get socket option `ipv6`. Available from libzmq 4.0.0. ``` nothing my_zsock.setIpv6 (Number) ``` Set socket option `ipv6`. Available from libzmq 4.0.0. ``` integer my_zsock.immediate () ``` Get socket option `immediate`. Available from libzmq 4.0.0. ``` nothing my_zsock.setImmediate (Number) ``` Set socket option `immediate`. Available from libzmq 4.0.0. ``` integer my_zsock.sndhwm () ``` Get socket option `sndhwm`. Available from libzmq 3.0.0. ``` nothing my_zsock.setSndhwm (Number) ``` Set socket option `sndhwm`. Available from libzmq 3.0.0. ``` integer my_zsock.rcvhwm () ``` Get socket option `rcvhwm`. Available from libzmq 3.0.0. ``` nothing my_zsock.setRcvhwm (Number) ``` Set socket option `rcvhwm`. Available from libzmq 3.0.0. ``` integer my_zsock.maxmsgsize () ``` Get socket option `maxmsgsize`. Available from libzmq 3.0.0. ``` nothing my_zsock.setMaxmsgsize (Number) ``` Set socket option `maxmsgsize`. Available from libzmq 3.0.0. ``` integer my_zsock.multicastHops () ``` Get socket option `multicast_hops`. Available from libzmq 3.0.0. ``` nothing my_zsock.setMulticastHops (Number) ``` Set socket option `multicast_hops`. Available from libzmq 3.0.0. ``` nothing my_zsock.setXpubVerbose (Number) ``` Set socket option `xpub_verbose`. Available from libzmq 3.0.0. ``` integer my_zsock.tcpKeepalive () ``` Get socket option `tcp_keepalive`. Available from libzmq 3.0.0. ``` nothing my_zsock.setTcpKeepalive (Number) ``` Set socket option `tcp_keepalive`. Available from libzmq 3.0.0. ``` integer my_zsock.tcpKeepaliveIdle () ``` Get socket option `tcp_keepalive_idle`. Available from libzmq 3.0.0. ``` nothing my_zsock.setTcpKeepaliveIdle (Number) ``` Set socket option `tcp_keepalive_idle`. Available from libzmq 3.0.0. ``` integer my_zsock.tcpKeepaliveCnt () ``` Get socket option `tcp_keepalive_cnt`. Available from libzmq 3.0.0. ``` nothing my_zsock.setTcpKeepaliveCnt (Number) ``` Set socket option `tcp_keepalive_cnt`. Available from libzmq 3.0.0. ``` integer my_zsock.tcpKeepaliveIntvl () ``` Get socket option `tcp_keepalive_intvl`. Available from libzmq 3.0.0. ``` nothing my_zsock.setTcpKeepaliveIntvl (Number) ``` Set socket option `tcp_keepalive_intvl`. Available from libzmq 3.0.0. ``` string my_zsock.tcpAcceptFilter () ``` Get socket option `tcp_accept_filter`. Available from libzmq 3.0.0. ``` nothing my_zsock.setTcpAcceptFilter (String) ``` Set socket option `tcp_accept_filter`. Available from libzmq 3.0.0. ``` string my_zsock.lastEndpoint () ``` Get socket option `last_endpoint`. Available from libzmq 3.0.0. ``` nothing my_zsock.setRouterRaw (Number) ``` Set socket option `router_raw`. Available from libzmq 3.0.0. ``` integer my_zsock.ipv4only () ``` Get socket option `ipv4only`. Available from libzmq 3.0.0. ``` nothing my_zsock.setIpv4only (Number) ``` Set socket option `ipv4only`. Available from libzmq 3.0.0. ``` nothing my_zsock.setDelayAttachOnConnect (Number) ``` Set socket option `delay_attach_on_connect`. Available from libzmq 3.0.0. ``` integer my_zsock.hwm () ``` Get socket option `hwm`. Available from libzmq 2.0.0 to 3.0.0. ``` nothing my_zsock.setHwm (Number) ``` Set socket option `hwm`. Available from libzmq 2.0.0 to 3.0.0. ``` integer my_zsock.swap () ``` Get socket option `swap`. Available from libzmq 2.0.0 to 3.0.0. ``` nothing my_zsock.setSwap (Number) ``` Set socket option `swap`. Available from libzmq 2.0.0 to 3.0.0. ``` integer my_zsock.affinity () ``` Get socket option `affinity`. Available from libzmq 2.0.0. ``` nothing my_zsock.setAffinity (Number) ``` Set socket option `affinity`. Available from libzmq 2.0.0. ``` string my_zsock.identity () ``` Get socket option `identity`. Available from libzmq 2.0.0. ``` nothing my_zsock.setIdentity (String) ``` Set socket option `identity`. Available from libzmq 2.0.0. ``` integer my_zsock.rate () ``` Get socket option `rate`. Available from libzmq 2.0.0. ``` nothing my_zsock.setRate (Number) ``` Set socket option `rate`. Available from libzmq 2.0.0. ``` integer my_zsock.recoveryIvl () ``` Get socket option `recovery_ivl`. Available from libzmq 2.0.0. ``` nothing my_zsock.setRecoveryIvl (Number) ``` Set socket option `recovery_ivl`. Available from libzmq 2.0.0. ``` integer my_zsock.recoveryIvlMsec () ``` Get socket option `recovery_ivl_msec`. Available from libzmq 2.0.0 to 3.0.0. ``` nothing my_zsock.setRecoveryIvlMsec (Number) ``` Set socket option `recovery_ivl_msec`. Available from libzmq 2.0.0 to 3.0.0. ``` integer my_zsock.mcastLoop () ``` Get socket option `mcast_loop`. Available from libzmq 2.0.0 to 3.0.0. ``` nothing my_zsock.setMcastLoop (Number) ``` Set socket option `mcast_loop`. Available from libzmq 2.0.0 to 3.0.0. ``` integer my_zsock.rcvtimeo () ``` Get socket option `rcvtimeo`. Available from libzmq 2.2.0. ``` nothing my_zsock.setRcvtimeo (Number) ``` Set socket option `rcvtimeo`. Available from libzmq 2.2.0. ``` integer my_zsock.sndtimeo () ``` Get socket option `sndtimeo`. Available from libzmq 2.2.0. ``` nothing my_zsock.setSndtimeo (Number) ``` Set socket option `sndtimeo`. Available from libzmq 2.2.0. ``` integer my_zsock.sndbuf () ``` Get socket option `sndbuf`. Available from libzmq 2.0.0. ``` nothing my_zsock.setSndbuf (Number) ``` Set socket option `sndbuf`. Available from libzmq 2.0.0. ``` integer my_zsock.rcvbuf () ``` Get socket option `rcvbuf`. Available from libzmq 2.0.0. ``` nothing my_zsock.setRcvbuf (Number) ``` Set socket option `rcvbuf`. Available from libzmq 2.0.0. ``` integer my_zsock.linger () ``` Get socket option `linger`. Available from libzmq 2.0.0. ``` nothing my_zsock.setLinger (Number) ``` Set socket option `linger`. Available from libzmq 2.0.0. ``` integer my_zsock.reconnectIvl () ``` Get socket option `reconnect_ivl`. Available from libzmq 2.0.0. ``` nothing my_zsock.setReconnectIvl (Number) ``` Set socket option `reconnect_ivl`. Available from libzmq 2.0.0. ``` integer my_zsock.reconnectIvlMax () ``` Get socket option `reconnect_ivl_max`. Available from libzmq 2.0.0. ``` nothing my_zsock.setReconnectIvlMax (Number) ``` Set socket option `reconnect_ivl_max`. Available from libzmq 2.0.0. ``` integer my_zsock.backlog () ``` Get socket option `backlog`. Available from libzmq 2.0.0. ``` nothing my_zsock.setBacklog (Number) ``` Set socket option `backlog`. Available from libzmq 2.0.0. ``` nothing my_zsock.setSubscribe (String) ``` Set socket option `subscribe`. Available from libzmq 2.0.0. ``` nothing my_zsock.setUnsubscribe (String) ``` Set socket option `unsubscribe`. Available from libzmq 2.0.0. ``` integer my_zsock.type () ``` Get socket option `type`. Available from libzmq 2.0.0. ``` integer my_zsock.rcvmore () ``` Get socket option `rcvmore`. Available from libzmq 2.0.0. ``` integer my_zsock.events () ``` Get socket option `events`. Available from libzmq 2.0.0. ``` nothing my_zsock.test (Boolean) ``` Self test of this class. ### The Zstr class - sending and receiving strings Constructor: ``` var czmq = require ('bindings')('czmq') var my_zstr = new czmq.Zstr () ``` Methods: ``` string my_zstr.recv (Zsock) ``` Receive C string from socket. Caller must free returned string using zstr_free(). Returns NULL if the context is being terminated or the process was interrupted. ``` integer my_zstr.recvx (Zsock, String) ``` Receive a series of strings (until NULL) from multipart data. Each string is allocated and filled with string data; if there are not enough frames, unallocated strings are set to NULL. Returns -1 if the message could not be read, else returns the number of strings filled, zero or more. Free each returned string using zstr_free(). If not enough strings are provided, remaining multipart frames in the message are dropped. ``` string my_zstr.recvCompress (Zsock) ``` De-compress and receive C string from socket, received as a message with two frames: size of the uncompressed string, and the string itself. Caller must free returned string using zstr_free(). Returns NULL if the context is being terminated or the process was interrupted. ``` integer my_zstr.send (Zsock, String) ``` Send a C string to a socket, as a frame. The string is sent without trailing null byte; to read this you can use zstr_recv, or a similar method that adds a null terminator on the received string. String may be NULL, which is sent as "". ``` integer my_zstr.sendm (Zsock, String) ``` Send a C string to a socket, as zstr_send(), with a MORE flag, so that you can send further strings in the same multi-part message. ``` integer my_zstr.sendf (Zsock, String) ``` Send a formatted string to a socket. Note that you should NOT use user-supplied strings in the format (they may contain '%' which will create security holes). ``` integer my_zstr.sendfm (Zsock, String) ``` Send a formatted string to a socket, as for zstr_sendf(), with a MORE flag, so that you can send further strings in the same multi-part message. ``` integer my_zstr.sendx (Zsock, String) ``` Send a series of strings (until NULL) as multipart data Returns 0 if the strings could be sent OK, or -1 on error. ``` integer my_zstr.sendCompress (Zsock, String) ``` Compress and send a C string to a socket, as a message with two frames: size of the uncompressed string, and the string itself. The string is sent without trailing null byte; to read this you can use zstr_recv_compress, or a similar method that de-compresses and adds a null terminator on the received string. ``` integer my_zstr.sendmCompress (Zsock, String) ``` Compress and send a C string to a socket, as zstr_send_compress(), with a MORE flag, so that you can send further strings in the same multi-part message. ``` string my_zstr.str (Zsock) ``` Accepts a void pointer and returns a fresh character string. If source is null, returns an empty string. ``` nothing my_zstr.free (String) ``` Free a provided string, and nullify the parent pointer. Safe to call on a null pointer. ``` nothing my_zstr.test (Boolean) ``` Self test of this class. ### The Zsys class - Constructor: ``` var czmq = require ('bindings')('czmq') var my_zsys = new czmq.Zsys () ``` Methods: ``` nothing my_zsys.shutdown () ``` Optionally shut down the CZMQ zsys layer; this normally happens automatically when the process exits; however this call lets you force a shutdown earlier, avoiding any potential problems with atexit() ordering, especially with Windows dlls. ``` string my_zsys.sockname (Number) ``` Return ZMQ socket name for socket type *** This is for CZMQ internal use only and may change arbitrarily *** ``` zsock my_zsys.createPipe (Zsock) ``` Create a pipe, which consists of two PAIR sockets connected over inproc. The pipe is configured to use the zsys_pipehwm setting. Returns the frontend socket successful, NULL if failed. ``` nothing my_zsys.handlerReset () ``` Reset interrupt handler, call this at exit if needed ``` nothing my_zsys.catchInterrupts () ``` Set default interrupt handler, so Ctrl-C or SIGTERM will set zsys_interrupted. Idempotent; safe to call multiple times. Can be supressed by ZSYS_SIGHANDLER=false *** This is for CZMQ internal use only and may change arbitrarily *** ``` boolean my_zsys.fileExists (String) ``` Return 1 if file exists, else zero ``` time my_zsys.fileModified (String) ``` Return file modification time. Returns 0 if the file does not exist. ``` integer my_zsys.fileMode (String) ``` Return file mode; provides at least support for the POSIX S_ISREG(m) and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. Returns a mode_t cast to int, or -1 in case of error. ``` integer my_zsys.fileDelete (String) ``` Delete file. Does not complain if the file is absent ``` boolean my_zsys.fileStable (String) ``` Check if file is 'stable' ``` integer my_zsys.dirCreate (String) ``` Create a file path if it doesn't exist. The file path is treated as printf format. ``` integer my_zsys.dirDelete (String) ``` Remove a file path if empty; the pathname is treated as printf format. ``` integer my_zsys.dirChange (String) ``` Move to a specified working directory. Returns 0 if OK, -1 if this failed. ``` nothing my_zsys.fileModePrivate () ``` Set private file creation mode; all files created from here will be readable/writable by the owner only. ``` nothing my_zsys.fileModeDefault () ``` Reset default file creation mode; all files created from here will use process file mode defaults. ``` nothing my_zsys.version (Number, Number, Number) ``` Return the CZMQ version for run-time API detection; returns version number into provided fields, providing reference isn't null in each case. ``` string my_zsys.sprintf (String) ``` 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(). ``` nothing my_zsys.socketError (String) ``` Handle an I/O error on some socket operation; will report and die on fatal errors, and continue silently on "try again" errors. *** This is for CZMQ internal use only and may change arbitrarily *** ``` string my_zsys.hostname () ``` Return current host name, for use in public tcp:// endpoints. Caller gets a freshly allocated string, should free it using zstr_free(). If the host name is not resolvable, returns NULL. ``` integer my_zsys.daemonize (String) ``` Move the current process into the background. The precise effect depends on the operating system. On POSIX boxes, moves to a specified working directory (if specified), closes all file handles, reopens stdin, stdout, and stderr to the null device, and sets the process to ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there was an error. ``` integer my_zsys.runAs (String, String, String) ``` Drop the process ID into the lockfile, with exclusive lock, and switch the process to the specified group and/or user. Any of the arguments may be null, indicating a no-op. Returns 0 on success, -1 on failure. Note if you combine this with zsys_daemonize, run after, not before that method, or the lockfile will hold the wrong process ID. ``` boolean my_zsys.hasCurve () ``` Returns true if the underlying libzmq supports CURVE security. Uses a heuristic probe according to the version of libzmq being used. ``` nothing my_zsys.setIoThreads () ``` Configure the number of I/O threads that ZeroMQ will use. A good rule of thumb is one thread per gigabit of traffic in or out. The default is 1, sufficient for most applications. If the environment variable ZSYS_IO_THREADS is defined, that provides the default. Note that this method is valid only before any socket is created. ``` nothing my_zsys.setThreadSchedPolicy (Number) ``` Configure the scheduling policy of the ZMQ context thread pool. Not available on Windows. See the sched_setscheduler man page or sched.h for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY is defined, that provides the default. Note that this method is valid only before any socket is created. ``` nothing my_zsys.setThreadPriority (Number) ``` Configure the scheduling priority of the ZMQ context thread pool. Not available on Windows. See the sched_setscheduler man page or sched.h for more information. If the environment variable ZSYS_THREAD_PRIORITY is defined, that provides the default. Note that this method is valid only before any socket is created. ``` nothing my_zsys.setMaxSockets () ``` Configure the number of sockets that ZeroMQ will allow. The default is 1024. The actual limit depends on the system, and you can query it by using zsys_socket_limit (). A value of zero means "maximum". Note that this method is valid only before any socket is created. ``` size my_zsys.socketLimit () ``` Return maximum number of ZeroMQ sockets that the system will support. ``` nothing my_zsys.setMaxMsgsz (Number) ``` Configure the maximum allowed size of a message sent. The default is INT_MAX. ``` integer my_zsys.maxMsgsz () ``` Return maximum message size. ``` nothing my_zsys.setFileStableAgeMsec (Number) ``` Configure the threshold value of filesystem object age per st_mtime that should elapse until we consider that object "stable" at the current zclock_time() moment. The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c which generally depends on host OS, with fallback value of 5000. ``` msecs my_zsys.fileStableAgeMsec () ``` Return current threshold value of file stable age in msec. This can be used in code that chooses to wait for this timeout before testing if a filesystem object is "stable" or not. ``` nothing my_zsys.setLinger () ``` Configure the default linger timeout in msecs for new zsock instances. You can also set this separately on each zsock_t instance. The default linger time is zero, i.e. any pending messages will be dropped. If the environment variable ZSYS_LINGER is defined, that provides the default. Note that process exit will typically be delayed by the linger time. ``` nothing my_zsys.setSndhwm () ``` Configure the default outgoing pipe limit (HWM) for new zsock instances. You can also set this separately on each zsock_t instance. The default HWM is 1,000, on all versions of ZeroMQ. If the environment variable ZSYS_SNDHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. ``` nothing my_zsys.setRcvhwm () ``` Configure the default incoming pipe limit (HWM) for new zsock instances. You can also set this separately on each zsock_t instance. The default HWM is 1,000, on all versions of ZeroMQ. If the environment variable ZSYS_RCVHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. ``` nothing my_zsys.setPipehwm () ``` Configure the default HWM for zactor internal pipes; this is set on both ends of the pipe, for outgoing messages only (sndhwm). The default HWM is 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. ``` size my_zsys.pipehwm () ``` Return the HWM for zactor internal pipes. ``` nothing my_zsys.setIpv6 (Number) ``` Configure use of IPv6 for new zsock instances. By default sockets accept and make only IPv4 connections. When you enable IPv6, sockets will accept and connect to both IPv4 and IPv6 peers. You can override the setting on each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the default. Note: has no effect on ZMQ v2. ``` integer my_zsys.ipv6 () ``` Return use of IPv6 for zsock instances. ``` nothing my_zsys.setInterface (String) ``` Set network interface name to use for broadcasts, particularly zbeacon. This lets the interface be configured for test environments where required. For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is the default when there is no specified interface. If the environment variable ZSYS_INTERFACE is set, use that as the default interface name. Setting the interface to "*" means "use all available interfaces". ``` string my_zsys.interface () ``` Return network interface to use for broadcasts, or "" if none was set. ``` nothing my_zsys.setIpv6Address (String) ``` Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. This needs to be set IPv6 is enabled as IPv6 can have multiple addresses on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, use that as the default IPv6 address. ``` string my_zsys.ipv6Address () ``` Return IPv6 address to use for zbeacon reception, or "" if none was set. ``` nothing my_zsys.setIpv6McastAddress (String) ``` Set IPv6 milticast address to use for sending zbeacon messages. This needs to be set if IPv6 is enabled. If the environment variable ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast address. ``` string my_zsys.ipv6McastAddress () ``` Return IPv6 multicast address to use for sending zbeacon, or "" if none was set. ``` nothing my_zsys.setAutoUseFd (Number) ``` Configure the automatic use of pre-allocated FDs when creating new sockets. If 0 (default), nothing will happen. Else, when a new socket is bound, the system API will be used to check if an existing pre-allocated FD with a matching port (if TCP) or path (if IPC) exists, and if it does it will be set via the ZMQ_USE_FD socket option so that the library will use it instead of creating a new socket. ``` integer my_zsys.autoUseFd () ``` Return use of automatic pre-allocated FDs for zsock instances. ``` nothing my_zsys.setLogident (String) ``` Set log identity, which is a string that prefixes all log messages sent by this process. The log identity defaults to the environment variable ZSYS_LOGIDENT, if that is set. ``` nothing my_zsys.setLogsender (String) ``` Sends log output to a PUB socket bound to the specified endpoint. To collect such log output, create a SUB socket, subscribe to the traffic you care about, and connect to the endpoint. Log traffic is sent as a single string frame, in the same format as when sent to stdout. The log system supports a single sender; multiple calls to this method will bind the same sender to multiple endpoints. To disable the sender, call this method with a null argument. ``` nothing my_zsys.setLogsystem (Boolean) ``` Enable or disable logging to the system facility (syslog on POSIX boxes, event log on Windows). By default this is disabled. ``` nothing my_zsys.error (String) ``` Log error condition - highest priority ``` nothing my_zsys.warning (String) ``` Log warning condition - high priority ``` nothing my_zsys.notice (String) ``` Log normal, but significant, condition - normal priority ``` nothing my_zsys.info (String) ``` Log informational message - low priority ``` nothing my_zsys.debug (String) ``` Log debug-level message - lowest priority ``` nothing my_zsys.test (Boolean) ``` Self test of this class. ### The Ztimerset class - timer set Constructor: ``` var czmq = require ('bindings')('czmq') var my_ztimerset = new czmq.Ztimerset () ``` You *must* call the destructor on every Ztimerset instance: ``` my_ztimerset.destroy () ``` Methods: ``` integer my_ztimerset.cancel (Number) ``` Cancel a timer. Returns 0 if OK, -1 on failure. ``` integer my_ztimerset.setInterval (Number) ``` Set timer interval. Returns 0 if OK, -1 on failure. This method is slow, canceling the timer and adding a new one yield better performance. ``` integer my_ztimerset.reset (Number) ``` Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. This method is slow, canceling the timer and adding a new one yield better performance. ``` integer my_ztimerset.timeout () ``` Return the time until the next interval. Should be used as timeout parameter for the zpoller wait method. The timeout is in msec. ``` integer my_ztimerset.execute () ``` Invoke callback function of all timers which their interval has elapsed. Should be call after zpoller wait method. Returns 0 if OK, -1 on failure. ``` nothing my_ztimerset.test (Boolean) ``` Self test of this class. ### The Ztrie class - simple trie for tokenizable strings Constructor: ``` var czmq = require ('bindings')('czmq') var my_ztrie = new czmq.Ztrie (String) ``` You *must* call the destructor on every Ztrie instance: ``` my_ztrie.destroy () ``` Methods: ``` integer my_ztrie.removeRoute (String) ``` Removes a route from the trie and destroys its data. Returns -1 if the route does not exists, otherwise 0. the start of the list call zlist_first (). Advances the cursor. ``` boolean my_ztrie.matches (String) ``` Returns true if the path matches a route in the tree, otherwise false. ``` size my_ztrie.hitParameterCount () ``` Returns the count of parameters that a matched route has. ``` zhashx my_ztrie.hitParameters () ``` Returns the parameters of a matched route with named regexes from last ztrie_matches. If the path did not match or the route did not contain any named regexes, returns NULL. ``` string my_ztrie.hitAsteriskMatch () ``` Returns the asterisk matched part of a route, if there has been no match or no asterisk match, returns NULL. ``` nothing my_ztrie.print () ``` Print the trie ``` nothing my_ztrie.test (Boolean) ``` Self test of this class. ### The Zuuid class - UUID support class Constructor: ``` var czmq = require ('bindings')('czmq') var my_zuuid = new czmq.Zuuid () ``` You *must* call the destructor on every Zuuid instance: ``` my_zuuid.destroy () ``` Methods: ``` nothing my_zuuid.set (String) ``` Set UUID to new supplied ZUUID_LEN-octet value. ``` integer my_zuuid.setStr (String) ``` Set UUID to new supplied string value skipping '-' and '{' '}' optional delimiters. Return 0 if OK, else returns -1. ``` buffer my_zuuid.data () ``` Return UUID binary data. ``` size my_zuuid.size () ``` Return UUID binary size ``` string my_zuuid.str () ``` Returns UUID as string ``` string my_zuuid.strCanonical () ``` Return UUID in the canonical string format: 8-4-4-4-12, in lower case. Caller does not modify or free returned value. See http://en.wikipedia.org/wiki/Universally_unique_identifier ``` nothing my_zuuid.export (String) ``` Store UUID blob in target array ``` boolean my_zuuid.eq (String) ``` Check if UUID is same as supplied value ``` boolean my_zuuid.neq (String) ``` Check if UUID is different from supplied value ``` zuuid my_zuuid.dup () ``` Make copy of UUID object; if uuid is null, or memory was exhausted, returns null. ``` nothing my_zuuid.test (Boolean) ``` Self test of this class. czmq-4.1.0/bindings/nodejs/index.js0000664000372000037200000000177713222211156020123 0ustar00travistravis00000000000000/* CZMQ exported constants and other initializations Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ var czmq = require('bindings')('czmq') /** * Expose the czmq bindings as the module. */ module.exports = czmq; var types = { ZMQ_PAIR: 0, ZMQ_PUB: 1, ZMQ_SUB: 2, ZMQ_REQ: 3, ZMQ_REP: 4, ZMQ_DEALER: 5, ZMQ_ROUTER: 6, ZMQ_PULL: 7, ZMQ_PUSH: 8, ZMQ_XPUB: 9, ZMQ_XSUB: 10, ZMQ_STREAM: 11, ZMQ_SERVER: 12, ZMQ_CLIENT: 13, ZMQ_RADIO: 14, ZMQ_DISH: 15, }; Object.assign(module.exports, types); czmq-4.1.0/bindings/nodejs/build.sh0000775000372000037200000000443613222211156020107 0ustar00travistravis00000000000000#! /bin/bash # # Builds czmq.node package from a fresh git clone # ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ # set -e # exit on any error FORCE=0 VERBOSE=0 QUIET="--quiet" LOGLEVEL="--loglevel=error" for ARG in $*; do if [ "$ARG" == "--help" -o "$ARG" == "-h" ]; then echo "build.sh" echo " --help / -h This help" echo " --force / -f Force full rebuild" echo " --verbose / -v Show build output" echo " --xverbose / -x Extra verbose" exit elif [ "$ARG" == "--force" -o "$ARG" == "-f" ]; then FORCE=1 elif [ "$ARG" == "--verbose" -o "$ARG" == "-v" ]; then VERBOSE=1 QUIET="" LOGLEVEL="" elif [ "$ARG" == "--xverbose" -o "$ARG" == "-x" ]; then VERBOSE=1 QUIET="" LOGLEVEL="--loglevel=verbose" set -x fi done BUILD_ROOT=`pwd` cd ../../.. # Check dependent projects if [ ! -d libzmq ]; then echo "I: cloning https://github.com/zeromq/libzmq.git into `pwd`/libzmq..." git clone $QUIET https://github.com/zeromq/libzmq.git fi if [ ! -f libzmq/builds/gyp/project.gyp ]; then echo "E: `pwd`/libzmq out of date (builds/gyp/project.gyp missing)" exit fi # Check Node.js dependencies cd $BUILD_ROOT echo "I: checking Node.js dependencies..." failed=0 set +e for package in node-ninja bindings nan prebuild; do npm list --depth 1 $package > /dev/null 2>&1 if [ $? -eq 1 ]; then npm list --global --depth 1 $package > /dev/null 2>&1 if [ $? -eq 1 ]; then echo "E: $package isn't installed, run 'npm install [-g] $package'" failed=1 fi fi done test $failed -eq 0 || exit set -e # Calculate how many compiles we can do in parallel export JOBS=$([[ $(uname) = 'Darwin' ]] \ && sysctl -n hw.logicalcpu_max \ || lscpu -p | egrep -v '^#' | wc -l) # Build the binding using node-ninja directly, not prebuild echo "I: building Node.js binding:" node-ninja configure node-ninja build czmq-4.1.0/bindings/nodejs/.prebuildrc0000664000372000037200000000004613222211156020576 0ustar00travistravis00000000000000prebuild[] = 4.2.4 prebuild[] = 5.6.0 czmq-4.1.0/bindings/nodejs/test_binding.js0000664000372000037200000000211413222211156021447 0ustar00travistravis00000000000000/* ========================================================================= test_binding.js - hand-written test cases for NodeJS binding ------------------------------------------------------------------------- Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ var czmq = require ('bindings')('czmq') var zstr = new czmq.Zstr (); var server = new czmq.Zsock ('server') server.bind ("inproc://test-endpoint") var client = new czmq.Zsock (ZMQ_CLIENT) client.connect ("inproc://test-endpoint") zstr.send (client, "Hello") var request = zstr.recv (server) console.log (request) zstr.send (server, "World") var reply = zstr.recv (client) console.log (reply) server.destroy () client.destroy () czmq-4.1.0/bindings/nodejs/.gitignore0000664000372000037200000000013113222211156020425 0ustar00travistravis00000000000000node_modules build binding.Makefile *.mk out/ Makefile logs *.log npm-debug.log* libzmq/ czmq-4.1.0/bindings/nodejs/package.json0000664000372000037200000000106513222211156020732 0ustar00travistravis00000000000000{ "name": "czmq", "version": "0.0.1", "description": "The high-level C binding for 0MQ", "scripts": { "install": "prebuild --install", "test": "echo \"Error: no test specified\" && exit 1", "rebuild": "prebuild --compile", "prebuild": "prebuild --strip --verbose" }, "main": "index", "author": "See AUTHORS", "license": "MPL-2.0", "gypfile": true, "repository": { "type": "git", "url": "" }, "dependencies": { "bindings": "^1.2.1", "nan": "^2.2.0", "node-ninja": "^1.0.1", "prebuild": "^3.0.3" } } czmq-4.1.0/bindings/nodejs/binding.gyp0000664000372000037200000000231513222211156020576 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ # GYP file for CZMQ Node.js binding { 'targets': [ { 'target_name': 'czmq', 'sources': [ 'binding.cc' ], 'include_dirs': [ " &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_progname); static NAN_METHOD (_arguments); static NAN_METHOD (_first); static NAN_METHOD (_next); static NAN_METHOD (_param_first); static NAN_METHOD (_param_next); static NAN_METHOD (_param_name); static NAN_METHOD (_param_lookup); static NAN_METHOD (_param_lookupx); static NAN_METHOD (_has_help); static NAN_METHOD (_param_empty); static NAN_METHOD (_print); static NAN_METHOD (_test); }; class Zarmour: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zarmour (void); explicit Zarmour (zarmour_t *self); zarmour_t *self; private: ~Zarmour (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_encode); static NAN_METHOD (_decode); static NAN_METHOD (_mode); static NAN_METHOD (_mode_str); static NAN_METHOD (_set_mode); static NAN_METHOD (_pad); static NAN_METHOD (_set_pad); static NAN_METHOD (_pad_char); static NAN_METHOD (_set_pad_char); static NAN_METHOD (_line_breaks); static NAN_METHOD (_set_line_breaks); static NAN_METHOD (_line_length); static NAN_METHOD (_set_line_length); static NAN_METHOD (_print); static NAN_METHOD (_test); }; class Zcert: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zcert (void); explicit Zcert (zcert_t *self); zcert_t *self; private: ~Zcert (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_public_key); static NAN_METHOD (_secret_key); static NAN_METHOD (_public_txt); static NAN_METHOD (_secret_txt); static NAN_METHOD (_set_meta); static NAN_METHOD (_unset_meta); static NAN_METHOD (_meta); static NAN_METHOD (_meta_keys); static NAN_METHOD (_save); static NAN_METHOD (_save_public); static NAN_METHOD (_save_secret); static NAN_METHOD (_apply); static NAN_METHOD (_dup); static NAN_METHOD (_eq); static NAN_METHOD (_print); static NAN_METHOD (_test); }; class Zcertstore: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zcertstore (const char *location); explicit Zcertstore (zcertstore_t *self); zcertstore_t *self; private: ~Zcertstore (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_lookup); static NAN_METHOD (_insert); static NAN_METHOD (_empty); static NAN_METHOD (_print); static NAN_METHOD (_certs); static NAN_METHOD (_test); }; class Zchunk: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zchunk (const void *data, size_t size); explicit Zchunk (zchunk_t *self); zchunk_t *self; private: ~Zchunk (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_resize); static NAN_METHOD (_size); static NAN_METHOD (_max_size); static NAN_METHOD (_data); static NAN_METHOD (_set); static NAN_METHOD (_append); static NAN_METHOD (_extend); static NAN_METHOD (_consume); static NAN_METHOD (_exhausted); static NAN_METHOD (_slurp); static NAN_METHOD (_dup); static NAN_METHOD (_strhex); static NAN_METHOD (_strdup); static NAN_METHOD (_streq); static NAN_METHOD (_pack); static NAN_METHOD (_unpack); static NAN_METHOD (_digest); static NAN_METHOD (_print); static NAN_METHOD (_test); }; class Zclock: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zclock (); private: ~Zclock (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (_sleep); static NAN_METHOD (_time); static NAN_METHOD (_mono); static NAN_METHOD (_usecs); static NAN_METHOD (_timestr); static NAN_METHOD (_test); }; class Zconfig: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zconfig (const char *name, zconfig_t *parent); explicit Zconfig (zconfig_t *self); zconfig_t *self; private: ~Zconfig (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_name); static NAN_METHOD (_value); static NAN_METHOD (_put); static NAN_METHOD (_putf); static NAN_METHOD (_get); static NAN_METHOD (_set_name); static NAN_METHOD (_set_value); static NAN_METHOD (_child); static NAN_METHOD (_next); static NAN_METHOD (_locate); static NAN_METHOD (_at_depth); static NAN_METHOD (_set_comment); static NAN_METHOD (_comments); static NAN_METHOD (_save); static NAN_METHOD (_savef); static NAN_METHOD (_filename); static NAN_METHOD (_reload); static NAN_METHOD (_chunk_load); static NAN_METHOD (_chunk_save); static NAN_METHOD (_str_load); static NAN_METHOD (_str_save); static NAN_METHOD (_has_changed); static NAN_METHOD (_remove_subtree); static NAN_METHOD (_remove); static NAN_METHOD (_print); static NAN_METHOD (_test); }; class Zdigest: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zdigest (void); explicit Zdigest (zdigest_t *self); zdigest_t *self; private: ~Zdigest (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_update); static NAN_METHOD (_data); static NAN_METHOD (_size); static NAN_METHOD (_string); static NAN_METHOD (_test); }; class Zdir: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zdir (const char *path, const char *parent); explicit Zdir (zdir_t *self); zdir_t *self; private: ~Zdir (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_path); static NAN_METHOD (_modified); static NAN_METHOD (_cursize); static NAN_METHOD (_count); static NAN_METHOD (_list); static NAN_METHOD (_remove); static NAN_METHOD (_diff); static NAN_METHOD (_resync); static NAN_METHOD (_cache); static NAN_METHOD (_print); static NAN_METHOD (_test); }; class ZdirPatch: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit ZdirPatch (const char *path, zfile_t *file, int op, const char *alias); explicit ZdirPatch (zdir_patch_t *self); zdir_patch_t *self; private: ~ZdirPatch (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_dup); static NAN_METHOD (_path); static NAN_METHOD (_file); static NAN_METHOD (_op); static NAN_METHOD (_vpath); static NAN_METHOD (_digest_set); static NAN_METHOD (_digest); static NAN_METHOD (_test); }; class Zfile: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zfile (const char *path, const char *name); explicit Zfile (zfile_t *self); zfile_t *self; private: ~Zfile (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_dup); static NAN_METHOD (_filename); static NAN_METHOD (_restat); static NAN_METHOD (_modified); static NAN_METHOD (_cursize); static NAN_METHOD (_is_directory); static NAN_METHOD (_is_regular); static NAN_METHOD (_is_readable); static NAN_METHOD (_is_writeable); static NAN_METHOD (_is_stable); static NAN_METHOD (_has_changed); static NAN_METHOD (_remove); static NAN_METHOD (_input); static NAN_METHOD (_output); static NAN_METHOD (_read); static NAN_METHOD (_eof); static NAN_METHOD (_write); static NAN_METHOD (_readln); static NAN_METHOD (_close); static NAN_METHOD (_digest); static NAN_METHOD (_test); }; class Zframe: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zframe (const void *data, size_t size); explicit Zframe (zframe_t *self); zframe_t *self; private: ~Zframe (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_send); static NAN_METHOD (_size); static NAN_METHOD (_data); static NAN_METHOD (_meta); static NAN_METHOD (_dup); static NAN_METHOD (_strhex); static NAN_METHOD (_strdup); static NAN_METHOD (_streq); static NAN_METHOD (_more); static NAN_METHOD (_set_more); static NAN_METHOD (_routing_id); static NAN_METHOD (_set_routing_id); static NAN_METHOD (_group); static NAN_METHOD (_set_group); static NAN_METHOD (_eq); static NAN_METHOD (_reset); static NAN_METHOD (_print); static NAN_METHOD (_test); }; class Zhash: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zhash (void); explicit Zhash (zhash_t *self); zhash_t *self; private: ~Zhash (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_delete); static NAN_METHOD (_rename); static NAN_METHOD (_size); static NAN_METHOD (_dup); static NAN_METHOD (_keys); static NAN_METHOD (_cursor); static NAN_METHOD (_comment); static NAN_METHOD (_pack); static NAN_METHOD (_save); static NAN_METHOD (_load); static NAN_METHOD (_refresh); static NAN_METHOD (_autofree); static NAN_METHOD (_test); }; class Zhashx: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zhashx (void); explicit Zhashx (zhashx_t *self); zhashx_t *self; private: ~Zhashx (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_purge); static NAN_METHOD (_size); static NAN_METHOD (_keys); static NAN_METHOD (_values); static NAN_METHOD (_comment); static NAN_METHOD (_save); static NAN_METHOD (_load); static NAN_METHOD (_refresh); static NAN_METHOD (_pack); static NAN_METHOD (_dup); static NAN_METHOD (_dup_v2); static NAN_METHOD (_test); }; class Ziflist: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Ziflist (void); explicit Ziflist (ziflist_t *self); ziflist_t *self; private: ~Ziflist (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_reload); static NAN_METHOD (_size); static NAN_METHOD (_first); static NAN_METHOD (_next); static NAN_METHOD (_address); static NAN_METHOD (_broadcast); static NAN_METHOD (_netmask); static NAN_METHOD (_print); static NAN_METHOD (_new_ipv6); static NAN_METHOD (_reload_ipv6); static NAN_METHOD (_is_ipv6); static NAN_METHOD (_test); }; class Zlist: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zlist (void); explicit Zlist (zlist_t *self); zlist_t *self; private: ~Zlist (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_dup); static NAN_METHOD (_purge); static NAN_METHOD (_size); static NAN_METHOD (_autofree); static NAN_METHOD (_test); }; class Zlistx: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zlistx (void); explicit Zlistx (zlistx_t *self); zlistx_t *self; private: ~Zlistx (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_size); static NAN_METHOD (_purge); static NAN_METHOD (_sort); static NAN_METHOD (_dup); static NAN_METHOD (_test); }; class Zloop: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zloop (void); explicit Zloop (zloop_t *self); zloop_t *self; private: ~Zloop (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_reader_end); static NAN_METHOD (_reader_set_tolerant); static NAN_METHOD (_timer_end); static NAN_METHOD (_set_ticket_delay); static NAN_METHOD (_set_max_timers); static NAN_METHOD (_set_verbose); static NAN_METHOD (_set_nonstop); static NAN_METHOD (_start); static NAN_METHOD (_test); }; class Zmsg: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zmsg (void); explicit Zmsg (zmsg_t *self); zmsg_t *self; private: ~Zmsg (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_send); static NAN_METHOD (_sendm); static NAN_METHOD (_size); static NAN_METHOD (_content_size); static NAN_METHOD (_routing_id); static NAN_METHOD (_set_routing_id); static NAN_METHOD (_prepend); static NAN_METHOD (_append); static NAN_METHOD (_pop); static NAN_METHOD (_pushmem); static NAN_METHOD (_addmem); static NAN_METHOD (_pushstr); static NAN_METHOD (_addstr); static NAN_METHOD (_pushstrf); static NAN_METHOD (_addstrf); static NAN_METHOD (_popstr); static NAN_METHOD (_addmsg); static NAN_METHOD (_popmsg); static NAN_METHOD (_remove); static NAN_METHOD (_first); static NAN_METHOD (_next); static NAN_METHOD (_last); static NAN_METHOD (_encode); static NAN_METHOD (_dup); static NAN_METHOD (_print); static NAN_METHOD (_eq); static NAN_METHOD (_signal); static NAN_METHOD (_test); }; class Zpoller: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zpoller (zsock_t *reader); explicit Zpoller (zpoller_t *self); zpoller_t *self; private: ~Zpoller (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_add); static NAN_METHOD (_set_nonstop); static NAN_METHOD (_expired); static NAN_METHOD (_terminated); static NAN_METHOD (_test); }; class Zproc: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zproc (void); explicit Zproc (zproc_t *self); zproc_t *self; private: ~Zproc (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_set_args); static NAN_METHOD (_set_env); static NAN_METHOD (_run); static NAN_METHOD (_returncode); static NAN_METHOD (_pid); static NAN_METHOD (_running); static NAN_METHOD (_wait); static NAN_METHOD (_kill); static NAN_METHOD (_set_verbose); static NAN_METHOD (_czmq_version); static NAN_METHOD (_interrupted); static NAN_METHOD (_has_curve); static NAN_METHOD (_hostname); static NAN_METHOD (_daemonize); static NAN_METHOD (_run_as); static NAN_METHOD (_set_io_threads); static NAN_METHOD (_set_max_sockets); static NAN_METHOD (_set_biface); static NAN_METHOD (_biface); static NAN_METHOD (_set_log_ident); static NAN_METHOD (_set_log_sender); static NAN_METHOD (_set_log_system); static NAN_METHOD (_log_error); static NAN_METHOD (_log_warning); static NAN_METHOD (_log_notice); static NAN_METHOD (_log_info); static NAN_METHOD (_log_debug); static NAN_METHOD (_test); }; class Zsock: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zsock (int type); explicit Zsock (zsock_t *self); zsock_t *self; private: ~Zsock (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_bind); static NAN_METHOD (_endpoint); static NAN_METHOD (_unbind); static NAN_METHOD (_connect); static NAN_METHOD (_disconnect); static NAN_METHOD (_attach); static NAN_METHOD (_type_str); static NAN_METHOD (_send); static NAN_METHOD (_recv); static NAN_METHOD (_bsend); static NAN_METHOD (_brecv); static NAN_METHOD (_routing_id); static NAN_METHOD (_set_routing_id); static NAN_METHOD (_set_unbounded); static NAN_METHOD (_wait); static NAN_METHOD (_flush); static NAN_METHOD (_join); static NAN_METHOD (_leave); static NAN_METHOD (_heartbeat_ivl); static NAN_METHOD (_set_heartbeat_ivl); static NAN_METHOD (_heartbeat_ttl); static NAN_METHOD (_set_heartbeat_ttl); static NAN_METHOD (_heartbeat_timeout); static NAN_METHOD (_set_heartbeat_timeout); static NAN_METHOD (_use_fd); static NAN_METHOD (_set_use_fd); static NAN_METHOD (_set_xpub_manual); static NAN_METHOD (_set_xpub_welcome_msg); static NAN_METHOD (_set_stream_notify); static NAN_METHOD (_invert_matching); static NAN_METHOD (_set_invert_matching); static NAN_METHOD (_set_xpub_verboser); static NAN_METHOD (_connect_timeout); static NAN_METHOD (_set_connect_timeout); static NAN_METHOD (_tcp_maxrt); static NAN_METHOD (_set_tcp_maxrt); static NAN_METHOD (_thread_safe); static NAN_METHOD (_multicast_maxtpdu); static NAN_METHOD (_set_multicast_maxtpdu); static NAN_METHOD (_vmci_buffer_size); static NAN_METHOD (_set_vmci_buffer_size); static NAN_METHOD (_vmci_buffer_min_size); static NAN_METHOD (_set_vmci_buffer_min_size); static NAN_METHOD (_vmci_buffer_max_size); static NAN_METHOD (_set_vmci_buffer_max_size); static NAN_METHOD (_vmci_connect_timeout); static NAN_METHOD (_set_vmci_connect_timeout); static NAN_METHOD (_tos); static NAN_METHOD (_set_tos); static NAN_METHOD (_set_router_handover); static NAN_METHOD (_set_connect_rid); static NAN_METHOD (_set_connect_rid_bin); static NAN_METHOD (_handshake_ivl); static NAN_METHOD (_set_handshake_ivl); static NAN_METHOD (_socks_proxy); static NAN_METHOD (_set_socks_proxy); static NAN_METHOD (_set_xpub_nodrop); static NAN_METHOD (_set_router_mandatory); static NAN_METHOD (_set_probe_router); static NAN_METHOD (_set_req_relaxed); static NAN_METHOD (_set_req_correlate); static NAN_METHOD (_set_conflate); static NAN_METHOD (_zap_domain); static NAN_METHOD (_set_zap_domain); static NAN_METHOD (_mechanism); static NAN_METHOD (_plain_server); static NAN_METHOD (_set_plain_server); static NAN_METHOD (_plain_username); static NAN_METHOD (_set_plain_username); static NAN_METHOD (_plain_password); static NAN_METHOD (_set_plain_password); static NAN_METHOD (_curve_server); static NAN_METHOD (_set_curve_server); static NAN_METHOD (_curve_publickey); static NAN_METHOD (_set_curve_publickey); static NAN_METHOD (_set_curve_publickey_bin); static NAN_METHOD (_curve_secretkey); static NAN_METHOD (_set_curve_secretkey); static NAN_METHOD (_set_curve_secretkey_bin); static NAN_METHOD (_curve_serverkey); static NAN_METHOD (_set_curve_serverkey); static NAN_METHOD (_set_curve_serverkey_bin); static NAN_METHOD (_gssapi_server); static NAN_METHOD (_set_gssapi_server); static NAN_METHOD (_gssapi_plaintext); static NAN_METHOD (_set_gssapi_plaintext); static NAN_METHOD (_gssapi_principal); static NAN_METHOD (_set_gssapi_principal); static NAN_METHOD (_gssapi_service_principal); static NAN_METHOD (_set_gssapi_service_principal); static NAN_METHOD (_ipv6); static NAN_METHOD (_set_ipv6); static NAN_METHOD (_immediate); static NAN_METHOD (_set_immediate); static NAN_METHOD (_sndhwm); static NAN_METHOD (_set_sndhwm); static NAN_METHOD (_rcvhwm); static NAN_METHOD (_set_rcvhwm); static NAN_METHOD (_maxmsgsize); static NAN_METHOD (_set_maxmsgsize); static NAN_METHOD (_multicast_hops); static NAN_METHOD (_set_multicast_hops); static NAN_METHOD (_set_xpub_verbose); static NAN_METHOD (_tcp_keepalive); static NAN_METHOD (_set_tcp_keepalive); static NAN_METHOD (_tcp_keepalive_idle); static NAN_METHOD (_set_tcp_keepalive_idle); static NAN_METHOD (_tcp_keepalive_cnt); static NAN_METHOD (_set_tcp_keepalive_cnt); static NAN_METHOD (_tcp_keepalive_intvl); static NAN_METHOD (_set_tcp_keepalive_intvl); static NAN_METHOD (_tcp_accept_filter); static NAN_METHOD (_set_tcp_accept_filter); static NAN_METHOD (_last_endpoint); static NAN_METHOD (_set_router_raw); static NAN_METHOD (_ipv4only); static NAN_METHOD (_set_ipv4only); static NAN_METHOD (_set_delay_attach_on_connect); static NAN_METHOD (_hwm); static NAN_METHOD (_set_hwm); static NAN_METHOD (_swap); static NAN_METHOD (_set_swap); static NAN_METHOD (_affinity); static NAN_METHOD (_set_affinity); static NAN_METHOD (_identity); static NAN_METHOD (_set_identity); static NAN_METHOD (_rate); static NAN_METHOD (_set_rate); static NAN_METHOD (_recovery_ivl); static NAN_METHOD (_set_recovery_ivl); static NAN_METHOD (_recovery_ivl_msec); static NAN_METHOD (_set_recovery_ivl_msec); static NAN_METHOD (_mcast_loop); static NAN_METHOD (_set_mcast_loop); static NAN_METHOD (_rcvtimeo); static NAN_METHOD (_set_rcvtimeo); static NAN_METHOD (_sndtimeo); static NAN_METHOD (_set_sndtimeo); static NAN_METHOD (_sndbuf); static NAN_METHOD (_set_sndbuf); static NAN_METHOD (_rcvbuf); static NAN_METHOD (_set_rcvbuf); static NAN_METHOD (_linger); static NAN_METHOD (_set_linger); static NAN_METHOD (_reconnect_ivl); static NAN_METHOD (_set_reconnect_ivl); static NAN_METHOD (_reconnect_ivl_max); static NAN_METHOD (_set_reconnect_ivl_max); static NAN_METHOD (_backlog); static NAN_METHOD (_set_backlog); static NAN_METHOD (_set_subscribe); static NAN_METHOD (_set_unsubscribe); static NAN_METHOD (_type); static NAN_METHOD (_rcvmore); static NAN_METHOD (_events); static NAN_METHOD (_test); }; class Zstr: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zstr (); private: ~Zstr (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (_recv); static NAN_METHOD (_recvx); static NAN_METHOD (_recv_compress); static NAN_METHOD (_send); static NAN_METHOD (_sendm); static NAN_METHOD (_sendf); static NAN_METHOD (_sendfm); static NAN_METHOD (_sendx); static NAN_METHOD (_send_compress); static NAN_METHOD (_sendm_compress); static NAN_METHOD (_str); static NAN_METHOD (_free); static NAN_METHOD (_test); }; class Zsys: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zsys (); private: ~Zsys (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (_shutdown); static NAN_METHOD (_sockname); static NAN_METHOD (_create_pipe); static NAN_METHOD (_handler_reset); static NAN_METHOD (_catch_interrupts); static NAN_METHOD (_file_exists); static NAN_METHOD (_file_modified); static NAN_METHOD (_file_mode); static NAN_METHOD (_file_delete); static NAN_METHOD (_file_stable); static NAN_METHOD (_dir_create); static NAN_METHOD (_dir_delete); static NAN_METHOD (_dir_change); static NAN_METHOD (_file_mode_private); static NAN_METHOD (_file_mode_default); static NAN_METHOD (_version); static NAN_METHOD (_sprintf); static NAN_METHOD (_socket_error); static NAN_METHOD (_hostname); static NAN_METHOD (_daemonize); static NAN_METHOD (_run_as); static NAN_METHOD (_has_curve); static NAN_METHOD (_set_io_threads); static NAN_METHOD (_set_thread_sched_policy); static NAN_METHOD (_set_thread_priority); static NAN_METHOD (_set_max_sockets); static NAN_METHOD (_socket_limit); static NAN_METHOD (_set_max_msgsz); static NAN_METHOD (_max_msgsz); static NAN_METHOD (_set_file_stable_age_msec); static NAN_METHOD (_file_stable_age_msec); static NAN_METHOD (_set_linger); static NAN_METHOD (_set_sndhwm); static NAN_METHOD (_set_rcvhwm); static NAN_METHOD (_set_pipehwm); static NAN_METHOD (_pipehwm); static NAN_METHOD (_set_ipv6); static NAN_METHOD (_ipv6); static NAN_METHOD (_set_interface); static NAN_METHOD (_interface); static NAN_METHOD (_set_ipv6_address); static NAN_METHOD (_ipv6_address); static NAN_METHOD (_set_ipv6_mcast_address); static NAN_METHOD (_ipv6_mcast_address); static NAN_METHOD (_set_auto_use_fd); static NAN_METHOD (_auto_use_fd); static NAN_METHOD (_set_logident); static NAN_METHOD (_set_logsender); static NAN_METHOD (_set_logsystem); static NAN_METHOD (_error); static NAN_METHOD (_warning); static NAN_METHOD (_notice); static NAN_METHOD (_info); static NAN_METHOD (_debug); static NAN_METHOD (_test); }; class Ztimerset: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Ztimerset (void); explicit Ztimerset (ztimerset_t *self); ztimerset_t *self; private: ~Ztimerset (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_cancel); static NAN_METHOD (_set_interval); static NAN_METHOD (_reset); static NAN_METHOD (_timeout); static NAN_METHOD (_execute); static NAN_METHOD (_test); }; class Ztrie: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Ztrie (char delimiter); explicit Ztrie (ztrie_t *self); ztrie_t *self; private: ~Ztrie (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_remove_route); static NAN_METHOD (_matches); static NAN_METHOD (_hit_parameter_count); static NAN_METHOD (_hit_parameters); static NAN_METHOD (_hit_asterisk_match); static NAN_METHOD (_print); static NAN_METHOD (_test); }; class Zuuid: public Nan::ObjectWrap { public: static NAN_MODULE_INIT (Init); explicit Zuuid (void); explicit Zuuid (zuuid_t *self); zuuid_t *self; private: ~Zuuid (); static Nan::Persistent &constructor (); static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); static NAN_METHOD (_set); static NAN_METHOD (_set_str); static NAN_METHOD (_data); static NAN_METHOD (_size); static NAN_METHOD (_str); static NAN_METHOD (_str_canonical); static NAN_METHOD (_export); static NAN_METHOD (_eq); static NAN_METHOD (_neq); static NAN_METHOD (_dup); static NAN_METHOD (_test); }; #endif czmq-4.1.0/bindings/nodejs/binding.cc0000664000372000037200000111521313222211156020367 0ustar00travistravis00000000000000/* ========================================================================= CZMQ Node.js binding implementation Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ ========================================================================= */ #include "binding.h" using namespace v8; using namespace Nan; NAN_MODULE_INIT (Zargs::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zargs").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "progname", _progname); Nan::SetPrototypeMethod (tpl, "arguments", _arguments); Nan::SetPrototypeMethod (tpl, "first", _first); Nan::SetPrototypeMethod (tpl, "next", _next); Nan::SetPrototypeMethod (tpl, "paramFirst", _param_first); Nan::SetPrototypeMethod (tpl, "paramNext", _param_next); Nan::SetPrototypeMethod (tpl, "paramName", _param_name); Nan::SetPrototypeMethod (tpl, "paramLookup", _param_lookup); Nan::SetPrototypeMethod (tpl, "paramLookupx", _param_lookupx); Nan::SetPrototypeMethod (tpl, "hasHelp", _has_help); Nan::SetPrototypeMethod (tpl, "paramEmpty", _param_empty); Nan::SetPrototypeMethod (tpl, "print", _print); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zargs").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zargs::Zargs (int argc, char **argv) { self = zargs_new ((int) argc, (char **)&argv); } Zargs::Zargs (zargs_t *self_) { self = self_; } Zargs::~Zargs () { } NAN_METHOD (Zargs::New) { assert (info.IsConstructCall ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `argc`"); //int argc; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int argc; if (info [0]->IsNumber ()) { argc = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`argc` must be a number"); char *argv; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `argv`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`argv` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String argv_utf8 (info [1].As()); argv = *argv_utf8; //} //bjornw end Zargs *zargs = new Zargs ((int) argc, (char **)&argv); if (zargs) { zargs->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zargs::destroy) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); zargs_destroy (&zargs->self); } NAN_METHOD (Zargs::defined) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zargs->self != NULL)); } NAN_METHOD (Zargs::_progname) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zargs_progname (zargs->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zargs::_arguments) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zargs_arguments (zargs->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zargs::_first) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zargs_first (zargs->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zargs::_next) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zargs_next (zargs->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zargs::_param_first) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zargs_param_first (zargs->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zargs::_param_next) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zargs_param_next (zargs->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zargs::_param_name) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zargs_param_name (zargs->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zargs::_param_lookup) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); char *keys; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `keys`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`keys` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String keys_utf8 (info [0].As()); keys = *keys_utf8; //} //bjornw end char *result = (char *) zargs_param_lookup (zargs->self, (const char *)keys); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zargs::_param_lookupx) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); char *keys; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `keys`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`keys` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String keys_utf8 (info [0].As()); keys = *keys_utf8; //} //bjornw end char *result = (char *) zargs_param_lookupx (zargs->self, (const char *)keys); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zargs::_has_help) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zargs_has_help (zargs->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zargs::_param_empty) { char *arg; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `arg`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`arg` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String arg_utf8 (info [0].As()); arg = *arg_utf8; //} //bjornw end bool result = zargs_param_empty ((const char *)arg); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zargs::_print) { Zargs *zargs = Nan::ObjectWrap::Unwrap (info.Holder ()); zargs_print (zargs->self); } NAN_METHOD (Zargs::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zargs_test ((bool) verbose); } Nan::Persistent &Zargs::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zarmour::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zarmour").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "encode", _encode); Nan::SetPrototypeMethod (tpl, "decode", _decode); Nan::SetPrototypeMethod (tpl, "mode", _mode); Nan::SetPrototypeMethod (tpl, "modeStr", _mode_str); Nan::SetPrototypeMethod (tpl, "setMode", _set_mode); Nan::SetPrototypeMethod (tpl, "pad", _pad); Nan::SetPrototypeMethod (tpl, "setPad", _set_pad); Nan::SetPrototypeMethod (tpl, "padChar", _pad_char); Nan::SetPrototypeMethod (tpl, "setPadChar", _set_pad_char); Nan::SetPrototypeMethod (tpl, "lineBreaks", _line_breaks); Nan::SetPrototypeMethod (tpl, "setLineBreaks", _set_line_breaks); Nan::SetPrototypeMethod (tpl, "lineLength", _line_length); Nan::SetPrototypeMethod (tpl, "setLineLength", _set_line_length); Nan::SetPrototypeMethod (tpl, "print", _print); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zarmour").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zarmour::Zarmour (void) { self = zarmour_new (); } Zarmour::Zarmour (zarmour_t *self_) { self = self_; } Zarmour::~Zarmour () { } NAN_METHOD (Zarmour::New) { assert (info.IsConstructCall ()); Zarmour *zarmour = new Zarmour (); if (zarmour) { zarmour->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zarmour::destroy) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); zarmour_destroy (&zarmour->self); } NAN_METHOD (Zarmour::defined) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zarmour->self != NULL)); } NAN_METHOD (Zarmour::_encode) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *data = (const byte *) node::Buffer::Data (buffer_node); size_t size = node::Buffer::Length (buffer_node); char *result = (char *) zarmour_encode (zarmour->self, (const byte *)data, (size_t) size); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zarmour::_decode) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); char *data; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `data`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`data` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String data_utf8 (info [0].As()); data = *data_utf8; //} //bjornw end zchunk_t *result = zarmour_decode (zarmour->self, (const char *)data); Zchunk *zchunk_result = new Zchunk (result); if (zchunk_result) { // Don't yet know how to return a new object // zchunk->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zarmour::_mode) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zarmour_mode (zarmour->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zarmour::_mode_str) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zarmour_mode_str (zarmour->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zarmour::_set_mode) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `mode`"); //int mode; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int mode; if (info [0]->IsNumber ()) { mode = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`mode` must be a number"); zarmour_set_mode (zarmour->self, (int) mode); } NAN_METHOD (Zarmour::_pad) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zarmour_pad (zarmour->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zarmour::_set_pad) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `pad`"); //bool pad; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool pad; if (info [0]->IsBoolean ()) { pad = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`pad` must be a Boolean"); zarmour_set_pad (zarmour->self, (bool) pad); } NAN_METHOD (Zarmour::_pad_char) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); char result [2] = " "; result [0] = zarmour_pad_char (zarmour->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zarmour::_set_pad_char) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); char pad_char; if (info [0]->IsUndefined ()) { return Nan::ThrowTypeError ("method requires a `pad char`"); } else if (!info [0]->IsString ()) { return Nan::ThrowTypeError ("`pad char` must be a string"); } //else { // bjornw: remove brackets to keep scope Nan::Utf8String pad_char_utf8 (info [0].As()); if (strlen (*pad_char_utf8) != 1) return Nan::ThrowTypeError ("`pad char` must be a single character"); pad_char = (*pad_char_utf8) [0]; //} // bjornw end zarmour_set_pad_char (zarmour->self, (char) pad_char); } NAN_METHOD (Zarmour::_line_breaks) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zarmour_line_breaks (zarmour->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zarmour::_set_line_breaks) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `line breaks`"); //bool line_breaks; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool line_breaks; if (info [0]->IsBoolean ()) { line_breaks = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`line breaks` must be a Boolean"); zarmour_set_line_breaks (zarmour->self, (bool) line_breaks); } NAN_METHOD (Zarmour::_line_length) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zarmour_line_length (zarmour->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zarmour::_set_line_length) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `line length`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`line length` must be a number"); size_t line_length = Nan::To(info [0]).FromJust (); zarmour_set_line_length (zarmour->self, (size_t) line_length); } NAN_METHOD (Zarmour::_print) { Zarmour *zarmour = Nan::ObjectWrap::Unwrap (info.Holder ()); zarmour_print (zarmour->self); } NAN_METHOD (Zarmour::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zarmour_test ((bool) verbose); } Nan::Persistent &Zarmour::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zcert::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zcert").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "publicKey", _public_key); Nan::SetPrototypeMethod (tpl, "secretKey", _secret_key); Nan::SetPrototypeMethod (tpl, "publicTxt", _public_txt); Nan::SetPrototypeMethod (tpl, "secretTxt", _secret_txt); Nan::SetPrototypeMethod (tpl, "setMeta", _set_meta); Nan::SetPrototypeMethod (tpl, "unsetMeta", _unset_meta); Nan::SetPrototypeMethod (tpl, "meta", _meta); Nan::SetPrototypeMethod (tpl, "metaKeys", _meta_keys); Nan::SetPrototypeMethod (tpl, "save", _save); Nan::SetPrototypeMethod (tpl, "savePublic", _save_public); Nan::SetPrototypeMethod (tpl, "saveSecret", _save_secret); Nan::SetPrototypeMethod (tpl, "apply", _apply); Nan::SetPrototypeMethod (tpl, "dup", _dup); Nan::SetPrototypeMethod (tpl, "eq", _eq); Nan::SetPrototypeMethod (tpl, "print", _print); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zcert").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zcert::Zcert (void) { self = zcert_new (); } Zcert::Zcert (zcert_t *self_) { self = self_; } Zcert::~Zcert () { } NAN_METHOD (Zcert::New) { assert (info.IsConstructCall ()); Zcert *zcert = new Zcert (); if (zcert) { zcert->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zcert::destroy) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); zcert_destroy (&zcert->self); } NAN_METHOD (Zcert::defined) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zcert->self != NULL)); } NAN_METHOD (Zcert::_public_key) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); const char *result = (const char *) zcert_public_key (zcert->self); info.GetReturnValue().Set (Nan::CopyBuffer (result, 32).ToLocalChecked ()); } NAN_METHOD (Zcert::_secret_key) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); const char *result = (const char *) zcert_secret_key (zcert->self); info.GetReturnValue().Set (Nan::CopyBuffer (result, 32).ToLocalChecked ()); } NAN_METHOD (Zcert::_public_txt) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zcert_public_txt (zcert->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zcert::_secret_txt) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zcert_secret_txt (zcert->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zcert::_set_meta) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); char *name; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `name`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`name` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String name_utf8 (info [0].As()); name = *name_utf8; //} //bjornw end char *format; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [1].As()); format = *format_utf8; //} //bjornw end zcert_set_meta (zcert->self, (const char *)name, "%s", format); } NAN_METHOD (Zcert::_unset_meta) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); char *name; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `name`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`name` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String name_utf8 (info [0].As()); name = *name_utf8; //} //bjornw end zcert_unset_meta (zcert->self, (const char *)name); } NAN_METHOD (Zcert::_meta) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); char *name; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `name`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`name` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String name_utf8 (info [0].As()); name = *name_utf8; //} //bjornw end char *result = (char *) zcert_meta (zcert->self, (const char *)name); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zcert::_meta_keys) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); zlist_t *result = zcert_meta_keys (zcert->self); Zlist *zlist_result = new Zlist (result); if (zlist_result) { // Don't yet know how to return a new object // zlist->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zcert::_save) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end int result = zcert_save (zcert->self, (const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zcert::_save_public) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end int result = zcert_save_public (zcert->self, (const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zcert::_save_secret) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end int result = zcert_save_secret (zcert->self, (const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zcert::_apply) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); Zsock *socket = Nan::ObjectWrap::Unwrap(info [0].As()); zcert_apply (zcert->self, socket->self); } NAN_METHOD (Zcert::_dup) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); zcert_t *result = zcert_dup (zcert->self); Zcert *zcert_result = new Zcert (result); if (zcert_result) { // Don't yet know how to return a new object // zcert->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zcert::_eq) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); Zcert *compare = Nan::ObjectWrap::Unwrap(info [0].As()); bool result = zcert_eq (zcert->self, compare->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zcert::_print) { Zcert *zcert = Nan::ObjectWrap::Unwrap (info.Holder ()); zcert_print (zcert->self); } NAN_METHOD (Zcert::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zcert_test ((bool) verbose); } Nan::Persistent &Zcert::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zcertstore::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zcertstore").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "lookup", _lookup); Nan::SetPrototypeMethod (tpl, "insert", _insert); Nan::SetPrototypeMethod (tpl, "empty", _empty); Nan::SetPrototypeMethod (tpl, "print", _print); Nan::SetPrototypeMethod (tpl, "certs", _certs); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zcertstore").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zcertstore::Zcertstore (const char *location) { self = zcertstore_new ((const char *)location); } Zcertstore::Zcertstore (zcertstore_t *self_) { self = self_; } Zcertstore::~Zcertstore () { } NAN_METHOD (Zcertstore::New) { assert (info.IsConstructCall ()); char *location; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `location`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`location` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String location_utf8 (info [0].As()); location = *location_utf8; //} //bjornw end Zcertstore *zcertstore = new Zcertstore ((const char *)location); if (zcertstore) { zcertstore->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zcertstore::destroy) { Zcertstore *zcertstore = Nan::ObjectWrap::Unwrap (info.Holder ()); zcertstore_destroy (&zcertstore->self); } NAN_METHOD (Zcertstore::defined) { Zcertstore *zcertstore = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zcertstore->self != NULL)); } NAN_METHOD (Zcertstore::_lookup) { Zcertstore *zcertstore = Nan::ObjectWrap::Unwrap (info.Holder ()); char *public_key; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `public key`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`public key` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String public_key_utf8 (info [0].As()); public_key = *public_key_utf8; //} //bjornw end zcert_t *result = zcertstore_lookup (zcertstore->self, (const char *)public_key); Zcert *zcert_result = new Zcert (result); if (zcert_result) { // Don't yet know how to return a new object // zcert->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zcertstore::_insert) { Zcertstore *zcertstore = Nan::ObjectWrap::Unwrap (info.Holder ()); Zcert *cert_p = Nan::ObjectWrap::Unwrap(info [0].As()); zcertstore_insert (zcertstore->self, &cert_p->self); } NAN_METHOD (Zcertstore::_empty) { Zcertstore *zcertstore = Nan::ObjectWrap::Unwrap (info.Holder ()); zcertstore_empty (zcertstore->self); } NAN_METHOD (Zcertstore::_print) { Zcertstore *zcertstore = Nan::ObjectWrap::Unwrap (info.Holder ()); zcertstore_print (zcertstore->self); } NAN_METHOD (Zcertstore::_certs) { Zcertstore *zcertstore = Nan::ObjectWrap::Unwrap (info.Holder ()); zlistx_t *result = zcertstore_certs (zcertstore->self); Zlistx *zlistx_result = new Zlistx (result); if (zlistx_result) { // Don't yet know how to return a new object // zlistx->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zcertstore::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zcertstore_test ((bool) verbose); } Nan::Persistent &Zcertstore::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zchunk::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zchunk").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "resize", _resize); Nan::SetPrototypeMethod (tpl, "size", _size); Nan::SetPrototypeMethod (tpl, "maxSize", _max_size); Nan::SetPrototypeMethod (tpl, "data", _data); Nan::SetPrototypeMethod (tpl, "set", _set); Nan::SetPrototypeMethod (tpl, "append", _append); Nan::SetPrototypeMethod (tpl, "extend", _extend); Nan::SetPrototypeMethod (tpl, "consume", _consume); Nan::SetPrototypeMethod (tpl, "exhausted", _exhausted); Nan::SetPrototypeMethod (tpl, "slurp", _slurp); Nan::SetPrototypeMethod (tpl, "dup", _dup); Nan::SetPrototypeMethod (tpl, "strhex", _strhex); Nan::SetPrototypeMethod (tpl, "strdup", _strdup); Nan::SetPrototypeMethod (tpl, "streq", _streq); Nan::SetPrototypeMethod (tpl, "pack", _pack); Nan::SetPrototypeMethod (tpl, "unpack", _unpack); Nan::SetPrototypeMethod (tpl, "digest", _digest); Nan::SetPrototypeMethod (tpl, "print", _print); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zchunk").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zchunk::Zchunk (const void *data, size_t size) { self = zchunk_new ((const void *)data, (size_t) size); } Zchunk::Zchunk (zchunk_t *self_) { self = self_; } Zchunk::~Zchunk () { } NAN_METHOD (Zchunk::New) { assert (info.IsConstructCall ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *data = (const byte *) node::Buffer::Data (buffer_node); size_t size = node::Buffer::Length (buffer_node); Zchunk *zchunk = new Zchunk ((const void *)data, (size_t) size); if (zchunk) { zchunk->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zchunk::destroy) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); zchunk_destroy (&zchunk->self); } NAN_METHOD (Zchunk::defined) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zchunk->self != NULL)); } NAN_METHOD (Zchunk::_resize) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `size`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`size` must be a number"); size_t size = Nan::To(info [0]).FromJust (); zchunk_resize (zchunk->self, (size_t) size); } NAN_METHOD (Zchunk::_size) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zchunk_size (zchunk->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zchunk::_max_size) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zchunk_max_size (zchunk->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zchunk::_data) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); const char *result = (const char *) zchunk_data (zchunk->self); info.GetReturnValue().Set (Nan::CopyBuffer (result, zchunk_size (zchunk->self)).ToLocalChecked ()); } NAN_METHOD (Zchunk::_set) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *data = (const byte *) node::Buffer::Data (buffer_node); size_t size = node::Buffer::Length (buffer_node); size_t result = zchunk_set (zchunk->self, (const void *)data, (size_t) size); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zchunk::_append) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *data = (const byte *) node::Buffer::Data (buffer_node); size_t size = node::Buffer::Length (buffer_node); size_t result = zchunk_append (zchunk->self, (const void *)data, (size_t) size); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zchunk::_extend) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *data = (const byte *) node::Buffer::Data (buffer_node); size_t size = node::Buffer::Length (buffer_node); size_t result = zchunk_extend (zchunk->self, (const void *)data, (size_t) size); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zchunk::_consume) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); Zchunk *source = Nan::ObjectWrap::Unwrap(info [0].As()); size_t result = zchunk_consume (zchunk->self, source->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zchunk::_exhausted) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zchunk_exhausted (zchunk->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zchunk::_slurp) { char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `maxsize`"); else if (!info [1]->IsNumber ()) return Nan::ThrowTypeError ("`maxsize` must be a number"); size_t maxsize = Nan::To(info [1]).FromJust (); zchunk_t *result = zchunk_slurp ((const char *)filename, (size_t) maxsize); Zchunk *zchunk_result = new Zchunk (result); if (zchunk_result) { // Don't yet know how to return a new object // zchunk->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zchunk::_dup) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); zchunk_t *result = zchunk_dup (zchunk->self); Zchunk *zchunk_result = new Zchunk (result); if (zchunk_result) { // Don't yet know how to return a new object // zchunk->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zchunk::_strhex) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zchunk_strhex (zchunk->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zchunk::_strdup) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zchunk_strdup (zchunk->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zchunk::_streq) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); char *string; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `string`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`string` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String string_utf8 (info [0].As()); string = *string_utf8; //} //bjornw end bool result = zchunk_streq (zchunk->self, (const char *)string); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zchunk::_pack) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); zframe_t *result = zchunk_pack (zchunk->self); Zframe *zframe_result = new Zframe (result); if (zframe_result) { // Don't yet know how to return a new object // zframe->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zchunk::_unpack) { Zframe *frame = Nan::ObjectWrap::Unwrap(info [0].As()); zchunk_t *result = zchunk_unpack (frame->self); Zchunk *zchunk_result = new Zchunk (result); if (zchunk_result) { // Don't yet know how to return a new object // zchunk->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zchunk::_digest) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zchunk_digest (zchunk->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zchunk::_print) { Zchunk *zchunk = Nan::ObjectWrap::Unwrap (info.Holder ()); zchunk_print (zchunk->self); } NAN_METHOD (Zchunk::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zchunk_test ((bool) verbose); } Nan::Persistent &Zchunk::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zclock::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zclock").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "sleep", _sleep); Nan::SetPrototypeMethod (tpl, "time", _time); Nan::SetPrototypeMethod (tpl, "mono", _mono); Nan::SetPrototypeMethod (tpl, "usecs", _usecs); Nan::SetPrototypeMethod (tpl, "timestr", _timestr); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zclock").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zclock::Zclock () { } Zclock::~Zclock () { } NAN_METHOD (Zclock::New) { assert (info.IsConstructCall ()); Zclock *zclock = new Zclock (); if (zclock) { zclock->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zclock::_sleep) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `msecs`"); //int msecs; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int msecs; if (info [0]->IsNumber ()) { msecs = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`msecs` must be a number"); zclock_sleep ((int) msecs); } NAN_METHOD (Zclock::_time) { int64_t result = zclock_time (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zclock::_mono) { int64_t result = zclock_mono (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zclock::_usecs) { int64_t result = zclock_usecs (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zclock::_timestr) { char *result = (char *) zclock_timestr (); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zclock::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zclock_test ((bool) verbose); } Nan::Persistent &Zclock::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zconfig::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zconfig").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "name", _name); Nan::SetPrototypeMethod (tpl, "value", _value); Nan::SetPrototypeMethod (tpl, "put", _put); Nan::SetPrototypeMethod (tpl, "putf", _putf); Nan::SetPrototypeMethod (tpl, "get", _get); Nan::SetPrototypeMethod (tpl, "setName", _set_name); Nan::SetPrototypeMethod (tpl, "setValue", _set_value); Nan::SetPrototypeMethod (tpl, "child", _child); Nan::SetPrototypeMethod (tpl, "next", _next); Nan::SetPrototypeMethod (tpl, "locate", _locate); Nan::SetPrototypeMethod (tpl, "atDepth", _at_depth); Nan::SetPrototypeMethod (tpl, "setComment", _set_comment); Nan::SetPrototypeMethod (tpl, "comments", _comments); Nan::SetPrototypeMethod (tpl, "save", _save); Nan::SetPrototypeMethod (tpl, "savef", _savef); Nan::SetPrototypeMethod (tpl, "filename", _filename); Nan::SetPrototypeMethod (tpl, "reload", _reload); Nan::SetPrototypeMethod (tpl, "chunkLoad", _chunk_load); Nan::SetPrototypeMethod (tpl, "chunkSave", _chunk_save); Nan::SetPrototypeMethod (tpl, "strLoad", _str_load); Nan::SetPrototypeMethod (tpl, "strSave", _str_save); Nan::SetPrototypeMethod (tpl, "hasChanged", _has_changed); Nan::SetPrototypeMethod (tpl, "removeSubtree", _remove_subtree); Nan::SetPrototypeMethod (tpl, "remove", _remove); Nan::SetPrototypeMethod (tpl, "print", _print); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zconfig").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zconfig::Zconfig (const char *name, zconfig_t *parent) { self = zconfig_new ((const char *)name, parent); } Zconfig::Zconfig (zconfig_t *self_) { self = self_; } Zconfig::~Zconfig () { } NAN_METHOD (Zconfig::New) { assert (info.IsConstructCall ()); char *name; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `name`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`name` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String name_utf8 (info [0].As()); name = *name_utf8; //} //bjornw end Zconfig *parent = Nan::ObjectWrap::Unwrap(info [1].As()); Zconfig *zconfig = new Zconfig ((const char *)name, parent->self); if (zconfig) { zconfig->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zconfig::destroy) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); zconfig_destroy (&zconfig->self); } NAN_METHOD (Zconfig::defined) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zconfig->self != NULL)); } NAN_METHOD (Zconfig::_name) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zconfig_name (zconfig->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zconfig::_value) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zconfig_value (zconfig->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zconfig::_put) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *path; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `path`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`path` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String path_utf8 (info [0].As()); path = *path_utf8; //} //bjornw end char *value; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `value`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`value` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String value_utf8 (info [1].As()); value = *value_utf8; //} //bjornw end zconfig_put (zconfig->self, (const char *)path, (const char *)value); } NAN_METHOD (Zconfig::_putf) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *path; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `path`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`path` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String path_utf8 (info [0].As()); path = *path_utf8; //} //bjornw end char *format; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [1].As()); format = *format_utf8; //} //bjornw end zconfig_putf (zconfig->self, (const char *)path, "%s", format); } NAN_METHOD (Zconfig::_get) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *path; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `path`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`path` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String path_utf8 (info [0].As()); path = *path_utf8; //} //bjornw end char *default_value; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `default value`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`default value` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String default_value_utf8 (info [1].As()); default_value = *default_value_utf8; //} //bjornw end char *result = (char *) zconfig_get (zconfig->self, (const char *)path, (const char *)default_value); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zconfig::_set_name) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *name; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `name`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`name` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String name_utf8 (info [0].As()); name = *name_utf8; //} //bjornw end zconfig_set_name (zconfig->self, (const char *)name); } NAN_METHOD (Zconfig::_set_value) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zconfig_set_value (zconfig->self, "%s", format); } NAN_METHOD (Zconfig::_child) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); zconfig_t *result = zconfig_child (zconfig->self); Zconfig *zconfig_result = new Zconfig (result); if (zconfig_result) { // Don't yet know how to return a new object // zconfig->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zconfig::_next) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); zconfig_t *result = zconfig_next (zconfig->self); Zconfig *zconfig_result = new Zconfig (result); if (zconfig_result) { // Don't yet know how to return a new object // zconfig->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zconfig::_locate) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *path; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `path`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`path` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String path_utf8 (info [0].As()); path = *path_utf8; //} //bjornw end zconfig_t *result = zconfig_locate (zconfig->self, (const char *)path); Zconfig *zconfig_result = new Zconfig (result); if (zconfig_result) { // Don't yet know how to return a new object // zconfig->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zconfig::_at_depth) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `level`"); //int level; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int level; if (info [0]->IsNumber ()) { level = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`level` must be a number"); zconfig_t *result = zconfig_at_depth (zconfig->self, (int) level); Zconfig *zconfig_result = new Zconfig (result); if (zconfig_result) { // Don't yet know how to return a new object // zconfig->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zconfig::_set_comment) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zconfig_set_comment (zconfig->self, "%s", format); } NAN_METHOD (Zconfig::_comments) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); zlist_t *result = zconfig_comments (zconfig->self); Zlist *zlist_result = new Zlist (result); if (zlist_result) { // Don't yet know how to return a new object // zlist->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zconfig::_save) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end int result = zconfig_save (zconfig->self, (const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zconfig::_savef) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end int result = zconfig_savef (zconfig->self, "%s", format); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zconfig::_filename) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zconfig_filename (zconfig->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zconfig::_reload) { Zconfig *self_p = Nan::ObjectWrap::Unwrap(info [0].As()); int result = zconfig_reload (&self_p->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zconfig::_chunk_load) { Zchunk *chunk = Nan::ObjectWrap::Unwrap(info [0].As()); zconfig_t *result = zconfig_chunk_load (chunk->self); Zconfig *zconfig_result = new Zconfig (result); if (zconfig_result) { // Don't yet know how to return a new object // zconfig->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zconfig::_chunk_save) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); zchunk_t *result = zconfig_chunk_save (zconfig->self); Zchunk *zchunk_result = new Zchunk (result); if (zchunk_result) { // Don't yet know how to return a new object // zchunk->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zconfig::_str_load) { char *string; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `string`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`string` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String string_utf8 (info [0].As()); string = *string_utf8; //} //bjornw end zconfig_t *result = zconfig_str_load ((const char *)string); Zconfig *zconfig_result = new Zconfig (result); if (zconfig_result) { // Don't yet know how to return a new object // zconfig->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zconfig::_str_save) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zconfig_str_save (zconfig->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zconfig::_has_changed) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zconfig_has_changed (zconfig->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zconfig::_remove_subtree) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); zconfig_remove_subtree (zconfig->self); } NAN_METHOD (Zconfig::_remove) { Zconfig *self_p = Nan::ObjectWrap::Unwrap(info [0].As()); zconfig_remove (&self_p->self); } NAN_METHOD (Zconfig::_print) { Zconfig *zconfig = Nan::ObjectWrap::Unwrap (info.Holder ()); zconfig_print (zconfig->self); } NAN_METHOD (Zconfig::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zconfig_test ((bool) verbose); } Nan::Persistent &Zconfig::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zdigest::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zdigest").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "update", _update); Nan::SetPrototypeMethod (tpl, "data", _data); Nan::SetPrototypeMethod (tpl, "size", _size); Nan::SetPrototypeMethod (tpl, "string", _string); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zdigest").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zdigest::Zdigest (void) { self = zdigest_new (); } Zdigest::Zdigest (zdigest_t *self_) { self = self_; } Zdigest::~Zdigest () { } NAN_METHOD (Zdigest::New) { assert (info.IsConstructCall ()); Zdigest *zdigest = new Zdigest (); if (zdigest) { zdigest->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zdigest::destroy) { Zdigest *zdigest = Nan::ObjectWrap::Unwrap (info.Holder ()); zdigest_destroy (&zdigest->self); } NAN_METHOD (Zdigest::defined) { Zdigest *zdigest = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zdigest->self != NULL)); } NAN_METHOD (Zdigest::_update) { Zdigest *zdigest = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *buffer = (const byte *) node::Buffer::Data (buffer_node); size_t length = node::Buffer::Length (buffer_node); zdigest_update (zdigest->self, (const byte *)buffer, (size_t) length); } NAN_METHOD (Zdigest::_data) { Zdigest *zdigest = Nan::ObjectWrap::Unwrap (info.Holder ()); const char *result = (const char *) zdigest_data (zdigest->self); info.GetReturnValue().Set (Nan::CopyBuffer (result, zdigest_size (zdigest->self)).ToLocalChecked ()); } NAN_METHOD (Zdigest::_size) { Zdigest *zdigest = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zdigest_size (zdigest->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zdigest::_string) { Zdigest *zdigest = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zdigest_string (zdigest->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zdigest::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zdigest_test ((bool) verbose); } Nan::Persistent &Zdigest::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zdir::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zdir").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "path", _path); Nan::SetPrototypeMethod (tpl, "modified", _modified); Nan::SetPrototypeMethod (tpl, "cursize", _cursize); Nan::SetPrototypeMethod (tpl, "count", _count); Nan::SetPrototypeMethod (tpl, "list", _list); Nan::SetPrototypeMethod (tpl, "remove", _remove); Nan::SetPrototypeMethod (tpl, "diff", _diff); Nan::SetPrototypeMethod (tpl, "resync", _resync); Nan::SetPrototypeMethod (tpl, "cache", _cache); Nan::SetPrototypeMethod (tpl, "print", _print); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zdir").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zdir::Zdir (const char *path, const char *parent) { self = zdir_new ((const char *)path, (const char *)parent); } Zdir::Zdir (zdir_t *self_) { self = self_; } Zdir::~Zdir () { } NAN_METHOD (Zdir::New) { assert (info.IsConstructCall ()); char *path; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `path`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`path` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String path_utf8 (info [0].As()); path = *path_utf8; //} //bjornw end char *parent; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `parent`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`parent` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String parent_utf8 (info [1].As()); parent = *parent_utf8; //} //bjornw end Zdir *zdir = new Zdir ((const char *)path, (const char *)parent); if (zdir) { zdir->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zdir::destroy) { Zdir *zdir = Nan::ObjectWrap::Unwrap (info.Holder ()); zdir_destroy (&zdir->self); } NAN_METHOD (Zdir::defined) { Zdir *zdir = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zdir->self != NULL)); } NAN_METHOD (Zdir::_path) { Zdir *zdir = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zdir_path (zdir->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zdir::_modified) { Zdir *zdir = Nan::ObjectWrap::Unwrap (info.Holder ()); time_t result = zdir_modified (zdir->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zdir::_cursize) { Zdir *zdir = Nan::ObjectWrap::Unwrap (info.Holder ()); off_t result = zdir_cursize (zdir->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zdir::_count) { Zdir *zdir = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zdir_count (zdir->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zdir::_list) { Zdir *zdir = Nan::ObjectWrap::Unwrap (info.Holder ()); zlist_t *result = zdir_list (zdir->self); Zlist *zlist_result = new Zlist (result); if (zlist_result) { // Don't yet know how to return a new object // zlist->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zdir::_remove) { Zdir *zdir = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `force`"); //bool force; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool force; if (info [0]->IsBoolean ()) { force = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`force` must be a Boolean"); zdir_remove (zdir->self, (bool) force); } NAN_METHOD (Zdir::_diff) { Zdir *older = Nan::ObjectWrap::Unwrap(info [0].As()); Zdir *newer = Nan::ObjectWrap::Unwrap(info [1].As()); char *alias; if (info [2]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `alias`"); else if (!info [2]->IsString ()) return Nan::ThrowTypeError ("`alias` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String alias_utf8 (info [2].As()); alias = *alias_utf8; //} //bjornw end zlist_t *result = zdir_diff (older->self, newer->self, (const char *)alias); Zlist *zlist_result = new Zlist (result); if (zlist_result) { // Don't yet know how to return a new object // zlist->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zdir::_resync) { Zdir *zdir = Nan::ObjectWrap::Unwrap (info.Holder ()); char *alias; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `alias`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`alias` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String alias_utf8 (info [0].As()); alias = *alias_utf8; //} //bjornw end zlist_t *result = zdir_resync (zdir->self, (const char *)alias); Zlist *zlist_result = new Zlist (result); if (zlist_result) { // Don't yet know how to return a new object // zlist->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zdir::_cache) { Zdir *zdir = Nan::ObjectWrap::Unwrap (info.Holder ()); zhash_t *result = zdir_cache (zdir->self); Zhash *zhash_result = new Zhash (result); if (zhash_result) { // Don't yet know how to return a new object // zhash->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zdir::_print) { Zdir *zdir = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `indent`"); //int indent; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int indent; if (info [0]->IsNumber ()) { indent = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`indent` must be a number"); zdir_print (zdir->self, (int) indent); } NAN_METHOD (Zdir::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zdir_test ((bool) verbose); } Nan::Persistent &Zdir::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (ZdirPatch::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("ZdirPatch").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "dup", _dup); Nan::SetPrototypeMethod (tpl, "path", _path); Nan::SetPrototypeMethod (tpl, "file", _file); Nan::SetPrototypeMethod (tpl, "op", _op); Nan::SetPrototypeMethod (tpl, "vpath", _vpath); Nan::SetPrototypeMethod (tpl, "digestSet", _digest_set); Nan::SetPrototypeMethod (tpl, "digest", _digest); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("ZdirPatch").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } ZdirPatch::ZdirPatch (const char *path, zfile_t *file, int op, const char *alias) { self = zdir_patch_new ((const char *)path, file, (int) op, (const char *)alias); } ZdirPatch::ZdirPatch (zdir_patch_t *self_) { self = self_; } ZdirPatch::~ZdirPatch () { } NAN_METHOD (ZdirPatch::New) { assert (info.IsConstructCall ()); char *path; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `path`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`path` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String path_utf8 (info [0].As()); path = *path_utf8; //} //bjornw end Zfile *file = Nan::ObjectWrap::Unwrap(info [1].As()); if (info [2]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `op`"); //int op; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int op; if (info [2]->IsNumber ()) { op = Nan::To(info [2]).FromJust (); } else return Nan::ThrowTypeError ("`op` must be a number"); char *alias; if (info [3]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `alias`"); else if (!info [3]->IsString ()) return Nan::ThrowTypeError ("`alias` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String alias_utf8 (info [3].As()); alias = *alias_utf8; //} //bjornw end ZdirPatch *zdir_patch = new ZdirPatch ((const char *)path, file->self, (int) op, (const char *)alias); if (zdir_patch) { zdir_patch->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (ZdirPatch::destroy) { ZdirPatch *zdir_patch = Nan::ObjectWrap::Unwrap (info.Holder ()); zdir_patch_destroy (&zdir_patch->self); } NAN_METHOD (ZdirPatch::defined) { ZdirPatch *zdir_patch = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zdir_patch->self != NULL)); } NAN_METHOD (ZdirPatch::_dup) { ZdirPatch *zdir_patch = Nan::ObjectWrap::Unwrap (info.Holder ()); zdir_patch_t *result = zdir_patch_dup (zdir_patch->self); ZdirPatch *zdir_patch_result = new ZdirPatch (result); if (zdir_patch_result) { // Don't yet know how to return a new object // zdir_patch->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (ZdirPatch::_path) { ZdirPatch *zdir_patch = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zdir_patch_path (zdir_patch->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (ZdirPatch::_file) { ZdirPatch *zdir_patch = Nan::ObjectWrap::Unwrap (info.Holder ()); zfile_t *result = zdir_patch_file (zdir_patch->self); Zfile *zfile_result = new Zfile (result); if (zfile_result) { // Don't yet know how to return a new object // zfile->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (ZdirPatch::_op) { ZdirPatch *zdir_patch = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zdir_patch_op (zdir_patch->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (ZdirPatch::_vpath) { ZdirPatch *zdir_patch = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zdir_patch_vpath (zdir_patch->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (ZdirPatch::_digest_set) { ZdirPatch *zdir_patch = Nan::ObjectWrap::Unwrap (info.Holder ()); zdir_patch_digest_set (zdir_patch->self); } NAN_METHOD (ZdirPatch::_digest) { ZdirPatch *zdir_patch = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zdir_patch_digest (zdir_patch->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (ZdirPatch::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zdir_patch_test ((bool) verbose); } Nan::Persistent &ZdirPatch::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zfile::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zfile").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "dup", _dup); Nan::SetPrototypeMethod (tpl, "filename", _filename); Nan::SetPrototypeMethod (tpl, "restat", _restat); Nan::SetPrototypeMethod (tpl, "modified", _modified); Nan::SetPrototypeMethod (tpl, "cursize", _cursize); Nan::SetPrototypeMethod (tpl, "isDirectory", _is_directory); Nan::SetPrototypeMethod (tpl, "isRegular", _is_regular); Nan::SetPrototypeMethod (tpl, "isReadable", _is_readable); Nan::SetPrototypeMethod (tpl, "isWriteable", _is_writeable); Nan::SetPrototypeMethod (tpl, "isStable", _is_stable); Nan::SetPrototypeMethod (tpl, "hasChanged", _has_changed); Nan::SetPrototypeMethod (tpl, "remove", _remove); Nan::SetPrototypeMethod (tpl, "input", _input); Nan::SetPrototypeMethod (tpl, "output", _output); Nan::SetPrototypeMethod (tpl, "read", _read); Nan::SetPrototypeMethod (tpl, "eof", _eof); Nan::SetPrototypeMethod (tpl, "write", _write); Nan::SetPrototypeMethod (tpl, "readln", _readln); Nan::SetPrototypeMethod (tpl, "close", _close); Nan::SetPrototypeMethod (tpl, "digest", _digest); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zfile").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zfile::Zfile (const char *path, const char *name) { self = zfile_new ((const char *)path, (const char *)name); } Zfile::Zfile (zfile_t *self_) { self = self_; } Zfile::~Zfile () { } NAN_METHOD (Zfile::New) { assert (info.IsConstructCall ()); char *path; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `path`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`path` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String path_utf8 (info [0].As()); path = *path_utf8; //} //bjornw end char *name; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `name`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`name` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String name_utf8 (info [1].As()); name = *name_utf8; //} //bjornw end Zfile *zfile = new Zfile ((const char *)path, (const char *)name); if (zfile) { zfile->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zfile::destroy) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); zfile_destroy (&zfile->self); } NAN_METHOD (Zfile::defined) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zfile->self != NULL)); } NAN_METHOD (Zfile::_dup) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); zfile_t *result = zfile_dup (zfile->self); Zfile *zfile_result = new Zfile (result); if (zfile_result) { // Don't yet know how to return a new object // zfile->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zfile::_filename) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); char *path; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `path`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`path` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String path_utf8 (info [0].As()); path = *path_utf8; //} //bjornw end char *result = (char *) zfile_filename (zfile->self, (const char *)path); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zfile::_restat) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); zfile_restat (zfile->self); } NAN_METHOD (Zfile::_modified) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); time_t result = zfile_modified (zfile->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zfile::_cursize) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); off_t result = zfile_cursize (zfile->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zfile::_is_directory) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zfile_is_directory (zfile->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zfile::_is_regular) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zfile_is_regular (zfile->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zfile::_is_readable) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zfile_is_readable (zfile->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zfile::_is_writeable) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zfile_is_writeable (zfile->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zfile::_is_stable) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zfile_is_stable (zfile->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zfile::_has_changed) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zfile_has_changed (zfile->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zfile::_remove) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); zfile_remove (zfile->self); } NAN_METHOD (Zfile::_input) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zfile_input (zfile->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zfile::_output) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zfile_output (zfile->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zfile::_read) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `bytes`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`bytes` must be a number"); size_t bytes = Nan::To(info [0]).FromJust (); if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `offset`"); //off_t offset; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int64_t offset; if (info [1]->IsNumber ()) { offset = Nan::To(info [1]).FromJust (); } else return Nan::ThrowTypeError ("`offset` must be a number"); zchunk_t *result = zfile_read (zfile->self, (size_t) bytes, (off_t) offset); Zchunk *zchunk_result = new Zchunk (result); if (zchunk_result) { // Don't yet know how to return a new object // zchunk->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zfile::_eof) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zfile_eof (zfile->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zfile::_write) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); Zchunk *chunk = Nan::ObjectWrap::Unwrap(info [0].As()); if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `offset`"); //off_t offset; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int64_t offset; if (info [1]->IsNumber ()) { offset = Nan::To(info [1]).FromJust (); } else return Nan::ThrowTypeError ("`offset` must be a number"); int result = zfile_write (zfile->self, chunk->self, (off_t) offset); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zfile::_readln) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zfile_readln (zfile->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zfile::_close) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); zfile_close (zfile->self); } NAN_METHOD (Zfile::_digest) { Zfile *zfile = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zfile_digest (zfile->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zfile::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zfile_test ((bool) verbose); } Nan::Persistent &Zfile::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zframe::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zframe").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "send", _send); Nan::SetPrototypeMethod (tpl, "size", _size); Nan::SetPrototypeMethod (tpl, "data", _data); Nan::SetPrototypeMethod (tpl, "meta", _meta); Nan::SetPrototypeMethod (tpl, "dup", _dup); Nan::SetPrototypeMethod (tpl, "strhex", _strhex); Nan::SetPrototypeMethod (tpl, "strdup", _strdup); Nan::SetPrototypeMethod (tpl, "streq", _streq); Nan::SetPrototypeMethod (tpl, "more", _more); Nan::SetPrototypeMethod (tpl, "setMore", _set_more); Nan::SetPrototypeMethod (tpl, "routingId", _routing_id); Nan::SetPrototypeMethod (tpl, "setRoutingId", _set_routing_id); Nan::SetPrototypeMethod (tpl, "group", _group); Nan::SetPrototypeMethod (tpl, "setGroup", _set_group); Nan::SetPrototypeMethod (tpl, "eq", _eq); Nan::SetPrototypeMethod (tpl, "reset", _reset); Nan::SetPrototypeMethod (tpl, "print", _print); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zframe").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zframe::Zframe (const void *data, size_t size) { self = zframe_new ((const void *)data, (size_t) size); } Zframe::Zframe (zframe_t *self_) { self = self_; } Zframe::~Zframe () { } NAN_METHOD (Zframe::New) { assert (info.IsConstructCall ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *data = (const byte *) node::Buffer::Data (buffer_node); size_t size = node::Buffer::Length (buffer_node); Zframe *zframe = new Zframe ((const void *)data, (size_t) size); if (zframe) { zframe->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zframe::destroy) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); zframe_destroy (&zframe->self); } NAN_METHOD (Zframe::defined) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zframe->self != NULL)); } NAN_METHOD (Zframe::_send) { Zframe *self_p = Nan::ObjectWrap::Unwrap(info [0].As()); Zsock *dest = Nan::ObjectWrap::Unwrap(info [1].As()); if (info [2]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `flags`"); //int flags; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int flags; if (info [2]->IsNumber ()) { flags = Nan::To(info [2]).FromJust (); } else return Nan::ThrowTypeError ("`flags` must be a number"); int result = zframe_send (&self_p->self, dest->self, (int) flags); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zframe::_size) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zframe_size (zframe->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zframe::_data) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); const char *result = (const char *) zframe_data (zframe->self); info.GetReturnValue().Set (Nan::CopyBuffer (result, zframe_size (zframe->self)).ToLocalChecked ()); } NAN_METHOD (Zframe::_meta) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); char *property; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `property`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`property` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String property_utf8 (info [0].As()); property = *property_utf8; //} //bjornw end char *result = (char *) zframe_meta (zframe->self, (const char *)property); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zframe::_dup) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); zframe_t *result = zframe_dup (zframe->self); Zframe *zframe_result = new Zframe (result); if (zframe_result) { // Don't yet know how to return a new object // zframe->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zframe::_strhex) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zframe_strhex (zframe->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zframe::_strdup) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zframe_strdup (zframe->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zframe::_streq) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); char *string; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `string`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`string` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String string_utf8 (info [0].As()); string = *string_utf8; //} //bjornw end bool result = zframe_streq (zframe->self, (const char *)string); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zframe::_more) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zframe_more (zframe->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zframe::_set_more) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `more`"); //int more; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int more; if (info [0]->IsNumber ()) { more = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`more` must be a number"); zframe_set_more (zframe->self, (int) more); } NAN_METHOD (Zframe::_routing_id) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); uint32_t result = zframe_routing_id (zframe->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zframe::_set_routing_id) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `routing id`"); //uint32_t routing_id; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int uint32_t routing_id; if (info [0]->IsNumber ()) { routing_id = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`routing id` must be a number"); zframe_set_routing_id (zframe->self, (uint32_t) routing_id); } NAN_METHOD (Zframe::_group) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zframe_group (zframe->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zframe::_set_group) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); char *group; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `group`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`group` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String group_utf8 (info [0].As()); group = *group_utf8; //} //bjornw end int result = zframe_set_group (zframe->self, (const char *)group); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zframe::_eq) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); Zframe *other = Nan::ObjectWrap::Unwrap(info [0].As()); bool result = zframe_eq (zframe->self, other->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zframe::_reset) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *data = (const byte *) node::Buffer::Data (buffer_node); size_t size = node::Buffer::Length (buffer_node); zframe_reset (zframe->self, (const void *)data, (size_t) size); } NAN_METHOD (Zframe::_print) { Zframe *zframe = Nan::ObjectWrap::Unwrap (info.Holder ()); char *prefix; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `prefix`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`prefix` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String prefix_utf8 (info [0].As()); prefix = *prefix_utf8; //} //bjornw end zframe_print (zframe->self, (const char *)prefix); } NAN_METHOD (Zframe::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zframe_test ((bool) verbose); } Nan::Persistent &Zframe::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zhash::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zhash").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "delete", _delete); Nan::SetPrototypeMethod (tpl, "rename", _rename); Nan::SetPrototypeMethod (tpl, "size", _size); Nan::SetPrototypeMethod (tpl, "dup", _dup); Nan::SetPrototypeMethod (tpl, "keys", _keys); Nan::SetPrototypeMethod (tpl, "cursor", _cursor); Nan::SetPrototypeMethod (tpl, "comment", _comment); Nan::SetPrototypeMethod (tpl, "pack", _pack); Nan::SetPrototypeMethod (tpl, "save", _save); Nan::SetPrototypeMethod (tpl, "load", _load); Nan::SetPrototypeMethod (tpl, "refresh", _refresh); Nan::SetPrototypeMethod (tpl, "autofree", _autofree); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zhash").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zhash::Zhash (void) { self = zhash_new (); } Zhash::Zhash (zhash_t *self_) { self = self_; } Zhash::~Zhash () { } NAN_METHOD (Zhash::New) { assert (info.IsConstructCall ()); Zhash *zhash = new Zhash (); if (zhash) { zhash->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zhash::destroy) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); zhash_destroy (&zhash->self); } NAN_METHOD (Zhash::defined) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zhash->self != NULL)); } NAN_METHOD (Zhash::_delete) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); char *key; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `key`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`key` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String key_utf8 (info [0].As()); key = *key_utf8; //} //bjornw end zhash_delete (zhash->self, (const char *)key); } NAN_METHOD (Zhash::_rename) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); char *old_key; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `old key`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`old key` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String old_key_utf8 (info [0].As()); old_key = *old_key_utf8; //} //bjornw end char *new_key; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `new key`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`new key` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String new_key_utf8 (info [1].As()); new_key = *new_key_utf8; //} //bjornw end int result = zhash_rename (zhash->self, (const char *)old_key, (const char *)new_key); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zhash::_size) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zhash_size (zhash->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zhash::_dup) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); zhash_t *result = zhash_dup (zhash->self); Zhash *zhash_result = new Zhash (result); if (zhash_result) { // Don't yet know how to return a new object // zhash->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zhash::_keys) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); zlist_t *result = zhash_keys (zhash->self); Zlist *zlist_result = new Zlist (result); if (zlist_result) { // Don't yet know how to return a new object // zlist->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zhash::_cursor) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zhash_cursor (zhash->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zhash::_comment) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zhash_comment (zhash->self, "%s", format); } NAN_METHOD (Zhash::_pack) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); zframe_t *result = zhash_pack (zhash->self); Zframe *zframe_result = new Zframe (result); if (zframe_result) { // Don't yet know how to return a new object // zframe->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zhash::_save) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end int result = zhash_save (zhash->self, (const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zhash::_load) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end int result = zhash_load (zhash->self, (const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zhash::_refresh) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zhash_refresh (zhash->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zhash::_autofree) { Zhash *zhash = Nan::ObjectWrap::Unwrap (info.Holder ()); zhash_autofree (zhash->self); } NAN_METHOD (Zhash::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zhash_test ((bool) verbose); } Nan::Persistent &Zhash::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zhashx::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zhashx").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "purge", _purge); Nan::SetPrototypeMethod (tpl, "size", _size); Nan::SetPrototypeMethod (tpl, "keys", _keys); Nan::SetPrototypeMethod (tpl, "values", _values); Nan::SetPrototypeMethod (tpl, "comment", _comment); Nan::SetPrototypeMethod (tpl, "save", _save); Nan::SetPrototypeMethod (tpl, "load", _load); Nan::SetPrototypeMethod (tpl, "refresh", _refresh); Nan::SetPrototypeMethod (tpl, "pack", _pack); Nan::SetPrototypeMethod (tpl, "dup", _dup); Nan::SetPrototypeMethod (tpl, "dupV2", _dup_v2); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zhashx").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zhashx::Zhashx (void) { self = zhashx_new (); } Zhashx::Zhashx (zhashx_t *self_) { self = self_; } Zhashx::~Zhashx () { } NAN_METHOD (Zhashx::New) { assert (info.IsConstructCall ()); Zhashx *zhashx = new Zhashx (); if (zhashx) { zhashx->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zhashx::destroy) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); zhashx_destroy (&zhashx->self); } NAN_METHOD (Zhashx::defined) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zhashx->self != NULL)); } NAN_METHOD (Zhashx::_purge) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); zhashx_purge (zhashx->self); } NAN_METHOD (Zhashx::_size) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zhashx_size (zhashx->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zhashx::_keys) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); zlistx_t *result = zhashx_keys (zhashx->self); Zlistx *zlistx_result = new Zlistx (result); if (zlistx_result) { // Don't yet know how to return a new object // zlistx->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zhashx::_values) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); zlistx_t *result = zhashx_values (zhashx->self); Zlistx *zlistx_result = new Zlistx (result); if (zlistx_result) { // Don't yet know how to return a new object // zlistx->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zhashx::_comment) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zhashx_comment (zhashx->self, "%s", format); } NAN_METHOD (Zhashx::_save) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end int result = zhashx_save (zhashx->self, (const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zhashx::_load) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end int result = zhashx_load (zhashx->self, (const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zhashx::_refresh) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zhashx_refresh (zhashx->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zhashx::_pack) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); zframe_t *result = zhashx_pack (zhashx->self); Zframe *zframe_result = new Zframe (result); if (zframe_result) { // Don't yet know how to return a new object // zframe->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zhashx::_dup) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); zhashx_t *result = zhashx_dup (zhashx->self); Zhashx *zhashx_result = new Zhashx (result); if (zhashx_result) { // Don't yet know how to return a new object // zhashx->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zhashx::_dup_v2) { Zhashx *zhashx = Nan::ObjectWrap::Unwrap (info.Holder ()); zhashx_t *result = zhashx_dup_v2 (zhashx->self); Zhashx *zhashx_result = new Zhashx (result); if (zhashx_result) { // Don't yet know how to return a new object // zhashx->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zhashx::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zhashx_test ((bool) verbose); } Nan::Persistent &Zhashx::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Ziflist::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Ziflist").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "reload", _reload); Nan::SetPrototypeMethod (tpl, "size", _size); Nan::SetPrototypeMethod (tpl, "first", _first); Nan::SetPrototypeMethod (tpl, "next", _next); Nan::SetPrototypeMethod (tpl, "address", _address); Nan::SetPrototypeMethod (tpl, "broadcast", _broadcast); Nan::SetPrototypeMethod (tpl, "netmask", _netmask); Nan::SetPrototypeMethod (tpl, "print", _print); Nan::SetPrototypeMethod (tpl, "newIpv6", _new_ipv6); Nan::SetPrototypeMethod (tpl, "reloadIpv6", _reload_ipv6); Nan::SetPrototypeMethod (tpl, "isIpv6", _is_ipv6); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Ziflist").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Ziflist::Ziflist (void) { self = ziflist_new (); } Ziflist::Ziflist (ziflist_t *self_) { self = self_; } Ziflist::~Ziflist () { } NAN_METHOD (Ziflist::New) { assert (info.IsConstructCall ()); Ziflist *ziflist = new Ziflist (); if (ziflist) { ziflist->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Ziflist::destroy) { Ziflist *ziflist = Nan::ObjectWrap::Unwrap (info.Holder ()); ziflist_destroy (&ziflist->self); } NAN_METHOD (Ziflist::defined) { Ziflist *ziflist = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (ziflist->self != NULL)); } NAN_METHOD (Ziflist::_reload) { Ziflist *ziflist = Nan::ObjectWrap::Unwrap (info.Holder ()); ziflist_reload (ziflist->self); } NAN_METHOD (Ziflist::_size) { Ziflist *ziflist = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = ziflist_size (ziflist->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Ziflist::_first) { Ziflist *ziflist = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) ziflist_first (ziflist->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Ziflist::_next) { Ziflist *ziflist = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) ziflist_next (ziflist->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Ziflist::_address) { Ziflist *ziflist = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) ziflist_address (ziflist->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Ziflist::_broadcast) { Ziflist *ziflist = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) ziflist_broadcast (ziflist->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Ziflist::_netmask) { Ziflist *ziflist = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) ziflist_netmask (ziflist->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Ziflist::_print) { Ziflist *ziflist = Nan::ObjectWrap::Unwrap (info.Holder ()); ziflist_print (ziflist->self); } NAN_METHOD (Ziflist::_new_ipv6) { ziflist_t *result = ziflist_new_ipv6 (); Ziflist *ziflist_result = new Ziflist (result); if (ziflist_result) { // Don't yet know how to return a new object // ziflist->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Ziflist::_reload_ipv6) { Ziflist *ziflist = Nan::ObjectWrap::Unwrap (info.Holder ()); ziflist_reload_ipv6 (ziflist->self); } NAN_METHOD (Ziflist::_is_ipv6) { Ziflist *ziflist = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = ziflist_is_ipv6 (ziflist->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Ziflist::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); ziflist_test ((bool) verbose); } Nan::Persistent &Ziflist::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zlist::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zlist").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "dup", _dup); Nan::SetPrototypeMethod (tpl, "purge", _purge); Nan::SetPrototypeMethod (tpl, "size", _size); Nan::SetPrototypeMethod (tpl, "autofree", _autofree); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zlist").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zlist::Zlist (void) { self = zlist_new (); } Zlist::Zlist (zlist_t *self_) { self = self_; } Zlist::~Zlist () { } NAN_METHOD (Zlist::New) { assert (info.IsConstructCall ()); Zlist *zlist = new Zlist (); if (zlist) { zlist->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zlist::destroy) { Zlist *zlist = Nan::ObjectWrap::Unwrap (info.Holder ()); zlist_destroy (&zlist->self); } NAN_METHOD (Zlist::defined) { Zlist *zlist = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zlist->self != NULL)); } NAN_METHOD (Zlist::_dup) { Zlist *zlist = Nan::ObjectWrap::Unwrap (info.Holder ()); zlist_t *result = zlist_dup (zlist->self); Zlist *zlist_result = new Zlist (result); if (zlist_result) { // Don't yet know how to return a new object // zlist->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zlist::_purge) { Zlist *zlist = Nan::ObjectWrap::Unwrap (info.Holder ()); zlist_purge (zlist->self); } NAN_METHOD (Zlist::_size) { Zlist *zlist = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zlist_size (zlist->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zlist::_autofree) { Zlist *zlist = Nan::ObjectWrap::Unwrap (info.Holder ()); zlist_autofree (zlist->self); } NAN_METHOD (Zlist::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zlist_test ((bool) verbose); } Nan::Persistent &Zlist::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zlistx::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zlistx").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "size", _size); Nan::SetPrototypeMethod (tpl, "purge", _purge); Nan::SetPrototypeMethod (tpl, "sort", _sort); Nan::SetPrototypeMethod (tpl, "dup", _dup); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zlistx").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zlistx::Zlistx (void) { self = zlistx_new (); } Zlistx::Zlistx (zlistx_t *self_) { self = self_; } Zlistx::~Zlistx () { } NAN_METHOD (Zlistx::New) { assert (info.IsConstructCall ()); Zlistx *zlistx = new Zlistx (); if (zlistx) { zlistx->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zlistx::destroy) { Zlistx *zlistx = Nan::ObjectWrap::Unwrap (info.Holder ()); zlistx_destroy (&zlistx->self); } NAN_METHOD (Zlistx::defined) { Zlistx *zlistx = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zlistx->self != NULL)); } NAN_METHOD (Zlistx::_size) { Zlistx *zlistx = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zlistx_size (zlistx->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zlistx::_purge) { Zlistx *zlistx = Nan::ObjectWrap::Unwrap (info.Holder ()); zlistx_purge (zlistx->self); } NAN_METHOD (Zlistx::_sort) { Zlistx *zlistx = Nan::ObjectWrap::Unwrap (info.Holder ()); zlistx_sort (zlistx->self); } NAN_METHOD (Zlistx::_dup) { Zlistx *zlistx = Nan::ObjectWrap::Unwrap (info.Holder ()); zlistx_t *result = zlistx_dup (zlistx->self); Zlistx *zlistx_result = new Zlistx (result); if (zlistx_result) { // Don't yet know how to return a new object // zlistx->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zlistx::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zlistx_test ((bool) verbose); } Nan::Persistent &Zlistx::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zloop::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zloop").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "readerEnd", _reader_end); Nan::SetPrototypeMethod (tpl, "readerSetTolerant", _reader_set_tolerant); Nan::SetPrototypeMethod (tpl, "timerEnd", _timer_end); Nan::SetPrototypeMethod (tpl, "setTicketDelay", _set_ticket_delay); Nan::SetPrototypeMethod (tpl, "setMaxTimers", _set_max_timers); Nan::SetPrototypeMethod (tpl, "setVerbose", _set_verbose); Nan::SetPrototypeMethod (tpl, "setNonstop", _set_nonstop); Nan::SetPrototypeMethod (tpl, "start", _start); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zloop").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zloop::Zloop (void) { self = zloop_new (); } Zloop::Zloop (zloop_t *self_) { self = self_; } Zloop::~Zloop () { } NAN_METHOD (Zloop::New) { assert (info.IsConstructCall ()); Zloop *zloop = new Zloop (); if (zloop) { zloop->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zloop::destroy) { Zloop *zloop = Nan::ObjectWrap::Unwrap (info.Holder ()); zloop_destroy (&zloop->self); } NAN_METHOD (Zloop::defined) { Zloop *zloop = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zloop->self != NULL)); } NAN_METHOD (Zloop::_reader_end) { Zloop *zloop = Nan::ObjectWrap::Unwrap (info.Holder ()); Zsock *sock = Nan::ObjectWrap::Unwrap(info [0].As()); zloop_reader_end (zloop->self, sock->self); } NAN_METHOD (Zloop::_reader_set_tolerant) { Zloop *zloop = Nan::ObjectWrap::Unwrap (info.Holder ()); Zsock *sock = Nan::ObjectWrap::Unwrap(info [0].As()); zloop_reader_set_tolerant (zloop->self, sock->self); } NAN_METHOD (Zloop::_timer_end) { Zloop *zloop = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `timer id`"); //int timer_id; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int timer_id; if (info [0]->IsNumber ()) { timer_id = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`timer id` must be a number"); int result = zloop_timer_end (zloop->self, (int) timer_id); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zloop::_set_ticket_delay) { Zloop *zloop = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `ticket delay`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`ticket delay` must be a number"); size_t ticket_delay = Nan::To(info [0]).FromJust (); zloop_set_ticket_delay (zloop->self, (size_t) ticket_delay); } NAN_METHOD (Zloop::_set_max_timers) { Zloop *zloop = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `max timers`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`max timers` must be a number"); size_t max_timers = Nan::To(info [0]).FromJust (); zloop_set_max_timers (zloop->self, (size_t) max_timers); } NAN_METHOD (Zloop::_set_verbose) { Zloop *zloop = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zloop_set_verbose (zloop->self, (bool) verbose); } NAN_METHOD (Zloop::_set_nonstop) { Zloop *zloop = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `nonstop`"); //bool nonstop; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool nonstop; if (info [0]->IsBoolean ()) { nonstop = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`nonstop` must be a Boolean"); zloop_set_nonstop (zloop->self, (bool) nonstop); } NAN_METHOD (Zloop::_start) { Zloop *zloop = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zloop_start (zloop->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zloop::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zloop_test ((bool) verbose); } Nan::Persistent &Zloop::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zmsg::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zmsg").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "send", _send); Nan::SetPrototypeMethod (tpl, "sendm", _sendm); Nan::SetPrototypeMethod (tpl, "size", _size); Nan::SetPrototypeMethod (tpl, "contentSize", _content_size); Nan::SetPrototypeMethod (tpl, "routingId", _routing_id); Nan::SetPrototypeMethod (tpl, "setRoutingId", _set_routing_id); Nan::SetPrototypeMethod (tpl, "prepend", _prepend); Nan::SetPrototypeMethod (tpl, "append", _append); Nan::SetPrototypeMethod (tpl, "pop", _pop); Nan::SetPrototypeMethod (tpl, "pushmem", _pushmem); Nan::SetPrototypeMethod (tpl, "addmem", _addmem); Nan::SetPrototypeMethod (tpl, "pushstr", _pushstr); Nan::SetPrototypeMethod (tpl, "addstr", _addstr); Nan::SetPrototypeMethod (tpl, "pushstrf", _pushstrf); Nan::SetPrototypeMethod (tpl, "addstrf", _addstrf); Nan::SetPrototypeMethod (tpl, "popstr", _popstr); Nan::SetPrototypeMethod (tpl, "addmsg", _addmsg); Nan::SetPrototypeMethod (tpl, "popmsg", _popmsg); Nan::SetPrototypeMethod (tpl, "remove", _remove); Nan::SetPrototypeMethod (tpl, "first", _first); Nan::SetPrototypeMethod (tpl, "next", _next); Nan::SetPrototypeMethod (tpl, "last", _last); Nan::SetPrototypeMethod (tpl, "encode", _encode); Nan::SetPrototypeMethod (tpl, "dup", _dup); Nan::SetPrototypeMethod (tpl, "print", _print); Nan::SetPrototypeMethod (tpl, "eq", _eq); Nan::SetPrototypeMethod (tpl, "signal", _signal); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zmsg").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zmsg::Zmsg (void) { self = zmsg_new (); } Zmsg::Zmsg (zmsg_t *self_) { self = self_; } Zmsg::~Zmsg () { } NAN_METHOD (Zmsg::New) { assert (info.IsConstructCall ()); Zmsg *zmsg = new Zmsg (); if (zmsg) { zmsg->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zmsg::destroy) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); zmsg_destroy (&zmsg->self); } NAN_METHOD (Zmsg::defined) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zmsg->self != NULL)); } NAN_METHOD (Zmsg::_send) { Zmsg *self_p = Nan::ObjectWrap::Unwrap(info [0].As()); Zsock *dest = Nan::ObjectWrap::Unwrap(info [1].As()); int result = zmsg_send (&self_p->self, dest->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_sendm) { Zmsg *self_p = Nan::ObjectWrap::Unwrap(info [0].As()); Zsock *dest = Nan::ObjectWrap::Unwrap(info [1].As()); int result = zmsg_sendm (&self_p->self, dest->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_size) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zmsg_size (zmsg->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_content_size) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zmsg_content_size (zmsg->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_routing_id) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); uint32_t result = zmsg_routing_id (zmsg->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_set_routing_id) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `routing id`"); //uint32_t routing_id; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int uint32_t routing_id; if (info [0]->IsNumber ()) { routing_id = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`routing id` must be a number"); zmsg_set_routing_id (zmsg->self, (uint32_t) routing_id); } NAN_METHOD (Zmsg::_prepend) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); Zframe *frame_p = Nan::ObjectWrap::Unwrap(info [0].As()); int result = zmsg_prepend (zmsg->self, &frame_p->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_append) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); Zframe *frame_p = Nan::ObjectWrap::Unwrap(info [0].As()); int result = zmsg_append (zmsg->self, &frame_p->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_pop) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); zframe_t *result = zmsg_pop (zmsg->self); Zframe *zframe_result = new Zframe (result); if (zframe_result) { // Don't yet know how to return a new object // zframe->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zmsg::_pushmem) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *data = (const byte *) node::Buffer::Data (buffer_node); size_t size = node::Buffer::Length (buffer_node); int result = zmsg_pushmem (zmsg->self, (const void *)data, (size_t) size); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_addmem) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *data = (const byte *) node::Buffer::Data (buffer_node); size_t size = node::Buffer::Length (buffer_node); int result = zmsg_addmem (zmsg->self, (const void *)data, (size_t) size); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_pushstr) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); char *string; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `string`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`string` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String string_utf8 (info [0].As()); string = *string_utf8; //} //bjornw end int result = zmsg_pushstr (zmsg->self, (const char *)string); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_addstr) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); char *string; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `string`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`string` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String string_utf8 (info [0].As()); string = *string_utf8; //} //bjornw end int result = zmsg_addstr (zmsg->self, (const char *)string); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_pushstrf) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end int result = zmsg_pushstrf (zmsg->self, "%s", format); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_addstrf) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end int result = zmsg_addstrf (zmsg->self, "%s", format); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_popstr) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zmsg_popstr (zmsg->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zmsg::_addmsg) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); Zmsg *msg_p = Nan::ObjectWrap::Unwrap(info [0].As()); int result = zmsg_addmsg (zmsg->self, &msg_p->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_popmsg) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); zmsg_t *result = zmsg_popmsg (zmsg->self); Zmsg *zmsg_result = new Zmsg (result); if (zmsg_result) { // Don't yet know how to return a new object // zmsg->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zmsg::_remove) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); Zframe *frame = Nan::ObjectWrap::Unwrap(info [0].As()); zmsg_remove (zmsg->self, frame->self); } NAN_METHOD (Zmsg::_first) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); zframe_t *result = zmsg_first (zmsg->self); Zframe *zframe_result = new Zframe (result); if (zframe_result) { // Don't yet know how to return a new object // zframe->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zmsg::_next) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); zframe_t *result = zmsg_next (zmsg->self); Zframe *zframe_result = new Zframe (result); if (zframe_result) { // Don't yet know how to return a new object // zframe->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zmsg::_last) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); zframe_t *result = zmsg_last (zmsg->self); Zframe *zframe_result = new Zframe (result); if (zframe_result) { // Don't yet know how to return a new object // zframe->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zmsg::_encode) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); zframe_t *result = zmsg_encode (zmsg->self); Zframe *zframe_result = new Zframe (result); if (zframe_result) { // Don't yet know how to return a new object // zframe->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zmsg::_dup) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); zmsg_t *result = zmsg_dup (zmsg->self); Zmsg *zmsg_result = new Zmsg (result); if (zmsg_result) { // Don't yet know how to return a new object // zmsg->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zmsg::_print) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); zmsg_print (zmsg->self); } NAN_METHOD (Zmsg::_eq) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); Zmsg *other = Nan::ObjectWrap::Unwrap(info [0].As()); bool result = zmsg_eq (zmsg->self, other->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_signal) { Zmsg *zmsg = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zmsg_signal (zmsg->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zmsg::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zmsg_test ((bool) verbose); } Nan::Persistent &Zmsg::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zpoller::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zpoller").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "add", _add); Nan::SetPrototypeMethod (tpl, "setNonstop", _set_nonstop); Nan::SetPrototypeMethod (tpl, "expired", _expired); Nan::SetPrototypeMethod (tpl, "terminated", _terminated); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zpoller").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zpoller::Zpoller (zsock_t *reader) { self = zpoller_new (reader); } Zpoller::Zpoller (zpoller_t *self_) { self = self_; } Zpoller::~Zpoller () { } NAN_METHOD (Zpoller::New) { assert (info.IsConstructCall ()); Zsock *reader = Nan::ObjectWrap::Unwrap(info [0].As()); Zpoller *zpoller = new Zpoller (reader->self); if (zpoller) { zpoller->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zpoller::destroy) { Zpoller *zpoller = Nan::ObjectWrap::Unwrap (info.Holder ()); zpoller_destroy (&zpoller->self); } NAN_METHOD (Zpoller::defined) { Zpoller *zpoller = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zpoller->self != NULL)); } NAN_METHOD (Zpoller::_add) { Zpoller *zpoller = Nan::ObjectWrap::Unwrap (info.Holder ()); Zsock *reader = Nan::ObjectWrap::Unwrap(info [0].As()); int result = zpoller_add (zpoller->self, reader->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zpoller::_set_nonstop) { Zpoller *zpoller = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `nonstop`"); //bool nonstop; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool nonstop; if (info [0]->IsBoolean ()) { nonstop = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`nonstop` must be a Boolean"); zpoller_set_nonstop (zpoller->self, (bool) nonstop); } NAN_METHOD (Zpoller::_expired) { Zpoller *zpoller = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zpoller_expired (zpoller->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zpoller::_terminated) { Zpoller *zpoller = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zpoller_terminated (zpoller->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zpoller::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zpoller_test ((bool) verbose); } Nan::Persistent &Zpoller::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zproc::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zproc").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "setArgs", _set_args); Nan::SetPrototypeMethod (tpl, "setEnv", _set_env); Nan::SetPrototypeMethod (tpl, "run", _run); Nan::SetPrototypeMethod (tpl, "returncode", _returncode); Nan::SetPrototypeMethod (tpl, "pid", _pid); Nan::SetPrototypeMethod (tpl, "running", _running); Nan::SetPrototypeMethod (tpl, "wait", _wait); Nan::SetPrototypeMethod (tpl, "kill", _kill); Nan::SetPrototypeMethod (tpl, "setVerbose", _set_verbose); Nan::SetPrototypeMethod (tpl, "czmqVersion", _czmq_version); Nan::SetPrototypeMethod (tpl, "interrupted", _interrupted); Nan::SetPrototypeMethod (tpl, "hasCurve", _has_curve); Nan::SetPrototypeMethod (tpl, "hostname", _hostname); Nan::SetPrototypeMethod (tpl, "daemonize", _daemonize); Nan::SetPrototypeMethod (tpl, "runAs", _run_as); Nan::SetPrototypeMethod (tpl, "setIoThreads", _set_io_threads); Nan::SetPrototypeMethod (tpl, "setMaxSockets", _set_max_sockets); Nan::SetPrototypeMethod (tpl, "setBiface", _set_biface); Nan::SetPrototypeMethod (tpl, "biface", _biface); Nan::SetPrototypeMethod (tpl, "setLogIdent", _set_log_ident); Nan::SetPrototypeMethod (tpl, "setLogSender", _set_log_sender); Nan::SetPrototypeMethod (tpl, "setLogSystem", _set_log_system); Nan::SetPrototypeMethod (tpl, "logError", _log_error); Nan::SetPrototypeMethod (tpl, "logWarning", _log_warning); Nan::SetPrototypeMethod (tpl, "logNotice", _log_notice); Nan::SetPrototypeMethod (tpl, "logInfo", _log_info); Nan::SetPrototypeMethod (tpl, "logDebug", _log_debug); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zproc").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zproc::Zproc (void) { self = zproc_new (); } Zproc::Zproc (zproc_t *self_) { self = self_; } Zproc::~Zproc () { } NAN_METHOD (Zproc::New) { assert (info.IsConstructCall ()); Zproc *zproc = new Zproc (); if (zproc) { zproc->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zproc::destroy) { Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); zproc_destroy (&zproc->self); } NAN_METHOD (Zproc::defined) { Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zproc->self != NULL)); } NAN_METHOD (Zproc::_set_args) { Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); Zlistx *args = Nan::ObjectWrap::Unwrap(info [0].As()); zproc_set_args (zproc->self, args->self); } NAN_METHOD (Zproc::_set_env) { Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); Zhashx *args = Nan::ObjectWrap::Unwrap(info [0].As()); zproc_set_env (zproc->self, args->self); } NAN_METHOD (Zproc::_run) { Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zproc_run (zproc->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zproc::_returncode) { Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zproc_returncode (zproc->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zproc::_pid) { Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zproc_pid (zproc->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zproc::_running) { Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); bool result = zproc_running (zproc->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zproc::_wait) { Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `hang`"); //bool hang; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool hang; if (info [0]->IsBoolean ()) { hang = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`hang` must be a Boolean"); int result = zproc_wait (zproc->self, (bool) hang); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zproc::_kill) { Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `signal`"); //int signal; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int signal; if (info [0]->IsNumber ()) { signal = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`signal` must be a number"); zproc_kill (zproc->self, (int) signal); } NAN_METHOD (Zproc::_set_verbose) { Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zproc_set_verbose (zproc->self, (bool) verbose); } NAN_METHOD (Zproc::_czmq_version) { int result = zproc_czmq_version (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zproc::_interrupted) { bool result = zproc_interrupted (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zproc::_has_curve) { bool result = zproc_has_curve (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zproc::_hostname) { char *result = (char *) zproc_hostname (); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zproc::_daemonize) { char *workdir; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `workdir`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`workdir` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String workdir_utf8 (info [0].As()); workdir = *workdir_utf8; //} //bjornw end zproc_daemonize ((const char *)workdir); } NAN_METHOD (Zproc::_run_as) { char *lockfile; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `lockfile`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`lockfile` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String lockfile_utf8 (info [0].As()); lockfile = *lockfile_utf8; //} //bjornw end char *group; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `group`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`group` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String group_utf8 (info [1].As()); group = *group_utf8; //} //bjornw end char *user; if (info [2]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `user`"); else if (!info [2]->IsString ()) return Nan::ThrowTypeError ("`user` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String user_utf8 (info [2].As()); user = *user_utf8; //} //bjornw end zproc_run_as ((const char *)lockfile, (const char *)group, (const char *)user); } NAN_METHOD (Zproc::_set_io_threads) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `io_threads`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`io_threads` must be a number"); size_t io_threads = Nan::To(info [0]).FromJust (); zproc_set_io_threads ((size_t) io_threads); } NAN_METHOD (Zproc::_set_max_sockets) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `max_sockets`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`max_sockets` must be a number"); size_t max_sockets = Nan::To(info [0]).FromJust (); zproc_set_max_sockets ((size_t) max_sockets); } NAN_METHOD (Zproc::_set_biface) { char *value; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `value`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`value` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String value_utf8 (info [0].As()); value = *value_utf8; //} //bjornw end zproc_set_biface ((const char *)value); } NAN_METHOD (Zproc::_biface) { char *result = (char *) zproc_biface (); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zproc::_set_log_ident) { char *value; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `value`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`value` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String value_utf8 (info [0].As()); value = *value_utf8; //} //bjornw end zproc_set_log_ident ((const char *)value); } NAN_METHOD (Zproc::_set_log_sender) { char *endpoint; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `endpoint`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`endpoint` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String endpoint_utf8 (info [0].As()); endpoint = *endpoint_utf8; //} //bjornw end zproc_set_log_sender ((const char *)endpoint); } NAN_METHOD (Zproc::_set_log_system) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `logsystem`"); //bool logsystem; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool logsystem; if (info [0]->IsBoolean ()) { logsystem = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`logsystem` must be a Boolean"); zproc_set_log_system ((bool) logsystem); } NAN_METHOD (Zproc::_log_error) { char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zproc_log_error ("%s", format); } NAN_METHOD (Zproc::_log_warning) { char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zproc_log_warning ("%s", format); } NAN_METHOD (Zproc::_log_notice) { char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zproc_log_notice ("%s", format); } NAN_METHOD (Zproc::_log_info) { char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zproc_log_info ("%s", format); } NAN_METHOD (Zproc::_log_debug) { char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zproc_log_debug ("%s", format); } NAN_METHOD (Zproc::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zproc_test ((bool) verbose); } Nan::Persistent &Zproc::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zsock::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zsock").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "bind", _bind); Nan::SetPrototypeMethod (tpl, "endpoint", _endpoint); Nan::SetPrototypeMethod (tpl, "unbind", _unbind); Nan::SetPrototypeMethod (tpl, "connect", _connect); Nan::SetPrototypeMethod (tpl, "disconnect", _disconnect); Nan::SetPrototypeMethod (tpl, "attach", _attach); Nan::SetPrototypeMethod (tpl, "typeStr", _type_str); Nan::SetPrototypeMethod (tpl, "send", _send); Nan::SetPrototypeMethod (tpl, "recv", _recv); Nan::SetPrototypeMethod (tpl, "bsend", _bsend); Nan::SetPrototypeMethod (tpl, "brecv", _brecv); Nan::SetPrototypeMethod (tpl, "routingId", _routing_id); Nan::SetPrototypeMethod (tpl, "setRoutingId", _set_routing_id); Nan::SetPrototypeMethod (tpl, "setUnbounded", _set_unbounded); Nan::SetPrototypeMethod (tpl, "wait", _wait); Nan::SetPrototypeMethod (tpl, "flush", _flush); Nan::SetPrototypeMethod (tpl, "join", _join); Nan::SetPrototypeMethod (tpl, "leave", _leave); Nan::SetPrototypeMethod (tpl, "heartbeatIvl", _heartbeat_ivl); Nan::SetPrototypeMethod (tpl, "setHeartbeatIvl", _set_heartbeat_ivl); Nan::SetPrototypeMethod (tpl, "heartbeatTtl", _heartbeat_ttl); Nan::SetPrototypeMethod (tpl, "setHeartbeatTtl", _set_heartbeat_ttl); Nan::SetPrototypeMethod (tpl, "heartbeatTimeout", _heartbeat_timeout); Nan::SetPrototypeMethod (tpl, "setHeartbeatTimeout", _set_heartbeat_timeout); Nan::SetPrototypeMethod (tpl, "useFd", _use_fd); Nan::SetPrototypeMethod (tpl, "setUseFd", _set_use_fd); Nan::SetPrototypeMethod (tpl, "setXpubManual", _set_xpub_manual); Nan::SetPrototypeMethod (tpl, "setXpubWelcomeMsg", _set_xpub_welcome_msg); Nan::SetPrototypeMethod (tpl, "setStreamNotify", _set_stream_notify); Nan::SetPrototypeMethod (tpl, "invertMatching", _invert_matching); Nan::SetPrototypeMethod (tpl, "setInvertMatching", _set_invert_matching); Nan::SetPrototypeMethod (tpl, "setXpubVerboser", _set_xpub_verboser); Nan::SetPrototypeMethod (tpl, "connectTimeout", _connect_timeout); Nan::SetPrototypeMethod (tpl, "setConnectTimeout", _set_connect_timeout); Nan::SetPrototypeMethod (tpl, "tcpMaxrt", _tcp_maxrt); Nan::SetPrototypeMethod (tpl, "setTcpMaxrt", _set_tcp_maxrt); Nan::SetPrototypeMethod (tpl, "threadSafe", _thread_safe); Nan::SetPrototypeMethod (tpl, "multicastMaxtpdu", _multicast_maxtpdu); Nan::SetPrototypeMethod (tpl, "setMulticastMaxtpdu", _set_multicast_maxtpdu); Nan::SetPrototypeMethod (tpl, "vmciBufferSize", _vmci_buffer_size); Nan::SetPrototypeMethod (tpl, "setVmciBufferSize", _set_vmci_buffer_size); Nan::SetPrototypeMethod (tpl, "vmciBufferMinSize", _vmci_buffer_min_size); Nan::SetPrototypeMethod (tpl, "setVmciBufferMinSize", _set_vmci_buffer_min_size); Nan::SetPrototypeMethod (tpl, "vmciBufferMaxSize", _vmci_buffer_max_size); Nan::SetPrototypeMethod (tpl, "setVmciBufferMaxSize", _set_vmci_buffer_max_size); Nan::SetPrototypeMethod (tpl, "vmciConnectTimeout", _vmci_connect_timeout); Nan::SetPrototypeMethod (tpl, "setVmciConnectTimeout", _set_vmci_connect_timeout); Nan::SetPrototypeMethod (tpl, "tos", _tos); Nan::SetPrototypeMethod (tpl, "setTos", _set_tos); Nan::SetPrototypeMethod (tpl, "setRouterHandover", _set_router_handover); Nan::SetPrototypeMethod (tpl, "setConnectRid", _set_connect_rid); Nan::SetPrototypeMethod (tpl, "setConnectRidBin", _set_connect_rid_bin); Nan::SetPrototypeMethod (tpl, "handshakeIvl", _handshake_ivl); Nan::SetPrototypeMethod (tpl, "setHandshakeIvl", _set_handshake_ivl); Nan::SetPrototypeMethod (tpl, "socksProxy", _socks_proxy); Nan::SetPrototypeMethod (tpl, "setSocksProxy", _set_socks_proxy); Nan::SetPrototypeMethod (tpl, "setXpubNodrop", _set_xpub_nodrop); Nan::SetPrototypeMethod (tpl, "setRouterMandatory", _set_router_mandatory); Nan::SetPrototypeMethod (tpl, "setProbeRouter", _set_probe_router); Nan::SetPrototypeMethod (tpl, "setReqRelaxed", _set_req_relaxed); Nan::SetPrototypeMethod (tpl, "setReqCorrelate", _set_req_correlate); Nan::SetPrototypeMethod (tpl, "setConflate", _set_conflate); Nan::SetPrototypeMethod (tpl, "zapDomain", _zap_domain); Nan::SetPrototypeMethod (tpl, "setZapDomain", _set_zap_domain); Nan::SetPrototypeMethod (tpl, "mechanism", _mechanism); Nan::SetPrototypeMethod (tpl, "plainServer", _plain_server); Nan::SetPrototypeMethod (tpl, "setPlainServer", _set_plain_server); Nan::SetPrototypeMethod (tpl, "plainUsername", _plain_username); Nan::SetPrototypeMethod (tpl, "setPlainUsername", _set_plain_username); Nan::SetPrototypeMethod (tpl, "plainPassword", _plain_password); Nan::SetPrototypeMethod (tpl, "setPlainPassword", _set_plain_password); Nan::SetPrototypeMethod (tpl, "curveServer", _curve_server); Nan::SetPrototypeMethod (tpl, "setCurveServer", _set_curve_server); Nan::SetPrototypeMethod (tpl, "curvePublickey", _curve_publickey); Nan::SetPrototypeMethod (tpl, "setCurvePublickey", _set_curve_publickey); Nan::SetPrototypeMethod (tpl, "setCurvePublickeyBin", _set_curve_publickey_bin); Nan::SetPrototypeMethod (tpl, "curveSecretkey", _curve_secretkey); Nan::SetPrototypeMethod (tpl, "setCurveSecretkey", _set_curve_secretkey); Nan::SetPrototypeMethod (tpl, "setCurveSecretkeyBin", _set_curve_secretkey_bin); Nan::SetPrototypeMethod (tpl, "curveServerkey", _curve_serverkey); Nan::SetPrototypeMethod (tpl, "setCurveServerkey", _set_curve_serverkey); Nan::SetPrototypeMethod (tpl, "setCurveServerkeyBin", _set_curve_serverkey_bin); Nan::SetPrototypeMethod (tpl, "gssapiServer", _gssapi_server); Nan::SetPrototypeMethod (tpl, "setGssapiServer", _set_gssapi_server); Nan::SetPrototypeMethod (tpl, "gssapiPlaintext", _gssapi_plaintext); Nan::SetPrototypeMethod (tpl, "setGssapiPlaintext", _set_gssapi_plaintext); Nan::SetPrototypeMethod (tpl, "gssapiPrincipal", _gssapi_principal); Nan::SetPrototypeMethod (tpl, "setGssapiPrincipal", _set_gssapi_principal); Nan::SetPrototypeMethod (tpl, "gssapiServicePrincipal", _gssapi_service_principal); Nan::SetPrototypeMethod (tpl, "setGssapiServicePrincipal", _set_gssapi_service_principal); Nan::SetPrototypeMethod (tpl, "ipv6", _ipv6); Nan::SetPrototypeMethod (tpl, "setIpv6", _set_ipv6); Nan::SetPrototypeMethod (tpl, "immediate", _immediate); Nan::SetPrototypeMethod (tpl, "setImmediate", _set_immediate); Nan::SetPrototypeMethod (tpl, "sndhwm", _sndhwm); Nan::SetPrototypeMethod (tpl, "setSndhwm", _set_sndhwm); Nan::SetPrototypeMethod (tpl, "rcvhwm", _rcvhwm); Nan::SetPrototypeMethod (tpl, "setRcvhwm", _set_rcvhwm); Nan::SetPrototypeMethod (tpl, "maxmsgsize", _maxmsgsize); Nan::SetPrototypeMethod (tpl, "setMaxmsgsize", _set_maxmsgsize); Nan::SetPrototypeMethod (tpl, "multicastHops", _multicast_hops); Nan::SetPrototypeMethod (tpl, "setMulticastHops", _set_multicast_hops); Nan::SetPrototypeMethod (tpl, "setXpubVerbose", _set_xpub_verbose); Nan::SetPrototypeMethod (tpl, "tcpKeepalive", _tcp_keepalive); Nan::SetPrototypeMethod (tpl, "setTcpKeepalive", _set_tcp_keepalive); Nan::SetPrototypeMethod (tpl, "tcpKeepaliveIdle", _tcp_keepalive_idle); Nan::SetPrototypeMethod (tpl, "setTcpKeepaliveIdle", _set_tcp_keepalive_idle); Nan::SetPrototypeMethod (tpl, "tcpKeepaliveCnt", _tcp_keepalive_cnt); Nan::SetPrototypeMethod (tpl, "setTcpKeepaliveCnt", _set_tcp_keepalive_cnt); Nan::SetPrototypeMethod (tpl, "tcpKeepaliveIntvl", _tcp_keepalive_intvl); Nan::SetPrototypeMethod (tpl, "setTcpKeepaliveIntvl", _set_tcp_keepalive_intvl); Nan::SetPrototypeMethod (tpl, "tcpAcceptFilter", _tcp_accept_filter); Nan::SetPrototypeMethod (tpl, "setTcpAcceptFilter", _set_tcp_accept_filter); Nan::SetPrototypeMethod (tpl, "lastEndpoint", _last_endpoint); Nan::SetPrototypeMethod (tpl, "setRouterRaw", _set_router_raw); Nan::SetPrototypeMethod (tpl, "ipv4only", _ipv4only); Nan::SetPrototypeMethod (tpl, "setIpv4only", _set_ipv4only); Nan::SetPrototypeMethod (tpl, "setDelayAttachOnConnect", _set_delay_attach_on_connect); Nan::SetPrototypeMethod (tpl, "hwm", _hwm); Nan::SetPrototypeMethod (tpl, "setHwm", _set_hwm); Nan::SetPrototypeMethod (tpl, "swap", _swap); Nan::SetPrototypeMethod (tpl, "setSwap", _set_swap); Nan::SetPrototypeMethod (tpl, "affinity", _affinity); Nan::SetPrototypeMethod (tpl, "setAffinity", _set_affinity); Nan::SetPrototypeMethod (tpl, "identity", _identity); Nan::SetPrototypeMethod (tpl, "setIdentity", _set_identity); Nan::SetPrototypeMethod (tpl, "rate", _rate); Nan::SetPrototypeMethod (tpl, "setRate", _set_rate); Nan::SetPrototypeMethod (tpl, "recoveryIvl", _recovery_ivl); Nan::SetPrototypeMethod (tpl, "setRecoveryIvl", _set_recovery_ivl); Nan::SetPrototypeMethod (tpl, "recoveryIvlMsec", _recovery_ivl_msec); Nan::SetPrototypeMethod (tpl, "setRecoveryIvlMsec", _set_recovery_ivl_msec); Nan::SetPrototypeMethod (tpl, "mcastLoop", _mcast_loop); Nan::SetPrototypeMethod (tpl, "setMcastLoop", _set_mcast_loop); Nan::SetPrototypeMethod (tpl, "rcvtimeo", _rcvtimeo); Nan::SetPrototypeMethod (tpl, "setRcvtimeo", _set_rcvtimeo); Nan::SetPrototypeMethod (tpl, "sndtimeo", _sndtimeo); Nan::SetPrototypeMethod (tpl, "setSndtimeo", _set_sndtimeo); Nan::SetPrototypeMethod (tpl, "sndbuf", _sndbuf); Nan::SetPrototypeMethod (tpl, "setSndbuf", _set_sndbuf); Nan::SetPrototypeMethod (tpl, "rcvbuf", _rcvbuf); Nan::SetPrototypeMethod (tpl, "setRcvbuf", _set_rcvbuf); Nan::SetPrototypeMethod (tpl, "linger", _linger); Nan::SetPrototypeMethod (tpl, "setLinger", _set_linger); Nan::SetPrototypeMethod (tpl, "reconnectIvl", _reconnect_ivl); Nan::SetPrototypeMethod (tpl, "setReconnectIvl", _set_reconnect_ivl); Nan::SetPrototypeMethod (tpl, "reconnectIvlMax", _reconnect_ivl_max); Nan::SetPrototypeMethod (tpl, "setReconnectIvlMax", _set_reconnect_ivl_max); Nan::SetPrototypeMethod (tpl, "backlog", _backlog); Nan::SetPrototypeMethod (tpl, "setBacklog", _set_backlog); Nan::SetPrototypeMethod (tpl, "setSubscribe", _set_subscribe); Nan::SetPrototypeMethod (tpl, "setUnsubscribe", _set_unsubscribe); Nan::SetPrototypeMethod (tpl, "type", _type); Nan::SetPrototypeMethod (tpl, "rcvmore", _rcvmore); Nan::SetPrototypeMethod (tpl, "events", _events); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zsock").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zsock::Zsock (int type) { self = zsock_new ((int) type); } Zsock::Zsock (zsock_t *self_) { self = self_; } Zsock::~Zsock () { } NAN_METHOD (Zsock::New) { assert (info.IsConstructCall ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `type`"); //int type; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int type; if (info [0]->IsString ()) { Nan::Utf8String type_utf8 (info [0].As()); // bjornw: check if we need to remove scope here char *type_name = *type_utf8; for (char *type_ptr = type_name; *type_ptr; type_ptr++) *type_ptr = tolower (*type_ptr); if (streq (type_name, "pair")) type = ZMQ_PAIR; else if (streq (type_name, "pub")) type = ZMQ_PUB; else if (streq (type_name, "sub")) type = ZMQ_SUB; else if (streq (type_name, "req")) type = ZMQ_REQ; else if (streq (type_name, "rep")) type = ZMQ_REP; else if (streq (type_name, "dealer")) type = ZMQ_DEALER; else if (streq (type_name, "router")) type = ZMQ_ROUTER; else if (streq (type_name, "pull")) type = ZMQ_PULL; else if (streq (type_name, "push")) type = ZMQ_PUSH; else if (streq (type_name, "xpub")) type = ZMQ_XPUB; else if (streq (type_name, "xsub")) type = ZMQ_XSUB; else if (streq (type_name, "stream")) type = 11; else if (streq (type_name, "server")) type = 12; else if (streq (type_name, "client")) type = 13; else if (streq (type_name, "radio")) type = 14; else if (streq (type_name, "dish")) type = 15; else if (streq (type_name, "gather")) type = 16; else if (streq (type_name, "scatter")) type = 17; else return Nan::ThrowTypeError ("`type` not a valid string"); } else if (info [0]->IsNumber ()) { type = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`type` must be a number or string"); Zsock *zsock = new Zsock ((int) type); if (zsock) { zsock->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zsock::destroy) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); zsock_destroy (&zsock->self); } NAN_METHOD (Zsock::defined) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zsock->self != NULL)); } NAN_METHOD (Zsock::_bind) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end int result = zsock_bind (zsock->self, "%s", format); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_endpoint) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_endpoint (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_unbind) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end int result = zsock_unbind (zsock->self, "%s", format); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_connect) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end int result = zsock_connect (zsock->self, "%s", format); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_disconnect) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end int result = zsock_disconnect (zsock->self, "%s", format); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_attach) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *endpoints; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `endpoints`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`endpoints` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String endpoints_utf8 (info [0].As()); endpoints = *endpoints_utf8; //} //bjornw end if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `serverish`"); //bool serverish; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool serverish; if (info [1]->IsBoolean ()) { serverish = Nan::To(info [1]).FromJust (); } else return Nan::ThrowTypeError ("`serverish` must be a Boolean"); int result = zsock_attach (zsock->self, (const char *)endpoints, (bool) serverish); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_type_str) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_type_str (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_send) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *picture; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `picture`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`picture` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String picture_utf8 (info [0].As()); picture = *picture_utf8; //} //bjornw end int result = zsock_send (zsock->self, (const char *)picture); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_recv) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *picture; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `picture`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`picture` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String picture_utf8 (info [0].As()); picture = *picture_utf8; //} //bjornw end int result = zsock_recv (zsock->self, (const char *)picture); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_bsend) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *picture; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `picture`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`picture` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String picture_utf8 (info [0].As()); picture = *picture_utf8; //} //bjornw end int result = zsock_bsend (zsock->self, (const char *)picture); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_brecv) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *picture; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `picture`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`picture` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String picture_utf8 (info [0].As()); picture = *picture_utf8; //} //bjornw end int result = zsock_brecv (zsock->self, (const char *)picture); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_routing_id) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); uint32_t result = zsock_routing_id (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_routing_id) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `routing id`"); //uint32_t routing_id; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int uint32_t routing_id; if (info [0]->IsNumber ()) { routing_id = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`routing id` must be a number"); zsock_set_routing_id (zsock->self, (uint32_t) routing_id); } NAN_METHOD (Zsock::_set_unbounded) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); zsock_set_unbounded (zsock->self); } NAN_METHOD (Zsock::_wait) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_wait (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_flush) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); zsock_flush (zsock->self); } NAN_METHOD (Zsock::_join) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *group; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `group`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`group` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String group_utf8 (info [0].As()); group = *group_utf8; //} //bjornw end int result = zsock_join (zsock->self, (const char *)group); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_leave) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *group; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `group`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`group` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String group_utf8 (info [0].As()); group = *group_utf8; //} //bjornw end int result = zsock_leave (zsock->self, (const char *)group); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_heartbeat_ivl) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_heartbeat_ivl (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_heartbeat_ivl) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `heartbeat ivl`"); //int heartbeat_ivl; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int heartbeat_ivl; if (info [0]->IsNumber ()) { heartbeat_ivl = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`heartbeat ivl` must be a number"); zsock_set_heartbeat_ivl (zsock->self, (int) heartbeat_ivl); } NAN_METHOD (Zsock::_heartbeat_ttl) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_heartbeat_ttl (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_heartbeat_ttl) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `heartbeat ttl`"); //int heartbeat_ttl; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int heartbeat_ttl; if (info [0]->IsNumber ()) { heartbeat_ttl = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`heartbeat ttl` must be a number"); zsock_set_heartbeat_ttl (zsock->self, (int) heartbeat_ttl); } NAN_METHOD (Zsock::_heartbeat_timeout) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_heartbeat_timeout (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_heartbeat_timeout) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `heartbeat timeout`"); //int heartbeat_timeout; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int heartbeat_timeout; if (info [0]->IsNumber ()) { heartbeat_timeout = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`heartbeat timeout` must be a number"); zsock_set_heartbeat_timeout (zsock->self, (int) heartbeat_timeout); } NAN_METHOD (Zsock::_use_fd) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_use_fd (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_use_fd) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `use fd`"); //int use_fd; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int use_fd; if (info [0]->IsNumber ()) { use_fd = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`use fd` must be a number"); zsock_set_use_fd (zsock->self, (int) use_fd); } NAN_METHOD (Zsock::_set_xpub_manual) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `xpub manual`"); //int xpub_manual; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int xpub_manual; if (info [0]->IsNumber ()) { xpub_manual = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`xpub manual` must be a number"); zsock_set_xpub_manual (zsock->self, (int) xpub_manual); } NAN_METHOD (Zsock::_set_xpub_welcome_msg) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *xpub_welcome_msg; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `xpub welcome msg`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`xpub welcome msg` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String xpub_welcome_msg_utf8 (info [0].As()); xpub_welcome_msg = *xpub_welcome_msg_utf8; //} //bjornw end zsock_set_xpub_welcome_msg (zsock->self, (const char *)xpub_welcome_msg); } NAN_METHOD (Zsock::_set_stream_notify) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `stream notify`"); //int stream_notify; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int stream_notify; if (info [0]->IsNumber ()) { stream_notify = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`stream notify` must be a number"); zsock_set_stream_notify (zsock->self, (int) stream_notify); } NAN_METHOD (Zsock::_invert_matching) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_invert_matching (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_invert_matching) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `invert matching`"); //int invert_matching; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int invert_matching; if (info [0]->IsNumber ()) { invert_matching = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`invert matching` must be a number"); zsock_set_invert_matching (zsock->self, (int) invert_matching); } NAN_METHOD (Zsock::_set_xpub_verboser) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `xpub verboser`"); //int xpub_verboser; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int xpub_verboser; if (info [0]->IsNumber ()) { xpub_verboser = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`xpub verboser` must be a number"); zsock_set_xpub_verboser (zsock->self, (int) xpub_verboser); } NAN_METHOD (Zsock::_connect_timeout) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_connect_timeout (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_connect_timeout) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `connect timeout`"); //int connect_timeout; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int connect_timeout; if (info [0]->IsNumber ()) { connect_timeout = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`connect timeout` must be a number"); zsock_set_connect_timeout (zsock->self, (int) connect_timeout); } NAN_METHOD (Zsock::_tcp_maxrt) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_tcp_maxrt (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_tcp_maxrt) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `tcp maxrt`"); //int tcp_maxrt; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int tcp_maxrt; if (info [0]->IsNumber ()) { tcp_maxrt = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`tcp maxrt` must be a number"); zsock_set_tcp_maxrt (zsock->self, (int) tcp_maxrt); } NAN_METHOD (Zsock::_thread_safe) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_thread_safe (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_multicast_maxtpdu) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_multicast_maxtpdu (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_multicast_maxtpdu) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `multicast maxtpdu`"); //int multicast_maxtpdu; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int multicast_maxtpdu; if (info [0]->IsNumber ()) { multicast_maxtpdu = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`multicast maxtpdu` must be a number"); zsock_set_multicast_maxtpdu (zsock->self, (int) multicast_maxtpdu); } NAN_METHOD (Zsock::_vmci_buffer_size) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_vmci_buffer_size (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_vmci_buffer_size) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `vmci buffer size`"); //int vmci_buffer_size; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int vmci_buffer_size; if (info [0]->IsNumber ()) { vmci_buffer_size = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`vmci buffer size` must be a number"); zsock_set_vmci_buffer_size (zsock->self, (int) vmci_buffer_size); } NAN_METHOD (Zsock::_vmci_buffer_min_size) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_vmci_buffer_min_size (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_vmci_buffer_min_size) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `vmci buffer min size`"); //int vmci_buffer_min_size; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int vmci_buffer_min_size; if (info [0]->IsNumber ()) { vmci_buffer_min_size = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`vmci buffer min size` must be a number"); zsock_set_vmci_buffer_min_size (zsock->self, (int) vmci_buffer_min_size); } NAN_METHOD (Zsock::_vmci_buffer_max_size) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_vmci_buffer_max_size (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_vmci_buffer_max_size) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `vmci buffer max size`"); //int vmci_buffer_max_size; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int vmci_buffer_max_size; if (info [0]->IsNumber ()) { vmci_buffer_max_size = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`vmci buffer max size` must be a number"); zsock_set_vmci_buffer_max_size (zsock->self, (int) vmci_buffer_max_size); } NAN_METHOD (Zsock::_vmci_connect_timeout) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_vmci_connect_timeout (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_vmci_connect_timeout) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `vmci connect timeout`"); //int vmci_connect_timeout; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int vmci_connect_timeout; if (info [0]->IsNumber ()) { vmci_connect_timeout = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`vmci connect timeout` must be a number"); zsock_set_vmci_connect_timeout (zsock->self, (int) vmci_connect_timeout); } NAN_METHOD (Zsock::_tos) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_tos (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_tos) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `tos`"); //int tos; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int tos; if (info [0]->IsNumber ()) { tos = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`tos` must be a number"); zsock_set_tos (zsock->self, (int) tos); } NAN_METHOD (Zsock::_set_router_handover) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `router handover`"); //int router_handover; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int router_handover; if (info [0]->IsNumber ()) { router_handover = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`router handover` must be a number"); zsock_set_router_handover (zsock->self, (int) router_handover); } NAN_METHOD (Zsock::_set_connect_rid) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *connect_rid; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `connect rid`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`connect rid` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String connect_rid_utf8 (info [0].As()); connect_rid = *connect_rid_utf8; //} //bjornw end zsock_set_connect_rid (zsock->self, (const char *)connect_rid); } NAN_METHOD (Zsock::_set_connect_rid_bin) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *connect_rid = (const byte *) node::Buffer::Data (buffer_node); zsock_set_connect_rid_bin (zsock->self, (const byte *)connect_rid); } NAN_METHOD (Zsock::_handshake_ivl) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_handshake_ivl (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_handshake_ivl) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `handshake ivl`"); //int handshake_ivl; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int handshake_ivl; if (info [0]->IsNumber ()) { handshake_ivl = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`handshake ivl` must be a number"); zsock_set_handshake_ivl (zsock->self, (int) handshake_ivl); } NAN_METHOD (Zsock::_socks_proxy) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_socks_proxy (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_set_socks_proxy) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *socks_proxy; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `socks proxy`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`socks proxy` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String socks_proxy_utf8 (info [0].As()); socks_proxy = *socks_proxy_utf8; //} //bjornw end zsock_set_socks_proxy (zsock->self, (const char *)socks_proxy); } NAN_METHOD (Zsock::_set_xpub_nodrop) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `xpub nodrop`"); //int xpub_nodrop; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int xpub_nodrop; if (info [0]->IsNumber ()) { xpub_nodrop = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`xpub nodrop` must be a number"); zsock_set_xpub_nodrop (zsock->self, (int) xpub_nodrop); } NAN_METHOD (Zsock::_set_router_mandatory) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `router mandatory`"); //int router_mandatory; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int router_mandatory; if (info [0]->IsNumber ()) { router_mandatory = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`router mandatory` must be a number"); zsock_set_router_mandatory (zsock->self, (int) router_mandatory); } NAN_METHOD (Zsock::_set_probe_router) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `probe router`"); //int probe_router; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int probe_router; if (info [0]->IsNumber ()) { probe_router = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`probe router` must be a number"); zsock_set_probe_router (zsock->self, (int) probe_router); } NAN_METHOD (Zsock::_set_req_relaxed) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `req relaxed`"); //int req_relaxed; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int req_relaxed; if (info [0]->IsNumber ()) { req_relaxed = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`req relaxed` must be a number"); zsock_set_req_relaxed (zsock->self, (int) req_relaxed); } NAN_METHOD (Zsock::_set_req_correlate) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `req correlate`"); //int req_correlate; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int req_correlate; if (info [0]->IsNumber ()) { req_correlate = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`req correlate` must be a number"); zsock_set_req_correlate (zsock->self, (int) req_correlate); } NAN_METHOD (Zsock::_set_conflate) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `conflate`"); //int conflate; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int conflate; if (info [0]->IsNumber ()) { conflate = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`conflate` must be a number"); zsock_set_conflate (zsock->self, (int) conflate); } NAN_METHOD (Zsock::_zap_domain) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_zap_domain (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_set_zap_domain) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *zap_domain; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `zap domain`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`zap domain` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String zap_domain_utf8 (info [0].As()); zap_domain = *zap_domain_utf8; //} //bjornw end zsock_set_zap_domain (zsock->self, (const char *)zap_domain); } NAN_METHOD (Zsock::_mechanism) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_mechanism (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_plain_server) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_plain_server (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_plain_server) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `plain server`"); //int plain_server; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int plain_server; if (info [0]->IsNumber ()) { plain_server = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`plain server` must be a number"); zsock_set_plain_server (zsock->self, (int) plain_server); } NAN_METHOD (Zsock::_plain_username) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_plain_username (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_set_plain_username) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *plain_username; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `plain username`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`plain username` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String plain_username_utf8 (info [0].As()); plain_username = *plain_username_utf8; //} //bjornw end zsock_set_plain_username (zsock->self, (const char *)plain_username); } NAN_METHOD (Zsock::_plain_password) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_plain_password (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_set_plain_password) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *plain_password; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `plain password`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`plain password` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String plain_password_utf8 (info [0].As()); plain_password = *plain_password_utf8; //} //bjornw end zsock_set_plain_password (zsock->self, (const char *)plain_password); } NAN_METHOD (Zsock::_curve_server) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_curve_server (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_curve_server) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `curve server`"); //int curve_server; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int curve_server; if (info [0]->IsNumber ()) { curve_server = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`curve server` must be a number"); zsock_set_curve_server (zsock->self, (int) curve_server); } NAN_METHOD (Zsock::_curve_publickey) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_curve_publickey (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_set_curve_publickey) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *curve_publickey; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `curve publickey`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`curve publickey` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String curve_publickey_utf8 (info [0].As()); curve_publickey = *curve_publickey_utf8; //} //bjornw end zsock_set_curve_publickey (zsock->self, (const char *)curve_publickey); } NAN_METHOD (Zsock::_set_curve_publickey_bin) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *curve_publickey = (const byte *) node::Buffer::Data (buffer_node); zsock_set_curve_publickey_bin (zsock->self, (const byte *)curve_publickey); } NAN_METHOD (Zsock::_curve_secretkey) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_curve_secretkey (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_set_curve_secretkey) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *curve_secretkey; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `curve secretkey`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`curve secretkey` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String curve_secretkey_utf8 (info [0].As()); curve_secretkey = *curve_secretkey_utf8; //} //bjornw end zsock_set_curve_secretkey (zsock->self, (const char *)curve_secretkey); } NAN_METHOD (Zsock::_set_curve_secretkey_bin) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *curve_secretkey = (const byte *) node::Buffer::Data (buffer_node); zsock_set_curve_secretkey_bin (zsock->self, (const byte *)curve_secretkey); } NAN_METHOD (Zsock::_curve_serverkey) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_curve_serverkey (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_set_curve_serverkey) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *curve_serverkey; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `curve serverkey`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`curve serverkey` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String curve_serverkey_utf8 (info [0].As()); curve_serverkey = *curve_serverkey_utf8; //} //bjornw end zsock_set_curve_serverkey (zsock->self, (const char *)curve_serverkey); } NAN_METHOD (Zsock::_set_curve_serverkey_bin) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *curve_serverkey = (const byte *) node::Buffer::Data (buffer_node); zsock_set_curve_serverkey_bin (zsock->self, (const byte *)curve_serverkey); } NAN_METHOD (Zsock::_gssapi_server) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_gssapi_server (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_gssapi_server) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `gssapi server`"); //int gssapi_server; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int gssapi_server; if (info [0]->IsNumber ()) { gssapi_server = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`gssapi server` must be a number"); zsock_set_gssapi_server (zsock->self, (int) gssapi_server); } NAN_METHOD (Zsock::_gssapi_plaintext) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_gssapi_plaintext (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_gssapi_plaintext) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `gssapi plaintext`"); //int gssapi_plaintext; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int gssapi_plaintext; if (info [0]->IsNumber ()) { gssapi_plaintext = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`gssapi plaintext` must be a number"); zsock_set_gssapi_plaintext (zsock->self, (int) gssapi_plaintext); } NAN_METHOD (Zsock::_gssapi_principal) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_gssapi_principal (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_set_gssapi_principal) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *gssapi_principal; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `gssapi principal`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`gssapi principal` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String gssapi_principal_utf8 (info [0].As()); gssapi_principal = *gssapi_principal_utf8; //} //bjornw end zsock_set_gssapi_principal (zsock->self, (const char *)gssapi_principal); } NAN_METHOD (Zsock::_gssapi_service_principal) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_gssapi_service_principal (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_set_gssapi_service_principal) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *gssapi_service_principal; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `gssapi service principal`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`gssapi service principal` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String gssapi_service_principal_utf8 (info [0].As()); gssapi_service_principal = *gssapi_service_principal_utf8; //} //bjornw end zsock_set_gssapi_service_principal (zsock->self, (const char *)gssapi_service_principal); } NAN_METHOD (Zsock::_ipv6) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_ipv6 (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_ipv6) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `ipv6`"); //int ipv6; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int ipv6; if (info [0]->IsNumber ()) { ipv6 = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`ipv6` must be a number"); zsock_set_ipv6 (zsock->self, (int) ipv6); } NAN_METHOD (Zsock::_immediate) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_immediate (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_immediate) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `immediate`"); //int immediate; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int immediate; if (info [0]->IsNumber ()) { immediate = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`immediate` must be a number"); zsock_set_immediate (zsock->self, (int) immediate); } NAN_METHOD (Zsock::_sndhwm) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_sndhwm (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_sndhwm) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `sndhwm`"); //int sndhwm; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int sndhwm; if (info [0]->IsNumber ()) { sndhwm = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`sndhwm` must be a number"); zsock_set_sndhwm (zsock->self, (int) sndhwm); } NAN_METHOD (Zsock::_rcvhwm) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_rcvhwm (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_rcvhwm) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `rcvhwm`"); //int rcvhwm; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int rcvhwm; if (info [0]->IsNumber ()) { rcvhwm = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`rcvhwm` must be a number"); zsock_set_rcvhwm (zsock->self, (int) rcvhwm); } NAN_METHOD (Zsock::_maxmsgsize) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_maxmsgsize (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_maxmsgsize) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `maxmsgsize`"); //int maxmsgsize; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int maxmsgsize; if (info [0]->IsNumber ()) { maxmsgsize = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`maxmsgsize` must be a number"); zsock_set_maxmsgsize (zsock->self, (int) maxmsgsize); } NAN_METHOD (Zsock::_multicast_hops) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_multicast_hops (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_multicast_hops) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `multicast hops`"); //int multicast_hops; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int multicast_hops; if (info [0]->IsNumber ()) { multicast_hops = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`multicast hops` must be a number"); zsock_set_multicast_hops (zsock->self, (int) multicast_hops); } NAN_METHOD (Zsock::_set_xpub_verbose) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `xpub verbose`"); //int xpub_verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int xpub_verbose; if (info [0]->IsNumber ()) { xpub_verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`xpub verbose` must be a number"); zsock_set_xpub_verbose (zsock->self, (int) xpub_verbose); } NAN_METHOD (Zsock::_tcp_keepalive) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_tcp_keepalive (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_tcp_keepalive) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `tcp keepalive`"); //int tcp_keepalive; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int tcp_keepalive; if (info [0]->IsNumber ()) { tcp_keepalive = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`tcp keepalive` must be a number"); zsock_set_tcp_keepalive (zsock->self, (int) tcp_keepalive); } NAN_METHOD (Zsock::_tcp_keepalive_idle) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_tcp_keepalive_idle (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_tcp_keepalive_idle) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `tcp keepalive idle`"); //int tcp_keepalive_idle; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int tcp_keepalive_idle; if (info [0]->IsNumber ()) { tcp_keepalive_idle = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`tcp keepalive idle` must be a number"); zsock_set_tcp_keepalive_idle (zsock->self, (int) tcp_keepalive_idle); } NAN_METHOD (Zsock::_tcp_keepalive_cnt) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_tcp_keepalive_cnt (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_tcp_keepalive_cnt) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `tcp keepalive cnt`"); //int tcp_keepalive_cnt; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int tcp_keepalive_cnt; if (info [0]->IsNumber ()) { tcp_keepalive_cnt = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`tcp keepalive cnt` must be a number"); zsock_set_tcp_keepalive_cnt (zsock->self, (int) tcp_keepalive_cnt); } NAN_METHOD (Zsock::_tcp_keepalive_intvl) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_tcp_keepalive_intvl (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_tcp_keepalive_intvl) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `tcp keepalive intvl`"); //int tcp_keepalive_intvl; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int tcp_keepalive_intvl; if (info [0]->IsNumber ()) { tcp_keepalive_intvl = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`tcp keepalive intvl` must be a number"); zsock_set_tcp_keepalive_intvl (zsock->self, (int) tcp_keepalive_intvl); } NAN_METHOD (Zsock::_tcp_accept_filter) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_tcp_accept_filter (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_set_tcp_accept_filter) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *tcp_accept_filter; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `tcp accept filter`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`tcp accept filter` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String tcp_accept_filter_utf8 (info [0].As()); tcp_accept_filter = *tcp_accept_filter_utf8; //} //bjornw end zsock_set_tcp_accept_filter (zsock->self, (const char *)tcp_accept_filter); } NAN_METHOD (Zsock::_last_endpoint) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_last_endpoint (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_set_router_raw) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `router raw`"); //int router_raw; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int router_raw; if (info [0]->IsNumber ()) { router_raw = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`router raw` must be a number"); zsock_set_router_raw (zsock->self, (int) router_raw); } NAN_METHOD (Zsock::_ipv4only) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_ipv4only (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_ipv4only) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `ipv4only`"); //int ipv4only; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int ipv4only; if (info [0]->IsNumber ()) { ipv4only = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`ipv4only` must be a number"); zsock_set_ipv4only (zsock->self, (int) ipv4only); } NAN_METHOD (Zsock::_set_delay_attach_on_connect) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `delay attach on connect`"); //int delay_attach_on_connect; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int delay_attach_on_connect; if (info [0]->IsNumber ()) { delay_attach_on_connect = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`delay attach on connect` must be a number"); zsock_set_delay_attach_on_connect (zsock->self, (int) delay_attach_on_connect); } NAN_METHOD (Zsock::_hwm) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_hwm (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_hwm) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `hwm`"); //int hwm; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int hwm; if (info [0]->IsNumber ()) { hwm = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`hwm` must be a number"); zsock_set_hwm (zsock->self, (int) hwm); } NAN_METHOD (Zsock::_swap) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_swap (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_swap) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `swap`"); //int swap; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int swap; if (info [0]->IsNumber ()) { swap = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`swap` must be a number"); zsock_set_swap (zsock->self, (int) swap); } NAN_METHOD (Zsock::_affinity) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_affinity (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_affinity) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `affinity`"); //int affinity; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int affinity; if (info [0]->IsNumber ()) { affinity = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`affinity` must be a number"); zsock_set_affinity (zsock->self, (int) affinity); } NAN_METHOD (Zsock::_identity) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zsock_identity (zsock->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsock::_set_identity) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *identity; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `identity`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`identity` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String identity_utf8 (info [0].As()); identity = *identity_utf8; //} //bjornw end zsock_set_identity (zsock->self, (const char *)identity); } NAN_METHOD (Zsock::_rate) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_rate (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_rate) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `rate`"); //int rate; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int rate; if (info [0]->IsNumber ()) { rate = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`rate` must be a number"); zsock_set_rate (zsock->self, (int) rate); } NAN_METHOD (Zsock::_recovery_ivl) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_recovery_ivl (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_recovery_ivl) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `recovery ivl`"); //int recovery_ivl; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int recovery_ivl; if (info [0]->IsNumber ()) { recovery_ivl = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`recovery ivl` must be a number"); zsock_set_recovery_ivl (zsock->self, (int) recovery_ivl); } NAN_METHOD (Zsock::_recovery_ivl_msec) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_recovery_ivl_msec (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_recovery_ivl_msec) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `recovery ivl msec`"); //int recovery_ivl_msec; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int recovery_ivl_msec; if (info [0]->IsNumber ()) { recovery_ivl_msec = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`recovery ivl msec` must be a number"); zsock_set_recovery_ivl_msec (zsock->self, (int) recovery_ivl_msec); } NAN_METHOD (Zsock::_mcast_loop) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_mcast_loop (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_mcast_loop) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `mcast loop`"); //int mcast_loop; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int mcast_loop; if (info [0]->IsNumber ()) { mcast_loop = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`mcast loop` must be a number"); zsock_set_mcast_loop (zsock->self, (int) mcast_loop); } NAN_METHOD (Zsock::_rcvtimeo) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_rcvtimeo (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_rcvtimeo) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `rcvtimeo`"); //int rcvtimeo; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int rcvtimeo; if (info [0]->IsNumber ()) { rcvtimeo = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`rcvtimeo` must be a number"); zsock_set_rcvtimeo (zsock->self, (int) rcvtimeo); } NAN_METHOD (Zsock::_sndtimeo) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_sndtimeo (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_sndtimeo) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `sndtimeo`"); //int sndtimeo; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int sndtimeo; if (info [0]->IsNumber ()) { sndtimeo = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`sndtimeo` must be a number"); zsock_set_sndtimeo (zsock->self, (int) sndtimeo); } NAN_METHOD (Zsock::_sndbuf) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_sndbuf (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_sndbuf) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `sndbuf`"); //int sndbuf; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int sndbuf; if (info [0]->IsNumber ()) { sndbuf = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`sndbuf` must be a number"); zsock_set_sndbuf (zsock->self, (int) sndbuf); } NAN_METHOD (Zsock::_rcvbuf) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_rcvbuf (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_rcvbuf) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `rcvbuf`"); //int rcvbuf; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int rcvbuf; if (info [0]->IsNumber ()) { rcvbuf = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`rcvbuf` must be a number"); zsock_set_rcvbuf (zsock->self, (int) rcvbuf); } NAN_METHOD (Zsock::_linger) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_linger (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_linger) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `linger`"); //int linger; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int linger; if (info [0]->IsNumber ()) { linger = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`linger` must be a number"); zsock_set_linger (zsock->self, (int) linger); } NAN_METHOD (Zsock::_reconnect_ivl) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_reconnect_ivl (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_reconnect_ivl) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `reconnect ivl`"); //int reconnect_ivl; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int reconnect_ivl; if (info [0]->IsNumber ()) { reconnect_ivl = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`reconnect ivl` must be a number"); zsock_set_reconnect_ivl (zsock->self, (int) reconnect_ivl); } NAN_METHOD (Zsock::_reconnect_ivl_max) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_reconnect_ivl_max (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_reconnect_ivl_max) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `reconnect ivl max`"); //int reconnect_ivl_max; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int reconnect_ivl_max; if (info [0]->IsNumber ()) { reconnect_ivl_max = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`reconnect ivl max` must be a number"); zsock_set_reconnect_ivl_max (zsock->self, (int) reconnect_ivl_max); } NAN_METHOD (Zsock::_backlog) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_backlog (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_set_backlog) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `backlog`"); //int backlog; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int backlog; if (info [0]->IsNumber ()) { backlog = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`backlog` must be a number"); zsock_set_backlog (zsock->self, (int) backlog); } NAN_METHOD (Zsock::_set_subscribe) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *subscribe; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `subscribe`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`subscribe` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String subscribe_utf8 (info [0].As()); subscribe = *subscribe_utf8; //} //bjornw end zsock_set_subscribe (zsock->self, (const char *)subscribe); } NAN_METHOD (Zsock::_set_unsubscribe) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); char *unsubscribe; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `unsubscribe`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`unsubscribe` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String unsubscribe_utf8 (info [0].As()); unsubscribe = *unsubscribe_utf8; //} //bjornw end zsock_set_unsubscribe (zsock->self, (const char *)unsubscribe); } NAN_METHOD (Zsock::_type) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_type (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_rcvmore) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_rcvmore (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_events) { Zsock *zsock = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = zsock_events (zsock->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsock::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zsock_test ((bool) verbose); } Nan::Persistent &Zsock::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zstr::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zstr").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "recv", _recv); Nan::SetPrototypeMethod (tpl, "recvx", _recvx); Nan::SetPrototypeMethod (tpl, "recvCompress", _recv_compress); Nan::SetPrototypeMethod (tpl, "send", _send); Nan::SetPrototypeMethod (tpl, "sendm", _sendm); Nan::SetPrototypeMethod (tpl, "sendf", _sendf); Nan::SetPrototypeMethod (tpl, "sendfm", _sendfm); Nan::SetPrototypeMethod (tpl, "sendx", _sendx); Nan::SetPrototypeMethod (tpl, "sendCompress", _send_compress); Nan::SetPrototypeMethod (tpl, "sendmCompress", _sendm_compress); Nan::SetPrototypeMethod (tpl, "str", _str); Nan::SetPrototypeMethod (tpl, "free", _free); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zstr").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zstr::Zstr () { } Zstr::~Zstr () { } NAN_METHOD (Zstr::New) { assert (info.IsConstructCall ()); Zstr *zstr = new Zstr (); if (zstr) { zstr->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zstr::_recv) { Zsock *source = Nan::ObjectWrap::Unwrap(info [0].As()); char *result = (char *) zstr_recv (source->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zstr::_recvx) { Zsock *source = Nan::ObjectWrap::Unwrap(info [0].As()); char *string_p; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `string_p`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`string_p` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String string_p_utf8 (info [1].As()); string_p = *string_p_utf8; //} //bjornw end int result = zstr_recvx (source->self, (char **)&string_p); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zstr::_recv_compress) { Zsock *source = Nan::ObjectWrap::Unwrap(info [0].As()); char *result = (char *) zstr_recv_compress (source->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zstr::_send) { Zsock *dest = Nan::ObjectWrap::Unwrap(info [0].As()); char *string; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `string`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`string` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String string_utf8 (info [1].As()); string = *string_utf8; //} //bjornw end int result = zstr_send (dest->self, (const char *)string); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zstr::_sendm) { Zsock *dest = Nan::ObjectWrap::Unwrap(info [0].As()); char *string; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `string`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`string` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String string_utf8 (info [1].As()); string = *string_utf8; //} //bjornw end int result = zstr_sendm (dest->self, (const char *)string); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zstr::_sendf) { Zsock *dest = Nan::ObjectWrap::Unwrap(info [0].As()); char *format; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [1].As()); format = *format_utf8; //} //bjornw end int result = zstr_sendf (dest->self, "%s", format); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zstr::_sendfm) { Zsock *dest = Nan::ObjectWrap::Unwrap(info [0].As()); char *format; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [1].As()); format = *format_utf8; //} //bjornw end int result = zstr_sendfm (dest->self, "%s", format); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zstr::_sendx) { Zsock *dest = Nan::ObjectWrap::Unwrap(info [0].As()); char *string; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `string`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`string` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String string_utf8 (info [1].As()); string = *string_utf8; //} //bjornw end int result = zstr_sendx (dest->self, (const char *)string); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zstr::_send_compress) { Zsock *dest = Nan::ObjectWrap::Unwrap(info [0].As()); char *string; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `string`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`string` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String string_utf8 (info [1].As()); string = *string_utf8; //} //bjornw end int result = zstr_send_compress (dest->self, (const char *)string); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zstr::_sendm_compress) { Zsock *dest = Nan::ObjectWrap::Unwrap(info [0].As()); char *string; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `string`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`string` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String string_utf8 (info [1].As()); string = *string_utf8; //} //bjornw end int result = zstr_sendm_compress (dest->self, (const char *)string); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zstr::_str) { Zsock *source = Nan::ObjectWrap::Unwrap(info [0].As()); char *result = (char *) zstr_str (source->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zstr::_free) { char *string_p; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `string_p`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`string_p` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String string_p_utf8 (info [0].As()); string_p = *string_p_utf8; //} //bjornw end zstr_free ((char **)&string_p); } NAN_METHOD (Zstr::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zstr_test ((bool) verbose); } Nan::Persistent &Zstr::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zsys::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zsys").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "shutdown", _shutdown); Nan::SetPrototypeMethod (tpl, "sockname", _sockname); Nan::SetPrototypeMethod (tpl, "createPipe", _create_pipe); Nan::SetPrototypeMethod (tpl, "handlerReset", _handler_reset); Nan::SetPrototypeMethod (tpl, "catchInterrupts", _catch_interrupts); Nan::SetPrototypeMethod (tpl, "fileExists", _file_exists); Nan::SetPrototypeMethod (tpl, "fileModified", _file_modified); Nan::SetPrototypeMethod (tpl, "fileMode", _file_mode); Nan::SetPrototypeMethod (tpl, "fileDelete", _file_delete); Nan::SetPrototypeMethod (tpl, "fileStable", _file_stable); Nan::SetPrototypeMethod (tpl, "dirCreate", _dir_create); Nan::SetPrototypeMethod (tpl, "dirDelete", _dir_delete); Nan::SetPrototypeMethod (tpl, "dirChange", _dir_change); Nan::SetPrototypeMethod (tpl, "fileModePrivate", _file_mode_private); Nan::SetPrototypeMethod (tpl, "fileModeDefault", _file_mode_default); Nan::SetPrototypeMethod (tpl, "version", _version); Nan::SetPrototypeMethod (tpl, "sprintf", _sprintf); Nan::SetPrototypeMethod (tpl, "socketError", _socket_error); Nan::SetPrototypeMethod (tpl, "hostname", _hostname); Nan::SetPrototypeMethod (tpl, "daemonize", _daemonize); Nan::SetPrototypeMethod (tpl, "runAs", _run_as); Nan::SetPrototypeMethod (tpl, "hasCurve", _has_curve); Nan::SetPrototypeMethod (tpl, "setIoThreads", _set_io_threads); Nan::SetPrototypeMethod (tpl, "setThreadSchedPolicy", _set_thread_sched_policy); Nan::SetPrototypeMethod (tpl, "setThreadPriority", _set_thread_priority); Nan::SetPrototypeMethod (tpl, "setMaxSockets", _set_max_sockets); Nan::SetPrototypeMethod (tpl, "socketLimit", _socket_limit); Nan::SetPrototypeMethod (tpl, "setMaxMsgsz", _set_max_msgsz); Nan::SetPrototypeMethod (tpl, "maxMsgsz", _max_msgsz); Nan::SetPrototypeMethod (tpl, "setFileStableAgeMsec", _set_file_stable_age_msec); Nan::SetPrototypeMethod (tpl, "fileStableAgeMsec", _file_stable_age_msec); Nan::SetPrototypeMethod (tpl, "setLinger", _set_linger); Nan::SetPrototypeMethod (tpl, "setSndhwm", _set_sndhwm); Nan::SetPrototypeMethod (tpl, "setRcvhwm", _set_rcvhwm); Nan::SetPrototypeMethod (tpl, "setPipehwm", _set_pipehwm); Nan::SetPrototypeMethod (tpl, "pipehwm", _pipehwm); Nan::SetPrototypeMethod (tpl, "setIpv6", _set_ipv6); Nan::SetPrototypeMethod (tpl, "ipv6", _ipv6); Nan::SetPrototypeMethod (tpl, "setInterface", _set_interface); Nan::SetPrototypeMethod (tpl, "interface", _interface); Nan::SetPrototypeMethod (tpl, "setIpv6Address", _set_ipv6_address); Nan::SetPrototypeMethod (tpl, "ipv6Address", _ipv6_address); Nan::SetPrototypeMethod (tpl, "setIpv6McastAddress", _set_ipv6_mcast_address); Nan::SetPrototypeMethod (tpl, "ipv6McastAddress", _ipv6_mcast_address); Nan::SetPrototypeMethod (tpl, "setAutoUseFd", _set_auto_use_fd); Nan::SetPrototypeMethod (tpl, "autoUseFd", _auto_use_fd); Nan::SetPrototypeMethod (tpl, "setLogident", _set_logident); Nan::SetPrototypeMethod (tpl, "setLogsender", _set_logsender); Nan::SetPrototypeMethod (tpl, "setLogsystem", _set_logsystem); Nan::SetPrototypeMethod (tpl, "error", _error); Nan::SetPrototypeMethod (tpl, "warning", _warning); Nan::SetPrototypeMethod (tpl, "notice", _notice); Nan::SetPrototypeMethod (tpl, "info", _info); Nan::SetPrototypeMethod (tpl, "debug", _debug); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zsys").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zsys::Zsys () { } Zsys::~Zsys () { } NAN_METHOD (Zsys::New) { assert (info.IsConstructCall ()); Zsys *zsys = new Zsys (); if (zsys) { zsys->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zsys::_shutdown) { zsys_shutdown (); } NAN_METHOD (Zsys::_sockname) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `socktype`"); //int socktype; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int socktype; if (info [0]->IsNumber ()) { socktype = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`socktype` must be a number"); char *result = (char *) zsys_sockname ((int) socktype); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsys::_create_pipe) { Zsock *backend_p = Nan::ObjectWrap::Unwrap(info [0].As()); zsock_t *result = zsys_create_pipe (&backend_p->self); Zsock *zsock_result = new Zsock (result); if (zsock_result) { // Don't yet know how to return a new object // zsock->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zsys::_handler_reset) { zsys_handler_reset (); } NAN_METHOD (Zsys::_catch_interrupts) { zsys_catch_interrupts (); } NAN_METHOD (Zsys::_file_exists) { char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end bool result = zsys_file_exists ((const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_file_modified) { char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end time_t result = zsys_file_modified ((const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_file_mode) { char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end int result = zsys_file_mode ((const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_file_delete) { char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end int result = zsys_file_delete ((const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_file_stable) { char *filename; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `filename`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`filename` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String filename_utf8 (info [0].As()); filename = *filename_utf8; //} //bjornw end bool result = zsys_file_stable ((const char *)filename); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_dir_create) { char *pathname; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `pathname`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`pathname` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String pathname_utf8 (info [0].As()); pathname = *pathname_utf8; //} //bjornw end int result = zsys_dir_create ((const char *)pathname); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_dir_delete) { char *pathname; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `pathname`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`pathname` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String pathname_utf8 (info [0].As()); pathname = *pathname_utf8; //} //bjornw end int result = zsys_dir_delete ((const char *)pathname); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_dir_change) { char *pathname; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `pathname`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`pathname` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String pathname_utf8 (info [0].As()); pathname = *pathname_utf8; //} //bjornw end int result = zsys_dir_change ((const char *)pathname); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_file_mode_private) { zsys_file_mode_private (); } NAN_METHOD (Zsys::_file_mode_default) { zsys_file_mode_default (); } NAN_METHOD (Zsys::_version) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `major`"); //int * major; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int major; if (info [0]->IsNumber ()) { major = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`major` must be a number"); if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `minor`"); //int * minor; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int minor; if (info [1]->IsNumber ()) { minor = Nan::To(info [1]).FromJust (); } else return Nan::ThrowTypeError ("`minor` must be a number"); if (info [2]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `patch`"); //int * patch; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int patch; if (info [2]->IsNumber ()) { patch = Nan::To(info [2]).FromJust (); } else return Nan::ThrowTypeError ("`patch` must be a number"); zsys_version ((int *) &major, (int *) &minor, (int *) &patch); } NAN_METHOD (Zsys::_sprintf) { char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end char *result = (char *) zsys_sprintf ((const char *)format); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsys::_socket_error) { char *reason; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `reason`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`reason` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String reason_utf8 (info [0].As()); reason = *reason_utf8; //} //bjornw end zsys_socket_error ((const char *)reason); } NAN_METHOD (Zsys::_hostname) { char *result = (char *) zsys_hostname (); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsys::_daemonize) { char *workdir; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `workdir`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`workdir` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String workdir_utf8 (info [0].As()); workdir = *workdir_utf8; //} //bjornw end int result = zsys_daemonize ((const char *)workdir); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_run_as) { char *lockfile; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `lockfile`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`lockfile` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String lockfile_utf8 (info [0].As()); lockfile = *lockfile_utf8; //} //bjornw end char *group; if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `group`"); else if (!info [1]->IsString ()) return Nan::ThrowTypeError ("`group` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String group_utf8 (info [1].As()); group = *group_utf8; //} //bjornw end char *user; if (info [2]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `user`"); else if (!info [2]->IsString ()) return Nan::ThrowTypeError ("`user` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String user_utf8 (info [2].As()); user = *user_utf8; //} //bjornw end int result = zsys_run_as ((const char *)lockfile, (const char *)group, (const char *)user); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_has_curve) { bool result = zsys_has_curve (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_set_io_threads) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `io_threads`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`io_threads` must be a number"); size_t io_threads = Nan::To(info [0]).FromJust (); zsys_set_io_threads ((size_t) io_threads); } NAN_METHOD (Zsys::_set_thread_sched_policy) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `policy`"); //int policy; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int policy; if (info [0]->IsNumber ()) { policy = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`policy` must be a number"); zsys_set_thread_sched_policy ((int) policy); } NAN_METHOD (Zsys::_set_thread_priority) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `priority`"); //int priority; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int priority; if (info [0]->IsNumber ()) { priority = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`priority` must be a number"); zsys_set_thread_priority ((int) priority); } NAN_METHOD (Zsys::_set_max_sockets) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `max sockets`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`max sockets` must be a number"); size_t max_sockets = Nan::To(info [0]).FromJust (); zsys_set_max_sockets ((size_t) max_sockets); } NAN_METHOD (Zsys::_socket_limit) { size_t result = zsys_socket_limit (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_set_max_msgsz) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `max msgsz`"); //int max_msgsz; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int max_msgsz; if (info [0]->IsNumber ()) { max_msgsz = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`max msgsz` must be a number"); zsys_set_max_msgsz ((int) max_msgsz); } NAN_METHOD (Zsys::_max_msgsz) { int result = zsys_max_msgsz (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_set_file_stable_age_msec) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `file stable age msec`"); //int64_t file_stable_age_msec; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int64_t file_stable_age_msec; if (info [0]->IsNumber ()) { file_stable_age_msec = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`file stable age msec` must be a number"); zsys_set_file_stable_age_msec ((int64_t) file_stable_age_msec); } NAN_METHOD (Zsys::_file_stable_age_msec) { int64_t result = zsys_file_stable_age_msec (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_set_linger) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `linger`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`linger` must be a number"); size_t linger = Nan::To(info [0]).FromJust (); zsys_set_linger ((size_t) linger); } NAN_METHOD (Zsys::_set_sndhwm) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `sndhwm`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`sndhwm` must be a number"); size_t sndhwm = Nan::To(info [0]).FromJust (); zsys_set_sndhwm ((size_t) sndhwm); } NAN_METHOD (Zsys::_set_rcvhwm) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `rcvhwm`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`rcvhwm` must be a number"); size_t rcvhwm = Nan::To(info [0]).FromJust (); zsys_set_rcvhwm ((size_t) rcvhwm); } NAN_METHOD (Zsys::_set_pipehwm) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `pipehwm`"); else if (!info [0]->IsNumber ()) return Nan::ThrowTypeError ("`pipehwm` must be a number"); size_t pipehwm = Nan::To(info [0]).FromJust (); zsys_set_pipehwm ((size_t) pipehwm); } NAN_METHOD (Zsys::_pipehwm) { size_t result = zsys_pipehwm (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_set_ipv6) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `ipv6`"); //int ipv6; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int ipv6; if (info [0]->IsNumber ()) { ipv6 = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`ipv6` must be a number"); zsys_set_ipv6 ((int) ipv6); } NAN_METHOD (Zsys::_ipv6) { int result = zsys_ipv6 (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_set_interface) { char *value; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `value`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`value` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String value_utf8 (info [0].As()); value = *value_utf8; //} //bjornw end zsys_set_interface ((const char *)value); } NAN_METHOD (Zsys::_interface) { char *result = (char *) zsys_interface (); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsys::_set_ipv6_address) { char *value; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `value`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`value` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String value_utf8 (info [0].As()); value = *value_utf8; //} //bjornw end zsys_set_ipv6_address ((const char *)value); } NAN_METHOD (Zsys::_ipv6_address) { char *result = (char *) zsys_ipv6_address (); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsys::_set_ipv6_mcast_address) { char *value; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `value`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`value` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String value_utf8 (info [0].As()); value = *value_utf8; //} //bjornw end zsys_set_ipv6_mcast_address ((const char *)value); } NAN_METHOD (Zsys::_ipv6_mcast_address) { char *result = (char *) zsys_ipv6_mcast_address (); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zsys::_set_auto_use_fd) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `auto use fd`"); //int auto_use_fd; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int auto_use_fd; if (info [0]->IsNumber ()) { auto_use_fd = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`auto use fd` must be a number"); zsys_set_auto_use_fd ((int) auto_use_fd); } NAN_METHOD (Zsys::_auto_use_fd) { int result = zsys_auto_use_fd (); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zsys::_set_logident) { char *value; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `value`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`value` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String value_utf8 (info [0].As()); value = *value_utf8; //} //bjornw end zsys_set_logident ((const char *)value); } NAN_METHOD (Zsys::_set_logsender) { char *endpoint; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `endpoint`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`endpoint` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String endpoint_utf8 (info [0].As()); endpoint = *endpoint_utf8; //} //bjornw end zsys_set_logsender ((const char *)endpoint); } NAN_METHOD (Zsys::_set_logsystem) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `logsystem`"); //bool logsystem; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool logsystem; if (info [0]->IsBoolean ()) { logsystem = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`logsystem` must be a Boolean"); zsys_set_logsystem ((bool) logsystem); } NAN_METHOD (Zsys::_error) { char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zsys_error ((const char *)format); } NAN_METHOD (Zsys::_warning) { char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zsys_warning ((const char *)format); } NAN_METHOD (Zsys::_notice) { char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zsys_notice ((const char *)format); } NAN_METHOD (Zsys::_info) { char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zsys_info ((const char *)format); } NAN_METHOD (Zsys::_debug) { char *format; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `format`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`format` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String format_utf8 (info [0].As()); format = *format_utf8; //} //bjornw end zsys_debug ((const char *)format); } NAN_METHOD (Zsys::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zsys_test ((bool) verbose); } Nan::Persistent &Zsys::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Ztimerset::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Ztimerset").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "cancel", _cancel); Nan::SetPrototypeMethod (tpl, "setInterval", _set_interval); Nan::SetPrototypeMethod (tpl, "reset", _reset); Nan::SetPrototypeMethod (tpl, "timeout", _timeout); Nan::SetPrototypeMethod (tpl, "execute", _execute); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Ztimerset").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Ztimerset::Ztimerset (void) { self = ztimerset_new (); } Ztimerset::Ztimerset (ztimerset_t *self_) { self = self_; } Ztimerset::~Ztimerset () { } NAN_METHOD (Ztimerset::New) { assert (info.IsConstructCall ()); Ztimerset *ztimerset = new Ztimerset (); if (ztimerset) { ztimerset->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Ztimerset::destroy) { Ztimerset *ztimerset = Nan::ObjectWrap::Unwrap (info.Holder ()); ztimerset_destroy (&ztimerset->self); } NAN_METHOD (Ztimerset::defined) { Ztimerset *ztimerset = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (ztimerset->self != NULL)); } NAN_METHOD (Ztimerset::_cancel) { Ztimerset *ztimerset = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `timer id`"); //int timer_id; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int timer_id; if (info [0]->IsNumber ()) { timer_id = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`timer id` must be a number"); int result = ztimerset_cancel (ztimerset->self, (int) timer_id); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Ztimerset::_set_interval) { Ztimerset *ztimerset = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `timer id`"); //int timer_id; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int timer_id; if (info [0]->IsNumber ()) { timer_id = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`timer id` must be a number"); if (info [1]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `interval`"); else if (!info [1]->IsNumber ()) return Nan::ThrowTypeError ("`interval` must be a number"); size_t interval = Nan::To(info [1]).FromJust (); int result = ztimerset_set_interval (ztimerset->self, (int) timer_id, (size_t) interval); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Ztimerset::_reset) { Ztimerset *ztimerset = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `timer id`"); //int timer_id; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int int timer_id; if (info [0]->IsNumber ()) { timer_id = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`timer id` must be a number"); int result = ztimerset_reset (ztimerset->self, (int) timer_id); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Ztimerset::_timeout) { Ztimerset *ztimerset = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = ztimerset_timeout (ztimerset->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Ztimerset::_execute) { Ztimerset *ztimerset = Nan::ObjectWrap::Unwrap (info.Holder ()); int result = ztimerset_execute (ztimerset->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Ztimerset::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); ztimerset_test ((bool) verbose); } Nan::Persistent &Ztimerset::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Ztrie::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Ztrie").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "removeRoute", _remove_route); Nan::SetPrototypeMethod (tpl, "matches", _matches); Nan::SetPrototypeMethod (tpl, "hitParameterCount", _hit_parameter_count); Nan::SetPrototypeMethod (tpl, "hitParameters", _hit_parameters); Nan::SetPrototypeMethod (tpl, "hitAsteriskMatch", _hit_asterisk_match); Nan::SetPrototypeMethod (tpl, "print", _print); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Ztrie").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Ztrie::Ztrie (char delimiter) { self = ztrie_new ((char) delimiter); } Ztrie::Ztrie (ztrie_t *self_) { self = self_; } Ztrie::~Ztrie () { } NAN_METHOD (Ztrie::New) { assert (info.IsConstructCall ()); char delimiter; if (info [0]->IsUndefined ()) { return Nan::ThrowTypeError ("method requires a `delimiter`"); } else if (!info [0]->IsString ()) { return Nan::ThrowTypeError ("`delimiter` must be a string"); } //else { // bjornw: remove brackets to keep scope Nan::Utf8String delimiter_utf8 (info [0].As()); if (strlen (*delimiter_utf8) != 1) return Nan::ThrowTypeError ("`delimiter` must be a single character"); delimiter = (*delimiter_utf8) [0]; //} // bjornw end Ztrie *ztrie = new Ztrie ((char) delimiter); if (ztrie) { ztrie->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Ztrie::destroy) { Ztrie *ztrie = Nan::ObjectWrap::Unwrap (info.Holder ()); ztrie_destroy (&ztrie->self); } NAN_METHOD (Ztrie::defined) { Ztrie *ztrie = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (ztrie->self != NULL)); } NAN_METHOD (Ztrie::_remove_route) { Ztrie *ztrie = Nan::ObjectWrap::Unwrap (info.Holder ()); char *path; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `path`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`path` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String path_utf8 (info [0].As()); path = *path_utf8; //} //bjornw end int result = ztrie_remove_route (ztrie->self, (const char *)path); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Ztrie::_matches) { Ztrie *ztrie = Nan::ObjectWrap::Unwrap (info.Holder ()); char *path; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `path`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`path` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String path_utf8 (info [0].As()); path = *path_utf8; //} //bjornw end bool result = ztrie_matches (ztrie->self, (const char *)path); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Ztrie::_hit_parameter_count) { Ztrie *ztrie = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = ztrie_hit_parameter_count (ztrie->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Ztrie::_hit_parameters) { Ztrie *ztrie = Nan::ObjectWrap::Unwrap (info.Holder ()); zhashx_t *result = ztrie_hit_parameters (ztrie->self); Zhashx *zhashx_result = new Zhashx (result); if (zhashx_result) { // Don't yet know how to return a new object // zhashx->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Ztrie::_hit_asterisk_match) { Ztrie *ztrie = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) ztrie_hit_asterisk_match (ztrie->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Ztrie::_print) { Ztrie *ztrie = Nan::ObjectWrap::Unwrap (info.Holder ()); ztrie_print (ztrie->self); } NAN_METHOD (Ztrie::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); ztrie_test ((bool) verbose); } Nan::Persistent &Ztrie::constructor () { static Nan::Persistent my_constructor; return my_constructor; } NAN_MODULE_INIT (Zuuid::Init) { Nan::HandleScope scope; // Prepare constructor template Local tpl = Nan::New (New); tpl->SetClassName (Nan::New ("Zuuid").ToLocalChecked ()); tpl->InstanceTemplate ()->SetInternalFieldCount (1); // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); Nan::SetPrototypeMethod (tpl, "set", _set); Nan::SetPrototypeMethod (tpl, "setStr", _set_str); Nan::SetPrototypeMethod (tpl, "data", _data); Nan::SetPrototypeMethod (tpl, "size", _size); Nan::SetPrototypeMethod (tpl, "str", _str); Nan::SetPrototypeMethod (tpl, "strCanonical", _str_canonical); Nan::SetPrototypeMethod (tpl, "export", _export); Nan::SetPrototypeMethod (tpl, "eq", _eq); Nan::SetPrototypeMethod (tpl, "neq", _neq); Nan::SetPrototypeMethod (tpl, "dup", _dup); Nan::SetPrototypeMethod (tpl, "test", _test); constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ()); Nan::Set (target, Nan::New ("Zuuid").ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ()); } Zuuid::Zuuid (void) { self = zuuid_new (); } Zuuid::Zuuid (zuuid_t *self_) { self = self_; } Zuuid::~Zuuid () { } NAN_METHOD (Zuuid::New) { assert (info.IsConstructCall ()); Zuuid *zuuid = new Zuuid (); if (zuuid) { zuuid->Wrap (info.This ()); info.GetReturnValue ().Set (info.This ()); } } NAN_METHOD (Zuuid::destroy) { Zuuid *zuuid = Nan::ObjectWrap::Unwrap (info.Holder ()); zuuid_destroy (&zuuid->self); } NAN_METHOD (Zuuid::defined) { Zuuid *zuuid = Nan::ObjectWrap::Unwrap (info.Holder ()); info.GetReturnValue ().Set (Nan::New (zuuid->self != NULL)); } NAN_METHOD (Zuuid::_set) { Zuuid *zuuid = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *source = (const byte *) node::Buffer::Data (buffer_node); zuuid_set (zuuid->self, (const byte *)source); } NAN_METHOD (Zuuid::_set_str) { Zuuid *zuuid = Nan::ObjectWrap::Unwrap (info.Holder ()); char *source; if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `source`"); else if (!info [0]->IsString ()) return Nan::ThrowTypeError ("`source` must be a string"); //else { // bjornw: remove brackets to keep scope Nan::Utf8String source_utf8 (info [0].As()); source = *source_utf8; //} //bjornw end int result = zuuid_set_str (zuuid->self, (const char *)source); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zuuid::_data) { Zuuid *zuuid = Nan::ObjectWrap::Unwrap (info.Holder ()); const char *result = (const char *) zuuid_data (zuuid->self); info.GetReturnValue().Set (Nan::CopyBuffer (result, zuuid_size (zuuid->self)).ToLocalChecked ()); } NAN_METHOD (Zuuid::_size) { Zuuid *zuuid = Nan::ObjectWrap::Unwrap (info.Holder ()); size_t result = zuuid_size (zuuid->self); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zuuid::_str) { Zuuid *zuuid = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zuuid_str (zuuid->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zuuid::_str_canonical) { Zuuid *zuuid = Nan::ObjectWrap::Unwrap (info.Holder ()); char *result = (char *) zuuid_str_canonical (zuuid->self); info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); } NAN_METHOD (Zuuid::_export) { Zuuid *zuuid = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *target = (const byte *) node::Buffer::Data (buffer_node); zuuid_export (zuuid->self, (byte *)target); } NAN_METHOD (Zuuid::_eq) { Zuuid *zuuid = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *compare = (const byte *) node::Buffer::Data (buffer_node); bool result = zuuid_eq (zuuid->self, (const byte *)compare); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zuuid::_neq) { Zuuid *zuuid = Nan::ObjectWrap::Unwrap (info.Holder ()); if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a argument to provide data"); Local buffer_node = info [0].As (); const byte *compare = (const byte *) node::Buffer::Data (buffer_node); bool result = zuuid_neq (zuuid->self, (const byte *)compare); info.GetReturnValue ().Set (Nan::New(result)); } NAN_METHOD (Zuuid::_dup) { Zuuid *zuuid = Nan::ObjectWrap::Unwrap (info.Holder ()); zuuid_t *result = zuuid_dup (zuuid->self); Zuuid *zuuid_result = new Zuuid (result); if (zuuid_result) { // Don't yet know how to return a new object // zuuid->Wrap (info.This ()); // info.GetReturnValue ().Set (info.This ()); info.GetReturnValue ().Set (Nan::New(true)); } } NAN_METHOD (Zuuid::_test) { if (info [0]->IsUndefined ()) return Nan::ThrowTypeError ("method requires a `verbose`"); //bool verbose; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int bool verbose; if (info [0]->IsBoolean ()) { verbose = Nan::To(info [0]).FromJust (); } else return Nan::ThrowTypeError ("`verbose` must be a Boolean"); zuuid_test ((bool) verbose); } Nan::Persistent &Zuuid::constructor () { static Nan::Persistent my_constructor; return my_constructor; } extern "C" NAN_MODULE_INIT (czmq_initialize) { Zargs::Init (target); Zarmour::Init (target); Zcert::Init (target); Zcertstore::Init (target); Zchunk::Init (target); Zclock::Init (target); Zconfig::Init (target); Zdigest::Init (target); Zdir::Init (target); ZdirPatch::Init (target); Zfile::Init (target); Zframe::Init (target); Zhash::Init (target); Zhashx::Init (target); Ziflist::Init (target); Zlist::Init (target); Zlistx::Init (target); Zloop::Init (target); Zmsg::Init (target); Zpoller::Init (target); Zproc::Init (target); Zsock::Init (target); Zstr::Init (target); Zsys::Init (target); Ztimerset::Init (target); Ztrie::Init (target); Zuuid::Init (target); } NODE_MODULE (czmq, czmq_initialize) czmq-4.1.0/bindings/python/0000775000372000037200000000000013222211156016501 5ustar00travistravis00000000000000czmq-4.1.0/bindings/python/czmq/0000775000372000037200000000000013222211156017453 5ustar00travistravis00000000000000czmq-4.1.0/bindings/python/czmq/__init__.py0000664000372000037200000000015413222211156021564 0ustar00travistravis00000000000000# This is a skeleton created by zproject. # You can add hand-written code here. from ._czmq_ctypes import * czmq-4.1.0/bindings/python/czmq/_czmq_ctypes.py0000664000372000037200000106577413222211156022551 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ from __future__ import print_function import os, sys from ctypes import * from ctypes.util import find_library # load libc to access free, etc. libcpath = find_library("c") if not libcpath: raise ImportError("Unable to find libc") libc = cdll.LoadLibrary(libcpath) libc.free.argtypes = [c_void_p] libc.free.restype = None def return_fresh_string(char_p): s = string_at(char_p) libc.free(char_p) return s # czmq lib = None # check to see if the shared object was embedded locally, attempt to load it # if not, try to load it using the default system paths... # we need to use os.chdir instead of trying to modify $LD_LIBRARY_PATH and reloading the interpreter t = os.getcwd() p = os.path.join(os.path.dirname(__file__), '..') # find the path to our $project_ctypes.py os.chdir(p) # change directories briefly try: from czmq import libczmq # attempt to import the shared lib if it exists lib = CDLL(libczmq.__file__) # if it exists try to load the shared lib except ImportError: pass finally: os.chdir(t) # switch back to orig dir if not lib: try: # If LD_LIBRARY_PATH or your OSs equivalent is set, this is the only way to # load the library. If we use find_library below, we get the wrong result. if os.name == 'posix': if sys.platform == 'darwin': lib = cdll.LoadLibrary('libczmq.4.dylib') else: lib = cdll.LoadLibrary("libczmq.so.4") elif os.name == 'nt': lib = cdll.LoadLibrary('libczmq.dll') except OSError: libpath = find_library("czmq") if not libpath: raise ImportError("Unable to find libczmq") lib = cdll.LoadLibrary(libpath) class zsock_t(Structure): pass # Empty - only for type checking zsock_p = POINTER(zsock_t) class zactor_t(Structure): pass # Empty - only for type checking zactor_p = POINTER(zactor_t) class zmsg_t(Structure): pass # Empty - only for type checking zmsg_p = POINTER(zmsg_t) class zargs_t(Structure): pass # Empty - only for type checking zargs_p = POINTER(zargs_t) class zarmour_t(Structure): pass # Empty - only for type checking zarmour_p = POINTER(zarmour_t) class zchunk_t(Structure): pass # Empty - only for type checking zchunk_p = POINTER(zchunk_t) class char_t(Structure): pass # Empty - only for type checking char_p = POINTER(char_t) class zcert_t(Structure): pass # Empty - only for type checking zcert_p = POINTER(zcert_t) class zlist_t(Structure): pass # Empty - only for type checking zlist_p = POINTER(zlist_t) class zcertstore_t(Structure): pass # Empty - only for type checking zcertstore_p = POINTER(zcertstore_t) class zlistx_t(Structure): pass # Empty - only for type checking zlistx_p = POINTER(zlistx_t) class FILE(Structure): pass # Empty - only for type checking FILE_p = POINTER(FILE) class zframe_t(Structure): pass # Empty - only for type checking zframe_p = POINTER(zframe_t) class msecs_t(Structure): pass # Empty - only for type checking msecs_p = POINTER(msecs_t) class zconfig_t(Structure): pass # Empty - only for type checking zconfig_p = POINTER(zconfig_t) class zdigest_t(Structure): pass # Empty - only for type checking zdigest_p = POINTER(zdigest_t) class zdir_t(Structure): pass # Empty - only for type checking zdir_p = POINTER(zdir_t) class zhash_t(Structure): pass # Empty - only for type checking zhash_p = POINTER(zhash_t) class zfile_t(Structure): pass # Empty - only for type checking zfile_p = POINTER(zfile_t) class zdir_patch_t(Structure): pass # Empty - only for type checking zdir_patch_p = POINTER(zdir_patch_t) class zhashx_t(Structure): pass # Empty - only for type checking zhashx_p = POINTER(zhashx_t) class ziflist_t(Structure): pass # Empty - only for type checking ziflist_p = POINTER(ziflist_t) class zloop_t(Structure): pass # Empty - only for type checking zloop_p = POINTER(zloop_t) class zmq_pollitem_t(Structure): pass # Empty - only for type checking zmq_pollitem_p = POINTER(zmq_pollitem_t) class zpoller_t(Structure): pass # Empty - only for type checking zpoller_p = POINTER(zpoller_t) class zproc_t(Structure): pass # Empty - only for type checking zproc_p = POINTER(zproc_t) class va_list_t(Structure): pass # Empty - only for type checking va_list_p = POINTER(va_list_t) class socket_t(Structure): pass # Empty - only for type checking socket_p = POINTER(socket_t) class ztimerset_t(Structure): pass # Empty - only for type checking ztimerset_p = POINTER(ztimerset_t) class ztrie_t(Structure): pass # Empty - only for type checking ztrie_p = POINTER(ztrie_t) class zuuid_t(Structure): pass # Empty - only for type checking zuuid_p = POINTER(zuuid_t) def return_py_file(c_file): if not sys.version_info > (3,): PyFile_FromFile_close_cb = CFUNCTYPE(c_int, FILE_p) PyFile_FromFile = pythonapi.PyFile_FromFile PyFile_FromFile.restype = py_object PyFile_FromFile.argtypes = [FILE_p, c_char_p, c_char_p, PyFile_FromFile_close_cb] return PyFile_FromFile(c_file, "", "r+", PyFile_FromFile_close_cb()) else: fileno = libc.fileno fileno.restype = c_int fileno.argtypes = [c_void_p] return os.fdopen(fileno(c_file), r'r+b') def coerce_py_file(obj): if not sys.version_info > (3,): PyFile_AsFile = pythonapi.PyFile_AsFile PyFile_AsFile.restype = FILE_p PyFile_AsFile.argtypes = [py_object] if isinstance(obj, FILE_p): return obj else: return PyFile_AsFile(obj) # Python 3 does not provide a low level buffered I/O (FILE*) API. Had to # resort to direct Standard C library calls. # # https://docs.python.org/3/c-api/file.html. # else: fdopen = libc.fdopen fdopen.restype = FILE_p fdopen.argtypes = [c_int, c_char_p] setbuf = libc.setbuf setbuf.restype = None setbuf.argtypes = [FILE_p, c_char_p] if isinstance(obj, FILE_p): return obj else: fd = obj.fileno() fp = fdopen(fd, obj.mode.encode()) # Make sure the file is opened in unbuffered mode. The test case # "test_zmsg" of the CZMQ Python fails if this mode is not set. setbuf(fp, None) return fp # zactor zactor_fn = CFUNCTYPE(None, zsock_p, c_void_p) zactor_destructor_fn = CFUNCTYPE(None, zactor_p) lib.zactor_new.restype = zactor_p lib.zactor_new.argtypes = [zactor_fn, c_void_p] lib.zactor_destroy.restype = None lib.zactor_destroy.argtypes = [POINTER(zactor_p)] lib.zactor_send.restype = c_int lib.zactor_send.argtypes = [zactor_p, POINTER(zmsg_p)] lib.zactor_recv.restype = zmsg_p lib.zactor_recv.argtypes = [zactor_p] lib.zactor_is.restype = c_bool lib.zactor_is.argtypes = [c_void_p] lib.zactor_resolve.restype = c_void_p lib.zactor_resolve.argtypes = [c_void_p] lib.zactor_sock.restype = zsock_p lib.zactor_sock.argtypes = [zactor_p] lib.zactor_set_destructor.restype = None lib.zactor_set_destructor.argtypes = [zactor_p, zactor_destructor_fn] lib.zactor_test.restype = None lib.zactor_test.argtypes = [c_bool] class Zactor(object): """ provides a simple actor framework """ allow_destruct = False def __init__(self, *args): """ Create a new actor passing arbitrary arguments reference. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zactor_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zactor_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 2) self._as_parameter_ = lib.zactor_new(args[0], args[1]) # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy an actor. """ if self.allow_destruct: lib.zactor_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def send(self, msg_p): """ Send a zmsg message to the actor, take ownership of the message and destroy when it has been sent. """ return lib.zactor_send(self._as_parameter_, byref(zmsg_p.from_param(msg_p))) def recv(self): """ Receive a zmsg message from the actor. Returns NULL if the actor was interrupted before the message could be received, or if there was a timeout on the actor. """ return Zmsg(lib.zactor_recv(self._as_parameter_), True) @staticmethod def is_(self): """ Probe the supplied object, and report if it looks like a zactor_t. """ return lib.zactor_is(self) @staticmethod def resolve(self): """ Probe the supplied reference. If it looks like a zactor_t instance, return the underlying libzmq actor handle; else if it looks like a libzmq actor handle, return the supplied value. """ return c_void_p(lib.zactor_resolve(self)) def sock(self): """ Return the actor's zsock handle. Use this when you absolutely need to work with the zsock instance rather than the actor. """ return Zsock(lib.zactor_sock(self._as_parameter_), False) def set_destructor(self, destructor): """ Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. """ return lib.zactor_set_destructor(self._as_parameter_, destructor) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zactor_test(verbose) # zargs lib.zargs_new.restype = zargs_p lib.zargs_new.argtypes = [c_int, POINTER(c_char_p)] lib.zargs_destroy.restype = None lib.zargs_destroy.argtypes = [POINTER(zargs_p)] lib.zargs_progname.restype = c_char_p lib.zargs_progname.argtypes = [zargs_p] lib.zargs_arguments.restype = c_size_t lib.zargs_arguments.argtypes = [zargs_p] lib.zargs_first.restype = c_char_p lib.zargs_first.argtypes = [zargs_p] lib.zargs_next.restype = c_char_p lib.zargs_next.argtypes = [zargs_p] lib.zargs_param_first.restype = c_char_p lib.zargs_param_first.argtypes = [zargs_p] lib.zargs_param_next.restype = c_char_p lib.zargs_param_next.argtypes = [zargs_p] lib.zargs_param_name.restype = c_char_p lib.zargs_param_name.argtypes = [zargs_p] lib.zargs_param_lookup.restype = c_char_p lib.zargs_param_lookup.argtypes = [zargs_p, c_char_p] lib.zargs_param_lookupx.restype = c_char_p lib.zargs_param_lookupx.argtypes = [zargs_p, c_char_p] lib.zargs_has_help.restype = c_bool lib.zargs_has_help.argtypes = [zargs_p] lib.zargs_param_empty.restype = c_bool lib.zargs_param_empty.argtypes = [c_char_p] lib.zargs_print.restype = None lib.zargs_print.argtypes = [zargs_p] lib.zargs_test.restype = None lib.zargs_test.argtypes = [c_bool] class Zargs(object): """ Platform independent command line argument parsing helpers There are two kind of elements provided by this class foo --named-parameter --parameter with_value positional arguments -a gain-parameter zargs keeps poision only for arguments, parameters are to be accessed like hash. It DOES: * provide easy to use CLASS compatible API for accessing argv * is platform independent * provide getopt_long style -- argument, which delimits parameters from arguments * makes parameters positon independent It does NOT * change argv * provide a "declarative" way to define command line interface In future it SHALL * hide several formats of command line to one (-Idir, --include=dir, --include dir are the same from API pov) """ allow_destruct = False def __init__(self, *args): """ Create a new zargs from command line arguments. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zargs_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zargs_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 2) self._as_parameter_ = lib.zargs_new(args[0], byref(c_char_p.from_param(args[1]))) # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy zargs instance. """ if self.allow_destruct: lib.zargs_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def progname(self): """ Return program name (argv[0]) """ return lib.zargs_progname(self._as_parameter_) def arguments(self): """ Return number of positional arguments """ return lib.zargs_arguments(self._as_parameter_) def first(self): """ Return first positional argument or NULL """ return lib.zargs_first(self._as_parameter_) def next(self): """ Return next positional argument or NULL """ return lib.zargs_next(self._as_parameter_) def param_first(self): """ Return first named parameter value, or NULL if there are no named parameters, or value for which zargs_param_empty (arg) returns true. """ return lib.zargs_param_first(self._as_parameter_) def param_next(self): """ Return next named parameter value, or NULL if there are no named parameters, or value for which zargs_param_empty (arg) returns true. """ return lib.zargs_param_next(self._as_parameter_) def param_name(self): """ Return current parameter name, or NULL if there are no named parameters. """ return lib.zargs_param_name(self._as_parameter_) def param_lookup(self, keys): """ Return value of named parameter, NULL if no given parameter has been specified, or special value for wich zargs_param_empty () returns true. """ return lib.zargs_param_lookup(self._as_parameter_, keys) def param_lookupx(self, keys, *args): """ Return value of named parameter(s), NULL if no given parameter has been specified, or special value for wich zargs_param_empty () returns true. """ return lib.zargs_param_lookupx(self._as_parameter_, keys, *args) def has_help(self): """ Returns true if there are --help -h arguments """ return lib.zargs_has_help(self._as_parameter_) @staticmethod def param_empty(arg): """ Returns true if parameter did not have a value """ return lib.zargs_param_empty(arg) def print(self): """ Print an instance of zargs. """ return lib.zargs_print(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zargs_test(verbose) # zarmour lib.zarmour_new.restype = zarmour_p lib.zarmour_new.argtypes = [] lib.zarmour_destroy.restype = None lib.zarmour_destroy.argtypes = [POINTER(zarmour_p)] lib.zarmour_encode.restype = POINTER(c_char) lib.zarmour_encode.argtypes = [zarmour_p, c_void_p, c_size_t] lib.zarmour_decode.restype = zchunk_p lib.zarmour_decode.argtypes = [zarmour_p, c_char_p] lib.zarmour_mode.restype = c_int lib.zarmour_mode.argtypes = [zarmour_p] lib.zarmour_mode_str.restype = c_char_p lib.zarmour_mode_str.argtypes = [zarmour_p] lib.zarmour_set_mode.restype = None lib.zarmour_set_mode.argtypes = [zarmour_p, c_int] lib.zarmour_pad.restype = c_bool lib.zarmour_pad.argtypes = [zarmour_p] lib.zarmour_set_pad.restype = None lib.zarmour_set_pad.argtypes = [zarmour_p, c_bool] lib.zarmour_pad_char.restype = char_p lib.zarmour_pad_char.argtypes = [zarmour_p] lib.zarmour_set_pad_char.restype = None lib.zarmour_set_pad_char.argtypes = [zarmour_p, char_p] lib.zarmour_line_breaks.restype = c_bool lib.zarmour_line_breaks.argtypes = [zarmour_p] lib.zarmour_set_line_breaks.restype = None lib.zarmour_set_line_breaks.argtypes = [zarmour_p, c_bool] lib.zarmour_line_length.restype = c_size_t lib.zarmour_line_length.argtypes = [zarmour_p] lib.zarmour_set_line_length.restype = None lib.zarmour_set_line_length.argtypes = [zarmour_p, c_size_t] lib.zarmour_print.restype = None lib.zarmour_print.argtypes = [zarmour_p] lib.zarmour_test.restype = None lib.zarmour_test.argtypes = [c_bool] class Zarmour(object): """ armoured text encoding and decoding """ MODE_BASE64_STD = 0 # Standard base 64 MODE_BASE64_URL = 1 # URL and filename friendly base 64 MODE_BASE32_STD = 2 # Standard base 32 MODE_BASE32_HEX = 3 # Extended hex base 32 MODE_BASE16 = 4 # Standard base 16 MODE_Z85 = 5 # Z85 from ZeroMQ RFC 32 allow_destruct = False def __init__(self, *args): """ Create a new zarmour """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zarmour_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zarmour_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.zarmour_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy the zarmour """ if self.allow_destruct: lib.zarmour_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def encode(self, data, size): """ Encode a stream of bytes into an armoured string. Returns the armoured string, or NULL if there was insufficient memory available to allocate a new string. """ return return_fresh_string(lib.zarmour_encode(self._as_parameter_, data, size)) def decode(self, data): """ Decode an armoured string into a chunk. The decoded output is null-terminated, so it may be treated as a string, if that's what it was prior to encoding. """ return Zchunk(lib.zarmour_decode(self._as_parameter_, data), True) def mode(self): """ Get the mode property. """ return lib.zarmour_mode(self._as_parameter_) def mode_str(self): """ Get printable string for mode. """ return lib.zarmour_mode_str(self._as_parameter_) def set_mode(self, mode): """ Set the mode property. """ return lib.zarmour_set_mode(self._as_parameter_, mode) def pad(self): """ Return true if padding is turned on. """ return lib.zarmour_pad(self._as_parameter_) def set_pad(self, pad): """ Turn padding on or off. Default is on. """ return lib.zarmour_set_pad(self._as_parameter_, pad) def pad_char(self): """ Get the padding character. """ return lib.zarmour_pad_char(self._as_parameter_) def set_pad_char(self, pad_char): """ Set the padding character. """ return lib.zarmour_set_pad_char(self._as_parameter_, pad_char) def line_breaks(self): """ Return if splitting output into lines is turned on. Default is off. """ return lib.zarmour_line_breaks(self._as_parameter_) def set_line_breaks(self, line_breaks): """ Turn splitting output into lines on or off. """ return lib.zarmour_set_line_breaks(self._as_parameter_, line_breaks) def line_length(self): """ Get the line length used for splitting lines. """ return lib.zarmour_line_length(self._as_parameter_) def set_line_length(self, line_length): """ Set the line length used for splitting lines. """ return lib.zarmour_set_line_length(self._as_parameter_, line_length) def print(self): """ Print properties of object """ return lib.zarmour_print(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zarmour_test(verbose) # zcert lib.zcert_new.restype = zcert_p lib.zcert_new.argtypes = [] lib.zcert_destroy.restype = None lib.zcert_destroy.argtypes = [POINTER(zcert_p)] lib.zcert_new_from.restype = zcert_p lib.zcert_new_from.argtypes = [c_void_p, c_void_p] lib.zcert_new_from_txt.restype = zcert_p lib.zcert_new_from_txt.argtypes = [c_char_p, c_char_p] lib.zcert_load.restype = zcert_p lib.zcert_load.argtypes = [c_char_p] lib.zcert_public_key.restype = c_void_p lib.zcert_public_key.argtypes = [zcert_p] lib.zcert_secret_key.restype = c_void_p lib.zcert_secret_key.argtypes = [zcert_p] lib.zcert_public_txt.restype = c_char_p lib.zcert_public_txt.argtypes = [zcert_p] lib.zcert_secret_txt.restype = c_char_p lib.zcert_secret_txt.argtypes = [zcert_p] lib.zcert_set_meta.restype = None lib.zcert_set_meta.argtypes = [zcert_p, c_char_p, c_char_p] lib.zcert_unset_meta.restype = None lib.zcert_unset_meta.argtypes = [zcert_p, c_char_p] lib.zcert_meta.restype = c_char_p lib.zcert_meta.argtypes = [zcert_p, c_char_p] lib.zcert_meta_keys.restype = zlist_p lib.zcert_meta_keys.argtypes = [zcert_p] lib.zcert_save.restype = c_int lib.zcert_save.argtypes = [zcert_p, c_char_p] lib.zcert_save_public.restype = c_int lib.zcert_save_public.argtypes = [zcert_p, c_char_p] lib.zcert_save_secret.restype = c_int lib.zcert_save_secret.argtypes = [zcert_p, c_char_p] lib.zcert_apply.restype = None lib.zcert_apply.argtypes = [zcert_p, c_void_p] lib.zcert_dup.restype = zcert_p lib.zcert_dup.argtypes = [zcert_p] lib.zcert_eq.restype = c_bool lib.zcert_eq.argtypes = [zcert_p, zcert_p] lib.zcert_print.restype = None lib.zcert_print.argtypes = [zcert_p] lib.zcert_test.restype = None lib.zcert_test.argtypes = [c_bool] class Zcert(object): """ work with CURVE security certificates """ allow_destruct = False def __init__(self, *args): """ Create and initialize a new certificate in memory """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zcert_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zcert_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.zcert_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a certificate in memory """ if self.allow_destruct: lib.zcert_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() @staticmethod def new_from(public_key, secret_key): """ Accepts public/secret key pair from caller """ return Zcert(lib.zcert_new_from(public_key, secret_key), True) @staticmethod def new_from_txt(public_txt, secret_txt): """ Accepts public/secret key text pair from caller """ return Zcert(lib.zcert_new_from_txt(public_txt, secret_txt), True) @staticmethod def load(filename): """ Load certificate from file """ return Zcert(lib.zcert_load(filename), True) def public_key(self): """ Return public part of key pair as 32-byte binary string """ return lib.zcert_public_key(self._as_parameter_) def secret_key(self): """ Return secret part of key pair as 32-byte binary string """ return lib.zcert_secret_key(self._as_parameter_) def public_txt(self): """ Return public part of key pair as Z85 armored string """ return lib.zcert_public_txt(self._as_parameter_) def secret_txt(self): """ Return secret part of key pair as Z85 armored string """ return lib.zcert_secret_txt(self._as_parameter_) def set_meta(self, name, format, *args): """ Set certificate metadata from formatted string. """ return lib.zcert_set_meta(self._as_parameter_, name, format, *args) def unset_meta(self, name): """ Unset certificate metadata. """ return lib.zcert_unset_meta(self._as_parameter_, name) def meta(self, name): """ Get metadata value from certificate; if the metadata value doesn't exist, returns NULL. """ return lib.zcert_meta(self._as_parameter_, name) def meta_keys(self): """ Get list of metadata fields from certificate. Caller is responsible for destroying list. Caller should not modify the values of list items. """ return Zlist(lib.zcert_meta_keys(self._as_parameter_), False) def save(self, filename): """ Save full certificate (public + secret) to file for persistent storage This creates one public file and one secret file (filename + "_secret"). """ return lib.zcert_save(self._as_parameter_, filename) def save_public(self, filename): """ Save public certificate only to file for persistent storage """ return lib.zcert_save_public(self._as_parameter_, filename) def save_secret(self, filename): """ Save secret certificate only to file for persistent storage """ return lib.zcert_save_secret(self._as_parameter_, filename) def apply(self, socket): """ Apply certificate to socket, i.e. use for CURVE security on socket. If certificate was loaded from public file, the secret key will be undefined, and this certificate will not work successfully. """ return lib.zcert_apply(self._as_parameter_, socket) def dup(self): """ Return copy of certificate; if certificate is NULL or we exhausted heap memory, returns NULL. """ return Zcert(lib.zcert_dup(self._as_parameter_), True) def eq(self, compare): """ Return true if two certificates have the same keys """ return lib.zcert_eq(self._as_parameter_, compare) def print(self): """ Print certificate contents to stdout """ return lib.zcert_print(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class """ return lib.zcert_test(verbose) # zcertstore zcertstore_loader = CFUNCTYPE(None, zcertstore_p) zcertstore_destructor = CFUNCTYPE(None, c_void_p) lib.zcertstore_new.restype = zcertstore_p lib.zcertstore_new.argtypes = [c_char_p] lib.zcertstore_destroy.restype = None lib.zcertstore_destroy.argtypes = [POINTER(zcertstore_p)] lib.zcertstore_set_loader.restype = None lib.zcertstore_set_loader.argtypes = [zcertstore_p, zcertstore_loader, zcertstore_destructor, c_void_p] lib.zcertstore_lookup.restype = zcert_p lib.zcertstore_lookup.argtypes = [zcertstore_p, c_char_p] lib.zcertstore_insert.restype = None lib.zcertstore_insert.argtypes = [zcertstore_p, POINTER(zcert_p)] lib.zcertstore_empty.restype = None lib.zcertstore_empty.argtypes = [zcertstore_p] lib.zcertstore_print.restype = None lib.zcertstore_print.argtypes = [zcertstore_p] lib.zcertstore_certs.restype = zlistx_p lib.zcertstore_certs.argtypes = [zcertstore_p] lib.zcertstore_test.restype = None lib.zcertstore_test.argtypes = [c_bool] class Zcertstore(object): """ work with CURVE security certificate stores """ allow_destruct = False def __init__(self, *args): """ Create a new certificate store from a disk directory, loading and indexing all certificates in that location. The directory itself may be absent, and created later, or modified at any time. The certificate store is automatically refreshed on any zcertstore_lookup() call. If the location is specified as NULL, creates a pure-memory store, which you can work with by inserting certificates at runtime. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zcertstore_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zcertstore_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 1) self._as_parameter_ = lib.zcertstore_new(args[0]) # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a certificate store object in memory. Does not affect anything stored on disk. """ if self.allow_destruct: lib.zcertstore_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def set_loader(self, loader, destructor, state): """ Override the default disk loader with a custom loader fn. """ return lib.zcertstore_set_loader(self._as_parameter_, loader, destructor, state) def lookup(self, public_key): """ Look up certificate by public key, returns zcert_t object if found, else returns NULL. The public key is provided in Z85 text format. """ return Zcert(lib.zcertstore_lookup(self._as_parameter_, public_key), False) def insert(self, cert_p): """ Insert certificate into certificate store in memory. Note that this does not save the certificate to disk. To do that, use zcert_save() directly on the certificate. Takes ownership of zcert_t object. """ return lib.zcertstore_insert(self._as_parameter_, byref(zcert_p.from_param(cert_p))) def empty(self): """ Empty certificate hashtable. This wrapper exists to be friendly to bindings, which don't usually have access to struct internals. """ return lib.zcertstore_empty(self._as_parameter_) def print(self): """ Print list of certificates in store to logging facility """ return lib.zcertstore_print(self._as_parameter_) def certs(self): """ Return a list of all the certificates in the store. The caller takes ownership of the zlistx_t object and is responsible for destroying it. The caller does not take ownership of the zcert_t objects. """ return Zlistx(lib.zcertstore_certs(self._as_parameter_), True) @staticmethod def test(verbose): """ Self test of this class """ return lib.zcertstore_test(verbose) # zchunk lib.zchunk_new.restype = zchunk_p lib.zchunk_new.argtypes = [c_void_p, c_size_t] lib.zchunk_destroy.restype = None lib.zchunk_destroy.argtypes = [POINTER(zchunk_p)] lib.zchunk_resize.restype = None lib.zchunk_resize.argtypes = [zchunk_p, c_size_t] lib.zchunk_size.restype = c_size_t lib.zchunk_size.argtypes = [zchunk_p] lib.zchunk_max_size.restype = c_size_t lib.zchunk_max_size.argtypes = [zchunk_p] lib.zchunk_data.restype = c_void_p lib.zchunk_data.argtypes = [zchunk_p] lib.zchunk_set.restype = c_size_t lib.zchunk_set.argtypes = [zchunk_p, c_void_p, c_size_t] lib.zchunk_fill.restype = c_size_t lib.zchunk_fill.argtypes = [zchunk_p, c_ubyte, c_size_t] lib.zchunk_append.restype = c_size_t lib.zchunk_append.argtypes = [zchunk_p, c_void_p, c_size_t] lib.zchunk_extend.restype = c_size_t lib.zchunk_extend.argtypes = [zchunk_p, c_void_p, c_size_t] lib.zchunk_consume.restype = c_size_t lib.zchunk_consume.argtypes = [zchunk_p, zchunk_p] lib.zchunk_exhausted.restype = c_bool lib.zchunk_exhausted.argtypes = [zchunk_p] lib.zchunk_read.restype = zchunk_p lib.zchunk_read.argtypes = [FILE_p, c_size_t] lib.zchunk_write.restype = c_int lib.zchunk_write.argtypes = [zchunk_p, FILE_p] lib.zchunk_slurp.restype = zchunk_p lib.zchunk_slurp.argtypes = [c_char_p, c_size_t] lib.zchunk_dup.restype = zchunk_p lib.zchunk_dup.argtypes = [zchunk_p] lib.zchunk_strhex.restype = POINTER(c_char) lib.zchunk_strhex.argtypes = [zchunk_p] lib.zchunk_strdup.restype = POINTER(c_char) lib.zchunk_strdup.argtypes = [zchunk_p] lib.zchunk_streq.restype = c_bool lib.zchunk_streq.argtypes = [zchunk_p, c_char_p] lib.zchunk_pack.restype = zframe_p lib.zchunk_pack.argtypes = [zchunk_p] lib.zchunk_unpack.restype = zchunk_p lib.zchunk_unpack.argtypes = [zframe_p] lib.zchunk_digest.restype = c_char_p lib.zchunk_digest.argtypes = [zchunk_p] lib.zchunk_fprint.restype = None lib.zchunk_fprint.argtypes = [zchunk_p, FILE_p] lib.zchunk_print.restype = None lib.zchunk_print.argtypes = [zchunk_p] lib.zchunk_is.restype = c_bool lib.zchunk_is.argtypes = [c_void_p] lib.zchunk_test.restype = None lib.zchunk_test.argtypes = [c_bool] class Zchunk(object): """ work with memory chunks """ allow_destruct = False def __init__(self, *args): """ Create a new chunk of the specified size. If you specify the data, it is copied into the chunk. If you do not specify the data, the chunk is allocated and left empty, and you can then add data using zchunk_append. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zchunk_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zchunk_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 2) self._as_parameter_ = lib.zchunk_new(args[0], args[1]) # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a chunk """ if self.allow_destruct: lib.zchunk_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def resize(self, size): """ Resizes chunk max_size as requested; chunk_cur size is set to zero """ return lib.zchunk_resize(self._as_parameter_, size) def size(self): """ Return chunk cur size """ return lib.zchunk_size(self._as_parameter_) def max_size(self): """ Return chunk max size """ return lib.zchunk_max_size(self._as_parameter_) def data(self): """ Return chunk data """ return lib.zchunk_data(self._as_parameter_) def set(self, data, size): """ Set chunk data from user-supplied data; truncate if too large. Data may be null. Returns actual size of chunk """ return lib.zchunk_set(self._as_parameter_, data, size) def fill(self, filler, size): """ Fill chunk data from user-supplied octet """ return lib.zchunk_fill(self._as_parameter_, filler, size) def append(self, data, size): """ Append user-supplied data to chunk, return resulting chunk size. If the data would exceeded the available space, it is truncated. If you want to grow the chunk to accommodate new data, use the zchunk_extend method. """ return lib.zchunk_append(self._as_parameter_, data, size) def extend(self, data, size): """ Append user-supplied data to chunk, return resulting chunk size. If the data would exceeded the available space, the chunk grows in size. """ return lib.zchunk_extend(self._as_parameter_, data, size) def consume(self, source): """ Copy as much data from 'source' into the chunk as possible; returns the new size of chunk. If all data from 'source' is used, returns exhausted on the source chunk. Source can be consumed as many times as needed until it is exhausted. If source was already exhausted, does not change chunk. """ return lib.zchunk_consume(self._as_parameter_, source) def exhausted(self): """ Returns true if the chunk was exhausted by consume methods, or if the chunk has a size of zero. """ return lib.zchunk_exhausted(self._as_parameter_) @staticmethod def read(handle, bytes): """ Read chunk from an open file descriptor """ return Zchunk(lib.zchunk_read(coerce_py_file(handle), bytes), True) def write(self, handle): """ Write chunk to an open file descriptor """ return lib.zchunk_write(self._as_parameter_, coerce_py_file(handle)) @staticmethod def slurp(filename, maxsize): """ Try to slurp an entire file into a chunk. Will read up to maxsize of the file. If maxsize is 0, will attempt to read the entire file and fail with an assertion if that cannot fit into memory. Returns a new chunk containing the file data, or NULL if the file could not be read. """ return Zchunk(lib.zchunk_slurp(filename, maxsize), True) def dup(self): """ Create copy of chunk, as new chunk object. Returns a fresh zchunk_t object, or null if there was not enough heap memory. If chunk is null, returns null. """ return Zchunk(lib.zchunk_dup(self._as_parameter_), True) def strhex(self): """ Return chunk data encoded as printable hex string. Caller must free string when finished with it. """ return return_fresh_string(lib.zchunk_strhex(self._as_parameter_)) def strdup(self): """ Return chunk data copied into freshly allocated string Caller must free string when finished with it. """ return return_fresh_string(lib.zchunk_strdup(self._as_parameter_)) def streq(self, string): """ Return TRUE if chunk body is equal to string, excluding terminator """ return lib.zchunk_streq(self._as_parameter_, string) def pack(self): """ Transform zchunk into a zframe that can be sent in a message. """ return Zframe(lib.zchunk_pack(self._as_parameter_), True) @staticmethod def unpack(frame): """ Transform a zframe into a zchunk. """ return Zchunk(lib.zchunk_unpack(frame), True) def digest(self): """ Calculate SHA1 digest for chunk, using zdigest class. """ return lib.zchunk_digest(self._as_parameter_) def fprint(self, file): """ Dump chunk to FILE stream, for debugging and tracing. """ return lib.zchunk_fprint(self._as_parameter_, coerce_py_file(file)) def print(self): """ Dump message to stderr, for debugging and tracing. See zchunk_fprint for details """ return lib.zchunk_print(self._as_parameter_) @staticmethod def is_(self): """ Probe the supplied object, and report if it looks like a zchunk_t. """ return lib.zchunk_is(self) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zchunk_test(verbose) # zclock lib.zclock_sleep.restype = None lib.zclock_sleep.argtypes = [c_int] lib.zclock_time.restype = msecs_p lib.zclock_time.argtypes = [] lib.zclock_mono.restype = msecs_p lib.zclock_mono.argtypes = [] lib.zclock_usecs.restype = msecs_p lib.zclock_usecs.argtypes = [] lib.zclock_timestr.restype = POINTER(c_char) lib.zclock_timestr.argtypes = [] lib.zclock_test.restype = None lib.zclock_test.argtypes = [c_bool] class Zclock(object): """ millisecond clocks and delays """ allow_destruct = False def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() @staticmethod def sleep(msecs): """ Sleep for a number of milliseconds """ return lib.zclock_sleep(msecs) @staticmethod def time(): """ Return current system clock as milliseconds. Note that this clock can jump backwards (if the system clock is changed) so is unsafe to use for timers and time offsets. Use zclock_mono for that instead. """ return lib.zclock_time() @staticmethod def mono(): """ Return current monotonic clock in milliseconds. Use this when you compute time offsets. The monotonic clock is not affected by system changes and so will never be reset backwards, unlike a system clock. """ return lib.zclock_mono() @staticmethod def usecs(): """ Return current monotonic clock in microseconds. Use this when you compute time offsets. The monotonic clock is not affected by system changes and so will never be reset backwards, unlike a system clock. """ return lib.zclock_usecs() @staticmethod def timestr(): """ Return formatted date/time as fresh string. Free using zstr_free(). """ return return_fresh_string(lib.zclock_timestr()) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zclock_test(verbose) # zconfig zconfig_fct = CFUNCTYPE(c_int, zconfig_p, c_void_p, c_int) lib.zconfig_new.restype = zconfig_p lib.zconfig_new.argtypes = [c_char_p, zconfig_p] lib.zconfig_destroy.restype = None lib.zconfig_destroy.argtypes = [POINTER(zconfig_p)] lib.zconfig_load.restype = zconfig_p lib.zconfig_load.argtypes = [c_char_p] lib.zconfig_loadf.restype = zconfig_p lib.zconfig_loadf.argtypes = [c_char_p] lib.zconfig_name.restype = c_char_p lib.zconfig_name.argtypes = [zconfig_p] lib.zconfig_value.restype = c_char_p lib.zconfig_value.argtypes = [zconfig_p] lib.zconfig_put.restype = None lib.zconfig_put.argtypes = [zconfig_p, c_char_p, c_char_p] lib.zconfig_putf.restype = None lib.zconfig_putf.argtypes = [zconfig_p, c_char_p, c_char_p] lib.zconfig_get.restype = c_char_p lib.zconfig_get.argtypes = [zconfig_p, c_char_p, c_char_p] lib.zconfig_set_name.restype = None lib.zconfig_set_name.argtypes = [zconfig_p, c_char_p] lib.zconfig_set_value.restype = None lib.zconfig_set_value.argtypes = [zconfig_p, c_char_p] lib.zconfig_child.restype = zconfig_p lib.zconfig_child.argtypes = [zconfig_p] lib.zconfig_next.restype = zconfig_p lib.zconfig_next.argtypes = [zconfig_p] lib.zconfig_locate.restype = zconfig_p lib.zconfig_locate.argtypes = [zconfig_p, c_char_p] lib.zconfig_at_depth.restype = zconfig_p lib.zconfig_at_depth.argtypes = [zconfig_p, c_int] lib.zconfig_execute.restype = c_int lib.zconfig_execute.argtypes = [zconfig_p, zconfig_fct, c_void_p] lib.zconfig_set_comment.restype = None lib.zconfig_set_comment.argtypes = [zconfig_p, c_char_p] lib.zconfig_comments.restype = zlist_p lib.zconfig_comments.argtypes = [zconfig_p] lib.zconfig_save.restype = c_int lib.zconfig_save.argtypes = [zconfig_p, c_char_p] lib.zconfig_savef.restype = c_int lib.zconfig_savef.argtypes = [zconfig_p, c_char_p] lib.zconfig_filename.restype = c_char_p lib.zconfig_filename.argtypes = [zconfig_p] lib.zconfig_reload.restype = c_int lib.zconfig_reload.argtypes = [POINTER(zconfig_p)] lib.zconfig_chunk_load.restype = zconfig_p lib.zconfig_chunk_load.argtypes = [zchunk_p] lib.zconfig_chunk_save.restype = zchunk_p lib.zconfig_chunk_save.argtypes = [zconfig_p] lib.zconfig_str_load.restype = zconfig_p lib.zconfig_str_load.argtypes = [c_char_p] lib.zconfig_str_save.restype = POINTER(c_char) lib.zconfig_str_save.argtypes = [zconfig_p] lib.zconfig_has_changed.restype = c_bool lib.zconfig_has_changed.argtypes = [zconfig_p] lib.zconfig_remove_subtree.restype = None lib.zconfig_remove_subtree.argtypes = [zconfig_p] lib.zconfig_remove.restype = None lib.zconfig_remove.argtypes = [POINTER(zconfig_p)] lib.zconfig_fprint.restype = None lib.zconfig_fprint.argtypes = [zconfig_p, FILE_p] lib.zconfig_print.restype = None lib.zconfig_print.argtypes = [zconfig_p] lib.zconfig_test.restype = None lib.zconfig_test.argtypes = [c_bool] class Zconfig(object): """ work with config files written in rfc.zeromq.org/spec:4/ZPL. """ allow_destruct = False def __init__(self, *args): """ Create new config item """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zconfig_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zconfig_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 2) self._as_parameter_ = lib.zconfig_new(args[0], args[1]) # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a config item and all its children """ if self.allow_destruct: lib.zconfig_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() @staticmethod def load(filename): """ Load a config tree from a specified ZPL text file; returns a zconfig_t reference for the root, if the file exists and is readable. Returns NULL if the file does not exist. """ return Zconfig(lib.zconfig_load(filename), True) @staticmethod def loadf(format, *args): """ Equivalent to zconfig_load, taking a format string instead of a fixed filename. """ return Zconfig(lib.zconfig_loadf(format, *args), True) def name(self): """ Return name of config item """ return lib.zconfig_name(self._as_parameter_) def value(self): """ Return value of config item """ return lib.zconfig_value(self._as_parameter_) def put(self, path, value): """ Insert or update configuration key with value """ return lib.zconfig_put(self._as_parameter_, path, value) def putf(self, path, format, *args): """ Equivalent to zconfig_put, accepting a format specifier and variable argument list, instead of a single string value. """ return lib.zconfig_putf(self._as_parameter_, path, format, *args) def get(self, path, default_value): """ Get value for config item into a string value; leading slash is optional and ignored. """ return lib.zconfig_get(self._as_parameter_, path, default_value) def set_name(self, name): """ Set config item name, name may be NULL """ return lib.zconfig_set_name(self._as_parameter_, name) def set_value(self, format, *args): """ Set new value for config item. The new value may be a string, a printf format, or NULL. Note that if string may possibly contain '%', or if it comes from an insecure source, you must use '%s' as the format, followed by the string. """ return lib.zconfig_set_value(self._as_parameter_, format, *args) def child(self): """ Find our first child, if any """ return Zconfig(lib.zconfig_child(self._as_parameter_), False) def next(self): """ Find our first sibling, if any """ return Zconfig(lib.zconfig_next(self._as_parameter_), False) def locate(self, path): """ Find a config item along a path; leading slash is optional and ignored. """ return Zconfig(lib.zconfig_locate(self._as_parameter_, path), False) def at_depth(self, level): """ Locate the last config item at a specified depth """ return Zconfig(lib.zconfig_at_depth(self._as_parameter_, level), False) def execute(self, handler, arg): """ Execute a callback for each config item in the tree; returns zero if successful, else -1. """ return lib.zconfig_execute(self._as_parameter_, handler, arg) def set_comment(self, format, *args): """ Add comment to config item before saving to disk. You can add as many comment lines as you like. If you use a null format, all comments are deleted. """ return lib.zconfig_set_comment(self._as_parameter_, format, *args) def comments(self): """ Return comments of config item, as zlist. """ return Zlist(lib.zconfig_comments(self._as_parameter_), False) def save(self, filename): """ Save a config tree to a specified ZPL text file, where a filename "-" means dump to standard output. """ return lib.zconfig_save(self._as_parameter_, filename) def savef(self, format, *args): """ Equivalent to zconfig_save, taking a format string instead of a fixed filename. """ return lib.zconfig_savef(self._as_parameter_, format, *args) def filename(self): """ Report filename used during zconfig_load, or NULL if none """ return lib.zconfig_filename(self._as_parameter_) @staticmethod def reload(self_p): """ Reload config tree from same file that it was previously loaded from. Returns 0 if OK, -1 if there was an error (and then does not change existing data). """ return lib.zconfig_reload(byref(zconfig_p.from_param(self_p))) @staticmethod def chunk_load(chunk): """ Load a config tree from a memory chunk """ return Zconfig(lib.zconfig_chunk_load(chunk), False) def chunk_save(self): """ Save a config tree to a new memory chunk """ return Zchunk(lib.zconfig_chunk_save(self._as_parameter_), False) @staticmethod def str_load(string): """ Load a config tree from a null-terminated string """ return Zconfig(lib.zconfig_str_load(string), True) def str_save(self): """ Save a config tree to a new null terminated string """ return return_fresh_string(lib.zconfig_str_save(self._as_parameter_)) def has_changed(self): """ Return true if a configuration tree was loaded from a file and that file has changed in since the tree was loaded. """ return lib.zconfig_has_changed(self._as_parameter_) def remove_subtree(self): """ Destroy subtree (all children) """ return lib.zconfig_remove_subtree(self._as_parameter_) @staticmethod def remove(self_p): """ Destroy node and subtree (all children) """ return lib.zconfig_remove(byref(zconfig_p.from_param(self_p))) def fprint(self, file): """ Print the config file to open stream """ return lib.zconfig_fprint(self._as_parameter_, coerce_py_file(file)) def print(self): """ Print properties of object """ return lib.zconfig_print(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class """ return lib.zconfig_test(verbose) # zdigest lib.zdigest_new.restype = zdigest_p lib.zdigest_new.argtypes = [] lib.zdigest_destroy.restype = None lib.zdigest_destroy.argtypes = [POINTER(zdigest_p)] lib.zdigest_update.restype = None lib.zdigest_update.argtypes = [zdigest_p, c_void_p, c_size_t] lib.zdigest_data.restype = c_void_p lib.zdigest_data.argtypes = [zdigest_p] lib.zdigest_size.restype = c_size_t lib.zdigest_size.argtypes = [zdigest_p] lib.zdigest_string.restype = c_char_p lib.zdigest_string.argtypes = [zdigest_p] lib.zdigest_test.restype = None lib.zdigest_test.argtypes = [c_bool] class Zdigest(object): """ provides hashing functions (SHA-1 at present) """ allow_destruct = False def __init__(self, *args): """ Constructor - creates new digest object, which you use to build up a digest by repeatedly calling zdigest_update() on chunks of data. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zdigest_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zdigest_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.zdigest_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a digest object """ if self.allow_destruct: lib.zdigest_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def update(self, buffer, length): """ Add buffer into digest calculation """ return lib.zdigest_update(self._as_parameter_, buffer, length) def data(self): """ Return final digest hash data. If built without crypto support, returns NULL. """ return lib.zdigest_data(self._as_parameter_) def size(self): """ Return final digest hash size """ return lib.zdigest_size(self._as_parameter_) def string(self): """ Return digest as printable hex string; caller should not modify nor free this string. After calling this, you may not use zdigest_update() on the same digest. If built without crypto support, returns NULL. """ return lib.zdigest_string(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zdigest_test(verbose) # zdir lib.zdir_new.restype = zdir_p lib.zdir_new.argtypes = [c_char_p, c_char_p] lib.zdir_destroy.restype = None lib.zdir_destroy.argtypes = [POINTER(zdir_p)] lib.zdir_path.restype = c_char_p lib.zdir_path.argtypes = [zdir_p] lib.zdir_modified.restype = c_int lib.zdir_modified.argtypes = [zdir_p] lib.zdir_cursize.restype = c_int lib.zdir_cursize.argtypes = [zdir_p] lib.zdir_count.restype = c_size_t lib.zdir_count.argtypes = [zdir_p] lib.zdir_list.restype = zlist_p lib.zdir_list.argtypes = [zdir_p] lib.zdir_remove.restype = None lib.zdir_remove.argtypes = [zdir_p, c_bool] lib.zdir_diff.restype = zlist_p lib.zdir_diff.argtypes = [zdir_p, zdir_p, c_char_p] lib.zdir_resync.restype = zlist_p lib.zdir_resync.argtypes = [zdir_p, c_char_p] lib.zdir_cache.restype = zhash_p lib.zdir_cache.argtypes = [zdir_p] lib.zdir_fprint.restype = None lib.zdir_fprint.argtypes = [zdir_p, FILE_p, c_int] lib.zdir_print.restype = None lib.zdir_print.argtypes = [zdir_p, c_int] lib.zdir_watch.restype = None lib.zdir_watch.argtypes = [zsock_p, c_void_p] lib.zdir_test.restype = None lib.zdir_test.argtypes = [c_bool] class Zdir(object): """ work with file-system directories """ allow_destruct = False def __init__(self, *args): """ Create a new directory item that loads in the full tree of the specified path, optionally located under some parent path. If parent is "-", then loads only the top-level directory, and does not use parent as a path. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zdir_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zdir_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 2) self._as_parameter_ = lib.zdir_new(args[0], args[1]) # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a directory tree and all children it contains. """ if self.allow_destruct: lib.zdir_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def path(self): """ Return directory path """ return lib.zdir_path(self._as_parameter_) def modified(self): """ Return last modification time for directory. """ return lib.zdir_modified(self._as_parameter_) def cursize(self): """ Return total hierarchy size, in bytes of data contained in all files in the directory tree. """ return lib.zdir_cursize(self._as_parameter_) def count(self): """ Return directory count """ return lib.zdir_count(self._as_parameter_) def list(self): """ Returns a sorted list of zfile objects; Each entry in the list is a pointer to a zfile_t item already allocated in the zdir tree. Do not destroy the original zdir tree until you are done with this list. """ return Zlist(lib.zdir_list(self._as_parameter_), True) def remove(self, force): """ Remove directory, optionally including all files that it contains, at all levels. If force is false, will only remove the directory if empty. If force is true, will remove all files and all subdirectories. """ return lib.zdir_remove(self._as_parameter_, force) @staticmethod def diff(older, newer, alias): """ Calculate differences between two versions of a directory tree. Returns a list of zdir_patch_t patches. Either older or newer may be null, indicating the directory is empty/absent. If alias is set, generates virtual filename (minus path, plus alias). """ return Zlist(lib.zdir_diff(older, newer, alias), True) def resync(self, alias): """ Return full contents of directory as a zdir_patch list. """ return Zlist(lib.zdir_resync(self._as_parameter_, alias), True) def cache(self): """ Load directory cache; returns a hash table containing the SHA-1 digests of every file in the tree. The cache is saved between runs in .cache. """ return Zhash(lib.zdir_cache(self._as_parameter_), True) def fprint(self, file, indent): """ Print contents of directory to open stream """ return lib.zdir_fprint(self._as_parameter_, coerce_py_file(file), indent) def print(self, indent): """ Print contents of directory to stdout """ return lib.zdir_print(self._as_parameter_, indent) @staticmethod def watch(pipe, unused): """ Create a new zdir_watch actor instance: zactor_t *watch = zactor_new (zdir_watch, NULL); Destroy zdir_watch instance: zactor_destroy (&watch); Enable verbose logging of commands and activity: zstr_send (watch, "VERBOSE"); Subscribe to changes to a directory path: zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); Unsubscribe from changes to a directory path: zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); Receive directory changes: zsock_recv (watch, "sp", &path, &patches); // Delete the received data. free (path); zlist_destroy (&patches); """ return lib.zdir_watch(pipe, unused) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zdir_test(verbose) # zdir_patch lib.zdir_patch_new.restype = zdir_patch_p lib.zdir_patch_new.argtypes = [c_char_p, zfile_p, c_int, c_char_p] lib.zdir_patch_destroy.restype = None lib.zdir_patch_destroy.argtypes = [POINTER(zdir_patch_p)] lib.zdir_patch_dup.restype = zdir_patch_p lib.zdir_patch_dup.argtypes = [zdir_patch_p] lib.zdir_patch_path.restype = c_char_p lib.zdir_patch_path.argtypes = [zdir_patch_p] lib.zdir_patch_file.restype = zfile_p lib.zdir_patch_file.argtypes = [zdir_patch_p] lib.zdir_patch_op.restype = c_int lib.zdir_patch_op.argtypes = [zdir_patch_p] lib.zdir_patch_vpath.restype = c_char_p lib.zdir_patch_vpath.argtypes = [zdir_patch_p] lib.zdir_patch_digest_set.restype = None lib.zdir_patch_digest_set.argtypes = [zdir_patch_p] lib.zdir_patch_digest.restype = c_char_p lib.zdir_patch_digest.argtypes = [zdir_patch_p] lib.zdir_patch_test.restype = None lib.zdir_patch_test.argtypes = [c_bool] class ZdirPatch(object): """ work with directory patches """ CREATE = 1 # Creates a new file DELETE = 2 # Delete a file allow_destruct = False def __init__(self, *args): """ Create new patch """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zdir_patch_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zdir_patch_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 4) self._as_parameter_ = lib.zdir_patch_new(args[0], args[1], args[2], args[3]) # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a patch """ if self.allow_destruct: lib.zdir_patch_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def dup(self): """ Create copy of a patch. If the patch is null, or memory was exhausted, returns null. """ return ZdirPatch(lib.zdir_patch_dup(self._as_parameter_), True) def path(self): """ Return patch file directory path """ return lib.zdir_patch_path(self._as_parameter_) def file(self): """ Return patch file item """ return Zfile(lib.zdir_patch_file(self._as_parameter_), False) def op(self): """ Return operation """ return lib.zdir_patch_op(self._as_parameter_) def vpath(self): """ Return patch virtual file path """ return lib.zdir_patch_vpath(self._as_parameter_) def digest_set(self): """ Calculate hash digest for file (create only) """ return lib.zdir_patch_digest_set(self._as_parameter_) def digest(self): """ Return hash digest for patch file """ return lib.zdir_patch_digest(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zdir_patch_test(verbose) # zfile lib.zfile_new.restype = zfile_p lib.zfile_new.argtypes = [c_char_p, c_char_p] lib.zfile_destroy.restype = None lib.zfile_destroy.argtypes = [POINTER(zfile_p)] lib.zfile_tmp.restype = zfile_p lib.zfile_tmp.argtypes = [] lib.zfile_dup.restype = zfile_p lib.zfile_dup.argtypes = [zfile_p] lib.zfile_filename.restype = c_char_p lib.zfile_filename.argtypes = [zfile_p, c_char_p] lib.zfile_restat.restype = None lib.zfile_restat.argtypes = [zfile_p] lib.zfile_modified.restype = c_int lib.zfile_modified.argtypes = [zfile_p] lib.zfile_cursize.restype = c_int lib.zfile_cursize.argtypes = [zfile_p] lib.zfile_is_directory.restype = c_bool lib.zfile_is_directory.argtypes = [zfile_p] lib.zfile_is_regular.restype = c_bool lib.zfile_is_regular.argtypes = [zfile_p] lib.zfile_is_readable.restype = c_bool lib.zfile_is_readable.argtypes = [zfile_p] lib.zfile_is_writeable.restype = c_bool lib.zfile_is_writeable.argtypes = [zfile_p] lib.zfile_is_stable.restype = c_bool lib.zfile_is_stable.argtypes = [zfile_p] lib.zfile_has_changed.restype = c_bool lib.zfile_has_changed.argtypes = [zfile_p] lib.zfile_remove.restype = None lib.zfile_remove.argtypes = [zfile_p] lib.zfile_input.restype = c_int lib.zfile_input.argtypes = [zfile_p] lib.zfile_output.restype = c_int lib.zfile_output.argtypes = [zfile_p] lib.zfile_read.restype = zchunk_p lib.zfile_read.argtypes = [zfile_p, c_size_t, c_int] lib.zfile_eof.restype = c_bool lib.zfile_eof.argtypes = [zfile_p] lib.zfile_write.restype = c_int lib.zfile_write.argtypes = [zfile_p, zchunk_p, c_int] lib.zfile_readln.restype = c_char_p lib.zfile_readln.argtypes = [zfile_p] lib.zfile_close.restype = None lib.zfile_close.argtypes = [zfile_p] lib.zfile_handle.restype = FILE_p lib.zfile_handle.argtypes = [zfile_p] lib.zfile_digest.restype = c_char_p lib.zfile_digest.argtypes = [zfile_p] lib.zfile_test.restype = None lib.zfile_test.argtypes = [c_bool] class Zfile(object): """ helper functions for working with files. """ allow_destruct = False def __init__(self, *args): """ If file exists, populates properties. CZMQ supports portable symbolic links, which are files with the extension ".ln". A symbolic link is a text file containing one line, the filename of a target file. Reading data from the symbolic link actually reads from the target file. Path may be NULL, in which case it is not used. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zfile_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zfile_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 2) self._as_parameter_ = lib.zfile_new(args[0], args[1]) # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a file item """ if self.allow_destruct: lib.zfile_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() @staticmethod def tmp(): """ Create new temporary file for writing via tmpfile. File is automaticaly deleted on destroy """ return Zfile(lib.zfile_tmp(), True) def dup(self): """ Duplicate a file item, returns a newly constructed item. If the file is null, or memory was exhausted, returns null. """ return Zfile(lib.zfile_dup(self._as_parameter_), True) def filename(self, path): """ Return file name, remove path if provided """ return lib.zfile_filename(self._as_parameter_, path) def restat(self): """ Refresh file properties from disk; this is not done automatically on access methods, otherwise it is not possible to compare directory snapshots. """ return lib.zfile_restat(self._as_parameter_) def modified(self): """ Return when the file was last modified. If you want this to reflect the current situation, call zfile_restat before checking this property. """ return lib.zfile_modified(self._as_parameter_) def cursize(self): """ Return the last-known size of the file. If you want this to reflect the current situation, call zfile_restat before checking this property. """ return lib.zfile_cursize(self._as_parameter_) def is_directory(self): """ Return true if the file is a directory. If you want this to reflect any external changes, call zfile_restat before checking this property. """ return lib.zfile_is_directory(self._as_parameter_) def is_regular(self): """ Return true if the file is a regular file. If you want this to reflect any external changes, call zfile_restat before checking this property. """ return lib.zfile_is_regular(self._as_parameter_) def is_readable(self): """ Return true if the file is readable by this process. If you want this to reflect any external changes, call zfile_restat before checking this property. """ return lib.zfile_is_readable(self._as_parameter_) def is_writeable(self): """ Return true if the file is writeable by this process. If you want this to reflect any external changes, call zfile_restat before checking this property. """ return lib.zfile_is_writeable(self._as_parameter_) def is_stable(self): """ Check if file has stopped changing and can be safely processed. Updates the file statistics from disk at every call. """ return lib.zfile_is_stable(self._as_parameter_) def has_changed(self): """ Return true if the file was changed on disk since the zfile_t object was created, or the last zfile_restat() call made on it. """ return lib.zfile_has_changed(self._as_parameter_) def remove(self): """ Remove the file from disk """ return lib.zfile_remove(self._as_parameter_) def input(self): """ Open file for reading Returns 0 if OK, -1 if not found or not accessible """ return lib.zfile_input(self._as_parameter_) def output(self): """ Open file for writing, creating directory if needed File is created if necessary; chunks can be written to file at any location. Returns 0 if OK, -1 if error. """ return lib.zfile_output(self._as_parameter_) def read(self, bytes, offset): """ Read chunk from file at specified position. If this was the last chunk, sets the eof property. Returns a null chunk in case of error. """ return Zchunk(lib.zfile_read(self._as_parameter_, bytes, offset), True) def eof(self): """ Returns true if zfile_read() just read the last chunk in the file. """ return lib.zfile_eof(self._as_parameter_) def write(self, chunk, offset): """ Write chunk to file at specified position Return 0 if OK, else -1 """ return lib.zfile_write(self._as_parameter_, chunk, offset) def readln(self): """ Read next line of text from file. Returns a pointer to the text line, or NULL if there was nothing more to read from the file. """ return lib.zfile_readln(self._as_parameter_) def close(self): """ Close file, if open """ return lib.zfile_close(self._as_parameter_) def handle(self): """ Return file handle, if opened """ return return_py_file(lib.zfile_handle(self._as_parameter_)) def digest(self): """ Calculate SHA1 digest for file, using zdigest class. """ return lib.zfile_digest(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zfile_test(verbose) # zframe lib.zframe_new.restype = zframe_p lib.zframe_new.argtypes = [c_void_p, c_size_t] lib.zframe_destroy.restype = None lib.zframe_destroy.argtypes = [POINTER(zframe_p)] lib.zframe_new_empty.restype = zframe_p lib.zframe_new_empty.argtypes = [] lib.zframe_from.restype = zframe_p lib.zframe_from.argtypes = [c_char_p] lib.zframe_recv.restype = zframe_p lib.zframe_recv.argtypes = [c_void_p] lib.zframe_send.restype = c_int lib.zframe_send.argtypes = [POINTER(zframe_p), c_void_p, c_int] lib.zframe_size.restype = c_size_t lib.zframe_size.argtypes = [zframe_p] lib.zframe_data.restype = c_void_p lib.zframe_data.argtypes = [zframe_p] lib.zframe_meta.restype = c_char_p lib.zframe_meta.argtypes = [zframe_p, c_char_p] lib.zframe_dup.restype = zframe_p lib.zframe_dup.argtypes = [zframe_p] lib.zframe_strhex.restype = POINTER(c_char) lib.zframe_strhex.argtypes = [zframe_p] lib.zframe_strdup.restype = POINTER(c_char) lib.zframe_strdup.argtypes = [zframe_p] lib.zframe_streq.restype = c_bool lib.zframe_streq.argtypes = [zframe_p, c_char_p] lib.zframe_more.restype = c_int lib.zframe_more.argtypes = [zframe_p] lib.zframe_set_more.restype = None lib.zframe_set_more.argtypes = [zframe_p, c_int] lib.zframe_routing_id.restype = c_int lib.zframe_routing_id.argtypes = [zframe_p] lib.zframe_set_routing_id.restype = None lib.zframe_set_routing_id.argtypes = [zframe_p, c_int] lib.zframe_group.restype = c_char_p lib.zframe_group.argtypes = [zframe_p] lib.zframe_set_group.restype = c_int lib.zframe_set_group.argtypes = [zframe_p, c_char_p] lib.zframe_eq.restype = c_bool lib.zframe_eq.argtypes = [zframe_p, zframe_p] lib.zframe_reset.restype = None lib.zframe_reset.argtypes = [zframe_p, c_void_p, c_size_t] lib.zframe_print.restype = None lib.zframe_print.argtypes = [zframe_p, c_char_p] lib.zframe_is.restype = c_bool lib.zframe_is.argtypes = [c_void_p] lib.zframe_test.restype = None lib.zframe_test.argtypes = [c_bool] class Zframe(object): """ working with single message frames """ MORE = 1 # REUSE = 2 # DONTWAIT = 4 # allow_destruct = False def __init__(self, *args): """ Create a new frame. If size is not null, allocates the frame data to the specified size. If additionally, data is not null, copies size octets from the specified data into the frame body. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zframe_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zframe_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 2) self._as_parameter_ = lib.zframe_new(args[0], args[1]) # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a frame """ if self.allow_destruct: lib.zframe_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() @staticmethod def new_empty(): """ Create an empty (zero-sized) frame """ return Zframe(lib.zframe_new_empty(), True) @staticmethod def from_(string): """ Create a frame with a specified string content. """ return Zframe(lib.zframe_from(string), True) @staticmethod def recv(source): """ Receive frame from socket, returns zframe_t object or NULL if the recv was interrupted. Does a blocking recv, if you want to not block then use zpoller or zloop. """ return Zframe(lib.zframe_recv(source), True) @staticmethod def send(self_p, dest, flags): """ Send a frame to a socket, destroy frame after sending. Return -1 on error, 0 on success. """ return lib.zframe_send(byref(zframe_p.from_param(self_p)), dest, flags) def size(self): """ Return number of bytes in frame data """ return lib.zframe_size(self._as_parameter_) def data(self): """ Return address of frame data """ return lib.zframe_data(self._as_parameter_) def meta(self, property): """ Return meta data property for frame The caller shall not modify or free the returned value, which shall be owned by the message. """ return lib.zframe_meta(self._as_parameter_, property) def dup(self): """ Create a new frame that duplicates an existing frame. If frame is null, or memory was exhausted, returns null. """ return Zframe(lib.zframe_dup(self._as_parameter_), True) def strhex(self): """ Return frame data encoded as printable hex string, useful for 0MQ UUIDs. Caller must free string when finished with it. """ return return_fresh_string(lib.zframe_strhex(self._as_parameter_)) def strdup(self): """ Return frame data copied into freshly allocated string Caller must free string when finished with it. """ return return_fresh_string(lib.zframe_strdup(self._as_parameter_)) def streq(self, string): """ Return TRUE if frame body is equal to string, excluding terminator """ return lib.zframe_streq(self._as_parameter_, string) def more(self): """ Return frame MORE indicator (1 or 0), set when reading frame from socket or by the zframe_set_more() method """ return lib.zframe_more(self._as_parameter_) def set_more(self, more): """ Set frame MORE indicator (1 or 0). Note this is NOT used when sending frame to socket, you have to specify flag explicitly. """ return lib.zframe_set_more(self._as_parameter_, more) def routing_id(self): """ Return frame routing ID, if the frame came from a ZMQ_SERVER socket. Else returns zero. """ return lib.zframe_routing_id(self._as_parameter_) def set_routing_id(self, routing_id): """ Set routing ID on frame. This is used if/when the frame is sent to a ZMQ_SERVER socket. """ return lib.zframe_set_routing_id(self._as_parameter_, routing_id) def group(self): """ Return frame group of radio-dish pattern. """ return lib.zframe_group(self._as_parameter_) def set_group(self, group): """ Set group on frame. This is used if/when the frame is sent to a ZMQ_RADIO socket. Return -1 on error, 0 on success. """ return lib.zframe_set_group(self._as_parameter_, group) def eq(self, other): """ Return TRUE if two frames have identical size and data If either frame is NULL, equality is always false. """ return lib.zframe_eq(self._as_parameter_, other) def reset(self, data, size): """ Set new contents for frame """ return lib.zframe_reset(self._as_parameter_, data, size) def print(self, prefix): """ Send message to zsys log sink (may be stdout, or system facility as configured by zsys_set_logstream). Prefix shows before frame, if not null. """ return lib.zframe_print(self._as_parameter_, prefix) @staticmethod def is_(self): """ Probe the supplied object, and report if it looks like a zframe_t. """ return lib.zframe_is(self) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zframe_test(verbose) # zhash zhash_free_fn = CFUNCTYPE(None, c_void_p) lib.zhash_new.restype = zhash_p lib.zhash_new.argtypes = [] lib.zhash_destroy.restype = None lib.zhash_destroy.argtypes = [POINTER(zhash_p)] lib.zhash_unpack.restype = zhash_p lib.zhash_unpack.argtypes = [zframe_p] lib.zhash_insert.restype = c_int lib.zhash_insert.argtypes = [zhash_p, c_char_p, c_void_p] lib.zhash_update.restype = None lib.zhash_update.argtypes = [zhash_p, c_char_p, c_void_p] lib.zhash_delete.restype = None lib.zhash_delete.argtypes = [zhash_p, c_char_p] lib.zhash_lookup.restype = c_void_p lib.zhash_lookup.argtypes = [zhash_p, c_char_p] lib.zhash_rename.restype = c_int lib.zhash_rename.argtypes = [zhash_p, c_char_p, c_char_p] lib.zhash_freefn.restype = c_void_p lib.zhash_freefn.argtypes = [zhash_p, c_char_p, zhash_free_fn] lib.zhash_size.restype = c_size_t lib.zhash_size.argtypes = [zhash_p] lib.zhash_dup.restype = zhash_p lib.zhash_dup.argtypes = [zhash_p] lib.zhash_keys.restype = zlist_p lib.zhash_keys.argtypes = [zhash_p] lib.zhash_first.restype = c_void_p lib.zhash_first.argtypes = [zhash_p] lib.zhash_next.restype = c_void_p lib.zhash_next.argtypes = [zhash_p] lib.zhash_cursor.restype = c_char_p lib.zhash_cursor.argtypes = [zhash_p] lib.zhash_comment.restype = None lib.zhash_comment.argtypes = [zhash_p, c_char_p] lib.zhash_pack.restype = zframe_p lib.zhash_pack.argtypes = [zhash_p] lib.zhash_save.restype = c_int lib.zhash_save.argtypes = [zhash_p, c_char_p] lib.zhash_load.restype = c_int lib.zhash_load.argtypes = [zhash_p, c_char_p] lib.zhash_refresh.restype = c_int lib.zhash_refresh.argtypes = [zhash_p] lib.zhash_autofree.restype = None lib.zhash_autofree.argtypes = [zhash_p] lib.zhash_test.restype = None lib.zhash_test.argtypes = [c_bool] class Zhash(object): """ generic type-free hash container (simple) """ allow_destruct = False def __init__(self, *args): """ Create a new, empty hash container """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zhash_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zhash_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.zhash_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a hash container and all items in it """ if self.allow_destruct: lib.zhash_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() @staticmethod def unpack(frame): """ Unpack binary frame into a new hash table. Packed data must follow format defined by zhash_pack. Hash table is set to autofree. An empty frame unpacks to an empty hash table. """ return Zhash(lib.zhash_unpack(frame), True) def insert(self, key, item): """ Insert item into hash table with specified key and item. If key is already present returns -1 and leaves existing item unchanged Returns 0 on success. """ return lib.zhash_insert(self._as_parameter_, key, item) def update(self, key, item): """ Update item into hash table with specified key and item. If key is already present, destroys old item and inserts new one. Use free_fn method to ensure deallocator is properly called on item. """ return lib.zhash_update(self._as_parameter_, key, item) def delete(self, key): """ Remove an item specified by key from the hash table. If there was no such item, this function does nothing. """ return lib.zhash_delete(self._as_parameter_, key) def lookup(self, key): """ Return the item at the specified key, or null """ return c_void_p(lib.zhash_lookup(self._as_parameter_, key)) def rename(self, old_key, new_key): """ Reindexes an item from an old key to a new key. If there was no such item, does nothing. Returns 0 if successful, else -1. """ return lib.zhash_rename(self._as_parameter_, old_key, new_key) def freefn(self, key, free_fn): """ Set a free function for the specified hash table item. When the item is destroyed, the free function, if any, is called on that item. Use this when hash items are dynamically allocated, to ensure that you don't have memory leaks. You can pass 'free' or NULL as a free_fn. Returns the item, or NULL if there is no such item. """ return c_void_p(lib.zhash_freefn(self._as_parameter_, key, free_fn)) def size(self): """ Return the number of keys/items in the hash table """ return lib.zhash_size(self._as_parameter_) def dup(self): """ Make copy of hash table; if supplied table is null, returns null. Does not copy items themselves. Rebuilds new table so may be slow on very large tables. NOTE: only works with item values that are strings since there's no other way to know how to duplicate the item value. """ return Zhash(lib.zhash_dup(self._as_parameter_), True) def keys(self): """ Return keys for items in table """ return Zlist(lib.zhash_keys(self._as_parameter_), True) def first(self): """ Simple iterator; returns first item in hash table, in no given order, or NULL if the table is empty. This method is simpler to use than the foreach() method, which is deprecated. To access the key for this item use zhash_cursor(). NOTE: do NOT modify the table while iterating. """ return c_void_p(lib.zhash_first(self._as_parameter_)) def next(self): """ Simple iterator; returns next item in hash table, in no given order, or NULL if the last item was already returned. Use this together with zhash_first() to process all items in a hash table. If you need the items in sorted order, use zhash_keys() and then zlist_sort(). To access the key for this item use zhash_cursor(). NOTE: do NOT modify the table while iterating. """ return c_void_p(lib.zhash_next(self._as_parameter_)) def cursor(self): """ After a successful first/next method, returns the key for the item that was returned. This is a constant string that you may not modify or deallocate, and which lasts as long as the item in the hash. After an unsuccessful first/next, returns NULL. """ return lib.zhash_cursor(self._as_parameter_) def comment(self, format, *args): """ Add a comment to hash table before saving to disk. You can add as many comment lines as you like. These comment lines are discarded when loading the file. If you use a null format, all comments are deleted. """ return lib.zhash_comment(self._as_parameter_, format, *args) def pack(self): """ Serialize hash table to a binary frame that can be sent in a message. The packed format is compatible with the 'dictionary' type defined in http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: ; A list of name/value pairs dictionary = dict-count *( dict-name dict-value ) dict-count = number-4 dict-value = longstr dict-name = string ; Strings are always length + text contents longstr = number-4 *VCHAR string = number-1 *VCHAR ; Numbers are unsigned integers in network byte order number-1 = 1OCTET number-4 = 4OCTET Comments are not included in the packed data. Item values MUST be strings. """ return Zframe(lib.zhash_pack(self._as_parameter_), True) def save(self, filename): """ Save hash table to a text file in name=value format. Hash values must be printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file error occurred. """ return lib.zhash_save(self._as_parameter_, filename) def load(self, filename): """ Load hash table from a text file in name=value format; hash table must already exist. Hash values must printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file was not readable. """ return lib.zhash_load(self._as_parameter_, filename) def refresh(self): """ When a hash table was loaded from a file by zhash_load, this method will reload the file if it has been modified since, and is "stable", i.e. not still changing. Returns 0 if OK, -1 if there was an error reloading the file. """ return lib.zhash_refresh(self._as_parameter_) def autofree(self): """ Set hash for automatic value destruction. Note that this assumes that values are NULL-terminated strings. Do not use with different types. """ return lib.zhash_autofree(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zhash_test(verbose) # zhashx zhashx_destructor_fn = CFUNCTYPE(None, POINTER(c_void_p)) zhashx_duplicator_fn = CFUNCTYPE(c_void_p, c_void_p) zhashx_comparator_fn = CFUNCTYPE(c_int, c_void_p, c_void_p) zhashx_free_fn = CFUNCTYPE(None, c_void_p) zhashx_hash_fn = CFUNCTYPE(c_size_t, c_void_p) zhashx_serializer_fn = CFUNCTYPE(POINTER(c_char), c_void_p) zhashx_deserializer_fn = CFUNCTYPE(c_void_p, c_char_p) lib.zhashx_new.restype = zhashx_p lib.zhashx_new.argtypes = [] lib.zhashx_destroy.restype = None lib.zhashx_destroy.argtypes = [POINTER(zhashx_p)] lib.zhashx_unpack.restype = zhashx_p lib.zhashx_unpack.argtypes = [zframe_p] lib.zhashx_unpack_own.restype = zhashx_p lib.zhashx_unpack_own.argtypes = [zframe_p, zhashx_deserializer_fn] lib.zhashx_insert.restype = c_int lib.zhashx_insert.argtypes = [zhashx_p, c_void_p, c_void_p] lib.zhashx_update.restype = None lib.zhashx_update.argtypes = [zhashx_p, c_void_p, c_void_p] lib.zhashx_delete.restype = None lib.zhashx_delete.argtypes = [zhashx_p, c_void_p] lib.zhashx_purge.restype = None lib.zhashx_purge.argtypes = [zhashx_p] lib.zhashx_lookup.restype = c_void_p lib.zhashx_lookup.argtypes = [zhashx_p, c_void_p] lib.zhashx_rename.restype = c_int lib.zhashx_rename.argtypes = [zhashx_p, c_void_p, c_void_p] lib.zhashx_freefn.restype = c_void_p lib.zhashx_freefn.argtypes = [zhashx_p, c_void_p, zhashx_free_fn] lib.zhashx_size.restype = c_size_t lib.zhashx_size.argtypes = [zhashx_p] lib.zhashx_keys.restype = zlistx_p lib.zhashx_keys.argtypes = [zhashx_p] lib.zhashx_values.restype = zlistx_p lib.zhashx_values.argtypes = [zhashx_p] lib.zhashx_first.restype = c_void_p lib.zhashx_first.argtypes = [zhashx_p] lib.zhashx_next.restype = c_void_p lib.zhashx_next.argtypes = [zhashx_p] lib.zhashx_cursor.restype = c_void_p lib.zhashx_cursor.argtypes = [zhashx_p] lib.zhashx_comment.restype = None lib.zhashx_comment.argtypes = [zhashx_p, c_char_p] lib.zhashx_save.restype = c_int lib.zhashx_save.argtypes = [zhashx_p, c_char_p] lib.zhashx_load.restype = c_int lib.zhashx_load.argtypes = [zhashx_p, c_char_p] lib.zhashx_refresh.restype = c_int lib.zhashx_refresh.argtypes = [zhashx_p] lib.zhashx_pack.restype = zframe_p lib.zhashx_pack.argtypes = [zhashx_p] lib.zhashx_pack_own.restype = zframe_p lib.zhashx_pack_own.argtypes = [zhashx_p, zhashx_serializer_fn] lib.zhashx_dup.restype = zhashx_p lib.zhashx_dup.argtypes = [zhashx_p] lib.zhashx_set_destructor.restype = None lib.zhashx_set_destructor.argtypes = [zhashx_p, zhashx_destructor_fn] lib.zhashx_set_duplicator.restype = None lib.zhashx_set_duplicator.argtypes = [zhashx_p, zhashx_duplicator_fn] lib.zhashx_set_key_destructor.restype = None lib.zhashx_set_key_destructor.argtypes = [zhashx_p, zhashx_destructor_fn] lib.zhashx_set_key_duplicator.restype = None lib.zhashx_set_key_duplicator.argtypes = [zhashx_p, zhashx_duplicator_fn] lib.zhashx_set_key_comparator.restype = None lib.zhashx_set_key_comparator.argtypes = [zhashx_p, zhashx_comparator_fn] lib.zhashx_set_key_hasher.restype = None lib.zhashx_set_key_hasher.argtypes = [zhashx_p, zhashx_hash_fn] lib.zhashx_dup_v2.restype = zhashx_p lib.zhashx_dup_v2.argtypes = [zhashx_p] lib.zhashx_test.restype = None lib.zhashx_test.argtypes = [c_bool] class Zhashx(object): """ extended generic type-free hash container """ allow_destruct = False def __init__(self, *args): """ Create a new, empty hash container """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zhashx_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zhashx_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.zhashx_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a hash container and all items in it """ if self.allow_destruct: lib.zhashx_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() @staticmethod def unpack(frame): """ Unpack binary frame into a new hash table. Packed data must follow format defined by zhashx_pack. Hash table is set to autofree. An empty frame unpacks to an empty hash table. """ return Zhashx(lib.zhashx_unpack(frame), True) @staticmethod def unpack_own(frame, deserializer): """ Same as unpack but uses a user-defined deserializer function to convert a longstr back into item format. """ return Zhashx(lib.zhashx_unpack_own(frame, deserializer), True) def insert(self, key, item): """ Insert item into hash table with specified key and item. If key is already present returns -1 and leaves existing item unchanged Returns 0 on success. """ return lib.zhashx_insert(self._as_parameter_, key, item) def update(self, key, item): """ Update or insert item into hash table with specified key and item. If the key is already present, destroys old item and inserts new one. If you set a container item destructor, this is called on the old value. If the key was not already present, inserts a new item. Sets the hash cursor to the new item. """ return lib.zhashx_update(self._as_parameter_, key, item) def delete(self, key): """ Remove an item specified by key from the hash table. If there was no such item, this function does nothing. """ return lib.zhashx_delete(self._as_parameter_, key) def purge(self): """ Delete all items from the hash table. If the key destructor is set, calls it on every key. If the item destructor is set, calls it on every item. """ return lib.zhashx_purge(self._as_parameter_) def lookup(self, key): """ Return the item at the specified key, or null """ return c_void_p(lib.zhashx_lookup(self._as_parameter_, key)) def rename(self, old_key, new_key): """ Reindexes an item from an old key to a new key. If there was no such item, does nothing. Returns 0 if successful, else -1. """ return lib.zhashx_rename(self._as_parameter_, old_key, new_key) def freefn(self, key, free_fn): """ Set a free function for the specified hash table item. When the item is destroyed, the free function, if any, is called on that item. Use this when hash items are dynamically allocated, to ensure that you don't have memory leaks. You can pass 'free' or NULL as a free_fn. Returns the item, or NULL if there is no such item. """ return c_void_p(lib.zhashx_freefn(self._as_parameter_, key, free_fn)) def size(self): """ Return the number of keys/items in the hash table """ return lib.zhashx_size(self._as_parameter_) def keys(self): """ Return a zlistx_t containing the keys for the items in the table. Uses the key_duplicator to duplicate all keys and sets the key_destructor as destructor for the list. """ return Zlistx(lib.zhashx_keys(self._as_parameter_), True) def values(self): """ Return a zlistx_t containing the values for the items in the table. Uses the duplicator to duplicate all items and sets the destructor as destructor for the list. """ return Zlistx(lib.zhashx_values(self._as_parameter_), True) def first(self): """ Simple iterator; returns first item in hash table, in no given order, or NULL if the table is empty. This method is simpler to use than the foreach() method, which is deprecated. To access the key for this item use zhashx_cursor(). NOTE: do NOT modify the table while iterating. """ return c_void_p(lib.zhashx_first(self._as_parameter_)) def next(self): """ Simple iterator; returns next item in hash table, in no given order, or NULL if the last item was already returned. Use this together with zhashx_first() to process all items in a hash table. If you need the items in sorted order, use zhashx_keys() and then zlistx_sort(). To access the key for this item use zhashx_cursor(). NOTE: do NOT modify the table while iterating. """ return c_void_p(lib.zhashx_next(self._as_parameter_)) def cursor(self): """ After a successful first/next method, returns the key for the item that was returned. This is a constant string that you may not modify or deallocate, and which lasts as long as the item in the hash. After an unsuccessful first/next, returns NULL. """ return c_void_p(lib.zhashx_cursor(self._as_parameter_)) def comment(self, format, *args): """ Add a comment to hash table before saving to disk. You can add as many comment lines as you like. These comment lines are discarded when loading the file. If you use a null format, all comments are deleted. """ return lib.zhashx_comment(self._as_parameter_, format, *args) def save(self, filename): """ Save hash table to a text file in name=value format. Hash values must be printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file error occurred. """ return lib.zhashx_save(self._as_parameter_, filename) def load(self, filename): """ Load hash table from a text file in name=value format; hash table must already exist. Hash values must printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file was not readable. """ return lib.zhashx_load(self._as_parameter_, filename) def refresh(self): """ When a hash table was loaded from a file by zhashx_load, this method will reload the file if it has been modified since, and is "stable", i.e. not still changing. Returns 0 if OK, -1 if there was an error reloading the file. """ return lib.zhashx_refresh(self._as_parameter_) def pack(self): """ Serialize hash table to a binary frame that can be sent in a message. The packed format is compatible with the 'dictionary' type defined in http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: ; A list of name/value pairs dictionary = dict-count *( dict-name dict-value ) dict-count = number-4 dict-value = longstr dict-name = string ; Strings are always length + text contents longstr = number-4 *VCHAR string = number-1 *VCHAR ; Numbers are unsigned integers in network byte order number-1 = 1OCTET number-4 = 4OCTET Comments are not included in the packed data. Item values MUST be strings. """ return Zframe(lib.zhashx_pack(self._as_parameter_), True) def pack_own(self, serializer): """ Same as pack but uses a user-defined serializer function to convert items into longstr. """ return Zframe(lib.zhashx_pack_own(self._as_parameter_, serializer), True) def dup(self): """ Make a copy of the list; items are duplicated if you set a duplicator for the list, otherwise not. Copying a null reference returns a null reference. Note that this method's behavior changed slightly for CZMQ v3.x, as it does not set nor respect autofree. It does however let you duplicate any hash table safely. The old behavior is in zhashx_dup_v2. """ return Zhashx(lib.zhashx_dup(self._as_parameter_), True) def set_destructor(self, destructor): """ Set a user-defined deallocator for hash items; by default items are not freed when the hash is destroyed. """ return lib.zhashx_set_destructor(self._as_parameter_, destructor) def set_duplicator(self, duplicator): """ Set a user-defined duplicator for hash items; by default items are not copied when the hash is duplicated. """ return lib.zhashx_set_duplicator(self._as_parameter_, duplicator) def set_key_destructor(self, destructor): """ Set a user-defined deallocator for keys; by default keys are freed when the hash is destroyed using free(). """ return lib.zhashx_set_key_destructor(self._as_parameter_, destructor) def set_key_duplicator(self, duplicator): """ Set a user-defined duplicator for keys; by default keys are duplicated using strdup. """ return lib.zhashx_set_key_duplicator(self._as_parameter_, duplicator) def set_key_comparator(self, comparator): """ Set a user-defined comparator for keys; by default keys are compared using strcmp. The callback function should return zero (0) on matching items. """ return lib.zhashx_set_key_comparator(self._as_parameter_, comparator) def set_key_hasher(self, hasher): """ Set a user-defined hash function for keys; by default keys are hashed by a modified Bernstein hashing function. """ return lib.zhashx_set_key_hasher(self._as_parameter_, hasher) def dup_v2(self): """ Make copy of hash table; if supplied table is null, returns null. Does not copy items themselves. Rebuilds new table so may be slow on very large tables. NOTE: only works with item values that are strings since there's no other way to know how to duplicate the item value. """ return Zhashx(lib.zhashx_dup_v2(self._as_parameter_), False) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zhashx_test(verbose) # ziflist lib.ziflist_new.restype = ziflist_p lib.ziflist_new.argtypes = [] lib.ziflist_destroy.restype = None lib.ziflist_destroy.argtypes = [POINTER(ziflist_p)] lib.ziflist_reload.restype = None lib.ziflist_reload.argtypes = [ziflist_p] lib.ziflist_size.restype = c_size_t lib.ziflist_size.argtypes = [ziflist_p] lib.ziflist_first.restype = c_char_p lib.ziflist_first.argtypes = [ziflist_p] lib.ziflist_next.restype = c_char_p lib.ziflist_next.argtypes = [ziflist_p] lib.ziflist_address.restype = c_char_p lib.ziflist_address.argtypes = [ziflist_p] lib.ziflist_broadcast.restype = c_char_p lib.ziflist_broadcast.argtypes = [ziflist_p] lib.ziflist_netmask.restype = c_char_p lib.ziflist_netmask.argtypes = [ziflist_p] lib.ziflist_print.restype = None lib.ziflist_print.argtypes = [ziflist_p] lib.ziflist_new_ipv6.restype = ziflist_p lib.ziflist_new_ipv6.argtypes = [] lib.ziflist_reload_ipv6.restype = None lib.ziflist_reload_ipv6.argtypes = [ziflist_p] lib.ziflist_is_ipv6.restype = c_bool lib.ziflist_is_ipv6.argtypes = [ziflist_p] lib.ziflist_test.restype = None lib.ziflist_test.argtypes = [c_bool] class Ziflist(object): """ List of network interfaces available on system """ allow_destruct = False def __init__(self, *args): """ Get a list of network interfaces currently defined on the system """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], ziflist_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is ziflist_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.ziflist_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a ziflist instance """ if self.allow_destruct: lib.ziflist_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def reload(self): """ Reload network interfaces from system """ return lib.ziflist_reload(self._as_parameter_) def size(self): """ Return the number of network interfaces on system """ return lib.ziflist_size(self._as_parameter_) def first(self): """ Get first network interface, return NULL if there are none """ return lib.ziflist_first(self._as_parameter_) def next(self): """ Get next network interface, return NULL if we hit the last one """ return lib.ziflist_next(self._as_parameter_) def address(self): """ Return the current interface IP address as a printable string """ return lib.ziflist_address(self._as_parameter_) def broadcast(self): """ Return the current interface broadcast address as a printable string """ return lib.ziflist_broadcast(self._as_parameter_) def netmask(self): """ Return the current interface network mask as a printable string """ return lib.ziflist_netmask(self._as_parameter_) def print(self): """ Return the list of interfaces. """ return lib.ziflist_print(self._as_parameter_) @staticmethod def new_ipv6(): """ Get a list of network interfaces currently defined on the system Includes IPv6 interfaces """ return Ziflist(lib.ziflist_new_ipv6(), True) def reload_ipv6(self): """ Reload network interfaces from system, including IPv6 """ return lib.ziflist_reload_ipv6(self._as_parameter_) def is_ipv6(self): """ Return true if the current interface uses IPv6 """ return lib.ziflist_is_ipv6(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class. """ return lib.ziflist_test(verbose) # zlist zlist_compare_fn = CFUNCTYPE(c_int, c_void_p, c_void_p) zlist_free_fn = CFUNCTYPE(None, c_void_p) lib.zlist_new.restype = zlist_p lib.zlist_new.argtypes = [] lib.zlist_destroy.restype = None lib.zlist_destroy.argtypes = [POINTER(zlist_p)] lib.zlist_first.restype = c_void_p lib.zlist_first.argtypes = [zlist_p] lib.zlist_next.restype = c_void_p lib.zlist_next.argtypes = [zlist_p] lib.zlist_last.restype = c_void_p lib.zlist_last.argtypes = [zlist_p] lib.zlist_head.restype = c_void_p lib.zlist_head.argtypes = [zlist_p] lib.zlist_tail.restype = c_void_p lib.zlist_tail.argtypes = [zlist_p] lib.zlist_item.restype = c_void_p lib.zlist_item.argtypes = [zlist_p] lib.zlist_append.restype = c_int lib.zlist_append.argtypes = [zlist_p, c_void_p] lib.zlist_push.restype = c_int lib.zlist_push.argtypes = [zlist_p, c_void_p] lib.zlist_pop.restype = c_void_p lib.zlist_pop.argtypes = [zlist_p] lib.zlist_exists.restype = c_bool lib.zlist_exists.argtypes = [zlist_p, c_void_p] lib.zlist_remove.restype = None lib.zlist_remove.argtypes = [zlist_p, c_void_p] lib.zlist_dup.restype = zlist_p lib.zlist_dup.argtypes = [zlist_p] lib.zlist_purge.restype = None lib.zlist_purge.argtypes = [zlist_p] lib.zlist_size.restype = c_size_t lib.zlist_size.argtypes = [zlist_p] lib.zlist_sort.restype = None lib.zlist_sort.argtypes = [zlist_p, zlist_compare_fn] lib.zlist_autofree.restype = None lib.zlist_autofree.argtypes = [zlist_p] lib.zlist_comparefn.restype = None lib.zlist_comparefn.argtypes = [zlist_p, zlist_compare_fn] lib.zlist_freefn.restype = c_void_p lib.zlist_freefn.argtypes = [zlist_p, c_void_p, zlist_free_fn, c_bool] lib.zlist_test.restype = None lib.zlist_test.argtypes = [c_bool] class Zlist(object): """ simple generic list container """ allow_destruct = False def __init__(self, *args): """ Create a new list container """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zlist_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zlist_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.zlist_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a list container """ if self.allow_destruct: lib.zlist_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def first(self): """ Return the item at the head of list. If the list is empty, returns NULL. Leaves cursor pointing at the head item, or NULL if the list is empty. """ return c_void_p(lib.zlist_first(self._as_parameter_)) def next(self): """ Return the next item. If the list is empty, returns NULL. To move to the start of the list call zlist_first (). Advances the cursor. """ return c_void_p(lib.zlist_next(self._as_parameter_)) def last(self): """ Return the item at the tail of list. If the list is empty, returns NULL. Leaves cursor pointing at the tail item, or NULL if the list is empty. """ return c_void_p(lib.zlist_last(self._as_parameter_)) def head(self): """ Return first item in the list, or null, leaves the cursor """ return c_void_p(lib.zlist_head(self._as_parameter_)) def tail(self): """ Return last item in the list, or null, leaves the cursor """ return c_void_p(lib.zlist_tail(self._as_parameter_)) def item(self): """ Return the current item of list. If the list is empty, returns NULL. Leaves cursor pointing at the current item, or NULL if the list is empty. """ return c_void_p(lib.zlist_item(self._as_parameter_)) def append(self, item): """ Append an item to the end of the list, return 0 if OK or -1 if this failed for some reason (out of memory). Note that if a duplicator has been set, this method will also duplicate the item. """ return lib.zlist_append(self._as_parameter_, item) def push(self, item): """ Push an item to the start of the list, return 0 if OK or -1 if this failed for some reason (out of memory). Note that if a duplicator has been set, this method will also duplicate the item. """ return lib.zlist_push(self._as_parameter_, item) def pop(self): """ Pop the item off the start of the list, if any """ return c_void_p(lib.zlist_pop(self._as_parameter_)) def exists(self, item): """ Checks if an item already is present. Uses compare method to determine if items are equal. If the compare method is NULL the check will only compare pointers. Returns true if item is present else false. """ return lib.zlist_exists(self._as_parameter_, item) def remove(self, item): """ Remove the specified item from the list if present """ return lib.zlist_remove(self._as_parameter_, item) def dup(self): """ Make a copy of list. If the list has autofree set, the copied list will duplicate all items, which must be strings. Otherwise, the list will hold pointers back to the items in the original list. If list is null, returns NULL. """ return Zlist(lib.zlist_dup(self._as_parameter_), True) def purge(self): """ Purge all items from list """ return lib.zlist_purge(self._as_parameter_) def size(self): """ Return number of items in the list """ return lib.zlist_size(self._as_parameter_) def sort(self, compare): """ Sort the list. If the compare function is null, sorts the list by ascending key value using a straight ASCII comparison. If you specify a compare function, this decides how items are sorted. The sort is not stable, so may reorder items with the same keys. The algorithm used is combsort, a compromise between performance and simplicity. """ return lib.zlist_sort(self._as_parameter_, compare) def autofree(self): """ Set list for automatic item destruction; item values MUST be strings. By default a list item refers to a value held elsewhere. When you set this, each time you append or push a list item, zlist will take a copy of the string value. Then, when you destroy the list, it will free all item values automatically. If you use any other technique to allocate list values, you must free them explicitly before destroying the list. The usual technique is to pop list items and destroy them, until the list is empty. """ return lib.zlist_autofree(self._as_parameter_) def comparefn(self, fn): """ Sets a compare function for this list. The function compares two items. It returns an integer less than, equal to, or greater than zero if the first item is found, respectively, to be less than, to match, or be greater than the second item. This function is used for sorting, removal and exists checking. """ return lib.zlist_comparefn(self._as_parameter_, fn) def freefn(self, item, fn, at_tail): """ Set a free function for the specified list item. When the item is destroyed, the free function, if any, is called on that item. Use this when list items are dynamically allocated, to ensure that you don't have memory leaks. You can pass 'free' or NULL as a free_fn. Returns the item, or NULL if there is no such item. """ return c_void_p(lib.zlist_freefn(self._as_parameter_, item, fn, at_tail)) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zlist_test(verbose) # zlistx zlistx_destructor_fn = CFUNCTYPE(None, POINTER(c_void_p)) zlistx_duplicator_fn = CFUNCTYPE(c_void_p, c_void_p) zlistx_comparator_fn = CFUNCTYPE(c_int, c_void_p, c_void_p) lib.zlistx_new.restype = zlistx_p lib.zlistx_new.argtypes = [] lib.zlistx_destroy.restype = None lib.zlistx_destroy.argtypes = [POINTER(zlistx_p)] lib.zlistx_add_start.restype = c_void_p lib.zlistx_add_start.argtypes = [zlistx_p, c_void_p] lib.zlistx_add_end.restype = c_void_p lib.zlistx_add_end.argtypes = [zlistx_p, c_void_p] lib.zlistx_size.restype = c_size_t lib.zlistx_size.argtypes = [zlistx_p] lib.zlistx_head.restype = c_void_p lib.zlistx_head.argtypes = [zlistx_p] lib.zlistx_tail.restype = c_void_p lib.zlistx_tail.argtypes = [zlistx_p] lib.zlistx_first.restype = c_void_p lib.zlistx_first.argtypes = [zlistx_p] lib.zlistx_next.restype = c_void_p lib.zlistx_next.argtypes = [zlistx_p] lib.zlistx_prev.restype = c_void_p lib.zlistx_prev.argtypes = [zlistx_p] lib.zlistx_last.restype = c_void_p lib.zlistx_last.argtypes = [zlistx_p] lib.zlistx_item.restype = c_void_p lib.zlistx_item.argtypes = [zlistx_p] lib.zlistx_cursor.restype = c_void_p lib.zlistx_cursor.argtypes = [zlistx_p] lib.zlistx_handle_item.restype = c_void_p lib.zlistx_handle_item.argtypes = [c_void_p] lib.zlistx_find.restype = c_void_p lib.zlistx_find.argtypes = [zlistx_p, c_void_p] lib.zlistx_detach.restype = c_void_p lib.zlistx_detach.argtypes = [zlistx_p, c_void_p] lib.zlistx_detach_cur.restype = c_void_p lib.zlistx_detach_cur.argtypes = [zlistx_p] lib.zlistx_delete.restype = c_int lib.zlistx_delete.argtypes = [zlistx_p, c_void_p] lib.zlistx_move_start.restype = None lib.zlistx_move_start.argtypes = [zlistx_p, c_void_p] lib.zlistx_move_end.restype = None lib.zlistx_move_end.argtypes = [zlistx_p, c_void_p] lib.zlistx_purge.restype = None lib.zlistx_purge.argtypes = [zlistx_p] lib.zlistx_sort.restype = None lib.zlistx_sort.argtypes = [zlistx_p] lib.zlistx_insert.restype = c_void_p lib.zlistx_insert.argtypes = [zlistx_p, c_void_p, c_bool] lib.zlistx_reorder.restype = None lib.zlistx_reorder.argtypes = [zlistx_p, c_void_p, c_bool] lib.zlistx_dup.restype = zlistx_p lib.zlistx_dup.argtypes = [zlistx_p] lib.zlistx_set_destructor.restype = None lib.zlistx_set_destructor.argtypes = [zlistx_p, zlistx_destructor_fn] lib.zlistx_set_duplicator.restype = None lib.zlistx_set_duplicator.argtypes = [zlistx_p, zlistx_duplicator_fn] lib.zlistx_set_comparator.restype = None lib.zlistx_set_comparator.argtypes = [zlistx_p, zlistx_comparator_fn] lib.zlistx_test.restype = None lib.zlistx_test.argtypes = [c_bool] class Zlistx(object): """ extended generic list container """ allow_destruct = False def __init__(self, *args): """ Create a new, empty list. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zlistx_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zlistx_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.zlistx_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a list. If an item destructor was specified, all items in the list are automatically destroyed as well. """ if self.allow_destruct: lib.zlistx_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def add_start(self, item): """ Add an item to the head of the list. Calls the item duplicator, if any, on the item. Resets cursor to list head. Returns an item handle on success, NULL if memory was exhausted. """ return c_void_p(lib.zlistx_add_start(self._as_parameter_, item)) def add_end(self, item): """ Add an item to the tail of the list. Calls the item duplicator, if any, on the item. Resets cursor to list head. Returns an item handle on success, NULL if memory was exhausted. """ return c_void_p(lib.zlistx_add_end(self._as_parameter_, item)) def size(self): """ Return the number of items in the list """ return lib.zlistx_size(self._as_parameter_) def head(self): """ Return first item in the list, or null, leaves the cursor """ return c_void_p(lib.zlistx_head(self._as_parameter_)) def tail(self): """ Return last item in the list, or null, leaves the cursor """ return c_void_p(lib.zlistx_tail(self._as_parameter_)) def first(self): """ Return the item at the head of list. If the list is empty, returns NULL. Leaves cursor pointing at the head item, or NULL if the list is empty. """ return c_void_p(lib.zlistx_first(self._as_parameter_)) def next(self): """ Return the next item. At the end of the list (or in an empty list), returns NULL. Use repeated zlistx_next () calls to work through the list from zlistx_first (). First time, acts as zlistx_first(). """ return c_void_p(lib.zlistx_next(self._as_parameter_)) def prev(self): """ Return the previous item. At the start of the list (or in an empty list), returns NULL. Use repeated zlistx_prev () calls to work through the list backwards from zlistx_last (). First time, acts as zlistx_last(). """ return c_void_p(lib.zlistx_prev(self._as_parameter_)) def last(self): """ Return the item at the tail of list. If the list is empty, returns NULL. Leaves cursor pointing at the tail item, or NULL if the list is empty. """ return c_void_p(lib.zlistx_last(self._as_parameter_)) def item(self): """ Returns the value of the item at the cursor, or NULL if the cursor is not pointing to an item. """ return c_void_p(lib.zlistx_item(self._as_parameter_)) def cursor(self): """ Returns the handle of the item at the cursor, or NULL if the cursor is not pointing to an item. """ return c_void_p(lib.zlistx_cursor(self._as_parameter_)) @staticmethod def handle_item(handle): """ Returns the item associated with the given list handle, or NULL if passed in handle is NULL. Asserts that the passed in handle points to a list element. """ return c_void_p(lib.zlistx_handle_item(handle)) def find(self, item): """ Find an item in the list, searching from the start. Uses the item comparator, if any, else compares item values directly. Returns the item handle found, or NULL. Sets the cursor to the found item, if any. """ return c_void_p(lib.zlistx_find(self._as_parameter_, item)) def detach(self, handle): """ Detach an item from the list, using its handle. The item is not modified, and the caller is responsible for destroying it if necessary. If handle is null, detaches the first item on the list. Returns item that was detached, or null if none was. If cursor was at item, moves cursor to previous item, so you can detach items while iterating forwards through a list. """ return c_void_p(lib.zlistx_detach(self._as_parameter_, handle)) def detach_cur(self): """ Detach item at the cursor, if any, from the list. The item is not modified, and the caller is responsible for destroying it as necessary. Returns item that was detached, or null if none was. Moves cursor to previous item, so you can detach items while iterating forwards through a list. """ return c_void_p(lib.zlistx_detach_cur(self._as_parameter_)) def delete(self, handle): """ Delete an item, using its handle. Calls the item destructor is any is set. If handle is null, deletes the first item on the list. Returns 0 if an item was deleted, -1 if not. If cursor was at item, moves cursor to previous item, so you can delete items while iterating forwards through a list. """ return lib.zlistx_delete(self._as_parameter_, handle) def move_start(self, handle): """ Move an item to the start of the list, via its handle. """ return lib.zlistx_move_start(self._as_parameter_, handle) def move_end(self, handle): """ Move an item to the end of the list, via its handle. """ return lib.zlistx_move_end(self._as_parameter_, handle) def purge(self): """ Remove all items from the list, and destroy them if the item destructor is set. """ return lib.zlistx_purge(self._as_parameter_) def sort(self): """ Sort the list. If an item comparator was set, calls that to compare items, otherwise compares on item value. The sort is not stable, so may reorder equal items. """ return lib.zlistx_sort(self._as_parameter_) def insert(self, item, low_value): """ Create a new node and insert it into a sorted list. Calls the item duplicator, if any, on the item. If low_value is true, starts searching from the start of the list, otherwise searches from the end. Use the item comparator, if any, to find where to place the new node. Returns a handle to the new node, or NULL if memory was exhausted. Resets the cursor to the list head. """ return c_void_p(lib.zlistx_insert(self._as_parameter_, item, low_value)) def reorder(self, handle, low_value): """ Move an item, specified by handle, into position in a sorted list. Uses the item comparator, if any, to determine the new location. If low_value is true, starts searching from the start of the list, otherwise searches from the end. """ return lib.zlistx_reorder(self._as_parameter_, handle, low_value) def dup(self): """ Make a copy of the list; items are duplicated if you set a duplicator for the list, otherwise not. Copying a null reference returns a null reference. """ return Zlistx(lib.zlistx_dup(self._as_parameter_), False) def set_destructor(self, destructor): """ Set a user-defined deallocator for list items; by default items are not freed when the list is destroyed. """ return lib.zlistx_set_destructor(self._as_parameter_, destructor) def set_duplicator(self, duplicator): """ Set a user-defined duplicator for list items; by default items are not copied when the list is duplicated. """ return lib.zlistx_set_duplicator(self._as_parameter_, duplicator) def set_comparator(self, comparator): """ Set a user-defined comparator for zlistx_find and zlistx_sort; the method must return -1, 0, or 1 depending on whether item1 is less than, equal to, or greater than, item2. """ return lib.zlistx_set_comparator(self._as_parameter_, comparator) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zlistx_test(verbose) # zloop zloop_reader_fn = CFUNCTYPE(c_int, zloop_p, zsock_p, c_void_p) zloop_fn = CFUNCTYPE(c_int, zloop_p, zmq_pollitem_p, c_void_p) zloop_timer_fn = CFUNCTYPE(c_int, zloop_p, c_int, c_void_p) lib.zloop_new.restype = zloop_p lib.zloop_new.argtypes = [] lib.zloop_destroy.restype = None lib.zloop_destroy.argtypes = [POINTER(zloop_p)] lib.zloop_reader.restype = c_int lib.zloop_reader.argtypes = [zloop_p, zsock_p, zloop_reader_fn, c_void_p] lib.zloop_reader_end.restype = None lib.zloop_reader_end.argtypes = [zloop_p, zsock_p] lib.zloop_reader_set_tolerant.restype = None lib.zloop_reader_set_tolerant.argtypes = [zloop_p, zsock_p] lib.zloop_poller.restype = c_int lib.zloop_poller.argtypes = [zloop_p, zmq_pollitem_p, zloop_fn, c_void_p] lib.zloop_poller_end.restype = None lib.zloop_poller_end.argtypes = [zloop_p, zmq_pollitem_p] lib.zloop_poller_set_tolerant.restype = None lib.zloop_poller_set_tolerant.argtypes = [zloop_p, zmq_pollitem_p] lib.zloop_timer.restype = c_int lib.zloop_timer.argtypes = [zloop_p, c_size_t, c_size_t, zloop_timer_fn, c_void_p] lib.zloop_timer_end.restype = c_int lib.zloop_timer_end.argtypes = [zloop_p, c_int] lib.zloop_ticket.restype = c_void_p lib.zloop_ticket.argtypes = [zloop_p, zloop_timer_fn, c_void_p] lib.zloop_ticket_reset.restype = None lib.zloop_ticket_reset.argtypes = [zloop_p, c_void_p] lib.zloop_ticket_delete.restype = None lib.zloop_ticket_delete.argtypes = [zloop_p, c_void_p] lib.zloop_set_ticket_delay.restype = None lib.zloop_set_ticket_delay.argtypes = [zloop_p, c_size_t] lib.zloop_set_max_timers.restype = None lib.zloop_set_max_timers.argtypes = [zloop_p, c_size_t] lib.zloop_set_verbose.restype = None lib.zloop_set_verbose.argtypes = [zloop_p, c_bool] lib.zloop_set_nonstop.restype = None lib.zloop_set_nonstop.argtypes = [zloop_p, c_bool] lib.zloop_start.restype = c_int lib.zloop_start.argtypes = [zloop_p] lib.zloop_test.restype = None lib.zloop_test.argtypes = [c_bool] class Zloop(object): """ event-driven reactor """ allow_destruct = False def __init__(self, *args): """ Create a new zloop reactor """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zloop_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zloop_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.zloop_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a reactor """ if self.allow_destruct: lib.zloop_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def reader(self, sock, handler, arg): """ Register socket reader with the reactor. When the reader has messages, the reactor will call the handler, passing the arg. Returns 0 if OK, -1 if there was an error. If you register the same socket more than once, each instance will invoke its corresponding handler. """ return lib.zloop_reader(self._as_parameter_, sock, handler, arg) def reader_end(self, sock): """ Cancel a socket reader from the reactor. If multiple readers exist for same socket, cancels ALL of them. """ return lib.zloop_reader_end(self._as_parameter_, sock) def reader_set_tolerant(self, sock): """ Configure a registered reader to ignore errors. If you do not set this, then readers that have errors are removed from the reactor silently. """ return lib.zloop_reader_set_tolerant(self._as_parameter_, sock) def poller(self, item, handler, arg): """ Register low-level libzmq pollitem with the reactor. When the pollitem is ready, will call the handler, passing the arg. Returns 0 if OK, -1 if there was an error. If you register the pollitem more than once, each instance will invoke its corresponding handler. A pollitem with socket=NULL and fd=0 means 'poll on FD zero'. """ return lib.zloop_poller(self._as_parameter_, item, handler, arg) def poller_end(self, item): """ Cancel a pollitem from the reactor, specified by socket or FD. If both are specified, uses only socket. If multiple poll items exist for same socket/FD, cancels ALL of them. """ return lib.zloop_poller_end(self._as_parameter_, item) def poller_set_tolerant(self, item): """ Configure a registered poller to ignore errors. If you do not set this, then poller that have errors are removed from the reactor silently. """ return lib.zloop_poller_set_tolerant(self._as_parameter_, item) def timer(self, delay, times, handler, arg): """ Register a timer that expires after some delay and repeats some number of times. At each expiry, will call the handler, passing the arg. To run a timer forever, use 0 times. Returns a timer_id that is used to cancel the timer in the future. Returns -1 if there was an error. """ return lib.zloop_timer(self._as_parameter_, delay, times, handler, arg) def timer_end(self, timer_id): """ Cancel a specific timer identified by a specific timer_id (as returned by zloop_timer). """ return lib.zloop_timer_end(self._as_parameter_, timer_id) def ticket(self, handler, arg): """ Register a ticket timer. Ticket timers are very fast in the case where you use a lot of timers (thousands), and frequently remove and add them. The main use case is expiry timers for servers that handle many clients, and which reset the expiry timer for each message received from a client. Whereas normal timers perform poorly as the number of clients grows, the cost of ticket timers is constant, no matter the number of clients. You must set the ticket delay using zloop_set_ticket_delay before creating a ticket. Returns a handle to the timer that you should use in zloop_ticket_reset and zloop_ticket_delete. """ return c_void_p(lib.zloop_ticket(self._as_parameter_, handler, arg)) def ticket_reset(self, handle): """ Reset a ticket timer, which moves it to the end of the ticket list and resets its execution time. This is a very fast operation. """ return lib.zloop_ticket_reset(self._as_parameter_, handle) def ticket_delete(self, handle): """ Delete a ticket timer. We do not actually delete the ticket here, as other code may still refer to the ticket. We mark as deleted, and remove later and safely. """ return lib.zloop_ticket_delete(self._as_parameter_, handle) def set_ticket_delay(self, ticket_delay): """ Set the ticket delay, which applies to all tickets. If you lower the delay and there are already tickets created, the results are undefined. """ return lib.zloop_set_ticket_delay(self._as_parameter_, ticket_delay) def set_max_timers(self, max_timers): """ Set hard limit on number of timers allowed. Setting more than a small number of timers (10-100) can have a dramatic impact on the performance of the reactor. For high-volume cases, use ticket timers. If the hard limit is reached, the reactor stops creating new timers and logs an error. """ return lib.zloop_set_max_timers(self._as_parameter_, max_timers) def set_verbose(self, verbose): """ Set verbose tracing of reactor on/off. The default verbose setting is off (false). """ return lib.zloop_set_verbose(self._as_parameter_, verbose) def set_nonstop(self, nonstop): """ By default the reactor stops if the process receives a SIGINT or SIGTERM signal. This makes it impossible to shut-down message based architectures like zactors. This method lets you switch off break handling. The default nonstop setting is off (false). """ return lib.zloop_set_nonstop(self._as_parameter_, nonstop) def start(self): """ Start the reactor. Takes control of the thread and returns when the 0MQ context is terminated or the process is interrupted, or any event handler returns -1. Event handlers may register new sockets and timers, and cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. """ return lib.zloop_start(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zloop_test(verbose) # zmsg lib.zmsg_new.restype = zmsg_p lib.zmsg_new.argtypes = [] lib.zmsg_destroy.restype = None lib.zmsg_destroy.argtypes = [POINTER(zmsg_p)] lib.zmsg_recv.restype = zmsg_p lib.zmsg_recv.argtypes = [c_void_p] lib.zmsg_load.restype = zmsg_p lib.zmsg_load.argtypes = [FILE_p] lib.zmsg_decode.restype = zmsg_p lib.zmsg_decode.argtypes = [zframe_p] lib.zmsg_new_signal.restype = zmsg_p lib.zmsg_new_signal.argtypes = [c_ubyte] lib.zmsg_send.restype = c_int lib.zmsg_send.argtypes = [POINTER(zmsg_p), c_void_p] lib.zmsg_sendm.restype = c_int lib.zmsg_sendm.argtypes = [POINTER(zmsg_p), c_void_p] lib.zmsg_size.restype = c_size_t lib.zmsg_size.argtypes = [zmsg_p] lib.zmsg_content_size.restype = c_size_t lib.zmsg_content_size.argtypes = [zmsg_p] lib.zmsg_routing_id.restype = c_int lib.zmsg_routing_id.argtypes = [zmsg_p] lib.zmsg_set_routing_id.restype = None lib.zmsg_set_routing_id.argtypes = [zmsg_p, c_int] lib.zmsg_prepend.restype = c_int lib.zmsg_prepend.argtypes = [zmsg_p, POINTER(zframe_p)] lib.zmsg_append.restype = c_int lib.zmsg_append.argtypes = [zmsg_p, POINTER(zframe_p)] lib.zmsg_pop.restype = zframe_p lib.zmsg_pop.argtypes = [zmsg_p] lib.zmsg_pushmem.restype = c_int lib.zmsg_pushmem.argtypes = [zmsg_p, c_void_p, c_size_t] lib.zmsg_addmem.restype = c_int lib.zmsg_addmem.argtypes = [zmsg_p, c_void_p, c_size_t] lib.zmsg_pushstr.restype = c_int lib.zmsg_pushstr.argtypes = [zmsg_p, c_char_p] lib.zmsg_addstr.restype = c_int lib.zmsg_addstr.argtypes = [zmsg_p, c_char_p] lib.zmsg_pushstrf.restype = c_int lib.zmsg_pushstrf.argtypes = [zmsg_p, c_char_p] lib.zmsg_addstrf.restype = c_int lib.zmsg_addstrf.argtypes = [zmsg_p, c_char_p] lib.zmsg_popstr.restype = POINTER(c_char) lib.zmsg_popstr.argtypes = [zmsg_p] lib.zmsg_addmsg.restype = c_int lib.zmsg_addmsg.argtypes = [zmsg_p, POINTER(zmsg_p)] lib.zmsg_popmsg.restype = zmsg_p lib.zmsg_popmsg.argtypes = [zmsg_p] lib.zmsg_remove.restype = None lib.zmsg_remove.argtypes = [zmsg_p, zframe_p] lib.zmsg_first.restype = zframe_p lib.zmsg_first.argtypes = [zmsg_p] lib.zmsg_next.restype = zframe_p lib.zmsg_next.argtypes = [zmsg_p] lib.zmsg_last.restype = zframe_p lib.zmsg_last.argtypes = [zmsg_p] lib.zmsg_save.restype = c_int lib.zmsg_save.argtypes = [zmsg_p, FILE_p] lib.zmsg_encode.restype = zframe_p lib.zmsg_encode.argtypes = [zmsg_p] lib.zmsg_dup.restype = zmsg_p lib.zmsg_dup.argtypes = [zmsg_p] lib.zmsg_print.restype = None lib.zmsg_print.argtypes = [zmsg_p] lib.zmsg_eq.restype = c_bool lib.zmsg_eq.argtypes = [zmsg_p, zmsg_p] lib.zmsg_signal.restype = c_int lib.zmsg_signal.argtypes = [zmsg_p] lib.zmsg_is.restype = c_bool lib.zmsg_is.argtypes = [c_void_p] lib.zmsg_test.restype = None lib.zmsg_test.argtypes = [c_bool] class Zmsg(object): """ working with multipart messages """ allow_destruct = False def __init__(self, *args): """ Create a new empty message object """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zmsg_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zmsg_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.zmsg_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a message object and all frames it contains """ if self.allow_destruct: lib.zmsg_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() @staticmethod def recv(source): """ Receive message from socket, returns zmsg_t object or NULL if the recv was interrupted. Does a blocking recv. If you want to not block then use the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input before receiving. """ return Zmsg(lib.zmsg_recv(source), True) @staticmethod def load(file): """ Load/append an open file into new message, return the message. Returns NULL if the message could not be loaded. """ return Zmsg(lib.zmsg_load(coerce_py_file(file)), True) @staticmethod def decode(frame): """ Decodes a serialized message frame created by zmsg_encode () and returns a new zmsg_t object. Returns NULL if the frame was badly formatted or there was insufficient memory to work. """ return Zmsg(lib.zmsg_decode(frame), True) @staticmethod def new_signal(status): """ Generate a signal message encoding the given status. A signal is a short message carrying a 1-byte success/failure code (by convention, 0 means OK). Signals are encoded to be distinguishable from "normal" messages. """ return Zmsg(lib.zmsg_new_signal(status), True) @staticmethod def send(self_p, dest): """ Send message to destination socket, and destroy the message after sending it successfully. If the message has no frames, sends nothing but destroys the message anyhow. Nullifies the caller's reference to the message (as it is a destructor). """ return lib.zmsg_send(byref(zmsg_p.from_param(self_p)), dest) @staticmethod def sendm(self_p, dest): """ Send message to destination socket as part of a multipart sequence, and destroy the message after sending it successfully. Note that after a zmsg_sendm, you must call zmsg_send or another method that sends a final message part. If the message has no frames, sends nothing but destroys the message anyhow. Nullifies the caller's reference to the message (as it is a destructor). """ return lib.zmsg_sendm(byref(zmsg_p.from_param(self_p)), dest) def size(self): """ Return size of message, i.e. number of frames (0 or more). """ return lib.zmsg_size(self._as_parameter_) def content_size(self): """ Return total size of all frames in message. """ return lib.zmsg_content_size(self._as_parameter_) def routing_id(self): """ Return message routing ID, if the message came from a ZMQ_SERVER socket. Else returns zero. """ return lib.zmsg_routing_id(self._as_parameter_) def set_routing_id(self, routing_id): """ Set routing ID on message. This is used if/when the message is sent to a ZMQ_SERVER socket. """ return lib.zmsg_set_routing_id(self._as_parameter_, routing_id) def prepend(self, frame_p): """ Push frame to the front of the message, i.e. before all other frames. Message takes ownership of frame, will destroy it when message is sent. Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not nullify the caller's frame reference. """ return lib.zmsg_prepend(self._as_parameter_, byref(zframe_p.from_param(frame_p))) def append(self, frame_p): """ Add frame to the end of the message, i.e. after all other frames. Message takes ownership of frame, will destroy it when message is sent. Returns 0 on success. Deprecates zmsg_add, which did not nullify the caller's frame reference. """ return lib.zmsg_append(self._as_parameter_, byref(zframe_p.from_param(frame_p))) def pop(self): """ Remove first frame from message, if any. Returns frame, or NULL. """ return Zframe(lib.zmsg_pop(self._as_parameter_), True) def pushmem(self, data, size): """ Push block of memory to front of message, as a new frame. Returns 0 on success, -1 on error. """ return lib.zmsg_pushmem(self._as_parameter_, data, size) def addmem(self, data, size): """ Add block of memory to the end of the message, as a new frame. Returns 0 on success, -1 on error. """ return lib.zmsg_addmem(self._as_parameter_, data, size) def pushstr(self, string): """ Push string as new frame to front of message. Returns 0 on success, -1 on error. """ return lib.zmsg_pushstr(self._as_parameter_, string) def addstr(self, string): """ Push string as new frame to end of message. Returns 0 on success, -1 on error. """ return lib.zmsg_addstr(self._as_parameter_, string) def pushstrf(self, format, *args): """ Push formatted string as new frame to front of message. Returns 0 on success, -1 on error. """ return lib.zmsg_pushstrf(self._as_parameter_, format, *args) def addstrf(self, format, *args): """ Push formatted string as new frame to end of message. Returns 0 on success, -1 on error. """ return lib.zmsg_addstrf(self._as_parameter_, format, *args) def popstr(self): """ Pop frame off front of message, return as fresh string. If there were no more frames in the message, returns NULL. """ return return_fresh_string(lib.zmsg_popstr(self._as_parameter_)) def addmsg(self, msg_p): """ Push encoded message as a new frame. Message takes ownership of submessage, so the original is destroyed in this call. Returns 0 on success, -1 on error. """ return lib.zmsg_addmsg(self._as_parameter_, byref(zmsg_p.from_param(msg_p))) def popmsg(self): """ Remove first submessage from message, if any. Returns zmsg_t, or NULL if decoding was not successful. """ return Zmsg(lib.zmsg_popmsg(self._as_parameter_), True) def remove(self, frame): """ Remove specified frame from list, if present. Does not destroy frame. """ return lib.zmsg_remove(self._as_parameter_, frame) def first(self): """ Set cursor to first frame in message. Returns frame, or NULL, if the message is empty. Use this to navigate the frames as a list. """ return Zframe(lib.zmsg_first(self._as_parameter_), False) def next(self): """ Return the next frame. If there are no more frames, returns NULL. To move to the first frame call zmsg_first(). Advances the cursor. """ return Zframe(lib.zmsg_next(self._as_parameter_), False) def last(self): """ Return the last frame. If there are no frames, returns NULL. """ return Zframe(lib.zmsg_last(self._as_parameter_), False) def save(self, file): """ Save message to an open file, return 0 if OK, else -1. The message is saved as a series of frames, each with length and data. Note that the file is NOT guaranteed to be portable between operating systems, not versions of CZMQ. The file format is at present undocumented and liable to arbitrary change. """ return lib.zmsg_save(self._as_parameter_, coerce_py_file(file)) def encode(self): """ Serialize multipart message to a single message frame. Use this method to send structured messages across transports that do not support multipart data. Allocates and returns a new frame containing the serialized message. To decode a serialized message frame, use zmsg_decode (). """ return Zframe(lib.zmsg_encode(self._as_parameter_), True) def dup(self): """ Create copy of message, as new message object. Returns a fresh zmsg_t object. If message is null, or memory was exhausted, returns null. """ return Zmsg(lib.zmsg_dup(self._as_parameter_), True) def print(self): """ Send message to zsys log sink (may be stdout, or system facility as configured by zsys_set_logstream). """ return lib.zmsg_print(self._as_parameter_) def eq(self, other): """ Return true if the two messages have the same number of frames and each frame in the first message is identical to the corresponding frame in the other message. As with zframe_eq, return false if either message is NULL. """ return lib.zmsg_eq(self._as_parameter_, other) def signal(self): """ Return signal value, 0 or greater, if message is a signal, -1 if not. """ return lib.zmsg_signal(self._as_parameter_) @staticmethod def is_(self): """ Probe the supplied object, and report if it looks like a zmsg_t. """ return lib.zmsg_is(self) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zmsg_test(verbose) # zpoller lib.zpoller_new.restype = zpoller_p lib.zpoller_new.argtypes = [c_void_p] lib.zpoller_destroy.restype = None lib.zpoller_destroy.argtypes = [POINTER(zpoller_p)] lib.zpoller_add.restype = c_int lib.zpoller_add.argtypes = [zpoller_p, c_void_p] lib.zpoller_remove.restype = c_int lib.zpoller_remove.argtypes = [zpoller_p, c_void_p] lib.zpoller_set_nonstop.restype = None lib.zpoller_set_nonstop.argtypes = [zpoller_p, c_bool] lib.zpoller_wait.restype = c_void_p lib.zpoller_wait.argtypes = [zpoller_p, c_int] lib.zpoller_expired.restype = c_bool lib.zpoller_expired.argtypes = [zpoller_p] lib.zpoller_terminated.restype = c_bool lib.zpoller_terminated.argtypes = [zpoller_p] lib.zpoller_test.restype = None lib.zpoller_test.argtypes = [c_bool] class Zpoller(object): """ event-driven reactor """ allow_destruct = False def __init__(self, *args): """ Create new poller, specifying zero or more readers. The list of readers ends in a NULL. Each reader can be a zsock_t instance, a zactor_t instance, a libzmq socket (void *), or a file handle. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zpoller_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zpoller_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) >= 1) self._as_parameter_ = lib.zpoller_new(args[0], *args[1:]) # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a poller """ if self.allow_destruct: lib.zpoller_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def add(self, reader): """ Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. """ return lib.zpoller_add(self._as_parameter_, reader) def remove(self, reader): """ Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader must have been passed during construction, or in an zpoller_add () call. """ return lib.zpoller_remove(self._as_parameter_, reader) def set_nonstop(self, nonstop): """ By default the poller stops if the process receives a SIGINT or SIGTERM signal. This makes it impossible to shut-down message based architectures like zactors. This method lets you switch off break handling. The default nonstop setting is off (false). """ return lib.zpoller_set_nonstop(self._as_parameter_, nonstop) def wait(self, timeout): """ Poll the registered readers for I/O, return first reader that has input. The reader will be a libzmq void * socket, or a zsock_t or zactor_t instance as specified in zpoller_new/zpoller_add. The timeout should be zero or greater, or -1 to wait indefinitely. Socket priority is defined by their order in the poll list. If you need a balanced poll, use the low level zmq_poll method directly. If the poll call was interrupted (SIGINT), or the ZMQ context was destroyed, or the timeout expired, returns NULL. You can test the actual exit condition by calling zpoller_expired () and zpoller_terminated (). The timeout is in msec. """ return c_void_p(lib.zpoller_wait(self._as_parameter_, timeout)) def expired(self): """ Return true if the last zpoller_wait () call ended because the timeout expired, without any error. """ return lib.zpoller_expired(self._as_parameter_) def terminated(self): """ Return true if the last zpoller_wait () call ended because the process was interrupted, or the parent context was destroyed. """ return lib.zpoller_terminated(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zpoller_test(verbose) # zproc lib.zproc_new.restype = zproc_p lib.zproc_new.argtypes = [] lib.zproc_destroy.restype = None lib.zproc_destroy.argtypes = [POINTER(zproc_p)] lib.zproc_set_args.restype = None lib.zproc_set_args.argtypes = [zproc_p, zlistx_p] lib.zproc_set_env.restype = None lib.zproc_set_env.argtypes = [zproc_p, zhashx_p] lib.zproc_set_stdin.restype = None lib.zproc_set_stdin.argtypes = [zproc_p, c_void_p] lib.zproc_set_stdout.restype = None lib.zproc_set_stdout.argtypes = [zproc_p, c_void_p] lib.zproc_set_stderr.restype = None lib.zproc_set_stderr.argtypes = [zproc_p, c_void_p] lib.zproc_stdin.restype = c_void_p lib.zproc_stdin.argtypes = [zproc_p] lib.zproc_stdout.restype = c_void_p lib.zproc_stdout.argtypes = [zproc_p] lib.zproc_stderr.restype = c_void_p lib.zproc_stderr.argtypes = [zproc_p] lib.zproc_run.restype = c_int lib.zproc_run.argtypes = [zproc_p] lib.zproc_returncode.restype = c_int lib.zproc_returncode.argtypes = [zproc_p] lib.zproc_pid.restype = c_int lib.zproc_pid.argtypes = [zproc_p] lib.zproc_running.restype = c_bool lib.zproc_running.argtypes = [zproc_p] lib.zproc_wait.restype = c_int lib.zproc_wait.argtypes = [zproc_p, c_bool] lib.zproc_actor.restype = c_void_p lib.zproc_actor.argtypes = [zproc_p] lib.zproc_kill.restype = None lib.zproc_kill.argtypes = [zproc_p, c_int] lib.zproc_set_verbose.restype = None lib.zproc_set_verbose.argtypes = [zproc_p, c_bool] lib.zproc_czmq_version.restype = c_int lib.zproc_czmq_version.argtypes = [] lib.zproc_interrupted.restype = c_bool lib.zproc_interrupted.argtypes = [] lib.zproc_has_curve.restype = c_bool lib.zproc_has_curve.argtypes = [] lib.zproc_hostname.restype = POINTER(c_char) lib.zproc_hostname.argtypes = [] lib.zproc_daemonize.restype = None lib.zproc_daemonize.argtypes = [c_char_p] lib.zproc_run_as.restype = None lib.zproc_run_as.argtypes = [c_char_p, c_char_p, c_char_p] lib.zproc_set_io_threads.restype = None lib.zproc_set_io_threads.argtypes = [c_size_t] lib.zproc_set_max_sockets.restype = None lib.zproc_set_max_sockets.argtypes = [c_size_t] lib.zproc_set_biface.restype = None lib.zproc_set_biface.argtypes = [c_char_p] lib.zproc_biface.restype = c_char_p lib.zproc_biface.argtypes = [] lib.zproc_set_log_ident.restype = None lib.zproc_set_log_ident.argtypes = [c_char_p] lib.zproc_set_log_sender.restype = None lib.zproc_set_log_sender.argtypes = [c_char_p] lib.zproc_set_log_system.restype = None lib.zproc_set_log_system.argtypes = [c_bool] lib.zproc_log_error.restype = None lib.zproc_log_error.argtypes = [c_char_p] lib.zproc_log_warning.restype = None lib.zproc_log_warning.argtypes = [c_char_p] lib.zproc_log_notice.restype = None lib.zproc_log_notice.argtypes = [c_char_p] lib.zproc_log_info.restype = None lib.zproc_log_info.argtypes = [c_char_p] lib.zproc_log_debug.restype = None lib.zproc_log_debug.argtypes = [c_char_p] lib.zproc_test.restype = None lib.zproc_test.argtypes = [c_bool] class Zproc(object): """ process configuration and status """ allow_destruct = False def __init__(self, *args): """ Create a new zproc. NOTE: On Windows and with libzmq3 and libzmq2 this function returns NULL. Code needs to be ported there. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zproc_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zproc_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.zproc_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy zproc, wait until process ends. """ if self.allow_destruct: lib.zproc_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def set_args(self, args): """ Setup the command line arguments, the first item must be an (absolute) filename to run. """ return lib.zproc_set_args(self._as_parameter_, args) def set_env(self, args): """ Setup the environment variables for the process. """ return lib.zproc_set_env(self._as_parameter_, args) def set_stdin(self, socket): """ Connects process stdin with a readable ('>', connect) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The writable one is then accessbile via zproc_stdin method. """ return lib.zproc_set_stdin(self._as_parameter_, socket) def set_stdout(self, socket): """ Connects process stdout with a writable ('@', bind) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The readable one is then accessbile via zproc_stdout method. """ return lib.zproc_set_stdout(self._as_parameter_, socket) def set_stderr(self, socket): """ Connects process stderr with a writable ('@', bind) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The readable one is then accessbile via zproc_stderr method. """ return lib.zproc_set_stderr(self._as_parameter_, socket) def stdin(self): """ Return subprocess stdin writable socket. NULL for not initialized or external sockets. """ return c_void_p(lib.zproc_stdin(self._as_parameter_)) def stdout(self): """ Return subprocess stdout readable socket. NULL for not initialized or external sockets. """ return c_void_p(lib.zproc_stdout(self._as_parameter_)) def stderr(self): """ Return subprocess stderr readable socket. NULL for not initialized or external sockets. """ return c_void_p(lib.zproc_stderr(self._as_parameter_)) def run(self): """ Starts the process. """ return lib.zproc_run(self._as_parameter_) def returncode(self): """ process exit code """ return lib.zproc_returncode(self._as_parameter_) def pid(self): """ PID of the process """ return lib.zproc_pid(self._as_parameter_) def running(self): """ return true if process is running, false if not yet started or finished """ return lib.zproc_running(self._as_parameter_) def wait(self, hang): """ wait or poll process status, return return code """ return lib.zproc_wait(self._as_parameter_, hang) def actor(self): """ return internal actor, usefull for the polling if process died """ return c_void_p(lib.zproc_actor(self._as_parameter_)) def kill(self, signal): """ send a signal to the subprocess """ return lib.zproc_kill(self._as_parameter_, signal) def set_verbose(self, verbose): """ set verbose mode """ return lib.zproc_set_verbose(self._as_parameter_, verbose) @staticmethod def czmq_version(): """ Returns CZMQ version as a single 6-digit integer encoding the major version (x 10000), the minor version (x 100) and the patch. """ return lib.zproc_czmq_version() @staticmethod def interrupted(): """ Returns true if the process received a SIGINT or SIGTERM signal. It is good practice to use this method to exit any infinite loop processing messages. """ return lib.zproc_interrupted() @staticmethod def has_curve(): """ Returns true if the underlying libzmq supports CURVE security. """ return lib.zproc_has_curve() @staticmethod def hostname(): """ Return current host name, for use in public tcp:// endpoints. If the host name is not resolvable, returns NULL. """ return return_fresh_string(lib.zproc_hostname()) @staticmethod def daemonize(workdir): """ Move the current process into the background. The precise effect depends on the operating system. On POSIX boxes, moves to a specified working directory (if specified), closes all file handles, reopens stdin, stdout, and stderr to the null device, and sets the process to ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there was an error. """ return lib.zproc_daemonize(workdir) @staticmethod def run_as(lockfile, group, user): """ Drop the process ID into the lockfile, with exclusive lock, and switch the process to the specified group and/or user. Any of the arguments may be null, indicating a no-op. Returns 0 on success, -1 on failure. Note if you combine this with zsys_daemonize, run after, not before that method, or the lockfile will hold the wrong process ID. """ return lib.zproc_run_as(lockfile, group, user) @staticmethod def set_io_threads(io_threads): """ Configure the number of I/O threads that ZeroMQ will use. A good rule of thumb is one thread per gigabit of traffic in or out. The default is 1, sufficient for most applications. If the environment variable ZSYS_IO_THREADS is defined, that provides the default. Note that this method is valid only before any socket is created. """ return lib.zproc_set_io_threads(io_threads) @staticmethod def set_max_sockets(max_sockets): """ Configure the number of sockets that ZeroMQ will allow. The default is 1024. The actual limit depends on the system, and you can query it by using zsys_socket_limit (). A value of zero means "maximum". Note that this method is valid only before any socket is created. """ return lib.zproc_set_max_sockets(max_sockets) @staticmethod def set_biface(value): """ Set network interface name to use for broadcasts, particularly zbeacon. This lets the interface be configured for test environments where required. For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is the default when there is no specified interface. If the environment variable ZSYS_INTERFACE is set, use that as the default interface name. Setting the interface to "*" means "use all available interfaces". """ return lib.zproc_set_biface(value) @staticmethod def biface(): """ Return network interface to use for broadcasts, or "" if none was set. """ return lib.zproc_biface() @staticmethod def set_log_ident(value): """ Set log identity, which is a string that prefixes all log messages sent by this process. The log identity defaults to the environment variable ZSYS_LOGIDENT, if that is set. """ return lib.zproc_set_log_ident(value) @staticmethod def set_log_sender(endpoint): """ Sends log output to a PUB socket bound to the specified endpoint. To collect such log output, create a SUB socket, subscribe to the traffic you care about, and connect to the endpoint. Log traffic is sent as a single string frame, in the same format as when sent to stdout. The log system supports a single sender; multiple calls to this method will bind the same sender to multiple endpoints. To disable the sender, call this method with a null argument. """ return lib.zproc_set_log_sender(endpoint) @staticmethod def set_log_system(logsystem): """ Enable or disable logging to the system facility (syslog on POSIX boxes, event log on Windows). By default this is disabled. """ return lib.zproc_set_log_system(logsystem) @staticmethod def log_error(format, *args): """ Log error condition - highest priority """ return lib.zproc_log_error(format, *args) @staticmethod def log_warning(format, *args): """ Log warning condition - high priority """ return lib.zproc_log_warning(format, *args) @staticmethod def log_notice(format, *args): """ Log normal, but significant, condition - normal priority """ return lib.zproc_log_notice(format, *args) @staticmethod def log_info(format, *args): """ Log informational message - low priority """ return lib.zproc_log_info(format, *args) @staticmethod def log_debug(format, *args): """ Log debug-level message - lowest priority """ return lib.zproc_log_debug(format, *args) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zproc_test(verbose) # zsock lib.zsock_new.restype = zsock_p lib.zsock_new.argtypes = [c_int] lib.zsock_destroy.restype = None lib.zsock_destroy.argtypes = [POINTER(zsock_p)] lib.zsock_new_pub.restype = zsock_p lib.zsock_new_pub.argtypes = [c_char_p] lib.zsock_new_sub.restype = zsock_p lib.zsock_new_sub.argtypes = [c_char_p, c_char_p] lib.zsock_new_req.restype = zsock_p lib.zsock_new_req.argtypes = [c_char_p] lib.zsock_new_rep.restype = zsock_p lib.zsock_new_rep.argtypes = [c_char_p] lib.zsock_new_dealer.restype = zsock_p lib.zsock_new_dealer.argtypes = [c_char_p] lib.zsock_new_router.restype = zsock_p lib.zsock_new_router.argtypes = [c_char_p] lib.zsock_new_push.restype = zsock_p lib.zsock_new_push.argtypes = [c_char_p] lib.zsock_new_pull.restype = zsock_p lib.zsock_new_pull.argtypes = [c_char_p] lib.zsock_new_xpub.restype = zsock_p lib.zsock_new_xpub.argtypes = [c_char_p] lib.zsock_new_xsub.restype = zsock_p lib.zsock_new_xsub.argtypes = [c_char_p] lib.zsock_new_pair.restype = zsock_p lib.zsock_new_pair.argtypes = [c_char_p] lib.zsock_new_stream.restype = zsock_p lib.zsock_new_stream.argtypes = [c_char_p] lib.zsock_new_server.restype = zsock_p lib.zsock_new_server.argtypes = [c_char_p] lib.zsock_new_client.restype = zsock_p lib.zsock_new_client.argtypes = [c_char_p] lib.zsock_new_radio.restype = zsock_p lib.zsock_new_radio.argtypes = [c_char_p] lib.zsock_new_dish.restype = zsock_p lib.zsock_new_dish.argtypes = [c_char_p] lib.zsock_new_gather.restype = zsock_p lib.zsock_new_gather.argtypes = [c_char_p] lib.zsock_new_scatter.restype = zsock_p lib.zsock_new_scatter.argtypes = [c_char_p] lib.zsock_bind.restype = c_int lib.zsock_bind.argtypes = [zsock_p, c_char_p] lib.zsock_endpoint.restype = c_char_p lib.zsock_endpoint.argtypes = [zsock_p] lib.zsock_unbind.restype = c_int lib.zsock_unbind.argtypes = [zsock_p, c_char_p] lib.zsock_connect.restype = c_int lib.zsock_connect.argtypes = [zsock_p, c_char_p] lib.zsock_disconnect.restype = c_int lib.zsock_disconnect.argtypes = [zsock_p, c_char_p] lib.zsock_attach.restype = c_int lib.zsock_attach.argtypes = [zsock_p, c_char_p, c_bool] lib.zsock_type_str.restype = c_char_p lib.zsock_type_str.argtypes = [zsock_p] lib.zsock_send.restype = c_int lib.zsock_send.argtypes = [zsock_p, c_char_p] lib.zsock_vsend.restype = c_int lib.zsock_vsend.argtypes = [zsock_p, c_char_p, va_list_p] lib.zsock_recv.restype = c_int lib.zsock_recv.argtypes = [zsock_p, c_char_p] lib.zsock_vrecv.restype = c_int lib.zsock_vrecv.argtypes = [zsock_p, c_char_p, va_list_p] lib.zsock_bsend.restype = c_int lib.zsock_bsend.argtypes = [zsock_p, c_char_p] lib.zsock_brecv.restype = c_int lib.zsock_brecv.argtypes = [zsock_p, c_char_p] lib.zsock_routing_id.restype = c_int lib.zsock_routing_id.argtypes = [zsock_p] lib.zsock_set_routing_id.restype = None lib.zsock_set_routing_id.argtypes = [zsock_p, c_int] lib.zsock_set_unbounded.restype = None lib.zsock_set_unbounded.argtypes = [zsock_p] lib.zsock_signal.restype = c_int lib.zsock_signal.argtypes = [zsock_p, c_ubyte] lib.zsock_wait.restype = c_int lib.zsock_wait.argtypes = [zsock_p] lib.zsock_flush.restype = None lib.zsock_flush.argtypes = [zsock_p] lib.zsock_join.restype = c_int lib.zsock_join.argtypes = [zsock_p, c_char_p] lib.zsock_leave.restype = c_int lib.zsock_leave.argtypes = [zsock_p, c_char_p] lib.zsock_is.restype = c_bool lib.zsock_is.argtypes = [c_void_p] lib.zsock_resolve.restype = c_void_p lib.zsock_resolve.argtypes = [c_void_p] lib.zsock_heartbeat_ivl.restype = c_int lib.zsock_heartbeat_ivl.argtypes = [zsock_p] lib.zsock_set_heartbeat_ivl.restype = None lib.zsock_set_heartbeat_ivl.argtypes = [zsock_p, c_int] lib.zsock_heartbeat_ttl.restype = c_int lib.zsock_heartbeat_ttl.argtypes = [zsock_p] lib.zsock_set_heartbeat_ttl.restype = None lib.zsock_set_heartbeat_ttl.argtypes = [zsock_p, c_int] lib.zsock_heartbeat_timeout.restype = c_int lib.zsock_heartbeat_timeout.argtypes = [zsock_p] lib.zsock_set_heartbeat_timeout.restype = None lib.zsock_set_heartbeat_timeout.argtypes = [zsock_p, c_int] lib.zsock_use_fd.restype = c_int lib.zsock_use_fd.argtypes = [zsock_p] lib.zsock_set_use_fd.restype = None lib.zsock_set_use_fd.argtypes = [zsock_p, c_int] lib.zsock_set_xpub_manual.restype = None lib.zsock_set_xpub_manual.argtypes = [zsock_p, c_int] lib.zsock_set_xpub_welcome_msg.restype = None lib.zsock_set_xpub_welcome_msg.argtypes = [zsock_p, c_char_p] lib.zsock_set_stream_notify.restype = None lib.zsock_set_stream_notify.argtypes = [zsock_p, c_int] lib.zsock_invert_matching.restype = c_int lib.zsock_invert_matching.argtypes = [zsock_p] lib.zsock_set_invert_matching.restype = None lib.zsock_set_invert_matching.argtypes = [zsock_p, c_int] lib.zsock_set_xpub_verboser.restype = None lib.zsock_set_xpub_verboser.argtypes = [zsock_p, c_int] lib.zsock_connect_timeout.restype = c_int lib.zsock_connect_timeout.argtypes = [zsock_p] lib.zsock_set_connect_timeout.restype = None lib.zsock_set_connect_timeout.argtypes = [zsock_p, c_int] lib.zsock_tcp_maxrt.restype = c_int lib.zsock_tcp_maxrt.argtypes = [zsock_p] lib.zsock_set_tcp_maxrt.restype = None lib.zsock_set_tcp_maxrt.argtypes = [zsock_p, c_int] lib.zsock_thread_safe.restype = c_int lib.zsock_thread_safe.argtypes = [zsock_p] lib.zsock_multicast_maxtpdu.restype = c_int lib.zsock_multicast_maxtpdu.argtypes = [zsock_p] lib.zsock_set_multicast_maxtpdu.restype = None lib.zsock_set_multicast_maxtpdu.argtypes = [zsock_p, c_int] lib.zsock_vmci_buffer_size.restype = c_int lib.zsock_vmci_buffer_size.argtypes = [zsock_p] lib.zsock_set_vmci_buffer_size.restype = None lib.zsock_set_vmci_buffer_size.argtypes = [zsock_p, c_int] lib.zsock_vmci_buffer_min_size.restype = c_int lib.zsock_vmci_buffer_min_size.argtypes = [zsock_p] lib.zsock_set_vmci_buffer_min_size.restype = None lib.zsock_set_vmci_buffer_min_size.argtypes = [zsock_p, c_int] lib.zsock_vmci_buffer_max_size.restype = c_int lib.zsock_vmci_buffer_max_size.argtypes = [zsock_p] lib.zsock_set_vmci_buffer_max_size.restype = None lib.zsock_set_vmci_buffer_max_size.argtypes = [zsock_p, c_int] lib.zsock_vmci_connect_timeout.restype = c_int lib.zsock_vmci_connect_timeout.argtypes = [zsock_p] lib.zsock_set_vmci_connect_timeout.restype = None lib.zsock_set_vmci_connect_timeout.argtypes = [zsock_p, c_int] lib.zsock_tos.restype = c_int lib.zsock_tos.argtypes = [zsock_p] lib.zsock_set_tos.restype = None lib.zsock_set_tos.argtypes = [zsock_p, c_int] lib.zsock_set_router_handover.restype = None lib.zsock_set_router_handover.argtypes = [zsock_p, c_int] lib.zsock_set_connect_rid.restype = None lib.zsock_set_connect_rid.argtypes = [zsock_p, c_char_p] lib.zsock_set_connect_rid_bin.restype = None lib.zsock_set_connect_rid_bin.argtypes = [zsock_p, c_void_p] lib.zsock_handshake_ivl.restype = c_int lib.zsock_handshake_ivl.argtypes = [zsock_p] lib.zsock_set_handshake_ivl.restype = None lib.zsock_set_handshake_ivl.argtypes = [zsock_p, c_int] lib.zsock_socks_proxy.restype = POINTER(c_char) lib.zsock_socks_proxy.argtypes = [zsock_p] lib.zsock_set_socks_proxy.restype = None lib.zsock_set_socks_proxy.argtypes = [zsock_p, c_char_p] lib.zsock_set_xpub_nodrop.restype = None lib.zsock_set_xpub_nodrop.argtypes = [zsock_p, c_int] lib.zsock_set_router_mandatory.restype = None lib.zsock_set_router_mandatory.argtypes = [zsock_p, c_int] lib.zsock_set_probe_router.restype = None lib.zsock_set_probe_router.argtypes = [zsock_p, c_int] lib.zsock_set_req_relaxed.restype = None lib.zsock_set_req_relaxed.argtypes = [zsock_p, c_int] lib.zsock_set_req_correlate.restype = None lib.zsock_set_req_correlate.argtypes = [zsock_p, c_int] lib.zsock_set_conflate.restype = None lib.zsock_set_conflate.argtypes = [zsock_p, c_int] lib.zsock_zap_domain.restype = POINTER(c_char) lib.zsock_zap_domain.argtypes = [zsock_p] lib.zsock_set_zap_domain.restype = None lib.zsock_set_zap_domain.argtypes = [zsock_p, c_char_p] lib.zsock_mechanism.restype = c_int lib.zsock_mechanism.argtypes = [zsock_p] lib.zsock_plain_server.restype = c_int lib.zsock_plain_server.argtypes = [zsock_p] lib.zsock_set_plain_server.restype = None lib.zsock_set_plain_server.argtypes = [zsock_p, c_int] lib.zsock_plain_username.restype = POINTER(c_char) lib.zsock_plain_username.argtypes = [zsock_p] lib.zsock_set_plain_username.restype = None lib.zsock_set_plain_username.argtypes = [zsock_p, c_char_p] lib.zsock_plain_password.restype = POINTER(c_char) lib.zsock_plain_password.argtypes = [zsock_p] lib.zsock_set_plain_password.restype = None lib.zsock_set_plain_password.argtypes = [zsock_p, c_char_p] lib.zsock_curve_server.restype = c_int lib.zsock_curve_server.argtypes = [zsock_p] lib.zsock_set_curve_server.restype = None lib.zsock_set_curve_server.argtypes = [zsock_p, c_int] lib.zsock_curve_publickey.restype = POINTER(c_char) lib.zsock_curve_publickey.argtypes = [zsock_p] lib.zsock_set_curve_publickey.restype = None lib.zsock_set_curve_publickey.argtypes = [zsock_p, c_char_p] lib.zsock_set_curve_publickey_bin.restype = None lib.zsock_set_curve_publickey_bin.argtypes = [zsock_p, c_void_p] lib.zsock_curve_secretkey.restype = POINTER(c_char) lib.zsock_curve_secretkey.argtypes = [zsock_p] lib.zsock_set_curve_secretkey.restype = None lib.zsock_set_curve_secretkey.argtypes = [zsock_p, c_char_p] lib.zsock_set_curve_secretkey_bin.restype = None lib.zsock_set_curve_secretkey_bin.argtypes = [zsock_p, c_void_p] lib.zsock_curve_serverkey.restype = POINTER(c_char) lib.zsock_curve_serverkey.argtypes = [zsock_p] lib.zsock_set_curve_serverkey.restype = None lib.zsock_set_curve_serverkey.argtypes = [zsock_p, c_char_p] lib.zsock_set_curve_serverkey_bin.restype = None lib.zsock_set_curve_serverkey_bin.argtypes = [zsock_p, c_void_p] lib.zsock_gssapi_server.restype = c_int lib.zsock_gssapi_server.argtypes = [zsock_p] lib.zsock_set_gssapi_server.restype = None lib.zsock_set_gssapi_server.argtypes = [zsock_p, c_int] lib.zsock_gssapi_plaintext.restype = c_int lib.zsock_gssapi_plaintext.argtypes = [zsock_p] lib.zsock_set_gssapi_plaintext.restype = None lib.zsock_set_gssapi_plaintext.argtypes = [zsock_p, c_int] lib.zsock_gssapi_principal.restype = POINTER(c_char) lib.zsock_gssapi_principal.argtypes = [zsock_p] lib.zsock_set_gssapi_principal.restype = None lib.zsock_set_gssapi_principal.argtypes = [zsock_p, c_char_p] lib.zsock_gssapi_service_principal.restype = POINTER(c_char) lib.zsock_gssapi_service_principal.argtypes = [zsock_p] lib.zsock_set_gssapi_service_principal.restype = None lib.zsock_set_gssapi_service_principal.argtypes = [zsock_p, c_char_p] lib.zsock_ipv6.restype = c_int lib.zsock_ipv6.argtypes = [zsock_p] lib.zsock_set_ipv6.restype = None lib.zsock_set_ipv6.argtypes = [zsock_p, c_int] lib.zsock_immediate.restype = c_int lib.zsock_immediate.argtypes = [zsock_p] lib.zsock_set_immediate.restype = None lib.zsock_set_immediate.argtypes = [zsock_p, c_int] lib.zsock_sndhwm.restype = c_int lib.zsock_sndhwm.argtypes = [zsock_p] lib.zsock_set_sndhwm.restype = None lib.zsock_set_sndhwm.argtypes = [zsock_p, c_int] lib.zsock_rcvhwm.restype = c_int lib.zsock_rcvhwm.argtypes = [zsock_p] lib.zsock_set_rcvhwm.restype = None lib.zsock_set_rcvhwm.argtypes = [zsock_p, c_int] lib.zsock_maxmsgsize.restype = c_int lib.zsock_maxmsgsize.argtypes = [zsock_p] lib.zsock_set_maxmsgsize.restype = None lib.zsock_set_maxmsgsize.argtypes = [zsock_p, c_int] lib.zsock_multicast_hops.restype = c_int lib.zsock_multicast_hops.argtypes = [zsock_p] lib.zsock_set_multicast_hops.restype = None lib.zsock_set_multicast_hops.argtypes = [zsock_p, c_int] lib.zsock_set_xpub_verbose.restype = None lib.zsock_set_xpub_verbose.argtypes = [zsock_p, c_int] lib.zsock_tcp_keepalive.restype = c_int lib.zsock_tcp_keepalive.argtypes = [zsock_p] lib.zsock_set_tcp_keepalive.restype = None lib.zsock_set_tcp_keepalive.argtypes = [zsock_p, c_int] lib.zsock_tcp_keepalive_idle.restype = c_int lib.zsock_tcp_keepalive_idle.argtypes = [zsock_p] lib.zsock_set_tcp_keepalive_idle.restype = None lib.zsock_set_tcp_keepalive_idle.argtypes = [zsock_p, c_int] lib.zsock_tcp_keepalive_cnt.restype = c_int lib.zsock_tcp_keepalive_cnt.argtypes = [zsock_p] lib.zsock_set_tcp_keepalive_cnt.restype = None lib.zsock_set_tcp_keepalive_cnt.argtypes = [zsock_p, c_int] lib.zsock_tcp_keepalive_intvl.restype = c_int lib.zsock_tcp_keepalive_intvl.argtypes = [zsock_p] lib.zsock_set_tcp_keepalive_intvl.restype = None lib.zsock_set_tcp_keepalive_intvl.argtypes = [zsock_p, c_int] lib.zsock_tcp_accept_filter.restype = POINTER(c_char) lib.zsock_tcp_accept_filter.argtypes = [zsock_p] lib.zsock_set_tcp_accept_filter.restype = None lib.zsock_set_tcp_accept_filter.argtypes = [zsock_p, c_char_p] lib.zsock_last_endpoint.restype = POINTER(c_char) lib.zsock_last_endpoint.argtypes = [zsock_p] lib.zsock_set_router_raw.restype = None lib.zsock_set_router_raw.argtypes = [zsock_p, c_int] lib.zsock_ipv4only.restype = c_int lib.zsock_ipv4only.argtypes = [zsock_p] lib.zsock_set_ipv4only.restype = None lib.zsock_set_ipv4only.argtypes = [zsock_p, c_int] lib.zsock_set_delay_attach_on_connect.restype = None lib.zsock_set_delay_attach_on_connect.argtypes = [zsock_p, c_int] lib.zsock_hwm.restype = c_int lib.zsock_hwm.argtypes = [zsock_p] lib.zsock_set_hwm.restype = None lib.zsock_set_hwm.argtypes = [zsock_p, c_int] lib.zsock_swap.restype = c_int lib.zsock_swap.argtypes = [zsock_p] lib.zsock_set_swap.restype = None lib.zsock_set_swap.argtypes = [zsock_p, c_int] lib.zsock_affinity.restype = c_int lib.zsock_affinity.argtypes = [zsock_p] lib.zsock_set_affinity.restype = None lib.zsock_set_affinity.argtypes = [zsock_p, c_int] lib.zsock_identity.restype = POINTER(c_char) lib.zsock_identity.argtypes = [zsock_p] lib.zsock_set_identity.restype = None lib.zsock_set_identity.argtypes = [zsock_p, c_char_p] lib.zsock_rate.restype = c_int lib.zsock_rate.argtypes = [zsock_p] lib.zsock_set_rate.restype = None lib.zsock_set_rate.argtypes = [zsock_p, c_int] lib.zsock_recovery_ivl.restype = c_int lib.zsock_recovery_ivl.argtypes = [zsock_p] lib.zsock_set_recovery_ivl.restype = None lib.zsock_set_recovery_ivl.argtypes = [zsock_p, c_int] lib.zsock_recovery_ivl_msec.restype = c_int lib.zsock_recovery_ivl_msec.argtypes = [zsock_p] lib.zsock_set_recovery_ivl_msec.restype = None lib.zsock_set_recovery_ivl_msec.argtypes = [zsock_p, c_int] lib.zsock_mcast_loop.restype = c_int lib.zsock_mcast_loop.argtypes = [zsock_p] lib.zsock_set_mcast_loop.restype = None lib.zsock_set_mcast_loop.argtypes = [zsock_p, c_int] lib.zsock_rcvtimeo.restype = c_int lib.zsock_rcvtimeo.argtypes = [zsock_p] lib.zsock_set_rcvtimeo.restype = None lib.zsock_set_rcvtimeo.argtypes = [zsock_p, c_int] lib.zsock_sndtimeo.restype = c_int lib.zsock_sndtimeo.argtypes = [zsock_p] lib.zsock_set_sndtimeo.restype = None lib.zsock_set_sndtimeo.argtypes = [zsock_p, c_int] lib.zsock_sndbuf.restype = c_int lib.zsock_sndbuf.argtypes = [zsock_p] lib.zsock_set_sndbuf.restype = None lib.zsock_set_sndbuf.argtypes = [zsock_p, c_int] lib.zsock_rcvbuf.restype = c_int lib.zsock_rcvbuf.argtypes = [zsock_p] lib.zsock_set_rcvbuf.restype = None lib.zsock_set_rcvbuf.argtypes = [zsock_p, c_int] lib.zsock_linger.restype = c_int lib.zsock_linger.argtypes = [zsock_p] lib.zsock_set_linger.restype = None lib.zsock_set_linger.argtypes = [zsock_p, c_int] lib.zsock_reconnect_ivl.restype = c_int lib.zsock_reconnect_ivl.argtypes = [zsock_p] lib.zsock_set_reconnect_ivl.restype = None lib.zsock_set_reconnect_ivl.argtypes = [zsock_p, c_int] lib.zsock_reconnect_ivl_max.restype = c_int lib.zsock_reconnect_ivl_max.argtypes = [zsock_p] lib.zsock_set_reconnect_ivl_max.restype = None lib.zsock_set_reconnect_ivl_max.argtypes = [zsock_p, c_int] lib.zsock_backlog.restype = c_int lib.zsock_backlog.argtypes = [zsock_p] lib.zsock_set_backlog.restype = None lib.zsock_set_backlog.argtypes = [zsock_p, c_int] lib.zsock_set_subscribe.restype = None lib.zsock_set_subscribe.argtypes = [zsock_p, c_char_p] lib.zsock_set_unsubscribe.restype = None lib.zsock_set_unsubscribe.argtypes = [zsock_p, c_char_p] lib.zsock_type.restype = c_int lib.zsock_type.argtypes = [zsock_p] lib.zsock_rcvmore.restype = c_int lib.zsock_rcvmore.argtypes = [zsock_p] lib.zsock_fd.restype = socket_p lib.zsock_fd.argtypes = [zsock_p] lib.zsock_events.restype = c_int lib.zsock_events.argtypes = [zsock_p] lib.zsock_test.restype = None lib.zsock_test.argtypes = [c_bool] class Zsock(object): """ high-level socket API that hides libzmq contexts and sockets """ allow_destruct = False def __init__(self, *args): """ Create a new socket. Returns the new socket, or NULL if the new socket could not be created. Note that the symbol zsock_new (and other constructors/destructors for zsock) are redirected to the *_checked variant, enabling intelligent socket leak detection. This can have performance implications if you use a LOT of sockets. To turn off this redirection behaviour, define ZSOCK_NOCHECK. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zsock_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zsock_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 1) self._as_parameter_ = lib.zsock_new(args[0]) # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy the socket. You must use this for any socket created via the zsock_new method. """ if self.allow_destruct: lib.zsock_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() @staticmethod def new_pub(endpoint): """ Create a PUB socket. Default action is bind. """ return Zsock(lib.zsock_new_pub(endpoint), True) @staticmethod def new_sub(endpoint, subscribe): """ Create a SUB socket, and optionally subscribe to some prefix string. Default action is connect. """ return Zsock(lib.zsock_new_sub(endpoint, subscribe), True) @staticmethod def new_req(endpoint): """ Create a REQ socket. Default action is connect. """ return Zsock(lib.zsock_new_req(endpoint), True) @staticmethod def new_rep(endpoint): """ Create a REP socket. Default action is bind. """ return Zsock(lib.zsock_new_rep(endpoint), True) @staticmethod def new_dealer(endpoint): """ Create a DEALER socket. Default action is connect. """ return Zsock(lib.zsock_new_dealer(endpoint), True) @staticmethod def new_router(endpoint): """ Create a ROUTER socket. Default action is bind. """ return Zsock(lib.zsock_new_router(endpoint), True) @staticmethod def new_push(endpoint): """ Create a PUSH socket. Default action is connect. """ return Zsock(lib.zsock_new_push(endpoint), True) @staticmethod def new_pull(endpoint): """ Create a PULL socket. Default action is bind. """ return Zsock(lib.zsock_new_pull(endpoint), True) @staticmethod def new_xpub(endpoint): """ Create an XPUB socket. Default action is bind. """ return Zsock(lib.zsock_new_xpub(endpoint), True) @staticmethod def new_xsub(endpoint): """ Create an XSUB socket. Default action is connect. """ return Zsock(lib.zsock_new_xsub(endpoint), True) @staticmethod def new_pair(endpoint): """ Create a PAIR socket. Default action is connect. """ return Zsock(lib.zsock_new_pair(endpoint), True) @staticmethod def new_stream(endpoint): """ Create a STREAM socket. Default action is connect. """ return Zsock(lib.zsock_new_stream(endpoint), True) @staticmethod def new_server(endpoint): """ Create a SERVER socket. Default action is bind. """ return Zsock(lib.zsock_new_server(endpoint), True) @staticmethod def new_client(endpoint): """ Create a CLIENT socket. Default action is connect. """ return Zsock(lib.zsock_new_client(endpoint), True) @staticmethod def new_radio(endpoint): """ Create a RADIO socket. Default action is bind. """ return Zsock(lib.zsock_new_radio(endpoint), True) @staticmethod def new_dish(endpoint): """ Create a DISH socket. Default action is connect. """ return Zsock(lib.zsock_new_dish(endpoint), True) @staticmethod def new_gather(endpoint): """ Create a GATHER socket. Default action is bind. """ return Zsock(lib.zsock_new_gather(endpoint), True) @staticmethod def new_scatter(endpoint): """ Create a SCATTER socket. Default action is connect. """ return Zsock(lib.zsock_new_scatter(endpoint), True) def bind(self, format, *args): """ Bind a socket to a formatted endpoint. For tcp:// endpoints, supports ephemeral ports, if you specify the port number as "*". By default zsock uses the IANA designated range from C000 (49152) to FFFF (65535). To override this range, follow the "*" with "[first-last]". Either or both first and last may be empty. To bind to a random port within the range, use "!" in place of "*". Examples: tcp://127.0.0.1:* bind to first free port from C000 up tcp://127.0.0.1:! bind to random port from C000 to FFFF tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 tcp://127.0.0.1:![55000-55999] bind to random port from 55000 to 55999 On success, returns the actual port number used, for tcp:// endpoints, and 0 for other transports. On failure, returns -1. Note that when using ephemeral ports, a port may be reused by different services without clients being aware. Protocols that run on ephemeral ports should take this into account. """ return lib.zsock_bind(self._as_parameter_, format, *args) def endpoint(self): """ Returns last bound endpoint, if any. """ return lib.zsock_endpoint(self._as_parameter_) def unbind(self, format, *args): """ Unbind a socket from a formatted endpoint. Returns 0 if OK, -1 if the endpoint was invalid or the function isn't supported. """ return lib.zsock_unbind(self._as_parameter_, format, *args) def connect(self, format, *args): """ Connect a socket to a formatted endpoint Returns 0 if OK, -1 if the endpoint was invalid. """ return lib.zsock_connect(self._as_parameter_, format, *args) def disconnect(self, format, *args): """ Disconnect a socket from a formatted endpoint Returns 0 if OK, -1 if the endpoint was invalid or the function isn't supported. """ return lib.zsock_disconnect(self._as_parameter_, format, *args) def attach(self, endpoints, serverish): """ Attach a socket to zero or more endpoints. If endpoints is not null, parses as list of ZeroMQ endpoints, separated by commas, and prefixed by '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all endpoints were valid, or -1 if there was a syntax error. If the endpoint does not start with '@' or '>', the serverish argument defines whether it is used to bind (serverish = true) or connect (serverish = false). """ return lib.zsock_attach(self._as_parameter_, endpoints, serverish) def type_str(self): """ Returns socket type as printable constant string. """ return lib.zsock_type_str(self._as_parameter_) def send(self, picture, *args): """ Send a 'picture' message to the socket (or actor). The picture is a string that defines the type of each frame. This makes it easy to send a complex multiframe message in one call. The picture can contain any of these characters, each corresponding to one or two arguments: i = int (signed) 1 = uint8_t 2 = uint16_t 4 = uint32_t 8 = uint64_t s = char * b = byte *, size_t (2 arguments) c = zchunk_t * f = zframe_t * h = zhashx_t * U = zuuid_t * p = void * (sends the pointer value, only meaningful over inproc) m = zmsg_t * (sends all frames in the zmsg) z = sends zero-sized frame (0 arguments) u = uint (deprecated) Note that s, b, c, and f are encoded the same way and the choice is offered as a convenience to the sender, which may or may not already have data in a zchunk or zframe. Does not change or take ownership of any arguments. Returns 0 if successful, -1 if sending failed for any reason. """ return lib.zsock_send(self._as_parameter_, picture, *args) def vsend(self, picture, argptr): """ Send a 'picture' message to the socket (or actor). This is a va_list version of zsock_send (), so please consult its documentation for the details. """ return lib.zsock_vsend(self._as_parameter_, picture, argptr) def recv(self, picture, *args): """ Receive a 'picture' message to the socket (or actor). See zsock_send for the format and meaning of the picture. Returns the picture elements into a series of pointers as provided by the caller: i = int * (stores signed integer) 4 = uint32_t * (stores 32-bit unsigned integer) 8 = uint64_t * (stores 64-bit unsigned integer) s = char ** (allocates new string) b = byte **, size_t * (2 arguments) (allocates memory) c = zchunk_t ** (creates zchunk) f = zframe_t ** (creates zframe) U = zuuid_t * (creates a zuuid with the data) h = zhashx_t ** (creates zhashx) p = void ** (stores pointer) m = zmsg_t ** (creates a zmsg with the remaing frames) z = null, asserts empty frame (0 arguments) u = uint * (stores unsigned integer, deprecated) Note that zsock_recv creates the returned objects, and the caller must destroy them when finished with them. The supplied pointers do not need to be initialized. Returns 0 if successful, or -1 if it failed to recv a message, in which case the pointers are not modified. When message frames are truncated (a short message), sets return values to zero/null. If an argument pointer is NULL, does not store any value (skips it). An 'n' picture matches an empty frame; if the message does not match, the method will return -1. """ return lib.zsock_recv(self._as_parameter_, picture, *args) def vrecv(self, picture, argptr): """ Receive a 'picture' message from the socket (or actor). This is a va_list version of zsock_recv (), so please consult its documentation for the details. """ return lib.zsock_vrecv(self._as_parameter_, picture, argptr) def bsend(self, picture, *args): """ Send a binary encoded 'picture' message to the socket (or actor). This method is similar to zsock_send, except the arguments are encoded in a binary format that is compatible with zproto, and is designed to reduce memory allocations. The pattern argument is a string that defines the type of each argument. Supports these argument types: pattern C type zproto type: 1 uint8_t type = "number" size = "1" 2 uint16_t type = "number" size = "2" 4 uint32_t type = "number" size = "3" 8 uint64_t type = "number" size = "4" s char *, 0-255 chars type = "string" S char *, 0-2^32-1 chars type = "longstr" c zchunk_t * type = "chunk" f zframe_t * type = "frame" u zuuid_t * type = "uuid" m zmsg_t * type = "msg" p void *, sends pointer value, only over inproc Does not change or take ownership of any arguments. Returns 0 if successful, -1 if sending failed for any reason. """ return lib.zsock_bsend(self._as_parameter_, picture, *args) def brecv(self, picture, *args): """ Receive a binary encoded 'picture' message from the socket (or actor). This method is similar to zsock_recv, except the arguments are encoded in a binary format that is compatible with zproto, and is designed to reduce memory allocations. The pattern argument is a string that defines the type of each argument. See zsock_bsend for the supported argument types. All arguments must be pointers; this call sets them to point to values held on a per-socket basis. For types 1, 2, 4 and 8 the caller must allocate the memory itself before calling zsock_brecv. For types S, the caller must free the value once finished with it, as zsock_brecv will allocate the buffer. For type s, the caller must not free the value as it is stored in a local cache for performance purposes. For types c, f, u and m the caller must call the appropriate destructor depending on the object as zsock_brecv will create new objects. For type p the caller must coordinate with the sender, as it is just a pointer value being passed. """ return lib.zsock_brecv(self._as_parameter_, picture, *args) def routing_id(self): """ Return socket routing ID if any. This returns 0 if the socket is not of type ZMQ_SERVER or if no request was already received on it. """ return lib.zsock_routing_id(self._as_parameter_) def set_routing_id(self, routing_id): """ Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. This will be used when sending messages on the socket via the zsock API. """ return lib.zsock_set_routing_id(self._as_parameter_, routing_id) def set_unbounded(self): """ Set socket to use unbounded pipes (HWM=0); use this in cases when you are totally certain the message volume can fit in memory. This method works across all versions of ZeroMQ. Takes a polymorphic socket reference. """ return lib.zsock_set_unbounded(self._as_parameter_) def signal(self, status): """ Send a signal over a socket. A signal is a short message carrying a success/failure code (by convention, 0 means OK). Signals are encoded to be distinguishable from "normal" messages. Accepts a zsock_t or a zactor_t argument, and returns 0 if successful, -1 if the signal could not be sent. Takes a polymorphic socket reference. """ return lib.zsock_signal(self._as_parameter_, status) def wait(self): """ Wait on a signal. Use this to coordinate between threads, over pipe pairs. Blocks until the signal is received. Returns -1 on error, 0 or greater on success. Accepts a zsock_t or a zactor_t as argument. Takes a polymorphic socket reference. """ return lib.zsock_wait(self._as_parameter_) def flush(self): """ If there is a partial message still waiting on the socket, remove and discard it. This is useful when reading partial messages, to get specific message types. """ return lib.zsock_flush(self._as_parameter_) def join(self, group): """ Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. Returns 0 if OK, -1 if failed. """ return lib.zsock_join(self._as_parameter_, group) def leave(self, group): """ Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. Returns 0 if OK, -1 if failed. """ return lib.zsock_leave(self._as_parameter_, group) @staticmethod def is_(self): """ Probe the supplied object, and report if it looks like a zsock_t. Takes a polymorphic socket reference. """ return lib.zsock_is(self) @staticmethod def resolve(self): """ Probe the supplied reference. If it looks like a zsock_t instance, return the underlying libzmq socket handle; else if it looks like a file descriptor, return NULL; else if it looks like a libzmq socket handle, return the supplied value. Takes a polymorphic socket reference. """ return c_void_p(lib.zsock_resolve(self)) def heartbeat_ivl(self): """ Get socket option `heartbeat_ivl`. Available from libzmq 4.2.0. """ return lib.zsock_heartbeat_ivl(self._as_parameter_) def set_heartbeat_ivl(self, heartbeat_ivl): """ Set socket option `heartbeat_ivl`. Available from libzmq 4.2.0. """ return lib.zsock_set_heartbeat_ivl(self._as_parameter_, heartbeat_ivl) def heartbeat_ttl(self): """ Get socket option `heartbeat_ttl`. Available from libzmq 4.2.0. """ return lib.zsock_heartbeat_ttl(self._as_parameter_) def set_heartbeat_ttl(self, heartbeat_ttl): """ Set socket option `heartbeat_ttl`. Available from libzmq 4.2.0. """ return lib.zsock_set_heartbeat_ttl(self._as_parameter_, heartbeat_ttl) def heartbeat_timeout(self): """ Get socket option `heartbeat_timeout`. Available from libzmq 4.2.0. """ return lib.zsock_heartbeat_timeout(self._as_parameter_) def set_heartbeat_timeout(self, heartbeat_timeout): """ Set socket option `heartbeat_timeout`. Available from libzmq 4.2.0. """ return lib.zsock_set_heartbeat_timeout(self._as_parameter_, heartbeat_timeout) def use_fd(self): """ Get socket option `use_fd`. Available from libzmq 4.2.0. """ return lib.zsock_use_fd(self._as_parameter_) def set_use_fd(self, use_fd): """ Set socket option `use_fd`. Available from libzmq 4.2.0. """ return lib.zsock_set_use_fd(self._as_parameter_, use_fd) def set_xpub_manual(self, xpub_manual): """ Set socket option `xpub_manual`. Available from libzmq 4.2.0. """ return lib.zsock_set_xpub_manual(self._as_parameter_, xpub_manual) def set_xpub_welcome_msg(self, xpub_welcome_msg): """ Set socket option `xpub_welcome_msg`. Available from libzmq 4.2.0. """ return lib.zsock_set_xpub_welcome_msg(self._as_parameter_, xpub_welcome_msg) def set_stream_notify(self, stream_notify): """ Set socket option `stream_notify`. Available from libzmq 4.2.0. """ return lib.zsock_set_stream_notify(self._as_parameter_, stream_notify) def invert_matching(self): """ Get socket option `invert_matching`. Available from libzmq 4.2.0. """ return lib.zsock_invert_matching(self._as_parameter_) def set_invert_matching(self, invert_matching): """ Set socket option `invert_matching`. Available from libzmq 4.2.0. """ return lib.zsock_set_invert_matching(self._as_parameter_, invert_matching) def set_xpub_verboser(self, xpub_verboser): """ Set socket option `xpub_verboser`. Available from libzmq 4.2.0. """ return lib.zsock_set_xpub_verboser(self._as_parameter_, xpub_verboser) def connect_timeout(self): """ Get socket option `connect_timeout`. Available from libzmq 4.2.0. """ return lib.zsock_connect_timeout(self._as_parameter_) def set_connect_timeout(self, connect_timeout): """ Set socket option `connect_timeout`. Available from libzmq 4.2.0. """ return lib.zsock_set_connect_timeout(self._as_parameter_, connect_timeout) def tcp_maxrt(self): """ Get socket option `tcp_maxrt`. Available from libzmq 4.2.0. """ return lib.zsock_tcp_maxrt(self._as_parameter_) def set_tcp_maxrt(self, tcp_maxrt): """ Set socket option `tcp_maxrt`. Available from libzmq 4.2.0. """ return lib.zsock_set_tcp_maxrt(self._as_parameter_, tcp_maxrt) def thread_safe(self): """ Get socket option `thread_safe`. Available from libzmq 4.2.0. """ return lib.zsock_thread_safe(self._as_parameter_) def multicast_maxtpdu(self): """ Get socket option `multicast_maxtpdu`. Available from libzmq 4.2.0. """ return lib.zsock_multicast_maxtpdu(self._as_parameter_) def set_multicast_maxtpdu(self, multicast_maxtpdu): """ Set socket option `multicast_maxtpdu`. Available from libzmq 4.2.0. """ return lib.zsock_set_multicast_maxtpdu(self._as_parameter_, multicast_maxtpdu) def vmci_buffer_size(self): """ Get socket option `vmci_buffer_size`. Available from libzmq 4.2.0. """ return lib.zsock_vmci_buffer_size(self._as_parameter_) def set_vmci_buffer_size(self, vmci_buffer_size): """ Set socket option `vmci_buffer_size`. Available from libzmq 4.2.0. """ return lib.zsock_set_vmci_buffer_size(self._as_parameter_, vmci_buffer_size) def vmci_buffer_min_size(self): """ Get socket option `vmci_buffer_min_size`. Available from libzmq 4.2.0. """ return lib.zsock_vmci_buffer_min_size(self._as_parameter_) def set_vmci_buffer_min_size(self, vmci_buffer_min_size): """ Set socket option `vmci_buffer_min_size`. Available from libzmq 4.2.0. """ return lib.zsock_set_vmci_buffer_min_size(self._as_parameter_, vmci_buffer_min_size) def vmci_buffer_max_size(self): """ Get socket option `vmci_buffer_max_size`. Available from libzmq 4.2.0. """ return lib.zsock_vmci_buffer_max_size(self._as_parameter_) def set_vmci_buffer_max_size(self, vmci_buffer_max_size): """ Set socket option `vmci_buffer_max_size`. Available from libzmq 4.2.0. """ return lib.zsock_set_vmci_buffer_max_size(self._as_parameter_, vmci_buffer_max_size) def vmci_connect_timeout(self): """ Get socket option `vmci_connect_timeout`. Available from libzmq 4.2.0. """ return lib.zsock_vmci_connect_timeout(self._as_parameter_) def set_vmci_connect_timeout(self, vmci_connect_timeout): """ Set socket option `vmci_connect_timeout`. Available from libzmq 4.2.0. """ return lib.zsock_set_vmci_connect_timeout(self._as_parameter_, vmci_connect_timeout) def tos(self): """ Get socket option `tos`. Available from libzmq 4.1.0. """ return lib.zsock_tos(self._as_parameter_) def set_tos(self, tos): """ Set socket option `tos`. Available from libzmq 4.1.0. """ return lib.zsock_set_tos(self._as_parameter_, tos) def set_router_handover(self, router_handover): """ Set socket option `router_handover`. Available from libzmq 4.1.0. """ return lib.zsock_set_router_handover(self._as_parameter_, router_handover) def set_connect_rid(self, connect_rid): """ Set socket option `connect_rid`. Available from libzmq 4.1.0. """ return lib.zsock_set_connect_rid(self._as_parameter_, connect_rid) def set_connect_rid_bin(self, connect_rid): """ Set socket option `connect_rid` from 32-octet binary Available from libzmq 4.1.0. """ return lib.zsock_set_connect_rid_bin(self._as_parameter_, connect_rid) def handshake_ivl(self): """ Get socket option `handshake_ivl`. Available from libzmq 4.1.0. """ return lib.zsock_handshake_ivl(self._as_parameter_) def set_handshake_ivl(self, handshake_ivl): """ Set socket option `handshake_ivl`. Available from libzmq 4.1.0. """ return lib.zsock_set_handshake_ivl(self._as_parameter_, handshake_ivl) def socks_proxy(self): """ Get socket option `socks_proxy`. Available from libzmq 4.1.0. """ return return_fresh_string(lib.zsock_socks_proxy(self._as_parameter_)) def set_socks_proxy(self, socks_proxy): """ Set socket option `socks_proxy`. Available from libzmq 4.1.0. """ return lib.zsock_set_socks_proxy(self._as_parameter_, socks_proxy) def set_xpub_nodrop(self, xpub_nodrop): """ Set socket option `xpub_nodrop`. Available from libzmq 4.1.0. """ return lib.zsock_set_xpub_nodrop(self._as_parameter_, xpub_nodrop) def set_router_mandatory(self, router_mandatory): """ Set socket option `router_mandatory`. Available from libzmq 4.0.0. """ return lib.zsock_set_router_mandatory(self._as_parameter_, router_mandatory) def set_probe_router(self, probe_router): """ Set socket option `probe_router`. Available from libzmq 4.0.0. """ return lib.zsock_set_probe_router(self._as_parameter_, probe_router) def set_req_relaxed(self, req_relaxed): """ Set socket option `req_relaxed`. Available from libzmq 4.0.0. """ return lib.zsock_set_req_relaxed(self._as_parameter_, req_relaxed) def set_req_correlate(self, req_correlate): """ Set socket option `req_correlate`. Available from libzmq 4.0.0. """ return lib.zsock_set_req_correlate(self._as_parameter_, req_correlate) def set_conflate(self, conflate): """ Set socket option `conflate`. Available from libzmq 4.0.0. """ return lib.zsock_set_conflate(self._as_parameter_, conflate) def zap_domain(self): """ Get socket option `zap_domain`. Available from libzmq 4.0.0. """ return return_fresh_string(lib.zsock_zap_domain(self._as_parameter_)) def set_zap_domain(self, zap_domain): """ Set socket option `zap_domain`. Available from libzmq 4.0.0. """ return lib.zsock_set_zap_domain(self._as_parameter_, zap_domain) def mechanism(self): """ Get socket option `mechanism`. Available from libzmq 4.0.0. """ return lib.zsock_mechanism(self._as_parameter_) def plain_server(self): """ Get socket option `plain_server`. Available from libzmq 4.0.0. """ return lib.zsock_plain_server(self._as_parameter_) def set_plain_server(self, plain_server): """ Set socket option `plain_server`. Available from libzmq 4.0.0. """ return lib.zsock_set_plain_server(self._as_parameter_, plain_server) def plain_username(self): """ Get socket option `plain_username`. Available from libzmq 4.0.0. """ return return_fresh_string(lib.zsock_plain_username(self._as_parameter_)) def set_plain_username(self, plain_username): """ Set socket option `plain_username`. Available from libzmq 4.0.0. """ return lib.zsock_set_plain_username(self._as_parameter_, plain_username) def plain_password(self): """ Get socket option `plain_password`. Available from libzmq 4.0.0. """ return return_fresh_string(lib.zsock_plain_password(self._as_parameter_)) def set_plain_password(self, plain_password): """ Set socket option `plain_password`. Available from libzmq 4.0.0. """ return lib.zsock_set_plain_password(self._as_parameter_, plain_password) def curve_server(self): """ Get socket option `curve_server`. Available from libzmq 4.0.0. """ return lib.zsock_curve_server(self._as_parameter_) def set_curve_server(self, curve_server): """ Set socket option `curve_server`. Available from libzmq 4.0.0. """ return lib.zsock_set_curve_server(self._as_parameter_, curve_server) def curve_publickey(self): """ Get socket option `curve_publickey`. Available from libzmq 4.0.0. """ return return_fresh_string(lib.zsock_curve_publickey(self._as_parameter_)) def set_curve_publickey(self, curve_publickey): """ Set socket option `curve_publickey`. Available from libzmq 4.0.0. """ return lib.zsock_set_curve_publickey(self._as_parameter_, curve_publickey) def set_curve_publickey_bin(self, curve_publickey): """ Set socket option `curve_publickey` from 32-octet binary Available from libzmq 4.0.0. """ return lib.zsock_set_curve_publickey_bin(self._as_parameter_, curve_publickey) def curve_secretkey(self): """ Get socket option `curve_secretkey`. Available from libzmq 4.0.0. """ return return_fresh_string(lib.zsock_curve_secretkey(self._as_parameter_)) def set_curve_secretkey(self, curve_secretkey): """ Set socket option `curve_secretkey`. Available from libzmq 4.0.0. """ return lib.zsock_set_curve_secretkey(self._as_parameter_, curve_secretkey) def set_curve_secretkey_bin(self, curve_secretkey): """ Set socket option `curve_secretkey` from 32-octet binary Available from libzmq 4.0.0. """ return lib.zsock_set_curve_secretkey_bin(self._as_parameter_, curve_secretkey) def curve_serverkey(self): """ Get socket option `curve_serverkey`. Available from libzmq 4.0.0. """ return return_fresh_string(lib.zsock_curve_serverkey(self._as_parameter_)) def set_curve_serverkey(self, curve_serverkey): """ Set socket option `curve_serverkey`. Available from libzmq 4.0.0. """ return lib.zsock_set_curve_serverkey(self._as_parameter_, curve_serverkey) def set_curve_serverkey_bin(self, curve_serverkey): """ Set socket option `curve_serverkey` from 32-octet binary Available from libzmq 4.0.0. """ return lib.zsock_set_curve_serverkey_bin(self._as_parameter_, curve_serverkey) def gssapi_server(self): """ Get socket option `gssapi_server`. Available from libzmq 4.0.0. """ return lib.zsock_gssapi_server(self._as_parameter_) def set_gssapi_server(self, gssapi_server): """ Set socket option `gssapi_server`. Available from libzmq 4.0.0. """ return lib.zsock_set_gssapi_server(self._as_parameter_, gssapi_server) def gssapi_plaintext(self): """ Get socket option `gssapi_plaintext`. Available from libzmq 4.0.0. """ return lib.zsock_gssapi_plaintext(self._as_parameter_) def set_gssapi_plaintext(self, gssapi_plaintext): """ Set socket option `gssapi_plaintext`. Available from libzmq 4.0.0. """ return lib.zsock_set_gssapi_plaintext(self._as_parameter_, gssapi_plaintext) def gssapi_principal(self): """ Get socket option `gssapi_principal`. Available from libzmq 4.0.0. """ return return_fresh_string(lib.zsock_gssapi_principal(self._as_parameter_)) def set_gssapi_principal(self, gssapi_principal): """ Set socket option `gssapi_principal`. Available from libzmq 4.0.0. """ return lib.zsock_set_gssapi_principal(self._as_parameter_, gssapi_principal) def gssapi_service_principal(self): """ Get socket option `gssapi_service_principal`. Available from libzmq 4.0.0. """ return return_fresh_string(lib.zsock_gssapi_service_principal(self._as_parameter_)) def set_gssapi_service_principal(self, gssapi_service_principal): """ Set socket option `gssapi_service_principal`. Available from libzmq 4.0.0. """ return lib.zsock_set_gssapi_service_principal(self._as_parameter_, gssapi_service_principal) def ipv6(self): """ Get socket option `ipv6`. Available from libzmq 4.0.0. """ return lib.zsock_ipv6(self._as_parameter_) def set_ipv6(self, ipv6): """ Set socket option `ipv6`. Available from libzmq 4.0.0. """ return lib.zsock_set_ipv6(self._as_parameter_, ipv6) def immediate(self): """ Get socket option `immediate`. Available from libzmq 4.0.0. """ return lib.zsock_immediate(self._as_parameter_) def set_immediate(self, immediate): """ Set socket option `immediate`. Available from libzmq 4.0.0. """ return lib.zsock_set_immediate(self._as_parameter_, immediate) def sndhwm(self): """ Get socket option `sndhwm`. Available from libzmq 3.0.0. """ return lib.zsock_sndhwm(self._as_parameter_) def set_sndhwm(self, sndhwm): """ Set socket option `sndhwm`. Available from libzmq 3.0.0. """ return lib.zsock_set_sndhwm(self._as_parameter_, sndhwm) def rcvhwm(self): """ Get socket option `rcvhwm`. Available from libzmq 3.0.0. """ return lib.zsock_rcvhwm(self._as_parameter_) def set_rcvhwm(self, rcvhwm): """ Set socket option `rcvhwm`. Available from libzmq 3.0.0. """ return lib.zsock_set_rcvhwm(self._as_parameter_, rcvhwm) def maxmsgsize(self): """ Get socket option `maxmsgsize`. Available from libzmq 3.0.0. """ return lib.zsock_maxmsgsize(self._as_parameter_) def set_maxmsgsize(self, maxmsgsize): """ Set socket option `maxmsgsize`. Available from libzmq 3.0.0. """ return lib.zsock_set_maxmsgsize(self._as_parameter_, maxmsgsize) def multicast_hops(self): """ Get socket option `multicast_hops`. Available from libzmq 3.0.0. """ return lib.zsock_multicast_hops(self._as_parameter_) def set_multicast_hops(self, multicast_hops): """ Set socket option `multicast_hops`. Available from libzmq 3.0.0. """ return lib.zsock_set_multicast_hops(self._as_parameter_, multicast_hops) def set_xpub_verbose(self, xpub_verbose): """ Set socket option `xpub_verbose`. Available from libzmq 3.0.0. """ return lib.zsock_set_xpub_verbose(self._as_parameter_, xpub_verbose) def tcp_keepalive(self): """ Get socket option `tcp_keepalive`. Available from libzmq 3.0.0. """ return lib.zsock_tcp_keepalive(self._as_parameter_) def set_tcp_keepalive(self, tcp_keepalive): """ Set socket option `tcp_keepalive`. Available from libzmq 3.0.0. """ return lib.zsock_set_tcp_keepalive(self._as_parameter_, tcp_keepalive) def tcp_keepalive_idle(self): """ Get socket option `tcp_keepalive_idle`. Available from libzmq 3.0.0. """ return lib.zsock_tcp_keepalive_idle(self._as_parameter_) def set_tcp_keepalive_idle(self, tcp_keepalive_idle): """ Set socket option `tcp_keepalive_idle`. Available from libzmq 3.0.0. """ return lib.zsock_set_tcp_keepalive_idle(self._as_parameter_, tcp_keepalive_idle) def tcp_keepalive_cnt(self): """ Get socket option `tcp_keepalive_cnt`. Available from libzmq 3.0.0. """ return lib.zsock_tcp_keepalive_cnt(self._as_parameter_) def set_tcp_keepalive_cnt(self, tcp_keepalive_cnt): """ Set socket option `tcp_keepalive_cnt`. Available from libzmq 3.0.0. """ return lib.zsock_set_tcp_keepalive_cnt(self._as_parameter_, tcp_keepalive_cnt) def tcp_keepalive_intvl(self): """ Get socket option `tcp_keepalive_intvl`. Available from libzmq 3.0.0. """ return lib.zsock_tcp_keepalive_intvl(self._as_parameter_) def set_tcp_keepalive_intvl(self, tcp_keepalive_intvl): """ Set socket option `tcp_keepalive_intvl`. Available from libzmq 3.0.0. """ return lib.zsock_set_tcp_keepalive_intvl(self._as_parameter_, tcp_keepalive_intvl) def tcp_accept_filter(self): """ Get socket option `tcp_accept_filter`. Available from libzmq 3.0.0. """ return return_fresh_string(lib.zsock_tcp_accept_filter(self._as_parameter_)) def set_tcp_accept_filter(self, tcp_accept_filter): """ Set socket option `tcp_accept_filter`. Available from libzmq 3.0.0. """ return lib.zsock_set_tcp_accept_filter(self._as_parameter_, tcp_accept_filter) def last_endpoint(self): """ Get socket option `last_endpoint`. Available from libzmq 3.0.0. """ return return_fresh_string(lib.zsock_last_endpoint(self._as_parameter_)) def set_router_raw(self, router_raw): """ Set socket option `router_raw`. Available from libzmq 3.0.0. """ return lib.zsock_set_router_raw(self._as_parameter_, router_raw) def ipv4only(self): """ Get socket option `ipv4only`. Available from libzmq 3.0.0. """ return lib.zsock_ipv4only(self._as_parameter_) def set_ipv4only(self, ipv4only): """ Set socket option `ipv4only`. Available from libzmq 3.0.0. """ return lib.zsock_set_ipv4only(self._as_parameter_, ipv4only) def set_delay_attach_on_connect(self, delay_attach_on_connect): """ Set socket option `delay_attach_on_connect`. Available from libzmq 3.0.0. """ return lib.zsock_set_delay_attach_on_connect(self._as_parameter_, delay_attach_on_connect) def hwm(self): """ Get socket option `hwm`. Available from libzmq 2.0.0 to 3.0.0. """ return lib.zsock_hwm(self._as_parameter_) def set_hwm(self, hwm): """ Set socket option `hwm`. Available from libzmq 2.0.0 to 3.0.0. """ return lib.zsock_set_hwm(self._as_parameter_, hwm) def swap(self): """ Get socket option `swap`. Available from libzmq 2.0.0 to 3.0.0. """ return lib.zsock_swap(self._as_parameter_) def set_swap(self, swap): """ Set socket option `swap`. Available from libzmq 2.0.0 to 3.0.0. """ return lib.zsock_set_swap(self._as_parameter_, swap) def affinity(self): """ Get socket option `affinity`. Available from libzmq 2.0.0. """ return lib.zsock_affinity(self._as_parameter_) def set_affinity(self, affinity): """ Set socket option `affinity`. Available from libzmq 2.0.0. """ return lib.zsock_set_affinity(self._as_parameter_, affinity) def identity(self): """ Get socket option `identity`. Available from libzmq 2.0.0. """ return return_fresh_string(lib.zsock_identity(self._as_parameter_)) def set_identity(self, identity): """ Set socket option `identity`. Available from libzmq 2.0.0. """ return lib.zsock_set_identity(self._as_parameter_, identity) def rate(self): """ Get socket option `rate`. Available from libzmq 2.0.0. """ return lib.zsock_rate(self._as_parameter_) def set_rate(self, rate): """ Set socket option `rate`. Available from libzmq 2.0.0. """ return lib.zsock_set_rate(self._as_parameter_, rate) def recovery_ivl(self): """ Get socket option `recovery_ivl`. Available from libzmq 2.0.0. """ return lib.zsock_recovery_ivl(self._as_parameter_) def set_recovery_ivl(self, recovery_ivl): """ Set socket option `recovery_ivl`. Available from libzmq 2.0.0. """ return lib.zsock_set_recovery_ivl(self._as_parameter_, recovery_ivl) def recovery_ivl_msec(self): """ Get socket option `recovery_ivl_msec`. Available from libzmq 2.0.0 to 3.0.0. """ return lib.zsock_recovery_ivl_msec(self._as_parameter_) def set_recovery_ivl_msec(self, recovery_ivl_msec): """ Set socket option `recovery_ivl_msec`. Available from libzmq 2.0.0 to 3.0.0. """ return lib.zsock_set_recovery_ivl_msec(self._as_parameter_, recovery_ivl_msec) def mcast_loop(self): """ Get socket option `mcast_loop`. Available from libzmq 2.0.0 to 3.0.0. """ return lib.zsock_mcast_loop(self._as_parameter_) def set_mcast_loop(self, mcast_loop): """ Set socket option `mcast_loop`. Available from libzmq 2.0.0 to 3.0.0. """ return lib.zsock_set_mcast_loop(self._as_parameter_, mcast_loop) def rcvtimeo(self): """ Get socket option `rcvtimeo`. Available from libzmq 2.2.0. """ return lib.zsock_rcvtimeo(self._as_parameter_) def set_rcvtimeo(self, rcvtimeo): """ Set socket option `rcvtimeo`. Available from libzmq 2.2.0. """ return lib.zsock_set_rcvtimeo(self._as_parameter_, rcvtimeo) def sndtimeo(self): """ Get socket option `sndtimeo`. Available from libzmq 2.2.0. """ return lib.zsock_sndtimeo(self._as_parameter_) def set_sndtimeo(self, sndtimeo): """ Set socket option `sndtimeo`. Available from libzmq 2.2.0. """ return lib.zsock_set_sndtimeo(self._as_parameter_, sndtimeo) def sndbuf(self): """ Get socket option `sndbuf`. Available from libzmq 2.0.0. """ return lib.zsock_sndbuf(self._as_parameter_) def set_sndbuf(self, sndbuf): """ Set socket option `sndbuf`. Available from libzmq 2.0.0. """ return lib.zsock_set_sndbuf(self._as_parameter_, sndbuf) def rcvbuf(self): """ Get socket option `rcvbuf`. Available from libzmq 2.0.0. """ return lib.zsock_rcvbuf(self._as_parameter_) def set_rcvbuf(self, rcvbuf): """ Set socket option `rcvbuf`. Available from libzmq 2.0.0. """ return lib.zsock_set_rcvbuf(self._as_parameter_, rcvbuf) def linger(self): """ Get socket option `linger`. Available from libzmq 2.0.0. """ return lib.zsock_linger(self._as_parameter_) def set_linger(self, linger): """ Set socket option `linger`. Available from libzmq 2.0.0. """ return lib.zsock_set_linger(self._as_parameter_, linger) def reconnect_ivl(self): """ Get socket option `reconnect_ivl`. Available from libzmq 2.0.0. """ return lib.zsock_reconnect_ivl(self._as_parameter_) def set_reconnect_ivl(self, reconnect_ivl): """ Set socket option `reconnect_ivl`. Available from libzmq 2.0.0. """ return lib.zsock_set_reconnect_ivl(self._as_parameter_, reconnect_ivl) def reconnect_ivl_max(self): """ Get socket option `reconnect_ivl_max`. Available from libzmq 2.0.0. """ return lib.zsock_reconnect_ivl_max(self._as_parameter_) def set_reconnect_ivl_max(self, reconnect_ivl_max): """ Set socket option `reconnect_ivl_max`. Available from libzmq 2.0.0. """ return lib.zsock_set_reconnect_ivl_max(self._as_parameter_, reconnect_ivl_max) def backlog(self): """ Get socket option `backlog`. Available from libzmq 2.0.0. """ return lib.zsock_backlog(self._as_parameter_) def set_backlog(self, backlog): """ Set socket option `backlog`. Available from libzmq 2.0.0. """ return lib.zsock_set_backlog(self._as_parameter_, backlog) def set_subscribe(self, subscribe): """ Set socket option `subscribe`. Available from libzmq 2.0.0. """ return lib.zsock_set_subscribe(self._as_parameter_, subscribe) def set_unsubscribe(self, unsubscribe): """ Set socket option `unsubscribe`. Available from libzmq 2.0.0. """ return lib.zsock_set_unsubscribe(self._as_parameter_, unsubscribe) def type(self): """ Get socket option `type`. Available from libzmq 2.0.0. """ return lib.zsock_type(self._as_parameter_) def rcvmore(self): """ Get socket option `rcvmore`. Available from libzmq 2.0.0. """ return lib.zsock_rcvmore(self._as_parameter_) def fd(self): """ Get socket option `fd`. Available from libzmq 2.0.0. """ return lib.zsock_fd(self._as_parameter_) def events(self): """ Get socket option `events`. Available from libzmq 2.0.0. """ return lib.zsock_events(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zsock_test(verbose) # zstr lib.zstr_recv.restype = POINTER(c_char) lib.zstr_recv.argtypes = [c_void_p] lib.zstr_recvx.restype = c_int lib.zstr_recvx.argtypes = [c_void_p, POINTER(c_char_p)] lib.zstr_recv_compress.restype = POINTER(c_char) lib.zstr_recv_compress.argtypes = [c_void_p] lib.zstr_send.restype = c_int lib.zstr_send.argtypes = [c_void_p, c_char_p] lib.zstr_sendm.restype = c_int lib.zstr_sendm.argtypes = [c_void_p, c_char_p] lib.zstr_sendf.restype = c_int lib.zstr_sendf.argtypes = [c_void_p, c_char_p] lib.zstr_sendfm.restype = c_int lib.zstr_sendfm.argtypes = [c_void_p, c_char_p] lib.zstr_sendx.restype = c_int lib.zstr_sendx.argtypes = [c_void_p, c_char_p] lib.zstr_send_compress.restype = c_int lib.zstr_send_compress.argtypes = [c_void_p, c_char_p] lib.zstr_sendm_compress.restype = c_int lib.zstr_sendm_compress.argtypes = [c_void_p, c_char_p] lib.zstr_str.restype = POINTER(c_char) lib.zstr_str.argtypes = [c_void_p] lib.zstr_free.restype = None lib.zstr_free.argtypes = [POINTER(c_char_p)] lib.zstr_test.restype = None lib.zstr_test.argtypes = [c_bool] class Zstr(object): """ sending and receiving strings """ allow_destruct = False def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() @staticmethod def recv(source): """ Receive C string from socket. Caller must free returned string using zstr_free(). Returns NULL if the context is being terminated or the process was interrupted. """ return return_fresh_string(lib.zstr_recv(source)) @staticmethod def recvx(source, string_p, *args): """ Receive a series of strings (until NULL) from multipart data. Each string is allocated and filled with string data; if there are not enough frames, unallocated strings are set to NULL. Returns -1 if the message could not be read, else returns the number of strings filled, zero or more. Free each returned string using zstr_free(). If not enough strings are provided, remaining multipart frames in the message are dropped. """ return lib.zstr_recvx(source, byref(c_char_p.from_param(string_p)), *args) @staticmethod def recv_compress(source): """ De-compress and receive C string from socket, received as a message with two frames: size of the uncompressed string, and the string itself. Caller must free returned string using zstr_free(). Returns NULL if the context is being terminated or the process was interrupted. """ return return_fresh_string(lib.zstr_recv_compress(source)) @staticmethod def send(dest, string): """ Send a C string to a socket, as a frame. The string is sent without trailing null byte; to read this you can use zstr_recv, or a similar method that adds a null terminator on the received string. String may be NULL, which is sent as "". """ return lib.zstr_send(dest, string) @staticmethod def sendm(dest, string): """ Send a C string to a socket, as zstr_send(), with a MORE flag, so that you can send further strings in the same multi-part message. """ return lib.zstr_sendm(dest, string) @staticmethod def sendf(dest, format, *args): """ Send a formatted string to a socket. Note that you should NOT use user-supplied strings in the format (they may contain '%' which will create security holes). """ return lib.zstr_sendf(dest, format, *args) @staticmethod def sendfm(dest, format, *args): """ Send a formatted string to a socket, as for zstr_sendf(), with a MORE flag, so that you can send further strings in the same multi-part message. """ return lib.zstr_sendfm(dest, format, *args) @staticmethod def sendx(dest, string, *args): """ Send a series of strings (until NULL) as multipart data Returns 0 if the strings could be sent OK, or -1 on error. """ return lib.zstr_sendx(dest, string, *args) @staticmethod def send_compress(dest, string): """ Compress and send a C string to a socket, as a message with two frames: size of the uncompressed string, and the string itself. The string is sent without trailing null byte; to read this you can use zstr_recv_compress, or a similar method that de-compresses and adds a null terminator on the received string. """ return lib.zstr_send_compress(dest, string) @staticmethod def sendm_compress(dest, string): """ Compress and send a C string to a socket, as zstr_send_compress(), with a MORE flag, so that you can send further strings in the same multi-part message. """ return lib.zstr_sendm_compress(dest, string) @staticmethod def str(source): """ Accepts a void pointer and returns a fresh character string. If source is null, returns an empty string. """ return return_fresh_string(lib.zstr_str(source)) @staticmethod def free(string_p): """ Free a provided string, and nullify the parent pointer. Safe to call on a null pointer. """ return lib.zstr_free(byref(c_char_p.from_param(string_p))) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zstr_test(verbose) # zsys zsys_handler_fn = CFUNCTYPE(None, c_int) lib.zsys_init.restype = c_void_p lib.zsys_init.argtypes = [] lib.zsys_shutdown.restype = None lib.zsys_shutdown.argtypes = [] lib.zsys_socket.restype = c_void_p lib.zsys_socket.argtypes = [c_int, c_char_p, c_size_t] lib.zsys_close.restype = c_int lib.zsys_close.argtypes = [c_void_p, c_char_p, c_size_t] lib.zsys_sockname.restype = c_char_p lib.zsys_sockname.argtypes = [c_int] lib.zsys_create_pipe.restype = zsock_p lib.zsys_create_pipe.argtypes = [POINTER(zsock_p)] lib.zsys_handler_set.restype = None lib.zsys_handler_set.argtypes = [POINTER(zsys_handler_fn)] lib.zsys_handler_reset.restype = None lib.zsys_handler_reset.argtypes = [] lib.zsys_catch_interrupts.restype = None lib.zsys_catch_interrupts.argtypes = [] lib.zsys_file_exists.restype = c_bool lib.zsys_file_exists.argtypes = [c_char_p] lib.zsys_file_modified.restype = c_int lib.zsys_file_modified.argtypes = [c_char_p] lib.zsys_file_mode.restype = c_int lib.zsys_file_mode.argtypes = [c_char_p] lib.zsys_file_delete.restype = c_int lib.zsys_file_delete.argtypes = [c_char_p] lib.zsys_file_stable.restype = c_bool lib.zsys_file_stable.argtypes = [c_char_p] lib.zsys_dir_create.restype = c_int lib.zsys_dir_create.argtypes = [c_char_p] lib.zsys_dir_delete.restype = c_int lib.zsys_dir_delete.argtypes = [c_char_p] lib.zsys_dir_change.restype = c_int lib.zsys_dir_change.argtypes = [c_char_p] lib.zsys_file_mode_private.restype = None lib.zsys_file_mode_private.argtypes = [] lib.zsys_file_mode_default.restype = None lib.zsys_file_mode_default.argtypes = [] lib.zsys_version.restype = None lib.zsys_version.argtypes = [POINTER(c_int), POINTER(c_int), POINTER(c_int)] lib.zsys_sprintf.restype = c_char_p lib.zsys_sprintf.argtypes = [c_char_p] lib.zsys_vprintf.restype = c_char_p lib.zsys_vprintf.argtypes = [c_char_p, va_list_p] lib.zsys_udp_new.restype = socket_p lib.zsys_udp_new.argtypes = [c_bool] lib.zsys_udp_close.restype = c_int lib.zsys_udp_close.argtypes = [socket_p] lib.zsys_udp_send.restype = c_int lib.zsys_udp_send.argtypes = [socket_p, zframe_p, c_void_p, c_int] lib.zsys_udp_recv.restype = zframe_p lib.zsys_udp_recv.argtypes = [socket_p, c_char_p, c_int] lib.zsys_socket_error.restype = None lib.zsys_socket_error.argtypes = [c_char_p] lib.zsys_hostname.restype = c_char_p lib.zsys_hostname.argtypes = [] lib.zsys_daemonize.restype = c_int lib.zsys_daemonize.argtypes = [c_char_p] lib.zsys_run_as.restype = c_int lib.zsys_run_as.argtypes = [c_char_p, c_char_p, c_char_p] lib.zsys_has_curve.restype = c_bool lib.zsys_has_curve.argtypes = [] lib.zsys_set_io_threads.restype = None lib.zsys_set_io_threads.argtypes = [c_size_t] lib.zsys_set_thread_sched_policy.restype = None lib.zsys_set_thread_sched_policy.argtypes = [c_int] lib.zsys_set_thread_priority.restype = None lib.zsys_set_thread_priority.argtypes = [c_int] lib.zsys_set_max_sockets.restype = None lib.zsys_set_max_sockets.argtypes = [c_size_t] lib.zsys_socket_limit.restype = c_size_t lib.zsys_socket_limit.argtypes = [] lib.zsys_set_max_msgsz.restype = None lib.zsys_set_max_msgsz.argtypes = [c_int] lib.zsys_max_msgsz.restype = c_int lib.zsys_max_msgsz.argtypes = [] lib.zsys_set_file_stable_age_msec.restype = None lib.zsys_set_file_stable_age_msec.argtypes = [msecs_p] lib.zsys_file_stable_age_msec.restype = msecs_p lib.zsys_file_stable_age_msec.argtypes = [] lib.zsys_set_linger.restype = None lib.zsys_set_linger.argtypes = [c_size_t] lib.zsys_set_sndhwm.restype = None lib.zsys_set_sndhwm.argtypes = [c_size_t] lib.zsys_set_rcvhwm.restype = None lib.zsys_set_rcvhwm.argtypes = [c_size_t] lib.zsys_set_pipehwm.restype = None lib.zsys_set_pipehwm.argtypes = [c_size_t] lib.zsys_pipehwm.restype = c_size_t lib.zsys_pipehwm.argtypes = [] lib.zsys_set_ipv6.restype = None lib.zsys_set_ipv6.argtypes = [c_int] lib.zsys_ipv6.restype = c_int lib.zsys_ipv6.argtypes = [] lib.zsys_set_interface.restype = None lib.zsys_set_interface.argtypes = [c_char_p] lib.zsys_interface.restype = c_char_p lib.zsys_interface.argtypes = [] lib.zsys_set_ipv6_address.restype = None lib.zsys_set_ipv6_address.argtypes = [c_char_p] lib.zsys_ipv6_address.restype = c_char_p lib.zsys_ipv6_address.argtypes = [] lib.zsys_set_ipv6_mcast_address.restype = None lib.zsys_set_ipv6_mcast_address.argtypes = [c_char_p] lib.zsys_ipv6_mcast_address.restype = c_char_p lib.zsys_ipv6_mcast_address.argtypes = [] lib.zsys_set_auto_use_fd.restype = None lib.zsys_set_auto_use_fd.argtypes = [c_int] lib.zsys_auto_use_fd.restype = c_int lib.zsys_auto_use_fd.argtypes = [] lib.zsys_set_logident.restype = None lib.zsys_set_logident.argtypes = [c_char_p] lib.zsys_set_logstream.restype = None lib.zsys_set_logstream.argtypes = [FILE_p] lib.zsys_set_logsender.restype = None lib.zsys_set_logsender.argtypes = [c_char_p] lib.zsys_set_logsystem.restype = None lib.zsys_set_logsystem.argtypes = [c_bool] lib.zsys_error.restype = None lib.zsys_error.argtypes = [c_char_p] lib.zsys_warning.restype = None lib.zsys_warning.argtypes = [c_char_p] lib.zsys_notice.restype = None lib.zsys_notice.argtypes = [c_char_p] lib.zsys_info.restype = None lib.zsys_info.argtypes = [c_char_p] lib.zsys_debug.restype = None lib.zsys_debug.argtypes = [c_char_p] lib.zsys_test.restype = None lib.zsys_test.argtypes = [c_bool] class Zsys(object): """ """ allow_destruct = False def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() @staticmethod def init(): """ Initialize CZMQ zsys layer; this happens automatically when you create a socket or an actor; however this call lets you force initialization earlier, so e.g. logging is properly set-up before you start working. Not threadsafe, so call only from main thread. Safe to call multiple times. Returns global CZMQ context. """ return c_void_p(lib.zsys_init()) @staticmethod def shutdown(): """ Optionally shut down the CZMQ zsys layer; this normally happens automatically when the process exits; however this call lets you force a shutdown earlier, avoiding any potential problems with atexit() ordering, especially with Windows dlls. """ return lib.zsys_shutdown() @staticmethod def socket(type, filename, line_nbr): """ Get a new ZMQ socket, automagically creating a ZMQ context if this is the first time. Caller is responsible for destroying the ZMQ socket before process exits, to avoid a ZMQ deadlock. Note: you should not use this method in CZMQ apps, use zsock_new() instead. *** This is for CZMQ internal use only and may change arbitrarily *** """ return c_void_p(lib.zsys_socket(type, filename, line_nbr)) @staticmethod def close(handle, filename, line_nbr): """ Destroy/close a ZMQ socket. You should call this for every socket you create using zsys_socket(). *** This is for CZMQ internal use only and may change arbitrarily *** """ return lib.zsys_close(handle, filename, line_nbr) @staticmethod def sockname(socktype): """ Return ZMQ socket name for socket type *** This is for CZMQ internal use only and may change arbitrarily *** """ return lib.zsys_sockname(socktype) @staticmethod def create_pipe(backend_p): """ Create a pipe, which consists of two PAIR sockets connected over inproc. The pipe is configured to use the zsys_pipehwm setting. Returns the frontend socket successful, NULL if failed. """ return Zsock(lib.zsys_create_pipe(byref(zsock_p.from_param(backend_p))), False) @staticmethod def handler_set(handler_fn): """ Set interrupt handler; this saves the default handlers so that a zsys_handler_reset () can restore them. If you call this multiple times then the last handler will take affect. If handler_fn is NULL, disables default SIGINT/SIGTERM handling in CZMQ. """ return lib.zsys_handler_set(byref(zsys_handler_fn.from_param(handler_fn))) @staticmethod def handler_reset(): """ Reset interrupt handler, call this at exit if needed """ return lib.zsys_handler_reset() @staticmethod def catch_interrupts(): """ Set default interrupt handler, so Ctrl-C or SIGTERM will set zsys_interrupted. Idempotent; safe to call multiple times. Can be supressed by ZSYS_SIGHANDLER=false *** This is for CZMQ internal use only and may change arbitrarily *** """ return lib.zsys_catch_interrupts() @staticmethod def file_exists(filename): """ Return 1 if file exists, else zero """ return lib.zsys_file_exists(filename) @staticmethod def file_modified(filename): """ Return file modification time. Returns 0 if the file does not exist. """ return lib.zsys_file_modified(filename) @staticmethod def file_mode(filename): """ Return file mode; provides at least support for the POSIX S_ISREG(m) and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. Returns a mode_t cast to int, or -1 in case of error. """ return lib.zsys_file_mode(filename) @staticmethod def file_delete(filename): """ Delete file. Does not complain if the file is absent """ return lib.zsys_file_delete(filename) @staticmethod def file_stable(filename): """ Check if file is 'stable' """ return lib.zsys_file_stable(filename) @staticmethod def dir_create(pathname, *args): """ Create a file path if it doesn't exist. The file path is treated as printf format. """ return lib.zsys_dir_create(pathname, *args) @staticmethod def dir_delete(pathname, *args): """ Remove a file path if empty; the pathname is treated as printf format. """ return lib.zsys_dir_delete(pathname, *args) @staticmethod def dir_change(pathname): """ Move to a specified working directory. Returns 0 if OK, -1 if this failed. """ return lib.zsys_dir_change(pathname) @staticmethod def file_mode_private(): """ Set private file creation mode; all files created from here will be readable/writable by the owner only. """ return lib.zsys_file_mode_private() @staticmethod def file_mode_default(): """ Reset default file creation mode; all files created from here will use process file mode defaults. """ return lib.zsys_file_mode_default() @staticmethod def version(major, minor, patch): """ Return the CZMQ version for run-time API detection; returns version number into provided fields, providing reference isn't null in each case. """ return lib.zsys_version(byref(c_int.from_param(major)), byref(c_int.from_param(minor)), byref(c_int.from_param(patch))) @staticmethod def sprintf(format, *args): """ 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(). """ return lib.zsys_sprintf(format, *args) @staticmethod def vprintf(format, argptr): """ Format a string with a va_list argument, returning a freshly allocated buffer. If there was insufficient memory, returns NULL. Free the returned string using zstr_free(). """ return lib.zsys_vprintf(format, argptr) @staticmethod def udp_new(routable): """ Create UDP beacon socket; if the routable option is true, uses multicast (not yet implemented), else uses broadcast. This method and related ones might _eventually_ be moved to a zudp class. *** This is for CZMQ internal use only and may change arbitrarily *** """ return lib.zsys_udp_new(routable) @staticmethod def udp_close(handle): """ Close a UDP socket *** This is for CZMQ internal use only and may change arbitrarily *** """ return lib.zsys_udp_close(handle) @staticmethod def udp_send(udpsock, frame, address, addrlen): """ Send zframe to UDP socket, return -1 if sending failed due to interface having disappeared (happens easily with WiFi) *** This is for CZMQ internal use only and may change arbitrarily *** """ return lib.zsys_udp_send(udpsock, frame, address, addrlen) @staticmethod def udp_recv(udpsock, peername, peerlen): """ Receive zframe from UDP socket, and set address of peer that sent it The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. *** This is for CZMQ internal use only and may change arbitrarily *** """ return Zframe(lib.zsys_udp_recv(udpsock, peername, peerlen), False) @staticmethod def socket_error(reason): """ Handle an I/O error on some socket operation; will report and die on fatal errors, and continue silently on "try again" errors. *** This is for CZMQ internal use only and may change arbitrarily *** """ return lib.zsys_socket_error(reason) @staticmethod def hostname(): """ Return current host name, for use in public tcp:// endpoints. Caller gets a freshly allocated string, should free it using zstr_free(). If the host name is not resolvable, returns NULL. """ return lib.zsys_hostname() @staticmethod def daemonize(workdir): """ Move the current process into the background. The precise effect depends on the operating system. On POSIX boxes, moves to a specified working directory (if specified), closes all file handles, reopens stdin, stdout, and stderr to the null device, and sets the process to ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there was an error. """ return lib.zsys_daemonize(workdir) @staticmethod def run_as(lockfile, group, user): """ Drop the process ID into the lockfile, with exclusive lock, and switch the process to the specified group and/or user. Any of the arguments may be null, indicating a no-op. Returns 0 on success, -1 on failure. Note if you combine this with zsys_daemonize, run after, not before that method, or the lockfile will hold the wrong process ID. """ return lib.zsys_run_as(lockfile, group, user) @staticmethod def has_curve(): """ Returns true if the underlying libzmq supports CURVE security. Uses a heuristic probe according to the version of libzmq being used. """ return lib.zsys_has_curve() @staticmethod def set_io_threads(io_threads): """ Configure the number of I/O threads that ZeroMQ will use. A good rule of thumb is one thread per gigabit of traffic in or out. The default is 1, sufficient for most applications. If the environment variable ZSYS_IO_THREADS is defined, that provides the default. Note that this method is valid only before any socket is created. """ return lib.zsys_set_io_threads(io_threads) @staticmethod def set_thread_sched_policy(policy): """ Configure the scheduling policy of the ZMQ context thread pool. Not available on Windows. See the sched_setscheduler man page or sched.h for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY is defined, that provides the default. Note that this method is valid only before any socket is created. """ return lib.zsys_set_thread_sched_policy(policy) @staticmethod def set_thread_priority(priority): """ Configure the scheduling priority of the ZMQ context thread pool. Not available on Windows. See the sched_setscheduler man page or sched.h for more information. If the environment variable ZSYS_THREAD_PRIORITY is defined, that provides the default. Note that this method is valid only before any socket is created. """ return lib.zsys_set_thread_priority(priority) @staticmethod def set_max_sockets(max_sockets): """ Configure the number of sockets that ZeroMQ will allow. The default is 1024. The actual limit depends on the system, and you can query it by using zsys_socket_limit (). A value of zero means "maximum". Note that this method is valid only before any socket is created. """ return lib.zsys_set_max_sockets(max_sockets) @staticmethod def socket_limit(): """ Return maximum number of ZeroMQ sockets that the system will support. """ return lib.zsys_socket_limit() @staticmethod def set_max_msgsz(max_msgsz): """ Configure the maximum allowed size of a message sent. The default is INT_MAX. """ return lib.zsys_set_max_msgsz(max_msgsz) @staticmethod def max_msgsz(): """ Return maximum message size. """ return lib.zsys_max_msgsz() @staticmethod def set_file_stable_age_msec(file_stable_age_msec): """ Configure the threshold value of filesystem object age per st_mtime that should elapse until we consider that object "stable" at the current zclock_time() moment. The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c which generally depends on host OS, with fallback value of 5000. """ return lib.zsys_set_file_stable_age_msec(file_stable_age_msec) @staticmethod def file_stable_age_msec(): """ Return current threshold value of file stable age in msec. This can be used in code that chooses to wait for this timeout before testing if a filesystem object is "stable" or not. """ return lib.zsys_file_stable_age_msec() @staticmethod def set_linger(linger): """ Configure the default linger timeout in msecs for new zsock instances. You can also set this separately on each zsock_t instance. The default linger time is zero, i.e. any pending messages will be dropped. If the environment variable ZSYS_LINGER is defined, that provides the default. Note that process exit will typically be delayed by the linger time. """ return lib.zsys_set_linger(linger) @staticmethod def set_sndhwm(sndhwm): """ Configure the default outgoing pipe limit (HWM) for new zsock instances. You can also set this separately on each zsock_t instance. The default HWM is 1,000, on all versions of ZeroMQ. If the environment variable ZSYS_SNDHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. """ return lib.zsys_set_sndhwm(sndhwm) @staticmethod def set_rcvhwm(rcvhwm): """ Configure the default incoming pipe limit (HWM) for new zsock instances. You can also set this separately on each zsock_t instance. The default HWM is 1,000, on all versions of ZeroMQ. If the environment variable ZSYS_RCVHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. """ return lib.zsys_set_rcvhwm(rcvhwm) @staticmethod def set_pipehwm(pipehwm): """ Configure the default HWM for zactor internal pipes; this is set on both ends of the pipe, for outgoing messages only (sndhwm). The default HWM is 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. """ return lib.zsys_set_pipehwm(pipehwm) @staticmethod def pipehwm(): """ Return the HWM for zactor internal pipes. """ return lib.zsys_pipehwm() @staticmethod def set_ipv6(ipv6): """ Configure use of IPv6 for new zsock instances. By default sockets accept and make only IPv4 connections. When you enable IPv6, sockets will accept and connect to both IPv4 and IPv6 peers. You can override the setting on each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the default. Note: has no effect on ZMQ v2. """ return lib.zsys_set_ipv6(ipv6) @staticmethod def ipv6(): """ Return use of IPv6 for zsock instances. """ return lib.zsys_ipv6() @staticmethod def set_interface(value): """ Set network interface name to use for broadcasts, particularly zbeacon. This lets the interface be configured for test environments where required. For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is the default when there is no specified interface. If the environment variable ZSYS_INTERFACE is set, use that as the default interface name. Setting the interface to "*" means "use all available interfaces". """ return lib.zsys_set_interface(value) @staticmethod def interface(): """ Return network interface to use for broadcasts, or "" if none was set. """ return lib.zsys_interface() @staticmethod def set_ipv6_address(value): """ Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. This needs to be set IPv6 is enabled as IPv6 can have multiple addresses on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, use that as the default IPv6 address. """ return lib.zsys_set_ipv6_address(value) @staticmethod def ipv6_address(): """ Return IPv6 address to use for zbeacon reception, or "" if none was set. """ return lib.zsys_ipv6_address() @staticmethod def set_ipv6_mcast_address(value): """ Set IPv6 milticast address to use for sending zbeacon messages. This needs to be set if IPv6 is enabled. If the environment variable ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast address. """ return lib.zsys_set_ipv6_mcast_address(value) @staticmethod def ipv6_mcast_address(): """ Return IPv6 multicast address to use for sending zbeacon, or "" if none was set. """ return lib.zsys_ipv6_mcast_address() @staticmethod def set_auto_use_fd(auto_use_fd): """ Configure the automatic use of pre-allocated FDs when creating new sockets. If 0 (default), nothing will happen. Else, when a new socket is bound, the system API will be used to check if an existing pre-allocated FD with a matching port (if TCP) or path (if IPC) exists, and if it does it will be set via the ZMQ_USE_FD socket option so that the library will use it instead of creating a new socket. """ return lib.zsys_set_auto_use_fd(auto_use_fd) @staticmethod def auto_use_fd(): """ Return use of automatic pre-allocated FDs for zsock instances. """ return lib.zsys_auto_use_fd() @staticmethod def set_logident(value): """ Set log identity, which is a string that prefixes all log messages sent by this process. The log identity defaults to the environment variable ZSYS_LOGIDENT, if that is set. """ return lib.zsys_set_logident(value) @staticmethod def set_logstream(stream): """ Set stream to receive log traffic. By default, log traffic is sent to stdout. If you set the stream to NULL, no stream will receive the log traffic (it may still be sent to the system facility). """ return lib.zsys_set_logstream(coerce_py_file(stream)) @staticmethod def set_logsender(endpoint): """ Sends log output to a PUB socket bound to the specified endpoint. To collect such log output, create a SUB socket, subscribe to the traffic you care about, and connect to the endpoint. Log traffic is sent as a single string frame, in the same format as when sent to stdout. The log system supports a single sender; multiple calls to this method will bind the same sender to multiple endpoints. To disable the sender, call this method with a null argument. """ return lib.zsys_set_logsender(endpoint) @staticmethod def set_logsystem(logsystem): """ Enable or disable logging to the system facility (syslog on POSIX boxes, event log on Windows). By default this is disabled. """ return lib.zsys_set_logsystem(logsystem) @staticmethod def error(format, *args): """ Log error condition - highest priority """ return lib.zsys_error(format, *args) @staticmethod def warning(format, *args): """ Log warning condition - high priority """ return lib.zsys_warning(format, *args) @staticmethod def notice(format, *args): """ Log normal, but significant, condition - normal priority """ return lib.zsys_notice(format, *args) @staticmethod def info(format, *args): """ Log informational message - low priority """ return lib.zsys_info(format, *args) @staticmethod def debug(format, *args): """ Log debug-level message - lowest priority """ return lib.zsys_debug(format, *args) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zsys_test(verbose) # ztimerset ztimerset_fn = CFUNCTYPE(None, c_int, c_void_p) lib.ztimerset_new.restype = ztimerset_p lib.ztimerset_new.argtypes = [] lib.ztimerset_destroy.restype = None lib.ztimerset_destroy.argtypes = [POINTER(ztimerset_p)] lib.ztimerset_add.restype = c_int lib.ztimerset_add.argtypes = [ztimerset_p, c_size_t, ztimerset_fn, c_void_p] lib.ztimerset_cancel.restype = c_int lib.ztimerset_cancel.argtypes = [ztimerset_p, c_int] lib.ztimerset_set_interval.restype = c_int lib.ztimerset_set_interval.argtypes = [ztimerset_p, c_int, c_size_t] lib.ztimerset_reset.restype = c_int lib.ztimerset_reset.argtypes = [ztimerset_p, c_int] lib.ztimerset_timeout.restype = c_int lib.ztimerset_timeout.argtypes = [ztimerset_p] lib.ztimerset_execute.restype = c_int lib.ztimerset_execute.argtypes = [ztimerset_p] lib.ztimerset_test.restype = None lib.ztimerset_test.argtypes = [c_bool] class Ztimerset(object): """ timer set """ allow_destruct = False def __init__(self, *args): """ Create new timer set. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], ztimerset_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is ztimerset_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.ztimerset_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a timer set """ if self.allow_destruct: lib.ztimerset_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def add(self, interval, handler, arg): """ Add a timer to the set. Returns timer id if OK, -1 on failure. """ return lib.ztimerset_add(self._as_parameter_, interval, handler, arg) def cancel(self, timer_id): """ Cancel a timer. Returns 0 if OK, -1 on failure. """ return lib.ztimerset_cancel(self._as_parameter_, timer_id) def set_interval(self, timer_id, interval): """ Set timer interval. Returns 0 if OK, -1 on failure. This method is slow, canceling the timer and adding a new one yield better performance. """ return lib.ztimerset_set_interval(self._as_parameter_, timer_id, interval) def reset(self, timer_id): """ Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. This method is slow, canceling the timer and adding a new one yield better performance. """ return lib.ztimerset_reset(self._as_parameter_, timer_id) def timeout(self): """ Return the time until the next interval. Should be used as timeout parameter for the zpoller wait method. The timeout is in msec. """ return lib.ztimerset_timeout(self._as_parameter_) def execute(self): """ Invoke callback function of all timers which their interval has elapsed. Should be call after zpoller wait method. Returns 0 if OK, -1 on failure. """ return lib.ztimerset_execute(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class. """ return lib.ztimerset_test(verbose) # ztrie ztrie_destroy_data_fn = CFUNCTYPE(None, POINTER(c_void_p)) lib.ztrie_new.restype = ztrie_p lib.ztrie_new.argtypes = [char_p] lib.ztrie_destroy.restype = None lib.ztrie_destroy.argtypes = [POINTER(ztrie_p)] lib.ztrie_insert_route.restype = c_int lib.ztrie_insert_route.argtypes = [ztrie_p, c_char_p, c_void_p, ztrie_destroy_data_fn] lib.ztrie_remove_route.restype = c_int lib.ztrie_remove_route.argtypes = [ztrie_p, c_char_p] lib.ztrie_matches.restype = c_bool lib.ztrie_matches.argtypes = [ztrie_p, c_char_p] lib.ztrie_hit_data.restype = c_void_p lib.ztrie_hit_data.argtypes = [ztrie_p] lib.ztrie_hit_parameter_count.restype = c_size_t lib.ztrie_hit_parameter_count.argtypes = [ztrie_p] lib.ztrie_hit_parameters.restype = zhashx_p lib.ztrie_hit_parameters.argtypes = [ztrie_p] lib.ztrie_hit_asterisk_match.restype = c_char_p lib.ztrie_hit_asterisk_match.argtypes = [ztrie_p] lib.ztrie_print.restype = None lib.ztrie_print.argtypes = [ztrie_p] lib.ztrie_test.restype = None lib.ztrie_test.argtypes = [c_bool] class Ztrie(object): """ simple trie for tokenizable strings """ allow_destruct = False def __init__(self, *args): """ Creates a new ztrie. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], ztrie_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is ztrie_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 1) self._as_parameter_ = lib.ztrie_new(args[0]) # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy the ztrie. """ if self.allow_destruct: lib.ztrie_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() def insert_route(self, path, data, destroy_data_fn): """ Inserts a new route into the tree and attaches the data. Returns -1 if the route already exists, otherwise 0. This method takes ownership of the provided data if a destroy_data_fn is provided. """ return lib.ztrie_insert_route(self._as_parameter_, path, data, destroy_data_fn) def remove_route(self, path): """ Removes a route from the trie and destroys its data. Returns -1 if the route does not exists, otherwise 0. the start of the list call zlist_first (). Advances the cursor. """ return lib.ztrie_remove_route(self._as_parameter_, path) def matches(self, path): """ Returns true if the path matches a route in the tree, otherwise false. """ return lib.ztrie_matches(self._as_parameter_, path) def hit_data(self): """ Returns the data of a matched route from last ztrie_matches. If the path did not match, returns NULL. Do not delete the data as it's owned by ztrie. """ return c_void_p(lib.ztrie_hit_data(self._as_parameter_)) def hit_parameter_count(self): """ Returns the count of parameters that a matched route has. """ return lib.ztrie_hit_parameter_count(self._as_parameter_) def hit_parameters(self): """ Returns the parameters of a matched route with named regexes from last ztrie_matches. If the path did not match or the route did not contain any named regexes, returns NULL. """ return Zhashx(lib.ztrie_hit_parameters(self._as_parameter_), False) def hit_asterisk_match(self): """ Returns the asterisk matched part of a route, if there has been no match or no asterisk match, returns NULL. """ return lib.ztrie_hit_asterisk_match(self._as_parameter_) def print(self): """ Print the trie """ return lib.ztrie_print(self._as_parameter_) @staticmethod def test(verbose): """ Self test of this class. """ return lib.ztrie_test(verbose) # zuuid lib.zuuid_new.restype = zuuid_p lib.zuuid_new.argtypes = [] lib.zuuid_destroy.restype = None lib.zuuid_destroy.argtypes = [POINTER(zuuid_p)] lib.zuuid_new_from.restype = zuuid_p lib.zuuid_new_from.argtypes = [c_void_p] lib.zuuid_set.restype = None lib.zuuid_set.argtypes = [zuuid_p, c_void_p] lib.zuuid_set_str.restype = c_int lib.zuuid_set_str.argtypes = [zuuid_p, c_char_p] lib.zuuid_data.restype = c_void_p lib.zuuid_data.argtypes = [zuuid_p] lib.zuuid_size.restype = c_size_t lib.zuuid_size.argtypes = [zuuid_p] lib.zuuid_str.restype = c_char_p lib.zuuid_str.argtypes = [zuuid_p] lib.zuuid_str_canonical.restype = c_char_p lib.zuuid_str_canonical.argtypes = [zuuid_p] lib.zuuid_export.restype = None lib.zuuid_export.argtypes = [zuuid_p, c_void_p] lib.zuuid_eq.restype = c_bool lib.zuuid_eq.argtypes = [zuuid_p, c_void_p] lib.zuuid_neq.restype = c_bool lib.zuuid_neq.argtypes = [zuuid_p, c_void_p] lib.zuuid_dup.restype = zuuid_p lib.zuuid_dup.argtypes = [zuuid_p] lib.zuuid_test.restype = None lib.zuuid_test.argtypes = [c_bool] class Zuuid(object): """ UUID support class """ allow_destruct = False def __init__(self, *args): """ Create a new UUID object. """ if len(args) == 2 and type(args[0]) is c_void_p and isinstance(args[1], bool): self._as_parameter_ = cast(args[0], zuuid_p) # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us elif len(args) == 2 and type(args[0]) is zuuid_p and isinstance(args[1], bool): self._as_parameter_ = args[0] # Conversion from raw type to binding self.allow_destruct = args[1] # This is a 'fresh' value, owned by us else: assert(len(args) == 0) self._as_parameter_ = lib.zuuid_new() # Creation of new raw type self.allow_destruct = True def __del__(self): """ Destroy a specified UUID object. """ if self.allow_destruct: lib.zuuid_destroy(byref(self._as_parameter_)) def __eq__(self, other): if type(other) == type(self): return other.c_address() == self.c_address() elif type(other) == c_void_p: return other.value == self.c_address() def c_address(self): """ Return the address of the object pointer in c. Useful for comparison. """ return addressof(self._as_parameter_.contents) def __bool__(self): "Determine whether the object is valid by converting to boolean" # Python 3 return self._as_parameter_.__bool__() def __nonzero__(self): "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() @staticmethod def new_from(source): """ Create UUID object from supplied ZUUID_LEN-octet value. """ return Zuuid(lib.zuuid_new_from(source), True) def set(self, source): """ Set UUID to new supplied ZUUID_LEN-octet value. """ return lib.zuuid_set(self._as_parameter_, source) def set_str(self, source): """ Set UUID to new supplied string value skipping '-' and '{' '}' optional delimiters. Return 0 if OK, else returns -1. """ return lib.zuuid_set_str(self._as_parameter_, source) def data(self): """ Return UUID binary data. """ return lib.zuuid_data(self._as_parameter_) def size(self): """ Return UUID binary size """ return lib.zuuid_size(self._as_parameter_) def str(self): """ Returns UUID as string """ return lib.zuuid_str(self._as_parameter_) def str_canonical(self): """ Return UUID in the canonical string format: 8-4-4-4-12, in lower case. Caller does not modify or free returned value. See http://en.wikipedia.org/wiki/Universally_unique_identifier """ return lib.zuuid_str_canonical(self._as_parameter_) def export(self, target): """ Store UUID blob in target array """ return lib.zuuid_export(self._as_parameter_, target) def eq(self, compare): """ Check if UUID is same as supplied value """ return lib.zuuid_eq(self._as_parameter_, compare) def neq(self, compare): """ Check if UUID is different from supplied value """ return lib.zuuid_neq(self._as_parameter_, compare) def dup(self): """ Make copy of UUID object; if uuid is null, or memory was exhausted, returns null. """ return Zuuid(lib.zuuid_dup(self._as_parameter_), False) @staticmethod def test(verbose): """ Self test of this class. """ return lib.zuuid_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python/ci_build.sh0000775000372000037200000000353013222211156020613 0ustar00travistravis00000000000000#!/usr/bin/env bash set -x # Go back to the root and build, just like the default target Only difference # is meant to be the final step, where we make install on this project, then # run the python tests. cd ../.. mkdir tmp BUILD_PREFIX=$PWD/tmp CONFIG_OPTS=() CONFIG_OPTS+=("CFLAGS=-I${BUILD_PREFIX}/include") CONFIG_OPTS+=("CPPFLAGS=-I${BUILD_PREFIX}/include") CONFIG_OPTS+=("CXXFLAGS=-I${BUILD_PREFIX}/include") CONFIG_OPTS+=("LDFLAGS=-L${BUILD_PREFIX}/lib") CONFIG_OPTS+=("PKG_CONFIG_PATH=${BUILD_PREFIX}/lib/pkgconfig") CONFIG_OPTS+=("--prefix=${BUILD_PREFIX}") CONFIG_OPTS+=("--with-docs=no") CONFIG_OPTS+=("--quiet") # Start of recipe for dependency: libzmq if ! (command -v dpkg-query >/dev/null 2>&1 && dpkg-query --list libzmq3-dev >/dev/null 2>&1) || \ (command -v brew >/dev/null 2>&1 && brew ls --versions libzmq >/dev/null 2>&1) \ ; then echo "" BASE_PWD=${PWD} echo "`date`: INFO: Building prerequisite 'libzmq' from Git repository..." >&2 git clone --quiet --depth 1 https://github.com/zeromq/libzmq.git libzmq cd libzmq CCACHE_BASEDIR=${PWD} export CCACHE_BASEDIR git --no-pager log --oneline -n1 if [ -e autogen.sh ]; then ./autogen.sh 2> /dev/null fi if [ -e buildconf ]; then ./buildconf 2> /dev/null fi if [ ! -e autogen.sh ] && [ ! -e buildconf ] && [ ! -e ./configure ] && [ -s ./configure.ac ]; then libtoolize --copy --force && \ aclocal -I . && \ autoheader && \ automake --add-missing --copy && \ autoconf || \ autoreconf -fiv fi ./configure "${CONFIG_OPTS[@]}" make -j4 make install cd "${BASE_PWD}" fi # Build and install this project ./autogen.sh 2> /dev/null ./configure --enable-drafts=yes "${CONFIG_OPTS[@]}" make VERBOSE=1 install LD_LIBRARY_PATH=$BUILD_PREFIX/lib python bindings/python/test.py czmq-4.1.0/bindings/python/test.py0000664000372000037200000011345613222211156020044 0ustar00travistravis00000000000000from __future__ import print_function import unittest import sys, os, time from ctypes import * from czmq import * # http://python3porting.com/problems.html#common-migration-problems PY3 = sys.version_info > (3,) if PY3: # Python 3 does not have a "cmp" builtin. def cmp(a, b): return (a > b) - (a < b) # Part test, part example of how to use python bindings. # Note the del statements are just to explicitly test functionality, it is generally not required. class TestCZMQ(unittest.TestCase): verbose = int(os.environ.get('VERBOSE', '0')) def test_zdir(self): older = Zdir(b'.', None) self.assertTrue(older) if self.verbose: older.print(0) newer = Zdir(b'..', None) self.assertTrue(newer) patches = Zdir.diff(older, newer, b'/') self.assertTrue(patches) while patches.size(): patch = ZdirPatch(patches.pop(), True) nosuch = Zdir(b"does-not-exist", None) self.assertFalse(nosuch) # zdir_watch test: watch = Zactor(zactor_fn(lib.zdir_watch), None) self.assertTrue(watch) if self.verbose: watch.sock().send(b"s", b"VERBOSE") self.assertEqual(watch.wait(), 0) # need to create a file in the test directory we're watching # in order to ensure the directory exists initfile = Zfile(b"./zdir-test-dir", b"initial_file") self.assertTrue(initfile) initfile.output() if PY3: with initfile.handle() as hdl: # Avoid ResourceWarning: unclosed file. hdl.write(b"initial file\n") else: initfile.handle().write(b"initial file\n") initfile.close() try: stable_age = float(file_stable_age_msec()) / 1000.0 + 0.050 except Exception: stable_age = 5.050 time.sleep(stable_age) # wait for initial file to become 'stable' watch.sock().send(b"si", b"TIMEOUT", 100) self.assertEqual(watch.sock().wait(), 0) watch.sock().send(b"ss", b"SUBSCRIBE", b"zdir-test-dir") self.assertEqual(watch.sock().wait(), 0) watch.sock().send(b"ss", b"UNSUBSCRIBE", b"zdir-test-dir") self.assertEqual(watch.sock().wait(), 0) watch.sock().send(b"ss", b"SUBSCRIBE", b"zdir-test-dir") self.assertEqual(watch.sock().wait(), 0) newfile = Zfile(b"zdir-test-dir", b"test_abc") newfile.output() if PY3: with newfile.handle() as hdl: # Avoid ResourceWarning: unclosed file. hdl.write(b"test file\n") else: newfile.handle().write(b"test file\n") newfile.close() #watch_poll = Zpoller(watch, None) # poll for a certain timeout before giving up and failing the test. #assert(watch_poll.wait(1001) == watch) # wait for notification of the file being added path = c_char_p() patches = zlist_p() rc = watch.sock().recv(b"sp", byref(path), byref(patches)) self.assertEqual(rc, 0) patches = Zlist(patches, True) self.assertEqual(string_at(path), b"zdir-test-dir") libc.free (path) self.assertEqual(patches.size(), 1) patch = ZdirPatch(patches.pop(), True) self.assertEqual(patch.path(), b"zdir-test-dir") patch_file = patch.file() self.assertEqual(patch_file.filename(b""), b"zdir-test-dir/test_abc") del patch del patches # remove the file newfile.remove() del newfile # poll for a certain timeout before giving up and failing the test. #assert(watch_poll.wait(1001) == watch) # wait for notification of the file being removed path = c_char_p() patches = zlist_p() rc = watch.sock().recv(b"sp", byref(path), byref(patches)) self.assertEqual(rc, 0) patches = Zlist(patches, True) self.assertEqual(string_at(path), b"zdir-test-dir") libc.free (path) self.assertEqual(patches.size(), 1) patch = ZdirPatch(patches.pop(), True) self.assertEqual(patch.path(), b"zdir-test-dir") patch_file = patch.file() self.assertEqual(patch_file.filename(b""), b"zdir-test-dir/test_abc") del patch del patches #zpoller_destroy (&watch_poll) del watch # clean up by removing the test directory. testdir = Zdir(b"zdir-test-dir", None) testdir.remove(True) del testdir def test_zdir_patch(self): file = Zfile(b".", b"bilbo") self.assertTrue(file) patch = ZdirPatch(b".", file, ZdirPatch.CREATE, b"/") self.assertTrue(patch) del file file = patch.file() self.assertTrue(file) self.assertEqual(file.filename(b"."), b"bilbo") self.assertEqual(patch.vpath(), b"/bilbo") del patch def test_zfile(self): file = Zfile(None, b"bilbo") self.assertTrue(file) self.assertEqual(file.filename(b"."), b"bilbo") self.assertFalse(file.is_readable()) del file # Create a test file in some random subdirectory file = Zfile(b"./this/is/a/test", b"bilbo") self.assertTrue(file) self.assertEqual(file.output(), 0) #chunk = Zchunk.new(None, 100) #self.assertTrue(chunk) #chunk.fill(0, 100) # Write 100 bytes at position 1,000,000 in the file #self.assertEqual(file.write(chunk, 1000000), 0) #del chunk file.close() self.assertTrue(file.is_readable()) #self.assertEqual(file.cursize(), 1000100) #self.assertFalse(file.is_stable()) self.assertTrue(file.digest()) # Now truncate file from outside f = open('./this/is/a/test/bilbo', 'wb') f.truncate() f.write(b"Hello, World\n") f.close() del f try: stable_age = float(file_stable_age_msec()) / 1000.0 + 0.050 except Exception: stable_age = 5.050 self.assertTrue(file.has_changed()) self.assertFalse(file.is_stable()) time.sleep(stable_age) # just over a threshold value passes... self.assertTrue(file.has_changed()) self.assertFalse(file.is_stable()) file.restat() # restat. self.assertTrue(file.is_stable()) self.assertFalse(file.has_changed()) self.assertEqual(file.digest(), b"4AB299C8AD6ED14F31923DD94F8B5F5CB89DFB54") # Check we can read from file self.assertEqual(file.input(), 0) #chunk = file.read(1000100, 0) #self.assertTrue(chunk) #self.assertEqual(chunk.size(), 13) #del chunk file.close() # Check we can read lines from file self.assertEqual(file.input(), 0) line = file.readln() self.assertEqual(line, b"Hello, World") line = file.readln() self.assertIsNone(line) file.close() # Try some fun with symbolic links link = Zfile(b"./this/is/a/test", b"bilbo.ln") self.assertTrue(link) self.assertEqual(link.output(), 0) if PY3: with link.handle() as hdl: # Avoid ResourceWarning: unclosed file. hdl.write(b"./this/is/a/test/bilbo\n") else: link.handle().write(b"./this/is/a/test/bilbo\n") del link link = Zfile(b"./this/is/a/test", b"bilbo.ln") self.assertTrue(link) self.assertEqual(link.input(), 0) #chunk = link.read(1000100, 0) #self.assertTrue(chunk) #self.assertEqual(chunk.size(), 13) #del chunk del link # Remove file and directory dir = Zdir(b"./this", None) self.assertTrue(dir) self.assertEqual(dir.cursize(), 26) dir.remove(True) self.assertEqual(dir.cursize(), 0) del dir # Check we can no longer read from file self.assertTrue(file.is_readable()) file.restat() self.assertFalse(file.is_readable()) self.assertEqual(file.input(), -1) del file def test_zframe(self): # Create two PAIR sockets and connect over inproc output = Zsock.new_pair (b"@inproc://zframe.test") self.assertTrue(output) input = Zsock.new_pair (b">inproc://zframe.test") self.assertTrue(input) # Send five different frames, test Zframe.MORE for frame_nbr in range(5): frame = Zframe(b"Hello", 5) self.assertTrue(frame) self.assertEqual(Zframe.send(frame, output, Zframe.MORE), 0) # Send same frame five times, test ZFRAME_REUSE frame = Zframe(b"Hello", 5) self.assertTrue(frame) for frame_nbr in range(5): self.assertEqual(Zframe.send(frame, output, Zframe.MORE + Zframe.REUSE), 0) self.assertTrue(frame) copy = frame.dup() self.assertTrue(frame.eq(copy)) self.assertEqual(copy.size(), 5) del copy self.assertFalse(frame.eq(None)) # Test zframe_new_empty frame = Zframe.new_empty() self.assertTrue(frame) self.assertEqual(frame.size(), 0) del frame # Send END frame frame = Zframe(b"NOT", 3) self.assertTrue(frame) frame.reset(b"END", 3) string = frame.strhex() self.assertEqual(string, b"454E44") string = frame.strdup() self.assertEqual(string, b"END") self.assertEqual(Zframe.send(frame, output, 0), 0) # Read and count until we receive END frame_nbr = 0 while True: frame = Zframe.recv(input) if frame.streq(b"END"): break self.assertTrue(frame.more()) frame.set_more(0) self.assertEqual(frame.more(), 0) frame_nbr += 1 self.assertEqual(frame_nbr, 10) def test_zhash(self): hash = Zhash() self.assertTrue(hash) self.assertEqual(hash.size(), 0) self.assertFalse(hash.first()) self.assertFalse(hash.cursor()) # Insert some items # Note the bindings for zhash are pretty pointless for actually storing # things - we have to keep our ctypes buffer objects around to keep the # memory alive buffer1 = create_string_buffer(b"dead beef") self.assertEqual(hash.insert(b"DEADBEEF", buffer1), 0) self.assertEqual(string_at(hash.first()), b"dead beef") self.assertEqual(hash.cursor(), b"DEADBEEF") buffer2 = create_string_buffer(b"a bad cafe") self.assertEqual(hash.insert(b"ABADCAFE", buffer2), 0) buffer3 = create_string_buffer(b"coded bad") self.assertEqual(hash.insert(b"C0DEDBAD", buffer3), 0) buffer4 = create_string_buffer(b"dead food") self.assertEqual(hash.insert(b"DEADF00D", b"dead food"), 0) self.assertEqual(hash.size(), 4) # Look for existing items self.assertEqual(string_at(hash.lookup(b"DEADBEEF")), b"dead beef") self.assertEqual(string_at(hash.lookup(b"ABADCAFE")), b"a bad cafe") self.assertEqual(string_at(hash.lookup(b"DEADF00D")), b"dead food") # Look for non-existent items self.assertFalse(hash.lookup(b"foo")) # Try to insert duplicate items self.assertEqual(hash.insert(b"DEADBEEF", b"foo"), -1) self.assertEqual(string_at(hash.lookup(b"DEADBEEF")), b"dead beef") # Some rename tests # Valid rename, key is now LIVEBEEF self.assertEqual(hash.rename(b"DEADBEEF", b"LIVEBEEF"), 0) self.assertEqual(string_at(hash.lookup(b"LIVEBEEF")), b"dead beef") # Trying to rename an unknown item to a non-existent key self.assertEqual(hash.rename(b"WHATBEEF", b"NONESUCH"), -1) # Trying to rename an unknown item to an existing key self.assertEqual(hash.rename(b"WHATBEEF", b"LIVEBEEF"), -1) self.assertEqual(string_at(hash.lookup(b"LIVEBEEF")), b"dead beef") # Trying to rename an existing item to another existing item self.assertEqual(hash.rename(b"LIVEBEEF", b"ABADCAFE"), -1) self.assertEqual(string_at(hash.lookup(b"LIVEBEEF")), b"dead beef") self.assertEqual(string_at(hash.lookup(b"ABADCAFE")), b"a bad cafe") # Test keys method keys = hash.keys() self.assertEqual(keys.size(), 4) del keys # Test dup method copy = hash.dup() self.assertEqual(copy.size(), 4) self.assertEqual(string_at(copy.lookup(b"LIVEBEEF")), b"dead beef") del copy # Test pack/unpack methods frame = hash.pack() copy = Zhash.unpack(frame) del frame self.assertEqual(copy.size(), 4) self.assertEqual(string_at(copy.lookup(b"LIVEBEEF")), b"dead beef") del copy # Test save and load hash.comment(b"This is a test file") hash.comment(b"Created by %s", b"czmq_selftest") hash.save(b".cache") copy = Zhash() self.assertTrue(copy) copy.load(b".cache") self.assertEqual(string_at(copy.lookup(b"LIVEBEEF")), b"dead beef") del copy os.remove(b".cache") # Delete a item hash.delete(b"LIVEBEEF") self.assertFalse(hash.lookup(b"LIVEBEEF")) self.assertEqual(hash.size(), 3) # Test autofree automatically copies and frees string values # This means the python string doesn't need to persist, like above hash = Zhash() self.assertTrue(hash) hash.autofree() self.assertEqual(hash.insert(b"key1", b"This is a string"), 0) self.assertEqual(hash.insert(b"key2", b"Ring a ding ding"), 0) self.assertEqual(string_at(hash.lookup(b"key1")), b"This is a string") self.assertEqual(string_at(hash.lookup(b"key2")), b"Ring a ding ding") del hash def test_zlist(self): def _zlist_free(data): x = Zlist(c_void_p(data), True) del x zlist_free = zlist_free_fn(_zlist_free) def _compare(item1, item2): return cmp(string_at(item1), string_at(item2)) > 0 zlist_compare = zlist_compare_fn(_compare) list = Zlist() self.assertTrue(list) self.assertEqual(list.size(), 0) # Three items we'll use as test data # List items are void *, not particularly strings cheese = create_string_buffer(b"boursin") bread = create_string_buffer(b"baguette") wine = create_string_buffer(b"bordeaux") list.append(cheese) self.assertEqual(list.size(), 1) list.append(bread) self.assertEqual(list.size(), 2) list.append(wine) self.assertEqual(list.size(), 3) self.assertEqual(list.head().value, addressof(cheese)) self.assertEqual(list.next().value, addressof(cheese)) self.assertEqual(list.first().value, addressof(cheese)) self.assertEqual(list.tail().value, addressof(wine)) self.assertEqual(list.next().value, addressof(bread)) self.assertEqual(list.first().value, addressof(cheese)) self.assertEqual(list.next().value, addressof(bread)) self.assertEqual(list.next().value, addressof(wine)) self.assertFalse(list.next()) # After we reach end of list, next wraps around self.assertEqual(list.next().value, addressof(cheese)) self.assertEqual(list.size(), 3) list.remove(wine) self.assertEqual(list.size(), 2) self.assertEqual(list.first().value, addressof(cheese)) list.remove(cheese) self.assertEqual(list.size(), 1) self.assertEqual(list.first().value, addressof(bread)) list.remove(bread) self.assertEqual(list.size(), 0) list.append(cheese) list.append(bread) self.assertEqual(list.last().value, addressof(bread)) list.remove(bread) self.assertEqual(list.last().value, addressof(cheese)) list.remove(cheese) self.assertFalse(list.last()) list.push(cheese) self.assertEqual(list.size(), 1) self.assertEqual(list.first().value, addressof(cheese)) list.push(bread) self.assertEqual(list.size(), 2) self.assertEqual(list.first().value, addressof(bread)) self.assertEqual(list.item().value, addressof(bread)) list.append(wine) self.assertEqual(list.size(), 3) self.assertEqual(list.first().value, addressof(bread)) sub_list = list.dup() self.assertTrue(sub_list) self.assertEqual(sub_list.size(), 3) list.sort(zlist_compare) self.assertEqual(list.pop().value, addressof(bread)) self.assertEqual(list.pop().value, addressof(wine)) self.assertEqual(list.pop().value, addressof(cheese)) self.assertEqual(list.size(), 0) self.assertEqual(sub_list.size(), 3) list.push(sub_list) sub_list_2 = sub_list.dup() list.append(sub_list_2) ret = list.freefn(sub_list, zlist_free, False) sub_list.allow_destruct = False # Can't double-free self.assertEqual(ret.value, cast(sub_list._as_parameter_, c_void_p).value) ret = list.freefn(sub_list_2, zlist_free, True) sub_list_2.allow_destruct = False # Can't double-free self.assertEqual(ret.value, cast(sub_list_2._as_parameter_, c_void_p).value) del list # Test autofree functionality list = Zlist() self.assertTrue(list) list.autofree() list.push(b"bread") list.append(b"cheese") self.assertEqual(list.size(), 2) self.assertEqual(string_at(list.first()), b"bread") item = list.pop() self.assertEqual(string_at(item), b"bread") libc.free(item) item = list.pop() self.assertEqual(string_at(item), b"cheese") libc.free(item) def test_zloop(self): def _cancel_timer_event(loop, timer_id, arg): # We are handling timer 2, and will cancel timer 1 cancel_timer_id = POINTER(c_int)(c_int(arg)).contents return Zloop(loop, False).timer_end(cancel_timer_id) cancel_timer_event = zloop_timer_fn(_cancel_timer_event) def _timer_event(loop, timer_id, arg): output.send(b's', b"PING") return 0 timer_event = zloop_timer_fn(_timer_event) def _socket_event(loop, handle, arg): # Just end the reactor return -1 socket_event = zloop_reader_fn(_socket_event) def _timer_event3(loop, timer_id, called): c_bool_p(called).contents = True # end the reactor return -1 timer_event3 = zloop_timer_fn(_timer_event3) # Create two PAIR sockets and connect over inproc output = Zsock.new_pair(b"@inproc://zloop.test") self.assertTrue(output) input = Zsock.new_pair(b">inproc://zloop.test") self.assertTrue(input) loop = Zloop() self.assertTrue(loop) loop.set_verbose(self.verbose) # Create a timer that will be cancelled timer_id = c_int(loop.timer(1000, 1, timer_event, None)) loop.timer(5, 1, cancel_timer_event, byref(timer_id)) # After 20 msecs, send a ping message to output3 loop.timer(20, 1, timer_event, output) # Set up some tickets that will never expire loop.set_ticket_delay(10000) ticket1 = loop.ticket(timer_event, None) ticket2 = loop.ticket(timer_event, None) ticket3 = loop.ticket(timer_event, None) # When we get the ping message, end the reactor self.assertEqual(loop.reader(input, socket_event, None), 0) loop.reader_set_tolerant(input) loop.start() loop.ticket_delete(ticket1) loop.ticket_delete(ticket2) loop.ticket_delete(ticket3) del loop # Check whether loop properly ignores zsys_interrupted flag # when asked to #loop = Zloop() #timer_event_called = c_bool(False) #loop.timer(1, 1, timer_event3, byref(timer_event_called)) #zsys_interrupted = 1 #zloop_start (loop) ## zloop returns immediately without giving any handler a chance to run #self.assertFalse(timer_event_called) #zloop_ignore_interrupts (loop) #zloop_start (loop) # zloop runs the handler which will terminate the loop #self.assertTrue(timer_event_called) #zsys_interrupted = 0 # cleanup #del loop #self.assertFalse(loop) def test_zmsg(self): # Create two PAIR sockets and connect over inproc output = Zsock.new_pair(b"@inproc://zmsg.test") self.assertTrue(output) input_ = Zsock.new_pair(b">inproc://zmsg.test") self.assertTrue(input_) # Test send and receive of single-frame message msg = Zmsg() self.assertTrue(msg) frame = Zframe(b"Hello", 5) self.assertTrue(frame) msg.prepend(frame) self.assertEqual(msg.size(), 1) self.assertEqual(msg.content_size(), 5) self.assertEqual(Zmsg.send(msg, output), 0) self.assertFalse(msg) msg = Zmsg.recv(input_) self.assertTrue(msg) self.assertEqual(msg.size(), 1) self.assertEqual(msg.content_size(), 5) del msg # Test send and receive of multi-frame message msg = Zmsg() self.assertTrue(msg) self.assertEqual(msg.addmem(b"Frame0", 6), 0) self.assertEqual(msg.addmem(b"Frame1", 6), 0) self.assertEqual(msg.addmem(b"Frame2", 6), 0) self.assertEqual(msg.addmem(b"Frame3", 6), 0) self.assertEqual(msg.addmem(b"Frame4", 6), 0) self.assertEqual(msg.addmem(b"Frame5", 6), 0) self.assertEqual(msg.addmem(b"Frame6", 6), 0) self.assertEqual(msg.addmem(b"Frame7", 6), 0) self.assertEqual(msg.addmem(b"Frame8", 6), 0) self.assertEqual(msg.addmem(b"Frame9", 6), 0) copy = msg.dup() self.assertTrue(copy) self.assertEqual(Zmsg.send(copy, output), 0) self.assertEqual(Zmsg.send(msg, output), 0) copy = Zmsg.recv(input_) self.assertTrue(copy) self.assertEqual(copy.size(), 10) self.assertEqual(copy.content_size(), 60) del copy msg = Zmsg.recv(input_) self.assertTrue(msg) self.assertEqual(msg.size(), 10) self.assertEqual(msg.content_size(), 60) # Save to a file, read back f = open("zmsg.test", "w") self.assertEqual(msg.save(f), 0) f.close() f = open ("zmsg.test", "r") self.assertEqual(msg.save(f), -1) f.close() del msg f = open ("zmsg.test", "r") msg = Zmsg.load(f) self.assertTrue(msg) f.close() os.remove ("zmsg.test") self.assertEqual(msg.size(), 10) self.assertEqual(msg.content_size(), 60) # Remove all frames except first and last for frame_nbr in range(8): msg.first() frame = msg.next() msg.remove(frame) # Test message frame manipulation self.assertEqual(msg.size(), 2) frame = msg.last() self.assertTrue(frame.streq(b"Frame9")) self.assertEqual(msg.content_size(), 12) frame = Zframe(b"Address", 7) self.assertTrue(frame) msg.prepend(frame) self.assertEqual(msg.size(), 3) self.assertEqual(msg.addstr(b"Body"), 0) self.assertEqual(msg.size(), 4) frame = msg.pop() del frame self.assertEqual(msg.size(), 3) body = msg.popstr() self.assertEqual(body, b"Frame0") del msg # Test encoding/decoding msg = Zmsg() self.assertTrue(msg) blank = create_string_buffer(100000) self.assertEqual(msg.addmem(blank, 0), 0) self.assertEqual(msg.addmem(blank, 1), 0) self.assertEqual(msg.addmem(blank, 253), 0) self.assertEqual(msg.addmem(blank, 254), 0) self.assertEqual(msg.addmem(blank, 255), 0) self.assertEqual(msg.addmem(blank, 256), 0) self.assertEqual(msg.addmem(blank, 65535), 0) self.assertEqual(msg.addmem(blank, 65536), 0) self.assertEqual(msg.addmem(blank, 65537), 0) del blank self.assertEqual(msg.size(), 9) frame = msg.encode() del msg msg = Zmsg.decode(frame) self.assertTrue(msg) del msg # Test submessages msg = Zmsg() self.assertTrue(msg) submsg = Zmsg() msg.pushstr(b"matr") submsg.pushstr(b"joska") self.assertEqual(msg.addmsg(submsg), 0) self.assertFalse(submsg) submsg = msg.popmsg() self.assertFalse(submsg) # string "matr" is not encoded zmsg_t, so was discarded submsg = msg.popmsg() self.assertTrue(submsg) body = submsg.popstr() self.assertEqual(body, b"joska") del submsg frame = msg.pop() self.assertFalse(frame) del msg # Test comparison of two messages msg = Zmsg() msg.addstr(b"One") msg.addstr(b"Two") msg.addstr(b"Three") msg_other = Zmsg() msg_other.addstr(b"One") msg_other.addstr(b"Two") msg_other.addstr(b"One-Hundred") msg_dup = msg.dup() empty_msg = Zmsg() empty_msg_2 = Zmsg() self.assertTrue(msg.eq(msg_dup)) self.assertFalse(msg.eq(msg_other)) self.assertTrue(empty_msg.eq(empty_msg_2)) self.assertFalse(msg.eq(None)) del msg del msg_other del msg_dup del empty_msg # Test signal messages msg = Zmsg.new_signal(0) self.assertEqual(msg.signal(), 0) del msg msg = Zmsg.new_signal(-1) self.assertEqual(msg.signal(), 255) del msg # Now try methods on an empty message msg = Zmsg() self.assertTrue(msg) self.assertEqual(msg.size(), 0) self.assertFalse(msg.first()) self.assertFalse(msg.last()) self.assertFalse(msg.next()) self.assertFalse(msg.pop()) # Sending an empty message is valid and destroys the message self.assertEqual(Zmsg.send(msg, output), 0) self.assertFalse(msg) def test_zsock(self): writer = Zsock.new_push (b"@tcp://127.0.0.1:5560") self.assertTrue(writer) self.assertTrue(Zsock.resolve(writer) != writer) self.assertEqual(writer.type_str(), b"PUSH") # Check unbind self.assertEqual(writer.unbind(b"tcp://127.0.0.1:%d", 5560), 0) # In some cases and especially when running under Valgrind, doing # a bind immediately after an unbind causes an EADDRINUSE error. # Even a short sleep allows the OS to release the port for reuse. time.sleep(0.1) # Bind again self.assertEqual(writer.bind(b"tcp://127.0.0.1:%d", 5560), 5560) self.assertEqual(writer.endpoint(), b"tcp://127.0.0.1:5560") #endif reader = Zsock.new_pull (b">tcp://127.0.0.1:5560") self.assertTrue(reader) self.assertTrue(Zsock.resolve(reader) != reader) self.assertEqual(reader.type_str(), b"PULL") # Basic Hello, World writer.send(b's', b"Hello, World") msg = Zmsg.recv(reader) self.assertTrue(msg) string = msg.popstr() self.assertEqual(string, b"Hello, World") del msg # Test resolve FD #fd = Zsock.fd(reader) #self.assertEqual(zsock_resolve (fd), None) # Test binding to ephemeral ports, sequential and random DYNAMIC_FIRST = 0xc000 DYNAMIC_LAST = 0xffff port = writer.bind(b"tcp://127.0.0.1:*") self.assertTrue(port >= DYNAMIC_FIRST and port <= DYNAMIC_LAST) port = writer.bind(b"tcp://127.0.0.1:*[50000-]") self.assertTrue(port >= 50000 and port <= DYNAMIC_LAST) port = writer.bind(b"tcp://127.0.0.1:*[-50001]") self.assertTrue(port >= DYNAMIC_FIRST and port <= 50001) port = writer.bind(b"tcp://127.0.0.1:*[60000-60050]") self.assertTrue(port >= 60000 and port <= 60050) port = writer.bind(b"tcp://127.0.0.1:!") self.assertTrue(port >= DYNAMIC_FIRST and port <= DYNAMIC_LAST) port = writer.bind(b"tcp://127.0.0.1:![50000-]") self.assertTrue(port >= 50000 and port <= DYNAMIC_LAST) port = writer.bind(b"tcp://127.0.0.1:![-50001]") self.assertTrue(port >= DYNAMIC_FIRST and port <= 50001) port = writer.bind(b"tcp://127.0.0.1:![60000-60050]") self.assertTrue(port >= 60000 and port <= 60050) # Test zsock_attach method server = Zsock.new_dealer(b"") self.assertTrue(server) self.assertEqual(server.attach(b"@inproc://myendpoint,tcp://127.0.0.1:5556,inproc://others", True), 0) self.assertEqual(server.attach(b"", False), 0) self.assertEqual(server.attach(None, True), 0) self.assertEqual(server.attach(b">a,@b, c,, ", False), -1) del server # Test zsock_endpoint method self.assertEqual(writer.bind(b"inproc://test.%s", b"writer"), 0) self.assertEqual(writer.endpoint(), b"inproc://test.writer") # Test error state when connecting to an invalid socket type # ('txp://' instead of 'tcp://', typo intentional) self.assertEqual(reader.connect(b"txp://127.0.0.1:5560"), -1) # Test signal/wait methods self.assertEqual(writer.signal(123), 0) self.assertEqual(reader.wait(), 123) # Test zsock_send/recv pictures number1 = 123 number2 = 123 * 123 number4 = 123 * 123 * 123 number8 = 123 * 123 * 123 * 123 #chunk = zchunk_new (b"HELLO", 5) #self.assertTrue(chunk) frame = Zframe(b"WORLD", 5) self.assertTrue(frame) #hash = zhashx_new () #self.assertTrue(hash) #hash.autofree() #hash.insert(b"1", b"value A") #hash.insert(b"2", b"value B") original = create_string_buffer(b"pointer") # Test zsock_recv into each supported type #writer.send(b"i1248zsbcfhp", # -12345, number1, number2, number4, number8, # b"This is a string", b"ABCDE", 5, chunk, frame, hash, original) writer.send(b"i1248zsbfp", -12345, number1, number2, number4, c_longlong(number8), b"This is a string", b"ABCDE", 5, frame, original) del frame #del chunk #del hash integer = c_int() number1 = c_byte() number2 = c_short() number4 = c_int() number8 = c_longlong() string = c_char_p() data = POINTER(c_ubyte)() size = c_size_t() #chunk = zchunk_p() frame = Zframe(c_void_p(), True) #hash = POINTER(zhashx_p) pointer = c_void_p() #rc = reader.recv(b"i1248zsbcfhp", # byref(integer), byref(number1), byref(number2), byref(number4), byref(number8), # byref(string), byref(data), byref(size), byref(chunk), byref(frame), byref(hash), byref(pointer)) rc = reader.recv(b"i1248zsbfp", byref(integer), byref(number1), byref(number2), byref(number4), byref(number8), byref(string), byref(data), byref(size), byref(frame._as_parameter_), byref(pointer)) self.assertEqual(rc, 0) self.assertEqual(integer.value, -12345) self.assertEqual(number1.value, 123) self.assertEqual(number2.value, 123 * 123) self.assertEqual(number4.value, 123 * 123 * 123) self.assertEqual(number8.value, 123 * 123 * 123 * 123) self.assertEqual(string_at(string), b"This is a string") self.assertEqual(string_at(data, size.value), b"ABCDE") self.assertEqual(size.value, 5) #self.assertEqual(memcmp (chunk.data(), b"HELLO", 5), 0) #self.assertEqual(chunk.size(), 5) self.assertTrue(frame.streq(b"WORLD")) self.assertEqual(frame.size(), 5) #value = string_at(hash.lookup(b"1")) #self.assertEqual(value, b"value A") #value = string_at(hash.lookup(b"2")) #self.assertEqual(value, b"value B") self.assertEqual(addressof(original), pointer.value) libc.free (string) libc.free (data) del frame #del chunk #del hash # Test zsock_recv of short message this lets us return a failure # with a status code and then nothing else the receiver will get # the status code and None/zero for all other values writer.send(b"i", -1) #reader.recv(b"izsbcfp", # byref(integer), byref(string), byref(data), byref(size), byref(chunk), byref(frame), byref(pointer)) frame = Zframe(c_void_p(), True) reader.recv(b"izsbfp", byref(integer), byref(string), byref(data), byref(size), byref(frame._as_parameter_), byref(pointer)) self.assertEqual(integer.value, -1) self.assertEqual(string.value, None) self.assertFalse(data) self.assertEqual(size.value, 0) #self.assertEqual(chunk, None) self.assertFalse(frame) self.assertEqual(pointer.value, None) msg = Zmsg() msg.addstr(b"frame 1") msg.addstr(b"frame 2") writer.send(b"szm", b"header", msg) del msg msg = Zmsg(c_void_p(), True) reader.recv(b"szm", byref(string), byref(msg._as_parameter_)) self.assertEqual(string_at(string), b"header") self.assertEqual(msg.size(), 2) self.assertEqual(msg.popstr(), b"frame 1") self.assertEqual(msg.popstr(), b"frame 2") #zstr_free (byref(string)) libc.free(string) del msg # Test zsock_recv with null arguments #chunk = zchunk_new (b"HELLO", 5) #self.assertTrue(chunk) frame = Zframe(b"WORLD", 5) self.assertTrue(frame) #writer.send(b"izsbcfp", # -12345, b"This is a string", b"ABCDE", 5, chunk, frame, original) writer.send(b"izsbfp", -12345, b"This is a string", b"ABCDE", 5, frame, original) del frame #del chunk #reader.recv(b"izsbcfp", byref(integer), None, None, None, byref(chunk), None, None) reader.recv(b"izsbcfp", byref(integer), None, None, None, None, None, None) self.assertEqual(integer.value, -12345) #self.assertEqual(chunk.data(), b"HELLO", 5), 0) #self.assertEqual(chunk.size(), 5) #del chunk # Test zsock_bsend/brecv pictures with binary encoding frame = Zframe(b"Hello", 5) #chunk = Zchunk(b"World", 5) msg = Zmsg() msg.addstr(b"Hello") msg.addstr(b"World") #writer.bsend(b"1248sSpcfm", # number1, number2, number4, number8, # b"Hello, World", # b"Goodbye cruel World!", # original, # chunk, frame, msg) writer.bsend(b"1248sSpfm", number1, number2, number4, number8, b"Hello, World", b"Goodbye cruel World!", original, frame, msg) #del chunk del frame del msg frame = Zframe(c_void_p(), True) msg = Zmsg(c_void_p(), True) longstr = c_char_p() #reader.brecv(b"1248sSpcfm", # byref(number1), byref(number2), byref(number4), byref(number8), # byref(string), byref(longstr), # byref(pointer), # byref(chunk), byref(frame._as_parameter_), byref(msg._as_parameter_)) reader.brecv(b"1248sSpfm", byref(number1), byref(number2), byref(number4), byref(number8), byref(string), byref(longstr), byref(pointer), byref(frame._as_parameter_), byref(msg._as_parameter_)) self.assertEqual(number1.value, 123) self.assertEqual(number2.value, 123 * 123) self.assertEqual(number4.value, 123 * 123 * 123) self.assertEqual(number8.value, 123 * 123 * 123 * 123) self.assertEqual(string_at(string), b"Hello, World") self.assertEqual(string_at(longstr), b"Goodbye cruel World!") self.assertEqual(pointer.value, addressof(original)) libc.free(longstr) #zstr_free (byref(longstr)) #del chunk del frame del msg # Check that we can send a zproto format message #writer.bsend(b"1111sS4", 0xAA, 0xA0, 0x02, 0x01, b"key", b"value", 1234) #gossip = zgossip_msg_new () #gossip.recv(reader) #self.assertEqual(gossip.id(), ZGOSSIP_MSG_PUBLISH) #del gossip def test_zactor(self): def _echo_actor(pipe, arg): # Do some initialization pipe = Zsock(pipe, False) # We don't own the pipe, so False. arg = string_at(arg) self.assertEqual(arg, b"Hello, World") pipe.signal(0) # startup ok terminated = False while not terminated: msg = Zmsg.recv(pipe) if not msg: break # Interrupted command = msg.popstr() if command == b"$TERM": # All actors must handle $TERM in this way terminated = True elif command == b"ECHO": # This is an example command for our test actor Zmsg.send(msg, pipe) else: self.fail(b"Unexpected message " + command) echo_actor = zactor_fn(_echo_actor) # ctypes function reference must live as long as the actor. arg_buffer = create_string_buffer(b"Hello, World") # argument buffer must live as long as the actor. actor = Zactor(echo_actor, arg_buffer) self.assertTrue(actor) actor.sock().send(b"ss", b"ECHO", b"This is a string"); result = c_char_p() actor.sock().recv(b"s", byref(result)) self.assertEqual(string_at(result), b"This is a string") libc.free(result) if __name__ == '__main__': unittest.main() czmq-4.1.0/bindings/lua_ffi/0000775000372000037200000000000013222211156016565 5ustar00travistravis00000000000000czmq-4.1.0/bindings/lua_ffi/czmq_ffi.lua0000664000372000037200000041005013222211156021066 0ustar00travistravis00000000000000-------------------------------------------------------------------------------- -- THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY - -- Read the zproject/README.md for information about making permanent changes. - -------------------------------------------------------------------------------- czmq_ffi = {} czmq_ffi.ffi = require ("ffi") -- typedefs simulating C standard library -- see https://github.com/eliben/pycparser/blob/master/utils/fake_libc_include/_fake_defines.h czmq_ffi.ffi.cdef [[ typedef struct __FILE FILE; typedef int time_t; typedef int off_t; ]] -- czmq_prelude.h czmq_ffi.ffi.cdef [[ typedef unsigned char byte; typedef int SOCKET; ]] czmq_ffi.ffi.cdef [[ typedef struct _zactor_t zactor_t; typedef struct _zsock_t zsock_t; typedef struct _zmsg_t zmsg_t; typedef struct _zargs_t zargs_t; typedef struct _zarmour_t zarmour_t; typedef struct _zchunk_t zchunk_t; typedef struct _char_t char_t; typedef struct _zcert_t zcert_t; typedef struct _zlist_t zlist_t; typedef struct _zcertstore_t zcertstore_t; typedef struct _zlistx_t zlistx_t; typedef struct _zframe_t zframe_t; typedef struct _zclock_t zclock_t; typedef struct _msecs_t msecs_t; typedef struct _zconfig_t zconfig_t; typedef struct _zdigest_t zdigest_t; typedef struct _zdir_t zdir_t; typedef struct _zhash_t zhash_t; typedef struct _zdir_patch_t zdir_patch_t; typedef struct _zfile_t zfile_t; typedef struct _zhashx_t zhashx_t; typedef struct _ziflist_t ziflist_t; typedef struct _zloop_t zloop_t; typedef struct _zmq_pollitem_t zmq_pollitem_t; typedef struct _zpoller_t zpoller_t; typedef struct _zproc_t zproc_t; typedef struct _va_list_t va_list_t; typedef struct _socket_t socket_t; typedef struct _zstr_t zstr_t; typedef struct _zsys_t zsys_t; typedef struct _ztimerset_t ztimerset_t; typedef struct _ztrie_t ztrie_t; typedef struct _zuuid_t zuuid_t; // Actors get a pipe and arguments from caller typedef void (zactor_fn) ( zsock_t *pipe, void *args); // Function to be called on zactor_destroy. Default behavior is to send zmsg_t with string "$TERM" in a first frame. // // An example - to send $KTHXBAI string // // if (zstr_send (self->pipe, "$KTHXBAI") == 0) // zsock_wait (self->pipe); typedef void (zactor_destructor_fn) ( zactor_t *self); // Loaders retrieve certificates from an arbitrary source. typedef void (zcertstore_loader) ( zcertstore_t *self); // Destructor for loader state. typedef void (zcertstore_destructor) ( void **self_p); // typedef int (zconfig_fct) ( zconfig_t *self, void *arg, int level); // Callback function for zhash_freefn method typedef void (zhash_free_fn) ( void *data); // Destroy an item typedef void (zhashx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zhashx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zhashx_comparator_fn) ( const void *item1, const void *item2); // Destroy an item. typedef void (zhashx_free_fn) ( void *data); // Hash function for keys. typedef size_t (zhashx_hash_fn) ( const void *key); // Serializes an item to a longstr. // The caller takes ownership of the newly created object. typedef char * (zhashx_serializer_fn) ( const void *item); // Deserializes a longstr into an item. // The caller takes ownership of the newly created object. typedef void * (zhashx_deserializer_fn) ( const char *item_str); // Comparison function e.g. for sorting and removing. typedef int (zlist_compare_fn) ( void *item1, void *item2); // Callback function for zlist_freefn method typedef void (zlist_free_fn) ( void *data); // Destroy an item typedef void (zlistx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zlistx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zlistx_comparator_fn) ( const void *item1, const void *item2); // Callback function for reactor socket activity typedef int (zloop_reader_fn) ( zloop_t *loop, zsock_t *reader, void *arg); // Callback function for reactor events (low-level) typedef int (zloop_fn) ( zloop_t *loop, zmq_pollitem_t *item, void *arg); // Callback for reactor timer events typedef int (zloop_timer_fn) ( zloop_t *loop, int timer_id, void *arg); // Callback for interrupt signal handler typedef void (zsys_handler_fn) ( int signal_value); // Callback function for timer event. typedef void (ztimerset_fn) ( int timer_id, void *arg); // Callback function for ztrie_node to destroy node data. typedef void (ztrie_destroy_data_fn) ( void **data); // CLASS: zactor // Create a new actor passing arbitrary arguments reference. zactor_t * zactor_new (zactor_fn task, void *args); // Destroy an actor. void zactor_destroy (zactor_t **self_p); // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. int zactor_send (zactor_t *self, zmsg_t **msg_p); // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. zmsg_t * zactor_recv (zactor_t *self); // Probe the supplied object, and report if it looks like a zactor_t. bool zactor_is (void *self); // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. void * zactor_resolve (void *self); // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. zsock_t * zactor_sock (zactor_t *self); // Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. void zactor_set_destructor (zactor_t *self, zactor_destructor_fn destructor); // Self test of this class. void zactor_test (bool verbose); // CLASS: zargs // Create a new zargs from command line arguments. zargs_t * zargs_new (int argc, char **argv); // Destroy zargs instance. void zargs_destroy (zargs_t **self_p); // Return program name (argv[0]) const char * zargs_progname (zargs_t *self); // Return number of positional arguments size_t zargs_arguments (zargs_t *self); // Return first positional argument or NULL const char * zargs_first (zargs_t *self); // Return next positional argument or NULL const char * zargs_next (zargs_t *self); // Return first named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const char * zargs_param_first (zargs_t *self); // Return next named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const char * zargs_param_next (zargs_t *self); // Return current parameter name, or NULL if there are no named // parameters. const char * zargs_param_name (zargs_t *self); // Return value of named parameter, NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const char * zargs_param_lookup (zargs_t *self, const char *keys); // Return value of named parameter(s), NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const char * zargs_param_lookupx (zargs_t *self, const char *keys, ...); // Returns true if there are --help -h arguments bool zargs_has_help (zargs_t *self); // Returns true if parameter did not have a value bool zargs_param_empty (const char *arg); // Print an instance of zargs. void zargs_print (zargs_t *self); // Self test of this class. void zargs_test (bool verbose); // CLASS: zarmour // Create a new zarmour zarmour_t * zarmour_new (void); // Destroy the zarmour void zarmour_destroy (zarmour_t **self_p); // Encode a stream of bytes into an armoured string. Returns the armoured // string, or NULL if there was insufficient memory available to allocate // a new string. char * zarmour_encode (zarmour_t *self, const byte *data, size_t size); // Decode an armoured string into a chunk. The decoded output is // null-terminated, so it may be treated as a string, if that's what // it was prior to encoding. zchunk_t * zarmour_decode (zarmour_t *self, const char *data); // Get the mode property. int zarmour_mode (zarmour_t *self); // Get printable string for mode. const char * zarmour_mode_str (zarmour_t *self); // Set the mode property. void zarmour_set_mode (zarmour_t *self, int mode); // Return true if padding is turned on. bool zarmour_pad (zarmour_t *self); // Turn padding on or off. Default is on. void zarmour_set_pad (zarmour_t *self, bool pad); // Get the padding character. char zarmour_pad_char (zarmour_t *self); // Set the padding character. void zarmour_set_pad_char (zarmour_t *self, char pad_char); // Return if splitting output into lines is turned on. Default is off. bool zarmour_line_breaks (zarmour_t *self); // Turn splitting output into lines on or off. void zarmour_set_line_breaks (zarmour_t *self, bool line_breaks); // Get the line length used for splitting lines. size_t zarmour_line_length (zarmour_t *self); // Set the line length used for splitting lines. void zarmour_set_line_length (zarmour_t *self, size_t line_length); // Print properties of object void zarmour_print (zarmour_t *self); // Self test of this class. void zarmour_test (bool verbose); // CLASS: zcert // Create and initialize a new certificate in memory zcert_t * zcert_new (void); // Accepts public/secret key pair from caller zcert_t * zcert_new_from (const byte *public_key, const byte *secret_key); // Accepts public/secret key text pair from caller zcert_t * zcert_new_from_txt (const char *public_txt, const char *secret_txt); // Load certificate from file zcert_t * zcert_load (const char *filename); // Destroy a certificate in memory void zcert_destroy (zcert_t **self_p); // Return public part of key pair as 32-byte binary string const byte * zcert_public_key (zcert_t *self); // Return secret part of key pair as 32-byte binary string const byte * zcert_secret_key (zcert_t *self); // Return public part of key pair as Z85 armored string const char * zcert_public_txt (zcert_t *self); // Return secret part of key pair as Z85 armored string const char * zcert_secret_txt (zcert_t *self); // Set certificate metadata from formatted string. void zcert_set_meta (zcert_t *self, const char *name, const char *format, ...); // Unset certificate metadata. void zcert_unset_meta (zcert_t *self, const char *name); // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. const char * zcert_meta (zcert_t *self, const char *name); // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. zlist_t * zcert_meta_keys (zcert_t *self); // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). int zcert_save (zcert_t *self, const char *filename); // Save public certificate only to file for persistent storage int zcert_save_public (zcert_t *self, const char *filename); // Save secret certificate only to file for persistent storage int zcert_save_secret (zcert_t *self, const char *filename); // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. void zcert_apply (zcert_t *self, void *socket); // Return copy of certificate; if certificate is NULL or we exhausted // heap memory, returns NULL. zcert_t * zcert_dup (zcert_t *self); // Return true if two certificates have the same keys bool zcert_eq (zcert_t *self, zcert_t *compare); // Print certificate contents to stdout void zcert_print (zcert_t *self); // Self test of this class void zcert_test (bool verbose); // CLASS: zcertstore // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. zcertstore_t * zcertstore_new (const char *location); // Destroy a certificate store object in memory. Does not affect anything // stored on disk. void zcertstore_destroy (zcertstore_t **self_p); // Override the default disk loader with a custom loader fn. void zcertstore_set_loader (zcertstore_t *self, zcertstore_loader loader, zcertstore_destructor destructor, void *state); // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. zcert_t * zcertstore_lookup (zcertstore_t *self, const char *public_key); // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. void zcertstore_insert (zcertstore_t *self, zcert_t **cert_p); // Empty certificate hashtable. This wrapper exists to be friendly to bindings, // which don't usually have access to struct internals. void zcertstore_empty (zcertstore_t *self); // Print list of certificates in store to logging facility void zcertstore_print (zcertstore_t *self); // Return a list of all the certificates in the store. // The caller takes ownership of the zlistx_t object and is responsible // for destroying it. The caller does not take ownership of the zcert_t // objects. zlistx_t * zcertstore_certs (zcertstore_t *self); // Self test of this class void zcertstore_test (bool verbose); // CLASS: zchunk // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. zchunk_t * zchunk_new (const void *data, size_t size); // Destroy a chunk void zchunk_destroy (zchunk_t **self_p); // Resizes chunk max_size as requested; chunk_cur size is set to zero void zchunk_resize (zchunk_t *self, size_t size); // Return chunk cur size size_t zchunk_size (zchunk_t *self); // Return chunk max size size_t zchunk_max_size (zchunk_t *self); // Return chunk data byte * zchunk_data (zchunk_t *self); // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk size_t zchunk_set (zchunk_t *self, const void *data, size_t size); // Fill chunk data from user-supplied octet size_t zchunk_fill (zchunk_t *self, byte filler, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, it is truncated. If you want to // grow the chunk to accommodate new data, use the zchunk_extend method. size_t zchunk_append (zchunk_t *self, const void *data, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, the chunk grows in size. size_t zchunk_extend (zchunk_t *self, const void *data, size_t size); // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. size_t zchunk_consume (zchunk_t *self, zchunk_t *source); // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. bool zchunk_exhausted (zchunk_t *self); // Read chunk from an open file descriptor zchunk_t * zchunk_read (FILE *handle, size_t bytes); // Write chunk to an open file descriptor int zchunk_write (zchunk_t *self, FILE *handle); // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. zchunk_t * zchunk_slurp (const char *filename, size_t maxsize); // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // returns null. zchunk_t * zchunk_dup (zchunk_t *self); // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. char * zchunk_strhex (zchunk_t *self); // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. char * zchunk_strdup (zchunk_t *self); // Return TRUE if chunk body is equal to string, excluding terminator bool zchunk_streq (zchunk_t *self, const char *string); // Transform zchunk into a zframe that can be sent in a message. zframe_t * zchunk_pack (zchunk_t *self); // Transform a zframe into a zchunk. zchunk_t * zchunk_unpack (zframe_t *frame); // Calculate SHA1 digest for chunk, using zdigest class. const char * zchunk_digest (zchunk_t *self); // Dump chunk to FILE stream, for debugging and tracing. void zchunk_fprint (zchunk_t *self, FILE *file); // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details void zchunk_print (zchunk_t *self); // Probe the supplied object, and report if it looks like a zchunk_t. bool zchunk_is (void *self); // Self test of this class. void zchunk_test (bool verbose); // CLASS: zclock // Sleep for a number of milliseconds void zclock_sleep (int msecs); // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. int64_t zclock_time (void); // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t zclock_mono (void); // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t zclock_usecs (void); // Return formatted date/time as fresh string. Free using zstr_free(). char * zclock_timestr (void); // Self test of this class. void zclock_test (bool verbose); // CLASS: zconfig // Create new config item zconfig_t * zconfig_new (const char *name, zconfig_t *parent); // Destroy a config item and all its children void zconfig_destroy (zconfig_t **self_p); // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. zconfig_t * zconfig_load (const char *filename); // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. zconfig_t * zconfig_loadf (const char *format, ...); // Return name of config item char * zconfig_name (zconfig_t *self); // Return value of config item char * zconfig_value (zconfig_t *self); // Insert or update configuration key with value void zconfig_put (zconfig_t *self, const char *path, const char *value); // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. void zconfig_putf (zconfig_t *self, const char *path, const char *format, ...); // Get value for config item into a string value; leading slash is optional // and ignored. char * zconfig_get (zconfig_t *self, const char *path, const char *default_value); // Set config item name, name may be NULL void zconfig_set_name (zconfig_t *self, const char *name); // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. void zconfig_set_value (zconfig_t *self, const char *format, ...); // Find our first child, if any zconfig_t * zconfig_child (zconfig_t *self); // Find our first sibling, if any zconfig_t * zconfig_next (zconfig_t *self); // Find a config item along a path; leading slash is optional and ignored. zconfig_t * zconfig_locate (zconfig_t *self, const char *path); // Locate the last config item at a specified depth zconfig_t * zconfig_at_depth (zconfig_t *self, int level); // Execute a callback for each config item in the tree; returns zero if // successful, else -1. int zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg); // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. void zconfig_set_comment (zconfig_t *self, const char *format, ...); // Return comments of config item, as zlist. zlist_t * zconfig_comments (zconfig_t *self); // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. int zconfig_save (zconfig_t *self, const char *filename); // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. int zconfig_savef (zconfig_t *self, const char *format, ...); // Report filename used during zconfig_load, or NULL if none const char * zconfig_filename (zconfig_t *self); // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). int zconfig_reload (zconfig_t **self_p); // Load a config tree from a memory chunk zconfig_t * zconfig_chunk_load (zchunk_t *chunk); // Save a config tree to a new memory chunk zchunk_t * zconfig_chunk_save (zconfig_t *self); // Load a config tree from a null-terminated string zconfig_t * zconfig_str_load (const char *string); // Save a config tree to a new null terminated string char * zconfig_str_save (zconfig_t *self); // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. bool zconfig_has_changed (zconfig_t *self); // Destroy subtree (all children) void zconfig_remove_subtree (zconfig_t *self); // Destroy node and subtree (all children) void zconfig_remove (zconfig_t **self_p); // Print the config file to open stream void zconfig_fprint (zconfig_t *self, FILE *file); // Print properties of object void zconfig_print (zconfig_t *self); // Self test of this class void zconfig_test (bool verbose); // CLASS: zdigest // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. zdigest_t * zdigest_new (void); // Destroy a digest object void zdigest_destroy (zdigest_t **self_p); // Add buffer into digest calculation void zdigest_update (zdigest_t *self, const byte *buffer, size_t length); // Return final digest hash data. If built without crypto support, // returns NULL. const byte * zdigest_data (zdigest_t *self); // Return final digest hash size size_t zdigest_size (zdigest_t *self); // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. char * zdigest_string (zdigest_t *self); // Self test of this class. void zdigest_test (bool verbose); // CLASS: zdir // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. zdir_t * zdir_new (const char *path, const char *parent); // Destroy a directory tree and all children it contains. void zdir_destroy (zdir_t **self_p); // Return directory path const char * zdir_path (zdir_t *self); // Return last modification time for directory. time_t zdir_modified (zdir_t *self); // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. off_t zdir_cursize (zdir_t *self); // Return directory count size_t zdir_count (zdir_t *self); // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. zlist_t * zdir_list (zdir_t *self); // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. void zdir_remove (zdir_t *self, bool force); // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). zlist_t * zdir_diff (zdir_t *older, zdir_t *newer, const char *alias); // Return full contents of directory as a zdir_patch list. zlist_t * zdir_resync (zdir_t *self, const char *alias); // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. zhash_t * zdir_cache (zdir_t *self); // Print contents of directory to open stream void zdir_fprint (zdir_t *self, FILE *file, int indent); // Print contents of directory to stdout void zdir_print (zdir_t *self, int indent); // Create a new zdir_watch actor instance: // // zactor_t *watch = zactor_new (zdir_watch, NULL); // // Destroy zdir_watch instance: // // zactor_destroy (&watch); // // Enable verbose logging of commands and activity: // // zstr_send (watch, "VERBOSE"); // // Subscribe to changes to a directory path: // // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); // // Unsubscribe from changes to a directory path: // // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); // // Receive directory changes: // zsock_recv (watch, "sp", &path, &patches); // // // Delete the received data. // free (path); // zlist_destroy (&patches); void zdir_watch (zsock_t *pipe, void *unused); // Self test of this class. void zdir_test (bool verbose); // CLASS: zdir_patch // Create new patch zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, int op, const char *alias); // Destroy a patch void zdir_patch_destroy (zdir_patch_t **self_p); // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. zdir_patch_t * zdir_patch_dup (zdir_patch_t *self); // Return patch file directory path const char * zdir_patch_path (zdir_patch_t *self); // Return patch file item zfile_t * zdir_patch_file (zdir_patch_t *self); // Return operation int zdir_patch_op (zdir_patch_t *self); // Return patch virtual file path const char * zdir_patch_vpath (zdir_patch_t *self); // Calculate hash digest for file (create only) void zdir_patch_digest_set (zdir_patch_t *self); // Return hash digest for patch file const char * zdir_patch_digest (zdir_patch_t *self); // Self test of this class. void zdir_patch_test (bool verbose); // CLASS: zfile // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. zfile_t * zfile_new (const char *path, const char *name); // Create new temporary file for writing via tmpfile. File is automaticaly // deleted on destroy zfile_t * zfile_tmp (void); // Destroy a file item void zfile_destroy (zfile_t **self_p); // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. zfile_t * zfile_dup (zfile_t *self); // Return file name, remove path if provided const char * zfile_filename (zfile_t *self, const char *path); // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. void zfile_restat (zfile_t *self); // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. time_t zfile_modified (zfile_t *self); // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. off_t zfile_cursize (zfile_t *self); // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool zfile_is_directory (zfile_t *self); // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool zfile_is_regular (zfile_t *self); // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. bool zfile_is_readable (zfile_t *self); // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. bool zfile_is_writeable (zfile_t *self); // Check if file has stopped changing and can be safely processed. // Updates the file statistics from disk at every call. bool zfile_is_stable (zfile_t *self); // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. bool zfile_has_changed (zfile_t *self); // Remove the file from disk void zfile_remove (zfile_t *self); // Open file for reading // Returns 0 if OK, -1 if not found or not accessible int zfile_input (zfile_t *self); // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. int zfile_output (zfile_t *self); // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. zchunk_t * zfile_read (zfile_t *self, size_t bytes, off_t offset); // Returns true if zfile_read() just read the last chunk in the file. bool zfile_eof (zfile_t *self); // Write chunk to file at specified position // Return 0 if OK, else -1 int zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset); // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. const char * zfile_readln (zfile_t *self); // Close file, if open void zfile_close (zfile_t *self); // Return file handle, if opened FILE * zfile_handle (zfile_t *self); // Calculate SHA1 digest for file, using zdigest class. const char * zfile_digest (zfile_t *self); // Self test of this class. void zfile_test (bool verbose); // CLASS: zframe // Create a new frame. If size is not null, allocates the frame data // to the specified size. If additionally, data is not null, copies // size octets from the specified data into the frame body. zframe_t * zframe_new (const void *data, size_t size); // Destroy a frame void zframe_destroy (zframe_t **self_p); // Create an empty (zero-sized) frame zframe_t * zframe_new_empty (void); // Create a frame with a specified string content. zframe_t * zframe_from (const char *string); // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. zframe_t * zframe_recv (void *source); // Send a frame to a socket, destroy frame after sending. // Return -1 on error, 0 on success. int zframe_send (zframe_t **self_p, void *dest, int flags); // Return number of bytes in frame data size_t zframe_size (zframe_t *self); // Return address of frame data byte * zframe_data (zframe_t *self); // Return meta data property for frame // The caller shall not modify or free the returned value, which shall be // owned by the message. const char * zframe_meta (zframe_t *self, const char *property); // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. zframe_t * zframe_dup (zframe_t *self); // Return frame data encoded as printable hex string, useful for 0MQ UUIDs. // Caller must free string when finished with it. char * zframe_strhex (zframe_t *self); // Return frame data copied into freshly allocated string // Caller must free string when finished with it. char * zframe_strdup (zframe_t *self); // Return TRUE if frame body is equal to string, excluding terminator bool zframe_streq (zframe_t *self, const char *string); // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method int zframe_more (zframe_t *self); // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. void zframe_set_more (zframe_t *self, int more); // Return frame routing ID, if the frame came from a ZMQ_SERVER socket. // Else returns zero. uint32_t zframe_routing_id (zframe_t *self); // Set routing ID on frame. This is used if/when the frame is sent to a // ZMQ_SERVER socket. void zframe_set_routing_id (zframe_t *self, uint32_t routing_id); // Return frame group of radio-dish pattern. const char * zframe_group (zframe_t *self); // Set group on frame. This is used if/when the frame is sent to a // ZMQ_RADIO socket. // Return -1 on error, 0 on success. int zframe_set_group (zframe_t *self, const char *group); // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false. bool zframe_eq (zframe_t *self, zframe_t *other); // Set new contents for frame void zframe_reset (zframe_t *self, const void *data, size_t size); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. void zframe_print (zframe_t *self, const char *prefix); // Probe the supplied object, and report if it looks like a zframe_t. bool zframe_is (void *self); // Self test of this class. void zframe_test (bool verbose); // CLASS: zhash // Create a new, empty hash container zhash_t * zhash_new (void); // Destroy a hash container and all items in it void zhash_destroy (zhash_t **self_p); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. zhash_t * zhash_unpack (zframe_t *frame); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int zhash_insert (zhash_t *self, const char *key, void *item); // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. void zhash_update (zhash_t *self, const char *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void zhash_delete (zhash_t *self, const char *key); // Return the item at the specified key, or null void * zhash_lookup (zhash_t *self, const char *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int zhash_rename (zhash_t *self, const char *old_key, const char *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn); // Return the number of keys/items in the hash table size_t zhash_size (zhash_t *self); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. zhash_t * zhash_dup (zhash_t *self); // Return keys for items in table zlist_t * zhash_keys (zhash_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhash_cursor(). NOTE: do NOT modify the table while iterating. void * zhash_first (zhash_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). To // access the key for this item use zhash_cursor(). NOTE: do NOT modify // the table while iterating. void * zhash_next (zhash_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const char * zhash_cursor (zhash_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void zhash_comment (zhash_t *self, const char *format, ...); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. zframe_t * zhash_pack (zhash_t *self); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int zhash_save (zhash_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int zhash_load (zhash_t *self, const char *filename); // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int zhash_refresh (zhash_t *self); // Set hash for automatic value destruction. Note that this assumes that // values are NULL-terminated strings. Do not use with different types. void zhash_autofree (zhash_t *self); // Self test of this class. void zhash_test (bool verbose); // CLASS: zhashx // Create a new, empty hash container zhashx_t * zhashx_new (void); // Destroy a hash container and all items in it void zhashx_destroy (zhashx_t **self_p); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. zhashx_t * zhashx_unpack (zframe_t *frame); // Same as unpack but uses a user-defined deserializer function to convert // a longstr back into item format. zhashx_t * zhashx_unpack_own (zframe_t *frame, zhashx_deserializer_fn deserializer); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int zhashx_insert (zhashx_t *self, const void *key, void *item); // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. void zhashx_update (zhashx_t *self, const void *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void zhashx_delete (zhashx_t *self, const void *key); // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. void zhashx_purge (zhashx_t *self); // Return the item at the specified key, or null void * zhashx_lookup (zhashx_t *self, const void *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn free_fn); // Return the number of keys/items in the hash table size_t zhashx_size (zhashx_t *self); // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. zlistx_t * zhashx_keys (zhashx_t *self); // Return a zlistx_t containing the values for the items in the // table. Uses the duplicator to duplicate all items and sets the // destructor as destructor for the list. zlistx_t * zhashx_values (zhashx_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhashx_cursor(). NOTE: do NOT modify the table while iterating. void * zhashx_first (zhashx_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). To // access the key for this item use zhashx_cursor(). NOTE: do NOT modify // the table while iterating. void * zhashx_next (zhashx_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const void * zhashx_cursor (zhashx_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void zhashx_comment (zhashx_t *self, const char *format, ...); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int zhashx_save (zhashx_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int zhashx_load (zhashx_t *self, const char *filename); // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int zhashx_refresh (zhashx_t *self); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. zframe_t * zhashx_pack (zhashx_t *self); // Same as pack but uses a user-defined serializer function to convert items // into longstr. zframe_t * zhashx_pack_own (zhashx_t *self, zhashx_serializer_fn serializer); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. zhashx_t * zhashx_dup (zhashx_t *self); // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. void zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. void zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined deallocator for keys; by default keys are freed // when the hash is destroyed using free(). void zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for keys; by default keys are duplicated // using strdup. void zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined comparator for keys; by default keys are // compared using strcmp. // The callback function should return zero (0) on matching // items. void zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator); // Set a user-defined hash function for keys; by default keys are // hashed by a modified Bernstein hashing function. void zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. zhashx_t * zhashx_dup_v2 (zhashx_t *self); // Self test of this class. void zhashx_test (bool verbose); // CLASS: ziflist // Get a list of network interfaces currently defined on the system ziflist_t * ziflist_new (void); // Destroy a ziflist instance void ziflist_destroy (ziflist_t **self_p); // Reload network interfaces from system void ziflist_reload (ziflist_t *self); // Return the number of network interfaces on system size_t ziflist_size (ziflist_t *self); // Get first network interface, return NULL if there are none const char * ziflist_first (ziflist_t *self); // Get next network interface, return NULL if we hit the last one const char * ziflist_next (ziflist_t *self); // Return the current interface IP address as a printable string const char * ziflist_address (ziflist_t *self); // Return the current interface broadcast address as a printable string const char * ziflist_broadcast (ziflist_t *self); // Return the current interface network mask as a printable string const char * ziflist_netmask (ziflist_t *self); // Return the list of interfaces. void ziflist_print (ziflist_t *self); // Get a list of network interfaces currently defined on the system // Includes IPv6 interfaces ziflist_t * ziflist_new_ipv6 (void); // Reload network interfaces from system, including IPv6 void ziflist_reload_ipv6 (ziflist_t *self); // Return true if the current interface uses IPv6 bool ziflist_is_ipv6 (ziflist_t *self); // Self test of this class. void ziflist_test (bool verbose); // CLASS: zlist // Create a new list container zlist_t * zlist_new (void); // Destroy a list container void zlist_destroy (zlist_t **self_p); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * zlist_first (zlist_t *self); // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. void * zlist_next (zlist_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * zlist_last (zlist_t *self); // Return first item in the list, or null, leaves the cursor void * zlist_head (zlist_t *self); // Return last item in the list, or null, leaves the cursor void * zlist_tail (zlist_t *self); // Return the current item of list. If the list is empty, returns NULL. // Leaves cursor pointing at the current item, or NULL if the list is empty. void * zlist_item (zlist_t *self); // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int zlist_append (zlist_t *self, void *item); // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int zlist_push (zlist_t *self, void *item); // Pop the item off the start of the list, if any void * zlist_pop (zlist_t *self); // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. bool zlist_exists (zlist_t *self, void *item); // Remove the specified item from the list if present void zlist_remove (zlist_t *self, void *item); // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. zlist_t * zlist_dup (zlist_t *self); // Purge all items from list void zlist_purge (zlist_t *self); // Return number of items in the list size_t zlist_size (zlist_t *self); // Sort the list. If the compare function is null, sorts the list by // ascending key value using a straight ASCII comparison. If you specify // a compare function, this decides how items are sorted. The sort is not // stable, so may reorder items with the same keys. The algorithm used is // combsort, a compromise between performance and simplicity. void zlist_sort (zlist_t *self, zlist_compare_fn compare); // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. void zlist_autofree (zlist_t *self); // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. void zlist_comparefn (zlist_t *self, zlist_compare_fn fn); // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zlist_freefn (zlist_t *self, void *item, zlist_free_fn fn, bool at_tail); // Self test of this class. void zlist_test (bool verbose); // CLASS: zlistx // Create a new, empty list. zlistx_t * zlistx_new (void); // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. void zlistx_destroy (zlistx_t **self_p); // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void * zlistx_add_start (zlistx_t *self, void *item); // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void * zlistx_add_end (zlistx_t *self, void *item); // Return the number of items in the list size_t zlistx_size (zlistx_t *self); // Return first item in the list, or null, leaves the cursor void * zlistx_head (zlistx_t *self); // Return last item in the list, or null, leaves the cursor void * zlistx_tail (zlistx_t *self); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * zlistx_first (zlistx_t *self); // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). void * zlistx_next (zlistx_t *self); // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). void * zlistx_prev (zlistx_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * zlistx_last (zlistx_t *self); // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * zlistx_item (zlistx_t *self); // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * zlistx_cursor (zlistx_t *self); // Returns the item associated with the given list handle, or NULL if passed // in handle is NULL. Asserts that the passed in handle points to a list element. void * zlistx_handle_item (void *handle); // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. void * zlistx_find (zlistx_t *self, void *item); // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. void * zlistx_detach (zlistx_t *self, void *handle); // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. void * zlistx_detach_cur (zlistx_t *self); // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. int zlistx_delete (zlistx_t *self, void *handle); // Move an item to the start of the list, via its handle. void zlistx_move_start (zlistx_t *self, void *handle); // Move an item to the end of the list, via its handle. void zlistx_move_end (zlistx_t *self, void *handle); // Remove all items from the list, and destroy them if the item destructor // is set. void zlistx_purge (zlistx_t *self); // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. void zlistx_sort (zlistx_t *self); // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. void * zlistx_insert (zlistx_t *self, void *item, bool low_value); // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. void zlistx_reorder (zlistx_t *self, void *handle, bool low_value); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. zlistx_t * zlistx_dup (zlistx_t *self); // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. void zlistx_set_destructor (zlistx_t *self, zlistx_destructor_fn destructor); // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. void zlistx_set_duplicator (zlistx_t *self, zlistx_duplicator_fn duplicator); // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. void zlistx_set_comparator (zlistx_t *self, zlistx_comparator_fn comparator); // Self test of this class. void zlistx_test (bool verbose); // CLASS: zloop // Create a new zloop reactor zloop_t * zloop_new (void); // Destroy a reactor void zloop_destroy (zloop_t **self_p); // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. int zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg); // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. void zloop_reader_end (zloop_t *self, zsock_t *sock); // Configure a registered reader to ignore errors. If you do not set this, // then readers that have errors are removed from the reactor silently. void zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock); // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. int zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg); // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. void zloop_poller_end (zloop_t *self, zmq_pollitem_t *item); // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. void zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item); // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. int zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg); // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer). int zloop_timer_end (zloop_t *self, int timer_id); // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. void * zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg); // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. void zloop_ticket_reset (zloop_t *self, void *handle); // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. void zloop_ticket_delete (zloop_t *self, void *handle); // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. void zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay); // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. void zloop_set_max_timers (zloop_t *self, size_t max_timers); // Set verbose tracing of reactor on/off. The default verbose setting is // off (false). void zloop_set_verbose (zloop_t *self, bool verbose); // By default the reactor stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void zloop_set_nonstop (zloop_t *self, bool nonstop); // Start the reactor. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. int zloop_start (zloop_t *self); // Self test of this class. void zloop_test (bool verbose); // CLASS: zmsg // Create a new empty message object zmsg_t * zmsg_new (void); // Destroy a message object and all frames it contains void zmsg_destroy (zmsg_t **self_p); // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted. Does a blocking recv. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving. zmsg_t * zmsg_recv (void *source); // Load/append an open file into new message, return the message. // Returns NULL if the message could not be loaded. zmsg_t * zmsg_load (FILE *file); // Decodes a serialized message frame created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the frame was badly formatted or // there was insufficient memory to work. zmsg_t * zmsg_decode (zframe_t *frame); // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. zmsg_t * zmsg_new_signal (byte status); // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int zmsg_send (zmsg_t **self_p, void *dest); // Send message to destination socket as part of a multipart sequence, and // destroy the message after sending it successfully. Note that after a // zmsg_sendm, you must call zmsg_send or another method that sends a final // message part. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int zmsg_sendm (zmsg_t **self_p, void *dest); // Return size of message, i.e. number of frames (0 or more). size_t zmsg_size (zmsg_t *self); // Return total size of all frames in message. size_t zmsg_content_size (zmsg_t *self); // Return message routing ID, if the message came from a ZMQ_SERVER socket. // Else returns zero. uint32_t zmsg_routing_id (zmsg_t *self); // Set routing ID on message. This is used if/when the message is sent to a // ZMQ_SERVER socket. void zmsg_set_routing_id (zmsg_t *self, uint32_t routing_id); // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. int zmsg_prepend (zmsg_t *self, zframe_t **frame_p); // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Deprecates zmsg_add, which did not nullify the // caller's frame reference. int zmsg_append (zmsg_t *self, zframe_t **frame_p); // Remove first frame from message, if any. Returns frame, or NULL. zframe_t * zmsg_pop (zmsg_t *self); // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. int zmsg_pushmem (zmsg_t *self, const void *data, size_t size); // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. int zmsg_addmem (zmsg_t *self, const void *data, size_t size); // Push string as new frame to front of message. // Returns 0 on success, -1 on error. int zmsg_pushstr (zmsg_t *self, const char *string); // Push string as new frame to end of message. // Returns 0 on success, -1 on error. int zmsg_addstr (zmsg_t *self, const char *string); // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. int zmsg_pushstrf (zmsg_t *self, const char *format, ...); // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. int zmsg_addstrf (zmsg_t *self, const char *format, ...); // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. char * zmsg_popstr (zmsg_t *self); // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. int zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p); // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not successful. zmsg_t * zmsg_popmsg (zmsg_t *self); // Remove specified frame from list, if present. Does not destroy frame. void zmsg_remove (zmsg_t *self, zframe_t *frame); // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. zframe_t * zmsg_first (zmsg_t *self); // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. zframe_t * zmsg_next (zmsg_t *self); // Return the last frame. If there are no frames, returns NULL. zframe_t * zmsg_last (zmsg_t *self); // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. int zmsg_save (zmsg_t *self, FILE *file); // Serialize multipart message to a single message frame. Use this method // to send structured messages across transports that do not support // multipart data. Allocates and returns a new frame containing the // serialized message. To decode a serialized message frame, use // zmsg_decode (). zframe_t * zmsg_encode (zmsg_t *self); // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. zmsg_t * zmsg_dup (zmsg_t *self); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). void zmsg_print (zmsg_t *self); // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. bool zmsg_eq (zmsg_t *self, zmsg_t *other); // Return signal value, 0 or greater, if message is a signal, -1 if not. int zmsg_signal (zmsg_t *self); // Probe the supplied object, and report if it looks like a zmsg_t. bool zmsg_is (void *self); // Self test of this class. void zmsg_test (bool verbose); // CLASS: zpoller // Create new poller, specifying zero or more readers. The list of // readers ends in a NULL. Each reader can be a zsock_t instance, a // zactor_t instance, a libzmq socket (void *), or a file handle. zpoller_t * zpoller_new (void *reader, ...); // Destroy a poller void zpoller_destroy (zpoller_t **self_p); // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. int zpoller_add (zpoller_t *self, void *reader); // Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader // must have been passed during construction, or in an zpoller_add () call. int zpoller_remove (zpoller_t *self, void *reader); // By default the poller stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void zpoller_set_nonstop (zpoller_t *self, bool nonstop); // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. void * zpoller_wait (zpoller_t *self, int timeout); // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. bool zpoller_expired (zpoller_t *self); // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. bool zpoller_terminated (zpoller_t *self); // Self test of this class. void zpoller_test (bool verbose); // CLASS: zproc // Create a new zproc. // NOTE: On Windows and with libzmq3 and libzmq2 this function // returns NULL. Code needs to be ported there. zproc_t * zproc_new (void); // Destroy zproc, wait until process ends. void zproc_destroy (zproc_t **self_p); // Setup the command line arguments, the first item must be an (absolute) filename // to run. void zproc_set_args (zproc_t *self, zlistx_t *args); // Setup the environment variables for the process. void zproc_set_env (zproc_t *self, zhashx_t *args); // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The writable one is then accessbile via zproc_stdin method. void zproc_set_stdin (zproc_t *self, void *socket); // Connects process stdout with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stdout method. void zproc_set_stdout (zproc_t *self, void *socket); // Connects process stderr with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stderr method. void zproc_set_stderr (zproc_t *self, void *socket); // Return subprocess stdin writable socket. NULL for // not initialized or external sockets. void * zproc_stdin (zproc_t *self); // Return subprocess stdout readable socket. NULL for // not initialized or external sockets. void * zproc_stdout (zproc_t *self); // Return subprocess stderr readable socket. NULL for // not initialized or external sockets. void * zproc_stderr (zproc_t *self); // Starts the process. int zproc_run (zproc_t *self); // process exit code int zproc_returncode (zproc_t *self); // PID of the process int zproc_pid (zproc_t *self); // return true if process is running, false if not yet started or finished bool zproc_running (zproc_t *self); // wait or poll process status, return return code int zproc_wait (zproc_t *self, bool hang); // return internal actor, usefull for the polling if process died void * zproc_actor (zproc_t *self); // send a signal to the subprocess void zproc_kill (zproc_t *self, int signal); // set verbose mode void zproc_set_verbose (zproc_t *self, bool verbose); // Returns CZMQ version as a single 6-digit integer encoding the major // version (x 10000), the minor version (x 100) and the patch. int zproc_czmq_version (void); // Returns true if the process received a SIGINT or SIGTERM signal. // It is good practice to use this method to exit any infinite loop // processing messages. bool zproc_interrupted (void); // Returns true if the underlying libzmq supports CURVE security. bool zproc_has_curve (void); // Return current host name, for use in public tcp:// endpoints. // If the host name is not resolvable, returns NULL. char * zproc_hostname (void); // Move the current process into the background. The precise effect // depends on the operating system. On POSIX boxes, moves to a specified // working directory (if specified), closes all file handles, reopens // stdin, stdout, and stderr to the null device, and sets the process to // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there // was an error. void zproc_daemonize (const char *workdir); // Drop the process ID into the lockfile, with exclusive lock, and // switch the process to the specified group and/or user. Any of the // arguments may be null, indicating a no-op. Returns 0 on success, // -1 on failure. Note if you combine this with zsys_daemonize, run // after, not before that method, or the lockfile will hold the wrong // process ID. void zproc_run_as (const char *lockfile, const char *group, const char *user); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void zproc_set_io_threads (size_t io_threads); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void zproc_set_max_sockets (size_t max_sockets); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void zproc_set_biface (const char *value); // Return network interface to use for broadcasts, or "" if none was set. const char * zproc_biface (void); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void zproc_set_log_ident (const char *value); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void zproc_set_log_sender (const char *endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void zproc_set_log_system (bool logsystem); // Log error condition - highest priority void zproc_log_error (const char *format, ...); // Log warning condition - high priority void zproc_log_warning (const char *format, ...); // Log normal, but significant, condition - normal priority void zproc_log_notice (const char *format, ...); // Log informational message - low priority void zproc_log_info (const char *format, ...); // Log debug-level message - lowest priority void zproc_log_debug (const char *format, ...); // Self test of this class. void zproc_test (bool verbose); // CLASS: zsock // Create a new socket. Returns the new socket, or NULL if the new socket // could not be created. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection. This can have // performance implications if you use a LOT of sockets. To turn off this // redirection behaviour, define ZSOCK_NOCHECK. zsock_t * zsock_new (int type); // Destroy the socket. You must use this for any socket created via the // zsock_new method. void zsock_destroy (zsock_t **self_p); // Create a PUB socket. Default action is bind. zsock_t * zsock_new_pub (const char *endpoint); // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. zsock_t * zsock_new_sub (const char *endpoint, const char *subscribe); // Create a REQ socket. Default action is connect. zsock_t * zsock_new_req (const char *endpoint); // Create a REP socket. Default action is bind. zsock_t * zsock_new_rep (const char *endpoint); // Create a DEALER socket. Default action is connect. zsock_t * zsock_new_dealer (const char *endpoint); // Create a ROUTER socket. Default action is bind. zsock_t * zsock_new_router (const char *endpoint); // Create a PUSH socket. Default action is connect. zsock_t * zsock_new_push (const char *endpoint); // Create a PULL socket. Default action is bind. zsock_t * zsock_new_pull (const char *endpoint); // Create an XPUB socket. Default action is bind. zsock_t * zsock_new_xpub (const char *endpoint); // Create an XSUB socket. Default action is connect. zsock_t * zsock_new_xsub (const char *endpoint); // Create a PAIR socket. Default action is connect. zsock_t * zsock_new_pair (const char *endpoint); // Create a STREAM socket. Default action is connect. zsock_t * zsock_new_stream (const char *endpoint); // Create a SERVER socket. Default action is bind. zsock_t * zsock_new_server (const char *endpoint); // Create a CLIENT socket. Default action is connect. zsock_t * zsock_new_client (const char *endpoint); // Create a RADIO socket. Default action is bind. zsock_t * zsock_new_radio (const char *endpoint); // Create a DISH socket. Default action is connect. zsock_t * zsock_new_dish (const char *endpoint); // Create a GATHER socket. Default action is bind. zsock_t * zsock_new_gather (const char *endpoint); // Create a SCATTER socket. Default action is connect. zsock_t * zsock_new_scatter (const char *endpoint); // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. int zsock_bind (zsock_t *self, const char *format, ...); // Returns last bound endpoint, if any. const char * zsock_endpoint (zsock_t *self); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int zsock_unbind (zsock_t *self, const char *format, ...); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. int zsock_connect (zsock_t *self, const char *format, ...); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int zsock_disconnect (zsock_t *self, const char *format, ...); // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). int zsock_attach (zsock_t *self, const char *endpoints, bool serverish); // Returns socket type as printable constant string. const char * zsock_type_str (zsock_t *self); // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. int zsock_send (void *self, const char *picture, ...); // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. int zsock_vsend (void *self, const char *picture, va_list argptr); // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // U = zuuid_t * (creates a zuuid with the data) // h = zhashx_t ** (creates zhashx) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. int zsock_recv (void *self, const char *picture, ...); // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. int zsock_vrecv (void *self, const char *picture, va_list argptr); // Send a binary encoded 'picture' message to the socket (or actor). This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations. The pattern argument is a string that defines the // type of each argument. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0-255 chars type = "string" // S char *, 0-2^32-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // u zuuid_t * type = "uuid" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments. Returns 0 if // successful, -1 if sending failed for any reason. int zsock_bsend (void *self, const char *picture, ...); // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. // For types 1, 2, 4 and 8 the caller must allocate the memory itself before // calling zsock_brecv. // For types S, the caller must free the value once finished with it, as // zsock_brecv will allocate the buffer. // For type s, the caller must not free the value as it is stored in a // local cache for performance purposes. // For types c, f, u and m the caller must call the appropriate destructor // depending on the object as zsock_brecv will create new objects. // For type p the caller must coordinate with the sender, as it is just a // pointer value being passed. int zsock_brecv (void *self, const char *picture, ...); // Return socket routing ID if any. This returns 0 if the socket is not // of type ZMQ_SERVER or if no request was already received on it. uint32_t zsock_routing_id (zsock_t *self); // Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. // This will be used when sending messages on the socket via the zsock API. void zsock_set_routing_id (zsock_t *self, uint32_t routing_id); // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. void zsock_set_unbounded (void *self); // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zsock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. int zsock_signal (void *self, byte status); // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. int zsock_wait (void *self); // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. void zsock_flush (void *self); // Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int zsock_join (void *self, const char *group); // Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int zsock_leave (void *self, const char *group); // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. bool zsock_is (void *self); // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. void * zsock_resolve (void *self); // Get socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. int zsock_heartbeat_ivl (void *self); // Set socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. void zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl); // Get socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. int zsock_heartbeat_ttl (void *self); // Set socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. void zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl); // Get socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. int zsock_heartbeat_timeout (void *self); // Set socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. void zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout); // Get socket option `use_fd`. // Available from libzmq 4.2.0. int zsock_use_fd (void *self); // Set socket option `use_fd`. // Available from libzmq 4.2.0. void zsock_set_use_fd (void *self, int use_fd); // Set socket option `xpub_manual`. // Available from libzmq 4.2.0. void zsock_set_xpub_manual (void *self, int xpub_manual); // Set socket option `xpub_welcome_msg`. // Available from libzmq 4.2.0. void zsock_set_xpub_welcome_msg (void *self, const char *xpub_welcome_msg); // Set socket option `stream_notify`. // Available from libzmq 4.2.0. void zsock_set_stream_notify (void *self, int stream_notify); // Get socket option `invert_matching`. // Available from libzmq 4.2.0. int zsock_invert_matching (void *self); // Set socket option `invert_matching`. // Available from libzmq 4.2.0. void zsock_set_invert_matching (void *self, int invert_matching); // Set socket option `xpub_verboser`. // Available from libzmq 4.2.0. void zsock_set_xpub_verboser (void *self, int xpub_verboser); // Get socket option `connect_timeout`. // Available from libzmq 4.2.0. int zsock_connect_timeout (void *self); // Set socket option `connect_timeout`. // Available from libzmq 4.2.0. void zsock_set_connect_timeout (void *self, int connect_timeout); // Get socket option `tcp_maxrt`. // Available from libzmq 4.2.0. int zsock_tcp_maxrt (void *self); // Set socket option `tcp_maxrt`. // Available from libzmq 4.2.0. void zsock_set_tcp_maxrt (void *self, int tcp_maxrt); // Get socket option `thread_safe`. // Available from libzmq 4.2.0. int zsock_thread_safe (void *self); // Get socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. int zsock_multicast_maxtpdu (void *self); // Set socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. void zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu); // Get socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. int zsock_vmci_buffer_size (void *self); // Set socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. void zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size); // Get socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. int zsock_vmci_buffer_min_size (void *self); // Set socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. void zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size); // Get socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. int zsock_vmci_buffer_max_size (void *self); // Set socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. void zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size); // Get socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. int zsock_vmci_connect_timeout (void *self); // Set socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. void zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout); // Get socket option `tos`. // Available from libzmq 4.1.0. int zsock_tos (void *self); // Set socket option `tos`. // Available from libzmq 4.1.0. void zsock_set_tos (void *self, int tos); // Set socket option `router_handover`. // Available from libzmq 4.1.0. void zsock_set_router_handover (void *self, int router_handover); // Set socket option `connect_rid`. // Available from libzmq 4.1.0. void zsock_set_connect_rid (void *self, const char *connect_rid); // Set socket option `connect_rid` from 32-octet binary // Available from libzmq 4.1.0. void zsock_set_connect_rid_bin (void *self, const byte *connect_rid); // Get socket option `handshake_ivl`. // Available from libzmq 4.1.0. int zsock_handshake_ivl (void *self); // Set socket option `handshake_ivl`. // Available from libzmq 4.1.0. void zsock_set_handshake_ivl (void *self, int handshake_ivl); // Get socket option `socks_proxy`. // Available from libzmq 4.1.0. char * zsock_socks_proxy (void *self); // Set socket option `socks_proxy`. // Available from libzmq 4.1.0. void zsock_set_socks_proxy (void *self, const char *socks_proxy); // Set socket option `xpub_nodrop`. // Available from libzmq 4.1.0. void zsock_set_xpub_nodrop (void *self, int xpub_nodrop); // Set socket option `router_mandatory`. // Available from libzmq 4.0.0. void zsock_set_router_mandatory (void *self, int router_mandatory); // Set socket option `probe_router`. // Available from libzmq 4.0.0. void zsock_set_probe_router (void *self, int probe_router); // Set socket option `req_relaxed`. // Available from libzmq 4.0.0. void zsock_set_req_relaxed (void *self, int req_relaxed); // Set socket option `req_correlate`. // Available from libzmq 4.0.0. void zsock_set_req_correlate (void *self, int req_correlate); // Set socket option `conflate`. // Available from libzmq 4.0.0. void zsock_set_conflate (void *self, int conflate); // Get socket option `zap_domain`. // Available from libzmq 4.0.0. char * zsock_zap_domain (void *self); // Set socket option `zap_domain`. // Available from libzmq 4.0.0. void zsock_set_zap_domain (void *self, const char *zap_domain); // Get socket option `mechanism`. // Available from libzmq 4.0.0. int zsock_mechanism (void *self); // Get socket option `plain_server`. // Available from libzmq 4.0.0. int zsock_plain_server (void *self); // Set socket option `plain_server`. // Available from libzmq 4.0.0. void zsock_set_plain_server (void *self, int plain_server); // Get socket option `plain_username`. // Available from libzmq 4.0.0. char * zsock_plain_username (void *self); // Set socket option `plain_username`. // Available from libzmq 4.0.0. void zsock_set_plain_username (void *self, const char *plain_username); // Get socket option `plain_password`. // Available from libzmq 4.0.0. char * zsock_plain_password (void *self); // Set socket option `plain_password`. // Available from libzmq 4.0.0. void zsock_set_plain_password (void *self, const char *plain_password); // Get socket option `curve_server`. // Available from libzmq 4.0.0. int zsock_curve_server (void *self); // Set socket option `curve_server`. // Available from libzmq 4.0.0. void zsock_set_curve_server (void *self, int curve_server); // Get socket option `curve_publickey`. // Available from libzmq 4.0.0. char * zsock_curve_publickey (void *self); // Set socket option `curve_publickey`. // Available from libzmq 4.0.0. void zsock_set_curve_publickey (void *self, const char *curve_publickey); // Set socket option `curve_publickey` from 32-octet binary // Available from libzmq 4.0.0. void zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey); // Get socket option `curve_secretkey`. // Available from libzmq 4.0.0. char * zsock_curve_secretkey (void *self); // Set socket option `curve_secretkey`. // Available from libzmq 4.0.0. void zsock_set_curve_secretkey (void *self, const char *curve_secretkey); // Set socket option `curve_secretkey` from 32-octet binary // Available from libzmq 4.0.0. void zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey); // Get socket option `curve_serverkey`. // Available from libzmq 4.0.0. char * zsock_curve_serverkey (void *self); // Set socket option `curve_serverkey`. // Available from libzmq 4.0.0. void zsock_set_curve_serverkey (void *self, const char *curve_serverkey); // Set socket option `curve_serverkey` from 32-octet binary // Available from libzmq 4.0.0. void zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey); // Get socket option `gssapi_server`. // Available from libzmq 4.0.0. int zsock_gssapi_server (void *self); // Set socket option `gssapi_server`. // Available from libzmq 4.0.0. void zsock_set_gssapi_server (void *self, int gssapi_server); // Get socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. int zsock_gssapi_plaintext (void *self); // Set socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. void zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext); // Get socket option `gssapi_principal`. // Available from libzmq 4.0.0. char * zsock_gssapi_principal (void *self); // Set socket option `gssapi_principal`. // Available from libzmq 4.0.0. void zsock_set_gssapi_principal (void *self, const char *gssapi_principal); // Get socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. char * zsock_gssapi_service_principal (void *self); // Set socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. void zsock_set_gssapi_service_principal (void *self, const char *gssapi_service_principal); // Get socket option `ipv6`. // Available from libzmq 4.0.0. int zsock_ipv6 (void *self); // Set socket option `ipv6`. // Available from libzmq 4.0.0. void zsock_set_ipv6 (void *self, int ipv6); // Get socket option `immediate`. // Available from libzmq 4.0.0. int zsock_immediate (void *self); // Set socket option `immediate`. // Available from libzmq 4.0.0. void zsock_set_immediate (void *self, int immediate); // Get socket option `sndhwm`. // Available from libzmq 3.0.0. int zsock_sndhwm (void *self); // Set socket option `sndhwm`. // Available from libzmq 3.0.0. void zsock_set_sndhwm (void *self, int sndhwm); // Get socket option `rcvhwm`. // Available from libzmq 3.0.0. int zsock_rcvhwm (void *self); // Set socket option `rcvhwm`. // Available from libzmq 3.0.0. void zsock_set_rcvhwm (void *self, int rcvhwm); // Get socket option `maxmsgsize`. // Available from libzmq 3.0.0. int zsock_maxmsgsize (void *self); // Set socket option `maxmsgsize`. // Available from libzmq 3.0.0. void zsock_set_maxmsgsize (void *self, int maxmsgsize); // Get socket option `multicast_hops`. // Available from libzmq 3.0.0. int zsock_multicast_hops (void *self); // Set socket option `multicast_hops`. // Available from libzmq 3.0.0. void zsock_set_multicast_hops (void *self, int multicast_hops); // Set socket option `xpub_verbose`. // Available from libzmq 3.0.0. void zsock_set_xpub_verbose (void *self, int xpub_verbose); // Get socket option `tcp_keepalive`. // Available from libzmq 3.0.0. int zsock_tcp_keepalive (void *self); // Set socket option `tcp_keepalive`. // Available from libzmq 3.0.0. void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); // Get socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. int zsock_tcp_keepalive_idle (void *self); // Set socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); // Get socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. int zsock_tcp_keepalive_cnt (void *self); // Set socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); // Get socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. int zsock_tcp_keepalive_intvl (void *self); // Set socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); // Get socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. char * zsock_tcp_accept_filter (void *self); // Set socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. void zsock_set_tcp_accept_filter (void *self, const char *tcp_accept_filter); // Get socket option `last_endpoint`. // Available from libzmq 3.0.0. char * zsock_last_endpoint (void *self); // Set socket option `router_raw`. // Available from libzmq 3.0.0. void zsock_set_router_raw (void *self, int router_raw); // Get socket option `ipv4only`. // Available from libzmq 3.0.0. int zsock_ipv4only (void *self); // Set socket option `ipv4only`. // Available from libzmq 3.0.0. void zsock_set_ipv4only (void *self, int ipv4only); // Set socket option `delay_attach_on_connect`. // Available from libzmq 3.0.0. void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); // Get socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. int zsock_hwm (void *self); // Set socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. void zsock_set_hwm (void *self, int hwm); // Get socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. int zsock_swap (void *self); // Set socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. void zsock_set_swap (void *self, int swap); // Get socket option `affinity`. // Available from libzmq 2.0.0. int zsock_affinity (void *self); // Set socket option `affinity`. // Available from libzmq 2.0.0. void zsock_set_affinity (void *self, int affinity); // Get socket option `identity`. // Available from libzmq 2.0.0. char * zsock_identity (void *self); // Set socket option `identity`. // Available from libzmq 2.0.0. void zsock_set_identity (void *self, const char *identity); // Get socket option `rate`. // Available from libzmq 2.0.0. int zsock_rate (void *self); // Set socket option `rate`. // Available from libzmq 2.0.0. void zsock_set_rate (void *self, int rate); // Get socket option `recovery_ivl`. // Available from libzmq 2.0.0. int zsock_recovery_ivl (void *self); // Set socket option `recovery_ivl`. // Available from libzmq 2.0.0. void zsock_set_recovery_ivl (void *self, int recovery_ivl); // Get socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. int zsock_recovery_ivl_msec (void *self); // Set socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. void zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec); // Get socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. int zsock_mcast_loop (void *self); // Set socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. void zsock_set_mcast_loop (void *self, int mcast_loop); // Get socket option `rcvtimeo`. // Available from libzmq 2.2.0. int zsock_rcvtimeo (void *self); // Set socket option `rcvtimeo`. // Available from libzmq 2.2.0. void zsock_set_rcvtimeo (void *self, int rcvtimeo); // Get socket option `sndtimeo`. // Available from libzmq 2.2.0. int zsock_sndtimeo (void *self); // Set socket option `sndtimeo`. // Available from libzmq 2.2.0. void zsock_set_sndtimeo (void *self, int sndtimeo); // Get socket option `sndbuf`. // Available from libzmq 2.0.0. int zsock_sndbuf (void *self); // Set socket option `sndbuf`. // Available from libzmq 2.0.0. void zsock_set_sndbuf (void *self, int sndbuf); // Get socket option `rcvbuf`. // Available from libzmq 2.0.0. int zsock_rcvbuf (void *self); // Set socket option `rcvbuf`. // Available from libzmq 2.0.0. void zsock_set_rcvbuf (void *self, int rcvbuf); // Get socket option `linger`. // Available from libzmq 2.0.0. int zsock_linger (void *self); // Set socket option `linger`. // Available from libzmq 2.0.0. void zsock_set_linger (void *self, int linger); // Get socket option `reconnect_ivl`. // Available from libzmq 2.0.0. int zsock_reconnect_ivl (void *self); // Set socket option `reconnect_ivl`. // Available from libzmq 2.0.0. void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); // Get socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. int zsock_reconnect_ivl_max (void *self); // Set socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); // Get socket option `backlog`. // Available from libzmq 2.0.0. int zsock_backlog (void *self); // Set socket option `backlog`. // Available from libzmq 2.0.0. void zsock_set_backlog (void *self, int backlog); // Set socket option `subscribe`. // Available from libzmq 2.0.0. void zsock_set_subscribe (void *self, const char *subscribe); // Set socket option `unsubscribe`. // Available from libzmq 2.0.0. void zsock_set_unsubscribe (void *self, const char *unsubscribe); // Get socket option `type`. // Available from libzmq 2.0.0. int zsock_type (void *self); // Get socket option `rcvmore`. // Available from libzmq 2.0.0. int zsock_rcvmore (void *self); // Get socket option `fd`. // Available from libzmq 2.0.0. SOCKET zsock_fd (void *self); // Get socket option `events`. // Available from libzmq 2.0.0. int zsock_events (void *self); // Self test of this class. void zsock_test (bool verbose); // CLASS: zstr // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. char * zstr_recv (void *source); // Receive a series of strings (until NULL) from multipart data. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL. // Returns -1 if the message could not be read, else returns the // number of strings filled, zero or more. Free each returned string // using zstr_free(). If not enough strings are provided, remaining // multipart frames in the message are dropped. int zstr_recvx (void *source, char **string_p, ...); // De-compress and receive C string from socket, received as a message // with two frames: size of the uncompressed string, and the string itself. // Caller must free returned string using zstr_free(). Returns NULL if the // context is being terminated or the process was interrupted. char * zstr_recv_compress (void *source); // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". int zstr_send (void *dest, const char *string); // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. int zstr_sendm (void *dest, const char *string); // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). int zstr_sendf (void *dest, const char *format, ...); // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. int zstr_sendfm (void *dest, const char *format, ...); // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or -1 on error. int zstr_sendx (void *dest, const char *string, ...); // Compress and send a C string to a socket, as a message with two frames: // size of the uncompressed string, and the string itself. The string is // sent without trailing null byte; to read this you can use // zstr_recv_compress, or a similar method that de-compresses and adds a // null terminator on the received string. int zstr_send_compress (void *dest, const char *string); // Compress and send a C string to a socket, as zstr_send_compress(), // with a MORE flag, so that you can send further strings in the same // multi-part message. int zstr_sendm_compress (void *dest, const char *string); // Accepts a void pointer and returns a fresh character string. If source // is null, returns an empty string. char * zstr_str (void *source); // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. void zstr_free (char **string_p); // Self test of this class. void zstr_test (bool verbose); // CLASS: zsys // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. void * zsys_init (void); // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls. void zsys_shutdown (void); // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. // *** This is for CZMQ internal use only and may change arbitrarily *** void * zsys_socket (int type, const char *filename, size_t line_nbr); // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). // *** This is for CZMQ internal use only and may change arbitrarily *** int zsys_close (void *handle, const char *filename, size_t line_nbr); // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** char * zsys_sockname (int socktype); // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. zsock_t * zsys_create_pipe (zsock_t **backend_p); // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. void zsys_handler_set (zsys_handler_fn *handler_fn); // Reset interrupt handler, call this at exit if needed void zsys_handler_reset (void); // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. // Can be supressed by ZSYS_SIGHANDLER=false // *** This is for CZMQ internal use only and may change arbitrarily *** void zsys_catch_interrupts (void); // Return 1 if file exists, else zero bool zsys_file_exists (const char *filename); // Return file modification time. Returns 0 if the file does not exist. time_t zsys_file_modified (const char *filename); // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. int zsys_file_mode (const char *filename); // Delete file. Does not complain if the file is absent int zsys_file_delete (const char *filename); // Check if file is 'stable' bool zsys_file_stable (const char *filename); // Create a file path if it doesn't exist. The file path is treated as // printf format. int zsys_dir_create (const char *pathname, ...); // Remove a file path if empty; the pathname is treated as printf format. int zsys_dir_delete (const char *pathname, ...); // Move to a specified working directory. Returns 0 if OK, -1 if this failed. int zsys_dir_change (const char *pathname); // Set private file creation mode; all files created from here will be // readable/writable by the owner only. void zsys_file_mode_private (void); // Reset default file creation mode; all files created from here will use // process file mode defaults. void zsys_file_mode_default (void); // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. 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(). char * zsys_sprintf (const char *format, ...); // Format a string with a va_list argument, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). char * zsys_vprintf (const char *format, va_list argptr); // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. // *** This is for CZMQ internal use only and may change arbitrarily *** SOCKET zsys_udp_new (bool routable); // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** int zsys_udp_close (SOCKET handle); // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address, int addrlen); // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or // NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. // *** This is for CZMQ internal use only and may change arbitrarily *** zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername, int peerlen); // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. // *** This is for CZMQ internal use only and may change arbitrarily *** void zsys_socket_error (const char *reason); // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. char * zsys_hostname (void); // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. int zsys_daemonize (const char *workdir); // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. int zsys_run_as (const char *lockfile, const char *group, const char *user); // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. bool zsys_has_curve (void); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_io_threads (size_t io_threads); // Configure the scheduling policy of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY // is defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_thread_sched_policy (int policy); // Configure the scheduling priority of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_PRIORITY is // defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_thread_priority (int priority); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void zsys_set_max_sockets (size_t max_sockets); // Return maximum number of ZeroMQ sockets that the system will support. size_t zsys_socket_limit (void); // Configure the maximum allowed size of a message sent. // The default is INT_MAX. void zsys_set_max_msgsz (int max_msgsz); // Return maximum message size. int zsys_max_msgsz (void); // Configure the threshold value of filesystem object age per st_mtime // that should elapse until we consider that object "stable" at the // current zclock_time() moment. // The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c // which generally depends on host OS, with fallback value of 5000. void zsys_set_file_stable_age_msec (int64_t file_stable_age_msec); // Return current threshold value of file stable age in msec. // This can be used in code that chooses to wait for this timeout // before testing if a filesystem object is "stable" or not. int64_t zsys_file_stable_age_msec (void); // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. void zsys_set_linger (size_t linger); // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void zsys_set_sndhwm (size_t sndhwm); // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void zsys_set_rcvhwm (size_t rcvhwm); // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. void zsys_set_pipehwm (size_t pipehwm); // Return the HWM for zactor internal pipes. size_t zsys_pipehwm (void); // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. void zsys_set_ipv6 (int ipv6); // Return use of IPv6 for zsock instances. int zsys_ipv6 (void); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void zsys_set_interface (const char *value); // Return network interface to use for broadcasts, or "" if none was set. const char * zsys_interface (void); // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses // on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, // use that as the default IPv6 address. void zsys_set_ipv6_address (const char *value); // Return IPv6 address to use for zbeacon reception, or "" if none was set. const char * zsys_ipv6_address (void); // Set IPv6 milticast address to use for sending zbeacon messages. This needs // to be set if IPv6 is enabled. If the environment variable // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast // address. void zsys_set_ipv6_mcast_address (const char *value); // Return IPv6 multicast address to use for sending zbeacon, or "" if none was // set. const char * zsys_ipv6_mcast_address (void); // Configure the automatic use of pre-allocated FDs when creating new sockets. // If 0 (default), nothing will happen. Else, when a new socket is bound, the // system API will be used to check if an existing pre-allocated FD with a // matching port (if TCP) or path (if IPC) exists, and if it does it will be // set via the ZMQ_USE_FD socket option so that the library will use it // instead of creating a new socket. void zsys_set_auto_use_fd (int auto_use_fd); // Return use of automatic pre-allocated FDs for zsock instances. int zsys_auto_use_fd (void); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void zsys_set_logident (const char *value); // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). void zsys_set_logstream (FILE *stream); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void zsys_set_logsender (const char *endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void zsys_set_logsystem (bool logsystem); // Log error condition - highest priority void zsys_error (const char *format, ...); // Log warning condition - high priority void zsys_warning (const char *format, ...); // Log normal, but significant, condition - normal priority void zsys_notice (const char *format, ...); // Log informational message - low priority void zsys_info (const char *format, ...); // Log debug-level message - lowest priority void zsys_debug (const char *format, ...); // Self test of this class. void zsys_test (bool verbose); // CLASS: ztimerset // Create new timer set. ztimerset_t * ztimerset_new (void); // Destroy a timer set void ztimerset_destroy (ztimerset_t **self_p); // Add a timer to the set. Returns timer id if OK, -1 on failure. int ztimerset_add (ztimerset_t *self, size_t interval, ztimerset_fn handler, void *arg); // Cancel a timer. Returns 0 if OK, -1 on failure. int ztimerset_cancel (ztimerset_t *self, int timer_id); // Set timer interval. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int ztimerset_set_interval (ztimerset_t *self, int timer_id, size_t interval); // Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int ztimerset_reset (ztimerset_t *self, int timer_id); // Return the time until the next interval. // Should be used as timeout parameter for the zpoller wait method. // The timeout is in msec. int ztimerset_timeout (ztimerset_t *self); // Invoke callback function of all timers which their interval has elapsed. // Should be call after zpoller wait method. // Returns 0 if OK, -1 on failure. int ztimerset_execute (ztimerset_t *self); // Self test of this class. void ztimerset_test (bool verbose); // CLASS: ztrie // Creates a new ztrie. ztrie_t * ztrie_new (char delimiter); // Destroy the ztrie. void ztrie_destroy (ztrie_t **self_p); // Inserts a new route into the tree and attaches the data. Returns -1 // if the route already exists, otherwise 0. This method takes ownership of // the provided data if a destroy_data_fn is provided. int ztrie_insert_route (ztrie_t *self, const char *path, void *data, ztrie_destroy_data_fn destroy_data_fn); // Removes a route from the trie and destroys its data. Returns -1 if the // route does not exists, otherwise 0. // the start of the list call zlist_first (). Advances the cursor. int ztrie_remove_route (ztrie_t *self, const char *path); // Returns true if the path matches a route in the tree, otherwise false. bool ztrie_matches (ztrie_t *self, const char *path); // Returns the data of a matched route from last ztrie_matches. If the path // did not match, returns NULL. Do not delete the data as it's owned by // ztrie. void * ztrie_hit_data (ztrie_t *self); // Returns the count of parameters that a matched route has. size_t ztrie_hit_parameter_count (ztrie_t *self); // Returns the parameters of a matched route with named regexes from last // ztrie_matches. If the path did not match or the route did not contain any // named regexes, returns NULL. zhashx_t * ztrie_hit_parameters (ztrie_t *self); // Returns the asterisk matched part of a route, if there has been no match // or no asterisk match, returns NULL. const char * ztrie_hit_asterisk_match (ztrie_t *self); // Print the trie void ztrie_print (ztrie_t *self); // Self test of this class. void ztrie_test (bool verbose); // CLASS: zuuid // Create a new UUID object. zuuid_t * zuuid_new (void); // Destroy a specified UUID object. void zuuid_destroy (zuuid_t **self_p); // Create UUID object from supplied ZUUID_LEN-octet value. zuuid_t * zuuid_new_from (const byte *source); // Set UUID to new supplied ZUUID_LEN-octet value. void zuuid_set (zuuid_t *self, const byte *source); // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. int zuuid_set_str (zuuid_t *self, const char *source); // Return UUID binary data. const byte * zuuid_data (zuuid_t *self); // Return UUID binary size size_t zuuid_size (zuuid_t *self); // Returns UUID as string const char * zuuid_str (zuuid_t *self); // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier const char * zuuid_str_canonical (zuuid_t *self); // Store UUID blob in target array void zuuid_export (zuuid_t *self, byte *target); // Check if UUID is same as supplied value bool zuuid_eq (zuuid_t *self, const byte *compare); // Check if UUID is different from supplied value bool zuuid_neq (zuuid_t *self, const byte *compare); // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. zuuid_t * zuuid_dup (zuuid_t *self); // Self test of this class. void zuuid_test (bool verbose); ]] czmq_ffi.czmq = czmq_ffi.ffi.load ("libczmq") return czmq_ffi czmq-4.1.0/bindings/qml/0000775000372000037200000000000013222211156015751 5ustar00travistravis00000000000000czmq-4.1.0/bindings/qml/README.md0000664000372000037200000001561113222211156017234 0ustar00travistravis00000000000000``` ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ ``` # qml_czmq QML bindings for creating UI applications using the "czmq" C library. ## Setting up a Build Environment The following is intended to be a complete guide to setting up a build environment that can build for Android (as well as your desktop, although that part is considerably easier). To that end, if you encounter parts where steps are missing or unclear, please file an issue or pull request about it so that others might learn from your research. Eventually, we'd like to remove some of these steps where possible to make this process simpler. If you have ideas about removing or simplifying steps, please file an issue or pull request so that others might be saved some complexity. ### C Library Dependencies If you are building for Android, you can skip this step, as the necessary dependencies are automatically pulled down and built by the `vendor/build` scripts. If you are developing and testing on your desktop, you will need a local installation of the czmq library to link against and include. ### Ruby You will need an installation of [Ruby 1.9 or greater](https://www.ruby-lang.org/en/downloads/) to run some of the build scripts. In the future, this requirement may be eliminated and replaced by "pure" shell scripts with no Ruby dependency. On Linux, you can get Ruby from your package manager. On OSX, use [brew](http://brew.sh/). If you are already a Ruby developer and have an existing system to manage your Rubies, use what you are comfortable with. Once Ruby is installed, you will need the [qt-commander](https://github.com/jemc/qt-commander) gem, a utility package for parsing the Qt Creator IDE configuration files to pull out key information for building projects and project dependencies from the command line without the IDE. You will also need the [rake](https://github.com/jimweirich/rake) gem, a task automation package with usage similiar to the `make` command. You can install both using the `gem` command: ``` gem install rake gem install qt-commander ``` ### Qt 5 You will need [Qt 5](http://www.qt.io/download-open-source/) and a fully-functioning environment for Qt that can build and deploy to Android. Qt features [a guide for Android](http://qt-project.org/doc/qt-5/android-support.html) but here are a few tips to get you started: * You will need the Android [SDK](https://developer.android.com/sdk/index.html) and [NDK](https://developer.android.com/tools/sdk/ndk/index.html). Install them to any path you like, but you will eventually need to point the Qt Creator IDE to them. * You will need Java 7 - JRE and JDK, and 'ant'. You can usually get these through your package manager. * You don't need the Eclipse IDE or bundle - all work is done from the command line or through the Qt Creator IDE. At the end of this setup, you should be able to use the Qt Creator IDE to build and deploy an out-of-the-box simple 'Hello World' app for QML. To ready your device for deployment: * Be sure your Android device has [developer options enabled](http://developer.android.com/tools/device.html#developer-device-options). * Run the adb server with a privileged user (`sudo adb start-server`). If you previously tried to run adb with an unprivileged user, you'll need to stop the old adb server first (`sudo adb kill-server`). You will need the `adb` binary from the Android development kit in your `$PATH`. * Connect your device via USB and set it to "USB Debugging Mode". * Run `adb devices` to make sure your device is detected and ready. To create the temporary project: * Click `File`->`New File or Project...` * Choose `Applications`/`Qt Quick Application` * Enter a name and location for the temporary project * Choose the latest "Qt Quick Component Set" * Select the relevant kits you want to be able to deploy with (this should include the Android kit(s) that you set up earlier) * Choose a version control system to use (if you like) * Finish the creation wizard Once you have a project to deploy: * In the lower-left corner of the IDE (above the build icons), select from the drop-down menu the Android kit that matches the architectureof your connected device. * Click the "Run" button (just below the kit menu) to deploy. * Watch the bottom output pane of the IDE; it will show output from the build and packaging process, transfer the file, then show in a different tab output from the program execution as it runs on your device. ## Build tasks ### Install Locally and Run Tests ``` rake test ``` Use this command when developing and testing the library. A copy of the czmq library is installed locally where Qt can find it for running desktop applications that use the library, and tests are run. You will need to have the czmq C library built and installed on your machine. ### Install Locally for Android ``` rake android ``` Use this command to install a copy of the library locally where Qt can find it later for bundling into an application you are deploying to Android. The build will repeat for each android kit you have configured in the Qt Creator IDE so that the installed library is available for all kits. In order to build for android, the qml_czmq needs access to an Android build of the czmq library and all its dependencies. This can be done one of two ways: 1. Clone the czmq library and all its dependencies from source into the same folder. If all project repos are side-by-side in the same "workspace" folder (as is typical for many users' workflows), they can detect eachother automatically and build in a chain when you run `rake android` in the qml_czmq folder. 2. Manually export the `CZMQ_ROOT` environment variable as the path to the CZMQ source code root. Do the same for any other projects that you are prompted for when you run `rake android`. When all environment variables are resolved, they will build in a chain. For all of the zeromq libraries in the dependencies, the source code will be copied to a temporary directory for building, but installed to the `$(XXX_ROOT)/builds/android/prefix/$(TOOLCHAIN_NAME)` directory within the original source tree. If you need to run builds for individual projects, use the `$(XXX_ROOT)/builds/android/prefix/build.sh` command. The build script will skip itself if it was already installed to `$(XXX_ROOT)/builds/android/prefix/$(TOOLCHAIN_NAME)`, so at times you may need to delete that directory to trigger a clean build. ``` ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ ``` czmq-4.1.0/bindings/qml/Rakefile0000664000372000037200000000207013222211156017415 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ require 'qt/commander' task :default => :test task :android do Qt::Commander::Creator.profiles.select(&:android?).each do |profile| profile.toolchain.env do system "#{profile.version.qmake} *.pro -spec android-g++" and system "make" end end end task :install do system "qmake *.pro && make" end task :test => :install do system "qmltestrunner" end task :clean do `make clean && rm Makefile` end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/qml/.gitignore0000664000372000037200000000000713222211156017736 0ustar00travistravis00000000000000build/ czmq-4.1.0/bindings/qml/test/0000775000372000037200000000000013222211156016730 5ustar00travistravis00000000000000czmq-4.1.0/bindings/qml/test/tst_QmlCZMQ.qml0000664000372000037200000000022613222211156021561 0ustar00travistravis00000000000000 import QtTest 1.0 import QtQuick 2.1 import QmlCZMQ 1.0 TestCase { id: test name: "QmlCZMQ" function test_it() { verify(true) } } czmq-4.1.0/bindings/qml/qml_czmq_bindings.pro0000664000372000037200000000756113222211156022204 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ TEMPLATE = lib CONFIG += plugin QT += qml quick TARGET = $$qtLibraryTarget(qml_czmq) uri = QmlCZMQ DESTDIR = $$[QT_INSTALL_QML]/$$replace(uri, \., /) SRCDIR = $$PWD/src BUILDDIR = $$PWD/build/native android { # Use a default value assuming the czmq project sits outside this one isEmpty(CZMQ_ROOT) { CZMQ_ROOT = $$clean_path($$PWD/../..) } !exists($$CZMQ_ROOT) { error(The CZMQ_ROOT directory does not exist: $$CZMQ_ROOT) } # Build the czmq library for android unless it is already built !system(bash $$CZMQ_ROOT/builds/android/build.sh) { error(Failed to build the czmq library with $$CZMQ_ROOT/builds/android/build.sh) } VENDOR_PREFIX = $$CZMQ_ROOT/builds/android/prefix/$(TOOLCHAIN_NAME) BUILDDIR = $$PWD/build/$(TOOLCHAIN_NAME) QMAKE_LIBDIR += $$VENDOR_PREFIX/lib QMAKE_INCDIR += $$VENDOR_PREFIX/include } LIBS += -lczmq HEADERS += \ $$SRCDIR/qml_czmq_plugin.h \ $$SRCDIR/QmlZactor.h \ $$SRCDIR/QmlZargs.h \ $$SRCDIR/QmlZarmour.h \ $$SRCDIR/QmlZcert.h \ $$SRCDIR/QmlZcertstore.h \ $$SRCDIR/QmlZchunk.h \ $$SRCDIR/QmlZclock.h \ $$SRCDIR/QmlZconfig.h \ $$SRCDIR/QmlZdigest.h \ $$SRCDIR/QmlZdir.h \ $$SRCDIR/QmlZdirPatch.h \ $$SRCDIR/QmlZfile.h \ $$SRCDIR/QmlZframe.h \ $$SRCDIR/QmlZhash.h \ $$SRCDIR/QmlZhashx.h \ $$SRCDIR/QmlZiflist.h \ $$SRCDIR/QmlZlist.h \ $$SRCDIR/QmlZlistx.h \ $$SRCDIR/QmlZloop.h \ $$SRCDIR/QmlZmsg.h \ $$SRCDIR/QmlZpoller.h \ $$SRCDIR/QmlZproc.h \ $$SRCDIR/QmlZsock.h \ $$SRCDIR/QmlZstr.h \ $$SRCDIR/QmlZsys.h \ $$SRCDIR/QmlZtimerset.h \ $$SRCDIR/QmlZtrie.h \ $$SRCDIR/QmlZuuid.h SOURCES += \ $$SRCDIR/QmlZactor.cpp \ $$SRCDIR/QmlZargs.cpp \ $$SRCDIR/QmlZarmour.cpp \ $$SRCDIR/QmlZcert.cpp \ $$SRCDIR/QmlZcertstore.cpp \ $$SRCDIR/QmlZchunk.cpp \ $$SRCDIR/QmlZclock.cpp \ $$SRCDIR/QmlZconfig.cpp \ $$SRCDIR/QmlZdigest.cpp \ $$SRCDIR/QmlZdir.cpp \ $$SRCDIR/QmlZdirPatch.cpp \ $$SRCDIR/QmlZfile.cpp \ $$SRCDIR/QmlZframe.cpp \ $$SRCDIR/QmlZhash.cpp \ $$SRCDIR/QmlZhashx.cpp \ $$SRCDIR/QmlZiflist.cpp \ $$SRCDIR/QmlZlist.cpp \ $$SRCDIR/QmlZlistx.cpp \ $$SRCDIR/QmlZloop.cpp \ $$SRCDIR/QmlZmsg.cpp \ $$SRCDIR/QmlZpoller.cpp \ $$SRCDIR/QmlZproc.cpp \ $$SRCDIR/QmlZsock.cpp \ $$SRCDIR/QmlZstr.cpp \ $$SRCDIR/QmlZsys.cpp \ $$SRCDIR/QmlZtimerset.cpp \ $$SRCDIR/QmlZtrie.cpp \ $$SRCDIR/QmlZuuid.cpp OBJECTS_DIR = $$BUILDDIR/.obj MOC_DIR = $$BUILDDIR/.moc RCC_DIR = $$BUILDDIR/.rcc UI_DIR = $$BUILDDIR/.ui target.path = $$DESTDIR qmldir.files = $$PWD/qmldir qmldir.path = $$DESTDIR OTHER_FILES += $$SRCDIR/qmldir \ $$SRCDIR/qml/* #*/ INSTALLS += target qmldir # Copy the qmldir file to the same folder as the plugin binary QMAKE_POST_LINK += \ $$QMAKE_COPY $$replace($$list($$quote($$SRCDIR/qmldir) $$DESTDIR), /, $$QMAKE_DIR_SEP) # Copy the dependency shared libraries to the plugin folder (on android only) android { QMAKE_POST_LINK += \ && $$QMAKE_COPY $$replace($$list($$quote($$VENDOR_PREFIX/lib/*.so) $$DESTDIR), /, $$QMAKE_DIR_SEP) } #*/ # Copy the qml implementation directory to the plugin folder copyqml.commands = $(COPY_DIR) $$SRCDIR/qml $$DESTDIR first.depends = $(first) copyqml export(first.depends) export(copyqml.commands) QMAKE_EXTRA_TARGETS += first copyqml ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/qml/src/0000775000372000037200000000000013222211156016540 5ustar00travistravis00000000000000czmq-4.1.0/bindings/qml/src/QmlZproc.h0000664000372000037200000001750413222211156020467 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZPROC_H #define QML_ZPROC_H #include #include #include "qml_czmq_plugin.h" class QmlZproc : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zproc_t *self; QmlZproc() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZproc.cpp public slots: // Setup the command line arguments, the first item must be an (absolute) filename // to run. void setArgs (QmlZlistx *args); // Setup the environment variables for the process. void setEnv (QmlZhashx *args); // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The writable one is then accessbile via zproc_stdin method. void setStdin (void *socket); // Connects process stdout with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stdout method. void setStdout (void *socket); // Connects process stderr with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stderr method. void setStderr (void *socket); // Return subprocess stdin writable socket. NULL for // not initialized or external sockets. void *stdin (); // Return subprocess stdout readable socket. NULL for // not initialized or external sockets. void *stdout (); // Return subprocess stderr readable socket. NULL for // not initialized or external sockets. void *stderr (); // Starts the process. int run (); // process exit code int returncode (); // PID of the process int pid (); // return true if process is running, false if not yet started or finished bool running (); // wait or poll process status, return return code int wait (bool hang); // return internal actor, usefull for the polling if process died void *actor (); // send a signal to the subprocess void kill (int signal); // set verbose mode void setVerbose (bool verbose); }; class QmlZprocAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZprocAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Returns CZMQ version as a single 6-digit integer encoding the major // version (x 10000), the minor version (x 100) and the patch. int czmqVersion (); // Returns true if the process received a SIGINT or SIGTERM signal. // It is good practice to use this method to exit any infinite loop // processing messages. bool interrupted (); // Returns true if the underlying libzmq supports CURVE security. bool hasCurve (); // Return current host name, for use in public tcp:// endpoints. // If the host name is not resolvable, returns NULL. QString hostname (); // Move the current process into the background. The precise effect // depends on the operating system. On POSIX boxes, moves to a specified // working directory (if specified), closes all file handles, reopens // stdin, stdout, and stderr to the null device, and sets the process to // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there // was an error. void daemonize (const QString &workdir); // Drop the process ID into the lockfile, with exclusive lock, and // switch the process to the specified group and/or user. Any of the // arguments may be null, indicating a no-op. Returns 0 on success, // -1 on failure. Note if you combine this with zsys_daemonize, run // after, not before that method, or the lockfile will hold the wrong // process ID. void runAs (const QString &lockfile, const QString &group, const QString &user); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void setIoThreads (size_t ioThreads); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void setMaxSockets (size_t maxSockets); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void setBiface (const QString &value); // Return network interface to use for broadcasts, or "" if none was set. const QString biface (); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void setLogIdent (const QString &value); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void setLogSender (const QString &endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void setLogSystem (bool logsystem); // Log error condition - highest priority void logError (const QString &format); // Log warning condition - high priority void logWarning (const QString &format); // Log normal, but significant, condition - normal priority void logNotice (const QString &format); // Log informational message - low priority void logInfo (const QString &format); // Log debug-level message - lowest priority void logDebug (const QString &format); // Self test of this class. void test (bool verbose); // Create a new zproc. // NOTE: On Windows and with libzmq3 and libzmq2 this function // returns NULL. Code needs to be ported there. QmlZproc *construct (); // Destroy zproc, wait until process ends. void destruct (QmlZproc *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZproc, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZhashx.cpp0000664000372000037200000002471413222211156021173 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZhashx.h" /// // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int QmlZhashx::insert (const void *key, void *item) { return zhashx_insert (self, key, item); }; /// // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. void QmlZhashx::update (const void *key, void *item) { zhashx_update (self, key, item); }; /// // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void QmlZhashx::delete (const void *key) { zhashx_delete (self, key); }; /// // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. void QmlZhashx::purge () { zhashx_purge (self); }; /// // Return the item at the specified key, or null void *QmlZhashx::lookup (const void *key) { return zhashx_lookup (self, key); }; /// // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int QmlZhashx::rename (const void *oldKey, const void *newKey) { return zhashx_rename (self, oldKey, newKey); }; /// // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void *QmlZhashx::freefn (const void *key, zhashx_free_fn freeFn) { return zhashx_freefn (self, key, freeFn); }; /// // Return the number of keys/items in the hash table size_t QmlZhashx::size () { return zhashx_size (self); }; /// // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. QmlZlistx *QmlZhashx::keys () { QmlZlistx *retQ_ = new QmlZlistx (); retQ_->self = zhashx_keys (self); return retQ_; }; /// // Return a zlistx_t containing the values for the items in the // table. Uses the duplicator to duplicate all items and sets the // destructor as destructor for the list. QmlZlistx *QmlZhashx::values () { QmlZlistx *retQ_ = new QmlZlistx (); retQ_->self = zhashx_values (self); return retQ_; }; /// // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhashx_cursor(). NOTE: do NOT modify the table while iterating. void *QmlZhashx::first () { return zhashx_first (self); }; /// // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). To // access the key for this item use zhashx_cursor(). NOTE: do NOT modify // the table while iterating. void *QmlZhashx::next () { return zhashx_next (self); }; /// // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const void *QmlZhashx::cursor () { return zhashx_cursor (self); }; /// // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void QmlZhashx::comment (const QString &format) { zhashx_comment (self, "%s", format.toUtf8().data()); }; /// // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int QmlZhashx::save (const QString &filename) { return zhashx_save (self, filename.toUtf8().data()); }; /// // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int QmlZhashx::load (const QString &filename) { return zhashx_load (self, filename.toUtf8().data()); }; /// // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int QmlZhashx::refresh () { return zhashx_refresh (self); }; /// // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. QmlZframe *QmlZhashx::pack () { QmlZframe *retQ_ = new QmlZframe (); retQ_->self = zhashx_pack (self); return retQ_; }; /// // Same as pack but uses a user-defined serializer function to convert items // into longstr. QmlZframe *QmlZhashx::packOwn (zhashx_serializer_fn serializer) { QmlZframe *retQ_ = new QmlZframe (); retQ_->self = zhashx_pack_own (self, serializer); return retQ_; }; /// // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. QmlZhashx *QmlZhashx::dup () { QmlZhashx *retQ_ = new QmlZhashx (); retQ_->self = zhashx_dup (self); return retQ_; }; /// // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. void QmlZhashx::setDestructor (zhashx_destructor_fn destructor) { zhashx_set_destructor (self, destructor); }; /// // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. void QmlZhashx::setDuplicator (zhashx_duplicator_fn duplicator) { zhashx_set_duplicator (self, duplicator); }; /// // Set a user-defined deallocator for keys; by default keys are freed // when the hash is destroyed using free(). void QmlZhashx::setKeyDestructor (zhashx_destructor_fn destructor) { zhashx_set_key_destructor (self, destructor); }; /// // Set a user-defined duplicator for keys; by default keys are duplicated // using strdup. void QmlZhashx::setKeyDuplicator (zhashx_duplicator_fn duplicator) { zhashx_set_key_duplicator (self, duplicator); }; /// // Set a user-defined comparator for keys; by default keys are // compared using strcmp. // The callback function should return zero (0) on matching // items. void QmlZhashx::setKeyComparator (zhashx_comparator_fn comparator) { zhashx_set_key_comparator (self, comparator); }; /// // Set a user-defined hash function for keys; by default keys are // hashed by a modified Bernstein hashing function. void QmlZhashx::setKeyHasher (zhashx_hash_fn hasher) { zhashx_set_key_hasher (self, hasher); }; /// // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. QmlZhashx *QmlZhashx::dupV2 () { QmlZhashx *retQ_ = new QmlZhashx (); retQ_->self = zhashx_dup_v2 (self); return retQ_; }; QObject* QmlZhashx::qmlAttachedProperties(QObject* object) { return new QmlZhashxAttached(object); } /// // Self test of this class. void QmlZhashxAttached::test (bool verbose) { zhashx_test (verbose); }; /// // Create a new, empty hash container QmlZhashx *QmlZhashxAttached::construct () { QmlZhashx *qmlSelf = new QmlZhashx (); qmlSelf->self = zhashx_new (); return qmlSelf; }; /// // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. QmlZhashx *QmlZhashxAttached::unpack (QmlZframe *frame) { QmlZhashx *qmlSelf = new QmlZhashx (); qmlSelf->self = zhashx_unpack (frame->self); return qmlSelf; }; /// // Same as unpack but uses a user-defined deserializer function to convert // a longstr back into item format. QmlZhashx *QmlZhashxAttached::unpackOwn (QmlZframe *frame, zhashx_deserializer_fn deserializer) { QmlZhashx *qmlSelf = new QmlZhashx (); qmlSelf->self = zhashx_unpack_own (frame->self, deserializer); return qmlSelf; }; /// // Destroy a hash container and all items in it void QmlZhashxAttached::destruct (QmlZhashx *qmlSelf) { zhashx_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZframe.cpp0000664000372000037200000001324413222211156021146 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZframe.h" /// // Return number of bytes in frame data size_t QmlZframe::size () { return zframe_size (self); }; /// // Return address of frame data byte *QmlZframe::data () { return zframe_data (self); }; /// // Return meta data property for frame // The caller shall not modify or free the returned value, which shall be // owned by the message. const QString QmlZframe::meta (const QString &property) { return QString (zframe_meta (self, property.toUtf8().data())); }; /// // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. QmlZframe *QmlZframe::dup () { QmlZframe *retQ_ = new QmlZframe (); retQ_->self = zframe_dup (self); return retQ_; }; /// // Return frame data encoded as printable hex string, useful for 0MQ UUIDs. // Caller must free string when finished with it. QString QmlZframe::strhex () { char *retStr_ = zframe_strhex (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Return frame data copied into freshly allocated string // Caller must free string when finished with it. QString QmlZframe::strdup () { char *retStr_ = zframe_strdup (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Return TRUE if frame body is equal to string, excluding terminator bool QmlZframe::streq (const QString &string) { return zframe_streq (self, string.toUtf8().data()); }; /// // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method int QmlZframe::more () { return zframe_more (self); }; /// // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. void QmlZframe::setMore (int more) { zframe_set_more (self, more); }; /// // Return frame routing ID, if the frame came from a ZMQ_SERVER socket. // Else returns zero. uint32_t QmlZframe::routingId () { return zframe_routing_id (self); }; /// // Set routing ID on frame. This is used if/when the frame is sent to a // ZMQ_SERVER socket. void QmlZframe::setRoutingId (uint32_t routingId) { zframe_set_routing_id (self, routingId); }; /// // Return frame group of radio-dish pattern. const QString QmlZframe::group () { return QString (zframe_group (self)); }; /// // Set group on frame. This is used if/when the frame is sent to a // ZMQ_RADIO socket. // Return -1 on error, 0 on success. int QmlZframe::setGroup (const QString &group) { return zframe_set_group (self, group.toUtf8().data()); }; /// // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false. bool QmlZframe::eq (QmlZframe *other) { return zframe_eq (self, other->self); }; /// // Set new contents for frame void QmlZframe::reset (const void *data, size_t size) { zframe_reset (self, data, size); }; /// // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. void QmlZframe::print (const QString &prefix) { zframe_print (self, prefix.toUtf8().data()); }; QObject* QmlZframe::qmlAttachedProperties(QObject* object) { return new QmlZframeAttached(object); } /// // Send a frame to a socket, destroy frame after sending. // Return -1 on error, 0 on success. int QmlZframeAttached::send (QmlZframe *selfP, void *dest, int flags) { return zframe_send (&selfP->self, dest, flags); }; /// // Probe the supplied object, and report if it looks like a zframe_t. bool QmlZframeAttached::is (void *self) { return zframe_is (self); }; /// // Self test of this class. void QmlZframeAttached::test (bool verbose) { zframe_test (verbose); }; /// // Create a new frame. If size is not null, allocates the frame data // to the specified size. If additionally, data is not null, copies // size octets from the specified data into the frame body. QmlZframe *QmlZframeAttached::construct (const void *data, size_t size) { QmlZframe *qmlSelf = new QmlZframe (); qmlSelf->self = zframe_new (data, size); return qmlSelf; }; /// // Create an empty (zero-sized) frame QmlZframe *QmlZframeAttached::constructEmpty () { QmlZframe *qmlSelf = new QmlZframe (); qmlSelf->self = zframe_new_empty (); return qmlSelf; }; /// // Create a frame with a specified string content. QmlZframe *QmlZframeAttached::from (const QString &string) { QmlZframe *qmlSelf = new QmlZframe (); qmlSelf->self = zframe_from (string.toUtf8().data()); return qmlSelf; }; /// // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. QmlZframe *QmlZframeAttached::recv (void *source) { QmlZframe *qmlSelf = new QmlZframe (); qmlSelf->self = zframe_recv (source); return qmlSelf; }; /// // Destroy a frame void QmlZframeAttached::destruct (QmlZframe *qmlSelf) { zframe_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZiflist.h0000664000372000037200000000504413222211156021012 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZIFLIST_H #define QML_ZIFLIST_H #include #include #include "qml_czmq_plugin.h" class QmlZiflist : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: ziflist_t *self; QmlZiflist() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZiflist.cpp public slots: // Reload network interfaces from system void reload (); // Return the number of network interfaces on system size_t size (); // Get first network interface, return NULL if there are none const QString first (); // Get next network interface, return NULL if we hit the last one const QString next (); // Return the current interface IP address as a printable string const QString address (); // Return the current interface broadcast address as a printable string const QString broadcast (); // Return the current interface network mask as a printable string const QString netmask (); // Return the list of interfaces. void print (); // Reload network interfaces from system, including IPv6 void reloadIpv6 (); // Return true if the current interface uses IPv6 bool isIpv6 (); }; class QmlZiflistAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZiflistAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Get a list of network interfaces currently defined on the system // Includes IPv6 interfaces QmlZiflist *newIpv6 (); // Self test of this class. void test (bool verbose); // Get a list of network interfaces currently defined on the system QmlZiflist *construct (); // Destroy a ziflist instance void destruct (QmlZiflist *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZiflist, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZtimerset.cpp0000664000372000037200000000506113222211156021706 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZtimerset.h" /// // Add a timer to the set. Returns timer id if OK, -1 on failure. int QmlZtimerset::add (size_t interval, ztimerset_fn handler, void *arg) { return ztimerset_add (self, interval, handler, arg); }; /// // Cancel a timer. Returns 0 if OK, -1 on failure. int QmlZtimerset::cancel (int timerId) { return ztimerset_cancel (self, timerId); }; /// // Set timer interval. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int QmlZtimerset::setInterval (int timerId, size_t interval) { return ztimerset_set_interval (self, timerId, interval); }; /// // Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int QmlZtimerset::reset (int timerId) { return ztimerset_reset (self, timerId); }; /// // Return the time until the next interval. // Should be used as timeout parameter for the zpoller wait method. // The timeout is in msec. int QmlZtimerset::timeout () { return ztimerset_timeout (self); }; /// // Invoke callback function of all timers which their interval has elapsed. // Should be call after zpoller wait method. // Returns 0 if OK, -1 on failure. int QmlZtimerset::execute () { return ztimerset_execute (self); }; QObject* QmlZtimerset::qmlAttachedProperties(QObject* object) { return new QmlZtimersetAttached(object); } /// // Self test of this class. void QmlZtimersetAttached::test (bool verbose) { ztimerset_test (verbose); }; /// // Create new timer set. QmlZtimerset *QmlZtimersetAttached::construct () { QmlZtimerset *qmlSelf = new QmlZtimerset (); qmlSelf->self = ztimerset_new (); return qmlSelf; }; /// // Destroy a timer set void QmlZtimersetAttached::destruct (QmlZtimerset *qmlSelf) { ztimerset_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZdigest.cpp0000664000372000037200000000401613222211156021330 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZdigest.h" /// // Add buffer into digest calculation void QmlZdigest::update (const byte *buffer, size_t length) { zdigest_update (self, buffer, length); }; /// // Return final digest hash data. If built without crypto support, // returns NULL. const byte *QmlZdigest::data () { return zdigest_data (self); }; /// // Return final digest hash size size_t QmlZdigest::size () { return zdigest_size (self); }; /// // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. const QString QmlZdigest::string () { return QString (zdigest_string (self)); }; QObject* QmlZdigest::qmlAttachedProperties(QObject* object) { return new QmlZdigestAttached(object); } /// // Self test of this class. void QmlZdigestAttached::test (bool verbose) { zdigest_test (verbose); }; /// // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. QmlZdigest *QmlZdigestAttached::construct () { QmlZdigest *qmlSelf = new QmlZdigest (); qmlSelf->self = zdigest_new (); return qmlSelf; }; /// // Destroy a digest object void QmlZdigestAttached::destruct (QmlZdigest *qmlSelf) { zdigest_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZfile.cpp0000664000372000037200000001343613222211156020776 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZfile.h" /// // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. QmlZfile *QmlZfile::dup () { QmlZfile *retQ_ = new QmlZfile (); retQ_->self = zfile_dup (self); return retQ_; }; /// // Return file name, remove path if provided const QString QmlZfile::filename (const QString &path) { return QString (zfile_filename (self, path.toUtf8().data())); }; /// // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. void QmlZfile::restat () { zfile_restat (self); }; /// // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. time_t QmlZfile::modified () { return zfile_modified (self); }; /// // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. off_t QmlZfile::cursize () { return zfile_cursize (self); }; /// // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool QmlZfile::isDirectory () { return zfile_is_directory (self); }; /// // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool QmlZfile::isRegular () { return zfile_is_regular (self); }; /// // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. bool QmlZfile::isReadable () { return zfile_is_readable (self); }; /// // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. bool QmlZfile::isWriteable () { return zfile_is_writeable (self); }; /// // Check if file has stopped changing and can be safely processed. // Updates the file statistics from disk at every call. bool QmlZfile::isStable () { return zfile_is_stable (self); }; /// // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. bool QmlZfile::hasChanged () { return zfile_has_changed (self); }; /// // Remove the file from disk void QmlZfile::remove () { zfile_remove (self); }; /// // Open file for reading // Returns 0 if OK, -1 if not found or not accessible int QmlZfile::input () { return zfile_input (self); }; /// // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. int QmlZfile::output () { return zfile_output (self); }; /// // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. QmlZchunk *QmlZfile::read (size_t bytes, off_t offset) { QmlZchunk *retQ_ = new QmlZchunk (); retQ_->self = zfile_read (self, bytes, offset); return retQ_; }; /// // Returns true if zfile_read() just read the last chunk in the file. bool QmlZfile::eof () { return zfile_eof (self); }; /// // Write chunk to file at specified position // Return 0 if OK, else -1 int QmlZfile::write (QmlZchunk *chunk, off_t offset) { return zfile_write (self, chunk->self, offset); }; /// // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. const QString QmlZfile::readln () { return QString (zfile_readln (self)); }; /// // Close file, if open void QmlZfile::close () { zfile_close (self); }; /// // Return file handle, if opened FILE *QmlZfile::handle () { return zfile_handle (self); }; /// // Calculate SHA1 digest for file, using zdigest class. const QString QmlZfile::digest () { return QString (zfile_digest (self)); }; QObject* QmlZfile::qmlAttachedProperties(QObject* object) { return new QmlZfileAttached(object); } /// // Self test of this class. void QmlZfileAttached::test (bool verbose) { zfile_test (verbose); }; /// // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. QmlZfile *QmlZfileAttached::construct (const QString &path, const QString &name) { QmlZfile *qmlSelf = new QmlZfile (); qmlSelf->self = zfile_new (path.toUtf8().data(), name.toUtf8().data()); return qmlSelf; }; /// // Create new temporary file for writing via tmpfile. File is automaticaly // deleted on destroy QmlZfile *QmlZfileAttached::tmp () { QmlZfile *qmlSelf = new QmlZfile (); qmlSelf->self = zfile_tmp (); return qmlSelf; }; /// // Destroy a file item void QmlZfileAttached::destruct (QmlZfile *qmlSelf) { zfile_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZconfig.h0000664000372000037200000001213113222211156020760 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZCONFIG_H #define QML_ZCONFIG_H #include #include #include "qml_czmq_plugin.h" class QmlZconfig : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zconfig_t *self; QmlZconfig() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZconfig.cpp public slots: // Return name of config item const QString name (); // Return value of config item const QString value (); // Insert or update configuration key with value void put (const QString &path, const QString &value); // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. void putf (const QString &path, const QString &format); // Get value for config item into a string value; leading slash is optional // and ignored. const QString get (const QString &path, const QString &defaultValue); // Set config item name, name may be NULL void setName (const QString &name); // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. void setValue (const QString &format); // Find our first child, if any QmlZconfig *child (); // Find our first sibling, if any QmlZconfig *next (); // Find a config item along a path; leading slash is optional and ignored. QmlZconfig *locate (const QString &path); // Locate the last config item at a specified depth QmlZconfig *atDepth (int level); // Execute a callback for each config item in the tree; returns zero if // successful, else -1. int execute (zconfig_fct handler, void *arg); // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. void setComment (const QString &format); // Return comments of config item, as zlist. QmlZlist *comments (); // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. int save (const QString &filename); // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. int savef (const QString &format); // Report filename used during zconfig_load, or NULL if none const QString filename (); // Save a config tree to a new memory chunk QmlZchunk *chunkSave (); // Save a config tree to a new null terminated string QString strSave (); // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. bool hasChanged (); // Destroy subtree (all children) void removeSubtree (); // Print the config file to open stream void fprint (FILE *file); // Print properties of object void print (); }; class QmlZconfigAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZconfigAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). int reload (QmlZconfig *selfP); // Load a config tree from a memory chunk QmlZconfig *chunkLoad (QmlZchunk *chunk); // Load a config tree from a null-terminated string QmlZconfig *strLoad (const QString &string); // Destroy node and subtree (all children) void remove (QmlZconfig *selfP); // Self test of this class void test (bool verbose); // Create new config item QmlZconfig *construct (const QString &name, QmlZconfig *parent); // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. QmlZconfig *load (const QString &filename); // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. QmlZconfig *loadf (const QString &format); // Destroy a config item and all its children void destruct (QmlZconfig *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZconfig, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZiflist.cpp0000664000372000037200000000551313222211156021346 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZiflist.h" /// // Reload network interfaces from system void QmlZiflist::reload () { ziflist_reload (self); }; /// // Return the number of network interfaces on system size_t QmlZiflist::size () { return ziflist_size (self); }; /// // Get first network interface, return NULL if there are none const QString QmlZiflist::first () { return QString (ziflist_first (self)); }; /// // Get next network interface, return NULL if we hit the last one const QString QmlZiflist::next () { return QString (ziflist_next (self)); }; /// // Return the current interface IP address as a printable string const QString QmlZiflist::address () { return QString (ziflist_address (self)); }; /// // Return the current interface broadcast address as a printable string const QString QmlZiflist::broadcast () { return QString (ziflist_broadcast (self)); }; /// // Return the current interface network mask as a printable string const QString QmlZiflist::netmask () { return QString (ziflist_netmask (self)); }; /// // Return the list of interfaces. void QmlZiflist::print () { ziflist_print (self); }; /// // Reload network interfaces from system, including IPv6 void QmlZiflist::reloadIpv6 () { ziflist_reload_ipv6 (self); }; /// // Return true if the current interface uses IPv6 bool QmlZiflist::isIpv6 () { return ziflist_is_ipv6 (self); }; QObject* QmlZiflist::qmlAttachedProperties(QObject* object) { return new QmlZiflistAttached(object); } /// // Get a list of network interfaces currently defined on the system // Includes IPv6 interfaces QmlZiflist *QmlZiflistAttached::newIpv6 () { QmlZiflist *retQ_ = new QmlZiflist (); retQ_->self = ziflist_new_ipv6 (); return retQ_; }; /// // Self test of this class. void QmlZiflistAttached::test (bool verbose) { ziflist_test (verbose); }; /// // Get a list of network interfaces currently defined on the system QmlZiflist *QmlZiflistAttached::construct () { QmlZiflist *qmlSelf = new QmlZiflist (); qmlSelf->self = ziflist_new (); return qmlSelf; }; /// // Destroy a ziflist instance void QmlZiflistAttached::destruct (QmlZiflist *qmlSelf) { ziflist_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZproc.cpp0000664000372000037200000002235013222211156021015 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZproc.h" /// // Setup the command line arguments, the first item must be an (absolute) filename // to run. void QmlZproc::setArgs (QmlZlistx *args) { zproc_set_args (self, args->self); }; /// // Setup the environment variables for the process. void QmlZproc::setEnv (QmlZhashx *args) { zproc_set_env (self, args->self); }; /// // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The writable one is then accessbile via zproc_stdin method. void QmlZproc::setStdin (void *socket) { zproc_set_stdin (self, socket); }; /// // Connects process stdout with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stdout method. void QmlZproc::setStdout (void *socket) { zproc_set_stdout (self, socket); }; /// // Connects process stderr with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stderr method. void QmlZproc::setStderr (void *socket) { zproc_set_stderr (self, socket); }; /// // Return subprocess stdin writable socket. NULL for // not initialized or external sockets. void *QmlZproc::stdin () { return zproc_stdin (self); }; /// // Return subprocess stdout readable socket. NULL for // not initialized or external sockets. void *QmlZproc::stdout () { return zproc_stdout (self); }; /// // Return subprocess stderr readable socket. NULL for // not initialized or external sockets. void *QmlZproc::stderr () { return zproc_stderr (self); }; /// // Starts the process. int QmlZproc::run () { return zproc_run (self); }; /// // process exit code int QmlZproc::returncode () { return zproc_returncode (self); }; /// // PID of the process int QmlZproc::pid () { return zproc_pid (self); }; /// // return true if process is running, false if not yet started or finished bool QmlZproc::running () { return zproc_running (self); }; /// // wait or poll process status, return return code int QmlZproc::wait (bool hang) { return zproc_wait (self, hang); }; /// // return internal actor, usefull for the polling if process died void *QmlZproc::actor () { return zproc_actor (self); }; /// // send a signal to the subprocess void QmlZproc::kill (int signal) { zproc_kill (self, signal); }; /// // set verbose mode void QmlZproc::setVerbose (bool verbose) { zproc_set_verbose (self, verbose); }; QObject* QmlZproc::qmlAttachedProperties(QObject* object) { return new QmlZprocAttached(object); } /// // Returns CZMQ version as a single 6-digit integer encoding the major // version (x 10000), the minor version (x 100) and the patch. int QmlZprocAttached::czmqVersion () { return zproc_czmq_version (); }; /// // Returns true if the process received a SIGINT or SIGTERM signal. // It is good practice to use this method to exit any infinite loop // processing messages. bool QmlZprocAttached::interrupted () { return zproc_interrupted (); }; /// // Returns true if the underlying libzmq supports CURVE security. bool QmlZprocAttached::hasCurve () { return zproc_has_curve (); }; /// // Return current host name, for use in public tcp:// endpoints. // If the host name is not resolvable, returns NULL. QString QmlZprocAttached::hostname () { char *retStr_ = zproc_hostname (); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Move the current process into the background. The precise effect // depends on the operating system. On POSIX boxes, moves to a specified // working directory (if specified), closes all file handles, reopens // stdin, stdout, and stderr to the null device, and sets the process to // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there // was an error. void QmlZprocAttached::daemonize (const QString &workdir) { zproc_daemonize (workdir.toUtf8().data()); }; /// // Drop the process ID into the lockfile, with exclusive lock, and // switch the process to the specified group and/or user. Any of the // arguments may be null, indicating a no-op. Returns 0 on success, // -1 on failure. Note if you combine this with zsys_daemonize, run // after, not before that method, or the lockfile will hold the wrong // process ID. void QmlZprocAttached::runAs (const QString &lockfile, const QString &group, const QString &user) { zproc_run_as (lockfile.toUtf8().data(), group.toUtf8().data(), user.toUtf8().data()); }; /// // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void QmlZprocAttached::setIoThreads (size_t ioThreads) { zproc_set_io_threads (ioThreads); }; /// // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void QmlZprocAttached::setMaxSockets (size_t maxSockets) { zproc_set_max_sockets (maxSockets); }; /// // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void QmlZprocAttached::setBiface (const QString &value) { zproc_set_biface (value.toUtf8().data()); }; /// // Return network interface to use for broadcasts, or "" if none was set. const QString QmlZprocAttached::biface () { return QString (zproc_biface ()); }; /// // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void QmlZprocAttached::setLogIdent (const QString &value) { zproc_set_log_ident (value.toUtf8().data()); }; /// // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void QmlZprocAttached::setLogSender (const QString &endpoint) { zproc_set_log_sender (endpoint.toUtf8().data()); }; /// // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void QmlZprocAttached::setLogSystem (bool logsystem) { zproc_set_log_system (logsystem); }; /// // Log error condition - highest priority void QmlZprocAttached::logError (const QString &format) { zproc_log_error ("%s", format.toUtf8().data()); }; /// // Log warning condition - high priority void QmlZprocAttached::logWarning (const QString &format) { zproc_log_warning ("%s", format.toUtf8().data()); }; /// // Log normal, but significant, condition - normal priority void QmlZprocAttached::logNotice (const QString &format) { zproc_log_notice ("%s", format.toUtf8().data()); }; /// // Log informational message - low priority void QmlZprocAttached::logInfo (const QString &format) { zproc_log_info ("%s", format.toUtf8().data()); }; /// // Log debug-level message - lowest priority void QmlZprocAttached::logDebug (const QString &format) { zproc_log_debug ("%s", format.toUtf8().data()); }; /// // Self test of this class. void QmlZprocAttached::test (bool verbose) { zproc_test (verbose); }; /// // Create a new zproc. // NOTE: On Windows and with libzmq3 and libzmq2 this function // returns NULL. Code needs to be ported there. QmlZproc *QmlZprocAttached::construct () { QmlZproc *qmlSelf = new QmlZproc (); qmlSelf->self = zproc_new (); return qmlSelf; }; /// // Destroy zproc, wait until process ends. void QmlZprocAttached::destruct (QmlZproc *qmlSelf) { zproc_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZsock.h0000664000372000037200000007430713222211156020467 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZSOCK_H #define QML_ZSOCK_H #include #include #include "qml_czmq_plugin.h" class QmlZsock : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zsock_t *self; QmlZsock() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZsock.cpp public slots: // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. int bind (const QString &format); // Returns last bound endpoint, if any. const QString endpoint (); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int unbind (const QString &format); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. int connect (const QString &format); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int disconnect (const QString &format); // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). int attach (const QString &endpoints, bool serverish); // Returns socket type as printable constant string. const QString typeStr (); // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. int send (const QString &picture); // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. int vsend (const QString &picture, va_list argptr); // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // U = zuuid_t * (creates a zuuid with the data) // h = zhashx_t ** (creates zhashx) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. int recv (const QString &picture); // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. int vrecv (const QString &picture, va_list argptr); // Send a binary encoded 'picture' message to the socket (or actor). This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations. The pattern argument is a string that defines the // type of each argument. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0-255 chars type = "string" // S char *, 0-2^32-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // u zuuid_t * type = "uuid" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments. Returns 0 if // successful, -1 if sending failed for any reason. int bsend (const QString &picture); // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. // For types 1, 2, 4 and 8 the caller must allocate the memory itself before // calling zsock_brecv. // For types S, the caller must free the value once finished with it, as // zsock_brecv will allocate the buffer. // For type s, the caller must not free the value as it is stored in a // local cache for performance purposes. // For types c, f, u and m the caller must call the appropriate destructor // depending on the object as zsock_brecv will create new objects. // For type p the caller must coordinate with the sender, as it is just a // pointer value being passed. int brecv (const QString &picture); // Return socket routing ID if any. This returns 0 if the socket is not // of type ZMQ_SERVER or if no request was already received on it. uint32_t routingId (); // Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. // This will be used when sending messages on the socket via the zsock API. void setRoutingId (uint32_t routingId); // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. void setUnbounded (); // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zsock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. int signal (byte status); // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. int wait (); // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. void flush (); // Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int join (const QString &group); // Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int leave (const QString &group); // Get socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. int heartbeatIvl (); // Set socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. void setHeartbeatIvl (int heartbeatIvl); // Get socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. int heartbeatTtl (); // Set socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. void setHeartbeatTtl (int heartbeatTtl); // Get socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. int heartbeatTimeout (); // Set socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. void setHeartbeatTimeout (int heartbeatTimeout); // Get socket option `use_fd`. // Available from libzmq 4.2.0. int useFd (); // Set socket option `use_fd`. // Available from libzmq 4.2.0. void setUseFd (int useFd); // Set socket option `xpub_manual`. // Available from libzmq 4.2.0. void setXpubManual (int xpubManual); // Set socket option `xpub_welcome_msg`. // Available from libzmq 4.2.0. void setXpubWelcomeMsg (const QString &xpubWelcomeMsg); // Set socket option `stream_notify`. // Available from libzmq 4.2.0. void setStreamNotify (int streamNotify); // Get socket option `invert_matching`. // Available from libzmq 4.2.0. int invertMatching (); // Set socket option `invert_matching`. // Available from libzmq 4.2.0. void setInvertMatching (int invertMatching); // Set socket option `xpub_verboser`. // Available from libzmq 4.2.0. void setXpubVerboser (int xpubVerboser); // Get socket option `connect_timeout`. // Available from libzmq 4.2.0. int connectTimeout (); // Set socket option `connect_timeout`. // Available from libzmq 4.2.0. void setConnectTimeout (int connectTimeout); // Get socket option `tcp_maxrt`. // Available from libzmq 4.2.0. int tcpMaxrt (); // Set socket option `tcp_maxrt`. // Available from libzmq 4.2.0. void setTcpMaxrt (int tcpMaxrt); // Get socket option `thread_safe`. // Available from libzmq 4.2.0. int threadSafe (); // Get socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. int multicastMaxtpdu (); // Set socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. void setMulticastMaxtpdu (int multicastMaxtpdu); // Get socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. int vmciBufferSize (); // Set socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. void setVmciBufferSize (int vmciBufferSize); // Get socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. int vmciBufferMinSize (); // Set socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. void setVmciBufferMinSize (int vmciBufferMinSize); // Get socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. int vmciBufferMaxSize (); // Set socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. void setVmciBufferMaxSize (int vmciBufferMaxSize); // Get socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. int vmciConnectTimeout (); // Set socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. void setVmciConnectTimeout (int vmciConnectTimeout); // Get socket option `tos`. // Available from libzmq 4.1.0. int tos (); // Set socket option `tos`. // Available from libzmq 4.1.0. void setTos (int tos); // Set socket option `router_handover`. // Available from libzmq 4.1.0. void setRouterHandover (int routerHandover); // Set socket option `connect_rid`. // Available from libzmq 4.1.0. void setConnectRid (const QString &connectRid); // Set socket option `connect_rid` from 32-octet binary // Available from libzmq 4.1.0. void setConnectRidBin (const byte *connectRid); // Get socket option `handshake_ivl`. // Available from libzmq 4.1.0. int handshakeIvl (); // Set socket option `handshake_ivl`. // Available from libzmq 4.1.0. void setHandshakeIvl (int handshakeIvl); // Get socket option `socks_proxy`. // Available from libzmq 4.1.0. QString socksProxy (); // Set socket option `socks_proxy`. // Available from libzmq 4.1.0. void setSocksProxy (const QString &socksProxy); // Set socket option `xpub_nodrop`. // Available from libzmq 4.1.0. void setXpubNodrop (int xpubNodrop); // Set socket option `router_mandatory`. // Available from libzmq 4.0.0. void setRouterMandatory (int routerMandatory); // Set socket option `probe_router`. // Available from libzmq 4.0.0. void setProbeRouter (int probeRouter); // Set socket option `req_relaxed`. // Available from libzmq 4.0.0. void setReqRelaxed (int reqRelaxed); // Set socket option `req_correlate`. // Available from libzmq 4.0.0. void setReqCorrelate (int reqCorrelate); // Set socket option `conflate`. // Available from libzmq 4.0.0. void setConflate (int conflate); // Get socket option `zap_domain`. // Available from libzmq 4.0.0. QString zapDomain (); // Set socket option `zap_domain`. // Available from libzmq 4.0.0. void setZapDomain (const QString &zapDomain); // Get socket option `mechanism`. // Available from libzmq 4.0.0. int mechanism (); // Get socket option `plain_server`. // Available from libzmq 4.0.0. int plainServer (); // Set socket option `plain_server`. // Available from libzmq 4.0.0. void setPlainServer (int plainServer); // Get socket option `plain_username`. // Available from libzmq 4.0.0. QString plainUsername (); // Set socket option `plain_username`. // Available from libzmq 4.0.0. void setPlainUsername (const QString &plainUsername); // Get socket option `plain_password`. // Available from libzmq 4.0.0. QString plainPassword (); // Set socket option `plain_password`. // Available from libzmq 4.0.0. void setPlainPassword (const QString &plainPassword); // Get socket option `curve_server`. // Available from libzmq 4.0.0. int curveServer (); // Set socket option `curve_server`. // Available from libzmq 4.0.0. void setCurveServer (int curveServer); // Get socket option `curve_publickey`. // Available from libzmq 4.0.0. QString curvePublickey (); // Set socket option `curve_publickey`. // Available from libzmq 4.0.0. void setCurvePublickey (const QString &curvePublickey); // Set socket option `curve_publickey` from 32-octet binary // Available from libzmq 4.0.0. void setCurvePublickeyBin (const byte *curvePublickey); // Get socket option `curve_secretkey`. // Available from libzmq 4.0.0. QString curveSecretkey (); // Set socket option `curve_secretkey`. // Available from libzmq 4.0.0. void setCurveSecretkey (const QString &curveSecretkey); // Set socket option `curve_secretkey` from 32-octet binary // Available from libzmq 4.0.0. void setCurveSecretkeyBin (const byte *curveSecretkey); // Get socket option `curve_serverkey`. // Available from libzmq 4.0.0. QString curveServerkey (); // Set socket option `curve_serverkey`. // Available from libzmq 4.0.0. void setCurveServerkey (const QString &curveServerkey); // Set socket option `curve_serverkey` from 32-octet binary // Available from libzmq 4.0.0. void setCurveServerkeyBin (const byte *curveServerkey); // Get socket option `gssapi_server`. // Available from libzmq 4.0.0. int gssapiServer (); // Set socket option `gssapi_server`. // Available from libzmq 4.0.0. void setGssapiServer (int gssapiServer); // Get socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. int gssapiPlaintext (); // Set socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. void setGssapiPlaintext (int gssapiPlaintext); // Get socket option `gssapi_principal`. // Available from libzmq 4.0.0. QString gssapiPrincipal (); // Set socket option `gssapi_principal`. // Available from libzmq 4.0.0. void setGssapiPrincipal (const QString &gssapiPrincipal); // Get socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. QString gssapiServicePrincipal (); // Set socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. void setGssapiServicePrincipal (const QString &gssapiServicePrincipal); // Get socket option `ipv6`. // Available from libzmq 4.0.0. int ipv6 (); // Set socket option `ipv6`. // Available from libzmq 4.0.0. void setIpv6 (int ipv6); // Get socket option `immediate`. // Available from libzmq 4.0.0. int immediate (); // Set socket option `immediate`. // Available from libzmq 4.0.0. void setImmediate (int immediate); // Get socket option `sndhwm`. // Available from libzmq 3.0.0. int sndhwm (); // Set socket option `sndhwm`. // Available from libzmq 3.0.0. void setSndhwm (int sndhwm); // Get socket option `rcvhwm`. // Available from libzmq 3.0.0. int rcvhwm (); // Set socket option `rcvhwm`. // Available from libzmq 3.0.0. void setRcvhwm (int rcvhwm); // Get socket option `maxmsgsize`. // Available from libzmq 3.0.0. int maxmsgsize (); // Set socket option `maxmsgsize`. // Available from libzmq 3.0.0. void setMaxmsgsize (int maxmsgsize); // Get socket option `multicast_hops`. // Available from libzmq 3.0.0. int multicastHops (); // Set socket option `multicast_hops`. // Available from libzmq 3.0.0. void setMulticastHops (int multicastHops); // Set socket option `xpub_verbose`. // Available from libzmq 3.0.0. void setXpubVerbose (int xpubVerbose); // Get socket option `tcp_keepalive`. // Available from libzmq 3.0.0. int tcpKeepalive (); // Set socket option `tcp_keepalive`. // Available from libzmq 3.0.0. void setTcpKeepalive (int tcpKeepalive); // Get socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. int tcpKeepaliveIdle (); // Set socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. void setTcpKeepaliveIdle (int tcpKeepaliveIdle); // Get socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. int tcpKeepaliveCnt (); // Set socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. void setTcpKeepaliveCnt (int tcpKeepaliveCnt); // Get socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. int tcpKeepaliveIntvl (); // Set socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. void setTcpKeepaliveIntvl (int tcpKeepaliveIntvl); // Get socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. QString tcpAcceptFilter (); // Set socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. void setTcpAcceptFilter (const QString &tcpAcceptFilter); // Get socket option `last_endpoint`. // Available from libzmq 3.0.0. QString lastEndpoint (); // Set socket option `router_raw`. // Available from libzmq 3.0.0. void setRouterRaw (int routerRaw); // Get socket option `ipv4only`. // Available from libzmq 3.0.0. int ipv4only (); // Set socket option `ipv4only`. // Available from libzmq 3.0.0. void setIpv4only (int ipv4only); // Set socket option `delay_attach_on_connect`. // Available from libzmq 3.0.0. void setDelayAttachOnConnect (int delayAttachOnConnect); // Get socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. int hwm (); // Set socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. void setHwm (int hwm); // Get socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. int swap (); // Set socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. void setSwap (int swap); // Get socket option `affinity`. // Available from libzmq 2.0.0. int affinity (); // Set socket option `affinity`. // Available from libzmq 2.0.0. void setAffinity (int affinity); // Get socket option `identity`. // Available from libzmq 2.0.0. QString identity (); // Set socket option `identity`. // Available from libzmq 2.0.0. void setIdentity (const QString &identity); // Get socket option `rate`. // Available from libzmq 2.0.0. int rate (); // Set socket option `rate`. // Available from libzmq 2.0.0. void setRate (int rate); // Get socket option `recovery_ivl`. // Available from libzmq 2.0.0. int recoveryIvl (); // Set socket option `recovery_ivl`. // Available from libzmq 2.0.0. void setRecoveryIvl (int recoveryIvl); // Get socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. int recoveryIvlMsec (); // Set socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. void setRecoveryIvlMsec (int recoveryIvlMsec); // Get socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. int mcastLoop (); // Set socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. void setMcastLoop (int mcastLoop); // Get socket option `rcvtimeo`. // Available from libzmq 2.2.0. int rcvtimeo (); // Set socket option `rcvtimeo`. // Available from libzmq 2.2.0. void setRcvtimeo (int rcvtimeo); // Get socket option `sndtimeo`. // Available from libzmq 2.2.0. int sndtimeo (); // Set socket option `sndtimeo`. // Available from libzmq 2.2.0. void setSndtimeo (int sndtimeo); // Get socket option `sndbuf`. // Available from libzmq 2.0.0. int sndbuf (); // Set socket option `sndbuf`. // Available from libzmq 2.0.0. void setSndbuf (int sndbuf); // Get socket option `rcvbuf`. // Available from libzmq 2.0.0. int rcvbuf (); // Set socket option `rcvbuf`. // Available from libzmq 2.0.0. void setRcvbuf (int rcvbuf); // Get socket option `linger`. // Available from libzmq 2.0.0. int linger (); // Set socket option `linger`. // Available from libzmq 2.0.0. void setLinger (int linger); // Get socket option `reconnect_ivl`. // Available from libzmq 2.0.0. int reconnectIvl (); // Set socket option `reconnect_ivl`. // Available from libzmq 2.0.0. void setReconnectIvl (int reconnectIvl); // Get socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. int reconnectIvlMax (); // Set socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. void setReconnectIvlMax (int reconnectIvlMax); // Get socket option `backlog`. // Available from libzmq 2.0.0. int backlog (); // Set socket option `backlog`. // Available from libzmq 2.0.0. void setBacklog (int backlog); // Set socket option `subscribe`. // Available from libzmq 2.0.0. void setSubscribe (const QString &subscribe); // Set socket option `unsubscribe`. // Available from libzmq 2.0.0. void setUnsubscribe (const QString &unsubscribe); // Get socket option `type`. // Available from libzmq 2.0.0. int type (); // Get socket option `rcvmore`. // Available from libzmq 2.0.0. int rcvmore (); // Get socket option `fd`. // Available from libzmq 2.0.0. SOCKET fd (); // Get socket option `events`. // Available from libzmq 2.0.0. int events (); }; class QmlZsockAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZsockAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. bool is (void *self); // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. void *resolve (void *self); // Self test of this class. void test (bool verbose); // Create a new socket. Returns the new socket, or NULL if the new socket // could not be created. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection. This can have // performance implications if you use a LOT of sockets. To turn off this // redirection behaviour, define ZSOCK_NOCHECK. QmlZsock *construct (int type); // Create a PUB socket. Default action is bind. QmlZsock *constructPub (const QString &endpoint); // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. QmlZsock *constructSub (const QString &endpoint, const QString &subscribe); // Create a REQ socket. Default action is connect. QmlZsock *constructReq (const QString &endpoint); // Create a REP socket. Default action is bind. QmlZsock *constructRep (const QString &endpoint); // Create a DEALER socket. Default action is connect. QmlZsock *constructDealer (const QString &endpoint); // Create a ROUTER socket. Default action is bind. QmlZsock *constructRouter (const QString &endpoint); // Create a PUSH socket. Default action is connect. QmlZsock *constructPush (const QString &endpoint); // Create a PULL socket. Default action is bind. QmlZsock *constructPull (const QString &endpoint); // Create an XPUB socket. Default action is bind. QmlZsock *constructXpub (const QString &endpoint); // Create an XSUB socket. Default action is connect. QmlZsock *constructXsub (const QString &endpoint); // Create a PAIR socket. Default action is connect. QmlZsock *constructPair (const QString &endpoint); // Create a STREAM socket. Default action is connect. QmlZsock *constructStream (const QString &endpoint); // Create a SERVER socket. Default action is bind. QmlZsock *constructServer (const QString &endpoint); // Create a CLIENT socket. Default action is connect. QmlZsock *constructClient (const QString &endpoint); // Create a RADIO socket. Default action is bind. QmlZsock *constructRadio (const QString &endpoint); // Create a DISH socket. Default action is connect. QmlZsock *constructDish (const QString &endpoint); // Create a GATHER socket. Default action is bind. QmlZsock *constructGather (const QString &endpoint); // Create a SCATTER socket. Default action is connect. QmlZsock *constructScatter (const QString &endpoint); // Destroy the socket. You must use this for any socket created via the // zsock_new method. void destruct (QmlZsock *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZsock, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZframe.h0000664000372000037200000001075213222211156020614 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZFRAME_H #define QML_ZFRAME_H #include #include #include "qml_czmq_plugin.h" class QmlZframe : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zframe_t *self; QmlZframe() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZframe.cpp public slots: // Return number of bytes in frame data size_t size (); // Return address of frame data byte *data (); // Return meta data property for frame // The caller shall not modify or free the returned value, which shall be // owned by the message. const QString meta (const QString &property); // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. QmlZframe *dup (); // Return frame data encoded as printable hex string, useful for 0MQ UUIDs. // Caller must free string when finished with it. QString strhex (); // Return frame data copied into freshly allocated string // Caller must free string when finished with it. QString strdup (); // Return TRUE if frame body is equal to string, excluding terminator bool streq (const QString &string); // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method int more (); // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. void setMore (int more); // Return frame routing ID, if the frame came from a ZMQ_SERVER socket. // Else returns zero. uint32_t routingId (); // Set routing ID on frame. This is used if/when the frame is sent to a // ZMQ_SERVER socket. void setRoutingId (uint32_t routingId); // Return frame group of radio-dish pattern. const QString group (); // Set group on frame. This is used if/when the frame is sent to a // ZMQ_RADIO socket. // Return -1 on error, 0 on success. int setGroup (const QString &group); // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false. bool eq (QmlZframe *other); // Set new contents for frame void reset (const void *data, size_t size); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. void print (const QString &prefix); }; class QmlZframeAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZframeAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Send a frame to a socket, destroy frame after sending. // Return -1 on error, 0 on success. int send (QmlZframe *selfP, void *dest, int flags); // Probe the supplied object, and report if it looks like a zframe_t. bool is (void *self); // Self test of this class. void test (bool verbose); // Create a new frame. If size is not null, allocates the frame data // to the specified size. If additionally, data is not null, copies // size octets from the specified data into the frame body. QmlZframe *construct (const void *data, size_t size); // Create an empty (zero-sized) frame QmlZframe *constructEmpty (); // Create a frame with a specified string content. QmlZframe *from (const QString &string); // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. QmlZframe *recv (void *source); // Destroy a frame void destruct (QmlZframe *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZframe, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZcert.cpp0000664000372000037200000001141213222211156021004 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZcert.h" /// // Return public part of key pair as 32-byte binary string const byte *QmlZcert::publicKey () { return zcert_public_key (self); }; /// // Return secret part of key pair as 32-byte binary string const byte *QmlZcert::secretKey () { return zcert_secret_key (self); }; /// // Return public part of key pair as Z85 armored string const QString QmlZcert::publicTxt () { return QString (zcert_public_txt (self)); }; /// // Return secret part of key pair as Z85 armored string const QString QmlZcert::secretTxt () { return QString (zcert_secret_txt (self)); }; /// // Set certificate metadata from formatted string. void QmlZcert::setMeta (const QString &name, const QString &format) { zcert_set_meta (self, name.toUtf8().data(), "%s", format.toUtf8().data()); }; /// // Unset certificate metadata. void QmlZcert::unsetMeta (const QString &name) { zcert_unset_meta (self, name.toUtf8().data()); }; /// // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. const QString QmlZcert::meta (const QString &name) { return QString (zcert_meta (self, name.toUtf8().data())); }; /// // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. QmlZlist *QmlZcert::metaKeys () { QmlZlist *retQ_ = new QmlZlist (); retQ_->self = zcert_meta_keys (self); return retQ_; }; /// // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). int QmlZcert::save (const QString &filename) { return zcert_save (self, filename.toUtf8().data()); }; /// // Save public certificate only to file for persistent storage int QmlZcert::savePublic (const QString &filename) { return zcert_save_public (self, filename.toUtf8().data()); }; /// // Save secret certificate only to file for persistent storage int QmlZcert::saveSecret (const QString &filename) { return zcert_save_secret (self, filename.toUtf8().data()); }; /// // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. void QmlZcert::apply (void *socket) { zcert_apply (self, socket); }; /// // Return copy of certificate; if certificate is NULL or we exhausted // heap memory, returns NULL. QmlZcert *QmlZcert::dup () { QmlZcert *retQ_ = new QmlZcert (); retQ_->self = zcert_dup (self); return retQ_; }; /// // Return true if two certificates have the same keys bool QmlZcert::eq (QmlZcert *compare) { return zcert_eq (self, compare->self); }; /// // Print certificate contents to stdout void QmlZcert::print () { zcert_print (self); }; QObject* QmlZcert::qmlAttachedProperties(QObject* object) { return new QmlZcertAttached(object); } /// // Self test of this class void QmlZcertAttached::test (bool verbose) { zcert_test (verbose); }; /// // Create and initialize a new certificate in memory QmlZcert *QmlZcertAttached::construct () { QmlZcert *qmlSelf = new QmlZcert (); qmlSelf->self = zcert_new (); return qmlSelf; }; /// // Accepts public/secret key pair from caller QmlZcert *QmlZcertAttached::constructFrom (const byte *publicKey, const byte *secretKey) { QmlZcert *qmlSelf = new QmlZcert (); qmlSelf->self = zcert_new_from (publicKey, secretKey); return qmlSelf; }; /// // Accepts public/secret key text pair from caller QmlZcert *QmlZcertAttached::constructFromTxt (const QString &publicTxt, const QString &secretTxt) { QmlZcert *qmlSelf = new QmlZcert (); qmlSelf->self = zcert_new_from_txt (publicTxt.toUtf8().data(), secretTxt.toUtf8().data()); return qmlSelf; }; /// // Load certificate from file QmlZcert *QmlZcertAttached::load (const QString &filename) { QmlZcert *qmlSelf = new QmlZcert (); qmlSelf->self = zcert_load (filename.toUtf8().data()); return qmlSelf; }; /// // Destroy a certificate in memory void QmlZcertAttached::destruct (QmlZcert *qmlSelf) { zcert_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZclock.h0000664000372000037200000000441113222211156020610 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZCLOCK_H #define QML_ZCLOCK_H #include #include #include "qml_czmq_plugin.h" class QmlZclock : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zclock_t *self; QmlZclock() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZclock.cpp public slots:}; class QmlZclockAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZclockAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Sleep for a number of milliseconds void sleep (int msecs); // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. int64_t time (); // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t mono (); // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t usecs (); // Return formatted date/time as fresh string. Free using zstr_free(). QString timestr (); // Self test of this class. void test (bool verbose); }; QML_DECLARE_TYPEINFO(QmlZclock, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZdir.cpp0000664000372000037200000001113613222211156020630 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZdir.h" /// // Return directory path const QString QmlZdir::path () { return QString (zdir_path (self)); }; /// // Return last modification time for directory. time_t QmlZdir::modified () { return zdir_modified (self); }; /// // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. off_t QmlZdir::cursize () { return zdir_cursize (self); }; /// // Return directory count size_t QmlZdir::count () { return zdir_count (self); }; /// // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. QmlZlist *QmlZdir::list () { QmlZlist *retQ_ = new QmlZlist (); retQ_->self = zdir_list (self); return retQ_; }; /// // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. void QmlZdir::remove (bool force) { zdir_remove (self, force); }; /// // Return full contents of directory as a zdir_patch list. QmlZlist *QmlZdir::resync (const QString &alias) { QmlZlist *retQ_ = new QmlZlist (); retQ_->self = zdir_resync (self, alias.toUtf8().data()); return retQ_; }; /// // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. QmlZhash *QmlZdir::cache () { QmlZhash *retQ_ = new QmlZhash (); retQ_->self = zdir_cache (self); return retQ_; }; /// // Print contents of directory to open stream void QmlZdir::fprint (FILE *file, int indent) { zdir_fprint (self, file, indent); }; /// // Print contents of directory to stdout void QmlZdir::print (int indent) { zdir_print (self, indent); }; QObject* QmlZdir::qmlAttachedProperties(QObject* object) { return new QmlZdirAttached(object); } /// // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). QmlZlist *QmlZdirAttached::diff (QmlZdir *older, QmlZdir *newer, const QString &alias) { QmlZlist *retQ_ = new QmlZlist (); retQ_->self = zdir_diff (older->self, newer->self, alias.toUtf8().data()); return retQ_; }; /// // Create a new zdir_watch actor instance: // // zactor_t *watch = zactor_new (zdir_watch, NULL); // // Destroy zdir_watch instance: // // zactor_destroy (&watch); // // Enable verbose logging of commands and activity: // // zstr_send (watch, "VERBOSE"); // // Subscribe to changes to a directory path: // // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); // // Unsubscribe from changes to a directory path: // // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); // // Receive directory changes: // zsock_recv (watch, "sp", &path, &patches); // // // Delete the received data. // free (path); // zlist_destroy (&patches); void QmlZdirAttached::watch (QmlZsock *pipe, void *unused) { zdir_watch (pipe->self, unused); }; /// // Self test of this class. void QmlZdirAttached::test (bool verbose) { zdir_test (verbose); }; /// // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. QmlZdir *QmlZdirAttached::construct (const QString &path, const QString &parent) { QmlZdir *qmlSelf = new QmlZdir (); qmlSelf->self = zdir_new (path.toUtf8().data(), parent.toUtf8().data()); return qmlSelf; }; /// // Destroy a directory tree and all children it contains. void QmlZdirAttached::destruct (QmlZdir *qmlSelf) { zdir_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZfile.h0000664000372000037200000001172413222211156020441 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZFILE_H #define QML_ZFILE_H #include #include #include "qml_czmq_plugin.h" class QmlZfile : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zfile_t *self; QmlZfile() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZfile.cpp public slots: // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. QmlZfile *dup (); // Return file name, remove path if provided const QString filename (const QString &path); // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. void restat (); // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. time_t modified (); // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. off_t cursize (); // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool isDirectory (); // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool isRegular (); // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. bool isReadable (); // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. bool isWriteable (); // Check if file has stopped changing and can be safely processed. // Updates the file statistics from disk at every call. bool isStable (); // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. bool hasChanged (); // Remove the file from disk void remove (); // Open file for reading // Returns 0 if OK, -1 if not found or not accessible int input (); // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. int output (); // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. QmlZchunk *read (size_t bytes, off_t offset); // Returns true if zfile_read() just read the last chunk in the file. bool eof (); // Write chunk to file at specified position // Return 0 if OK, else -1 int write (QmlZchunk *chunk, off_t offset); // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. const QString readln (); // Close file, if open void close (); // Return file handle, if opened FILE *handle (); // Calculate SHA1 digest for file, using zdigest class. const QString digest (); }; class QmlZfileAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZfileAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class. void test (bool verbose); // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. QmlZfile *construct (const QString &path, const QString &name); // Create new temporary file for writing via tmpfile. File is automaticaly // deleted on destroy QmlZfile *tmp (); // Destroy a file item void destruct (QmlZfile *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZfile, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZclock.cpp0000664000372000037200000000411413222211156021143 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZclock.h" QObject* QmlZclock::qmlAttachedProperties(QObject* object) { return new QmlZclockAttached(object); } /// // Sleep for a number of milliseconds void QmlZclockAttached::sleep (int msecs) { zclock_sleep (msecs); }; /// // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. int64_t QmlZclockAttached::time () { return zclock_time (); }; /// // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t QmlZclockAttached::mono () { return zclock_mono (); }; /// // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t QmlZclockAttached::usecs () { return zclock_usecs (); }; /// // Return formatted date/time as fresh string. Free using zstr_free(). QString QmlZclockAttached::timestr () { char *retStr_ = zclock_timestr (); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Self test of this class. void QmlZclockAttached::test (bool verbose) { zclock_test (verbose); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZactor.h0000664000372000037200000000507313222211156020632 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZACTOR_H #define QML_ZACTOR_H #include #include #include "qml_czmq_plugin.h" class QmlZactor : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zactor_t *self; QmlZactor() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZactor.cpp public slots: // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. int send (QmlZmsg *msgP); // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. QmlZmsg *recv (); // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. QmlZsock *sock (); // Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. void setDestructor (zactor_destructor_fn destructor); }; class QmlZactorAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZactorAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Probe the supplied object, and report if it looks like a zactor_t. bool is (void *self); // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. void *resolve (void *self); // Self test of this class. void test (bool verbose); // Create a new actor passing arbitrary arguments reference. QmlZactor *construct (zactor_fn task, void *args); // Destroy an actor. void destruct (QmlZactor *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZactor, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZtimerset.h0000664000372000037200000000502313222211156021351 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZTIMERSET_H #define QML_ZTIMERSET_H #include #include #include "qml_czmq_plugin.h" class QmlZtimerset : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: ztimerset_t *self; QmlZtimerset() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZtimerset.cpp public slots: // Add a timer to the set. Returns timer id if OK, -1 on failure. int add (size_t interval, ztimerset_fn handler, void *arg); // Cancel a timer. Returns 0 if OK, -1 on failure. int cancel (int timerId); // Set timer interval. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int setInterval (int timerId, size_t interval); // Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int reset (int timerId); // Return the time until the next interval. // Should be used as timeout parameter for the zpoller wait method. // The timeout is in msec. int timeout (); // Invoke callback function of all timers which their interval has elapsed. // Should be call after zpoller wait method. // Returns 0 if OK, -1 on failure. int execute (); }; class QmlZtimersetAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZtimersetAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class. void test (bool verbose); // Create new timer set. QmlZtimerset *construct (); // Destroy a timer set void destruct (QmlZtimerset *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZtimerset, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZloop.h0000664000372000037200000001403013222211156020464 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZLOOP_H #define QML_ZLOOP_H #include #include #include "qml_czmq_plugin.h" class QmlZloop : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zloop_t *self; QmlZloop() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZloop.cpp public slots: // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. int reader (QmlZsock *sock, zloop_reader_fn handler, void *arg); // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. void readerEnd (QmlZsock *sock); // Configure a registered reader to ignore errors. If you do not set this, // then readers that have errors are removed from the reactor silently. void readerSetTolerant (QmlZsock *sock); // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. int poller (zmq_pollitem_t *item, zloop_fn handler, void *arg); // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. void pollerEnd (zmq_pollitem_t *item); // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. void pollerSetTolerant (zmq_pollitem_t *item); // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. int timer (size_t delay, size_t times, zloop_timer_fn handler, void *arg); // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer). int timerEnd (int timerId); // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. void *ticket (zloop_timer_fn handler, void *arg); // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. void ticketReset (void *handle); // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. void ticketDelete (void *handle); // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. void setTicketDelay (size_t ticketDelay); // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. void setMaxTimers (size_t maxTimers); // Set verbose tracing of reactor on/off. The default verbose setting is // off (false). void setVerbose (bool verbose); // By default the reactor stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void setNonstop (bool nonstop); // Start the reactor. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. int start (); }; class QmlZloopAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZloopAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class. void test (bool verbose); // Create a new zloop reactor QmlZloop *construct (); // Destroy a reactor void destruct (QmlZloop *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZloop, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZcert.h0000664000372000037200000000731413222211156020457 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZCERT_H #define QML_ZCERT_H #include #include #include "qml_czmq_plugin.h" class QmlZcert : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zcert_t *self; QmlZcert() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZcert.cpp public slots: // Return public part of key pair as 32-byte binary string const byte *publicKey (); // Return secret part of key pair as 32-byte binary string const byte *secretKey (); // Return public part of key pair as Z85 armored string const QString publicTxt (); // Return secret part of key pair as Z85 armored string const QString secretTxt (); // Set certificate metadata from formatted string. void setMeta (const QString &name, const QString &format); // Unset certificate metadata. void unsetMeta (const QString &name); // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. const QString meta (const QString &name); // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. QmlZlist *metaKeys (); // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). int save (const QString &filename); // Save public certificate only to file for persistent storage int savePublic (const QString &filename); // Save secret certificate only to file for persistent storage int saveSecret (const QString &filename); // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. void apply (void *socket); // Return copy of certificate; if certificate is NULL or we exhausted // heap memory, returns NULL. QmlZcert *dup (); // Return true if two certificates have the same keys bool eq (QmlZcert *compare); // Print certificate contents to stdout void print (); }; class QmlZcertAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZcertAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class void test (bool verbose); // Create and initialize a new certificate in memory QmlZcert *construct (); // Accepts public/secret key pair from caller QmlZcert *constructFrom (const byte *publicKey, const byte *secretKey); // Accepts public/secret key text pair from caller QmlZcert *constructFromTxt (const QString &publicTxt, const QString &secretTxt); // Load certificate from file QmlZcert *load (const QString &filename); // Destroy a certificate in memory void destruct (QmlZcert *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZcert, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZchunk.cpp0000664000372000037200000001425313222211156021165 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZchunk.h" /// // Resizes chunk max_size as requested; chunk_cur size is set to zero void QmlZchunk::resize (size_t size) { zchunk_resize (self, size); }; /// // Return chunk cur size size_t QmlZchunk::size () { return zchunk_size (self); }; /// // Return chunk max size size_t QmlZchunk::maxSize () { return zchunk_max_size (self); }; /// // Return chunk data byte *QmlZchunk::data () { return zchunk_data (self); }; /// // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk size_t QmlZchunk::set (const void *data, size_t size) { return zchunk_set (self, data, size); }; /// // Fill chunk data from user-supplied octet size_t QmlZchunk::fill (byte filler, size_t size) { return zchunk_fill (self, filler, size); }; /// // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, it is truncated. If you want to // grow the chunk to accommodate new data, use the zchunk_extend method. size_t QmlZchunk::append (const void *data, size_t size) { return zchunk_append (self, data, size); }; /// // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, the chunk grows in size. size_t QmlZchunk::extend (const void *data, size_t size) { return zchunk_extend (self, data, size); }; /// // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. size_t QmlZchunk::consume (QmlZchunk *source) { return zchunk_consume (self, source->self); }; /// // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. bool QmlZchunk::exhausted () { return zchunk_exhausted (self); }; /// // Write chunk to an open file descriptor int QmlZchunk::write (FILE *handle) { return zchunk_write (self, handle); }; /// // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // returns null. QmlZchunk *QmlZchunk::dup () { QmlZchunk *retQ_ = new QmlZchunk (); retQ_->self = zchunk_dup (self); return retQ_; }; /// // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. QString QmlZchunk::strhex () { char *retStr_ = zchunk_strhex (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. QString QmlZchunk::strdup () { char *retStr_ = zchunk_strdup (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Return TRUE if chunk body is equal to string, excluding terminator bool QmlZchunk::streq (const QString &string) { return zchunk_streq (self, string.toUtf8().data()); }; /// // Transform zchunk into a zframe that can be sent in a message. QmlZframe *QmlZchunk::pack () { QmlZframe *retQ_ = new QmlZframe (); retQ_->self = zchunk_pack (self); return retQ_; }; /// // Calculate SHA1 digest for chunk, using zdigest class. const QString QmlZchunk::digest () { return QString (zchunk_digest (self)); }; /// // Dump chunk to FILE stream, for debugging and tracing. void QmlZchunk::fprint (FILE *file) { zchunk_fprint (self, file); }; /// // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details void QmlZchunk::print () { zchunk_print (self); }; QObject* QmlZchunk::qmlAttachedProperties(QObject* object) { return new QmlZchunkAttached(object); } /// // Read chunk from an open file descriptor QmlZchunk *QmlZchunkAttached::read (FILE *handle, size_t bytes) { QmlZchunk *retQ_ = new QmlZchunk (); retQ_->self = zchunk_read (handle, bytes); return retQ_; }; /// // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. QmlZchunk *QmlZchunkAttached::slurp (const QString &filename, size_t maxsize) { QmlZchunk *retQ_ = new QmlZchunk (); retQ_->self = zchunk_slurp (filename.toUtf8().data(), maxsize); return retQ_; }; /// // Transform a zframe into a zchunk. QmlZchunk *QmlZchunkAttached::unpack (QmlZframe *frame) { QmlZchunk *retQ_ = new QmlZchunk (); retQ_->self = zchunk_unpack (frame->self); return retQ_; }; /// // Probe the supplied object, and report if it looks like a zchunk_t. bool QmlZchunkAttached::is (void *self) { return zchunk_is (self); }; /// // Self test of this class. void QmlZchunkAttached::test (bool verbose) { zchunk_test (verbose); }; /// // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. QmlZchunk *QmlZchunkAttached::construct (const void *data, size_t size) { QmlZchunk *qmlSelf = new QmlZchunk (); qmlSelf->self = zchunk_new (data, size); return qmlSelf; }; /// // Destroy a chunk void QmlZchunkAttached::destruct (QmlZchunk *qmlSelf) { zchunk_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZarmour.cpp0000664000372000037200000000653513222211156021366 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZarmour.h" /// // Encode a stream of bytes into an armoured string. Returns the armoured // string, or NULL if there was insufficient memory available to allocate // a new string. QString QmlZarmour::encode (const byte *data, size_t size) { char *retStr_ = zarmour_encode (self, data, size); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Decode an armoured string into a chunk. The decoded output is // null-terminated, so it may be treated as a string, if that's what // it was prior to encoding. QmlZchunk *QmlZarmour::decode (const QString &data) { QmlZchunk *retQ_ = new QmlZchunk (); retQ_->self = zarmour_decode (self, data.toUtf8().data()); return retQ_; }; /// // Get the mode property. int QmlZarmour::mode () { return zarmour_mode (self); }; /// // Get printable string for mode. const QString QmlZarmour::modeStr () { return QString (zarmour_mode_str (self)); }; /// // Set the mode property. void QmlZarmour::setMode (int mode) { zarmour_set_mode (self, mode); }; /// // Return true if padding is turned on. bool QmlZarmour::pad () { return zarmour_pad (self); }; /// // Turn padding on or off. Default is on. void QmlZarmour::setPad (bool pad) { zarmour_set_pad (self, pad); }; /// // Get the padding character. char QmlZarmour::padChar () { return zarmour_pad_char (self); }; /// // Set the padding character. void QmlZarmour::setPadChar (char padChar) { zarmour_set_pad_char (self, padChar); }; /// // Return if splitting output into lines is turned on. Default is off. bool QmlZarmour::lineBreaks () { return zarmour_line_breaks (self); }; /// // Turn splitting output into lines on or off. void QmlZarmour::setLineBreaks (bool lineBreaks) { zarmour_set_line_breaks (self, lineBreaks); }; /// // Get the line length used for splitting lines. size_t QmlZarmour::lineLength () { return zarmour_line_length (self); }; /// // Set the line length used for splitting lines. void QmlZarmour::setLineLength (size_t lineLength) { zarmour_set_line_length (self, lineLength); }; /// // Print properties of object void QmlZarmour::print () { zarmour_print (self); }; QObject* QmlZarmour::qmlAttachedProperties(QObject* object) { return new QmlZarmourAttached(object); } /// // Self test of this class. void QmlZarmourAttached::test (bool verbose) { zarmour_test (verbose); }; /// // Create a new zarmour QmlZarmour *QmlZarmourAttached::construct () { QmlZarmour *qmlSelf = new QmlZarmour (); qmlSelf->self = zarmour_new (); return qmlSelf; }; /// // Destroy the zarmour void QmlZarmourAttached::destruct (QmlZarmour *qmlSelf) { zarmour_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZtrie.cpp0000664000372000037200000000606213222211156021017 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZtrie.h" /// // Inserts a new route into the tree and attaches the data. Returns -1 // if the route already exists, otherwise 0. This method takes ownership of // the provided data if a destroy_data_fn is provided. int QmlZtrie::insertRoute (const QString &path, void *data, ztrie_destroy_data_fn destroyDataFn) { return ztrie_insert_route (self, path.toUtf8().data(), data, destroyDataFn); }; /// // Removes a route from the trie and destroys its data. Returns -1 if the // route does not exists, otherwise 0. // the start of the list call zlist_first (). Advances the cursor. int QmlZtrie::removeRoute (const QString &path) { return ztrie_remove_route (self, path.toUtf8().data()); }; /// // Returns true if the path matches a route in the tree, otherwise false. bool QmlZtrie::matches (const QString &path) { return ztrie_matches (self, path.toUtf8().data()); }; /// // Returns the data of a matched route from last ztrie_matches. If the path // did not match, returns NULL. Do not delete the data as it's owned by // ztrie. void *QmlZtrie::hitData () { return ztrie_hit_data (self); }; /// // Returns the count of parameters that a matched route has. size_t QmlZtrie::hitParameterCount () { return ztrie_hit_parameter_count (self); }; /// // Returns the parameters of a matched route with named regexes from last // ztrie_matches. If the path did not match or the route did not contain any // named regexes, returns NULL. QmlZhashx *QmlZtrie::hitParameters () { QmlZhashx *retQ_ = new QmlZhashx (); retQ_->self = ztrie_hit_parameters (self); return retQ_; }; /// // Returns the asterisk matched part of a route, if there has been no match // or no asterisk match, returns NULL. const QString QmlZtrie::hitAsteriskMatch () { return QString (ztrie_hit_asterisk_match (self)); }; /// // Print the trie void QmlZtrie::print () { ztrie_print (self); }; QObject* QmlZtrie::qmlAttachedProperties(QObject* object) { return new QmlZtrieAttached(object); } /// // Self test of this class. void QmlZtrieAttached::test (bool verbose) { ztrie_test (verbose); }; /// // Creates a new ztrie. QmlZtrie *QmlZtrieAttached::construct (char delimiter) { QmlZtrie *qmlSelf = new QmlZtrie (); qmlSelf->self = ztrie_new (delimiter); return qmlSelf; }; /// // Destroy the ztrie. void QmlZtrieAttached::destruct (QmlZtrie *qmlSelf) { ztrie_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZpoller.cpp0000664000372000037200000000651013222211156021347 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZpoller.h" /// // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. int QmlZpoller::add (void *reader) { return zpoller_add (self, reader); }; /// // Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader // must have been passed during construction, or in an zpoller_add () call. int QmlZpoller::remove (void *reader) { return zpoller_remove (self, reader); }; /// // By default the poller stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void QmlZpoller::setNonstop (bool nonstop) { zpoller_set_nonstop (self, nonstop); }; /// // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. void *QmlZpoller::wait (int timeout) { return zpoller_wait (self, timeout); }; /// // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. bool QmlZpoller::expired () { return zpoller_expired (self); }; /// // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. bool QmlZpoller::terminated () { return zpoller_terminated (self); }; QObject* QmlZpoller::qmlAttachedProperties(QObject* object) { return new QmlZpollerAttached(object); } /// // Self test of this class. void QmlZpollerAttached::test (bool verbose) { zpoller_test (verbose); }; /// // Create new poller, specifying zero or more readers. The list of // readers ends in a NULL. Each reader can be a zsock_t instance, a // zactor_t instance, a libzmq socket (void *), or a file handle. QmlZpoller *QmlZpollerAttached::construct (void *reader) { QmlZpoller *qmlSelf = new QmlZpoller (); qmlSelf->self = zpoller_new (reader); return qmlSelf; }; /// // Destroy a poller void QmlZpollerAttached::destruct (QmlZpoller *qmlSelf) { zpoller_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZargs.cpp0000664000372000037200000000646313222211156021015 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZargs.h" /// // Return program name (argv[0]) const QString QmlZargs::progname () { return QString (zargs_progname (self)); }; /// // Return number of positional arguments size_t QmlZargs::arguments () { return zargs_arguments (self); }; /// // Return first positional argument or NULL const QString QmlZargs::first () { return QString (zargs_first (self)); }; /// // Return next positional argument or NULL const QString QmlZargs::next () { return QString (zargs_next (self)); }; /// // Return first named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const QString QmlZargs::paramFirst () { return QString (zargs_param_first (self)); }; /// // Return next named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const QString QmlZargs::paramNext () { return QString (zargs_param_next (self)); }; /// // Return current parameter name, or NULL if there are no named // parameters. const QString QmlZargs::paramName () { return QString (zargs_param_name (self)); }; /// // Return value of named parameter, NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const QString QmlZargs::paramLookup (const QString &keys) { return QString (zargs_param_lookup (self, keys.toUtf8().data())); }; /// // Return value of named parameter(s), NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const QString QmlZargs::paramLookupx (const QString &keys) { return QString (zargs_param_lookupx (self, keys.toUtf8().data())); }; /// // Returns true if there are --help -h arguments bool QmlZargs::hasHelp () { return zargs_has_help (self); }; /// // Print an instance of zargs. void QmlZargs::print () { zargs_print (self); }; QObject* QmlZargs::qmlAttachedProperties(QObject* object) { return new QmlZargsAttached(object); } /// // Returns true if parameter did not have a value bool QmlZargsAttached::paramEmpty (const QString &arg) { return zargs_param_empty (arg.toUtf8().data()); }; /// // Self test of this class. void QmlZargsAttached::test (bool verbose) { zargs_test (verbose); }; /// // Create a new zargs from command line arguments. QmlZargs *QmlZargsAttached::construct (int argc, QString argv) { QmlZargs *qmlSelf = new QmlZargs (); qmlSelf->self = zargs_new (argc, argv.toUtf8().data()); return qmlSelf; }; /// // Destroy zargs instance. void QmlZargsAttached::destruct (QmlZargs *qmlSelf) { zargs_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZargs.h0000664000372000037200000000571613222211156020462 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZARGS_H #define QML_ZARGS_H #include #include #include "qml_czmq_plugin.h" class QmlZargs : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zargs_t *self; QmlZargs() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZargs.cpp public slots: // Return program name (argv[0]) const QString progname (); // Return number of positional arguments size_t arguments (); // Return first positional argument or NULL const QString first (); // Return next positional argument or NULL const QString next (); // Return first named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const QString paramFirst (); // Return next named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const QString paramNext (); // Return current parameter name, or NULL if there are no named // parameters. const QString paramName (); // Return value of named parameter, NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const QString paramLookup (const QString &keys); // Return value of named parameter(s), NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const QString paramLookupx (const QString &keys); // Returns true if there are --help -h arguments bool hasHelp (); // Print an instance of zargs. void print (); }; class QmlZargsAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZargsAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Returns true if parameter did not have a value bool paramEmpty (const QString &arg); // Self test of this class. void test (bool verbose); // Create a new zargs from command line arguments. QmlZargs *construct (int argc, QString argv); // Destroy zargs instance. void destruct (QmlZargs *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZargs, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZhash.cpp0000664000372000037200000001666113222211156021005 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZhash.h" /// // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int QmlZhash::insert (const QString &key, void *item) { return zhash_insert (self, key.toUtf8().data(), item); }; /// // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. void QmlZhash::update (const QString &key, void *item) { zhash_update (self, key.toUtf8().data(), item); }; /// // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void QmlZhash::delete (const QString &key) { zhash_delete (self, key.toUtf8().data()); }; /// // Return the item at the specified key, or null void *QmlZhash::lookup (const QString &key) { return zhash_lookup (self, key.toUtf8().data()); }; /// // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int QmlZhash::rename (const QString &oldKey, const QString &newKey) { return zhash_rename (self, oldKey.toUtf8().data(), newKey.toUtf8().data()); }; /// // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void *QmlZhash::freefn (const QString &key, zhash_free_fn freeFn) { return zhash_freefn (self, key.toUtf8().data(), freeFn); }; /// // Return the number of keys/items in the hash table size_t QmlZhash::size () { return zhash_size (self); }; /// // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. QmlZhash *QmlZhash::dup () { QmlZhash *retQ_ = new QmlZhash (); retQ_->self = zhash_dup (self); return retQ_; }; /// // Return keys for items in table QmlZlist *QmlZhash::keys () { QmlZlist *retQ_ = new QmlZlist (); retQ_->self = zhash_keys (self); return retQ_; }; /// // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhash_cursor(). NOTE: do NOT modify the table while iterating. void *QmlZhash::first () { return zhash_first (self); }; /// // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). To // access the key for this item use zhash_cursor(). NOTE: do NOT modify // the table while iterating. void *QmlZhash::next () { return zhash_next (self); }; /// // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const QString QmlZhash::cursor () { return QString (zhash_cursor (self)); }; /// // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void QmlZhash::comment (const QString &format) { zhash_comment (self, "%s", format.toUtf8().data()); }; /// // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. QmlZframe *QmlZhash::pack () { QmlZframe *retQ_ = new QmlZframe (); retQ_->self = zhash_pack (self); return retQ_; }; /// // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int QmlZhash::save (const QString &filename) { return zhash_save (self, filename.toUtf8().data()); }; /// // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int QmlZhash::load (const QString &filename) { return zhash_load (self, filename.toUtf8().data()); }; /// // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int QmlZhash::refresh () { return zhash_refresh (self); }; /// // Set hash for automatic value destruction. Note that this assumes that // values are NULL-terminated strings. Do not use with different types. void QmlZhash::autofree () { zhash_autofree (self); }; QObject* QmlZhash::qmlAttachedProperties(QObject* object) { return new QmlZhashAttached(object); } /// // Self test of this class. void QmlZhashAttached::test (bool verbose) { zhash_test (verbose); }; /// // Create a new, empty hash container QmlZhash *QmlZhashAttached::construct () { QmlZhash *qmlSelf = new QmlZhash (); qmlSelf->self = zhash_new (); return qmlSelf; }; /// // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. QmlZhash *QmlZhashAttached::unpack (QmlZframe *frame) { QmlZhash *qmlSelf = new QmlZhash (); qmlSelf->self = zhash_unpack (frame->self); return qmlSelf; }; /// // Destroy a hash container and all items in it void QmlZhashAttached::destruct (QmlZhash *qmlSelf) { zhash_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZtrie.h0000664000372000037200000000556113222211156020467 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZTRIE_H #define QML_ZTRIE_H #include #include #include "qml_czmq_plugin.h" class QmlZtrie : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: ztrie_t *self; QmlZtrie() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZtrie.cpp public slots: // Inserts a new route into the tree and attaches the data. Returns -1 // if the route already exists, otherwise 0. This method takes ownership of // the provided data if a destroy_data_fn is provided. int insertRoute (const QString &path, void *data, ztrie_destroy_data_fn destroyDataFn); // Removes a route from the trie and destroys its data. Returns -1 if the // route does not exists, otherwise 0. // the start of the list call zlist_first (). Advances the cursor. int removeRoute (const QString &path); // Returns true if the path matches a route in the tree, otherwise false. bool matches (const QString &path); // Returns the data of a matched route from last ztrie_matches. If the path // did not match, returns NULL. Do not delete the data as it's owned by // ztrie. void *hitData (); // Returns the count of parameters that a matched route has. size_t hitParameterCount (); // Returns the parameters of a matched route with named regexes from last // ztrie_matches. If the path did not match or the route did not contain any // named regexes, returns NULL. QmlZhashx *hitParameters (); // Returns the asterisk matched part of a route, if there has been no match // or no asterisk match, returns NULL. const QString hitAsteriskMatch (); // Print the trie void print (); }; class QmlZtrieAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZtrieAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class. void test (bool verbose); // Creates a new ztrie. QmlZtrie *construct (char delimiter); // Destroy the ztrie. void destruct (QmlZtrie *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZtrie, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZlist.h0000664000372000037200000001263513222211156020477 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZLIST_H #define QML_ZLIST_H #include #include #include "qml_czmq_plugin.h" class QmlZlist : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zlist_t *self; QmlZlist() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZlist.cpp public slots: // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void *first (); // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. void *next (); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void *last (); // Return first item in the list, or null, leaves the cursor void *head (); // Return last item in the list, or null, leaves the cursor void *tail (); // Return the current item of list. If the list is empty, returns NULL. // Leaves cursor pointing at the current item, or NULL if the list is empty. void *item (); // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int append (void *item); // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int push (void *item); // Pop the item off the start of the list, if any void *pop (); // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. bool exists (void *item); // Remove the specified item from the list if present void remove (void *item); // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. QmlZlist *dup (); // Purge all items from list void purge (); // Return number of items in the list size_t size (); // Sort the list. If the compare function is null, sorts the list by // ascending key value using a straight ASCII comparison. If you specify // a compare function, this decides how items are sorted. The sort is not // stable, so may reorder items with the same keys. The algorithm used is // combsort, a compromise between performance and simplicity. void sort (zlist_compare_fn compare); // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. void autofree (); // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. void comparefn (zlist_compare_fn fn); // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void *freefn (void *item, zlist_free_fn fn, bool atTail); }; class QmlZlistAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZlistAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class. void test (bool verbose); // Create a new list container QmlZlist *construct (); // Destroy a list container void destruct (QmlZlist *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZlist, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZsys.cpp0000664000372000037200000004765313222211156020705 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZsys.h" QObject* QmlZsys::qmlAttachedProperties(QObject* object) { return new QmlZsysAttached(object); } /// // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. void *QmlZsysAttached::init () { return zsys_init (); }; /// // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls. void QmlZsysAttached::shutdown () { zsys_shutdown (); }; /// // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. // *** This is for CZMQ internal use only and may change arbitrarily *** void *QmlZsysAttached::socket (int type, const QString &filename, size_t lineNbr) { return zsys_socket (type, filename.toUtf8().data(), lineNbr); }; /// // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). // *** This is for CZMQ internal use only and may change arbitrarily *** int QmlZsysAttached::close (void *handle, const QString &filename, size_t lineNbr) { return zsys_close (handle, filename.toUtf8().data(), lineNbr); }; /// // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** const QString QmlZsysAttached::sockname (int socktype) { return QString (zsys_sockname (socktype)); }; /// // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. QmlZsock *QmlZsysAttached::createPipe (QmlZsock *backendP) { QmlZsock *retQ_ = new QmlZsock (); retQ_->self = zsys_create_pipe (&backendP->self); return retQ_; }; /// // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. void QmlZsysAttached::handlerSet (zsys_handler_fn *handlerFn) { zsys_handler_set (handlerFn); }; /// // Reset interrupt handler, call this at exit if needed void QmlZsysAttached::handlerReset () { zsys_handler_reset (); }; /// // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. // Can be supressed by ZSYS_SIGHANDLER=false // *** This is for CZMQ internal use only and may change arbitrarily *** void QmlZsysAttached::catchInterrupts () { zsys_catch_interrupts (); }; /// // Return 1 if file exists, else zero bool QmlZsysAttached::fileExists (const QString &filename) { return zsys_file_exists (filename.toUtf8().data()); }; /// // Return file modification time. Returns 0 if the file does not exist. time_t QmlZsysAttached::fileModified (const QString &filename) { return zsys_file_modified (filename.toUtf8().data()); }; /// // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. int QmlZsysAttached::fileMode (const QString &filename) { return zsys_file_mode (filename.toUtf8().data()); }; /// // Delete file. Does not complain if the file is absent int QmlZsysAttached::fileDelete (const QString &filename) { return zsys_file_delete (filename.toUtf8().data()); }; /// // Check if file is 'stable' bool QmlZsysAttached::fileStable (const QString &filename) { return zsys_file_stable (filename.toUtf8().data()); }; /// // Create a file path if it doesn't exist. The file path is treated as // printf format. int QmlZsysAttached::dirCreate (const QString &pathname) { return zsys_dir_create (pathname.toUtf8().data()); }; /// // Remove a file path if empty; the pathname is treated as printf format. int QmlZsysAttached::dirDelete (const QString &pathname) { return zsys_dir_delete (pathname.toUtf8().data()); }; /// // Move to a specified working directory. Returns 0 if OK, -1 if this failed. int QmlZsysAttached::dirChange (const QString &pathname) { return zsys_dir_change (pathname.toUtf8().data()); }; /// // Set private file creation mode; all files created from here will be // readable/writable by the owner only. void QmlZsysAttached::fileModePrivate () { zsys_file_mode_private (); }; /// // Reset default file creation mode; all files created from here will use // process file mode defaults. void QmlZsysAttached::fileModeDefault () { zsys_file_mode_default (); }; /// // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. void QmlZsysAttached::version (int *major, int *minor, int *patch) { zsys_version (major, minor, 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(). const QString QmlZsysAttached::sprintf (const QString &format) { return QString (zsys_sprintf (format.toUtf8().data())); }; /// // Format a string with a va_list argument, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). const QString QmlZsysAttached::vprintf (const QString &format, va_list argptr) { return QString (zsys_vprintf (format.toUtf8().data(), argptr)); }; /// // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. // *** This is for CZMQ internal use only and may change arbitrarily *** SOCKET QmlZsysAttached::udpNew (bool routable) { return zsys_udp_new (routable); }; /// // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** int QmlZsysAttached::udpClose (SOCKET handle) { return zsys_udp_close (handle); }; /// // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** int QmlZsysAttached::udpSend (SOCKET udpsock, QmlZframe *frame, inaddr_t *address, int addrlen) { return zsys_udp_send (udpsock, frame->self, address, addrlen); }; /// // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or // NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. // *** This is for CZMQ internal use only and may change arbitrarily *** QmlZframe *QmlZsysAttached::udpRecv (SOCKET udpsock, const QString &peername, int peerlen) { QmlZframe *retQ_ = new QmlZframe (); retQ_->self = zsys_udp_recv (udpsock, peername.toUtf8().data(), peerlen); return retQ_; }; /// // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. // *** This is for CZMQ internal use only and may change arbitrarily *** void QmlZsysAttached::socketError (const QString &reason) { zsys_socket_error (reason.toUtf8().data()); }; /// // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. const QString QmlZsysAttached::hostname () { return QString (zsys_hostname ()); }; /// // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. int QmlZsysAttached::daemonize (const QString &workdir) { return zsys_daemonize (workdir.toUtf8().data()); }; /// // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. int QmlZsysAttached::runAs (const QString &lockfile, const QString &group, const QString &user) { return zsys_run_as (lockfile.toUtf8().data(), group.toUtf8().data(), user.toUtf8().data()); }; /// // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. bool QmlZsysAttached::hasCurve () { return zsys_has_curve (); }; /// // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void QmlZsysAttached::setIoThreads (size_t ioThreads) { zsys_set_io_threads (ioThreads); }; /// // Configure the scheduling policy of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY // is defined, that provides the default. // Note that this method is valid only before any socket is created. void QmlZsysAttached::setThreadSchedPolicy (int policy) { zsys_set_thread_sched_policy (policy); }; /// // Configure the scheduling priority of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_PRIORITY is // defined, that provides the default. // Note that this method is valid only before any socket is created. void QmlZsysAttached::setThreadPriority (int priority) { zsys_set_thread_priority (priority); }; /// // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void QmlZsysAttached::setMaxSockets (size_t maxSockets) { zsys_set_max_sockets (maxSockets); }; /// // Return maximum number of ZeroMQ sockets that the system will support. size_t QmlZsysAttached::socketLimit () { return zsys_socket_limit (); }; /// // Configure the maximum allowed size of a message sent. // The default is INT_MAX. void QmlZsysAttached::setMaxMsgsz (int maxMsgsz) { zsys_set_max_msgsz (maxMsgsz); }; /// // Return maximum message size. int QmlZsysAttached::maxMsgsz () { return zsys_max_msgsz (); }; /// // Configure the threshold value of filesystem object age per st_mtime // that should elapse until we consider that object "stable" at the // current zclock_time() moment. // The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c // which generally depends on host OS, with fallback value of 5000. void QmlZsysAttached::setFileStableAgeMsec (int64_t fileStableAgeMsec) { zsys_set_file_stable_age_msec (fileStableAgeMsec); }; /// // Return current threshold value of file stable age in msec. // This can be used in code that chooses to wait for this timeout // before testing if a filesystem object is "stable" or not. int64_t QmlZsysAttached::fileStableAgeMsec () { return zsys_file_stable_age_msec (); }; /// // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. void QmlZsysAttached::setLinger (size_t linger) { zsys_set_linger (linger); }; /// // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void QmlZsysAttached::setSndhwm (size_t sndhwm) { zsys_set_sndhwm (sndhwm); }; /// // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void QmlZsysAttached::setRcvhwm (size_t rcvhwm) { zsys_set_rcvhwm (rcvhwm); }; /// // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. void QmlZsysAttached::setPipehwm (size_t pipehwm) { zsys_set_pipehwm (pipehwm); }; /// // Return the HWM for zactor internal pipes. size_t QmlZsysAttached::pipehwm () { return zsys_pipehwm (); }; /// // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. void QmlZsysAttached::setIpv6 (int ipv6) { zsys_set_ipv6 (ipv6); }; /// // Return use of IPv6 for zsock instances. int QmlZsysAttached::ipv6 () { return zsys_ipv6 (); }; /// // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void QmlZsysAttached::setInterface (const QString &value) { zsys_set_interface (value.toUtf8().data()); }; /// // Return network interface to use for broadcasts, or "" if none was set. const QString QmlZsysAttached::interface () { return QString (zsys_interface ()); }; /// // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses // on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, // use that as the default IPv6 address. void QmlZsysAttached::setIpv6Address (const QString &value) { zsys_set_ipv6_address (value.toUtf8().data()); }; /// // Return IPv6 address to use for zbeacon reception, or "" if none was set. const QString QmlZsysAttached::ipv6Address () { return QString (zsys_ipv6_address ()); }; /// // Set IPv6 milticast address to use for sending zbeacon messages. This needs // to be set if IPv6 is enabled. If the environment variable // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast // address. void QmlZsysAttached::setIpv6McastAddress (const QString &value) { zsys_set_ipv6_mcast_address (value.toUtf8().data()); }; /// // Return IPv6 multicast address to use for sending zbeacon, or "" if none was // set. const QString QmlZsysAttached::ipv6McastAddress () { return QString (zsys_ipv6_mcast_address ()); }; /// // Configure the automatic use of pre-allocated FDs when creating new sockets. // If 0 (default), nothing will happen. Else, when a new socket is bound, the // system API will be used to check if an existing pre-allocated FD with a // matching port (if TCP) or path (if IPC) exists, and if it does it will be // set via the ZMQ_USE_FD socket option so that the library will use it // instead of creating a new socket. void QmlZsysAttached::setAutoUseFd (int autoUseFd) { zsys_set_auto_use_fd (autoUseFd); }; /// // Return use of automatic pre-allocated FDs for zsock instances. int QmlZsysAttached::autoUseFd () { return zsys_auto_use_fd (); }; /// // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void QmlZsysAttached::setLogident (const QString &value) { zsys_set_logident (value.toUtf8().data()); }; /// // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). void QmlZsysAttached::setLogstream (FILE *stream) { zsys_set_logstream (stream); }; /// // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void QmlZsysAttached::setLogsender (const QString &endpoint) { zsys_set_logsender (endpoint.toUtf8().data()); }; /// // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void QmlZsysAttached::setLogsystem (bool logsystem) { zsys_set_logsystem (logsystem); }; /// // Log error condition - highest priority void QmlZsysAttached::error (const QString &format) { zsys_error (format.toUtf8().data()); }; /// // Log warning condition - high priority void QmlZsysAttached::warning (const QString &format) { zsys_warning (format.toUtf8().data()); }; /// // Log normal, but significant, condition - normal priority void QmlZsysAttached::notice (const QString &format) { zsys_notice (format.toUtf8().data()); }; /// // Log informational message - low priority void QmlZsysAttached::info (const QString &format) { zsys_info (format.toUtf8().data()); }; /// // Log debug-level message - lowest priority void QmlZsysAttached::debug (const QString &format) { zsys_debug (format.toUtf8().data()); }; /// // Self test of this class. void QmlZsysAttached::test (bool verbose) { zsys_test (verbose); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZdir.h0000664000372000037200000001027713222211156020302 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZDIR_H #define QML_ZDIR_H #include #include #include "qml_czmq_plugin.h" class QmlZdir : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zdir_t *self; QmlZdir() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZdir.cpp public slots: // Return directory path const QString path (); // Return last modification time for directory. time_t modified (); // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. off_t cursize (); // Return directory count size_t count (); // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. QmlZlist *list (); // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. void remove (bool force); // Return full contents of directory as a zdir_patch list. QmlZlist *resync (const QString &alias); // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. QmlZhash *cache (); // Print contents of directory to open stream void fprint (FILE *file, int indent); // Print contents of directory to stdout void print (int indent); }; class QmlZdirAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZdirAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). QmlZlist *diff (QmlZdir *older, QmlZdir *newer, const QString &alias); // Create a new zdir_watch actor instance: // // zactor_t *watch = zactor_new (zdir_watch, NULL); // // Destroy zdir_watch instance: // // zactor_destroy (&watch); // // Enable verbose logging of commands and activity: // // zstr_send (watch, "VERBOSE"); // // Subscribe to changes to a directory path: // // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); // // Unsubscribe from changes to a directory path: // // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); // // Receive directory changes: // zsock_recv (watch, "sp", &path, &patches); // // // Delete the received data. // free (path); // zlist_destroy (&patches); void watch (QmlZsock *pipe, void *unused); // Self test of this class. void test (bool verbose); // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. QmlZdir *construct (const QString &path, const QString &parent); // Destroy a directory tree and all children it contains. void destruct (QmlZdir *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZdir, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZmsg.h0000664000372000037200000001743713222211156020317 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZMSG_H #define QML_ZMSG_H #include #include #include "qml_czmq_plugin.h" class QmlZmsg : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zmsg_t *self; QmlZmsg() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZmsg.cpp public slots: // Return size of message, i.e. number of frames (0 or more). size_t size (); // Return total size of all frames in message. size_t contentSize (); // Return message routing ID, if the message came from a ZMQ_SERVER socket. // Else returns zero. uint32_t routingId (); // Set routing ID on message. This is used if/when the message is sent to a // ZMQ_SERVER socket. void setRoutingId (uint32_t routingId); // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. int prepend (QmlZframe *frameP); // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Deprecates zmsg_add, which did not nullify the // caller's frame reference. int append (QmlZframe *frameP); // Remove first frame from message, if any. Returns frame, or NULL. QmlZframe *pop (); // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. int pushmem (const void *data, size_t size); // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. int addmem (const void *data, size_t size); // Push string as new frame to front of message. // Returns 0 on success, -1 on error. int pushstr (const QString &string); // Push string as new frame to end of message. // Returns 0 on success, -1 on error. int addstr (const QString &string); // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. int pushstrf (const QString &format); // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. int addstrf (const QString &format); // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. QString popstr (); // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. int addmsg (QmlZmsg *msgP); // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not successful. QmlZmsg *popmsg (); // Remove specified frame from list, if present. Does not destroy frame. void remove (QmlZframe *frame); // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. QmlZframe *first (); // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. QmlZframe *next (); // Return the last frame. If there are no frames, returns NULL. QmlZframe *last (); // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. int save (FILE *file); // Serialize multipart message to a single message frame. Use this method // to send structured messages across transports that do not support // multipart data. Allocates and returns a new frame containing the // serialized message. To decode a serialized message frame, use // zmsg_decode (). QmlZframe *encode (); // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. QmlZmsg *dup (); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). void print (); // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. bool eq (QmlZmsg *other); // Return signal value, 0 or greater, if message is a signal, -1 if not. int signal (); }; class QmlZmsgAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZmsgAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int send (QmlZmsg *selfP, void *dest); // Send message to destination socket as part of a multipart sequence, and // destroy the message after sending it successfully. Note that after a // zmsg_sendm, you must call zmsg_send or another method that sends a final // message part. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int sendm (QmlZmsg *selfP, void *dest); // Probe the supplied object, and report if it looks like a zmsg_t. bool is (void *self); // Self test of this class. void test (bool verbose); // Create a new empty message object QmlZmsg *construct (); // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted. Does a blocking recv. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving. QmlZmsg *recv (void *source); // Load/append an open file into new message, return the message. // Returns NULL if the message could not be loaded. QmlZmsg *load (FILE *file); // Decodes a serialized message frame created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the frame was badly formatted or // there was insufficient memory to work. QmlZmsg *decode (QmlZframe *frame); // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. QmlZmsg *constructSignal (byte status); // Destroy a message object and all frames it contains void destruct (QmlZmsg *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZmsg, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZsys.h0000664000372000037200000004171413222211156020342 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZSYS_H #define QML_ZSYS_H #include #include #include "qml_czmq_plugin.h" class QmlZsys : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zsys_t *self; QmlZsys() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZsys.cpp public slots:}; class QmlZsysAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZsysAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. void *init (); // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls. void shutdown (); // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. // *** This is for CZMQ internal use only and may change arbitrarily *** void *socket (int type, const QString &filename, size_t lineNbr); // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). // *** This is for CZMQ internal use only and may change arbitrarily *** int close (void *handle, const QString &filename, size_t lineNbr); // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** const QString sockname (int socktype); // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. QmlZsock *createPipe (QmlZsock *backendP); // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. void handlerSet (zsys_handler_fn *handlerFn); // Reset interrupt handler, call this at exit if needed void handlerReset (); // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. // Can be supressed by ZSYS_SIGHANDLER=false // *** This is for CZMQ internal use only and may change arbitrarily *** void catchInterrupts (); // Return 1 if file exists, else zero bool fileExists (const QString &filename); // Return file modification time. Returns 0 if the file does not exist. time_t fileModified (const QString &filename); // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. int fileMode (const QString &filename); // Delete file. Does not complain if the file is absent int fileDelete (const QString &filename); // Check if file is 'stable' bool fileStable (const QString &filename); // Create a file path if it doesn't exist. The file path is treated as // printf format. int dirCreate (const QString &pathname); // Remove a file path if empty; the pathname is treated as printf format. int dirDelete (const QString &pathname); // Move to a specified working directory. Returns 0 if OK, -1 if this failed. int dirChange (const QString &pathname); // Set private file creation mode; all files created from here will be // readable/writable by the owner only. void fileModePrivate (); // Reset default file creation mode; all files created from here will use // process file mode defaults. void fileModeDefault (); // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. void 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(). const QString sprintf (const QString &format); // Format a string with a va_list argument, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). const QString vprintf (const QString &format, va_list argptr); // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. // *** This is for CZMQ internal use only and may change arbitrarily *** SOCKET udpNew (bool routable); // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** int udpClose (SOCKET handle); // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** int udpSend (SOCKET udpsock, QmlZframe *frame, inaddr_t *address, int addrlen); // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or // NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. // *** This is for CZMQ internal use only and may change arbitrarily *** QmlZframe *udpRecv (SOCKET udpsock, const QString &peername, int peerlen); // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. // *** This is for CZMQ internal use only and may change arbitrarily *** void socketError (const QString &reason); // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. const QString hostname (); // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. int daemonize (const QString &workdir); // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. int runAs (const QString &lockfile, const QString &group, const QString &user); // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. bool hasCurve (); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void setIoThreads (size_t ioThreads); // Configure the scheduling policy of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY // is defined, that provides the default. // Note that this method is valid only before any socket is created. void setThreadSchedPolicy (int policy); // Configure the scheduling priority of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_PRIORITY is // defined, that provides the default. // Note that this method is valid only before any socket is created. void setThreadPriority (int priority); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void setMaxSockets (size_t maxSockets); // Return maximum number of ZeroMQ sockets that the system will support. size_t socketLimit (); // Configure the maximum allowed size of a message sent. // The default is INT_MAX. void setMaxMsgsz (int maxMsgsz); // Return maximum message size. int maxMsgsz (); // Configure the threshold value of filesystem object age per st_mtime // that should elapse until we consider that object "stable" at the // current zclock_time() moment. // The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c // which generally depends on host OS, with fallback value of 5000. void setFileStableAgeMsec (int64_t fileStableAgeMsec); // Return current threshold value of file stable age in msec. // This can be used in code that chooses to wait for this timeout // before testing if a filesystem object is "stable" or not. int64_t fileStableAgeMsec (); // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. void setLinger (size_t linger); // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void setSndhwm (size_t sndhwm); // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void setRcvhwm (size_t rcvhwm); // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. void setPipehwm (size_t pipehwm); // Return the HWM for zactor internal pipes. size_t pipehwm (); // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. void setIpv6 (int ipv6); // Return use of IPv6 for zsock instances. int ipv6 (); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void setInterface (const QString &value); // Return network interface to use for broadcasts, or "" if none was set. const QString interface (); // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses // on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, // use that as the default IPv6 address. void setIpv6Address (const QString &value); // Return IPv6 address to use for zbeacon reception, or "" if none was set. const QString ipv6Address (); // Set IPv6 milticast address to use for sending zbeacon messages. This needs // to be set if IPv6 is enabled. If the environment variable // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast // address. void setIpv6McastAddress (const QString &value); // Return IPv6 multicast address to use for sending zbeacon, or "" if none was // set. const QString ipv6McastAddress (); // Configure the automatic use of pre-allocated FDs when creating new sockets. // If 0 (default), nothing will happen. Else, when a new socket is bound, the // system API will be used to check if an existing pre-allocated FD with a // matching port (if TCP) or path (if IPC) exists, and if it does it will be // set via the ZMQ_USE_FD socket option so that the library will use it // instead of creating a new socket. void setAutoUseFd (int autoUseFd); // Return use of automatic pre-allocated FDs for zsock instances. int autoUseFd (); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void setLogident (const QString &value); // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). void setLogstream (FILE *stream); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void setLogsender (const QString &endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void setLogsystem (bool logsystem); // Log error condition - highest priority void error (const QString &format); // Log warning condition - high priority void warning (const QString &format); // Log normal, but significant, condition - normal priority void notice (const QString &format); // Log informational message - low priority void info (const QString &format); // Log debug-level message - lowest priority void debug (const QString &format); // Self test of this class. void test (bool verbose); }; QML_DECLARE_TYPEINFO(QmlZsys, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZcertstore.h0000664000372000037200000000621413222211156021532 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZCERTSTORE_H #define QML_ZCERTSTORE_H #include #include #include "qml_czmq_plugin.h" class QmlZcertstore : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zcertstore_t *self; QmlZcertstore() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZcertstore.cpp public slots: // Override the default disk loader with a custom loader fn. void setLoader (zcertstore_loader loader, zcertstore_destructor destructor, void *state); // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. QmlZcert *lookup (const QString &publicKey); // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. void insert (QmlZcert *certP); // Empty certificate hashtable. This wrapper exists to be friendly to bindings, // which don't usually have access to struct internals. void empty (); // Print list of certificates in store to logging facility void print (); // Return a list of all the certificates in the store. // The caller takes ownership of the zlistx_t object and is responsible // for destroying it. The caller does not take ownership of the zcert_t // objects. QmlZlistx *certs (); }; class QmlZcertstoreAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZcertstoreAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class void test (bool verbose); // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. QmlZcertstore *construct (const QString &location); // Destroy a certificate store object in memory. Does not affect anything // stored on disk. void destruct (QmlZcertstore *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZcertstore, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZlist.cpp0000664000372000037200000001342313222211156021026 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZlist.h" /// // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void *QmlZlist::first () { return zlist_first (self); }; /// // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. void *QmlZlist::next () { return zlist_next (self); }; /// // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void *QmlZlist::last () { return zlist_last (self); }; /// // Return first item in the list, or null, leaves the cursor void *QmlZlist::head () { return zlist_head (self); }; /// // Return last item in the list, or null, leaves the cursor void *QmlZlist::tail () { return zlist_tail (self); }; /// // Return the current item of list. If the list is empty, returns NULL. // Leaves cursor pointing at the current item, or NULL if the list is empty. void *QmlZlist::item () { return zlist_item (self); }; /// // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int QmlZlist::append (void *item) { return zlist_append (self, item); }; /// // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int QmlZlist::push (void *item) { return zlist_push (self, item); }; /// // Pop the item off the start of the list, if any void *QmlZlist::pop () { return zlist_pop (self); }; /// // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. bool QmlZlist::exists (void *item) { return zlist_exists (self, item); }; /// // Remove the specified item from the list if present void QmlZlist::remove (void *item) { zlist_remove (self, item); }; /// // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. QmlZlist *QmlZlist::dup () { QmlZlist *retQ_ = new QmlZlist (); retQ_->self = zlist_dup (self); return retQ_; }; /// // Purge all items from list void QmlZlist::purge () { zlist_purge (self); }; /// // Return number of items in the list size_t QmlZlist::size () { return zlist_size (self); }; /// // Sort the list. If the compare function is null, sorts the list by // ascending key value using a straight ASCII comparison. If you specify // a compare function, this decides how items are sorted. The sort is not // stable, so may reorder items with the same keys. The algorithm used is // combsort, a compromise between performance and simplicity. void QmlZlist::sort (zlist_compare_fn compare) { zlist_sort (self, compare); }; /// // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. void QmlZlist::autofree () { zlist_autofree (self); }; /// // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. void QmlZlist::comparefn (zlist_compare_fn fn) { zlist_comparefn (self, fn); }; /// // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void *QmlZlist::freefn (void *item, zlist_free_fn fn, bool atTail) { return zlist_freefn (self, item, fn, atTail); }; QObject* QmlZlist::qmlAttachedProperties(QObject* object) { return new QmlZlistAttached(object); } /// // Self test of this class. void QmlZlistAttached::test (bool verbose) { zlist_test (verbose); }; /// // Create a new list container QmlZlist *QmlZlistAttached::construct () { QmlZlist *qmlSelf = new QmlZlist (); qmlSelf->self = zlist_new (); return qmlSelf; }; /// // Destroy a list container void QmlZlistAttached::destruct (QmlZlist *qmlSelf) { zlist_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZsock.cpp0000664000372000037200000012233713222211156021017 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZsock.h" /// // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. int QmlZsock::bind (const QString &format) { return zsock_bind (self, "%s", format.toUtf8().data()); }; /// // Returns last bound endpoint, if any. const QString QmlZsock::endpoint () { return QString (zsock_endpoint (self)); }; /// // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int QmlZsock::unbind (const QString &format) { return zsock_unbind (self, "%s", format.toUtf8().data()); }; /// // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. int QmlZsock::connect (const QString &format) { return zsock_connect (self, "%s", format.toUtf8().data()); }; /// // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int QmlZsock::disconnect (const QString &format) { return zsock_disconnect (self, "%s", format.toUtf8().data()); }; /// // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). int QmlZsock::attach (const QString &endpoints, bool serverish) { return zsock_attach (self, endpoints.toUtf8().data(), serverish); }; /// // Returns socket type as printable constant string. const QString QmlZsock::typeStr () { return QString (zsock_type_str (self)); }; /// // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. int QmlZsock::send (const QString &picture) { return zsock_send (self, picture.toUtf8().data()); }; /// // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. int QmlZsock::vsend (const QString &picture, va_list argptr) { return zsock_vsend (self, picture.toUtf8().data(), argptr); }; /// // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // U = zuuid_t * (creates a zuuid with the data) // h = zhashx_t ** (creates zhashx) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. int QmlZsock::recv (const QString &picture) { return zsock_recv (self, picture.toUtf8().data()); }; /// // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. int QmlZsock::vrecv (const QString &picture, va_list argptr) { return zsock_vrecv (self, picture.toUtf8().data(), argptr); }; /// // Send a binary encoded 'picture' message to the socket (or actor). This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations. The pattern argument is a string that defines the // type of each argument. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0-255 chars type = "string" // S char *, 0-2^32-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // u zuuid_t * type = "uuid" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments. Returns 0 if // successful, -1 if sending failed for any reason. int QmlZsock::bsend (const QString &picture) { return zsock_bsend (self, picture.toUtf8().data()); }; /// // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. // For types 1, 2, 4 and 8 the caller must allocate the memory itself before // calling zsock_brecv. // For types S, the caller must free the value once finished with it, as // zsock_brecv will allocate the buffer. // For type s, the caller must not free the value as it is stored in a // local cache for performance purposes. // For types c, f, u and m the caller must call the appropriate destructor // depending on the object as zsock_brecv will create new objects. // For type p the caller must coordinate with the sender, as it is just a // pointer value being passed. int QmlZsock::brecv (const QString &picture) { return zsock_brecv (self, picture.toUtf8().data()); }; /// // Return socket routing ID if any. This returns 0 if the socket is not // of type ZMQ_SERVER or if no request was already received on it. uint32_t QmlZsock::routingId () { return zsock_routing_id (self); }; /// // Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. // This will be used when sending messages on the socket via the zsock API. void QmlZsock::setRoutingId (uint32_t routingId) { zsock_set_routing_id (self, routingId); }; /// // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. void QmlZsock::setUnbounded () { zsock_set_unbounded (self); }; /// // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zsock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. int QmlZsock::signal (byte status) { return zsock_signal (self, status); }; /// // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. int QmlZsock::wait () { return zsock_wait (self); }; /// // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. void QmlZsock::flush () { zsock_flush (self); }; /// // Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int QmlZsock::join (const QString &group) { return zsock_join (self, group.toUtf8().data()); }; /// // Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int QmlZsock::leave (const QString &group) { return zsock_leave (self, group.toUtf8().data()); }; /// // Get socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. int QmlZsock::heartbeatIvl () { return zsock_heartbeat_ivl (self); }; /// // Set socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. void QmlZsock::setHeartbeatIvl (int heartbeatIvl) { zsock_set_heartbeat_ivl (self, heartbeatIvl); }; /// // Get socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. int QmlZsock::heartbeatTtl () { return zsock_heartbeat_ttl (self); }; /// // Set socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. void QmlZsock::setHeartbeatTtl (int heartbeatTtl) { zsock_set_heartbeat_ttl (self, heartbeatTtl); }; /// // Get socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. int QmlZsock::heartbeatTimeout () { return zsock_heartbeat_timeout (self); }; /// // Set socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. void QmlZsock::setHeartbeatTimeout (int heartbeatTimeout) { zsock_set_heartbeat_timeout (self, heartbeatTimeout); }; /// // Get socket option `use_fd`. // Available from libzmq 4.2.0. int QmlZsock::useFd () { return zsock_use_fd (self); }; /// // Set socket option `use_fd`. // Available from libzmq 4.2.0. void QmlZsock::setUseFd (int useFd) { zsock_set_use_fd (self, useFd); }; /// // Set socket option `xpub_manual`. // Available from libzmq 4.2.0. void QmlZsock::setXpubManual (int xpubManual) { zsock_set_xpub_manual (self, xpubManual); }; /// // Set socket option `xpub_welcome_msg`. // Available from libzmq 4.2.0. void QmlZsock::setXpubWelcomeMsg (const QString &xpubWelcomeMsg) { zsock_set_xpub_welcome_msg (self, xpubWelcomeMsg.toUtf8().data()); }; /// // Set socket option `stream_notify`. // Available from libzmq 4.2.0. void QmlZsock::setStreamNotify (int streamNotify) { zsock_set_stream_notify (self, streamNotify); }; /// // Get socket option `invert_matching`. // Available from libzmq 4.2.0. int QmlZsock::invertMatching () { return zsock_invert_matching (self); }; /// // Set socket option `invert_matching`. // Available from libzmq 4.2.0. void QmlZsock::setInvertMatching (int invertMatching) { zsock_set_invert_matching (self, invertMatching); }; /// // Set socket option `xpub_verboser`. // Available from libzmq 4.2.0. void QmlZsock::setXpubVerboser (int xpubVerboser) { zsock_set_xpub_verboser (self, xpubVerboser); }; /// // Get socket option `connect_timeout`. // Available from libzmq 4.2.0. int QmlZsock::connectTimeout () { return zsock_connect_timeout (self); }; /// // Set socket option `connect_timeout`. // Available from libzmq 4.2.0. void QmlZsock::setConnectTimeout (int connectTimeout) { zsock_set_connect_timeout (self, connectTimeout); }; /// // Get socket option `tcp_maxrt`. // Available from libzmq 4.2.0. int QmlZsock::tcpMaxrt () { return zsock_tcp_maxrt (self); }; /// // Set socket option `tcp_maxrt`. // Available from libzmq 4.2.0. void QmlZsock::setTcpMaxrt (int tcpMaxrt) { zsock_set_tcp_maxrt (self, tcpMaxrt); }; /// // Get socket option `thread_safe`. // Available from libzmq 4.2.0. int QmlZsock::threadSafe () { return zsock_thread_safe (self); }; /// // Get socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. int QmlZsock::multicastMaxtpdu () { return zsock_multicast_maxtpdu (self); }; /// // Set socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. void QmlZsock::setMulticastMaxtpdu (int multicastMaxtpdu) { zsock_set_multicast_maxtpdu (self, multicastMaxtpdu); }; /// // Get socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. int QmlZsock::vmciBufferSize () { return zsock_vmci_buffer_size (self); }; /// // Set socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. void QmlZsock::setVmciBufferSize (int vmciBufferSize) { zsock_set_vmci_buffer_size (self, vmciBufferSize); }; /// // Get socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. int QmlZsock::vmciBufferMinSize () { return zsock_vmci_buffer_min_size (self); }; /// // Set socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. void QmlZsock::setVmciBufferMinSize (int vmciBufferMinSize) { zsock_set_vmci_buffer_min_size (self, vmciBufferMinSize); }; /// // Get socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. int QmlZsock::vmciBufferMaxSize () { return zsock_vmci_buffer_max_size (self); }; /// // Set socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. void QmlZsock::setVmciBufferMaxSize (int vmciBufferMaxSize) { zsock_set_vmci_buffer_max_size (self, vmciBufferMaxSize); }; /// // Get socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. int QmlZsock::vmciConnectTimeout () { return zsock_vmci_connect_timeout (self); }; /// // Set socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. void QmlZsock::setVmciConnectTimeout (int vmciConnectTimeout) { zsock_set_vmci_connect_timeout (self, vmciConnectTimeout); }; /// // Get socket option `tos`. // Available from libzmq 4.1.0. int QmlZsock::tos () { return zsock_tos (self); }; /// // Set socket option `tos`. // Available from libzmq 4.1.0. void QmlZsock::setTos (int tos) { zsock_set_tos (self, tos); }; /// // Set socket option `router_handover`. // Available from libzmq 4.1.0. void QmlZsock::setRouterHandover (int routerHandover) { zsock_set_router_handover (self, routerHandover); }; /// // Set socket option `connect_rid`. // Available from libzmq 4.1.0. void QmlZsock::setConnectRid (const QString &connectRid) { zsock_set_connect_rid (self, connectRid.toUtf8().data()); }; /// // Set socket option `connect_rid` from 32-octet binary // Available from libzmq 4.1.0. void QmlZsock::setConnectRidBin (const byte *connectRid) { zsock_set_connect_rid_bin (self, connectRid); }; /// // Get socket option `handshake_ivl`. // Available from libzmq 4.1.0. int QmlZsock::handshakeIvl () { return zsock_handshake_ivl (self); }; /// // Set socket option `handshake_ivl`. // Available from libzmq 4.1.0. void QmlZsock::setHandshakeIvl (int handshakeIvl) { zsock_set_handshake_ivl (self, handshakeIvl); }; /// // Get socket option `socks_proxy`. // Available from libzmq 4.1.0. QString QmlZsock::socksProxy () { char *retStr_ = zsock_socks_proxy (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Set socket option `socks_proxy`. // Available from libzmq 4.1.0. void QmlZsock::setSocksProxy (const QString &socksProxy) { zsock_set_socks_proxy (self, socksProxy.toUtf8().data()); }; /// // Set socket option `xpub_nodrop`. // Available from libzmq 4.1.0. void QmlZsock::setXpubNodrop (int xpubNodrop) { zsock_set_xpub_nodrop (self, xpubNodrop); }; /// // Set socket option `router_mandatory`. // Available from libzmq 4.0.0. void QmlZsock::setRouterMandatory (int routerMandatory) { zsock_set_router_mandatory (self, routerMandatory); }; /// // Set socket option `probe_router`. // Available from libzmq 4.0.0. void QmlZsock::setProbeRouter (int probeRouter) { zsock_set_probe_router (self, probeRouter); }; /// // Set socket option `req_relaxed`. // Available from libzmq 4.0.0. void QmlZsock::setReqRelaxed (int reqRelaxed) { zsock_set_req_relaxed (self, reqRelaxed); }; /// // Set socket option `req_correlate`. // Available from libzmq 4.0.0. void QmlZsock::setReqCorrelate (int reqCorrelate) { zsock_set_req_correlate (self, reqCorrelate); }; /// // Set socket option `conflate`. // Available from libzmq 4.0.0. void QmlZsock::setConflate (int conflate) { zsock_set_conflate (self, conflate); }; /// // Get socket option `zap_domain`. // Available from libzmq 4.0.0. QString QmlZsock::zapDomain () { char *retStr_ = zsock_zap_domain (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Set socket option `zap_domain`. // Available from libzmq 4.0.0. void QmlZsock::setZapDomain (const QString &zapDomain) { zsock_set_zap_domain (self, zapDomain.toUtf8().data()); }; /// // Get socket option `mechanism`. // Available from libzmq 4.0.0. int QmlZsock::mechanism () { return zsock_mechanism (self); }; /// // Get socket option `plain_server`. // Available from libzmq 4.0.0. int QmlZsock::plainServer () { return zsock_plain_server (self); }; /// // Set socket option `plain_server`. // Available from libzmq 4.0.0. void QmlZsock::setPlainServer (int plainServer) { zsock_set_plain_server (self, plainServer); }; /// // Get socket option `plain_username`. // Available from libzmq 4.0.0. QString QmlZsock::plainUsername () { char *retStr_ = zsock_plain_username (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Set socket option `plain_username`. // Available from libzmq 4.0.0. void QmlZsock::setPlainUsername (const QString &plainUsername) { zsock_set_plain_username (self, plainUsername.toUtf8().data()); }; /// // Get socket option `plain_password`. // Available from libzmq 4.0.0. QString QmlZsock::plainPassword () { char *retStr_ = zsock_plain_password (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Set socket option `plain_password`. // Available from libzmq 4.0.0. void QmlZsock::setPlainPassword (const QString &plainPassword) { zsock_set_plain_password (self, plainPassword.toUtf8().data()); }; /// // Get socket option `curve_server`. // Available from libzmq 4.0.0. int QmlZsock::curveServer () { return zsock_curve_server (self); }; /// // Set socket option `curve_server`. // Available from libzmq 4.0.0. void QmlZsock::setCurveServer (int curveServer) { zsock_set_curve_server (self, curveServer); }; /// // Get socket option `curve_publickey`. // Available from libzmq 4.0.0. QString QmlZsock::curvePublickey () { char *retStr_ = zsock_curve_publickey (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Set socket option `curve_publickey`. // Available from libzmq 4.0.0. void QmlZsock::setCurvePublickey (const QString &curvePublickey) { zsock_set_curve_publickey (self, curvePublickey.toUtf8().data()); }; /// // Set socket option `curve_publickey` from 32-octet binary // Available from libzmq 4.0.0. void QmlZsock::setCurvePublickeyBin (const byte *curvePublickey) { zsock_set_curve_publickey_bin (self, curvePublickey); }; /// // Get socket option `curve_secretkey`. // Available from libzmq 4.0.0. QString QmlZsock::curveSecretkey () { char *retStr_ = zsock_curve_secretkey (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Set socket option `curve_secretkey`. // Available from libzmq 4.0.0. void QmlZsock::setCurveSecretkey (const QString &curveSecretkey) { zsock_set_curve_secretkey (self, curveSecretkey.toUtf8().data()); }; /// // Set socket option `curve_secretkey` from 32-octet binary // Available from libzmq 4.0.0. void QmlZsock::setCurveSecretkeyBin (const byte *curveSecretkey) { zsock_set_curve_secretkey_bin (self, curveSecretkey); }; /// // Get socket option `curve_serverkey`. // Available from libzmq 4.0.0. QString QmlZsock::curveServerkey () { char *retStr_ = zsock_curve_serverkey (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Set socket option `curve_serverkey`. // Available from libzmq 4.0.0. void QmlZsock::setCurveServerkey (const QString &curveServerkey) { zsock_set_curve_serverkey (self, curveServerkey.toUtf8().data()); }; /// // Set socket option `curve_serverkey` from 32-octet binary // Available from libzmq 4.0.0. void QmlZsock::setCurveServerkeyBin (const byte *curveServerkey) { zsock_set_curve_serverkey_bin (self, curveServerkey); }; /// // Get socket option `gssapi_server`. // Available from libzmq 4.0.0. int QmlZsock::gssapiServer () { return zsock_gssapi_server (self); }; /// // Set socket option `gssapi_server`. // Available from libzmq 4.0.0. void QmlZsock::setGssapiServer (int gssapiServer) { zsock_set_gssapi_server (self, gssapiServer); }; /// // Get socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. int QmlZsock::gssapiPlaintext () { return zsock_gssapi_plaintext (self); }; /// // Set socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. void QmlZsock::setGssapiPlaintext (int gssapiPlaintext) { zsock_set_gssapi_plaintext (self, gssapiPlaintext); }; /// // Get socket option `gssapi_principal`. // Available from libzmq 4.0.0. QString QmlZsock::gssapiPrincipal () { char *retStr_ = zsock_gssapi_principal (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Set socket option `gssapi_principal`. // Available from libzmq 4.0.0. void QmlZsock::setGssapiPrincipal (const QString &gssapiPrincipal) { zsock_set_gssapi_principal (self, gssapiPrincipal.toUtf8().data()); }; /// // Get socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. QString QmlZsock::gssapiServicePrincipal () { char *retStr_ = zsock_gssapi_service_principal (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Set socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. void QmlZsock::setGssapiServicePrincipal (const QString &gssapiServicePrincipal) { zsock_set_gssapi_service_principal (self, gssapiServicePrincipal.toUtf8().data()); }; /// // Get socket option `ipv6`. // Available from libzmq 4.0.0. int QmlZsock::ipv6 () { return zsock_ipv6 (self); }; /// // Set socket option `ipv6`. // Available from libzmq 4.0.0. void QmlZsock::setIpv6 (int ipv6) { zsock_set_ipv6 (self, ipv6); }; /// // Get socket option `immediate`. // Available from libzmq 4.0.0. int QmlZsock::immediate () { return zsock_immediate (self); }; /// // Set socket option `immediate`. // Available from libzmq 4.0.0. void QmlZsock::setImmediate (int immediate) { zsock_set_immediate (self, immediate); }; /// // Get socket option `sndhwm`. // Available from libzmq 3.0.0. int QmlZsock::sndhwm () { return zsock_sndhwm (self); }; /// // Set socket option `sndhwm`. // Available from libzmq 3.0.0. void QmlZsock::setSndhwm (int sndhwm) { zsock_set_sndhwm (self, sndhwm); }; /// // Get socket option `rcvhwm`. // Available from libzmq 3.0.0. int QmlZsock::rcvhwm () { return zsock_rcvhwm (self); }; /// // Set socket option `rcvhwm`. // Available from libzmq 3.0.0. void QmlZsock::setRcvhwm (int rcvhwm) { zsock_set_rcvhwm (self, rcvhwm); }; /// // Get socket option `maxmsgsize`. // Available from libzmq 3.0.0. int QmlZsock::maxmsgsize () { return zsock_maxmsgsize (self); }; /// // Set socket option `maxmsgsize`. // Available from libzmq 3.0.0. void QmlZsock::setMaxmsgsize (int maxmsgsize) { zsock_set_maxmsgsize (self, maxmsgsize); }; /// // Get socket option `multicast_hops`. // Available from libzmq 3.0.0. int QmlZsock::multicastHops () { return zsock_multicast_hops (self); }; /// // Set socket option `multicast_hops`. // Available from libzmq 3.0.0. void QmlZsock::setMulticastHops (int multicastHops) { zsock_set_multicast_hops (self, multicastHops); }; /// // Set socket option `xpub_verbose`. // Available from libzmq 3.0.0. void QmlZsock::setXpubVerbose (int xpubVerbose) { zsock_set_xpub_verbose (self, xpubVerbose); }; /// // Get socket option `tcp_keepalive`. // Available from libzmq 3.0.0. int QmlZsock::tcpKeepalive () { return zsock_tcp_keepalive (self); }; /// // Set socket option `tcp_keepalive`. // Available from libzmq 3.0.0. void QmlZsock::setTcpKeepalive (int tcpKeepalive) { zsock_set_tcp_keepalive (self, tcpKeepalive); }; /// // Get socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. int QmlZsock::tcpKeepaliveIdle () { return zsock_tcp_keepalive_idle (self); }; /// // Set socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. void QmlZsock::setTcpKeepaliveIdle (int tcpKeepaliveIdle) { zsock_set_tcp_keepalive_idle (self, tcpKeepaliveIdle); }; /// // Get socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. int QmlZsock::tcpKeepaliveCnt () { return zsock_tcp_keepalive_cnt (self); }; /// // Set socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. void QmlZsock::setTcpKeepaliveCnt (int tcpKeepaliveCnt) { zsock_set_tcp_keepalive_cnt (self, tcpKeepaliveCnt); }; /// // Get socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. int QmlZsock::tcpKeepaliveIntvl () { return zsock_tcp_keepalive_intvl (self); }; /// // Set socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. void QmlZsock::setTcpKeepaliveIntvl (int tcpKeepaliveIntvl) { zsock_set_tcp_keepalive_intvl (self, tcpKeepaliveIntvl); }; /// // Get socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. QString QmlZsock::tcpAcceptFilter () { char *retStr_ = zsock_tcp_accept_filter (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Set socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. void QmlZsock::setTcpAcceptFilter (const QString &tcpAcceptFilter) { zsock_set_tcp_accept_filter (self, tcpAcceptFilter.toUtf8().data()); }; /// // Get socket option `last_endpoint`. // Available from libzmq 3.0.0. QString QmlZsock::lastEndpoint () { char *retStr_ = zsock_last_endpoint (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Set socket option `router_raw`. // Available from libzmq 3.0.0. void QmlZsock::setRouterRaw (int routerRaw) { zsock_set_router_raw (self, routerRaw); }; /// // Get socket option `ipv4only`. // Available from libzmq 3.0.0. int QmlZsock::ipv4only () { return zsock_ipv4only (self); }; /// // Set socket option `ipv4only`. // Available from libzmq 3.0.0. void QmlZsock::setIpv4only (int ipv4only) { zsock_set_ipv4only (self, ipv4only); }; /// // Set socket option `delay_attach_on_connect`. // Available from libzmq 3.0.0. void QmlZsock::setDelayAttachOnConnect (int delayAttachOnConnect) { zsock_set_delay_attach_on_connect (self, delayAttachOnConnect); }; /// // Get socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. int QmlZsock::hwm () { return zsock_hwm (self); }; /// // Set socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. void QmlZsock::setHwm (int hwm) { zsock_set_hwm (self, hwm); }; /// // Get socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. int QmlZsock::swap () { return zsock_swap (self); }; /// // Set socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. void QmlZsock::setSwap (int swap) { zsock_set_swap (self, swap); }; /// // Get socket option `affinity`. // Available from libzmq 2.0.0. int QmlZsock::affinity () { return zsock_affinity (self); }; /// // Set socket option `affinity`. // Available from libzmq 2.0.0. void QmlZsock::setAffinity (int affinity) { zsock_set_affinity (self, affinity); }; /// // Get socket option `identity`. // Available from libzmq 2.0.0. QString QmlZsock::identity () { char *retStr_ = zsock_identity (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Set socket option `identity`. // Available from libzmq 2.0.0. void QmlZsock::setIdentity (const QString &identity) { zsock_set_identity (self, identity.toUtf8().data()); }; /// // Get socket option `rate`. // Available from libzmq 2.0.0. int QmlZsock::rate () { return zsock_rate (self); }; /// // Set socket option `rate`. // Available from libzmq 2.0.0. void QmlZsock::setRate (int rate) { zsock_set_rate (self, rate); }; /// // Get socket option `recovery_ivl`. // Available from libzmq 2.0.0. int QmlZsock::recoveryIvl () { return zsock_recovery_ivl (self); }; /// // Set socket option `recovery_ivl`. // Available from libzmq 2.0.0. void QmlZsock::setRecoveryIvl (int recoveryIvl) { zsock_set_recovery_ivl (self, recoveryIvl); }; /// // Get socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. int QmlZsock::recoveryIvlMsec () { return zsock_recovery_ivl_msec (self); }; /// // Set socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. void QmlZsock::setRecoveryIvlMsec (int recoveryIvlMsec) { zsock_set_recovery_ivl_msec (self, recoveryIvlMsec); }; /// // Get socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. int QmlZsock::mcastLoop () { return zsock_mcast_loop (self); }; /// // Set socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. void QmlZsock::setMcastLoop (int mcastLoop) { zsock_set_mcast_loop (self, mcastLoop); }; /// // Get socket option `rcvtimeo`. // Available from libzmq 2.2.0. int QmlZsock::rcvtimeo () { return zsock_rcvtimeo (self); }; /// // Set socket option `rcvtimeo`. // Available from libzmq 2.2.0. void QmlZsock::setRcvtimeo (int rcvtimeo) { zsock_set_rcvtimeo (self, rcvtimeo); }; /// // Get socket option `sndtimeo`. // Available from libzmq 2.2.0. int QmlZsock::sndtimeo () { return zsock_sndtimeo (self); }; /// // Set socket option `sndtimeo`. // Available from libzmq 2.2.0. void QmlZsock::setSndtimeo (int sndtimeo) { zsock_set_sndtimeo (self, sndtimeo); }; /// // Get socket option `sndbuf`. // Available from libzmq 2.0.0. int QmlZsock::sndbuf () { return zsock_sndbuf (self); }; /// // Set socket option `sndbuf`. // Available from libzmq 2.0.0. void QmlZsock::setSndbuf (int sndbuf) { zsock_set_sndbuf (self, sndbuf); }; /// // Get socket option `rcvbuf`. // Available from libzmq 2.0.0. int QmlZsock::rcvbuf () { return zsock_rcvbuf (self); }; /// // Set socket option `rcvbuf`. // Available from libzmq 2.0.0. void QmlZsock::setRcvbuf (int rcvbuf) { zsock_set_rcvbuf (self, rcvbuf); }; /// // Get socket option `linger`. // Available from libzmq 2.0.0. int QmlZsock::linger () { return zsock_linger (self); }; /// // Set socket option `linger`. // Available from libzmq 2.0.0. void QmlZsock::setLinger (int linger) { zsock_set_linger (self, linger); }; /// // Get socket option `reconnect_ivl`. // Available from libzmq 2.0.0. int QmlZsock::reconnectIvl () { return zsock_reconnect_ivl (self); }; /// // Set socket option `reconnect_ivl`. // Available from libzmq 2.0.0. void QmlZsock::setReconnectIvl (int reconnectIvl) { zsock_set_reconnect_ivl (self, reconnectIvl); }; /// // Get socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. int QmlZsock::reconnectIvlMax () { return zsock_reconnect_ivl_max (self); }; /// // Set socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. void QmlZsock::setReconnectIvlMax (int reconnectIvlMax) { zsock_set_reconnect_ivl_max (self, reconnectIvlMax); }; /// // Get socket option `backlog`. // Available from libzmq 2.0.0. int QmlZsock::backlog () { return zsock_backlog (self); }; /// // Set socket option `backlog`. // Available from libzmq 2.0.0. void QmlZsock::setBacklog (int backlog) { zsock_set_backlog (self, backlog); }; /// // Set socket option `subscribe`. // Available from libzmq 2.0.0. void QmlZsock::setSubscribe (const QString &subscribe) { zsock_set_subscribe (self, subscribe.toUtf8().data()); }; /// // Set socket option `unsubscribe`. // Available from libzmq 2.0.0. void QmlZsock::setUnsubscribe (const QString &unsubscribe) { zsock_set_unsubscribe (self, unsubscribe.toUtf8().data()); }; /// // Get socket option `type`. // Available from libzmq 2.0.0. int QmlZsock::type () { return zsock_type (self); }; /// // Get socket option `rcvmore`. // Available from libzmq 2.0.0. int QmlZsock::rcvmore () { return zsock_rcvmore (self); }; /// // Get socket option `fd`. // Available from libzmq 2.0.0. SOCKET QmlZsock::fd () { return zsock_fd (self); }; /// // Get socket option `events`. // Available from libzmq 2.0.0. int QmlZsock::events () { return zsock_events (self); }; QObject* QmlZsock::qmlAttachedProperties(QObject* object) { return new QmlZsockAttached(object); } /// // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. bool QmlZsockAttached::is (void *self) { return zsock_is (self); }; /// // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. void *QmlZsockAttached::resolve (void *self) { return zsock_resolve (self); }; /// // Self test of this class. void QmlZsockAttached::test (bool verbose) { zsock_test (verbose); }; /// // Create a new socket. Returns the new socket, or NULL if the new socket // could not be created. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection. This can have // performance implications if you use a LOT of sockets. To turn off this // redirection behaviour, define ZSOCK_NOCHECK. QmlZsock *QmlZsockAttached::construct (int type) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new (type); return qmlSelf; }; /// // Create a PUB socket. Default action is bind. QmlZsock *QmlZsockAttached::constructPub (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_pub (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. QmlZsock *QmlZsockAttached::constructSub (const QString &endpoint, const QString &subscribe) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_sub (endpoint.toUtf8().data(), subscribe.toUtf8().data()); return qmlSelf; }; /// // Create a REQ socket. Default action is connect. QmlZsock *QmlZsockAttached::constructReq (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_req (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a REP socket. Default action is bind. QmlZsock *QmlZsockAttached::constructRep (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_rep (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a DEALER socket. Default action is connect. QmlZsock *QmlZsockAttached::constructDealer (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_dealer (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a ROUTER socket. Default action is bind. QmlZsock *QmlZsockAttached::constructRouter (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_router (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a PUSH socket. Default action is connect. QmlZsock *QmlZsockAttached::constructPush (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_push (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a PULL socket. Default action is bind. QmlZsock *QmlZsockAttached::constructPull (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_pull (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create an XPUB socket. Default action is bind. QmlZsock *QmlZsockAttached::constructXpub (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_xpub (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create an XSUB socket. Default action is connect. QmlZsock *QmlZsockAttached::constructXsub (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_xsub (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a PAIR socket. Default action is connect. QmlZsock *QmlZsockAttached::constructPair (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_pair (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a STREAM socket. Default action is connect. QmlZsock *QmlZsockAttached::constructStream (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_stream (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a SERVER socket. Default action is bind. QmlZsock *QmlZsockAttached::constructServer (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_server (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a CLIENT socket. Default action is connect. QmlZsock *QmlZsockAttached::constructClient (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_client (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a RADIO socket. Default action is bind. QmlZsock *QmlZsockAttached::constructRadio (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_radio (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a DISH socket. Default action is connect. QmlZsock *QmlZsockAttached::constructDish (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_dish (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a GATHER socket. Default action is bind. QmlZsock *QmlZsockAttached::constructGather (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_gather (endpoint.toUtf8().data()); return qmlSelf; }; /// // Create a SCATTER socket. Default action is connect. QmlZsock *QmlZsockAttached::constructScatter (const QString &endpoint) { QmlZsock *qmlSelf = new QmlZsock (); qmlSelf->self = zsock_new_scatter (endpoint.toUtf8().data()); return qmlSelf; }; /// // Destroy the socket. You must use this for any socket created via the // zsock_new method. void QmlZsockAttached::destruct (QmlZsock *qmlSelf) { zsock_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZuuid.h0000664000372000037200000000520313222211156020463 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZUUID_H #define QML_ZUUID_H #include #include #include "qml_czmq_plugin.h" class QmlZuuid : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zuuid_t *self; QmlZuuid() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZuuid.cpp public slots: // Set UUID to new supplied ZUUID_LEN-octet value. void set (const byte *source); // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. int setStr (const QString &source); // Return UUID binary data. const byte *data (); // Return UUID binary size size_t size (); // Returns UUID as string const QString str (); // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier const QString strCanonical (); // Store UUID blob in target array void export (byte *target); // Check if UUID is same as supplied value bool eq (const byte *compare); // Check if UUID is different from supplied value bool neq (const byte *compare); // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. QmlZuuid *dup (); }; class QmlZuuidAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZuuidAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class. void test (bool verbose); // Create a new UUID object. QmlZuuid *construct (); // Create UUID object from supplied ZUUID_LEN-octet value. QmlZuuid *constructFrom (const byte *source); // Destroy a specified UUID object. void destruct (QmlZuuid *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZuuid, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZmsg.cpp0000664000372000037200000002323113222211156020637 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZmsg.h" /// // Return size of message, i.e. number of frames (0 or more). size_t QmlZmsg::size () { return zmsg_size (self); }; /// // Return total size of all frames in message. size_t QmlZmsg::contentSize () { return zmsg_content_size (self); }; /// // Return message routing ID, if the message came from a ZMQ_SERVER socket. // Else returns zero. uint32_t QmlZmsg::routingId () { return zmsg_routing_id (self); }; /// // Set routing ID on message. This is used if/when the message is sent to a // ZMQ_SERVER socket. void QmlZmsg::setRoutingId (uint32_t routingId) { zmsg_set_routing_id (self, routingId); }; /// // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. int QmlZmsg::prepend (QmlZframe *frameP) { return zmsg_prepend (self, &frameP->self); }; /// // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Deprecates zmsg_add, which did not nullify the // caller's frame reference. int QmlZmsg::append (QmlZframe *frameP) { return zmsg_append (self, &frameP->self); }; /// // Remove first frame from message, if any. Returns frame, or NULL. QmlZframe *QmlZmsg::pop () { QmlZframe *retQ_ = new QmlZframe (); retQ_->self = zmsg_pop (self); return retQ_; }; /// // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. int QmlZmsg::pushmem (const void *data, size_t size) { return zmsg_pushmem (self, data, size); }; /// // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. int QmlZmsg::addmem (const void *data, size_t size) { return zmsg_addmem (self, data, size); }; /// // Push string as new frame to front of message. // Returns 0 on success, -1 on error. int QmlZmsg::pushstr (const QString &string) { return zmsg_pushstr (self, string.toUtf8().data()); }; /// // Push string as new frame to end of message. // Returns 0 on success, -1 on error. int QmlZmsg::addstr (const QString &string) { return zmsg_addstr (self, string.toUtf8().data()); }; /// // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. int QmlZmsg::pushstrf (const QString &format) { return zmsg_pushstrf (self, "%s", format.toUtf8().data()); }; /// // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. int QmlZmsg::addstrf (const QString &format) { return zmsg_addstrf (self, "%s", format.toUtf8().data()); }; /// // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. QString QmlZmsg::popstr () { char *retStr_ = zmsg_popstr (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. int QmlZmsg::addmsg (QmlZmsg *msgP) { return zmsg_addmsg (self, &msgP->self); }; /// // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not successful. QmlZmsg *QmlZmsg::popmsg () { QmlZmsg *retQ_ = new QmlZmsg (); retQ_->self = zmsg_popmsg (self); return retQ_; }; /// // Remove specified frame from list, if present. Does not destroy frame. void QmlZmsg::remove (QmlZframe *frame) { zmsg_remove (self, frame->self); }; /// // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. QmlZframe *QmlZmsg::first () { QmlZframe *retQ_ = new QmlZframe (); retQ_->self = zmsg_first (self); return retQ_; }; /// // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. QmlZframe *QmlZmsg::next () { QmlZframe *retQ_ = new QmlZframe (); retQ_->self = zmsg_next (self); return retQ_; }; /// // Return the last frame. If there are no frames, returns NULL. QmlZframe *QmlZmsg::last () { QmlZframe *retQ_ = new QmlZframe (); retQ_->self = zmsg_last (self); return retQ_; }; /// // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. int QmlZmsg::save (FILE *file) { return zmsg_save (self, file); }; /// // Serialize multipart message to a single message frame. Use this method // to send structured messages across transports that do not support // multipart data. Allocates and returns a new frame containing the // serialized message. To decode a serialized message frame, use // zmsg_decode (). QmlZframe *QmlZmsg::encode () { QmlZframe *retQ_ = new QmlZframe (); retQ_->self = zmsg_encode (self); return retQ_; }; /// // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. QmlZmsg *QmlZmsg::dup () { QmlZmsg *retQ_ = new QmlZmsg (); retQ_->self = zmsg_dup (self); return retQ_; }; /// // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). void QmlZmsg::print () { zmsg_print (self); }; /// // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. bool QmlZmsg::eq (QmlZmsg *other) { return zmsg_eq (self, other->self); }; /// // Return signal value, 0 or greater, if message is a signal, -1 if not. int QmlZmsg::signal () { return zmsg_signal (self); }; QObject* QmlZmsg::qmlAttachedProperties(QObject* object) { return new QmlZmsgAttached(object); } /// // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int QmlZmsgAttached::send (QmlZmsg *selfP, void *dest) { return zmsg_send (&selfP->self, dest); }; /// // Send message to destination socket as part of a multipart sequence, and // destroy the message after sending it successfully. Note that after a // zmsg_sendm, you must call zmsg_send or another method that sends a final // message part. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int QmlZmsgAttached::sendm (QmlZmsg *selfP, void *dest) { return zmsg_sendm (&selfP->self, dest); }; /// // Probe the supplied object, and report if it looks like a zmsg_t. bool QmlZmsgAttached::is (void *self) { return zmsg_is (self); }; /// // Self test of this class. void QmlZmsgAttached::test (bool verbose) { zmsg_test (verbose); }; /// // Create a new empty message object QmlZmsg *QmlZmsgAttached::construct () { QmlZmsg *qmlSelf = new QmlZmsg (); qmlSelf->self = zmsg_new (); return qmlSelf; }; /// // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted. Does a blocking recv. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving. QmlZmsg *QmlZmsgAttached::recv (void *source) { QmlZmsg *qmlSelf = new QmlZmsg (); qmlSelf->self = zmsg_recv (source); return qmlSelf; }; /// // Load/append an open file into new message, return the message. // Returns NULL if the message could not be loaded. QmlZmsg *QmlZmsgAttached::load (FILE *file) { QmlZmsg *qmlSelf = new QmlZmsg (); qmlSelf->self = zmsg_load (file); return qmlSelf; }; /// // Decodes a serialized message frame created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the frame was badly formatted or // there was insufficient memory to work. QmlZmsg *QmlZmsgAttached::decode (QmlZframe *frame) { QmlZmsg *qmlSelf = new QmlZmsg (); qmlSelf->self = zmsg_decode (frame->self); return qmlSelf; }; /// // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. QmlZmsg *QmlZmsgAttached::constructSignal (byte status) { QmlZmsg *qmlSelf = new QmlZmsg (); qmlSelf->self = zmsg_new_signal (status); return qmlSelf; }; /// // Destroy a message object and all frames it contains void QmlZmsgAttached::destruct (QmlZmsg *qmlSelf) { zmsg_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZactor.cpp0000664000372000037200000000522713222211156021166 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZactor.h" /// // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. int QmlZactor::send (QmlZmsg *msgP) { return zactor_send (self, &msgP->self); }; /// // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. QmlZmsg *QmlZactor::recv () { QmlZmsg *retQ_ = new QmlZmsg (); retQ_->self = zactor_recv (self); return retQ_; }; /// // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. QmlZsock *QmlZactor::sock () { QmlZsock *retQ_ = new QmlZsock (); retQ_->self = zactor_sock (self); return retQ_; }; /// // Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. void QmlZactor::setDestructor (zactor_destructor_fn destructor) { zactor_set_destructor (self, destructor); }; QObject* QmlZactor::qmlAttachedProperties(QObject* object) { return new QmlZactorAttached(object); } /// // Probe the supplied object, and report if it looks like a zactor_t. bool QmlZactorAttached::is (void *self) { return zactor_is (self); }; /// // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. void *QmlZactorAttached::resolve (void *self) { return zactor_resolve (self); }; /// // Self test of this class. void QmlZactorAttached::test (bool verbose) { zactor_test (verbose); }; /// // Create a new actor passing arbitrary arguments reference. QmlZactor *QmlZactorAttached::construct (zactor_fn task, void *args) { QmlZactor *qmlSelf = new QmlZactor (); qmlSelf->self = zactor_new (task, args); return qmlSelf; }; /// // Destroy an actor. void QmlZactorAttached::destruct (QmlZactor *qmlSelf) { zactor_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZcertstore.cpp0000664000372000037200000000643613222211156022073 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZcertstore.h" /// // Override the default disk loader with a custom loader fn. void QmlZcertstore::setLoader (zcertstore_loader loader, zcertstore_destructor destructor, void *state) { zcertstore_set_loader (self, loader, destructor, state); }; /// // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. QmlZcert *QmlZcertstore::lookup (const QString &publicKey) { QmlZcert *retQ_ = new QmlZcert (); retQ_->self = zcertstore_lookup (self, publicKey.toUtf8().data()); return retQ_; }; /// // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. void QmlZcertstore::insert (QmlZcert *certP) { zcertstore_insert (self, &certP->self); }; /// // Empty certificate hashtable. This wrapper exists to be friendly to bindings, // which don't usually have access to struct internals. void QmlZcertstore::empty () { zcertstore_empty (self); }; /// // Print list of certificates in store to logging facility void QmlZcertstore::print () { zcertstore_print (self); }; /// // Return a list of all the certificates in the store. // The caller takes ownership of the zlistx_t object and is responsible // for destroying it. The caller does not take ownership of the zcert_t // objects. QmlZlistx *QmlZcertstore::certs () { QmlZlistx *retQ_ = new QmlZlistx (); retQ_->self = zcertstore_certs (self); return retQ_; }; QObject* QmlZcertstore::qmlAttachedProperties(QObject* object) { return new QmlZcertstoreAttached(object); } /// // Self test of this class void QmlZcertstoreAttached::test (bool verbose) { zcertstore_test (verbose); }; /// // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. QmlZcertstore *QmlZcertstoreAttached::construct (const QString &location) { QmlZcertstore *qmlSelf = new QmlZcertstore (); qmlSelf->self = zcertstore_new (location.toUtf8().data()); return qmlSelf; }; /// // Destroy a certificate store object in memory. Does not affect anything // stored on disk. void QmlZcertstoreAttached::destruct (QmlZcertstore *qmlSelf) { zcertstore_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZdirPatch.h0000664000372000037200000000411513222211156021254 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZDIR_PATCH_H #define QML_ZDIR_PATCH_H #include #include #include "qml_czmq_plugin.h" class QmlZdirPatch : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zdir_patch_t *self; QmlZdirPatch() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZdirPatch.cpp public slots: // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. QmlZdirPatch *dup (); // Return patch file directory path const QString path (); // Return patch file item QmlZfile *file (); // Return operation int op (); // Return patch virtual file path const QString vpath (); // Calculate hash digest for file (create only) void digestSet (); // Return hash digest for patch file const QString digest (); }; class QmlZdirPatchAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZdirPatchAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class. void test (bool verbose); // Create new patch QmlZdirPatch *construct (const QString &path, QmlZfile *file, int op, const QString &alias); // Destroy a patch void destruct (QmlZdirPatch *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZdirPatch, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZdigest.h0000664000372000037200000000422213222211156020774 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZDIGEST_H #define QML_ZDIGEST_H #include #include #include "qml_czmq_plugin.h" class QmlZdigest : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zdigest_t *self; QmlZdigest() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZdigest.cpp public slots: // Add buffer into digest calculation void update (const byte *buffer, size_t length); // Return final digest hash data. If built without crypto support, // returns NULL. const byte *data (); // Return final digest hash size size_t size (); // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. const QString string (); }; class QmlZdigestAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZdigestAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class. void test (bool verbose); // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. QmlZdigest *construct (); // Destroy a digest object void destruct (QmlZdigest *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZdigest, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZhash.h0000664000372000037200000001526613222211156020452 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZHASH_H #define QML_ZHASH_H #include #include #include "qml_czmq_plugin.h" class QmlZhash : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zhash_t *self; QmlZhash() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZhash.cpp public slots: // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int insert (const QString &key, void *item); // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. void update (const QString &key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void delete (const QString &key); // Return the item at the specified key, or null void *lookup (const QString &key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int rename (const QString &oldKey, const QString &newKey); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void *freefn (const QString &key, zhash_free_fn freeFn); // Return the number of keys/items in the hash table size_t size (); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. QmlZhash *dup (); // Return keys for items in table QmlZlist *keys (); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhash_cursor(). NOTE: do NOT modify the table while iterating. void *first (); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). To // access the key for this item use zhash_cursor(). NOTE: do NOT modify // the table while iterating. void *next (); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const QString cursor (); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void comment (const QString &format); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. QmlZframe *pack (); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int save (const QString &filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int load (const QString &filename); // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int refresh (); // Set hash for automatic value destruction. Note that this assumes that // values are NULL-terminated strings. Do not use with different types. void autofree (); }; class QmlZhashAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZhashAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class. void test (bool verbose); // Create a new, empty hash container QmlZhash *construct (); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. QmlZhash *unpack (QmlZframe *frame); // Destroy a hash container and all items in it void destruct (QmlZhash *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZhash, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZchunk.h0000664000372000037200000001162413222211156020631 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZCHUNK_H #define QML_ZCHUNK_H #include #include #include "qml_czmq_plugin.h" class QmlZchunk : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zchunk_t *self; QmlZchunk() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZchunk.cpp public slots: // Resizes chunk max_size as requested; chunk_cur size is set to zero void resize (size_t size); // Return chunk cur size size_t size (); // Return chunk max size size_t maxSize (); // Return chunk data byte *data (); // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk size_t set (const void *data, size_t size); // Fill chunk data from user-supplied octet size_t fill (byte filler, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, it is truncated. If you want to // grow the chunk to accommodate new data, use the zchunk_extend method. size_t append (const void *data, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, the chunk grows in size. size_t extend (const void *data, size_t size); // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. size_t consume (QmlZchunk *source); // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. bool exhausted (); // Write chunk to an open file descriptor int write (FILE *handle); // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // returns null. QmlZchunk *dup (); // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. QString strhex (); // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. QString strdup (); // Return TRUE if chunk body is equal to string, excluding terminator bool streq (const QString &string); // Transform zchunk into a zframe that can be sent in a message. QmlZframe *pack (); // Calculate SHA1 digest for chunk, using zdigest class. const QString digest (); // Dump chunk to FILE stream, for debugging and tracing. void fprint (FILE *file); // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details void print (); }; class QmlZchunkAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZchunkAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Read chunk from an open file descriptor QmlZchunk *read (FILE *handle, size_t bytes); // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. QmlZchunk *slurp (const QString &filename, size_t maxsize); // Transform a zframe into a zchunk. QmlZchunk *unpack (QmlZframe *frame); // Probe the supplied object, and report if it looks like a zchunk_t. bool is (void *self); // Self test of this class. void test (bool verbose); // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. QmlZchunk *construct (const void *data, size_t size); // Destroy a chunk void destruct (QmlZchunk *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZchunk, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZdirPatch.cpp0000664000372000037200000000451113222211156021607 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZdirPatch.h" /// // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. QmlZdirPatch *QmlZdirPatch::dup () { QmlZdirPatch *retQ_ = new QmlZdirPatch (); retQ_->self = zdir_patch_dup (self); return retQ_; }; /// // Return patch file directory path const QString QmlZdirPatch::path () { return QString (zdir_patch_path (self)); }; /// // Return patch file item QmlZfile *QmlZdirPatch::file () { QmlZfile *retQ_ = new QmlZfile (); retQ_->self = zdir_patch_file (self); return retQ_; }; /// // Return operation int QmlZdirPatch::op () { return zdir_patch_op (self); }; /// // Return patch virtual file path const QString QmlZdirPatch::vpath () { return QString (zdir_patch_vpath (self)); }; /// // Calculate hash digest for file (create only) void QmlZdirPatch::digestSet () { zdir_patch_digest_set (self); }; /// // Return hash digest for patch file const QString QmlZdirPatch::digest () { return QString (zdir_patch_digest (self)); }; QObject* QmlZdirPatch::qmlAttachedProperties(QObject* object) { return new QmlZdirPatchAttached(object); } /// // Self test of this class. void QmlZdirPatchAttached::test (bool verbose) { zdir_patch_test (verbose); }; /// // Create new patch QmlZdirPatch *QmlZdirPatchAttached::construct (const QString &path, QmlZfile *file, int op, const QString &alias) { QmlZdirPatch *qmlSelf = new QmlZdirPatch (); qmlSelf->self = zdir_patch_new (path.toUtf8().data(), file->self, op, alias.toUtf8().data()); return qmlSelf; }; /// // Destroy a patch void QmlZdirPatchAttached::destruct (QmlZdirPatch *qmlSelf) { zdir_patch_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/qml_czmq_plugin.h0000664000372000037200000001321613222211156022115 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_CZMQ_PLUGIN_H #define QML_CZMQ_PLUGIN_H #include #include class QmlZactor; class QmlZactorAttached; class QmlZargs; class QmlZargsAttached; class QmlZarmour; class QmlZarmourAttached; class QmlZcert; class QmlZcertAttached; class QmlZcertstore; class QmlZcertstoreAttached; class QmlZchunk; class QmlZchunkAttached; class QmlZclock; class QmlZclockAttached; class QmlZconfig; class QmlZconfigAttached; class QmlZdigest; class QmlZdigestAttached; class QmlZdir; class QmlZdirAttached; class QmlZdirPatch; class QmlZdirPatchAttached; class QmlZfile; class QmlZfileAttached; class QmlZframe; class QmlZframeAttached; class QmlZhash; class QmlZhashAttached; class QmlZhashx; class QmlZhashxAttached; class QmlZiflist; class QmlZiflistAttached; class QmlZlist; class QmlZlistAttached; class QmlZlistx; class QmlZlistxAttached; class QmlZloop; class QmlZloopAttached; class QmlZmsg; class QmlZmsgAttached; class QmlZpoller; class QmlZpollerAttached; class QmlZproc; class QmlZprocAttached; class QmlZsock; class QmlZsockAttached; class QmlZstr; class QmlZstrAttached; class QmlZsys; class QmlZsysAttached; class QmlZtimerset; class QmlZtimersetAttached; class QmlZtrie; class QmlZtrieAttached; class QmlZuuid; class QmlZuuidAttached; #include "QmlZactor.h" #include "QmlZargs.h" #include "QmlZarmour.h" #include "QmlZcert.h" #include "QmlZcertstore.h" #include "QmlZchunk.h" #include "QmlZclock.h" #include "QmlZconfig.h" #include "QmlZdigest.h" #include "QmlZdir.h" #include "QmlZdirPatch.h" #include "QmlZfile.h" #include "QmlZframe.h" #include "QmlZhash.h" #include "QmlZhashx.h" #include "QmlZiflist.h" #include "QmlZlist.h" #include "QmlZlistx.h" #include "QmlZloop.h" #include "QmlZmsg.h" #include "QmlZpoller.h" #include "QmlZproc.h" #include "QmlZsock.h" #include "QmlZstr.h" #include "QmlZsys.h" #include "QmlZtimerset.h" #include "QmlZtrie.h" #include "QmlZuuid.h" class QmlCZMQPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA (IID "org.qt-project.Qt.QQmlExtensionInterface") public: void registerTypes (const char *uri) { qmlRegisterType (uri, 1, 0, "QmlZactor"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZargs"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZarmour"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZcert"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZcertstore"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZchunk"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZclock"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZconfig"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZdigest"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZdir"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZdirPatch"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZfile"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZframe"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZhash"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZhashx"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZiflist"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZlist"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZlistx"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZloop"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZmsg"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZpoller"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZproc"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZsock"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZstr"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZsys"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZtimerset"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZtrie"); qmlRegisterType(); qmlRegisterType (uri, 1, 0, "QmlZuuid"); qmlRegisterType(); }; }; #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZstr.cpp0000664000372000037200000001170513222211156020664 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZstr.h" QObject* QmlZstr::qmlAttachedProperties(QObject* object) { return new QmlZstrAttached(object); } /// // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. QString QmlZstrAttached::recv (void *source) { char *retStr_ = zstr_recv (source); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Receive a series of strings (until NULL) from multipart data. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL. // Returns -1 if the message could not be read, else returns the // number of strings filled, zero or more. Free each returned string // using zstr_free(). If not enough strings are provided, remaining // multipart frames in the message are dropped. int QmlZstrAttached::recvx (void *source, QString stringP) { return zstr_recvx (source, stringP.toUtf8().data()); }; /// // De-compress and receive C string from socket, received as a message // with two frames: size of the uncompressed string, and the string itself. // Caller must free returned string using zstr_free(). Returns NULL if the // context is being terminated or the process was interrupted. QString QmlZstrAttached::recvCompress (void *source) { char *retStr_ = zstr_recv_compress (source); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". int QmlZstrAttached::send (void *dest, const QString &string) { return zstr_send (dest, string.toUtf8().data()); }; /// // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. int QmlZstrAttached::sendm (void *dest, const QString &string) { return zstr_sendm (dest, string.toUtf8().data()); }; /// // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). int QmlZstrAttached::sendf (void *dest, const QString &format) { return zstr_sendf (dest, "%s", format.toUtf8().data()); }; /// // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. int QmlZstrAttached::sendfm (void *dest, const QString &format) { return zstr_sendfm (dest, "%s", format.toUtf8().data()); }; /// // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or -1 on error. int QmlZstrAttached::sendx (void *dest, const QString &string) { return zstr_sendx (dest, string.toUtf8().data()); }; /// // Compress and send a C string to a socket, as a message with two frames: // size of the uncompressed string, and the string itself. The string is // sent without trailing null byte; to read this you can use // zstr_recv_compress, or a similar method that de-compresses and adds a // null terminator on the received string. int QmlZstrAttached::sendCompress (void *dest, const QString &string) { return zstr_send_compress (dest, string.toUtf8().data()); }; /// // Compress and send a C string to a socket, as zstr_send_compress(), // with a MORE flag, so that you can send further strings in the same // multi-part message. int QmlZstrAttached::sendmCompress (void *dest, const QString &string) { return zstr_sendm_compress (dest, string.toUtf8().data()); }; /// // Accepts a void pointer and returns a fresh character string. If source // is null, returns an empty string. QString QmlZstrAttached::str (void *source) { char *retStr_ = zstr_str (source); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. void QmlZstrAttached::free (QString stringP) { zstr_free (stringP.toUtf8().data()); }; /// // Self test of this class. void QmlZstrAttached::test (bool verbose) { zstr_test (verbose); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZpoller.h0000664000372000037200000000661513222211156021022 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZPOLLER_H #define QML_ZPOLLER_H #include #include #include "qml_czmq_plugin.h" class QmlZpoller : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zpoller_t *self; QmlZpoller() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZpoller.cpp public slots: // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. int add (void *reader); // Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader // must have been passed during construction, or in an zpoller_add () call. int remove (void *reader); // By default the poller stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void setNonstop (bool nonstop); // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. void *wait (int timeout); // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. bool expired (); // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. bool terminated (); }; class QmlZpollerAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZpollerAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class. void test (bool verbose); // Create new poller, specifying zero or more readers. The list of // readers ends in a NULL. Each reader can be a zsock_t instance, a // zactor_t instance, a libzmq socket (void *), or a file handle. QmlZpoller *construct (void *reader); // Destroy a poller void destruct (QmlZpoller *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZpoller, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZloop.cpp0000664000372000037200000001464213222211156021030 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZloop.h" /// // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. int QmlZloop::reader (QmlZsock *sock, zloop_reader_fn handler, void *arg) { return zloop_reader (self, sock->self, handler, arg); }; /// // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. void QmlZloop::readerEnd (QmlZsock *sock) { zloop_reader_end (self, sock->self); }; /// // Configure a registered reader to ignore errors. If you do not set this, // then readers that have errors are removed from the reactor silently. void QmlZloop::readerSetTolerant (QmlZsock *sock) { zloop_reader_set_tolerant (self, sock->self); }; /// // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. int QmlZloop::poller (zmq_pollitem_t *item, zloop_fn handler, void *arg) { return zloop_poller (self, item, handler, arg); }; /// // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. void QmlZloop::pollerEnd (zmq_pollitem_t *item) { zloop_poller_end (self, item); }; /// // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. void QmlZloop::pollerSetTolerant (zmq_pollitem_t *item) { zloop_poller_set_tolerant (self, item); }; /// // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. int QmlZloop::timer (size_t delay, size_t times, zloop_timer_fn handler, void *arg) { return zloop_timer (self, delay, times, handler, arg); }; /// // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer). int QmlZloop::timerEnd (int timerId) { return zloop_timer_end (self, timerId); }; /// // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. void *QmlZloop::ticket (zloop_timer_fn handler, void *arg) { return zloop_ticket (self, handler, arg); }; /// // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. void QmlZloop::ticketReset (void *handle) { zloop_ticket_reset (self, handle); }; /// // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. void QmlZloop::ticketDelete (void *handle) { zloop_ticket_delete (self, handle); }; /// // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. void QmlZloop::setTicketDelay (size_t ticketDelay) { zloop_set_ticket_delay (self, ticketDelay); }; /// // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. void QmlZloop::setMaxTimers (size_t maxTimers) { zloop_set_max_timers (self, maxTimers); }; /// // Set verbose tracing of reactor on/off. The default verbose setting is // off (false). void QmlZloop::setVerbose (bool verbose) { zloop_set_verbose (self, verbose); }; /// // By default the reactor stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void QmlZloop::setNonstop (bool nonstop) { zloop_set_nonstop (self, nonstop); }; /// // Start the reactor. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. int QmlZloop::start () { return zloop_start (self); }; QObject* QmlZloop::qmlAttachedProperties(QObject* object) { return new QmlZloopAttached(object); } /// // Self test of this class. void QmlZloopAttached::test (bool verbose) { zloop_test (verbose); }; /// // Create a new zloop reactor QmlZloop *QmlZloopAttached::construct () { QmlZloop *qmlSelf = new QmlZloop (); qmlSelf->self = zloop_new (); return qmlSelf; }; /// // Destroy a reactor void QmlZloopAttached::destruct (QmlZloop *qmlSelf) { zloop_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZhashx.h0000664000372000037200000002205113222211156020630 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZHASHX_H #define QML_ZHASHX_H #include #include #include "qml_czmq_plugin.h" class QmlZhashx : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zhashx_t *self; QmlZhashx() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZhashx.cpp public slots: // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int insert (const void *key, void *item); // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. void update (const void *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void delete (const void *key); // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. void purge (); // Return the item at the specified key, or null void *lookup (const void *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int rename (const void *oldKey, const void *newKey); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void *freefn (const void *key, zhashx_free_fn freeFn); // Return the number of keys/items in the hash table size_t size (); // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. QmlZlistx *keys (); // Return a zlistx_t containing the values for the items in the // table. Uses the duplicator to duplicate all items and sets the // destructor as destructor for the list. QmlZlistx *values (); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhashx_cursor(). NOTE: do NOT modify the table while iterating. void *first (); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). To // access the key for this item use zhashx_cursor(). NOTE: do NOT modify // the table while iterating. void *next (); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const void *cursor (); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void comment (const QString &format); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int save (const QString &filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int load (const QString &filename); // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int refresh (); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. QmlZframe *pack (); // Same as pack but uses a user-defined serializer function to convert items // into longstr. QmlZframe *packOwn (zhashx_serializer_fn serializer); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. QmlZhashx *dup (); // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. void setDestructor (zhashx_destructor_fn destructor); // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. void setDuplicator (zhashx_duplicator_fn duplicator); // Set a user-defined deallocator for keys; by default keys are freed // when the hash is destroyed using free(). void setKeyDestructor (zhashx_destructor_fn destructor); // Set a user-defined duplicator for keys; by default keys are duplicated // using strdup. void setKeyDuplicator (zhashx_duplicator_fn duplicator); // Set a user-defined comparator for keys; by default keys are // compared using strcmp. // The callback function should return zero (0) on matching // items. void setKeyComparator (zhashx_comparator_fn comparator); // Set a user-defined hash function for keys; by default keys are // hashed by a modified Bernstein hashing function. void setKeyHasher (zhashx_hash_fn hasher); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. QmlZhashx *dupV2 (); }; class QmlZhashxAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZhashxAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class. void test (bool verbose); // Create a new, empty hash container QmlZhashx *construct (); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. QmlZhashx *unpack (QmlZframe *frame); // Same as unpack but uses a user-defined deserializer function to convert // a longstr back into item format. QmlZhashx *unpackOwn (QmlZframe *frame, zhashx_deserializer_fn deserializer); // Destroy a hash container and all items in it void destruct (QmlZhashx *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZhashx, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZuuid.cpp0000664000372000037200000000571013222211156021021 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZuuid.h" /// // Set UUID to new supplied ZUUID_LEN-octet value. void QmlZuuid::set (const byte *source) { zuuid_set (self, source); }; /// // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. int QmlZuuid::setStr (const QString &source) { return zuuid_set_str (self, source.toUtf8().data()); }; /// // Return UUID binary data. const byte *QmlZuuid::data () { return zuuid_data (self); }; /// // Return UUID binary size size_t QmlZuuid::size () { return zuuid_size (self); }; /// // Returns UUID as string const QString QmlZuuid::str () { return QString (zuuid_str (self)); }; /// // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier const QString QmlZuuid::strCanonical () { return QString (zuuid_str_canonical (self)); }; /// // Store UUID blob in target array void QmlZuuid::export (byte *target) { zuuid_export (self, target); }; /// // Check if UUID is same as supplied value bool QmlZuuid::eq (const byte *compare) { return zuuid_eq (self, compare); }; /// // Check if UUID is different from supplied value bool QmlZuuid::neq (const byte *compare) { return zuuid_neq (self, compare); }; /// // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. QmlZuuid *QmlZuuid::dup () { QmlZuuid *retQ_ = new QmlZuuid (); retQ_->self = zuuid_dup (self); return retQ_; }; QObject* QmlZuuid::qmlAttachedProperties(QObject* object) { return new QmlZuuidAttached(object); } /// // Self test of this class. void QmlZuuidAttached::test (bool verbose) { zuuid_test (verbose); }; /// // Create a new UUID object. QmlZuuid *QmlZuuidAttached::construct () { QmlZuuid *qmlSelf = new QmlZuuid (); qmlSelf->self = zuuid_new (); return qmlSelf; }; /// // Create UUID object from supplied ZUUID_LEN-octet value. QmlZuuid *QmlZuuidAttached::constructFrom (const byte *source) { QmlZuuid *qmlSelf = new QmlZuuid (); qmlSelf->self = zuuid_new_from (source); return qmlSelf; }; /// // Destroy a specified UUID object. void QmlZuuidAttached::destruct (QmlZuuid *qmlSelf) { zuuid_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZlistx.h0000664000372000037200000001602413222211156020663 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZLISTX_H #define QML_ZLISTX_H #include #include #include "qml_czmq_plugin.h" class QmlZlistx : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zlistx_t *self; QmlZlistx() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZlistx.cpp public slots: // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void *addStart (void *item); // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void *addEnd (void *item); // Return the number of items in the list size_t size (); // Return first item in the list, or null, leaves the cursor void *head (); // Return last item in the list, or null, leaves the cursor void *tail (); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void *first (); // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). void *next (); // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). void *prev (); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void *last (); // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. void *item (); // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. void *cursor (); // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. void *find (void *item); // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. void *detach (void *handle); // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. void *detachCur (); // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. int delete (void *handle); // Move an item to the start of the list, via its handle. void moveStart (void *handle); // Move an item to the end of the list, via its handle. void moveEnd (void *handle); // Remove all items from the list, and destroy them if the item destructor // is set. void purge (); // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. void sort (); // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. void *insert (void *item, bool lowValue); // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. void reorder (void *handle, bool lowValue); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. QmlZlistx *dup (); // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. void setDestructor (zlistx_destructor_fn destructor); // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. void setDuplicator (zlistx_duplicator_fn duplicator); // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. void setComparator (zlistx_comparator_fn comparator); }; class QmlZlistxAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZlistxAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Returns the item associated with the given list handle, or NULL if passed // in handle is NULL. Asserts that the passed in handle points to a list element. void *handleItem (void *handle); // Self test of this class. void test (bool verbose); // Create a new, empty list. QmlZlistx *construct (); // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. void destruct (QmlZlistx *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZlistx, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZstr.h0000664000372000037200000001073113222211156020327 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZSTR_H #define QML_ZSTR_H #include #include #include "qml_czmq_plugin.h" class QmlZstr : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zstr_t *self; QmlZstr() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZstr.cpp public slots:}; class QmlZstrAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZstrAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. QString recv (void *source); // Receive a series of strings (until NULL) from multipart data. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL. // Returns -1 if the message could not be read, else returns the // number of strings filled, zero or more. Free each returned string // using zstr_free(). If not enough strings are provided, remaining // multipart frames in the message are dropped. int recvx (void *source, QString stringP); // De-compress and receive C string from socket, received as a message // with two frames: size of the uncompressed string, and the string itself. // Caller must free returned string using zstr_free(). Returns NULL if the // context is being terminated or the process was interrupted. QString recvCompress (void *source); // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". int send (void *dest, const QString &string); // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. int sendm (void *dest, const QString &string); // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). int sendf (void *dest, const QString &format); // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. int sendfm (void *dest, const QString &format); // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or -1 on error. int sendx (void *dest, const QString &string); // Compress and send a C string to a socket, as a message with two frames: // size of the uncompressed string, and the string itself. The string is // sent without trailing null byte; to read this you can use // zstr_recv_compress, or a similar method that de-compresses and adds a // null terminator on the received string. int sendCompress (void *dest, const QString &string); // Compress and send a C string to a socket, as zstr_send_compress(), // with a MORE flag, so that you can send further strings in the same // multi-part message. int sendmCompress (void *dest, const QString &string); // Accepts a void pointer and returns a fresh character string. If source // is null, returns an empty string. QString str (void *source); // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. void free (QString stringP); // Self test of this class. void test (bool verbose); }; QML_DECLARE_TYPEINFO(QmlZstr, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZlistx.cpp0000664000372000037200000001750013222211156021216 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZlistx.h" /// // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void *QmlZlistx::addStart (void *item) { return zlistx_add_start (self, item); }; /// // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void *QmlZlistx::addEnd (void *item) { return zlistx_add_end (self, item); }; /// // Return the number of items in the list size_t QmlZlistx::size () { return zlistx_size (self); }; /// // Return first item in the list, or null, leaves the cursor void *QmlZlistx::head () { return zlistx_head (self); }; /// // Return last item in the list, or null, leaves the cursor void *QmlZlistx::tail () { return zlistx_tail (self); }; /// // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void *QmlZlistx::first () { return zlistx_first (self); }; /// // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). void *QmlZlistx::next () { return zlistx_next (self); }; /// // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). void *QmlZlistx::prev () { return zlistx_prev (self); }; /// // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void *QmlZlistx::last () { return zlistx_last (self); }; /// // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. void *QmlZlistx::item () { return zlistx_item (self); }; /// // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. void *QmlZlistx::cursor () { return zlistx_cursor (self); }; /// // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. void *QmlZlistx::find (void *item) { return zlistx_find (self, item); }; /// // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. void *QmlZlistx::detach (void *handle) { return zlistx_detach (self, handle); }; /// // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. void *QmlZlistx::detachCur () { return zlistx_detach_cur (self); }; /// // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. int QmlZlistx::delete (void *handle) { return zlistx_delete (self, handle); }; /// // Move an item to the start of the list, via its handle. void QmlZlistx::moveStart (void *handle) { zlistx_move_start (self, handle); }; /// // Move an item to the end of the list, via its handle. void QmlZlistx::moveEnd (void *handle) { zlistx_move_end (self, handle); }; /// // Remove all items from the list, and destroy them if the item destructor // is set. void QmlZlistx::purge () { zlistx_purge (self); }; /// // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. void QmlZlistx::sort () { zlistx_sort (self); }; /// // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. void *QmlZlistx::insert (void *item, bool lowValue) { return zlistx_insert (self, item, lowValue); }; /// // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. void QmlZlistx::reorder (void *handle, bool lowValue) { zlistx_reorder (self, handle, lowValue); }; /// // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. QmlZlistx *QmlZlistx::dup () { QmlZlistx *retQ_ = new QmlZlistx (); retQ_->self = zlistx_dup (self); return retQ_; }; /// // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. void QmlZlistx::setDestructor (zlistx_destructor_fn destructor) { zlistx_set_destructor (self, destructor); }; /// // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. void QmlZlistx::setDuplicator (zlistx_duplicator_fn duplicator) { zlistx_set_duplicator (self, duplicator); }; /// // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. void QmlZlistx::setComparator (zlistx_comparator_fn comparator) { zlistx_set_comparator (self, comparator); }; QObject* QmlZlistx::qmlAttachedProperties(QObject* object) { return new QmlZlistxAttached(object); } /// // Returns the item associated with the given list handle, or NULL if passed // in handle is NULL. Asserts that the passed in handle points to a list element. void *QmlZlistxAttached::handleItem (void *handle) { return zlistx_handle_item (handle); }; /// // Self test of this class. void QmlZlistxAttached::test (bool verbose) { zlistx_test (verbose); }; /// // Create a new, empty list. QmlZlistx *QmlZlistxAttached::construct () { QmlZlistx *qmlSelf = new QmlZlistx (); qmlSelf->self = zlistx_new (); return qmlSelf; }; /// // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. void QmlZlistxAttached::destruct (QmlZlistx *qmlSelf) { zlistx_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/qmldir0000664000372000037200000000003713222211156017753 0ustar00travistravis00000000000000module QmlCZMQ plugin qml_czmq czmq-4.1.0/bindings/qml/src/QmlZarmour.h0000664000372000037200000000546513222211156021034 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef QML_ZARMOUR_H #define QML_ZARMOUR_H #include #include #include "qml_czmq_plugin.h" class QmlZarmour : public QObject { Q_OBJECT Q_PROPERTY(bool isNULL READ isNULL) public: zarmour_t *self; QmlZarmour() { self = NULL; } bool isNULL() { return self == NULL; } static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZarmour.cpp public slots: // Encode a stream of bytes into an armoured string. Returns the armoured // string, or NULL if there was insufficient memory available to allocate // a new string. QString encode (const byte *data, size_t size); // Decode an armoured string into a chunk. The decoded output is // null-terminated, so it may be treated as a string, if that's what // it was prior to encoding. QmlZchunk *decode (const QString &data); // Get the mode property. int mode (); // Get printable string for mode. const QString modeStr (); // Set the mode property. void setMode (int mode); // Return true if padding is turned on. bool pad (); // Turn padding on or off. Default is on. void setPad (bool pad); // Get the padding character. char padChar (); // Set the padding character. void setPadChar (char padChar); // Return if splitting output into lines is turned on. Default is off. bool lineBreaks (); // Turn splitting output into lines on or off. void setLineBreaks (bool lineBreaks); // Get the line length used for splitting lines. size_t lineLength (); // Set the line length used for splitting lines. void setLineLength (size_t lineLength); // Print properties of object void print (); }; class QmlZarmourAttached : public QObject { Q_OBJECT QObject* m_attached; public: QmlZarmourAttached (QObject* attached) { Q_UNUSED (attached); }; public slots: // Self test of this class. void test (bool verbose); // Create a new zarmour QmlZarmour *construct (); // Destroy the zarmour void destruct (QmlZarmour *qmlSelf); }; QML_DECLARE_TYPEINFO(QmlZarmour, QML_HAS_ATTACHED_PROPERTIES) #endif /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qml/src/QmlZconfig.cpp0000664000372000037200000001642313222211156021323 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "QmlZconfig.h" /// // Return name of config item const QString QmlZconfig::name () { return QString (zconfig_name (self)); }; /// // Return value of config item const QString QmlZconfig::value () { return QString (zconfig_value (self)); }; /// // Insert or update configuration key with value void QmlZconfig::put (const QString &path, const QString &value) { zconfig_put (self, path.toUtf8().data(), value.toUtf8().data()); }; /// // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. void QmlZconfig::putf (const QString &path, const QString &format) { zconfig_putf (self, path.toUtf8().data(), "%s", format.toUtf8().data()); }; /// // Get value for config item into a string value; leading slash is optional // and ignored. const QString QmlZconfig::get (const QString &path, const QString &defaultValue) { return QString (zconfig_get (self, path.toUtf8().data(), defaultValue.toUtf8().data())); }; /// // Set config item name, name may be NULL void QmlZconfig::setName (const QString &name) { zconfig_set_name (self, name.toUtf8().data()); }; /// // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. void QmlZconfig::setValue (const QString &format) { zconfig_set_value (self, "%s", format.toUtf8().data()); }; /// // Find our first child, if any QmlZconfig *QmlZconfig::child () { QmlZconfig *retQ_ = new QmlZconfig (); retQ_->self = zconfig_child (self); return retQ_; }; /// // Find our first sibling, if any QmlZconfig *QmlZconfig::next () { QmlZconfig *retQ_ = new QmlZconfig (); retQ_->self = zconfig_next (self); return retQ_; }; /// // Find a config item along a path; leading slash is optional and ignored. QmlZconfig *QmlZconfig::locate (const QString &path) { QmlZconfig *retQ_ = new QmlZconfig (); retQ_->self = zconfig_locate (self, path.toUtf8().data()); return retQ_; }; /// // Locate the last config item at a specified depth QmlZconfig *QmlZconfig::atDepth (int level) { QmlZconfig *retQ_ = new QmlZconfig (); retQ_->self = zconfig_at_depth (self, level); return retQ_; }; /// // Execute a callback for each config item in the tree; returns zero if // successful, else -1. int QmlZconfig::execute (zconfig_fct handler, void *arg) { return zconfig_execute (self, handler, arg); }; /// // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. void QmlZconfig::setComment (const QString &format) { zconfig_set_comment (self, "%s", format.toUtf8().data()); }; /// // Return comments of config item, as zlist. QmlZlist *QmlZconfig::comments () { QmlZlist *retQ_ = new QmlZlist (); retQ_->self = zconfig_comments (self); return retQ_; }; /// // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. int QmlZconfig::save (const QString &filename) { return zconfig_save (self, filename.toUtf8().data()); }; /// // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. int QmlZconfig::savef (const QString &format) { return zconfig_savef (self, "%s", format.toUtf8().data()); }; /// // Report filename used during zconfig_load, or NULL if none const QString QmlZconfig::filename () { return QString (zconfig_filename (self)); }; /// // Save a config tree to a new memory chunk QmlZchunk *QmlZconfig::chunkSave () { QmlZchunk *retQ_ = new QmlZchunk (); retQ_->self = zconfig_chunk_save (self); return retQ_; }; /// // Save a config tree to a new null terminated string QString QmlZconfig::strSave () { char *retStr_ = zconfig_str_save (self); QString retQStr_ = QString (retStr_); free (retStr_); return retQStr_; }; /// // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. bool QmlZconfig::hasChanged () { return zconfig_has_changed (self); }; /// // Destroy subtree (all children) void QmlZconfig::removeSubtree () { zconfig_remove_subtree (self); }; /// // Print the config file to open stream void QmlZconfig::fprint (FILE *file) { zconfig_fprint (self, file); }; /// // Print properties of object void QmlZconfig::print () { zconfig_print (self); }; QObject* QmlZconfig::qmlAttachedProperties(QObject* object) { return new QmlZconfigAttached(object); } /// // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). int QmlZconfigAttached::reload (QmlZconfig *selfP) { return zconfig_reload (&selfP->self); }; /// // Load a config tree from a memory chunk QmlZconfig *QmlZconfigAttached::chunkLoad (QmlZchunk *chunk) { QmlZconfig *retQ_ = new QmlZconfig (); retQ_->self = zconfig_chunk_load (chunk->self); return retQ_; }; /// // Load a config tree from a null-terminated string QmlZconfig *QmlZconfigAttached::strLoad (const QString &string) { QmlZconfig *retQ_ = new QmlZconfig (); retQ_->self = zconfig_str_load (string.toUtf8().data()); return retQ_; }; /// // Destroy node and subtree (all children) void QmlZconfigAttached::remove (QmlZconfig *selfP) { zconfig_remove (&selfP->self); }; /// // Self test of this class void QmlZconfigAttached::test (bool verbose) { zconfig_test (verbose); }; /// // Create new config item QmlZconfig *QmlZconfigAttached::construct (const QString &name, QmlZconfig *parent) { QmlZconfig *qmlSelf = new QmlZconfig (); qmlSelf->self = zconfig_new (name.toUtf8().data(), parent->self); return qmlSelf; }; /// // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. QmlZconfig *QmlZconfigAttached::load (const QString &filename) { QmlZconfig *qmlSelf = new QmlZconfig (); qmlSelf->self = zconfig_load (filename.toUtf8().data()); return qmlSelf; }; /// // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. QmlZconfig *QmlZconfigAttached::loadf (const QString &format) { QmlZconfig *qmlSelf = new QmlZconfig (); qmlSelf->self = zconfig_loadf ("%s", format.toUtf8().data()); return qmlSelf; }; /// // Destroy a config item and all its children void QmlZconfigAttached::destruct (QmlZconfig *qmlSelf) { zconfig_destroy (&qmlSelf->self); }; /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/0000775000372000037200000000000013222211156015604 5ustar00travistravis00000000000000czmq-4.1.0/bindings/qt/README.md0000664000372000037200000000472013222211156017066 0ustar00travistravis00000000000000``` ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ ``` # qczmq ## Overview qczmq is a Qt wrapper for czmq. It's possible to statically or dynamically link against it as well as use it as internal or external library. ## Internal library You can use the Qt wrapper as internal library by including the `qczmq.pri` file. Here is a minimal example app: ```make QT += core QT -= gui include(/qczmq.pri) CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp ``` To link statically against the wrapper you need to change the `QCZMQ_LIBRARY` variable in `config.pri` to `no`. To link dynamically against the wrapper you need to change the `QCZMQ_LIBRARY` variable in `config.pri` to `yes`. ## External library To install qczmq as a shared library do the following: ```sh qmake make sudo make install ``` The default installation directory prefix on unix is `/usr/local/`. If you like to change the prefix define the PREFIX variable when calling qmake: ```sh qmake PREFIX=/usr ``` ## Notes ### Dependent classes If the bindings are generated as part of a zproject that depends on another zproject (e.g. zyre on czmq), the Qt bindings will automatically detect all dependent classes and generate bindings for them too. Check the ./generate.sh output the see which dependent classes couldn't be resolved. ### Format methods Whenever a c method takes a format followed by variadic arguments, this is replaced in the Qt bindings by one string instead. ### Excluded methods If you're missing some methods in the bindings then because they have been excluded. Currently methods are excluded if, * they have variadic arguments and don't have a sibling method that accepts a va_list. Most prominent example is probably printf and vprintf. * they have char** arguments, as they might get freed which doesn't play well with QString. ``` ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ ``` czmq-4.1.0/bindings/qt/selftest/0000775000372000037200000000000013222211156017435 5ustar00travistravis00000000000000czmq-4.1.0/bindings/qt/selftest/selftest.pro0000664000372000037200000000141113222211156022005 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ QT += core QT -= gui include(../src/qczmq.pri) CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/qt/selftest/main.cpp0000664000372000037200000000334613222211156021073 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include "qczmq.h" int main(int argc, char **argv) { bool verbose; if (argc == 2 && streq (argv [1], "-v")) verbose = true; else verbose = false; qDebug() << "Running qczmq selftests...\n"; QZactor::test (verbose); QZargs::test (verbose); QZarmour::test (verbose); QZcert::test (verbose); QZcertstore::test (verbose); QZchunk::test (verbose); QZclock::test (verbose); QZconfig::test (verbose); QZdigest::test (verbose); QZdir::test (verbose); QZdirPatch::test (verbose); QZfile::test (verbose); QZframe::test (verbose); QZhash::test (verbose); QZhashx::test (verbose); QZiflist::test (verbose); QZlist::test (verbose); QZlistx::test (verbose); QZloop::test (verbose); QZmsg::test (verbose); QZpoller::test (verbose); QZproc::test (verbose); QZsock::test (verbose); QZstr::test (verbose); QZsys::test (verbose); QZtimerset::test (verbose); QZtrie::test (verbose); QZuuid::test (verbose); qDebug() << "Tests passed OK\n"; return 0; } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/config.pri0000664000372000037200000000002413222211156017561 0ustar00travistravis00000000000000QCZMQ_LIBRARY = yes czmq-4.1.0/bindings/qt/buildlib/0000775000372000037200000000000013222211156017372 5ustar00travistravis00000000000000czmq-4.1.0/bindings/qt/buildlib/buildlib.pro0000664000372000037200000000244013222211156021702 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ TEMPLATE = lib VERSION = 4.1.0 CONFIG += qt dll qczmq-buildlib mac:CONFIG += absolute_library_soname win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release build_all include(../src/qczmq.pri) TARGET = $$QCZMQ_LIBNAME DESTDIR = $$QCZMQ_LIBDIR !packagesExist (libzmq): error ("cannot link with -lzmq, install libzmq.") LIBS += \ -lzmq \ -lczmq win32 { DLLDESTDIR = $$[QT_INSTALL_BINS] QMAKE_DISTCLEAN += $$[QT_INSTALL_BINS]\$${QCZMQ_LIBNAME}.dll } unix { isEmpty(PREFIX): PREFIX = /usr/local header.files = $$PWD/../src/*.h header.path = $$PREFIX/include target.path = $$PREFIX/lib INSTALLS += target header } ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/qt/qczmq.pro0000664000372000037200000000135713222211156017467 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ TEMPLATE=subdirs CONFIG += ordered include(common.pri) qczmq-uselib:SUBDIRS=buildlib SUBDIRS+=selftest ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/qt/common.pri0000664000372000037200000000206713222211156017615 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ exists(config.pri):infile(config.pri, QCZMQ_LIBRARY, yes): CONFIG += qczmq-uselib TEMPLATE += fakelib QCZMQ_LIBNAME = qczmq CONFIG(debug, debug|release) { mac:QCZMQ_LIBNAME = $$member(QCZMQ_LIBNAME, 0)_debug else:win32:QCZMQ_LIBNAME = $$member(QCZMQ_LIBNAME, 0)d } TEMPLATE -= fakelib CONFIG += link_pkgconfig PKGCONFIG += libczmq QCZMQ_LIBDIR = $$PWD/lib unix:qczmq-uselib:!qczmq-buildlib:QMAKE_RPATHDIR += $$QCZMQ_LIBDIR ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/qt/src/0000775000372000037200000000000013222211156016373 5ustar00travistravis00000000000000czmq-4.1.0/bindings/qt/src/qzsock.cpp0000664000372000037200000011551713222211156020423 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZsock::QZsock (zsock_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new socket. Returns the new socket, or NULL if the new socket // could not be created. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection. This can have // performance implications if you use a LOT of sockets. To turn off this // redirection behaviour, define ZSOCK_NOCHECK. QZsock::QZsock (int type, QObject *qObjParent) : QObject (qObjParent) { this->self = zsock_new (type); } /// // Create a PUB socket. Default action is bind. QZsock* QZsock::newPub (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_pub (endpoint.toUtf8().data()), qObjParent); } /// // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. QZsock* QZsock::newSub (const QString &endpoint, const QString &subscribe, QObject *qObjParent) { return new QZsock (zsock_new_sub (endpoint.toUtf8().data(), subscribe.toUtf8().data()), qObjParent); } /// // Create a REQ socket. Default action is connect. QZsock* QZsock::newReq (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_req (endpoint.toUtf8().data()), qObjParent); } /// // Create a REP socket. Default action is bind. QZsock* QZsock::newRep (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_rep (endpoint.toUtf8().data()), qObjParent); } /// // Create a DEALER socket. Default action is connect. QZsock* QZsock::newDealer (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_dealer (endpoint.toUtf8().data()), qObjParent); } /// // Create a ROUTER socket. Default action is bind. QZsock* QZsock::newRouter (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_router (endpoint.toUtf8().data()), qObjParent); } /// // Create a PUSH socket. Default action is connect. QZsock* QZsock::newPush (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_push (endpoint.toUtf8().data()), qObjParent); } /// // Create a PULL socket. Default action is bind. QZsock* QZsock::newPull (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_pull (endpoint.toUtf8().data()), qObjParent); } /// // Create an XPUB socket. Default action is bind. QZsock* QZsock::newXpub (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_xpub (endpoint.toUtf8().data()), qObjParent); } /// // Create an XSUB socket. Default action is connect. QZsock* QZsock::newXsub (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_xsub (endpoint.toUtf8().data()), qObjParent); } /// // Create a PAIR socket. Default action is connect. QZsock* QZsock::newPair (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_pair (endpoint.toUtf8().data()), qObjParent); } /// // Create a STREAM socket. Default action is connect. QZsock* QZsock::newStream (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_stream (endpoint.toUtf8().data()), qObjParent); } /// // Create a SERVER socket. Default action is bind. QZsock* QZsock::newServer (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_server (endpoint.toUtf8().data()), qObjParent); } /// // Create a CLIENT socket. Default action is connect. QZsock* QZsock::newClient (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_client (endpoint.toUtf8().data()), qObjParent); } /// // Create a RADIO socket. Default action is bind. QZsock* QZsock::newRadio (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_radio (endpoint.toUtf8().data()), qObjParent); } /// // Create a DISH socket. Default action is connect. QZsock* QZsock::newDish (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_dish (endpoint.toUtf8().data()), qObjParent); } /// // Create a GATHER socket. Default action is bind. QZsock* QZsock::newGather (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_gather (endpoint.toUtf8().data()), qObjParent); } /// // Create a SCATTER socket. Default action is connect. QZsock* QZsock::newScatter (const QString &endpoint, QObject *qObjParent) { return new QZsock (zsock_new_scatter (endpoint.toUtf8().data()), qObjParent); } /// // Destroy the socket. You must use this for any socket created via the // zsock_new method. QZsock::~QZsock () { zsock_destroy (&self); } /// // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. int QZsock::bind (const QString ¶m) { int rv = zsock_bind (self, "%s", param.toUtf8().data()); return rv; } /// // Returns last bound endpoint, if any. const QString QZsock::endpoint () { const QString rv = QString (zsock_endpoint (self)); return rv; } /// // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int QZsock::unbind (const QString ¶m) { int rv = zsock_unbind (self, "%s", param.toUtf8().data()); return rv; } /// // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. int QZsock::connect (const QString ¶m) { int rv = zsock_connect (self, "%s", param.toUtf8().data()); return rv; } /// // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int QZsock::disconnect (const QString ¶m) { int rv = zsock_disconnect (self, "%s", param.toUtf8().data()); return rv; } /// // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). int QZsock::attach (const QString &endpoints, bool serverish) { int rv = zsock_attach (self, endpoints.toUtf8().data(), serverish); return rv; } /// // Returns socket type as printable constant string. const QString QZsock::typeStr () { const QString rv = QString (zsock_type_str (self)); return rv; } /// // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. int QZsock::send (const QString &picture, ...) { va_list args; va_start (args, picture); int rv = zsock_vsend (self, picture.toUtf8().data(), args); va_end (args); return rv; } /// // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. int QZsock::vsend (const QString &picture, va_list argptr) { int rv = zsock_vsend (self, picture.toUtf8().data(), argptr); return rv; } /// // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // U = zuuid_t * (creates a zuuid with the data) // h = zhashx_t ** (creates zhashx) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. int QZsock::recv (const QString &picture, ...) { va_list args; va_start (args, picture); int rv = zsock_vrecv (self, picture.toUtf8().data(), args); va_end (args); return rv; } /// // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. int QZsock::vrecv (const QString &picture, va_list argptr) { int rv = zsock_vrecv (self, picture.toUtf8().data(), argptr); return rv; } /// // Return socket routing ID if any. This returns 0 if the socket is not // of type ZMQ_SERVER or if no request was already received on it. quint32 QZsock::routingId () { uint32_t rv = zsock_routing_id (self); return rv; } /// // Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. // This will be used when sending messages on the socket via the zsock API. void QZsock::setRoutingId (quint32 routingId) { zsock_set_routing_id (self, (uint32_t) routingId); } /// // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. void QZsock::setUnbounded () { zsock_set_unbounded (self); } /// // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zsock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. int QZsock::signal (byte status) { int rv = zsock_signal (self, status); return rv; } /// // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. int QZsock::wait () { int rv = zsock_wait (self); return rv; } /// // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. void QZsock::flush () { zsock_flush (self); } /// // Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int QZsock::join (const QString &group) { int rv = zsock_join (self, group.toUtf8().data()); return rv; } /// // Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int QZsock::leave (const QString &group) { int rv = zsock_leave (self, group.toUtf8().data()); return rv; } /// // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. bool QZsock::is (void *self) { bool rv = zsock_is (self); return rv; } /// // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. void * QZsock::resolve (void *self) { void * rv = zsock_resolve (self); return rv; } /// // Get socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. int QZsock::heartbeatIvl () { int rv = zsock_heartbeat_ivl (self); return rv; } /// // Set socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. void QZsock::setHeartbeatIvl (int heartbeatIvl) { zsock_set_heartbeat_ivl (self, heartbeatIvl); } /// // Get socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. int QZsock::heartbeatTtl () { int rv = zsock_heartbeat_ttl (self); return rv; } /// // Set socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. void QZsock::setHeartbeatTtl (int heartbeatTtl) { zsock_set_heartbeat_ttl (self, heartbeatTtl); } /// // Get socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. int QZsock::heartbeatTimeout () { int rv = zsock_heartbeat_timeout (self); return rv; } /// // Set socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. void QZsock::setHeartbeatTimeout (int heartbeatTimeout) { zsock_set_heartbeat_timeout (self, heartbeatTimeout); } /// // Get socket option `use_fd`. // Available from libzmq 4.2.0. int QZsock::useFd () { int rv = zsock_use_fd (self); return rv; } /// // Set socket option `use_fd`. // Available from libzmq 4.2.0. void QZsock::setUseFd (int useFd) { zsock_set_use_fd (self, useFd); } /// // Set socket option `xpub_manual`. // Available from libzmq 4.2.0. void QZsock::setXpubManual (int xpubManual) { zsock_set_xpub_manual (self, xpubManual); } /// // Set socket option `xpub_welcome_msg`. // Available from libzmq 4.2.0. void QZsock::setXpubWelcomeMsg (const QString &xpubWelcomeMsg) { zsock_set_xpub_welcome_msg (self, xpubWelcomeMsg.toUtf8().data()); } /// // Set socket option `stream_notify`. // Available from libzmq 4.2.0. void QZsock::setStreamNotify (int streamNotify) { zsock_set_stream_notify (self, streamNotify); } /// // Get socket option `invert_matching`. // Available from libzmq 4.2.0. int QZsock::invertMatching () { int rv = zsock_invert_matching (self); return rv; } /// // Set socket option `invert_matching`. // Available from libzmq 4.2.0. void QZsock::setInvertMatching (int invertMatching) { zsock_set_invert_matching (self, invertMatching); } /// // Set socket option `xpub_verboser`. // Available from libzmq 4.2.0. void QZsock::setXpubVerboser (int xpubVerboser) { zsock_set_xpub_verboser (self, xpubVerboser); } /// // Get socket option `connect_timeout`. // Available from libzmq 4.2.0. int QZsock::connectTimeout () { int rv = zsock_connect_timeout (self); return rv; } /// // Set socket option `connect_timeout`. // Available from libzmq 4.2.0. void QZsock::setConnectTimeout (int connectTimeout) { zsock_set_connect_timeout (self, connectTimeout); } /// // Get socket option `tcp_maxrt`. // Available from libzmq 4.2.0. int QZsock::tcpMaxrt () { int rv = zsock_tcp_maxrt (self); return rv; } /// // Set socket option `tcp_maxrt`. // Available from libzmq 4.2.0. void QZsock::setTcpMaxrt (int tcpMaxrt) { zsock_set_tcp_maxrt (self, tcpMaxrt); } /// // Get socket option `thread_safe`. // Available from libzmq 4.2.0. int QZsock::threadSafe () { int rv = zsock_thread_safe (self); return rv; } /// // Get socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. int QZsock::multicastMaxtpdu () { int rv = zsock_multicast_maxtpdu (self); return rv; } /// // Set socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. void QZsock::setMulticastMaxtpdu (int multicastMaxtpdu) { zsock_set_multicast_maxtpdu (self, multicastMaxtpdu); } /// // Get socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. int QZsock::vmciBufferSize () { int rv = zsock_vmci_buffer_size (self); return rv; } /// // Set socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. void QZsock::setVmciBufferSize (int vmciBufferSize) { zsock_set_vmci_buffer_size (self, vmciBufferSize); } /// // Get socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. int QZsock::vmciBufferMinSize () { int rv = zsock_vmci_buffer_min_size (self); return rv; } /// // Set socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. void QZsock::setVmciBufferMinSize (int vmciBufferMinSize) { zsock_set_vmci_buffer_min_size (self, vmciBufferMinSize); } /// // Get socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. int QZsock::vmciBufferMaxSize () { int rv = zsock_vmci_buffer_max_size (self); return rv; } /// // Set socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. void QZsock::setVmciBufferMaxSize (int vmciBufferMaxSize) { zsock_set_vmci_buffer_max_size (self, vmciBufferMaxSize); } /// // Get socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. int QZsock::vmciConnectTimeout () { int rv = zsock_vmci_connect_timeout (self); return rv; } /// // Set socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. void QZsock::setVmciConnectTimeout (int vmciConnectTimeout) { zsock_set_vmci_connect_timeout (self, vmciConnectTimeout); } /// // Get socket option `tos`. // Available from libzmq 4.1.0. int QZsock::tos () { int rv = zsock_tos (self); return rv; } /// // Set socket option `tos`. // Available from libzmq 4.1.0. void QZsock::setTos (int tos) { zsock_set_tos (self, tos); } /// // Set socket option `router_handover`. // Available from libzmq 4.1.0. void QZsock::setRouterHandover (int routerHandover) { zsock_set_router_handover (self, routerHandover); } /// // Set socket option `connect_rid`. // Available from libzmq 4.1.0. void QZsock::setConnectRid (const QString &connectRid) { zsock_set_connect_rid (self, connectRid.toUtf8().data()); } /// // Set socket option `connect_rid` from 32-octet binary // Available from libzmq 4.1.0. void QZsock::setConnectRidBin (const byte *connectRid) { zsock_set_connect_rid_bin (self, connectRid); } /// // Get socket option `handshake_ivl`. // Available from libzmq 4.1.0. int QZsock::handshakeIvl () { int rv = zsock_handshake_ivl (self); return rv; } /// // Set socket option `handshake_ivl`. // Available from libzmq 4.1.0. void QZsock::setHandshakeIvl (int handshakeIvl) { zsock_set_handshake_ivl (self, handshakeIvl); } /// // Get socket option `socks_proxy`. // Available from libzmq 4.1.0. QString QZsock::socksProxy () { char *retStr_ = zsock_socks_proxy (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Set socket option `socks_proxy`. // Available from libzmq 4.1.0. void QZsock::setSocksProxy (const QString &socksProxy) { zsock_set_socks_proxy (self, socksProxy.toUtf8().data()); } /// // Set socket option `xpub_nodrop`. // Available from libzmq 4.1.0. void QZsock::setXpubNodrop (int xpubNodrop) { zsock_set_xpub_nodrop (self, xpubNodrop); } /// // Set socket option `router_mandatory`. // Available from libzmq 4.0.0. void QZsock::setRouterMandatory (int routerMandatory) { zsock_set_router_mandatory (self, routerMandatory); } /// // Set socket option `probe_router`. // Available from libzmq 4.0.0. void QZsock::setProbeRouter (int probeRouter) { zsock_set_probe_router (self, probeRouter); } /// // Set socket option `req_relaxed`. // Available from libzmq 4.0.0. void QZsock::setReqRelaxed (int reqRelaxed) { zsock_set_req_relaxed (self, reqRelaxed); } /// // Set socket option `req_correlate`. // Available from libzmq 4.0.0. void QZsock::setReqCorrelate (int reqCorrelate) { zsock_set_req_correlate (self, reqCorrelate); } /// // Set socket option `conflate`. // Available from libzmq 4.0.0. void QZsock::setConflate (int conflate) { zsock_set_conflate (self, conflate); } /// // Get socket option `zap_domain`. // Available from libzmq 4.0.0. QString QZsock::zapDomain () { char *retStr_ = zsock_zap_domain (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Set socket option `zap_domain`. // Available from libzmq 4.0.0. void QZsock::setZapDomain (const QString &zapDomain) { zsock_set_zap_domain (self, zapDomain.toUtf8().data()); } /// // Get socket option `mechanism`. // Available from libzmq 4.0.0. int QZsock::mechanism () { int rv = zsock_mechanism (self); return rv; } /// // Get socket option `plain_server`. // Available from libzmq 4.0.0. int QZsock::plainServer () { int rv = zsock_plain_server (self); return rv; } /// // Set socket option `plain_server`. // Available from libzmq 4.0.0. void QZsock::setPlainServer (int plainServer) { zsock_set_plain_server (self, plainServer); } /// // Get socket option `plain_username`. // Available from libzmq 4.0.0. QString QZsock::plainUsername () { char *retStr_ = zsock_plain_username (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Set socket option `plain_username`. // Available from libzmq 4.0.0. void QZsock::setPlainUsername (const QString &plainUsername) { zsock_set_plain_username (self, plainUsername.toUtf8().data()); } /// // Get socket option `plain_password`. // Available from libzmq 4.0.0. QString QZsock::plainPassword () { char *retStr_ = zsock_plain_password (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Set socket option `plain_password`. // Available from libzmq 4.0.0. void QZsock::setPlainPassword (const QString &plainPassword) { zsock_set_plain_password (self, plainPassword.toUtf8().data()); } /// // Get socket option `curve_server`. // Available from libzmq 4.0.0. int QZsock::curveServer () { int rv = zsock_curve_server (self); return rv; } /// // Set socket option `curve_server`. // Available from libzmq 4.0.0. void QZsock::setCurveServer (int curveServer) { zsock_set_curve_server (self, curveServer); } /// // Get socket option `curve_publickey`. // Available from libzmq 4.0.0. QString QZsock::curvePublickey () { char *retStr_ = zsock_curve_publickey (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Set socket option `curve_publickey`. // Available from libzmq 4.0.0. void QZsock::setCurvePublickey (const QString &curvePublickey) { zsock_set_curve_publickey (self, curvePublickey.toUtf8().data()); } /// // Set socket option `curve_publickey` from 32-octet binary // Available from libzmq 4.0.0. void QZsock::setCurvePublickeyBin (const byte *curvePublickey) { zsock_set_curve_publickey_bin (self, curvePublickey); } /// // Get socket option `curve_secretkey`. // Available from libzmq 4.0.0. QString QZsock::curveSecretkey () { char *retStr_ = zsock_curve_secretkey (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Set socket option `curve_secretkey`. // Available from libzmq 4.0.0. void QZsock::setCurveSecretkey (const QString &curveSecretkey) { zsock_set_curve_secretkey (self, curveSecretkey.toUtf8().data()); } /// // Set socket option `curve_secretkey` from 32-octet binary // Available from libzmq 4.0.0. void QZsock::setCurveSecretkeyBin (const byte *curveSecretkey) { zsock_set_curve_secretkey_bin (self, curveSecretkey); } /// // Get socket option `curve_serverkey`. // Available from libzmq 4.0.0. QString QZsock::curveServerkey () { char *retStr_ = zsock_curve_serverkey (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Set socket option `curve_serverkey`. // Available from libzmq 4.0.0. void QZsock::setCurveServerkey (const QString &curveServerkey) { zsock_set_curve_serverkey (self, curveServerkey.toUtf8().data()); } /// // Set socket option `curve_serverkey` from 32-octet binary // Available from libzmq 4.0.0. void QZsock::setCurveServerkeyBin (const byte *curveServerkey) { zsock_set_curve_serverkey_bin (self, curveServerkey); } /// // Get socket option `gssapi_server`. // Available from libzmq 4.0.0. int QZsock::gssapiServer () { int rv = zsock_gssapi_server (self); return rv; } /// // Set socket option `gssapi_server`. // Available from libzmq 4.0.0. void QZsock::setGssapiServer (int gssapiServer) { zsock_set_gssapi_server (self, gssapiServer); } /// // Get socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. int QZsock::gssapiPlaintext () { int rv = zsock_gssapi_plaintext (self); return rv; } /// // Set socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. void QZsock::setGssapiPlaintext (int gssapiPlaintext) { zsock_set_gssapi_plaintext (self, gssapiPlaintext); } /// // Get socket option `gssapi_principal`. // Available from libzmq 4.0.0. QString QZsock::gssapiPrincipal () { char *retStr_ = zsock_gssapi_principal (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Set socket option `gssapi_principal`. // Available from libzmq 4.0.0. void QZsock::setGssapiPrincipal (const QString &gssapiPrincipal) { zsock_set_gssapi_principal (self, gssapiPrincipal.toUtf8().data()); } /// // Get socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. QString QZsock::gssapiServicePrincipal () { char *retStr_ = zsock_gssapi_service_principal (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Set socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. void QZsock::setGssapiServicePrincipal (const QString &gssapiServicePrincipal) { zsock_set_gssapi_service_principal (self, gssapiServicePrincipal.toUtf8().data()); } /// // Get socket option `ipv6`. // Available from libzmq 4.0.0. int QZsock::ipv6 () { int rv = zsock_ipv6 (self); return rv; } /// // Set socket option `ipv6`. // Available from libzmq 4.0.0. void QZsock::setIpv6 (int ipv6) { zsock_set_ipv6 (self, ipv6); } /// // Get socket option `immediate`. // Available from libzmq 4.0.0. int QZsock::immediate () { int rv = zsock_immediate (self); return rv; } /// // Set socket option `immediate`. // Available from libzmq 4.0.0. void QZsock::setImmediate (int immediate) { zsock_set_immediate (self, immediate); } /// // Get socket option `sndhwm`. // Available from libzmq 3.0.0. int QZsock::sndhwm () { int rv = zsock_sndhwm (self); return rv; } /// // Set socket option `sndhwm`. // Available from libzmq 3.0.0. void QZsock::setSndhwm (int sndhwm) { zsock_set_sndhwm (self, sndhwm); } /// // Get socket option `rcvhwm`. // Available from libzmq 3.0.0. int QZsock::rcvhwm () { int rv = zsock_rcvhwm (self); return rv; } /// // Set socket option `rcvhwm`. // Available from libzmq 3.0.0. void QZsock::setRcvhwm (int rcvhwm) { zsock_set_rcvhwm (self, rcvhwm); } /// // Get socket option `maxmsgsize`. // Available from libzmq 3.0.0. int QZsock::maxmsgsize () { int rv = zsock_maxmsgsize (self); return rv; } /// // Set socket option `maxmsgsize`. // Available from libzmq 3.0.0. void QZsock::setMaxmsgsize (int maxmsgsize) { zsock_set_maxmsgsize (self, maxmsgsize); } /// // Get socket option `multicast_hops`. // Available from libzmq 3.0.0. int QZsock::multicastHops () { int rv = zsock_multicast_hops (self); return rv; } /// // Set socket option `multicast_hops`. // Available from libzmq 3.0.0. void QZsock::setMulticastHops (int multicastHops) { zsock_set_multicast_hops (self, multicastHops); } /// // Set socket option `xpub_verbose`. // Available from libzmq 3.0.0. void QZsock::setXpubVerbose (int xpubVerbose) { zsock_set_xpub_verbose (self, xpubVerbose); } /// // Get socket option `tcp_keepalive`. // Available from libzmq 3.0.0. int QZsock::tcpKeepalive () { int rv = zsock_tcp_keepalive (self); return rv; } /// // Set socket option `tcp_keepalive`. // Available from libzmq 3.0.0. void QZsock::setTcpKeepalive (int tcpKeepalive) { zsock_set_tcp_keepalive (self, tcpKeepalive); } /// // Get socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. int QZsock::tcpKeepaliveIdle () { int rv = zsock_tcp_keepalive_idle (self); return rv; } /// // Set socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. void QZsock::setTcpKeepaliveIdle (int tcpKeepaliveIdle) { zsock_set_tcp_keepalive_idle (self, tcpKeepaliveIdle); } /// // Get socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. int QZsock::tcpKeepaliveCnt () { int rv = zsock_tcp_keepalive_cnt (self); return rv; } /// // Set socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. void QZsock::setTcpKeepaliveCnt (int tcpKeepaliveCnt) { zsock_set_tcp_keepalive_cnt (self, tcpKeepaliveCnt); } /// // Get socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. int QZsock::tcpKeepaliveIntvl () { int rv = zsock_tcp_keepalive_intvl (self); return rv; } /// // Set socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. void QZsock::setTcpKeepaliveIntvl (int tcpKeepaliveIntvl) { zsock_set_tcp_keepalive_intvl (self, tcpKeepaliveIntvl); } /// // Get socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. QString QZsock::tcpAcceptFilter () { char *retStr_ = zsock_tcp_accept_filter (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Set socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. void QZsock::setTcpAcceptFilter (const QString &tcpAcceptFilter) { zsock_set_tcp_accept_filter (self, tcpAcceptFilter.toUtf8().data()); } /// // Get socket option `last_endpoint`. // Available from libzmq 3.0.0. QString QZsock::lastEndpoint () { char *retStr_ = zsock_last_endpoint (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Set socket option `router_raw`. // Available from libzmq 3.0.0. void QZsock::setRouterRaw (int routerRaw) { zsock_set_router_raw (self, routerRaw); } /// // Get socket option `ipv4only`. // Available from libzmq 3.0.0. int QZsock::ipv4only () { int rv = zsock_ipv4only (self); return rv; } /// // Set socket option `ipv4only`. // Available from libzmq 3.0.0. void QZsock::setIpv4only (int ipv4only) { zsock_set_ipv4only (self, ipv4only); } /// // Set socket option `delay_attach_on_connect`. // Available from libzmq 3.0.0. void QZsock::setDelayAttachOnConnect (int delayAttachOnConnect) { zsock_set_delay_attach_on_connect (self, delayAttachOnConnect); } /// // Get socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. int QZsock::hwm () { int rv = zsock_hwm (self); return rv; } /// // Set socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. void QZsock::setHwm (int hwm) { zsock_set_hwm (self, hwm); } /// // Get socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. int QZsock::swap () { int rv = zsock_swap (self); return rv; } /// // Set socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. void QZsock::setSwap (int swap) { zsock_set_swap (self, swap); } /// // Get socket option `affinity`. // Available from libzmq 2.0.0. int QZsock::affinity () { int rv = zsock_affinity (self); return rv; } /// // Set socket option `affinity`. // Available from libzmq 2.0.0. void QZsock::setAffinity (int affinity) { zsock_set_affinity (self, affinity); } /// // Get socket option `identity`. // Available from libzmq 2.0.0. QString QZsock::identity () { char *retStr_ = zsock_identity (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Set socket option `identity`. // Available from libzmq 2.0.0. void QZsock::setIdentity (const QString &identity) { zsock_set_identity (self, identity.toUtf8().data()); } /// // Get socket option `rate`. // Available from libzmq 2.0.0. int QZsock::rate () { int rv = zsock_rate (self); return rv; } /// // Set socket option `rate`. // Available from libzmq 2.0.0. void QZsock::setRate (int rate) { zsock_set_rate (self, rate); } /// // Get socket option `recovery_ivl`. // Available from libzmq 2.0.0. int QZsock::recoveryIvl () { int rv = zsock_recovery_ivl (self); return rv; } /// // Set socket option `recovery_ivl`. // Available from libzmq 2.0.0. void QZsock::setRecoveryIvl (int recoveryIvl) { zsock_set_recovery_ivl (self, recoveryIvl); } /// // Get socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. int QZsock::recoveryIvlMsec () { int rv = zsock_recovery_ivl_msec (self); return rv; } /// // Set socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. void QZsock::setRecoveryIvlMsec (int recoveryIvlMsec) { zsock_set_recovery_ivl_msec (self, recoveryIvlMsec); } /// // Get socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. int QZsock::mcastLoop () { int rv = zsock_mcast_loop (self); return rv; } /// // Set socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. void QZsock::setMcastLoop (int mcastLoop) { zsock_set_mcast_loop (self, mcastLoop); } /// // Get socket option `rcvtimeo`. // Available from libzmq 2.2.0. int QZsock::rcvtimeo () { int rv = zsock_rcvtimeo (self); return rv; } /// // Set socket option `rcvtimeo`. // Available from libzmq 2.2.0. void QZsock::setRcvtimeo (int rcvtimeo) { zsock_set_rcvtimeo (self, rcvtimeo); } /// // Get socket option `sndtimeo`. // Available from libzmq 2.2.0. int QZsock::sndtimeo () { int rv = zsock_sndtimeo (self); return rv; } /// // Set socket option `sndtimeo`. // Available from libzmq 2.2.0. void QZsock::setSndtimeo (int sndtimeo) { zsock_set_sndtimeo (self, sndtimeo); } /// // Get socket option `sndbuf`. // Available from libzmq 2.0.0. int QZsock::sndbuf () { int rv = zsock_sndbuf (self); return rv; } /// // Set socket option `sndbuf`. // Available from libzmq 2.0.0. void QZsock::setSndbuf (int sndbuf) { zsock_set_sndbuf (self, sndbuf); } /// // Get socket option `rcvbuf`. // Available from libzmq 2.0.0. int QZsock::rcvbuf () { int rv = zsock_rcvbuf (self); return rv; } /// // Set socket option `rcvbuf`. // Available from libzmq 2.0.0. void QZsock::setRcvbuf (int rcvbuf) { zsock_set_rcvbuf (self, rcvbuf); } /// // Get socket option `linger`. // Available from libzmq 2.0.0. int QZsock::linger () { int rv = zsock_linger (self); return rv; } /// // Set socket option `linger`. // Available from libzmq 2.0.0. void QZsock::setLinger (int linger) { zsock_set_linger (self, linger); } /// // Get socket option `reconnect_ivl`. // Available from libzmq 2.0.0. int QZsock::reconnectIvl () { int rv = zsock_reconnect_ivl (self); return rv; } /// // Set socket option `reconnect_ivl`. // Available from libzmq 2.0.0. void QZsock::setReconnectIvl (int reconnectIvl) { zsock_set_reconnect_ivl (self, reconnectIvl); } /// // Get socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. int QZsock::reconnectIvlMax () { int rv = zsock_reconnect_ivl_max (self); return rv; } /// // Set socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. void QZsock::setReconnectIvlMax (int reconnectIvlMax) { zsock_set_reconnect_ivl_max (self, reconnectIvlMax); } /// // Get socket option `backlog`. // Available from libzmq 2.0.0. int QZsock::backlog () { int rv = zsock_backlog (self); return rv; } /// // Set socket option `backlog`. // Available from libzmq 2.0.0. void QZsock::setBacklog (int backlog) { zsock_set_backlog (self, backlog); } /// // Set socket option `subscribe`. // Available from libzmq 2.0.0. void QZsock::setSubscribe (const QString &subscribe) { zsock_set_subscribe (self, subscribe.toUtf8().data()); } /// // Set socket option `unsubscribe`. // Available from libzmq 2.0.0. void QZsock::setUnsubscribe (const QString &unsubscribe) { zsock_set_unsubscribe (self, unsubscribe.toUtf8().data()); } /// // Get socket option `type`. // Available from libzmq 2.0.0. int QZsock::type () { int rv = zsock_type (self); return rv; } /// // Get socket option `rcvmore`. // Available from libzmq 2.0.0. int QZsock::rcvmore () { int rv = zsock_rcvmore (self); return rv; } /// // Get socket option `fd`. // Available from libzmq 2.0.0. SOCKET QZsock::fd () { SOCKET rv = zsock_fd (self); return rv; } /// // Get socket option `events`. // Available from libzmq 2.0.0. int QZsock::events () { int rv = zsock_events (self); return rv; } /// // Self test of this class. void QZsock::test (bool verbose) { zsock_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzproc.h0000664000372000037200000001710613222211156020067 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZPROC_H #define Q_ZPROC_H #include "qczmq.h" class QT_CZMQ_EXPORT QZproc : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZproc (zproc_t *self, QObject *qObjParent = 0); // Create a new zproc. // NOTE: On Windows and with libzmq3 and libzmq2 this function // returns NULL. Code needs to be ported there. explicit QZproc (QObject *qObjParent = 0); // Destroy zproc, wait until process ends. ~QZproc (); // Setup the command line arguments, the first item must be an (absolute) filename // to run. void setArgs (QZlistx *args); // Setup the environment variables for the process. void setEnv (QZhashx *args); // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The writable one is then accessbile via zproc_stdin method. void setStdin (void *socket); // Connects process stdout with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stdout method. void setStdout (void *socket); // Connects process stderr with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stderr method. void setStderr (void *socket); // Return subprocess stdin writable socket. NULL for // not initialized or external sockets. void * stdin (); // Return subprocess stdout readable socket. NULL for // not initialized or external sockets. void * stdout (); // Return subprocess stderr readable socket. NULL for // not initialized or external sockets. void * stderr (); // Starts the process. int run (); // process exit code int returncode (); // PID of the process int pid (); // return true if process is running, false if not yet started or finished bool running (); // wait or poll process status, return return code int wait (bool hang); // return internal actor, usefull for the polling if process died void * actor (); // send a signal to the subprocess void kill (int signal); // set verbose mode void setVerbose (bool verbose); // Returns CZMQ version as a single 6-digit integer encoding the major // version (x 10000), the minor version (x 100) and the patch. static int czmqVersion (); // Returns true if the process received a SIGINT or SIGTERM signal. // It is good practice to use this method to exit any infinite loop // processing messages. static bool interrupted (); // Returns true if the underlying libzmq supports CURVE security. static bool hasCurve (); // Return current host name, for use in public tcp:// endpoints. // If the host name is not resolvable, returns NULL. static QString hostname (); // Move the current process into the background. The precise effect // depends on the operating system. On POSIX boxes, moves to a specified // working directory (if specified), closes all file handles, reopens // stdin, stdout, and stderr to the null device, and sets the process to // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there // was an error. static void daemonize (const QString &workdir); // Drop the process ID into the lockfile, with exclusive lock, and // switch the process to the specified group and/or user. Any of the // arguments may be null, indicating a no-op. Returns 0 on success, // -1 on failure. Note if you combine this with zsys_daemonize, run // after, not before that method, or the lockfile will hold the wrong // process ID. static void runAs (const QString &lockfile, const QString &group, const QString &user); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. static void setIoThreads (size_t ioThreads); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. static void setMaxSockets (size_t maxSockets); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". static void setBiface (const QString &value); // Return network interface to use for broadcasts, or "" if none was set. static const QString biface (); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. static void setLogIdent (const QString &value); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. static void setLogSender (const QString &endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. static void setLogSystem (bool logsystem); // Log error condition - highest priority static void logError (const QString ¶m); // Log warning condition - high priority static void logWarning (const QString ¶m); // Log normal, but significant, condition - normal priority static void logNotice (const QString ¶m); // Log informational message - low priority static void logInfo (const QString ¶m); // Log debug-level message - lowest priority static void logDebug (const QString ¶m); // Self test of this class. static void test (bool verbose); zproc_t *self; }; #endif // Q_ZPROC_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qztrie.h0000664000372000037200000000477413222211156020076 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZTRIE_H #define Q_ZTRIE_H #include "qczmq.h" class QT_CZMQ_EXPORT QZtrie : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZtrie (ztrie_t *self, QObject *qObjParent = 0); // Creates a new ztrie. explicit QZtrie (char delimiter, QObject *qObjParent = 0); // Destroy the ztrie. ~QZtrie (); // Inserts a new route into the tree and attaches the data. Returns -1 // if the route already exists, otherwise 0. This method takes ownership of // the provided data if a destroy_data_fn is provided. int insertRoute (const QString &path, void *data, ztrie_destroy_data_fn destroyDataFn); // Removes a route from the trie and destroys its data. Returns -1 if the // route does not exists, otherwise 0. // the start of the list call zlist_first (). Advances the cursor. int removeRoute (const QString &path); // Returns true if the path matches a route in the tree, otherwise false. bool matches (const QString &path); // Returns the data of a matched route from last ztrie_matches. If the path // did not match, returns NULL. Do not delete the data as it's owned by // ztrie. void * hitData (); // Returns the count of parameters that a matched route has. size_t hitParameterCount (); // Returns the parameters of a matched route with named regexes from last // ztrie_matches. If the path did not match or the route did not contain any // named regexes, returns NULL. QZhashx * hitParameters (); // Returns the asterisk matched part of a route, if there has been no match // or no asterisk match, returns NULL. const QString hitAsteriskMatch (); // Print the trie void print (); // Self test of this class. static void test (bool verbose); ztrie_t *self; }; #endif // Q_ZTRIE_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzloop.cpp0000664000372000037200000001466213222211156020434 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZloop::QZloop (zloop_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new zloop reactor QZloop::QZloop (QObject *qObjParent) : QObject (qObjParent) { this->self = zloop_new (); } /// // Destroy a reactor QZloop::~QZloop () { zloop_destroy (&self); } /// // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. int QZloop::reader (QZsock *sock, zloop_reader_fn handler, void *arg) { int rv = zloop_reader (self, sock->self, handler, arg); return rv; } /// // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. void QZloop::readerEnd (QZsock *sock) { zloop_reader_end (self, sock->self); } /// // Configure a registered reader to ignore errors. If you do not set this, // then readers that have errors are removed from the reactor silently. void QZloop::readerSetTolerant (QZsock *sock) { zloop_reader_set_tolerant (self, sock->self); } /// // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. int QZloop::poller (zmq_pollitem_t *item, zloop_fn handler, void *arg) { int rv = zloop_poller (self, item, handler, arg); return rv; } /// // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. void QZloop::pollerEnd (zmq_pollitem_t *item) { zloop_poller_end (self, item); } /// // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. void QZloop::pollerSetTolerant (zmq_pollitem_t *item) { zloop_poller_set_tolerant (self, item); } /// // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. int QZloop::timer (size_t delay, size_t times, zloop_timer_fn handler, void *arg) { int rv = zloop_timer (self, delay, times, handler, arg); return rv; } /// // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer). int QZloop::timerEnd (int timerId) { int rv = zloop_timer_end (self, timerId); return rv; } /// // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. void * QZloop::ticket (zloop_timer_fn handler, void *arg) { void * rv = zloop_ticket (self, handler, arg); return rv; } /// // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. void QZloop::ticketReset (void *handle) { zloop_ticket_reset (self, handle); } /// // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. void QZloop::ticketDelete (void *handle) { zloop_ticket_delete (self, handle); } /// // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. void QZloop::setTicketDelay (size_t ticketDelay) { zloop_set_ticket_delay (self, ticketDelay); } /// // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. void QZloop::setMaxTimers (size_t maxTimers) { zloop_set_max_timers (self, maxTimers); } /// // Set verbose tracing of reactor on/off. The default verbose setting is // off (false). void QZloop::setVerbose (bool verbose) { zloop_set_verbose (self, verbose); } /// // By default the reactor stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void QZloop::setNonstop (bool nonstop) { zloop_set_nonstop (self, nonstop); } /// // Start the reactor. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. int QZloop::start () { int rv = zloop_start (self); return rv; } /// // Self test of this class. void QZloop::test (bool verbose) { zloop_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzdigest.cpp0000664000372000037200000000403313222211156020731 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZdigest::QZdigest (zdigest_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. QZdigest::QZdigest (QObject *qObjParent) : QObject (qObjParent) { this->self = zdigest_new (); } /// // Destroy a digest object QZdigest::~QZdigest () { zdigest_destroy (&self); } /// // Add buffer into digest calculation void QZdigest::update (const byte *buffer, size_t length) { zdigest_update (self, buffer, length); } /// // Return final digest hash data. If built without crypto support, // returns NULL. const byte * QZdigest::data () { const byte * rv = zdigest_data (self); return rv; } /// // Return final digest hash size size_t QZdigest::size () { size_t rv = zdigest_size (self); return rv; } /// // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. const QString QZdigest::string () { const QString rv = QString (zdigest_string (self)); return rv; } /// // Self test of this class. void QZdigest::test (bool verbose) { zdigest_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzargs.h0000664000372000037200000000440113222211156020052 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZARGS_H #define Q_ZARGS_H #include "qczmq.h" class QT_CZMQ_EXPORT QZargs : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZargs (zargs_t *self, QObject *qObjParent = 0); // Destroy zargs instance. ~QZargs (); // Return program name (argv[0]) const QString progname (); // Return number of positional arguments size_t arguments (); // Return first positional argument or NULL const QString first (); // Return next positional argument or NULL const QString next (); // Return first named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const QString paramFirst (); // Return next named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const QString paramNext (); // Return current parameter name, or NULL if there are no named // parameters. const QString paramName (); // Return value of named parameter, NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const QString paramLookup (const QString &keys); // Returns true if there are --help -h arguments bool hasHelp (); // Returns true if parameter did not have a value static bool paramEmpty (const QString &arg); // Print an instance of zargs. void print (); // Self test of this class. static void test (bool verbose); zargs_t *self; }; #endif // Q_ZARGS_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzdir.h0000664000372000037200000000752013222211156017701 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZDIR_H #define Q_ZDIR_H #include "qczmq.h" class QT_CZMQ_EXPORT QZdir : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZdir (zdir_t *self, QObject *qObjParent = 0); // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. explicit QZdir (const QString &path, const QString &parent, QObject *qObjParent = 0); // Destroy a directory tree and all children it contains. ~QZdir (); // Return directory path const QString path (); // Return last modification time for directory. time_t modified (); // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. off_t cursize (); // Return directory count size_t count (); // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. QZlist * list (); // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. void remove (bool force); // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). static QZlist * diff (QZdir *older, QZdir *newer, const QString &alias); // Return full contents of directory as a zdir_patch list. QZlist * resync (const QString &alias); // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. QZhash * cache (); // Print contents of directory to open stream void fprint (FILE *file, int indent); // Print contents of directory to stdout void print (int indent); // Create a new zdir_watch actor instance: // // zactor_t *watch = zactor_new (zdir_watch, NULL); // // Destroy zdir_watch instance: // // zactor_destroy (&watch); // // Enable verbose logging of commands and activity: // // zstr_send (watch, "VERBOSE"); // // Subscribe to changes to a directory path: // // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); // // Unsubscribe from changes to a directory path: // // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); // // Receive directory changes: // zsock_recv (watch, "sp", &path, &patches); // // // Delete the received data. // free (path); // zlist_destroy (&patches); static void watch (QZsock *pipe, void *unused); // Self test of this class. static void test (bool verbose); zdir_t *self; }; #endif // Q_ZDIR_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzhashx.cpp0000664000372000037200000002445313222211156020575 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZhashx::QZhashx (zhashx_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new, empty hash container QZhashx::QZhashx (QObject *qObjParent) : QObject (qObjParent) { this->self = zhashx_new (); } /// // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. QZhashx* QZhashx::unpack (QZframe *frame, QObject *qObjParent) { return new QZhashx (zhashx_unpack (frame->self), qObjParent); } /// // Same as unpack but uses a user-defined deserializer function to convert // a longstr back into item format. QZhashx* QZhashx::unpackOwn (QZframe *frame, zhashx_deserializer_fn deserializer, QObject *qObjParent) { return new QZhashx (zhashx_unpack_own (frame->self, deserializer), qObjParent); } /// // Destroy a hash container and all items in it QZhashx::~QZhashx () { zhashx_destroy (&self); } /// // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int QZhashx::insert (const void *key, void *item) { int rv = zhashx_insert (self, key, item); return rv; } /// // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. void QZhashx::update (const void *key, void *item) { zhashx_update (self, key, item); } /// // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void QZhashx::deleteNoConflict (const void *key) { zhashx_delete (self, key); } /// // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. void QZhashx::purge () { zhashx_purge (self); } /// // Return the item at the specified key, or null void * QZhashx::lookup (const void *key) { void * rv = zhashx_lookup (self, key); return rv; } /// // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int QZhashx::rename (const void *oldKey, const void *newKey) { int rv = zhashx_rename (self, oldKey, newKey); return rv; } /// // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * QZhashx::freefn (const void *key, zhashx_free_fn freeFn) { void * rv = zhashx_freefn (self, key, freeFn); return rv; } /// // Return the number of keys/items in the hash table size_t QZhashx::size () { size_t rv = zhashx_size (self); return rv; } /// // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. QZlistx * QZhashx::keys () { QZlistx *rv = new QZlistx (zhashx_keys (self)); return rv; } /// // Return a zlistx_t containing the values for the items in the // table. Uses the duplicator to duplicate all items and sets the // destructor as destructor for the list. QZlistx * QZhashx::values () { QZlistx *rv = new QZlistx (zhashx_values (self)); return rv; } /// // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhashx_cursor(). NOTE: do NOT modify the table while iterating. void * QZhashx::first () { void * rv = zhashx_first (self); return rv; } /// // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). To // access the key for this item use zhashx_cursor(). NOTE: do NOT modify // the table while iterating. void * QZhashx::next () { void * rv = zhashx_next (self); return rv; } /// // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const void * QZhashx::cursor () { const void * rv = zhashx_cursor (self); return rv; } /// // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void QZhashx::comment (const QString ¶m) { zhashx_comment (self, "%s", param.toUtf8().data()); } /// // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int QZhashx::save (const QString &filename) { int rv = zhashx_save (self, filename.toUtf8().data()); return rv; } /// // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int QZhashx::load (const QString &filename) { int rv = zhashx_load (self, filename.toUtf8().data()); return rv; } /// // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int QZhashx::refresh () { int rv = zhashx_refresh (self); return rv; } /// // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. QZframe * QZhashx::pack () { QZframe *rv = new QZframe (zhashx_pack (self)); return rv; } /// // Same as pack but uses a user-defined serializer function to convert items // into longstr. QZframe * QZhashx::packOwn (zhashx_serializer_fn serializer) { QZframe *rv = new QZframe (zhashx_pack_own (self, serializer)); return rv; } /// // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. QZhashx * QZhashx::dup () { QZhashx *rv = new QZhashx (zhashx_dup (self)); return rv; } /// // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. void QZhashx::setDestructor (zhashx_destructor_fn destructor) { zhashx_set_destructor (self, destructor); } /// // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. void QZhashx::setDuplicator (zhashx_duplicator_fn duplicator) { zhashx_set_duplicator (self, duplicator); } /// // Set a user-defined deallocator for keys; by default keys are freed // when the hash is destroyed using free(). void QZhashx::setKeyDestructor (zhashx_destructor_fn destructor) { zhashx_set_key_destructor (self, destructor); } /// // Set a user-defined duplicator for keys; by default keys are duplicated // using strdup. void QZhashx::setKeyDuplicator (zhashx_duplicator_fn duplicator) { zhashx_set_key_duplicator (self, duplicator); } /// // Set a user-defined comparator for keys; by default keys are // compared using strcmp. // The callback function should return zero (0) on matching // items. void QZhashx::setKeyComparator (zhashx_comparator_fn comparator) { zhashx_set_key_comparator (self, comparator); } /// // Set a user-defined hash function for keys; by default keys are // hashed by a modified Bernstein hashing function. void QZhashx::setKeyHasher (zhashx_hash_fn hasher) { zhashx_set_key_hasher (self, hasher); } /// // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. QZhashx * QZhashx::dupV2 () { QZhashx *rv = new QZhashx (zhashx_dup_v2 (self)); return rv; } /// // Self test of this class. void QZhashx::test (bool verbose) { zhashx_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzpoller.cpp0000664000372000037200000000603013222211156020746 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZpoller::QZpoller (zpoller_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Destroy a poller QZpoller::~QZpoller () { zpoller_destroy (&self); } /// // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. int QZpoller::add (void *reader) { int rv = zpoller_add (self, reader); return rv; } /// // Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader // must have been passed during construction, or in an zpoller_add () call. int QZpoller::remove (void *reader) { int rv = zpoller_remove (self, reader); return rv; } /// // By default the poller stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void QZpoller::setNonstop (bool nonstop) { zpoller_set_nonstop (self, nonstop); } /// // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. void * QZpoller::wait (int timeout) { void * rv = zpoller_wait (self, timeout); return rv; } /// // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. bool QZpoller::expired () { bool rv = zpoller_expired (self); return rv; } /// // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. bool QZpoller::terminated () { bool rv = zpoller_terminated (self); return rv; } /// // Self test of this class. void QZpoller::test (bool verbose) { zpoller_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qztimerset.cpp0000664000372000037200000000511713222211156021312 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZtimerset::QZtimerset (ztimerset_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create new timer set. QZtimerset::QZtimerset (QObject *qObjParent) : QObject (qObjParent) { this->self = ztimerset_new (); } /// // Destroy a timer set QZtimerset::~QZtimerset () { ztimerset_destroy (&self); } /// // Add a timer to the set. Returns timer id if OK, -1 on failure. int QZtimerset::add (size_t interval, ztimerset_fn handler, void *arg) { int rv = ztimerset_add (self, interval, handler, arg); return rv; } /// // Cancel a timer. Returns 0 if OK, -1 on failure. int QZtimerset::cancel (int timerId) { int rv = ztimerset_cancel (self, timerId); return rv; } /// // Set timer interval. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int QZtimerset::setInterval (int timerId, size_t interval) { int rv = ztimerset_set_interval (self, timerId, interval); return rv; } /// // Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int QZtimerset::reset (int timerId) { int rv = ztimerset_reset (self, timerId); return rv; } /// // Return the time until the next interval. // Should be used as timeout parameter for the zpoller wait method. // The timeout is in msec. int QZtimerset::timeout () { int rv = ztimerset_timeout (self); return rv; } /// // Invoke callback function of all timers which their interval has elapsed. // Should be call after zpoller wait method. // Returns 0 if OK, -1 on failure. int QZtimerset::execute () { int rv = ztimerset_execute (self); return rv; } /// // Self test of this class. void QZtimerset::test (bool verbose) { ztimerset_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzcertstore.h0000664000372000037200000000541113222211156021132 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZCERTSTORE_H #define Q_ZCERTSTORE_H #include "qczmq.h" class QT_CZMQ_EXPORT QZcertstore : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZcertstore (zcertstore_t *self, QObject *qObjParent = 0); // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. explicit QZcertstore (const QString &location, QObject *qObjParent = 0); // Destroy a certificate store object in memory. Does not affect anything // stored on disk. ~QZcertstore (); // Override the default disk loader with a custom loader fn. void setLoader (zcertstore_loader loader, zcertstore_destructor destructor, void *state); // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. QZcert * lookup (const QString &publicKey); // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. void insert (QZcert *certP); // Empty certificate hashtable. This wrapper exists to be friendly to bindings, // which don't usually have access to struct internals. void empty (); // Print list of certificates in store to logging facility void print (); // Return a list of all the certificates in the store. // The caller takes ownership of the zlistx_t object and is responsible // for destroying it. The caller does not take ownership of the zcert_t // objects. QZlistx * certs (); // Self test of this class static void test (bool verbose); zcertstore_t *self; }; #endif // Q_ZCERTSTORE_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzpoller.h0000664000372000037200000000537513222211156020426 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZPOLLER_H #define Q_ZPOLLER_H #include "qczmq.h" class QT_CZMQ_EXPORT QZpoller : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZpoller (zpoller_t *self, QObject *qObjParent = 0); // Destroy a poller ~QZpoller (); // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. int add (void *reader); // Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader // must have been passed during construction, or in an zpoller_add () call. int remove (void *reader); // By default the poller stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void setNonstop (bool nonstop); // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. void * wait (int timeout); // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. bool expired (); // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. bool terminated (); // Self test of this class. static void test (bool verbose); zpoller_t *self; }; #endif // Q_ZPOLLER_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzframe.h0000664000372000037200000001030013222211156020203 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZFRAME_H #define Q_ZFRAME_H #include "qczmq.h" class QT_CZMQ_EXPORT QZframe : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZframe (zframe_t *self, QObject *qObjParent = 0); // Create a new frame. If size is not null, allocates the frame data // to the specified size. If additionally, data is not null, copies // size octets from the specified data into the frame body. explicit QZframe (const void *data, size_t size, QObject *qObjParent = 0); // Create an empty (zero-sized) frame static QZframe* newEmpty (QObject *qObjParent = 0); // Create a frame with a specified string content. static QZframe* from (const QString &string, 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 // zpoller or zloop. static QZframe* recv (void *source, QObject *qObjParent = 0); // Destroy a frame ~QZframe (); // Send a frame to a socket, destroy frame after sending. // Return -1 on error, 0 on success. int send (void *dest, int flags); // Return number of bytes in frame data size_t size (); // Return address of frame data byte * data (); // Return meta data property for frame // The caller shall not modify or free the returned value, which shall be // owned by the message. const QString meta (const QString &property); // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. QZframe * dup (); // Return frame data encoded as printable hex string, useful for 0MQ UUIDs. // Caller must free string when finished with it. QString strhex (); // Return frame data copied into freshly allocated string // Caller must free string when finished with it. QString strdup (); // Return TRUE if frame body is equal to string, excluding terminator bool streqNoConflict (const QString &string); // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method int more (); // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. void setMore (int more); // Return frame routing ID, if the frame came from a ZMQ_SERVER socket. // Else returns zero. quint32 routingId (); // Set routing ID on frame. This is used if/when the frame is sent to a // ZMQ_SERVER socket. void setRoutingId (quint32 routingId); // Return frame group of radio-dish pattern. const QString group (); // Set group on frame. This is used if/when the frame is sent to a // ZMQ_RADIO socket. // Return -1 on error, 0 on success. int setGroup (const QString &group); // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false. bool eq (QZframe *other); // Set new contents for frame void reset (const void *data, size_t size); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. void print (const QString &prefix); // Probe the supplied object, and report if it looks like a zframe_t. static bool is (void *self); // Self test of this class. static void test (bool verbose); zframe_t *self; }; #endif // Q_ZFRAME_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzchunk.cpp0000664000372000037200000001417513222211156020572 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZchunk::QZchunk (zchunk_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. QZchunk::QZchunk (const void *data, size_t size, QObject *qObjParent) : QObject (qObjParent) { this->self = zchunk_new (data, size); } /// // Destroy a chunk QZchunk::~QZchunk () { zchunk_destroy (&self); } /// // Resizes chunk max_size as requested; chunk_cur size is set to zero void QZchunk::resize (size_t size) { zchunk_resize (self, size); } /// // Return chunk cur size size_t QZchunk::size () { size_t rv = zchunk_size (self); return rv; } /// // Return chunk max size size_t QZchunk::maxSize () { size_t rv = zchunk_max_size (self); return rv; } /// // Return chunk data byte * QZchunk::data () { byte * rv = zchunk_data (self); return rv; } /// // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk size_t QZchunk::set (const void *data, size_t size) { size_t rv = zchunk_set (self, data, size); return rv; } /// // Fill chunk data from user-supplied octet size_t QZchunk::fill (byte filler, size_t size) { size_t rv = zchunk_fill (self, filler, size); return rv; } /// // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, it is truncated. If you want to // grow the chunk to accommodate new data, use the zchunk_extend method. size_t QZchunk::append (const void *data, size_t size) { size_t rv = zchunk_append (self, data, size); return rv; } /// // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, the chunk grows in size. size_t QZchunk::extend (const void *data, size_t size) { size_t rv = zchunk_extend (self, data, size); return rv; } /// // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. size_t QZchunk::consume (QZchunk *source) { size_t rv = zchunk_consume (self, source->self); return rv; } /// // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. bool QZchunk::exhausted () { bool rv = zchunk_exhausted (self); return rv; } /// // Read chunk from an open file descriptor QZchunk * QZchunk::read (FILE *handle, size_t bytes) { QZchunk *rv = new QZchunk (zchunk_read (handle, bytes)); return rv; } /// // Write chunk to an open file descriptor int QZchunk::write (FILE *handle) { int rv = zchunk_write (self, handle); return rv; } /// // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. QZchunk * QZchunk::slurp (const QString &filename, size_t maxsize) { QZchunk *rv = new QZchunk (zchunk_slurp (filename.toUtf8().data(), maxsize)); return rv; } /// // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // returns null. QZchunk * QZchunk::dup () { QZchunk *rv = new QZchunk (zchunk_dup (self)); return rv; } /// // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. QString QZchunk::strhex () { char *retStr_ = zchunk_strhex (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. QString QZchunk::strdup () { char *retStr_ = zchunk_strdup (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Return TRUE if chunk body is equal to string, excluding terminator bool QZchunk::streqNoConflict (const QString &string) { bool rv = zchunk_streq (self, string.toUtf8().data()); return rv; } /// // Transform zchunk into a zframe that can be sent in a message. QZframe * QZchunk::pack () { QZframe *rv = new QZframe (zchunk_pack (self)); return rv; } /// // Transform a zframe into a zchunk. QZchunk * QZchunk::unpack (QZframe *frame) { QZchunk *rv = new QZchunk (zchunk_unpack (frame->self)); return rv; } /// // Calculate SHA1 digest for chunk, using zdigest class. const QString QZchunk::digest () { const QString rv = QString (zchunk_digest (self)); return rv; } /// // Dump chunk to FILE stream, for debugging and tracing. void QZchunk::fprint (FILE *file) { zchunk_fprint (self, file); } /// // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details void QZchunk::print () { zchunk_print (self); } /// // Probe the supplied object, and report if it looks like a zchunk_t. bool QZchunk::is (void *self) { bool rv = zchunk_is (self); return rv; } /// // Self test of this class. void QZchunk::test (bool verbose) { zchunk_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzclock.h0000664000372000037200000000366713222211156020226 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZCLOCK_H #define Q_ZCLOCK_H #include "qczmq.h" class QT_CZMQ_EXPORT QZclock : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZclock (zclock_t *self, QObject *qObjParent = 0); // Sleep for a number of milliseconds static void sleep (int msecs); // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. static int64_t time (); // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. static int64_t mono (); // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. static int64_t usecs (); // Return formatted date/time as fresh string. Free using zstr_free(). static QString timestr (); // Self test of this class. static void test (bool verbose); zclock_t *self; }; #endif // Q_ZCLOCK_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzsys.h0000664000372000037200000004001213222211156017732 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZSYS_H #define Q_ZSYS_H #include "qczmq.h" class QT_CZMQ_EXPORT QZsys : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZsys (zsys_t *self, QObject *qObjParent = 0); // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. static void * init (); // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls. static void shutdown (); // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. // *** This is for CZMQ internal use only and may change arbitrarily *** static void * socket (int type, const QString &filename, size_t lineNbr); // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). // *** This is for CZMQ internal use only and may change arbitrarily *** static int close (void *handle, const QString &filename, size_t lineNbr); // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** static const QString sockname (int socktype); // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. static QZsock * createPipe (QZsock *backendP); // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. static void handlerSet (zsys_handler_fn *handlerFn); // Reset interrupt handler, call this at exit if needed static void handlerReset (); // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. // Can be supressed by ZSYS_SIGHANDLER=false // *** This is for CZMQ internal use only and may change arbitrarily *** static void catchInterrupts (); // Return 1 if file exists, else zero static bool fileExists (const QString &filename); // Return file modification time. Returns 0 if the file does not exist. static time_t fileModified (const QString &filename); // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. static int fileMode (const QString &filename); // Delete file. Does not complain if the file is absent static int fileDelete (const QString &filename); // Check if file is 'stable' static bool fileStable (const QString &filename); // Move to a specified working directory. Returns 0 if OK, -1 if this failed. static int dirChange (const QString &pathname); // Set private file creation mode; all files created from here will be // readable/writable by the owner only. static void fileModePrivate (); // Reset default file creation mode; all files created from here will use // process file mode defaults. static void fileModeDefault (); // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. static void version (int *major, int *minor, int *patch); // Format a string with a va_list argument, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). static const QString vprintf (const QString &format, va_list argptr); // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. // *** This is for CZMQ internal use only and may change arbitrarily *** static SOCKET udpNew (bool routable); // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** static int udpClose (SOCKET handle); // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** static int udpSend (SOCKET udpsock, QZframe *frame, inaddr_t *address, int addrlen); // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or // NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. // *** This is for CZMQ internal use only and may change arbitrarily *** static QZframe * udpRecv (SOCKET udpsock, const QString &peername, int peerlen); // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. // *** This is for CZMQ internal use only and may change arbitrarily *** static void socketError (const QString &reason); // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. static const QString hostname (); // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. static int daemonize (const QString &workdir); // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. static int runAs (const QString &lockfile, const QString &group, const QString &user); // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. static bool hasCurve (); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. static void setIoThreads (size_t ioThreads); // Configure the scheduling policy of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY // is defined, that provides the default. // Note that this method is valid only before any socket is created. static void setThreadSchedPolicy (int policy); // Configure the scheduling priority of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_PRIORITY is // defined, that provides the default. // Note that this method is valid only before any socket is created. static void setThreadPriority (int priority); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. static void setMaxSockets (size_t maxSockets); // Return maximum number of ZeroMQ sockets that the system will support. static size_t socketLimit (); // Configure the maximum allowed size of a message sent. // The default is INT_MAX. static void setMaxMsgsz (int maxMsgsz); // Return maximum message size. static int maxMsgsz (); // Configure the threshold value of filesystem object age per st_mtime // that should elapse until we consider that object "stable" at the // current zclock_time() moment. // The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c // which generally depends on host OS, with fallback value of 5000. static void setFileStableAgeMsec (int64_t fileStableAgeMsec); // Return current threshold value of file stable age in msec. // This can be used in code that chooses to wait for this timeout // before testing if a filesystem object is "stable" or not. static int64_t fileStableAgeMsec (); // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. static void setLinger (size_t linger); // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. static void setSndhwm (size_t sndhwm); // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. static void setRcvhwm (size_t rcvhwm); // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. static void setPipehwm (size_t pipehwm); // Return the HWM for zactor internal pipes. static size_t pipehwm (); // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. static void setIpv6 (int ipv6); // Return use of IPv6 for zsock instances. static int ipv6 (); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". static void setInterface (const QString &value); // Return network interface to use for broadcasts, or "" if none was set. static const QString interface (); // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses // on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, // use that as the default IPv6 address. static void setIpv6Address (const QString &value); // Return IPv6 address to use for zbeacon reception, or "" if none was set. static const QString ipv6Address (); // Set IPv6 milticast address to use for sending zbeacon messages. This needs // to be set if IPv6 is enabled. If the environment variable // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast // address. static void setIpv6McastAddress (const QString &value); // Return IPv6 multicast address to use for sending zbeacon, or "" if none was // set. static const QString ipv6McastAddress (); // Configure the automatic use of pre-allocated FDs when creating new sockets. // If 0 (default), nothing will happen. Else, when a new socket is bound, the // system API will be used to check if an existing pre-allocated FD with a // matching port (if TCP) or path (if IPC) exists, and if it does it will be // set via the ZMQ_USE_FD socket option so that the library will use it // instead of creating a new socket. static void setAutoUseFd (int autoUseFd); // Return use of automatic pre-allocated FDs for zsock instances. static int autoUseFd (); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. static void setLogident (const QString &value); // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). static void setLogstream (FILE *stream); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. static void setLogsender (const QString &endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. static void setLogsystem (bool logsystem); // Self test of this class. static void test (bool verbose); zsys_t *self; }; #endif // Q_ZSYS_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzmsg.cpp0000664000372000037200000002262613222211156020250 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZmsg::QZmsg (zmsg_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new empty message object QZmsg::QZmsg (QObject *qObjParent) : QObject (qObjParent) { this->self = zmsg_new (); } /// // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted. Does a blocking recv. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving. QZmsg* QZmsg::recv (void *source, QObject *qObjParent) { return new QZmsg (zmsg_recv (source), qObjParent); } /// // Load/append an open file into new message, return the message. // Returns NULL if the message could not be loaded. QZmsg* QZmsg::load (FILE *file, QObject *qObjParent) { return new QZmsg (zmsg_load (file), qObjParent); } /// // Decodes a serialized message frame created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the frame was badly formatted or // there was insufficient memory to work. QZmsg* QZmsg::decode (QZframe *frame, QObject *qObjParent) { return new QZmsg (zmsg_decode (frame->self), qObjParent); } /// // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. QZmsg* QZmsg::newSignal (byte status, QObject *qObjParent) { return new QZmsg (zmsg_new_signal (status), qObjParent); } /// // Destroy a message object and all frames it contains QZmsg::~QZmsg () { zmsg_destroy (&self); } /// // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int QZmsg::send (void *dest) { int rv = zmsg_send (&self, dest); return rv; } /// // Send message to destination socket as part of a multipart sequence, and // destroy the message after sending it successfully. Note that after a // zmsg_sendm, you must call zmsg_send or another method that sends a final // message part. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int QZmsg::sendm (void *dest) { int rv = zmsg_sendm (&self, dest); return rv; } /// // Return size of message, i.e. number of frames (0 or more). size_t QZmsg::size () { size_t rv = zmsg_size (self); return rv; } /// // Return total size of all frames in message. size_t QZmsg::contentSize () { size_t rv = zmsg_content_size (self); return rv; } /// // Return message routing ID, if the message came from a ZMQ_SERVER socket. // Else returns zero. quint32 QZmsg::routingId () { uint32_t rv = zmsg_routing_id (self); return rv; } /// // Set routing ID on message. This is used if/when the message is sent to a // ZMQ_SERVER socket. void QZmsg::setRoutingId (quint32 routingId) { zmsg_set_routing_id (self, (uint32_t) routingId); } /// // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. int QZmsg::prepend (QZframe *frameP) { int rv = zmsg_prepend (self, &frameP->self); return rv; } /// // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Deprecates zmsg_add, which did not nullify the // caller's frame reference. int QZmsg::append (QZframe *frameP) { int rv = zmsg_append (self, &frameP->self); return rv; } /// // Remove first frame from message, if any. Returns frame, or NULL. QZframe * QZmsg::pop () { QZframe *rv = new QZframe (zmsg_pop (self)); return rv; } /// // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. int QZmsg::pushmem (const void *data, size_t size) { int rv = zmsg_pushmem (self, data, size); return rv; } /// // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. int QZmsg::addmem (const void *data, size_t size) { int rv = zmsg_addmem (self, data, size); return rv; } /// // Push string as new frame to front of message. // Returns 0 on success, -1 on error. int QZmsg::pushstr (const QString &string) { int rv = zmsg_pushstr (self, string.toUtf8().data()); return rv; } /// // Push string as new frame to end of message. // Returns 0 on success, -1 on error. int QZmsg::addstr (const QString &string) { int rv = zmsg_addstr (self, string.toUtf8().data()); return rv; } /// // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. int QZmsg::pushstrf (const QString ¶m) { int rv = zmsg_pushstrf (self, "%s", param.toUtf8().data()); return rv; } /// // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. int QZmsg::addstrf (const QString ¶m) { int rv = zmsg_addstrf (self, "%s", param.toUtf8().data()); return rv; } /// // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. QString QZmsg::popstr () { char *retStr_ = zmsg_popstr (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. int QZmsg::addmsg (QZmsg *msgP) { int rv = zmsg_addmsg (self, &msgP->self); return rv; } /// // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not successful. QZmsg * QZmsg::popmsg () { QZmsg *rv = new QZmsg (zmsg_popmsg (self)); return rv; } /// // Remove specified frame from list, if present. Does not destroy frame. void QZmsg::remove (QZframe *frame) { zmsg_remove (self, frame->self); } /// // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. QZframe * QZmsg::first () { QZframe *rv = new QZframe (zmsg_first (self)); return rv; } /// // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. QZframe * QZmsg::next () { QZframe *rv = new QZframe (zmsg_next (self)); return rv; } /// // Return the last frame. If there are no frames, returns NULL. QZframe * QZmsg::last () { QZframe *rv = new QZframe (zmsg_last (self)); return rv; } /// // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. int QZmsg::save (FILE *file) { int rv = zmsg_save (self, file); return rv; } /// // Serialize multipart message to a single message frame. Use this method // to send structured messages across transports that do not support // multipart data. Allocates and returns a new frame containing the // serialized message. To decode a serialized message frame, use // zmsg_decode (). QZframe * QZmsg::encode () { QZframe *rv = new QZframe (zmsg_encode (self)); return rv; } /// // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. QZmsg * QZmsg::dup () { QZmsg *rv = new QZmsg (zmsg_dup (self)); return rv; } /// // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). void QZmsg::print () { zmsg_print (self); } /// // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. bool QZmsg::eq (QZmsg *other) { bool rv = zmsg_eq (self, other->self); return rv; } /// // Return signal value, 0 or greater, if message is a signal, -1 if not. int QZmsg::signal () { int rv = zmsg_signal (self); return rv; } /// // Probe the supplied object, and report if it looks like a zmsg_t. bool QZmsg::is (void *self) { bool rv = zmsg_is (self); return rv; } /// // Self test of this class. void QZmsg::test (bool verbose) { zmsg_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzcert.cpp0000664000372000037200000001130213222211156020404 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZcert::QZcert (zcert_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create and initialize a new certificate in memory QZcert::QZcert (QObject *qObjParent) : QObject (qObjParent) { this->self = zcert_new (); } /// // Accepts public/secret key pair from caller QZcert* QZcert::newFrom (const byte *publicKey, const byte *secretKey, QObject *qObjParent) { return new QZcert (zcert_new_from (publicKey, secretKey), qObjParent); } /// // Accepts public/secret key text pair from caller QZcert* QZcert::newFromTxt (const QString &publicTxt, const QString &secretTxt, QObject *qObjParent) { return new QZcert (zcert_new_from_txt (publicTxt.toUtf8().data(), secretTxt.toUtf8().data()), qObjParent); } /// // Load certificate from file QZcert* QZcert::load (const QString &filename, QObject *qObjParent) { return new QZcert (zcert_load (filename.toUtf8().data()), qObjParent); } /// // Destroy a certificate in memory QZcert::~QZcert () { zcert_destroy (&self); } /// // Return public part of key pair as 32-byte binary string const byte * QZcert::publicKey () { const byte * rv = zcert_public_key (self); return rv; } /// // Return secret part of key pair as 32-byte binary string const byte * QZcert::secretKey () { const byte * rv = zcert_secret_key (self); return rv; } /// // Return public part of key pair as Z85 armored string const QString QZcert::publicTxt () { const QString rv = QString (zcert_public_txt (self)); return rv; } /// // Return secret part of key pair as Z85 armored string const QString QZcert::secretTxt () { const QString rv = QString (zcert_secret_txt (self)); return rv; } /// // Set certificate metadata from formatted string. void QZcert::setMeta (const QString &name, const QString ¶m) { zcert_set_meta (self, name.toUtf8().data(), "%s", param.toUtf8().data()); } /// // Unset certificate metadata. void QZcert::unsetMeta (const QString &name) { zcert_unset_meta (self, name.toUtf8().data()); } /// // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. const QString QZcert::meta (const QString &name) { const QString rv = QString (zcert_meta (self, name.toUtf8().data())); return rv; } /// // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. QZlist * QZcert::metaKeys () { QZlist *rv = new QZlist (zcert_meta_keys (self)); return rv; } /// // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). int QZcert::save (const QString &filename) { int rv = zcert_save (self, filename.toUtf8().data()); return rv; } /// // Save public certificate only to file for persistent storage int QZcert::savePublic (const QString &filename) { int rv = zcert_save_public (self, filename.toUtf8().data()); return rv; } /// // Save secret certificate only to file for persistent storage int QZcert::saveSecret (const QString &filename) { int rv = zcert_save_secret (self, filename.toUtf8().data()); return rv; } /// // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. void QZcert::apply (void *socket) { zcert_apply (self, socket); } /// // Return copy of certificate; if certificate is NULL or we exhausted // heap memory, returns NULL. QZcert * QZcert::dup () { QZcert *rv = new QZcert (zcert_dup (self)); return rv; } /// // Return true if two certificates have the same keys bool QZcert::eq (QZcert *compare) { bool rv = zcert_eq (self, compare->self); return rv; } /// // Print certificate contents to stdout void QZcert::print () { zcert_print (self); } /// // Self test of this class void QZcert::test (bool verbose) { zcert_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qztimerset.h0000664000372000037200000000422413222211156020755 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZTIMERSET_H #define Q_ZTIMERSET_H #include "qczmq.h" class QT_CZMQ_EXPORT QZtimerset : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZtimerset (ztimerset_t *self, QObject *qObjParent = 0); // Create new timer set. explicit QZtimerset (QObject *qObjParent = 0); // Destroy a timer set ~QZtimerset (); // Add a timer to the set. Returns timer id if OK, -1 on failure. int add (size_t interval, ztimerset_fn handler, void *arg); // Cancel a timer. Returns 0 if OK, -1 on failure. int cancel (int timerId); // Set timer interval. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int setInterval (int timerId, size_t interval); // Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int reset (int timerId); // Return the time until the next interval. // Should be used as timeout parameter for the zpoller wait method. // The timeout is in msec. int timeout (); // Invoke callback function of all timers which their interval has elapsed. // Should be call after zpoller wait method. // Returns 0 if OK, -1 on failure. int execute (); // Self test of this class. static void test (bool verbose); ztimerset_t *self; }; #endif // Q_ZTIMERSET_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzlist.h0000664000372000037200000001205513222211156020075 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZLIST_H #define Q_ZLIST_H #include "qczmq.h" class QT_CZMQ_EXPORT QZlist : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZlist (zlist_t *self, QObject *qObjParent = 0); // Create a new list container explicit QZlist (QObject *qObjParent = 0); // Destroy a list container ~QZlist (); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * first (); // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. void * next (); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * last (); // Return first item in the list, or null, leaves the cursor void * head (); // Return last item in the list, or null, leaves the cursor void * tail (); // Return the current item of list. If the list is empty, returns NULL. // Leaves cursor pointing at the current item, or NULL if the list is empty. void * item (); // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int append (void *item); // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int push (void *item); // Pop the item off the start of the list, if any void * pop (); // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. bool exists (void *item); // Remove the specified item from the list if present void remove (void *item); // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. QZlist * dup (); // Purge all items from list void purge (); // Return number of items in the list size_t size (); // Sort the list. If the compare function is null, sorts the list by // ascending key value using a straight ASCII comparison. If you specify // a compare function, this decides how items are sorted. The sort is not // stable, so may reorder items with the same keys. The algorithm used is // combsort, a compromise between performance and simplicity. void sort (zlist_compare_fn compare); // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. void autofree (); // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. void comparefn (zlist_compare_fn fn); // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * freefn (void *item, zlist_free_fn fn, bool atTail); // Self test of this class. static void test (bool verbose); zlist_t *self; }; #endif // Q_ZLIST_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzfile.cpp0000664000372000037200000001361513222211156020377 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZfile::QZfile (zfile_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. QZfile::QZfile (const QString &path, const QString &name, QObject *qObjParent) : QObject (qObjParent) { this->self = zfile_new (path.toUtf8().data(), name.toUtf8().data()); } /// // Create new temporary file for writing via tmpfile. File is automaticaly // deleted on destroy QZfile* QZfile::tmp (QObject *qObjParent) { return new QZfile (zfile_tmp (), qObjParent); } /// // Destroy a file item QZfile::~QZfile () { zfile_destroy (&self); } /// // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. QZfile * QZfile::dup () { QZfile *rv = new QZfile (zfile_dup (self)); return rv; } /// // Return file name, remove path if provided const QString QZfile::filename (const QString &path) { const QString rv = QString (zfile_filename (self, path.toUtf8().data())); return rv; } /// // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. void QZfile::restat () { zfile_restat (self); } /// // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. time_t QZfile::modified () { time_t rv = zfile_modified (self); return rv; } /// // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. off_t QZfile::cursize () { off_t rv = zfile_cursize (self); return rv; } /// // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool QZfile::isDirectory () { bool rv = zfile_is_directory (self); return rv; } /// // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool QZfile::isRegular () { bool rv = zfile_is_regular (self); return rv; } /// // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. bool QZfile::isReadable () { bool rv = zfile_is_readable (self); return rv; } /// // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. bool QZfile::isWriteable () { bool rv = zfile_is_writeable (self); return rv; } /// // Check if file has stopped changing and can be safely processed. // Updates the file statistics from disk at every call. bool QZfile::isStable () { bool rv = zfile_is_stable (self); return rv; } /// // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. bool QZfile::hasChanged () { bool rv = zfile_has_changed (self); return rv; } /// // Remove the file from disk void QZfile::remove () { zfile_remove (self); } /// // Open file for reading // Returns 0 if OK, -1 if not found or not accessible int QZfile::input () { int rv = zfile_input (self); return rv; } /// // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. int QZfile::output () { int rv = zfile_output (self); return rv; } /// // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. QZchunk * QZfile::read (size_t bytes, off_t offset) { QZchunk *rv = new QZchunk (zfile_read (self, bytes, offset)); return rv; } /// // Returns true if zfile_read() just read the last chunk in the file. bool QZfile::eof () { bool rv = zfile_eof (self); return rv; } /// // Write chunk to file at specified position // Return 0 if OK, else -1 int QZfile::write (QZchunk *chunk, off_t offset) { int rv = zfile_write (self, chunk->self, offset); return rv; } /// // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. const QString QZfile::readln () { const QString rv = QString (zfile_readln (self)); return rv; } /// // Close file, if open void QZfile::close () { zfile_close (self); } /// // Return file handle, if opened FILE * QZfile::handle () { FILE * rv = zfile_handle (self); return rv; } /// // Calculate SHA1 digest for file, using zdigest class. const QString QZfile::digest () { const QString rv = QString (zfile_digest (self)); return rv; } /// // Self test of this class. void QZfile::test (bool verbose) { zfile_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzsock.h0000664000372000037200000006751513222211156020074 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZSOCK_H #define Q_ZSOCK_H #include "qczmq.h" class QT_CZMQ_EXPORT QZsock : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZsock (zsock_t *self, QObject *qObjParent = 0); // Create a new socket. Returns the new socket, or NULL if the new socket // could not be created. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection. This can have // performance implications if you use a LOT of sockets. To turn off this // redirection behaviour, define ZSOCK_NOCHECK. explicit QZsock (int type, QObject *qObjParent = 0); // Create a PUB socket. Default action is bind. static QZsock* newPub (const QString &endpoint, QObject *qObjParent = 0); // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. static QZsock* newSub (const QString &endpoint, const QString &subscribe, QObject *qObjParent = 0); // Create a REQ socket. Default action is connect. static QZsock* newReq (const QString &endpoint, QObject *qObjParent = 0); // Create a REP socket. Default action is bind. static QZsock* newRep (const QString &endpoint, QObject *qObjParent = 0); // Create a DEALER socket. Default action is connect. static QZsock* newDealer (const QString &endpoint, QObject *qObjParent = 0); // Create a ROUTER socket. Default action is bind. static QZsock* newRouter (const QString &endpoint, QObject *qObjParent = 0); // Create a PUSH socket. Default action is connect. static QZsock* newPush (const QString &endpoint, QObject *qObjParent = 0); // Create a PULL socket. Default action is bind. static QZsock* newPull (const QString &endpoint, QObject *qObjParent = 0); // Create an XPUB socket. Default action is bind. static QZsock* newXpub (const QString &endpoint, QObject *qObjParent = 0); // Create an XSUB socket. Default action is connect. static QZsock* newXsub (const QString &endpoint, QObject *qObjParent = 0); // Create a PAIR socket. Default action is connect. static QZsock* newPair (const QString &endpoint, QObject *qObjParent = 0); // Create a STREAM socket. Default action is connect. static QZsock* newStream (const QString &endpoint, QObject *qObjParent = 0); // Create a SERVER socket. Default action is bind. static QZsock* newServer (const QString &endpoint, QObject *qObjParent = 0); // Create a CLIENT socket. Default action is connect. static QZsock* newClient (const QString &endpoint, QObject *qObjParent = 0); // Create a RADIO socket. Default action is bind. static QZsock* newRadio (const QString &endpoint, QObject *qObjParent = 0); // Create a DISH socket. Default action is connect. static QZsock* newDish (const QString &endpoint, QObject *qObjParent = 0); // Create a GATHER socket. Default action is bind. static QZsock* newGather (const QString &endpoint, QObject *qObjParent = 0); // Create a SCATTER socket. Default action is connect. static QZsock* newScatter (const QString &endpoint, QObject *qObjParent = 0); // Destroy the socket. You must use this for any socket created via the // zsock_new method. ~QZsock (); // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. int bind (const QString ¶m); // Returns last bound endpoint, if any. const QString endpoint (); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int unbind (const QString ¶m); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. int connect (const QString ¶m); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int disconnect (const QString ¶m); // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). int attach (const QString &endpoints, bool serverish); // Returns socket type as printable constant string. const QString typeStr (); // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. int send (const QString &picture, ...); // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. int vsend (const QString &picture, va_list argptr); // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // U = zuuid_t * (creates a zuuid with the data) // h = zhashx_t ** (creates zhashx) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. int recv (const QString &picture, ...); // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. int vrecv (const QString &picture, va_list argptr); // Return socket routing ID if any. This returns 0 if the socket is not // of type ZMQ_SERVER or if no request was already received on it. quint32 routingId (); // Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. // This will be used when sending messages on the socket via the zsock API. void setRoutingId (quint32 routingId); // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. void setUnbounded (); // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zsock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. int signal (byte status); // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. int wait (); // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. void flush (); // Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int join (const QString &group); // Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int leave (const QString &group); // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. static bool is (void *self); // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. static void * resolve (void *self); // Get socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. int heartbeatIvl (); // Set socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. void setHeartbeatIvl (int heartbeatIvl); // Get socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. int heartbeatTtl (); // Set socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. void setHeartbeatTtl (int heartbeatTtl); // Get socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. int heartbeatTimeout (); // Set socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. void setHeartbeatTimeout (int heartbeatTimeout); // Get socket option `use_fd`. // Available from libzmq 4.2.0. int useFd (); // Set socket option `use_fd`. // Available from libzmq 4.2.0. void setUseFd (int useFd); // Set socket option `xpub_manual`. // Available from libzmq 4.2.0. void setXpubManual (int xpubManual); // Set socket option `xpub_welcome_msg`. // Available from libzmq 4.2.0. void setXpubWelcomeMsg (const QString &xpubWelcomeMsg); // Set socket option `stream_notify`. // Available from libzmq 4.2.0. void setStreamNotify (int streamNotify); // Get socket option `invert_matching`. // Available from libzmq 4.2.0. int invertMatching (); // Set socket option `invert_matching`. // Available from libzmq 4.2.0. void setInvertMatching (int invertMatching); // Set socket option `xpub_verboser`. // Available from libzmq 4.2.0. void setXpubVerboser (int xpubVerboser); // Get socket option `connect_timeout`. // Available from libzmq 4.2.0. int connectTimeout (); // Set socket option `connect_timeout`. // Available from libzmq 4.2.0. void setConnectTimeout (int connectTimeout); // Get socket option `tcp_maxrt`. // Available from libzmq 4.2.0. int tcpMaxrt (); // Set socket option `tcp_maxrt`. // Available from libzmq 4.2.0. void setTcpMaxrt (int tcpMaxrt); // Get socket option `thread_safe`. // Available from libzmq 4.2.0. int threadSafe (); // Get socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. int multicastMaxtpdu (); // Set socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. void setMulticastMaxtpdu (int multicastMaxtpdu); // Get socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. int vmciBufferSize (); // Set socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. void setVmciBufferSize (int vmciBufferSize); // Get socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. int vmciBufferMinSize (); // Set socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. void setVmciBufferMinSize (int vmciBufferMinSize); // Get socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. int vmciBufferMaxSize (); // Set socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. void setVmciBufferMaxSize (int vmciBufferMaxSize); // Get socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. int vmciConnectTimeout (); // Set socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. void setVmciConnectTimeout (int vmciConnectTimeout); // Get socket option `tos`. // Available from libzmq 4.1.0. int tos (); // Set socket option `tos`. // Available from libzmq 4.1.0. void setTos (int tos); // Set socket option `router_handover`. // Available from libzmq 4.1.0. void setRouterHandover (int routerHandover); // Set socket option `connect_rid`. // Available from libzmq 4.1.0. void setConnectRid (const QString &connectRid); // Set socket option `connect_rid` from 32-octet binary // Available from libzmq 4.1.0. void setConnectRidBin (const byte *connectRid); // Get socket option `handshake_ivl`. // Available from libzmq 4.1.0. int handshakeIvl (); // Set socket option `handshake_ivl`. // Available from libzmq 4.1.0. void setHandshakeIvl (int handshakeIvl); // Get socket option `socks_proxy`. // Available from libzmq 4.1.0. QString socksProxy (); // Set socket option `socks_proxy`. // Available from libzmq 4.1.0. void setSocksProxy (const QString &socksProxy); // Set socket option `xpub_nodrop`. // Available from libzmq 4.1.0. void setXpubNodrop (int xpubNodrop); // Set socket option `router_mandatory`. // Available from libzmq 4.0.0. void setRouterMandatory (int routerMandatory); // Set socket option `probe_router`. // Available from libzmq 4.0.0. void setProbeRouter (int probeRouter); // Set socket option `req_relaxed`. // Available from libzmq 4.0.0. void setReqRelaxed (int reqRelaxed); // Set socket option `req_correlate`. // Available from libzmq 4.0.0. void setReqCorrelate (int reqCorrelate); // Set socket option `conflate`. // Available from libzmq 4.0.0. void setConflate (int conflate); // Get socket option `zap_domain`. // Available from libzmq 4.0.0. QString zapDomain (); // Set socket option `zap_domain`. // Available from libzmq 4.0.0. void setZapDomain (const QString &zapDomain); // Get socket option `mechanism`. // Available from libzmq 4.0.0. int mechanism (); // Get socket option `plain_server`. // Available from libzmq 4.0.0. int plainServer (); // Set socket option `plain_server`. // Available from libzmq 4.0.0. void setPlainServer (int plainServer); // Get socket option `plain_username`. // Available from libzmq 4.0.0. QString plainUsername (); // Set socket option `plain_username`. // Available from libzmq 4.0.0. void setPlainUsername (const QString &plainUsername); // Get socket option `plain_password`. // Available from libzmq 4.0.0. QString plainPassword (); // Set socket option `plain_password`. // Available from libzmq 4.0.0. void setPlainPassword (const QString &plainPassword); // Get socket option `curve_server`. // Available from libzmq 4.0.0. int curveServer (); // Set socket option `curve_server`. // Available from libzmq 4.0.0. void setCurveServer (int curveServer); // Get socket option `curve_publickey`. // Available from libzmq 4.0.0. QString curvePublickey (); // Set socket option `curve_publickey`. // Available from libzmq 4.0.0. void setCurvePublickey (const QString &curvePublickey); // Set socket option `curve_publickey` from 32-octet binary // Available from libzmq 4.0.0. void setCurvePublickeyBin (const byte *curvePublickey); // Get socket option `curve_secretkey`. // Available from libzmq 4.0.0. QString curveSecretkey (); // Set socket option `curve_secretkey`. // Available from libzmq 4.0.0. void setCurveSecretkey (const QString &curveSecretkey); // Set socket option `curve_secretkey` from 32-octet binary // Available from libzmq 4.0.0. void setCurveSecretkeyBin (const byte *curveSecretkey); // Get socket option `curve_serverkey`. // Available from libzmq 4.0.0. QString curveServerkey (); // Set socket option `curve_serverkey`. // Available from libzmq 4.0.0. void setCurveServerkey (const QString &curveServerkey); // Set socket option `curve_serverkey` from 32-octet binary // Available from libzmq 4.0.0. void setCurveServerkeyBin (const byte *curveServerkey); // Get socket option `gssapi_server`. // Available from libzmq 4.0.0. int gssapiServer (); // Set socket option `gssapi_server`. // Available from libzmq 4.0.0. void setGssapiServer (int gssapiServer); // Get socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. int gssapiPlaintext (); // Set socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. void setGssapiPlaintext (int gssapiPlaintext); // Get socket option `gssapi_principal`. // Available from libzmq 4.0.0. QString gssapiPrincipal (); // Set socket option `gssapi_principal`. // Available from libzmq 4.0.0. void setGssapiPrincipal (const QString &gssapiPrincipal); // Get socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. QString gssapiServicePrincipal (); // Set socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. void setGssapiServicePrincipal (const QString &gssapiServicePrincipal); // Get socket option `ipv6`. // Available from libzmq 4.0.0. int ipv6 (); // Set socket option `ipv6`. // Available from libzmq 4.0.0. void setIpv6 (int ipv6); // Get socket option `immediate`. // Available from libzmq 4.0.0. int immediate (); // Set socket option `immediate`. // Available from libzmq 4.0.0. void setImmediate (int immediate); // Get socket option `sndhwm`. // Available from libzmq 3.0.0. int sndhwm (); // Set socket option `sndhwm`. // Available from libzmq 3.0.0. void setSndhwm (int sndhwm); // Get socket option `rcvhwm`. // Available from libzmq 3.0.0. int rcvhwm (); // Set socket option `rcvhwm`. // Available from libzmq 3.0.0. void setRcvhwm (int rcvhwm); // Get socket option `maxmsgsize`. // Available from libzmq 3.0.0. int maxmsgsize (); // Set socket option `maxmsgsize`. // Available from libzmq 3.0.0. void setMaxmsgsize (int maxmsgsize); // Get socket option `multicast_hops`. // Available from libzmq 3.0.0. int multicastHops (); // Set socket option `multicast_hops`. // Available from libzmq 3.0.0. void setMulticastHops (int multicastHops); // Set socket option `xpub_verbose`. // Available from libzmq 3.0.0. void setXpubVerbose (int xpubVerbose); // Get socket option `tcp_keepalive`. // Available from libzmq 3.0.0. int tcpKeepalive (); // Set socket option `tcp_keepalive`. // Available from libzmq 3.0.0. void setTcpKeepalive (int tcpKeepalive); // Get socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. int tcpKeepaliveIdle (); // Set socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. void setTcpKeepaliveIdle (int tcpKeepaliveIdle); // Get socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. int tcpKeepaliveCnt (); // Set socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. void setTcpKeepaliveCnt (int tcpKeepaliveCnt); // Get socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. int tcpKeepaliveIntvl (); // Set socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. void setTcpKeepaliveIntvl (int tcpKeepaliveIntvl); // Get socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. QString tcpAcceptFilter (); // Set socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. void setTcpAcceptFilter (const QString &tcpAcceptFilter); // Get socket option `last_endpoint`. // Available from libzmq 3.0.0. QString lastEndpoint (); // Set socket option `router_raw`. // Available from libzmq 3.0.0. void setRouterRaw (int routerRaw); // Get socket option `ipv4only`. // Available from libzmq 3.0.0. int ipv4only (); // Set socket option `ipv4only`. // Available from libzmq 3.0.0. void setIpv4only (int ipv4only); // Set socket option `delay_attach_on_connect`. // Available from libzmq 3.0.0. void setDelayAttachOnConnect (int delayAttachOnConnect); // Get socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. int hwm (); // Set socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. void setHwm (int hwm); // Get socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. int swap (); // Set socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. void setSwap (int swap); // Get socket option `affinity`. // Available from libzmq 2.0.0. int affinity (); // Set socket option `affinity`. // Available from libzmq 2.0.0. void setAffinity (int affinity); // Get socket option `identity`. // Available from libzmq 2.0.0. QString identity (); // Set socket option `identity`. // Available from libzmq 2.0.0. void setIdentity (const QString &identity); // Get socket option `rate`. // Available from libzmq 2.0.0. int rate (); // Set socket option `rate`. // Available from libzmq 2.0.0. void setRate (int rate); // Get socket option `recovery_ivl`. // Available from libzmq 2.0.0. int recoveryIvl (); // Set socket option `recovery_ivl`. // Available from libzmq 2.0.0. void setRecoveryIvl (int recoveryIvl); // Get socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. int recoveryIvlMsec (); // Set socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. void setRecoveryIvlMsec (int recoveryIvlMsec); // Get socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. int mcastLoop (); // Set socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. void setMcastLoop (int mcastLoop); // Get socket option `rcvtimeo`. // Available from libzmq 2.2.0. int rcvtimeo (); // Set socket option `rcvtimeo`. // Available from libzmq 2.2.0. void setRcvtimeo (int rcvtimeo); // Get socket option `sndtimeo`. // Available from libzmq 2.2.0. int sndtimeo (); // Set socket option `sndtimeo`. // Available from libzmq 2.2.0. void setSndtimeo (int sndtimeo); // Get socket option `sndbuf`. // Available from libzmq 2.0.0. int sndbuf (); // Set socket option `sndbuf`. // Available from libzmq 2.0.0. void setSndbuf (int sndbuf); // Get socket option `rcvbuf`. // Available from libzmq 2.0.0. int rcvbuf (); // Set socket option `rcvbuf`. // Available from libzmq 2.0.0. void setRcvbuf (int rcvbuf); // Get socket option `linger`. // Available from libzmq 2.0.0. int linger (); // Set socket option `linger`. // Available from libzmq 2.0.0. void setLinger (int linger); // Get socket option `reconnect_ivl`. // Available from libzmq 2.0.0. int reconnectIvl (); // Set socket option `reconnect_ivl`. // Available from libzmq 2.0.0. void setReconnectIvl (int reconnectIvl); // Get socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. int reconnectIvlMax (); // Set socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. void setReconnectIvlMax (int reconnectIvlMax); // Get socket option `backlog`. // Available from libzmq 2.0.0. int backlog (); // Set socket option `backlog`. // Available from libzmq 2.0.0. void setBacklog (int backlog); // Set socket option `subscribe`. // Available from libzmq 2.0.0. void setSubscribe (const QString &subscribe); // Set socket option `unsubscribe`. // Available from libzmq 2.0.0. void setUnsubscribe (const QString &unsubscribe); // Get socket option `type`. // Available from libzmq 2.0.0. int type (); // Get socket option `rcvmore`. // Available from libzmq 2.0.0. int rcvmore (); // Get socket option `fd`. // Available from libzmq 2.0.0. SOCKET fd (); // Get socket option `events`. // Available from libzmq 2.0.0. int events (); // Self test of this class. static void test (bool verbose); zsock_t *self; }; #endif // Q_ZSOCK_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzcert.h0000664000372000037200000000664013222211156020062 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZCERT_H #define Q_ZCERT_H #include "qczmq.h" class QT_CZMQ_EXPORT QZcert : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZcert (zcert_t *self, QObject *qObjParent = 0); // Create and initialize a new certificate in memory explicit QZcert (QObject *qObjParent = 0); // Accepts public/secret key pair from caller static QZcert* newFrom (const byte *publicKey, const byte *secretKey, QObject *qObjParent = 0); // Accepts public/secret key text pair from caller static QZcert* newFromTxt (const QString &publicTxt, const QString &secretTxt, QObject *qObjParent = 0); // Load certificate from file static QZcert* load (const QString &filename, QObject *qObjParent = 0); // Destroy a certificate in memory ~QZcert (); // Return public part of key pair as 32-byte binary string const byte * publicKey (); // Return secret part of key pair as 32-byte binary string const byte * secretKey (); // Return public part of key pair as Z85 armored string const QString publicTxt (); // Return secret part of key pair as Z85 armored string const QString secretTxt (); // Set certificate metadata from formatted string. void setMeta (const QString &name, const QString ¶m); // Unset certificate metadata. void unsetMeta (const QString &name); // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. const QString meta (const QString &name); // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. QZlist * metaKeys (); // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). int save (const QString &filename); // Save public certificate only to file for persistent storage int savePublic (const QString &filename); // Save secret certificate only to file for persistent storage int saveSecret (const QString &filename); // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. void apply (void *socket); // Return copy of certificate; if certificate is NULL or we exhausted // heap memory, returns NULL. QZcert * dup (); // Return true if two certificates have the same keys bool eq (QZcert *compare); // Print certificate contents to stdout void print (); // Self test of this class static void test (bool verbose); zcert_t *self; }; #endif // Q_ZCERT_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzdirpatch.h0000664000372000037200000000331613222211156020720 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZDIR_PATCH_H #define Q_ZDIR_PATCH_H #include "qczmq.h" class QT_CZMQ_EXPORT QZdirPatch : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZdirPatch (zdir_patch_t *self, QObject *qObjParent = 0); // Create new patch explicit QZdirPatch (const QString &path, QZfile *file, int op, const QString &alias, QObject *qObjParent = 0); // Destroy a patch ~QZdirPatch (); // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. QZdirPatch * dup (); // Return patch file directory path const QString path (); // Return patch file item QZfile * file (); // Return operation int op (); // Return patch virtual file path const QString vpath (); // Calculate hash digest for file (create only) void digestSet (); // Return hash digest for patch file const QString digest (); // Self test of this class. static void test (bool verbose); zdir_patch_t *self; }; #endif // Q_ZDIR_PATCH_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzargs.cpp0000664000372000037200000000574213222211156020416 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZargs::QZargs (zargs_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Destroy zargs instance. QZargs::~QZargs () { zargs_destroy (&self); } /// // Return program name (argv[0]) const QString QZargs::progname () { const QString rv = QString (zargs_progname (self)); return rv; } /// // Return number of positional arguments size_t QZargs::arguments () { size_t rv = zargs_arguments (self); return rv; } /// // Return first positional argument or NULL const QString QZargs::first () { const QString rv = QString (zargs_first (self)); return rv; } /// // Return next positional argument or NULL const QString QZargs::next () { const QString rv = QString (zargs_next (self)); return rv; } /// // Return first named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const QString QZargs::paramFirst () { const QString rv = QString (zargs_param_first (self)); return rv; } /// // Return next named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const QString QZargs::paramNext () { const QString rv = QString (zargs_param_next (self)); return rv; } /// // Return current parameter name, or NULL if there are no named // parameters. const QString QZargs::paramName () { const QString rv = QString (zargs_param_name (self)); return rv; } /// // Return value of named parameter, NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const QString QZargs::paramLookup (const QString &keys) { const QString rv = QString (zargs_param_lookup (self, keys.toUtf8().data())); return rv; } /// // Returns true if there are --help -h arguments bool QZargs::hasHelp () { bool rv = zargs_has_help (self); return rv; } /// // Returns true if parameter did not have a value bool QZargs::paramEmpty (const QString &arg) { bool rv = zargs_param_empty (arg.toUtf8().data()); return rv; } /// // Print an instance of zargs. void QZargs::print () { zargs_print (self); } /// // Self test of this class. void QZargs::test (bool verbose) { zargs_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzchunk.h0000664000372000037200000001107313222211156020231 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZCHUNK_H #define Q_ZCHUNK_H #include "qczmq.h" class QT_CZMQ_EXPORT QZchunk : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZchunk (zchunk_t *self, QObject *qObjParent = 0); // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. explicit QZchunk (const void *data, size_t size, QObject *qObjParent = 0); // Destroy a chunk ~QZchunk (); // Resizes chunk max_size as requested; chunk_cur size is set to zero void resize (size_t size); // Return chunk cur size size_t size (); // Return chunk max size size_t maxSize (); // Return chunk data byte * data (); // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk size_t set (const void *data, size_t size); // Fill chunk data from user-supplied octet size_t fill (byte filler, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, it is truncated. If you want to // grow the chunk to accommodate new data, use the zchunk_extend method. size_t append (const void *data, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, the chunk grows in size. size_t extend (const void *data, size_t size); // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. size_t consume (QZchunk *source); // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. bool exhausted (); // Read chunk from an open file descriptor static QZchunk * read (FILE *handle, size_t bytes); // Write chunk to an open file descriptor int write (FILE *handle); // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. static QZchunk * slurp (const QString &filename, size_t maxsize); // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // returns null. QZchunk * dup (); // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. QString strhex (); // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. QString strdup (); // Return TRUE if chunk body is equal to string, excluding terminator bool streqNoConflict (const QString &string); // Transform zchunk into a zframe that can be sent in a message. QZframe * pack (); // Transform a zframe into a zchunk. static QZchunk * unpack (QZframe *frame); // Calculate SHA1 digest for chunk, using zdigest class. const QString digest (); // Dump chunk to FILE stream, for debugging and tracing. void fprint (FILE *file); // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details void print (); // Probe the supplied object, and report if it looks like a zchunk_t. static bool is (void *self); // Self test of this class. static void test (bool verbose); zchunk_t *self; }; #endif // Q_ZCHUNK_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qztrie.cpp0000664000372000037200000000611013222211156020413 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZtrie::QZtrie (ztrie_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Creates a new ztrie. QZtrie::QZtrie (char delimiter, QObject *qObjParent) : QObject (qObjParent) { this->self = ztrie_new (delimiter); } /// // Destroy the ztrie. QZtrie::~QZtrie () { ztrie_destroy (&self); } /// // Inserts a new route into the tree and attaches the data. Returns -1 // if the route already exists, otherwise 0. This method takes ownership of // the provided data if a destroy_data_fn is provided. int QZtrie::insertRoute (const QString &path, void *data, ztrie_destroy_data_fn destroyDataFn) { int rv = ztrie_insert_route (self, path.toUtf8().data(), data, destroyDataFn); return rv; } /// // Removes a route from the trie and destroys its data. Returns -1 if the // route does not exists, otherwise 0. // the start of the list call zlist_first (). Advances the cursor. int QZtrie::removeRoute (const QString &path) { int rv = ztrie_remove_route (self, path.toUtf8().data()); return rv; } /// // Returns true if the path matches a route in the tree, otherwise false. bool QZtrie::matches (const QString &path) { bool rv = ztrie_matches (self, path.toUtf8().data()); return rv; } /// // Returns the data of a matched route from last ztrie_matches. If the path // did not match, returns NULL. Do not delete the data as it's owned by // ztrie. void * QZtrie::hitData () { void * rv = ztrie_hit_data (self); return rv; } /// // Returns the count of parameters that a matched route has. size_t QZtrie::hitParameterCount () { size_t rv = ztrie_hit_parameter_count (self); return rv; } /// // Returns the parameters of a matched route with named regexes from last // ztrie_matches. If the path did not match or the route did not contain any // named regexes, returns NULL. QZhashx * QZtrie::hitParameters () { QZhashx *rv = new QZhashx (ztrie_hit_parameters (self)); return rv; } /// // Returns the asterisk matched part of a route, if there has been no match // or no asterisk match, returns NULL. const QString QZtrie::hitAsteriskMatch () { const QString rv = QString (ztrie_hit_asterisk_match (self)); return rv; } /// // Print the trie void QZtrie::print () { ztrie_print (self); } /// // Self test of this class. void QZtrie::test (bool verbose) { ztrie_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzuuid.cpp0000664000372000037200000000573013222211156020425 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZuuid::QZuuid (zuuid_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new UUID object. QZuuid::QZuuid (QObject *qObjParent) : QObject (qObjParent) { this->self = zuuid_new (); } /// // Create UUID object from supplied ZUUID_LEN-octet value. QZuuid* QZuuid::newFrom (const byte *source, QObject *qObjParent) { return new QZuuid (zuuid_new_from (source), qObjParent); } /// // Destroy a specified UUID object. QZuuid::~QZuuid () { zuuid_destroy (&self); } /// // Set UUID to new supplied ZUUID_LEN-octet value. void QZuuid::set (const byte *source) { zuuid_set (self, source); } /// // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. int QZuuid::setStr (const QString &source) { int rv = zuuid_set_str (self, source.toUtf8().data()); return rv; } /// // Return UUID binary data. const byte * QZuuid::data () { const byte * rv = zuuid_data (self); return rv; } /// // Return UUID binary size size_t QZuuid::size () { size_t rv = zuuid_size (self); return rv; } /// // Returns UUID as string const QString QZuuid::str () { const QString rv = QString (zuuid_str (self)); return rv; } /// // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier const QString QZuuid::strCanonical () { const QString rv = QString (zuuid_str_canonical (self)); return rv; } /// // Store UUID blob in target array void QZuuid::exportNoConflict (byte *target) { zuuid_export (self, target); } /// // Check if UUID is same as supplied value bool QZuuid::eq (const byte *compare) { bool rv = zuuid_eq (self, compare); return rv; } /// // Check if UUID is different from supplied value bool QZuuid::neq (const byte *compare) { bool rv = zuuid_neq (self, compare); return rv; } /// // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. QZuuid * QZuuid::dup () { QZuuid *rv = new QZuuid (zuuid_dup (self)); return rv; } /// // Self test of this class. void QZuuid::test (bool verbose) { zuuid_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzdir.cpp0000664000372000037200000001073013222211156020231 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZdir::QZdir (zdir_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. QZdir::QZdir (const QString &path, const QString &parent, QObject *qObjParent) : QObject (qObjParent) { this->self = zdir_new (path.toUtf8().data(), parent.toUtf8().data()); } /// // Destroy a directory tree and all children it contains. QZdir::~QZdir () { zdir_destroy (&self); } /// // Return directory path const QString QZdir::path () { const QString rv = QString (zdir_path (self)); return rv; } /// // Return last modification time for directory. time_t QZdir::modified () { time_t rv = zdir_modified (self); return rv; } /// // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. off_t QZdir::cursize () { off_t rv = zdir_cursize (self); return rv; } /// // Return directory count size_t QZdir::count () { size_t rv = zdir_count (self); return rv; } /// // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. QZlist * QZdir::list () { QZlist *rv = new QZlist (zdir_list (self)); return rv; } /// // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. void QZdir::remove (bool force) { zdir_remove (self, force); } /// // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). QZlist * QZdir::diff (QZdir *older, QZdir *newer, const QString &alias) { QZlist *rv = new QZlist (zdir_diff (older->self, newer->self, alias.toUtf8().data())); return rv; } /// // Return full contents of directory as a zdir_patch list. QZlist * QZdir::resync (const QString &alias) { QZlist *rv = new QZlist (zdir_resync (self, alias.toUtf8().data())); return rv; } /// // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. QZhash * QZdir::cache () { QZhash *rv = new QZhash (zdir_cache (self)); return rv; } /// // Print contents of directory to open stream void QZdir::fprint (FILE *file, int indent) { zdir_fprint (self, file, indent); } /// // Print contents of directory to stdout void QZdir::print (int indent) { zdir_print (self, indent); } /// // Create a new zdir_watch actor instance: // // zactor_t *watch = zactor_new (zdir_watch, NULL); // // Destroy zdir_watch instance: // // zactor_destroy (&watch); // // Enable verbose logging of commands and activity: // // zstr_send (watch, "VERBOSE"); // // Subscribe to changes to a directory path: // // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); // // Unsubscribe from changes to a directory path: // // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); // // Receive directory changes: // zsock_recv (watch, "sp", &path, &patches); // // // Delete the received data. // free (path); // zlist_destroy (&patches); void QZdir::watch (QZsock *pipe, void *unused) { zdir_watch (pipe->self, unused); } /// // Self test of this class. void QZdir::test (bool verbose) { zdir_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzuuid.h0000664000372000037200000000445613222211156020076 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZUUID_H #define Q_ZUUID_H #include "qczmq.h" class QT_CZMQ_EXPORT QZuuid : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZuuid (zuuid_t *self, QObject *qObjParent = 0); // Create a new UUID object. explicit QZuuid (QObject *qObjParent = 0); // Create UUID object from supplied ZUUID_LEN-octet value. static QZuuid* newFrom (const byte *source, QObject *qObjParent = 0); // Destroy a specified UUID object. ~QZuuid (); // Set UUID to new supplied ZUUID_LEN-octet value. void set (const byte *source); // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. int setStr (const QString &source); // Return UUID binary data. const byte * data (); // Return UUID binary size size_t size (); // Returns UUID as string const QString str (); // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier const QString strCanonical (); // Store UUID blob in target array void exportNoConflict (byte *target); // Check if UUID is same as supplied value bool eq (const byte *compare); // Check if UUID is different from supplied value bool neq (const byte *compare); // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. QZuuid * dup (); // Self test of this class. static void test (bool verbose); zuuid_t *self; }; #endif // Q_ZUUID_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzlistx.h0000664000372000037200000001527213222211156020271 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZLISTX_H #define Q_ZLISTX_H #include "qczmq.h" class QT_CZMQ_EXPORT QZlistx : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZlistx (zlistx_t *self, QObject *qObjParent = 0); // Create a new, empty list. explicit QZlistx (QObject *qObjParent = 0); // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. ~QZlistx (); // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void * addStart (void *item); // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void * addEnd (void *item); // Return the number of items in the list size_t size (); // Return first item in the list, or null, leaves the cursor void * head (); // Return last item in the list, or null, leaves the cursor void * tail (); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * first (); // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). void * next (); // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). void * prev (); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * last (); // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * item (); // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * cursor (); // Returns the item associated with the given list handle, or NULL if passed // in handle is NULL. Asserts that the passed in handle points to a list element. static void * handleItem (void *handle); // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. void * find (void *item); // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. void * detach (void *handle); // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. void * detachCur (); // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. int deleteNoConflict (void *handle); // Move an item to the start of the list, via its handle. void moveStart (void *handle); // Move an item to the end of the list, via its handle. void moveEnd (void *handle); // Remove all items from the list, and destroy them if the item destructor // is set. void purge (); // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. void sort (); // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. void * insert (void *item, bool lowValue); // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. void reorder (void *handle, bool lowValue); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. QZlistx * dup (); // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. void setDestructor (zlistx_destructor_fn destructor); // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. void setDuplicator (zlistx_duplicator_fn duplicator); // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. void setComparator (zlistx_comparator_fn comparator); // Self test of this class. static void test (bool verbose); zlistx_t *self; }; #endif // Q_ZLISTX_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzsys.cpp0000664000372000037200000004463713222211156020306 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZsys::QZsys (zsys_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. void * QZsys::init () { void * rv = zsys_init (); return rv; } /// // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls. void QZsys::shutdown () { zsys_shutdown (); } /// // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. // *** This is for CZMQ internal use only and may change arbitrarily *** void * QZsys::socket (int type, const QString &filename, size_t lineNbr) { void * rv = zsys_socket (type, filename.toUtf8().data(), lineNbr); return rv; } /// // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). // *** This is for CZMQ internal use only and may change arbitrarily *** int QZsys::close (void *handle, const QString &filename, size_t lineNbr) { int rv = zsys_close (handle, filename.toUtf8().data(), lineNbr); return rv; } /// // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** const QString QZsys::sockname (int socktype) { const QString rv = QString (zsys_sockname (socktype)); return rv; } /// // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. QZsock * QZsys::createPipe (QZsock *backendP) { QZsock *rv = new QZsock (zsys_create_pipe (&backendP->self)); return rv; } /// // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. void QZsys::handlerSet (zsys_handler_fn *handlerFn) { zsys_handler_set (handlerFn); } /// // Reset interrupt handler, call this at exit if needed void QZsys::handlerReset () { zsys_handler_reset (); } /// // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. // Can be supressed by ZSYS_SIGHANDLER=false // *** This is for CZMQ internal use only and may change arbitrarily *** void QZsys::catchInterrupts () { zsys_catch_interrupts (); } /// // Return 1 if file exists, else zero bool QZsys::fileExists (const QString &filename) { bool rv = zsys_file_exists (filename.toUtf8().data()); return rv; } /// // Return file modification time. Returns 0 if the file does not exist. time_t QZsys::fileModified (const QString &filename) { time_t rv = zsys_file_modified (filename.toUtf8().data()); return rv; } /// // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. int QZsys::fileMode (const QString &filename) { int rv = zsys_file_mode (filename.toUtf8().data()); return rv; } /// // Delete file. Does not complain if the file is absent int QZsys::fileDelete (const QString &filename) { int rv = zsys_file_delete (filename.toUtf8().data()); return rv; } /// // Check if file is 'stable' bool QZsys::fileStable (const QString &filename) { bool rv = zsys_file_stable (filename.toUtf8().data()); return rv; } /// // Move to a specified working directory. Returns 0 if OK, -1 if this failed. int QZsys::dirChange (const QString &pathname) { int rv = zsys_dir_change (pathname.toUtf8().data()); return rv; } /// // Set private file creation mode; all files created from here will be // readable/writable by the owner only. void QZsys::fileModePrivate () { zsys_file_mode_private (); } /// // Reset default file creation mode; all files created from here will use // process file mode defaults. void QZsys::fileModeDefault () { zsys_file_mode_default (); } /// // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. void QZsys::version (int *major, int *minor, int *patch) { zsys_version (major, minor, patch); } /// // Format a string with a va_list argument, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). const QString QZsys::vprintf (const QString &format, va_list argptr) { const QString rv = QString (zsys_vprintf (format.toUtf8().data(), argptr)); return rv; } /// // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. // *** This is for CZMQ internal use only and may change arbitrarily *** SOCKET QZsys::udpNew (bool routable) { SOCKET rv = zsys_udp_new (routable); return rv; } /// // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** int QZsys::udpClose (SOCKET handle) { int rv = zsys_udp_close (handle); return rv; } /// // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** int QZsys::udpSend (SOCKET udpsock, QZframe *frame, inaddr_t *address, int addrlen) { int rv = zsys_udp_send (udpsock, frame->self, address, addrlen); return rv; } /// // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or // NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. // *** This is for CZMQ internal use only and may change arbitrarily *** QZframe * QZsys::udpRecv (SOCKET udpsock, const QString &peername, int peerlen) { QZframe *rv = new QZframe (zsys_udp_recv (udpsock, peername.toUtf8().data(), peerlen)); return rv; } /// // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. // *** This is for CZMQ internal use only and may change arbitrarily *** void QZsys::socketError (const QString &reason) { zsys_socket_error (reason.toUtf8().data()); } /// // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. const QString QZsys::hostname () { const QString rv = QString (zsys_hostname ()); return rv; } /// // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. int QZsys::daemonize (const QString &workdir) { int rv = zsys_daemonize (workdir.toUtf8().data()); return rv; } /// // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. int QZsys::runAs (const QString &lockfile, const QString &group, const QString &user) { int rv = zsys_run_as (lockfile.toUtf8().data(), group.toUtf8().data(), user.toUtf8().data()); return rv; } /// // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. bool QZsys::hasCurve () { bool rv = zsys_has_curve (); return rv; } /// // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void QZsys::setIoThreads (size_t ioThreads) { zsys_set_io_threads (ioThreads); } /// // Configure the scheduling policy of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY // is defined, that provides the default. // Note that this method is valid only before any socket is created. void QZsys::setThreadSchedPolicy (int policy) { zsys_set_thread_sched_policy (policy); } /// // Configure the scheduling priority of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_PRIORITY is // defined, that provides the default. // Note that this method is valid only before any socket is created. void QZsys::setThreadPriority (int priority) { zsys_set_thread_priority (priority); } /// // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void QZsys::setMaxSockets (size_t maxSockets) { zsys_set_max_sockets (maxSockets); } /// // Return maximum number of ZeroMQ sockets that the system will support. size_t QZsys::socketLimit () { size_t rv = zsys_socket_limit (); return rv; } /// // Configure the maximum allowed size of a message sent. // The default is INT_MAX. void QZsys::setMaxMsgsz (int maxMsgsz) { zsys_set_max_msgsz (maxMsgsz); } /// // Return maximum message size. int QZsys::maxMsgsz () { int rv = zsys_max_msgsz (); return rv; } /// // Configure the threshold value of filesystem object age per st_mtime // that should elapse until we consider that object "stable" at the // current zclock_time() moment. // The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c // which generally depends on host OS, with fallback value of 5000. void QZsys::setFileStableAgeMsec (int64_t fileStableAgeMsec) { zsys_set_file_stable_age_msec (fileStableAgeMsec); } /// // Return current threshold value of file stable age in msec. // This can be used in code that chooses to wait for this timeout // before testing if a filesystem object is "stable" or not. int64_t QZsys::fileStableAgeMsec () { int64_t rv = zsys_file_stable_age_msec (); return rv; } /// // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. void QZsys::setLinger (size_t linger) { zsys_set_linger (linger); } /// // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void QZsys::setSndhwm (size_t sndhwm) { zsys_set_sndhwm (sndhwm); } /// // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void QZsys::setRcvhwm (size_t rcvhwm) { zsys_set_rcvhwm (rcvhwm); } /// // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. void QZsys::setPipehwm (size_t pipehwm) { zsys_set_pipehwm (pipehwm); } /// // Return the HWM for zactor internal pipes. size_t QZsys::pipehwm () { size_t rv = zsys_pipehwm (); return rv; } /// // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. void QZsys::setIpv6 (int ipv6) { zsys_set_ipv6 (ipv6); } /// // Return use of IPv6 for zsock instances. int QZsys::ipv6 () { int rv = zsys_ipv6 (); return rv; } /// // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void QZsys::setInterface (const QString &value) { zsys_set_interface (value.toUtf8().data()); } /// // Return network interface to use for broadcasts, or "" if none was set. const QString QZsys::interface () { const QString rv = QString (zsys_interface ()); return rv; } /// // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses // on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, // use that as the default IPv6 address. void QZsys::setIpv6Address (const QString &value) { zsys_set_ipv6_address (value.toUtf8().data()); } /// // Return IPv6 address to use for zbeacon reception, or "" if none was set. const QString QZsys::ipv6Address () { const QString rv = QString (zsys_ipv6_address ()); return rv; } /// // Set IPv6 milticast address to use for sending zbeacon messages. This needs // to be set if IPv6 is enabled. If the environment variable // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast // address. void QZsys::setIpv6McastAddress (const QString &value) { zsys_set_ipv6_mcast_address (value.toUtf8().data()); } /// // Return IPv6 multicast address to use for sending zbeacon, or "" if none was // set. const QString QZsys::ipv6McastAddress () { const QString rv = QString (zsys_ipv6_mcast_address ()); return rv; } /// // Configure the automatic use of pre-allocated FDs when creating new sockets. // If 0 (default), nothing will happen. Else, when a new socket is bound, the // system API will be used to check if an existing pre-allocated FD with a // matching port (if TCP) or path (if IPC) exists, and if it does it will be // set via the ZMQ_USE_FD socket option so that the library will use it // instead of creating a new socket. void QZsys::setAutoUseFd (int autoUseFd) { zsys_set_auto_use_fd (autoUseFd); } /// // Return use of automatic pre-allocated FDs for zsock instances. int QZsys::autoUseFd () { int rv = zsys_auto_use_fd (); return rv; } /// // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void QZsys::setLogident (const QString &value) { zsys_set_logident (value.toUtf8().data()); } /// // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). void QZsys::setLogstream (FILE *stream) { zsys_set_logstream (stream); } /// // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void QZsys::setLogsender (const QString &endpoint) { zsys_set_logsender (endpoint.toUtf8().data()); } /// // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void QZsys::setLogsystem (bool logsystem) { zsys_set_logsystem (logsystem); } /// // Self test of this class. void QZsys::test (bool verbose) { zsys_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzlistx.cpp0000664000372000037200000002001513222211156020613 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZlistx::QZlistx (zlistx_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new, empty list. QZlistx::QZlistx (QObject *qObjParent) : QObject (qObjParent) { this->self = zlistx_new (); } /// // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. QZlistx::~QZlistx () { zlistx_destroy (&self); } /// // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void * QZlistx::addStart (void *item) { void * rv = zlistx_add_start (self, item); return rv; } /// // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void * QZlistx::addEnd (void *item) { void * rv = zlistx_add_end (self, item); return rv; } /// // Return the number of items in the list size_t QZlistx::size () { size_t rv = zlistx_size (self); return rv; } /// // Return first item in the list, or null, leaves the cursor void * QZlistx::head () { void * rv = zlistx_head (self); return rv; } /// // Return last item in the list, or null, leaves the cursor void * QZlistx::tail () { void * rv = zlistx_tail (self); return rv; } /// // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * QZlistx::first () { void * rv = zlistx_first (self); return rv; } /// // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). void * QZlistx::next () { void * rv = zlistx_next (self); return rv; } /// // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). void * QZlistx::prev () { void * rv = zlistx_prev (self); return rv; } /// // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * QZlistx::last () { void * rv = zlistx_last (self); return rv; } /// // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * QZlistx::item () { void * rv = zlistx_item (self); return rv; } /// // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * QZlistx::cursor () { void * rv = zlistx_cursor (self); return rv; } /// // Returns the item associated with the given list handle, or NULL if passed // in handle is NULL. Asserts that the passed in handle points to a list element. void * QZlistx::handleItem (void *handle) { void * rv = zlistx_handle_item (handle); return rv; } /// // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. void * QZlistx::find (void *item) { void * rv = zlistx_find (self, item); return rv; } /// // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. void * QZlistx::detach (void *handle) { void * rv = zlistx_detach (self, handle); return rv; } /// // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. void * QZlistx::detachCur () { void * rv = zlistx_detach_cur (self); return rv; } /// // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. int QZlistx::deleteNoConflict (void *handle) { int rv = zlistx_delete (self, handle); return rv; } /// // Move an item to the start of the list, via its handle. void QZlistx::moveStart (void *handle) { zlistx_move_start (self, handle); } /// // Move an item to the end of the list, via its handle. void QZlistx::moveEnd (void *handle) { zlistx_move_end (self, handle); } /// // Remove all items from the list, and destroy them if the item destructor // is set. void QZlistx::purge () { zlistx_purge (self); } /// // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. void QZlistx::sort () { zlistx_sort (self); } /// // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. void * QZlistx::insert (void *item, bool lowValue) { void * rv = zlistx_insert (self, item, lowValue); return rv; } /// // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. void QZlistx::reorder (void *handle, bool lowValue) { zlistx_reorder (self, handle, lowValue); } /// // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. QZlistx * QZlistx::dup () { QZlistx *rv = new QZlistx (zlistx_dup (self)); return rv; } /// // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. void QZlistx::setDestructor (zlistx_destructor_fn destructor) { zlistx_set_destructor (self, destructor); } /// // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. void QZlistx::setDuplicator (zlistx_duplicator_fn duplicator) { zlistx_set_duplicator (self, duplicator); } /// // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. void QZlistx::setComparator (zlistx_comparator_fn comparator) { zlistx_set_comparator (self, comparator); } /// // Self test of this class. void QZlistx::test (bool verbose) { zlistx_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzmsg.h0000664000372000037200000001675413222211156017722 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZMSG_H #define Q_ZMSG_H #include "qczmq.h" class QT_CZMQ_EXPORT QZmsg : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZmsg (zmsg_t *self, QObject *qObjParent = 0); // Create a new empty message object explicit QZmsg (QObject *qObjParent = 0); // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted. Does a blocking recv. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving. static QZmsg* recv (void *source, QObject *qObjParent = 0); // Load/append an open file into new message, return the message. // Returns NULL if the message could not be loaded. static QZmsg* load (FILE *file, QObject *qObjParent = 0); // Decodes a serialized message frame created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the frame was badly formatted or // there was insufficient memory to work. static QZmsg* decode (QZframe *frame, QObject *qObjParent = 0); // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. static QZmsg* newSignal (byte status, QObject *qObjParent = 0); // Destroy a message object and all frames it contains ~QZmsg (); // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int send (void *dest); // Send message to destination socket as part of a multipart sequence, and // destroy the message after sending it successfully. Note that after a // zmsg_sendm, you must call zmsg_send or another method that sends a final // message part. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int sendm (void *dest); // Return size of message, i.e. number of frames (0 or more). size_t size (); // Return total size of all frames in message. size_t contentSize (); // Return message routing ID, if the message came from a ZMQ_SERVER socket. // Else returns zero. quint32 routingId (); // Set routing ID on message. This is used if/when the message is sent to a // ZMQ_SERVER socket. void setRoutingId (quint32 routingId); // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. int prepend (QZframe *frameP); // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Deprecates zmsg_add, which did not nullify the // caller's frame reference. int append (QZframe *frameP); // Remove first frame from message, if any. Returns frame, or NULL. QZframe * pop (); // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. int pushmem (const void *data, size_t size); // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. int addmem (const void *data, size_t size); // Push string as new frame to front of message. // Returns 0 on success, -1 on error. int pushstr (const QString &string); // Push string as new frame to end of message. // Returns 0 on success, -1 on error. int addstr (const QString &string); // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. int pushstrf (const QString ¶m); // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. int addstrf (const QString ¶m); // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. QString popstr (); // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. int addmsg (QZmsg *msgP); // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not successful. QZmsg * popmsg (); // Remove specified frame from list, if present. Does not destroy frame. void remove (QZframe *frame); // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. QZframe * first (); // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. QZframe * next (); // Return the last frame. If there are no frames, returns NULL. QZframe * last (); // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. int save (FILE *file); // Serialize multipart message to a single message frame. Use this method // to send structured messages across transports that do not support // multipart data. Allocates and returns a new frame containing the // serialized message. To decode a serialized message frame, use // zmsg_decode (). QZframe * encode (); // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. QZmsg * dup (); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). void print (); // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. bool eq (QZmsg *other); // Return signal value, 0 or greater, if message is a signal, -1 if not. int signal (); // Probe the supplied object, and report if it looks like a zmsg_t. static bool is (void *self); // Self test of this class. static void test (bool verbose); zmsg_t *self; }; #endif // Q_ZMSG_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzactor.cpp0000664000372000037200000000510013222211156020556 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZactor::QZactor (zactor_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new actor passing arbitrary arguments reference. QZactor::QZactor (zactor_fn task, void *args, QObject *qObjParent) : QObject (qObjParent) { this->self = zactor_new (task, args); } /// // Destroy an actor. QZactor::~QZactor () { zactor_destroy (&self); } /// // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. int QZactor::send (QZmsg *msgP) { int rv = zactor_send (self, &msgP->self); return rv; } /// // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. QZmsg * QZactor::recv () { QZmsg *rv = new QZmsg (zactor_recv (self)); return rv; } /// // Probe the supplied object, and report if it looks like a zactor_t. bool QZactor::is (void *self) { bool rv = zactor_is (self); return rv; } /// // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. void * QZactor::resolve (void *self) { void * rv = zactor_resolve (self); return rv; } /// // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. QZsock * QZactor::sock () { QZsock *rv = new QZsock (zactor_sock (self)); return rv; } /// // Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. void QZactor::setDestructor (zactor_destructor_fn destructor) { zactor_set_destructor (self, destructor); } /// // Self test of this class. void QZactor::test (bool verbose) { zactor_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzclock.cpp0000664000372000037200000000417213222211156020551 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZclock::QZclock (zclock_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Sleep for a number of milliseconds void QZclock::sleep (int msecs) { zclock_sleep (msecs); } /// // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. int64_t QZclock::time () { int64_t rv = zclock_time (); return rv; } /// // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t QZclock::mono () { int64_t rv = zclock_mono (); return rv; } /// // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t QZclock::usecs () { int64_t rv = zclock_usecs (); return rv; } /// // Return formatted date/time as fresh string. Free using zstr_free(). QString QZclock::timestr () { char *retStr_ = zclock_timestr (); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Self test of this class. void QZclock::test (bool verbose) { zclock_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzdirpatch.cpp0000664000372000037200000000444413222211156021256 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZdirPatch::QZdirPatch (zdir_patch_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create new patch QZdirPatch::QZdirPatch (const QString &path, QZfile *file, int op, const QString &alias, QObject *qObjParent) : QObject (qObjParent) { this->self = zdir_patch_new (path.toUtf8().data(), file->self, op, alias.toUtf8().data()); } /// // Destroy a patch QZdirPatch::~QZdirPatch () { zdir_patch_destroy (&self); } /// // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. QZdirPatch * QZdirPatch::dup () { QZdirPatch *rv = new QZdirPatch (zdir_patch_dup (self)); return rv; } /// // Return patch file directory path const QString QZdirPatch::path () { const QString rv = QString (zdir_patch_path (self)); return rv; } /// // Return patch file item QZfile * QZdirPatch::file () { QZfile *rv = new QZfile (zdir_patch_file (self)); return rv; } /// // Return operation int QZdirPatch::op () { int rv = zdir_patch_op (self); return rv; } /// // Return patch virtual file path const QString QZdirPatch::vpath () { const QString rv = QString (zdir_patch_vpath (self)); return rv; } /// // Calculate hash digest for file (create only) void QZdirPatch::digestSet () { zdir_patch_digest_set (self); } /// // Return hash digest for patch file const QString QZdirPatch::digest () { const QString rv = QString (zdir_patch_digest (self)); return rv; } /// // Self test of this class. void QZdirPatch::test (bool verbose) { zdir_patch_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzlist.cpp0000664000372000037200000001360513222211156020432 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZlist::QZlist (zlist_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new list container QZlist::QZlist (QObject *qObjParent) : QObject (qObjParent) { this->self = zlist_new (); } /// // Destroy a list container QZlist::~QZlist () { zlist_destroy (&self); } /// // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * QZlist::first () { void * rv = zlist_first (self); return rv; } /// // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. void * QZlist::next () { void * rv = zlist_next (self); return rv; } /// // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * QZlist::last () { void * rv = zlist_last (self); return rv; } /// // Return first item in the list, or null, leaves the cursor void * QZlist::head () { void * rv = zlist_head (self); return rv; } /// // Return last item in the list, or null, leaves the cursor void * QZlist::tail () { void * rv = zlist_tail (self); return rv; } /// // Return the current item of list. If the list is empty, returns NULL. // Leaves cursor pointing at the current item, or NULL if the list is empty. void * QZlist::item () { void * rv = zlist_item (self); return rv; } /// // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int QZlist::append (void *item) { int rv = zlist_append (self, item); return rv; } /// // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int QZlist::push (void *item) { int rv = zlist_push (self, item); return rv; } /// // Pop the item off the start of the list, if any void * QZlist::pop () { void * rv = zlist_pop (self); return rv; } /// // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. bool QZlist::exists (void *item) { bool rv = zlist_exists (self, item); return rv; } /// // Remove the specified item from the list if present void QZlist::remove (void *item) { zlist_remove (self, item); } /// // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. QZlist * QZlist::dup () { QZlist *rv = new QZlist (zlist_dup (self)); return rv; } /// // Purge all items from list void QZlist::purge () { zlist_purge (self); } /// // Return number of items in the list size_t QZlist::size () { size_t rv = zlist_size (self); return rv; } /// // Sort the list. If the compare function is null, sorts the list by // ascending key value using a straight ASCII comparison. If you specify // a compare function, this decides how items are sorted. The sort is not // stable, so may reorder items with the same keys. The algorithm used is // combsort, a compromise between performance and simplicity. void QZlist::sort (zlist_compare_fn compare) { zlist_sort (self, compare); } /// // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. void QZlist::autofree () { zlist_autofree (self); } /// // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. void QZlist::comparefn (zlist_compare_fn fn) { zlist_comparefn (self, fn); } /// // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * QZlist::freefn (void *item, zlist_free_fn fn, bool atTail) { void * rv = zlist_freefn (self, item, fn, atTail); return rv; } /// // Self test of this class. void QZlist::test (bool verbose) { zlist_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzhashx.h0000664000372000037200000002136013222211156020234 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZHASHX_H #define Q_ZHASHX_H #include "qczmq.h" class QT_CZMQ_EXPORT QZhashx : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZhashx (zhashx_t *self, QObject *qObjParent = 0); // Create a new, empty hash container explicit QZhashx (QObject *qObjParent = 0); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. static QZhashx* unpack (QZframe *frame, QObject *qObjParent = 0); // Same as unpack but uses a user-defined deserializer function to convert // a longstr back into item format. static QZhashx* unpackOwn (QZframe *frame, zhashx_deserializer_fn deserializer, QObject *qObjParent = 0); // Destroy a hash container and all items in it ~QZhashx (); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int insert (const void *key, void *item); // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. void update (const void *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void deleteNoConflict (const void *key); // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. void purge (); // Return the item at the specified key, or null void * lookup (const void *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int rename (const void *oldKey, const void *newKey); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * freefn (const void *key, zhashx_free_fn freeFn); // Return the number of keys/items in the hash table size_t size (); // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. QZlistx * keys (); // Return a zlistx_t containing the values for the items in the // table. Uses the duplicator to duplicate all items and sets the // destructor as destructor for the list. QZlistx * values (); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhashx_cursor(). NOTE: do NOT modify the table while iterating. void * first (); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). To // access the key for this item use zhashx_cursor(). NOTE: do NOT modify // the table while iterating. void * next (); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const void * cursor (); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void comment (const QString ¶m); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int save (const QString &filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int load (const QString &filename); // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int refresh (); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. QZframe * pack (); // Same as pack but uses a user-defined serializer function to convert items // into longstr. QZframe * packOwn (zhashx_serializer_fn serializer); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. QZhashx * dup (); // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. void setDestructor (zhashx_destructor_fn destructor); // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. void setDuplicator (zhashx_duplicator_fn duplicator); // Set a user-defined deallocator for keys; by default keys are freed // when the hash is destroyed using free(). void setKeyDestructor (zhashx_destructor_fn destructor); // Set a user-defined duplicator for keys; by default keys are duplicated // using strdup. void setKeyDuplicator (zhashx_duplicator_fn duplicator); // Set a user-defined comparator for keys; by default keys are // compared using strcmp. // The callback function should return zero (0) on matching // items. void setKeyComparator (zhashx_comparator_fn comparator); // Set a user-defined hash function for keys; by default keys are // hashed by a modified Bernstein hashing function. void setKeyHasher (zhashx_hash_fn hasher); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. QZhashx * dupV2 (); // Self test of this class. static void test (bool verbose); zhashx_t *self; }; #endif // Q_ZHASHX_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzproc.cpp0000664000372000037200000002227613222211156020426 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZproc::QZproc (zproc_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new zproc. // NOTE: On Windows and with libzmq3 and libzmq2 this function // returns NULL. Code needs to be ported there. QZproc::QZproc (QObject *qObjParent) : QObject (qObjParent) { this->self = zproc_new (); } /// // Destroy zproc, wait until process ends. QZproc::~QZproc () { zproc_destroy (&self); } /// // Setup the command line arguments, the first item must be an (absolute) filename // to run. void QZproc::setArgs (QZlistx *args) { zproc_set_args (self, args->self); } /// // Setup the environment variables for the process. void QZproc::setEnv (QZhashx *args) { zproc_set_env (self, args->self); } /// // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The writable one is then accessbile via zproc_stdin method. void QZproc::setStdin (void *socket) { zproc_set_stdin (self, socket); } /// // Connects process stdout with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stdout method. void QZproc::setStdout (void *socket) { zproc_set_stdout (self, socket); } /// // Connects process stderr with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stderr method. void QZproc::setStderr (void *socket) { zproc_set_stderr (self, socket); } /// // Return subprocess stdin writable socket. NULL for // not initialized or external sockets. void * QZproc::stdin () { void * rv = zproc_stdin (self); return rv; } /// // Return subprocess stdout readable socket. NULL for // not initialized or external sockets. void * QZproc::stdout () { void * rv = zproc_stdout (self); return rv; } /// // Return subprocess stderr readable socket. NULL for // not initialized or external sockets. void * QZproc::stderr () { void * rv = zproc_stderr (self); return rv; } /// // Starts the process. int QZproc::run () { int rv = zproc_run (self); return rv; } /// // process exit code int QZproc::returncode () { int rv = zproc_returncode (self); return rv; } /// // PID of the process int QZproc::pid () { int rv = zproc_pid (self); return rv; } /// // return true if process is running, false if not yet started or finished bool QZproc::running () { bool rv = zproc_running (self); return rv; } /// // wait or poll process status, return return code int QZproc::wait (bool hang) { int rv = zproc_wait (self, hang); return rv; } /// // return internal actor, usefull for the polling if process died void * QZproc::actor () { void * rv = zproc_actor (self); return rv; } /// // send a signal to the subprocess void QZproc::kill (int signal) { zproc_kill (self, signal); } /// // set verbose mode void QZproc::setVerbose (bool verbose) { zproc_set_verbose (self, verbose); } /// // Returns CZMQ version as a single 6-digit integer encoding the major // version (x 10000), the minor version (x 100) and the patch. int QZproc::czmqVersion () { int rv = zproc_czmq_version (); return rv; } /// // Returns true if the process received a SIGINT or SIGTERM signal. // It is good practice to use this method to exit any infinite loop // processing messages. bool QZproc::interrupted () { bool rv = zproc_interrupted (); return rv; } /// // Returns true if the underlying libzmq supports CURVE security. bool QZproc::hasCurve () { bool rv = zproc_has_curve (); return rv; } /// // Return current host name, for use in public tcp:// endpoints. // If the host name is not resolvable, returns NULL. QString QZproc::hostname () { char *retStr_ = zproc_hostname (); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Move the current process into the background. The precise effect // depends on the operating system. On POSIX boxes, moves to a specified // working directory (if specified), closes all file handles, reopens // stdin, stdout, and stderr to the null device, and sets the process to // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there // was an error. void QZproc::daemonize (const QString &workdir) { zproc_daemonize (workdir.toUtf8().data()); } /// // Drop the process ID into the lockfile, with exclusive lock, and // switch the process to the specified group and/or user. Any of the // arguments may be null, indicating a no-op. Returns 0 on success, // -1 on failure. Note if you combine this with zsys_daemonize, run // after, not before that method, or the lockfile will hold the wrong // process ID. void QZproc::runAs (const QString &lockfile, const QString &group, const QString &user) { zproc_run_as (lockfile.toUtf8().data(), group.toUtf8().data(), user.toUtf8().data()); } /// // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void QZproc::setIoThreads (size_t ioThreads) { zproc_set_io_threads (ioThreads); } /// // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void QZproc::setMaxSockets (size_t maxSockets) { zproc_set_max_sockets (maxSockets); } /// // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void QZproc::setBiface (const QString &value) { zproc_set_biface (value.toUtf8().data()); } /// // Return network interface to use for broadcasts, or "" if none was set. const QString QZproc::biface () { const QString rv = QString (zproc_biface ()); return rv; } /// // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void QZproc::setLogIdent (const QString &value) { zproc_set_log_ident (value.toUtf8().data()); } /// // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void QZproc::setLogSender (const QString &endpoint) { zproc_set_log_sender (endpoint.toUtf8().data()); } /// // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void QZproc::setLogSystem (bool logsystem) { zproc_set_log_system (logsystem); } /// // Log error condition - highest priority void QZproc::logError (const QString ¶m) { zproc_log_error ("%s", param.toUtf8().data()); } /// // Log warning condition - high priority void QZproc::logWarning (const QString ¶m) { zproc_log_warning ("%s", param.toUtf8().data()); } /// // Log normal, but significant, condition - normal priority void QZproc::logNotice (const QString ¶m) { zproc_log_notice ("%s", param.toUtf8().data()); } /// // Log informational message - low priority void QZproc::logInfo (const QString ¶m) { zproc_log_info ("%s", param.toUtf8().data()); } /// // Log debug-level message - lowest priority void QZproc::logDebug (const QString ¶m) { zproc_log_debug ("%s", param.toUtf8().data()); } /// // Self test of this class. void QZproc::test (bool verbose) { zproc_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzhash.h0000664000372000037200000001454513222211156020053 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZHASH_H #define Q_ZHASH_H #include "qczmq.h" class QT_CZMQ_EXPORT QZhash : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZhash (zhash_t *self, QObject *qObjParent = 0); // Create a new, empty hash container explicit QZhash (QObject *qObjParent = 0); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. static QZhash* unpack (QZframe *frame, QObject *qObjParent = 0); // Destroy a hash container and all items in it ~QZhash (); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int insert (const QString &key, void *item); // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. void update (const QString &key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void deleteNoConflict (const QString &key); // Return the item at the specified key, or null void * lookup (const QString &key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int rename (const QString &oldKey, const QString &newKey); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * freefn (const QString &key, zhash_free_fn freeFn); // Return the number of keys/items in the hash table size_t size (); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. QZhash * dup (); // Return keys for items in table QZlist * keys (); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhash_cursor(). NOTE: do NOT modify the table while iterating. void * first (); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). To // access the key for this item use zhash_cursor(). NOTE: do NOT modify // the table while iterating. void * next (); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const QString cursor (); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void comment (const QString ¶m); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. QZframe * pack (); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int save (const QString &filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int load (const QString &filename); // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int refresh (); // Set hash for automatic value destruction. Note that this assumes that // values are NULL-terminated strings. Do not use with different types. void autofree (); // Self test of this class. static void test (bool verbose); zhash_t *self; }; #endif // Q_ZHASH_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzframe.cpp0000664000372000037200000001314513222211156020550 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZframe::QZframe (zframe_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new frame. If size is not null, allocates the frame data // to the specified size. If additionally, data is not null, copies // size octets from the specified data into the frame body. QZframe::QZframe (const void *data, size_t size, QObject *qObjParent) : QObject (qObjParent) { this->self = zframe_new (data, size); } /// // Create an empty (zero-sized) frame QZframe* QZframe::newEmpty (QObject *qObjParent) { return new QZframe (zframe_new_empty (), qObjParent); } /// // Create a frame with a specified string content. QZframe* QZframe::from (const QString &string, QObject *qObjParent) { return new QZframe (zframe_from (string.toUtf8().data()), qObjParent); } /// // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. QZframe* QZframe::recv (void *source, QObject *qObjParent) { return new QZframe (zframe_recv (source), qObjParent); } /// // Destroy a frame QZframe::~QZframe () { zframe_destroy (&self); } /// // Send a frame to a socket, destroy frame after sending. // Return -1 on error, 0 on success. int QZframe::send (void *dest, int flags) { int rv = zframe_send (&self, dest, flags); return rv; } /// // Return number of bytes in frame data size_t QZframe::size () { size_t rv = zframe_size (self); return rv; } /// // Return address of frame data byte * QZframe::data () { byte * rv = zframe_data (self); return rv; } /// // Return meta data property for frame // The caller shall not modify or free the returned value, which shall be // owned by the message. const QString QZframe::meta (const QString &property) { const QString rv = QString (zframe_meta (self, property.toUtf8().data())); return rv; } /// // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. QZframe * QZframe::dup () { QZframe *rv = new QZframe (zframe_dup (self)); return rv; } /// // Return frame data encoded as printable hex string, useful for 0MQ UUIDs. // Caller must free string when finished with it. QString QZframe::strhex () { char *retStr_ = zframe_strhex (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Return frame data copied into freshly allocated string // Caller must free string when finished with it. QString QZframe::strdup () { char *retStr_ = zframe_strdup (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Return TRUE if frame body is equal to string, excluding terminator bool QZframe::streqNoConflict (const QString &string) { bool rv = zframe_streq (self, string.toUtf8().data()); return rv; } /// // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method int QZframe::more () { int rv = zframe_more (self); return rv; } /// // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. void QZframe::setMore (int more) { zframe_set_more (self, more); } /// // Return frame routing ID, if the frame came from a ZMQ_SERVER socket. // Else returns zero. quint32 QZframe::routingId () { uint32_t rv = zframe_routing_id (self); return rv; } /// // Set routing ID on frame. This is used if/when the frame is sent to a // ZMQ_SERVER socket. void QZframe::setRoutingId (quint32 routingId) { zframe_set_routing_id (self, (uint32_t) routingId); } /// // Return frame group of radio-dish pattern. const QString QZframe::group () { const QString rv = QString (zframe_group (self)); return rv; } /// // Set group on frame. This is used if/when the frame is sent to a // ZMQ_RADIO socket. // Return -1 on error, 0 on success. int QZframe::setGroup (const QString &group) { int rv = zframe_set_group (self, group.toUtf8().data()); return rv; } /// // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false. bool QZframe::eq (QZframe *other) { bool rv = zframe_eq (self, other->self); return rv; } /// // Set new contents for frame void QZframe::reset (const void *data, size_t size) { zframe_reset (self, data, size); } /// // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. void QZframe::print (const QString &prefix) { zframe_print (self, prefix.toUtf8().data()); } /// // Probe the supplied object, and report if it looks like a zframe_t. bool QZframe::is (void *self) { bool rv = zframe_is (self); return rv; } /// // Self test of this class. void QZframe::test (bool verbose) { zframe_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzstr.cpp0000664000372000037200000000774213222211156020274 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZstr::QZstr (zstr_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. QString QZstr::recv (void *source) { char *retStr_ = zstr_recv (source); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // De-compress and receive C string from socket, received as a message // with two frames: size of the uncompressed string, and the string itself. // Caller must free returned string using zstr_free(). Returns NULL if the // context is being terminated or the process was interrupted. QString QZstr::recvCompress (void *source) { char *retStr_ = zstr_recv_compress (source); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". int QZstr::send (void *dest, const QString &string) { int rv = zstr_send (dest, string.toUtf8().data()); return rv; } /// // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. int QZstr::sendm (void *dest, const QString &string) { int rv = zstr_sendm (dest, string.toUtf8().data()); return rv; } /// // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). int QZstr::sendf (void *dest, const QString ¶m) { int rv = zstr_sendf (dest, "%s", param.toUtf8().data()); return rv; } /// // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. int QZstr::sendfm (void *dest, const QString ¶m) { int rv = zstr_sendfm (dest, "%s", param.toUtf8().data()); return rv; } /// // Compress and send a C string to a socket, as a message with two frames: // size of the uncompressed string, and the string itself. The string is // sent without trailing null byte; to read this you can use // zstr_recv_compress, or a similar method that de-compresses and adds a // null terminator on the received string. int QZstr::sendCompress (void *dest, const QString &string) { int rv = zstr_send_compress (dest, string.toUtf8().data()); return rv; } /// // Compress and send a C string to a socket, as zstr_send_compress(), // with a MORE flag, so that you can send further strings in the same // multi-part message. int QZstr::sendmCompress (void *dest, const QString &string) { int rv = zstr_sendm_compress (dest, string.toUtf8().data()); return rv; } /// // Accepts a void pointer and returns a fresh character string. If source // is null, returns an empty string. QString QZstr::str (void *source) { char *retStr_ = zstr_str (source); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Self test of this class. void QZstr::test (bool verbose) { zstr_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qziflist.cpp0000664000372000037200000000560113222211156020746 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZiflist::QZiflist (ziflist_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Get a list of network interfaces currently defined on the system QZiflist::QZiflist (QObject *qObjParent) : QObject (qObjParent) { this->self = ziflist_new (); } /// // Destroy a ziflist instance QZiflist::~QZiflist () { ziflist_destroy (&self); } /// // Reload network interfaces from system void QZiflist::reload () { ziflist_reload (self); } /// // Return the number of network interfaces on system size_t QZiflist::size () { size_t rv = ziflist_size (self); return rv; } /// // Get first network interface, return NULL if there are none const QString QZiflist::first () { const QString rv = QString (ziflist_first (self)); return rv; } /// // Get next network interface, return NULL if we hit the last one const QString QZiflist::next () { const QString rv = QString (ziflist_next (self)); return rv; } /// // Return the current interface IP address as a printable string const QString QZiflist::address () { const QString rv = QString (ziflist_address (self)); return rv; } /// // Return the current interface broadcast address as a printable string const QString QZiflist::broadcast () { const QString rv = QString (ziflist_broadcast (self)); return rv; } /// // Return the current interface network mask as a printable string const QString QZiflist::netmask () { const QString rv = QString (ziflist_netmask (self)); return rv; } /// // Return the list of interfaces. void QZiflist::print () { ziflist_print (self); } /// // Get a list of network interfaces currently defined on the system // Includes IPv6 interfaces QZiflist * QZiflist::newIpv6 () { QZiflist *rv = new QZiflist (ziflist_new_ipv6 ()); return rv; } /// // Reload network interfaces from system, including IPv6 void QZiflist::reloadIpv6 () { ziflist_reload_ipv6 (self); } /// // Return true if the current interface uses IPv6 bool QZiflist::isIpv6 () { bool rv = ziflist_is_ipv6 (self); return rv; } /// // Self test of this class. void QZiflist::test (bool verbose) { ziflist_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzactor.h0000664000372000037200000000431713222211156020234 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZACTOR_H #define Q_ZACTOR_H #include "qczmq.h" class QT_CZMQ_EXPORT QZactor : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZactor (zactor_t *self, QObject *qObjParent = 0); // Create a new actor passing arbitrary arguments reference. explicit QZactor (zactor_fn task, void *args, QObject *qObjParent = 0); // Destroy an actor. ~QZactor (); // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. int send (QZmsg *msgP); // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. QZmsg * recv (); // Probe the supplied object, and report if it looks like a zactor_t. static bool is (void *self); // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. static void * resolve (void *self); // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. QZsock * sock (); // Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. void setDestructor (zactor_destructor_fn destructor); // Self test of this class. static void test (bool verbose); zactor_t *self; }; #endif // Q_ZACTOR_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzfile.h0000664000372000037200000001117013222211156020036 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZFILE_H #define Q_ZFILE_H #include "qczmq.h" class QT_CZMQ_EXPORT QZfile : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZfile (zfile_t *self, QObject *qObjParent = 0); // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. explicit QZfile (const QString &path, const QString &name, QObject *qObjParent = 0); // Create new temporary file for writing via tmpfile. File is automaticaly // deleted on destroy static QZfile* tmp (QObject *qObjParent = 0); // Destroy a file item ~QZfile (); // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. QZfile * dup (); // Return file name, remove path if provided const QString filename (const QString &path); // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. void restat (); // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. time_t modified (); // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. off_t cursize (); // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool isDirectory (); // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool isRegular (); // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. bool isReadable (); // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. bool isWriteable (); // Check if file has stopped changing and can be safely processed. // Updates the file statistics from disk at every call. bool isStable (); // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. bool hasChanged (); // Remove the file from disk void remove (); // Open file for reading // Returns 0 if OK, -1 if not found or not accessible int input (); // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. int output (); // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. QZchunk * read (size_t bytes, off_t offset); // Returns true if zfile_read() just read the last chunk in the file. bool eof (); // Write chunk to file at specified position // Return 0 if OK, else -1 int write (QZchunk *chunk, off_t offset); // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. const QString readln (); // Close file, if open void close (); // Return file handle, if opened FILE * handle (); // Calculate SHA1 digest for file, using zdigest class. const QString digest (); // Self test of this class. static void test (bool verbose); zfile_t *self; }; #endif // Q_ZFILE_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzconfig.h0000664000372000037200000001136713222211156020374 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZCONFIG_H #define Q_ZCONFIG_H #include "qczmq.h" class QT_CZMQ_EXPORT QZconfig : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZconfig (zconfig_t *self, QObject *qObjParent = 0); // Create new config item explicit QZconfig (const QString &name, QZconfig *parent, QObject *qObjParent = 0); // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. static QZconfig* load (const QString &filename, QObject *qObjParent = 0); // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. static QZconfig* loadf (const QString ¶m, QObject *qObjParent = 0); // Destroy a config item and all its children ~QZconfig (); // Return name of config item const QString name (); // Return value of config item const QString value (); // Insert or update configuration key with value void put (const QString &path, const QString &value); // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. void putf (const QString &path, const QString ¶m); // Get value for config item into a string value; leading slash is optional // and ignored. const QString get (const QString &path, const QString &defaultValue); // Set config item name, name may be NULL void setName (const QString &name); // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. void setValue (const QString ¶m); // Find our first child, if any QZconfig * child (); // Find our first sibling, if any QZconfig * next (); // Find a config item along a path; leading slash is optional and ignored. QZconfig * locate (const QString &path); // Locate the last config item at a specified depth QZconfig * atDepth (int level); // Execute a callback for each config item in the tree; returns zero if // successful, else -1. int execute (zconfig_fct handler, void *arg); // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. void setComment (const QString ¶m); // Return comments of config item, as zlist. QZlist * comments (); // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. int save (const QString &filename); // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. int savef (const QString ¶m); // Report filename used during zconfig_load, or NULL if none const QString filename (); // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). int reload (); // Load a config tree from a memory chunk static QZconfig * chunkLoad (QZchunk *chunk); // Save a config tree to a new memory chunk QZchunk * chunkSave (); // Load a config tree from a null-terminated string static QZconfig * strLoad (const QString &string); // Save a config tree to a new null terminated string QString strSave (); // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. bool hasChanged (); // Destroy subtree (all children) void removeSubtree (); // Destroy node and subtree (all children) void remove (); // Print the config file to open stream void fprint (FILE *file); // Print properties of object void print (); // Self test of this class static void test (bool verbose); zconfig_t *self; }; #endif // Q_ZCONFIG_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qczmq.h0000664000372000037200000000433613222211156017705 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_CZMQ_H #define Q_CZMQ_H #include #include #include #if defined(Q_OS_WIN) # if !defined(QT_CZMQ_EXPORT) && !defined(QT_CZMQ_IMPORT) # define QT_CZMQ_EXPORT # elif defined(QT_CZMQ_IMPORT) # if defined(QT_CZMQ_EXPORT) # undef QT_CZMQ_EXPORT # endif # define QT_CZMQ_EXPORT __declspec(dllimport) # elif defined(QT_CZMQ_EXPORT) # undef QT_CZMQ_EXPORT # define QT_CZMQ_EXPORT __declspec(dllexport) # endif #else # define QT_CZMQ_EXPORT #endif // Opaque class structures to allow forward references class QZactor; class QZargs; class QZarmour; class QZcert; class QZcertstore; class QZchunk; class QZclock; class QZconfig; class QZdigest; class QZdir; class QZdirPatch; class QZfile; class QZframe; class QZhash; class QZhashx; class QZiflist; class QZlist; class QZlistx; class QZloop; class QZmsg; class QZpoller; class QZproc; class QZsock; class QZstr; class QZsys; class QZtimerset; class QZtrie; class QZuuid; // Public API classes #include "qzactor.h" #include "qzargs.h" #include "qzarmour.h" #include "qzcert.h" #include "qzcertstore.h" #include "qzchunk.h" #include "qzclock.h" #include "qzconfig.h" #include "qzdigest.h" #include "qzdir.h" #include "qzdirpatch.h" #include "qzfile.h" #include "qzframe.h" #include "qzhash.h" #include "qzhashx.h" #include "qziflist.h" #include "qzlist.h" #include "qzlistx.h" #include "qzloop.h" #include "qzmsg.h" #include "qzpoller.h" #include "qzproc.h" #include "qzsock.h" #include "qzstr.h" #include "qzsys.h" #include "qztimerset.h" #include "qztrie.h" #include "qzuuid.h" #endif // Q_CZMQ_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzarmour.cpp0000664000372000037200000000653013222211156020763 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZarmour::QZarmour (zarmour_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new zarmour QZarmour::QZarmour (QObject *qObjParent) : QObject (qObjParent) { this->self = zarmour_new (); } /// // Destroy the zarmour QZarmour::~QZarmour () { zarmour_destroy (&self); } /// // Encode a stream of bytes into an armoured string. Returns the armoured // string, or NULL if there was insufficient memory available to allocate // a new string. QString QZarmour::encode (const byte *data, size_t size) { char *retStr_ = zarmour_encode (self, data, size); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Decode an armoured string into a chunk. The decoded output is // null-terminated, so it may be treated as a string, if that's what // it was prior to encoding. QZchunk * QZarmour::decode (const QString &data) { QZchunk *rv = new QZchunk (zarmour_decode (self, data.toUtf8().data())); return rv; } /// // Get the mode property. int QZarmour::mode () { int rv = zarmour_mode (self); return rv; } /// // Get printable string for mode. const QString QZarmour::modeStr () { const QString rv = QString (zarmour_mode_str (self)); return rv; } /// // Set the mode property. void QZarmour::setMode (int mode) { zarmour_set_mode (self, mode); } /// // Return true if padding is turned on. bool QZarmour::pad () { bool rv = zarmour_pad (self); return rv; } /// // Turn padding on or off. Default is on. void QZarmour::setPad (bool pad) { zarmour_set_pad (self, pad); } /// // Get the padding character. char QZarmour::padChar () { char rv = zarmour_pad_char (self); return rv; } /// // Set the padding character. void QZarmour::setPadChar (char padChar) { zarmour_set_pad_char (self, padChar); } /// // Return if splitting output into lines is turned on. Default is off. bool QZarmour::lineBreaks () { bool rv = zarmour_line_breaks (self); return rv; } /// // Turn splitting output into lines on or off. void QZarmour::setLineBreaks (bool lineBreaks) { zarmour_set_line_breaks (self, lineBreaks); } /// // Get the line length used for splitting lines. size_t QZarmour::lineLength () { size_t rv = zarmour_line_length (self); return rv; } /// // Set the line length used for splitting lines. void QZarmour::setLineLength (size_t lineLength) { zarmour_set_line_length (self, lineLength); } /// // Print properties of object void QZarmour::print () { zarmour_print (self); } /// // Self test of this class. void QZarmour::test (bool verbose) { zarmour_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qziflist.h0000664000372000037200000000425713222211156020421 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZIFLIST_H #define Q_ZIFLIST_H #include "qczmq.h" class QT_CZMQ_EXPORT QZiflist : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZiflist (ziflist_t *self, QObject *qObjParent = 0); // Get a list of network interfaces currently defined on the system explicit QZiflist (QObject *qObjParent = 0); // Destroy a ziflist instance ~QZiflist (); // Reload network interfaces from system void reload (); // Return the number of network interfaces on system size_t size (); // Get first network interface, return NULL if there are none const QString first (); // Get next network interface, return NULL if we hit the last one const QString next (); // Return the current interface IP address as a printable string const QString address (); // Return the current interface broadcast address as a printable string const QString broadcast (); // Return the current interface network mask as a printable string const QString netmask (); // Return the list of interfaces. void print (); // Get a list of network interfaces currently defined on the system // Includes IPv6 interfaces static QZiflist * newIpv6 (); // Reload network interfaces from system, including IPv6 void reloadIpv6 (); // Return true if the current interface uses IPv6 bool isIpv6 (); // Self test of this class. static void test (bool verbose); ziflist_t *self; }; #endif // Q_ZIFLIST_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzstr.h0000664000372000037200000000652513222211156017737 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZSTR_H #define Q_ZSTR_H #include "qczmq.h" class QT_CZMQ_EXPORT QZstr : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZstr (zstr_t *self, QObject *qObjParent = 0); // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. static QString recv (void *source); // De-compress and receive C string from socket, received as a message // with two frames: size of the uncompressed string, and the string itself. // Caller must free returned string using zstr_free(). Returns NULL if the // context is being terminated or the process was interrupted. static QString recvCompress (void *source); // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". static int send (void *dest, const QString &string); // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. static int sendm (void *dest, const QString &string); // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). static int sendf (void *dest, const QString ¶m); // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. static int sendfm (void *dest, const QString ¶m); // Compress and send a C string to a socket, as a message with two frames: // size of the uncompressed string, and the string itself. The string is // sent without trailing null byte; to read this you can use // zstr_recv_compress, or a similar method that de-compresses and adds a // null terminator on the received string. static int sendCompress (void *dest, const QString &string); // Compress and send a C string to a socket, as zstr_send_compress(), // with a MORE flag, so that you can send further strings in the same // multi-part message. static int sendmCompress (void *dest, const QString &string); // Accepts a void pointer and returns a fresh character string. If source // is null, returns an empty string. static QString str (void *source); // Self test of this class. static void test (bool verbose); zstr_t *self; }; #endif // Q_ZSTR_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzconfig.cpp0000664000372000037200000001566313222211156020732 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZconfig::QZconfig (zconfig_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create new config item QZconfig::QZconfig (const QString &name, QZconfig *parent, QObject *qObjParent) : QObject (qObjParent) { this->self = zconfig_new (name.toUtf8().data(), parent->self); } /// // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. QZconfig* QZconfig::load (const QString &filename, QObject *qObjParent) { return new QZconfig (zconfig_load (filename.toUtf8().data()), qObjParent); } /// // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. QZconfig* QZconfig::loadf (const QString ¶m, QObject *qObjParent) { return new QZconfig (zconfig_loadf ("%s", param.toUtf8().data()), qObjParent); } /// // Destroy a config item and all its children QZconfig::~QZconfig () { zconfig_destroy (&self); } /// // Return name of config item const QString QZconfig::name () { const QString rv = QString (zconfig_name (self)); return rv; } /// // Return value of config item const QString QZconfig::value () { const QString rv = QString (zconfig_value (self)); return rv; } /// // Insert or update configuration key with value void QZconfig::put (const QString &path, const QString &value) { zconfig_put (self, path.toUtf8().data(), value.toUtf8().data()); } /// // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. void QZconfig::putf (const QString &path, const QString ¶m) { zconfig_putf (self, path.toUtf8().data(), "%s", param.toUtf8().data()); } /// // Get value for config item into a string value; leading slash is optional // and ignored. const QString QZconfig::get (const QString &path, const QString &defaultValue) { const QString rv = QString (zconfig_get (self, path.toUtf8().data(), defaultValue.toUtf8().data())); return rv; } /// // Set config item name, name may be NULL void QZconfig::setName (const QString &name) { zconfig_set_name (self, name.toUtf8().data()); } /// // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. void QZconfig::setValue (const QString ¶m) { zconfig_set_value (self, "%s", param.toUtf8().data()); } /// // Find our first child, if any QZconfig * QZconfig::child () { QZconfig *rv = new QZconfig (zconfig_child (self)); return rv; } /// // Find our first sibling, if any QZconfig * QZconfig::next () { QZconfig *rv = new QZconfig (zconfig_next (self)); return rv; } /// // Find a config item along a path; leading slash is optional and ignored. QZconfig * QZconfig::locate (const QString &path) { QZconfig *rv = new QZconfig (zconfig_locate (self, path.toUtf8().data())); return rv; } /// // Locate the last config item at a specified depth QZconfig * QZconfig::atDepth (int level) { QZconfig *rv = new QZconfig (zconfig_at_depth (self, level)); return rv; } /// // Execute a callback for each config item in the tree; returns zero if // successful, else -1. int QZconfig::execute (zconfig_fct handler, void *arg) { int rv = zconfig_execute (self, handler, arg); return rv; } /// // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. void QZconfig::setComment (const QString ¶m) { zconfig_set_comment (self, "%s", param.toUtf8().data()); } /// // Return comments of config item, as zlist. QZlist * QZconfig::comments () { QZlist *rv = new QZlist (zconfig_comments (self)); return rv; } /// // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. int QZconfig::save (const QString &filename) { int rv = zconfig_save (self, filename.toUtf8().data()); return rv; } /// // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. int QZconfig::savef (const QString ¶m) { int rv = zconfig_savef (self, "%s", param.toUtf8().data()); return rv; } /// // Report filename used during zconfig_load, or NULL if none const QString QZconfig::filename () { const QString rv = QString (zconfig_filename (self)); return rv; } /// // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). int QZconfig::reload () { int rv = zconfig_reload (&self); return rv; } /// // Load a config tree from a memory chunk QZconfig * QZconfig::chunkLoad (QZchunk *chunk) { QZconfig *rv = new QZconfig (zconfig_chunk_load (chunk->self)); return rv; } /// // Save a config tree to a new memory chunk QZchunk * QZconfig::chunkSave () { QZchunk *rv = new QZchunk (zconfig_chunk_save (self)); return rv; } /// // Load a config tree from a null-terminated string QZconfig * QZconfig::strLoad (const QString &string) { QZconfig *rv = new QZconfig (zconfig_str_load (string.toUtf8().data())); return rv; } /// // Save a config tree to a new null terminated string QString QZconfig::strSave () { char *retStr_ = zconfig_str_save (self); QString rv = QString (retStr_); zstr_free (&retStr_); return rv; } /// // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. bool QZconfig::hasChanged () { bool rv = zconfig_has_changed (self); return rv; } /// // Destroy subtree (all children) void QZconfig::removeSubtree () { zconfig_remove_subtree (self); } /// // Destroy node and subtree (all children) void QZconfig::remove () { zconfig_remove (&self); } /// // Print the config file to open stream void QZconfig::fprint (FILE *file) { zconfig_fprint (self, file); } /// // Print properties of object void QZconfig::print () { zconfig_print (self); } /// // Self test of this class void QZconfig::test (bool verbose) { zconfig_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qczmq.pri0000664000372000037200000000623313222211156020246 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ include(../common.pri) INCLUDEPATH += $$PWD DEPENDPATH += $$PWD qczmq-uselib:!qczmq-buildlib { LIBS += -L$$QCZMQ_LIBDIR -l$$QCZMQ_LIBNAME } else { HEADERS += \ $$PWD/qczmq.h \ $$PWD/qzactor.h \ $$PWD/qzargs.h \ $$PWD/qzarmour.h \ $$PWD/qzcert.h \ $$PWD/qzcertstore.h \ $$PWD/qzchunk.h \ $$PWD/qzclock.h \ $$PWD/qzconfig.h \ $$PWD/qzdigest.h \ $$PWD/qzdir.h \ $$PWD/qzdirpatch.h \ $$PWD/qzfile.h \ $$PWD/qzframe.h \ $$PWD/qzhash.h \ $$PWD/qzhashx.h \ $$PWD/qziflist.h \ $$PWD/qzlist.h \ $$PWD/qzlistx.h \ $$PWD/qzloop.h \ $$PWD/qzmsg.h \ $$PWD/qzpoller.h \ $$PWD/qzproc.h \ $$PWD/qzsock.h \ $$PWD/qzstr.h \ $$PWD/qzsys.h \ $$PWD/qztimerset.h \ $$PWD/qztrie.h \ $$PWD/qzuuid.h SOURCES += \ $$PWD/qzactor.cpp \ $$PWD/qzargs.cpp \ $$PWD/qzarmour.cpp \ $$PWD/qzcert.cpp \ $$PWD/qzcertstore.cpp \ $$PWD/qzchunk.cpp \ $$PWD/qzclock.cpp \ $$PWD/qzconfig.cpp \ $$PWD/qzdigest.cpp \ $$PWD/qzdir.cpp \ $$PWD/qzdirpatch.cpp \ $$PWD/qzfile.cpp \ $$PWD/qzframe.cpp \ $$PWD/qzhash.cpp \ $$PWD/qzhashx.cpp \ $$PWD/qziflist.cpp \ $$PWD/qzlist.cpp \ $$PWD/qzlistx.cpp \ $$PWD/qzloop.cpp \ $$PWD/qzmsg.cpp \ $$PWD/qzpoller.cpp \ $$PWD/qzproc.cpp \ $$PWD/qzsock.cpp \ $$PWD/qzstr.cpp \ $$PWD/qzsys.cpp \ $$PWD/qztimerset.cpp \ $$PWD/qztrie.cpp \ $$PWD/qzuuid.cpp } win32 { qczmq-buildlib:shared:DEFINES += QT_CZMQ_EXPORT else:qczmq-uselib:DEFINES += QT_CZMQ_IMPORT } ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/qt/src/qzarmour.h0000664000372000037200000000467113222211156020434 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZARMOUR_H #define Q_ZARMOUR_H #include "qczmq.h" class QT_CZMQ_EXPORT QZarmour : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZarmour (zarmour_t *self, QObject *qObjParent = 0); // Create a new zarmour explicit QZarmour (QObject *qObjParent = 0); // Destroy the zarmour ~QZarmour (); // Encode a stream of bytes into an armoured string. Returns the armoured // string, or NULL if there was insufficient memory available to allocate // a new string. QString encode (const byte *data, size_t size); // Decode an armoured string into a chunk. The decoded output is // null-terminated, so it may be treated as a string, if that's what // it was prior to encoding. QZchunk * decode (const QString &data); // Get the mode property. int mode (); // Get printable string for mode. const QString modeStr (); // Set the mode property. void setMode (int mode); // Return true if padding is turned on. bool pad (); // Turn padding on or off. Default is on. void setPad (bool pad); // Get the padding character. char padChar (); // Set the padding character. void setPadChar (char padChar); // Return if splitting output into lines is turned on. Default is off. bool lineBreaks (); // Turn splitting output into lines on or off. void setLineBreaks (bool lineBreaks); // Get the line length used for splitting lines. size_t lineLength (); // Set the line length used for splitting lines. void setLineLength (size_t lineLength); // Print properties of object void print (); // Self test of this class. static void test (bool verbose); zarmour_t *self; }; #endif // Q_ZARMOUR_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzcertstore.cpp0000664000372000037200000000623213222211156021467 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZcertstore::QZcertstore (zcertstore_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. QZcertstore::QZcertstore (const QString &location, QObject *qObjParent) : QObject (qObjParent) { this->self = zcertstore_new (location.toUtf8().data()); } /// // Destroy a certificate store object in memory. Does not affect anything // stored on disk. QZcertstore::~QZcertstore () { zcertstore_destroy (&self); } /// // Override the default disk loader with a custom loader fn. void QZcertstore::setLoader (zcertstore_loader loader, zcertstore_destructor destructor, void *state) { zcertstore_set_loader (self, loader, destructor, state); } /// // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. QZcert * QZcertstore::lookup (const QString &publicKey) { QZcert *rv = new QZcert (zcertstore_lookup (self, publicKey.toUtf8().data())); return rv; } /// // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. void QZcertstore::insert (QZcert *certP) { zcertstore_insert (self, &certP->self); } /// // Empty certificate hashtable. This wrapper exists to be friendly to bindings, // which don't usually have access to struct internals. void QZcertstore::empty () { zcertstore_empty (self); } /// // Print list of certificates in store to logging facility void QZcertstore::print () { zcertstore_print (self); } /// // Return a list of all the certificates in the store. // The caller takes ownership of the zlistx_t object and is responsible // for destroying it. The caller does not take ownership of the zcert_t // objects. QZlistx * QZcertstore::certs () { QZlistx *rv = new QZlistx (zcertstore_certs (self)); return rv; } /// // Self test of this class void QZcertstore::test (bool verbose) { zcertstore_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzhash.cpp0000664000372000037200000001665513222211156020412 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include "qczmq.h" /// // Copy-construct to return the proper wrapped c types QZhash::QZhash (zhash_t *self, QObject *qObjParent) : QObject (qObjParent) { this->self = self; } /// // Create a new, empty hash container QZhash::QZhash (QObject *qObjParent) : QObject (qObjParent) { this->self = zhash_new (); } /// // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. QZhash* QZhash::unpack (QZframe *frame, QObject *qObjParent) { return new QZhash (zhash_unpack (frame->self), qObjParent); } /// // Destroy a hash container and all items in it QZhash::~QZhash () { zhash_destroy (&self); } /// // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int QZhash::insert (const QString &key, void *item) { int rv = zhash_insert (self, key.toUtf8().data(), item); return rv; } /// // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. void QZhash::update (const QString &key, void *item) { zhash_update (self, key.toUtf8().data(), item); } /// // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void QZhash::deleteNoConflict (const QString &key) { zhash_delete (self, key.toUtf8().data()); } /// // Return the item at the specified key, or null void * QZhash::lookup (const QString &key) { void * rv = zhash_lookup (self, key.toUtf8().data()); return rv; } /// // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int QZhash::rename (const QString &oldKey, const QString &newKey) { int rv = zhash_rename (self, oldKey.toUtf8().data(), newKey.toUtf8().data()); return rv; } /// // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * QZhash::freefn (const QString &key, zhash_free_fn freeFn) { void * rv = zhash_freefn (self, key.toUtf8().data(), freeFn); return rv; } /// // Return the number of keys/items in the hash table size_t QZhash::size () { size_t rv = zhash_size (self); return rv; } /// // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. QZhash * QZhash::dup () { QZhash *rv = new QZhash (zhash_dup (self)); return rv; } /// // Return keys for items in table QZlist * QZhash::keys () { QZlist *rv = new QZlist (zhash_keys (self)); return rv; } /// // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhash_cursor(). NOTE: do NOT modify the table while iterating. void * QZhash::first () { void * rv = zhash_first (self); return rv; } /// // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). To // access the key for this item use zhash_cursor(). NOTE: do NOT modify // the table while iterating. void * QZhash::next () { void * rv = zhash_next (self); return rv; } /// // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const QString QZhash::cursor () { const QString rv = QString (zhash_cursor (self)); return rv; } /// // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void QZhash::comment (const QString ¶m) { zhash_comment (self, "%s", param.toUtf8().data()); } /// // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. QZframe * QZhash::pack () { QZframe *rv = new QZframe (zhash_pack (self)); return rv; } /// // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int QZhash::save (const QString &filename) { int rv = zhash_save (self, filename.toUtf8().data()); return rv; } /// // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int QZhash::load (const QString &filename) { int rv = zhash_load (self, filename.toUtf8().data()); return rv; } /// // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int QZhash::refresh () { int rv = zhash_refresh (self); return rv; } /// // Set hash for automatic value destruction. Note that this assumes that // values are NULL-terminated strings. Do not use with different types. void QZhash::autofree () { zhash_autofree (self); } /// // Self test of this class. void QZhash::test (bool verbose) { zhash_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzdigest.h0000664000372000037200000000343013222211156020376 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZDIGEST_H #define Q_ZDIGEST_H #include "qczmq.h" class QT_CZMQ_EXPORT QZdigest : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZdigest (zdigest_t *self, QObject *qObjParent = 0); // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. explicit QZdigest (QObject *qObjParent = 0); // Destroy a digest object ~QZdigest (); // Add buffer into digest calculation void update (const byte *buffer, size_t length); // Return final digest hash data. If built without crypto support, // returns NULL. const byte * data (); // Return final digest hash size size_t size (); // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. const QString string (); // Self test of this class. static void test (bool verbose); zdigest_t *self; }; #endif // Q_ZDIGEST_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/qt/src/qzloop.h0000664000372000037200000001323413222211156020073 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #ifndef Q_ZLOOP_H #define Q_ZLOOP_H #include "qczmq.h" class QT_CZMQ_EXPORT QZloop : public QObject { Q_OBJECT public: // Copy-construct to return the proper wrapped c types QZloop (zloop_t *self, QObject *qObjParent = 0); // Create a new zloop reactor explicit QZloop (QObject *qObjParent = 0); // Destroy a reactor ~QZloop (); // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. int reader (QZsock *sock, zloop_reader_fn handler, void *arg); // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. void readerEnd (QZsock *sock); // Configure a registered reader to ignore errors. If you do not set this, // then readers that have errors are removed from the reactor silently. void readerSetTolerant (QZsock *sock); // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. int poller (zmq_pollitem_t *item, zloop_fn handler, void *arg); // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. void pollerEnd (zmq_pollitem_t *item); // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. void pollerSetTolerant (zmq_pollitem_t *item); // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. int timer (size_t delay, size_t times, zloop_timer_fn handler, void *arg); // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer). int timerEnd (int timerId); // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. void * ticket (zloop_timer_fn handler, void *arg); // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. void ticketReset (void *handle); // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. void ticketDelete (void *handle); // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. void setTicketDelay (size_t ticketDelay); // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. void setMaxTimers (size_t maxTimers); // Set verbose tracing of reactor on/off. The default verbose setting is // off (false). void setVerbose (bool verbose); // By default the reactor stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void setNonstop (bool nonstop); // Start the reactor. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. int start (); // Self test of this class. static void test (bool verbose); zloop_t *self; }; #endif // Q_ZLOOP_H /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/bindings/ruby/0000775000372000037200000000000013222211156016141 5ustar00travistravis00000000000000czmq-4.1.0/bindings/ruby/Rakefile0000664000372000037200000000016113222211156017604 0ustar00travistravis00000000000000 require 'rspec/core/rake_task' task :default => :test # Run tests. RSpec::Core::RakeTask.new :test do |c| end czmq-4.1.0/bindings/ruby/spec/0000775000372000037200000000000013222211156017073 5ustar00travistravis00000000000000czmq-4.1.0/bindings/ruby/spec/spec_helper.rb0000664000372000037200000000030713222211156021711 0ustar00travistravis00000000000000 require 'czmq/ffi' RSpec.configure do |c| # Enable 'should' syntax c.expect_with(:rspec) { |c| c.syntax = [:should, :expect] } c.mock_with(:rspec) { |c| c.syntax = [:should, :expect] } end czmq-4.1.0/bindings/ruby/spec/ffi_spec.rb0000664000372000037200000000132013222211156021172 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ require 'spec_helper' describe ::CZMQ::FFI do it { should be } end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/0000775000372000037200000000000013222211156016707 5ustar00travistravis00000000000000czmq-4.1.0/bindings/ruby/lib/czmq/0000775000372000037200000000000013222211156017661 5ustar00travistravis00000000000000czmq-4.1.0/bindings/ruby/lib/czmq/ffi.rb0000664000372000037200000015252013222211156020757 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ require 'ffi' require_relative 'ffi/version' module CZMQ module FFI module LibC extend ::FFI::Library ffi_lib ::FFI::Platform::LIBC attach_function :free, [ :pointer ], :void, blocking: true end extend ::FFI::Library def self.available? @available end begin lib_name = 'libczmq' lib_dirs = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64'] env_name = "#{lib_name.upcase}_PATH" lib_dirs = [*ENV[env_name].split(':'), *lib_dirs] if ENV[env_name] lib_paths = lib_dirs.map { |path| "#{path}/#{lib_name}.#{::FFI::Platform::LIBSUFFIX}" } ffi_lib lib_paths + [lib_name] @available = true rescue LoadError warn "" warn "WARNING: ::CZMQ::FFI is not available without libczmq." warn "" @available = false end def self.attach_function(name, *rest) super rescue ::FFI::NotFoundError define_singleton_method name do |*| raise NotImplementedError, "The function #{name}() is not provided by the CZMQ library installed. Upgrade the library or compile it with --enable-drafts." end return unless $VERBOSE || $DEBUG warn "The function #{name}() is not provided by the installed CZMQ library." end if available? opts = { blocking: true # only necessary on MRI to deal with the GIL. } attach_function :zactor_new, [:pointer, :pointer], :pointer, **opts attach_function :zactor_destroy, [:pointer], :void, **opts attach_function :zactor_send, [:pointer, :pointer], :int, **opts attach_function :zactor_recv, [:pointer], :pointer, **opts attach_function :zactor_is, [:pointer], :bool, **opts attach_function :zactor_resolve, [:pointer], :pointer, **opts attach_function :zactor_sock, [:pointer], :pointer, **opts attach_function :zactor_set_destructor, [:pointer, :pointer], :void, **opts attach_function :zactor_test, [:bool], :void, **opts require_relative 'ffi/zactor' attach_function :zargs_new, [:int, :pointer], :pointer, **opts attach_function :zargs_destroy, [:pointer], :void, **opts attach_function :zargs_progname, [:pointer], :string, **opts attach_function :zargs_arguments, [:pointer], :size_t, **opts attach_function :zargs_first, [:pointer], :string, **opts attach_function :zargs_next, [:pointer], :string, **opts attach_function :zargs_param_first, [:pointer], :string, **opts attach_function :zargs_param_next, [:pointer], :string, **opts attach_function :zargs_param_name, [:pointer], :string, **opts attach_function :zargs_param_lookup, [:pointer, :string], :string, **opts attach_function :zargs_param_lookupx, [:pointer, :string, :varargs], :string, **opts attach_function :zargs_has_help, [:pointer], :bool, **opts attach_function :zargs_param_empty, [:string], :bool, **opts attach_function :zargs_print, [:pointer], :void, **opts attach_function :zargs_test, [:bool], :void, **opts require_relative 'ffi/zargs' attach_function :zarmour_new, [], :pointer, **opts attach_function :zarmour_destroy, [:pointer], :void, **opts attach_function :zarmour_encode, [:pointer, :pointer, :size_t], :pointer, **opts attach_function :zarmour_decode, [:pointer, :string], :pointer, **opts attach_function :zarmour_mode, [:pointer], :int, **opts attach_function :zarmour_mode_str, [:pointer], :string, **opts attach_function :zarmour_set_mode, [:pointer, :int], :void, **opts attach_function :zarmour_pad, [:pointer], :bool, **opts attach_function :zarmour_set_pad, [:pointer, :bool], :void, **opts attach_function :zarmour_pad_char, [:pointer], :pointer, **opts attach_function :zarmour_set_pad_char, [:pointer, :pointer], :void, **opts attach_function :zarmour_line_breaks, [:pointer], :bool, **opts attach_function :zarmour_set_line_breaks, [:pointer, :bool], :void, **opts attach_function :zarmour_line_length, [:pointer], :size_t, **opts attach_function :zarmour_set_line_length, [:pointer, :size_t], :void, **opts attach_function :zarmour_print, [:pointer], :void, **opts attach_function :zarmour_test, [:bool], :void, **opts require_relative 'ffi/zarmour' attach_function :zcert_new, [], :pointer, **opts attach_function :zcert_new_from, [:pointer, :pointer], :pointer, **opts attach_function :zcert_new_from_txt, [:string, :string], :pointer, **opts attach_function :zcert_load, [:string], :pointer, **opts attach_function :zcert_destroy, [:pointer], :void, **opts attach_function :zcert_public_key, [:pointer], :pointer, **opts attach_function :zcert_secret_key, [:pointer], :pointer, **opts attach_function :zcert_public_txt, [:pointer], :string, **opts attach_function :zcert_secret_txt, [:pointer], :string, **opts attach_function :zcert_set_meta, [:pointer, :string, :string, :varargs], :void, **opts attach_function :zcert_unset_meta, [:pointer, :string], :void, **opts attach_function :zcert_meta, [:pointer, :string], :string, **opts attach_function :zcert_meta_keys, [:pointer], :pointer, **opts attach_function :zcert_save, [:pointer, :string], :int, **opts attach_function :zcert_save_public, [:pointer, :string], :int, **opts attach_function :zcert_save_secret, [:pointer, :string], :int, **opts attach_function :zcert_apply, [:pointer, :pointer], :void, **opts attach_function :zcert_dup, [:pointer], :pointer, **opts attach_function :zcert_eq, [:pointer, :pointer], :bool, **opts attach_function :zcert_print, [:pointer], :void, **opts attach_function :zcert_test, [:bool], :void, **opts require_relative 'ffi/zcert' attach_function :zcertstore_new, [:string], :pointer, **opts attach_function :zcertstore_destroy, [:pointer], :void, **opts attach_function :zcertstore_set_loader, [:pointer, :pointer, :pointer, :pointer], :void, **opts attach_function :zcertstore_lookup, [:pointer, :string], :pointer, **opts attach_function :zcertstore_insert, [:pointer, :pointer], :void, **opts attach_function :zcertstore_empty, [:pointer], :void, **opts attach_function :zcertstore_print, [:pointer], :void, **opts attach_function :zcertstore_certs, [:pointer], :pointer, **opts attach_function :zcertstore_test, [:bool], :void, **opts require_relative 'ffi/zcertstore' attach_function :zchunk_new, [:pointer, :size_t], :pointer, **opts attach_function :zchunk_destroy, [:pointer], :void, **opts attach_function :zchunk_resize, [:pointer, :size_t], :void, **opts attach_function :zchunk_size, [:pointer], :size_t, **opts attach_function :zchunk_max_size, [:pointer], :size_t, **opts attach_function :zchunk_data, [:pointer], :pointer, **opts attach_function :zchunk_set, [:pointer, :pointer, :size_t], :size_t, **opts attach_function :zchunk_fill, [:pointer, :char, :size_t], :size_t, **opts attach_function :zchunk_append, [:pointer, :pointer, :size_t], :size_t, **opts attach_function :zchunk_extend, [:pointer, :pointer, :size_t], :size_t, **opts attach_function :zchunk_consume, [:pointer, :pointer], :size_t, **opts attach_function :zchunk_exhausted, [:pointer], :bool, **opts attach_function :zchunk_read, [:pointer, :size_t], :pointer, **opts attach_function :zchunk_write, [:pointer, :pointer], :int, **opts attach_function :zchunk_slurp, [:string, :size_t], :pointer, **opts attach_function :zchunk_dup, [:pointer], :pointer, **opts attach_function :zchunk_strhex, [:pointer], :pointer, **opts attach_function :zchunk_strdup, [:pointer], :pointer, **opts attach_function :zchunk_streq, [:pointer, :string], :bool, **opts attach_function :zchunk_pack, [:pointer], :pointer, **opts attach_function :zchunk_unpack, [:pointer], :pointer, **opts attach_function :zchunk_digest, [:pointer], :string, **opts attach_function :zchunk_fprint, [:pointer, :pointer], :void, **opts attach_function :zchunk_print, [:pointer], :void, **opts attach_function :zchunk_is, [:pointer], :bool, **opts attach_function :zchunk_test, [:bool], :void, **opts require_relative 'ffi/zchunk' attach_function :zclock_sleep, [:int], :void, **opts attach_function :zclock_time, [], :pointer, **opts attach_function :zclock_mono, [], :pointer, **opts attach_function :zclock_usecs, [], :pointer, **opts attach_function :zclock_timestr, [], :pointer, **opts attach_function :zclock_test, [:bool], :void, **opts require_relative 'ffi/zclock' attach_function :zconfig_new, [:string, :pointer], :pointer, **opts attach_function :zconfig_load, [:string], :pointer, **opts attach_function :zconfig_loadf, [:string, :varargs], :pointer, **opts attach_function :zconfig_destroy, [:pointer], :void, **opts attach_function :zconfig_name, [:pointer], :pointer, **opts attach_function :zconfig_value, [:pointer], :pointer, **opts attach_function :zconfig_put, [:pointer, :string, :string], :void, **opts attach_function :zconfig_putf, [:pointer, :string, :string, :varargs], :void, **opts attach_function :zconfig_get, [:pointer, :string, :string], :pointer, **opts attach_function :zconfig_set_name, [:pointer, :string], :void, **opts attach_function :zconfig_set_value, [:pointer, :string, :varargs], :void, **opts attach_function :zconfig_child, [:pointer], :pointer, **opts attach_function :zconfig_next, [:pointer], :pointer, **opts attach_function :zconfig_locate, [:pointer, :string], :pointer, **opts attach_function :zconfig_at_depth, [:pointer, :int], :pointer, **opts attach_function :zconfig_execute, [:pointer, :pointer, :pointer], :int, **opts attach_function :zconfig_set_comment, [:pointer, :string, :varargs], :void, **opts attach_function :zconfig_comments, [:pointer], :pointer, **opts attach_function :zconfig_save, [:pointer, :string], :int, **opts attach_function :zconfig_savef, [:pointer, :string, :varargs], :int, **opts attach_function :zconfig_filename, [:pointer], :string, **opts attach_function :zconfig_reload, [:pointer], :int, **opts attach_function :zconfig_chunk_load, [:pointer], :pointer, **opts attach_function :zconfig_chunk_save, [:pointer], :pointer, **opts attach_function :zconfig_str_load, [:string], :pointer, **opts attach_function :zconfig_str_save, [:pointer], :pointer, **opts attach_function :zconfig_has_changed, [:pointer], :bool, **opts attach_function :zconfig_remove_subtree, [:pointer], :void, **opts attach_function :zconfig_remove, [:pointer], :void, **opts attach_function :zconfig_fprint, [:pointer, :pointer], :void, **opts attach_function :zconfig_print, [:pointer], :void, **opts attach_function :zconfig_test, [:bool], :void, **opts require_relative 'ffi/zconfig' attach_function :zdigest_new, [], :pointer, **opts attach_function :zdigest_destroy, [:pointer], :void, **opts attach_function :zdigest_update, [:pointer, :pointer, :size_t], :void, **opts attach_function :zdigest_data, [:pointer], :pointer, **opts attach_function :zdigest_size, [:pointer], :size_t, **opts attach_function :zdigest_string, [:pointer], :pointer, **opts attach_function :zdigest_test, [:bool], :void, **opts require_relative 'ffi/zdigest' attach_function :zdir_new, [:string, :string], :pointer, **opts attach_function :zdir_destroy, [:pointer], :void, **opts attach_function :zdir_path, [:pointer], :string, **opts attach_function :zdir_modified, [:pointer], :pointer, **opts attach_function :zdir_cursize, [:pointer], :pointer, **opts attach_function :zdir_count, [:pointer], :size_t, **opts attach_function :zdir_list, [:pointer], :pointer, **opts attach_function :zdir_remove, [:pointer, :bool], :void, **opts attach_function :zdir_diff, [:pointer, :pointer, :string], :pointer, **opts attach_function :zdir_resync, [:pointer, :string], :pointer, **opts attach_function :zdir_cache, [:pointer], :pointer, **opts attach_function :zdir_fprint, [:pointer, :pointer, :int], :void, **opts attach_function :zdir_print, [:pointer, :int], :void, **opts attach_function :zdir_watch, [:pointer, :pointer], :void, **opts attach_function :zdir_test, [:bool], :void, **opts require_relative 'ffi/zdir' attach_function :zdir_patch_new, [:string, :pointer, :int, :string], :pointer, **opts attach_function :zdir_patch_destroy, [:pointer], :void, **opts attach_function :zdir_patch_dup, [:pointer], :pointer, **opts attach_function :zdir_patch_path, [:pointer], :string, **opts attach_function :zdir_patch_file, [:pointer], :pointer, **opts attach_function :zdir_patch_op, [:pointer], :int, **opts attach_function :zdir_patch_vpath, [:pointer], :string, **opts attach_function :zdir_patch_digest_set, [:pointer], :void, **opts attach_function :zdir_patch_digest, [:pointer], :string, **opts attach_function :zdir_patch_test, [:bool], :void, **opts require_relative 'ffi/zdir_patch' attach_function :zfile_new, [:string, :string], :pointer, **opts attach_function :zfile_tmp, [], :pointer, **opts attach_function :zfile_destroy, [:pointer], :void, **opts attach_function :zfile_dup, [:pointer], :pointer, **opts attach_function :zfile_filename, [:pointer, :string], :string, **opts attach_function :zfile_restat, [:pointer], :void, **opts attach_function :zfile_modified, [:pointer], :pointer, **opts attach_function :zfile_cursize, [:pointer], :pointer, **opts attach_function :zfile_is_directory, [:pointer], :bool, **opts attach_function :zfile_is_regular, [:pointer], :bool, **opts attach_function :zfile_is_readable, [:pointer], :bool, **opts attach_function :zfile_is_writeable, [:pointer], :bool, **opts attach_function :zfile_is_stable, [:pointer], :bool, **opts attach_function :zfile_has_changed, [:pointer], :bool, **opts attach_function :zfile_remove, [:pointer], :void, **opts attach_function :zfile_input, [:pointer], :int, **opts attach_function :zfile_output, [:pointer], :int, **opts attach_function :zfile_read, [:pointer, :size_t, :pointer], :pointer, **opts attach_function :zfile_eof, [:pointer], :bool, **opts attach_function :zfile_write, [:pointer, :pointer, :pointer], :int, **opts attach_function :zfile_readln, [:pointer], :string, **opts attach_function :zfile_close, [:pointer], :void, **opts attach_function :zfile_handle, [:pointer], :pointer, **opts attach_function :zfile_digest, [:pointer], :string, **opts attach_function :zfile_test, [:bool], :void, **opts require_relative 'ffi/zfile' attach_function :zframe_new, [:pointer, :size_t], :pointer, **opts attach_function :zframe_new_empty, [], :pointer, **opts attach_function :zframe_from, [:string], :pointer, **opts attach_function :zframe_recv, [:pointer], :pointer, **opts attach_function :zframe_destroy, [:pointer], :void, **opts attach_function :zframe_send, [:pointer, :pointer, :int], :int, **opts attach_function :zframe_size, [:pointer], :size_t, **opts attach_function :zframe_data, [:pointer], :pointer, **opts attach_function :zframe_meta, [:pointer, :string], :string, **opts attach_function :zframe_dup, [:pointer], :pointer, **opts attach_function :zframe_strhex, [:pointer], :pointer, **opts attach_function :zframe_strdup, [:pointer], :pointer, **opts attach_function :zframe_streq, [:pointer, :string], :bool, **opts attach_function :zframe_more, [:pointer], :int, **opts attach_function :zframe_set_more, [:pointer, :int], :void, **opts attach_function :zframe_routing_id, [:pointer], :uint32, **opts attach_function :zframe_set_routing_id, [:pointer, :uint32], :void, **opts attach_function :zframe_group, [:pointer], :string, **opts attach_function :zframe_set_group, [:pointer, :string], :int, **opts attach_function :zframe_eq, [:pointer, :pointer], :bool, **opts attach_function :zframe_reset, [:pointer, :pointer, :size_t], :void, **opts attach_function :zframe_print, [:pointer, :string], :void, **opts attach_function :zframe_is, [:pointer], :bool, **opts attach_function :zframe_test, [:bool], :void, **opts require_relative 'ffi/zframe' attach_function :zhash_new, [], :pointer, **opts attach_function :zhash_unpack, [:pointer], :pointer, **opts attach_function :zhash_destroy, [:pointer], :void, **opts attach_function :zhash_insert, [:pointer, :string, :pointer], :int, **opts attach_function :zhash_update, [:pointer, :string, :pointer], :void, **opts attach_function :zhash_delete, [:pointer, :string], :void, **opts attach_function :zhash_lookup, [:pointer, :string], :pointer, **opts attach_function :zhash_rename, [:pointer, :string, :string], :int, **opts attach_function :zhash_freefn, [:pointer, :string, :pointer], :pointer, **opts attach_function :zhash_size, [:pointer], :size_t, **opts attach_function :zhash_dup, [:pointer], :pointer, **opts attach_function :zhash_keys, [:pointer], :pointer, **opts attach_function :zhash_first, [:pointer], :pointer, **opts attach_function :zhash_next, [:pointer], :pointer, **opts attach_function :zhash_cursor, [:pointer], :string, **opts attach_function :zhash_comment, [:pointer, :string, :varargs], :void, **opts attach_function :zhash_pack, [:pointer], :pointer, **opts attach_function :zhash_save, [:pointer, :string], :int, **opts attach_function :zhash_load, [:pointer, :string], :int, **opts attach_function :zhash_refresh, [:pointer], :int, **opts attach_function :zhash_autofree, [:pointer], :void, **opts attach_function :zhash_test, [:bool], :void, **opts require_relative 'ffi/zhash' attach_function :zhashx_new, [], :pointer, **opts attach_function :zhashx_unpack, [:pointer], :pointer, **opts attach_function :zhashx_unpack_own, [:pointer, :pointer], :pointer, **opts attach_function :zhashx_destroy, [:pointer], :void, **opts attach_function :zhashx_insert, [:pointer, :pointer, :pointer], :int, **opts attach_function :zhashx_update, [:pointer, :pointer, :pointer], :void, **opts attach_function :zhashx_delete, [:pointer, :pointer], :void, **opts attach_function :zhashx_purge, [:pointer], :void, **opts attach_function :zhashx_lookup, [:pointer, :pointer], :pointer, **opts attach_function :zhashx_rename, [:pointer, :pointer, :pointer], :int, **opts attach_function :zhashx_freefn, [:pointer, :pointer, :pointer], :pointer, **opts attach_function :zhashx_size, [:pointer], :size_t, **opts attach_function :zhashx_keys, [:pointer], :pointer, **opts attach_function :zhashx_values, [:pointer], :pointer, **opts attach_function :zhashx_first, [:pointer], :pointer, **opts attach_function :zhashx_next, [:pointer], :pointer, **opts attach_function :zhashx_cursor, [:pointer], :pointer, **opts attach_function :zhashx_comment, [:pointer, :string, :varargs], :void, **opts attach_function :zhashx_save, [:pointer, :string], :int, **opts attach_function :zhashx_load, [:pointer, :string], :int, **opts attach_function :zhashx_refresh, [:pointer], :int, **opts attach_function :zhashx_pack, [:pointer], :pointer, **opts attach_function :zhashx_pack_own, [:pointer, :pointer], :pointer, **opts attach_function :zhashx_dup, [:pointer], :pointer, **opts attach_function :zhashx_set_destructor, [:pointer, :pointer], :void, **opts attach_function :zhashx_set_duplicator, [:pointer, :pointer], :void, **opts attach_function :zhashx_set_key_destructor, [:pointer, :pointer], :void, **opts attach_function :zhashx_set_key_duplicator, [:pointer, :pointer], :void, **opts attach_function :zhashx_set_key_comparator, [:pointer, :pointer], :void, **opts attach_function :zhashx_set_key_hasher, [:pointer, :pointer], :void, **opts attach_function :zhashx_dup_v2, [:pointer], :pointer, **opts attach_function :zhashx_test, [:bool], :void, **opts require_relative 'ffi/zhashx' attach_function :ziflist_new, [], :pointer, **opts attach_function :ziflist_destroy, [:pointer], :void, **opts attach_function :ziflist_reload, [:pointer], :void, **opts attach_function :ziflist_size, [:pointer], :size_t, **opts attach_function :ziflist_first, [:pointer], :string, **opts attach_function :ziflist_next, [:pointer], :string, **opts attach_function :ziflist_address, [:pointer], :string, **opts attach_function :ziflist_broadcast, [:pointer], :string, **opts attach_function :ziflist_netmask, [:pointer], :string, **opts attach_function :ziflist_print, [:pointer], :void, **opts attach_function :ziflist_new_ipv6, [], :pointer, **opts attach_function :ziflist_reload_ipv6, [:pointer], :void, **opts attach_function :ziflist_is_ipv6, [:pointer], :bool, **opts attach_function :ziflist_test, [:bool], :void, **opts require_relative 'ffi/ziflist' attach_function :zlist_new, [], :pointer, **opts attach_function :zlist_destroy, [:pointer], :void, **opts attach_function :zlist_first, [:pointer], :pointer, **opts attach_function :zlist_next, [:pointer], :pointer, **opts attach_function :zlist_last, [:pointer], :pointer, **opts attach_function :zlist_head, [:pointer], :pointer, **opts attach_function :zlist_tail, [:pointer], :pointer, **opts attach_function :zlist_item, [:pointer], :pointer, **opts attach_function :zlist_append, [:pointer, :pointer], :int, **opts attach_function :zlist_push, [:pointer, :pointer], :int, **opts attach_function :zlist_pop, [:pointer], :pointer, **opts attach_function :zlist_exists, [:pointer, :pointer], :bool, **opts attach_function :zlist_remove, [:pointer, :pointer], :void, **opts attach_function :zlist_dup, [:pointer], :pointer, **opts attach_function :zlist_purge, [:pointer], :void, **opts attach_function :zlist_size, [:pointer], :size_t, **opts attach_function :zlist_sort, [:pointer, :pointer], :void, **opts attach_function :zlist_autofree, [:pointer], :void, **opts attach_function :zlist_comparefn, [:pointer, :pointer], :void, **opts attach_function :zlist_freefn, [:pointer, :pointer, :pointer, :bool], :pointer, **opts attach_function :zlist_test, [:bool], :void, **opts require_relative 'ffi/zlist' attach_function :zlistx_new, [], :pointer, **opts attach_function :zlistx_destroy, [:pointer], :void, **opts attach_function :zlistx_add_start, [:pointer, :pointer], :pointer, **opts attach_function :zlistx_add_end, [:pointer, :pointer], :pointer, **opts attach_function :zlistx_size, [:pointer], :size_t, **opts attach_function :zlistx_head, [:pointer], :pointer, **opts attach_function :zlistx_tail, [:pointer], :pointer, **opts attach_function :zlistx_first, [:pointer], :pointer, **opts attach_function :zlistx_next, [:pointer], :pointer, **opts attach_function :zlistx_prev, [:pointer], :pointer, **opts attach_function :zlistx_last, [:pointer], :pointer, **opts attach_function :zlistx_item, [:pointer], :pointer, **opts attach_function :zlistx_cursor, [:pointer], :pointer, **opts attach_function :zlistx_handle_item, [:pointer], :pointer, **opts attach_function :zlistx_find, [:pointer, :pointer], :pointer, **opts attach_function :zlistx_detach, [:pointer, :pointer], :pointer, **opts attach_function :zlistx_detach_cur, [:pointer], :pointer, **opts attach_function :zlistx_delete, [:pointer, :pointer], :int, **opts attach_function :zlistx_move_start, [:pointer, :pointer], :void, **opts attach_function :zlistx_move_end, [:pointer, :pointer], :void, **opts attach_function :zlistx_purge, [:pointer], :void, **opts attach_function :zlistx_sort, [:pointer], :void, **opts attach_function :zlistx_insert, [:pointer, :pointer, :bool], :pointer, **opts attach_function :zlistx_reorder, [:pointer, :pointer, :bool], :void, **opts attach_function :zlistx_dup, [:pointer], :pointer, **opts attach_function :zlistx_set_destructor, [:pointer, :pointer], :void, **opts attach_function :zlistx_set_duplicator, [:pointer, :pointer], :void, **opts attach_function :zlistx_set_comparator, [:pointer, :pointer], :void, **opts attach_function :zlistx_test, [:bool], :void, **opts require_relative 'ffi/zlistx' attach_function :zloop_new, [], :pointer, **opts attach_function :zloop_destroy, [:pointer], :void, **opts attach_function :zloop_reader, [:pointer, :pointer, :pointer, :pointer], :int, **opts attach_function :zloop_reader_end, [:pointer, :pointer], :void, **opts attach_function :zloop_reader_set_tolerant, [:pointer, :pointer], :void, **opts attach_function :zloop_poller, [:pointer, :pointer, :pointer, :pointer], :int, **opts attach_function :zloop_poller_end, [:pointer, :pointer], :void, **opts attach_function :zloop_poller_set_tolerant, [:pointer, :pointer], :void, **opts attach_function :zloop_timer, [:pointer, :size_t, :size_t, :pointer, :pointer], :int, **opts attach_function :zloop_timer_end, [:pointer, :int], :int, **opts attach_function :zloop_ticket, [:pointer, :pointer, :pointer], :pointer, **opts attach_function :zloop_ticket_reset, [:pointer, :pointer], :void, **opts attach_function :zloop_ticket_delete, [:pointer, :pointer], :void, **opts attach_function :zloop_set_ticket_delay, [:pointer, :size_t], :void, **opts attach_function :zloop_set_max_timers, [:pointer, :size_t], :void, **opts attach_function :zloop_set_verbose, [:pointer, :bool], :void, **opts attach_function :zloop_set_nonstop, [:pointer, :bool], :void, **opts attach_function :zloop_start, [:pointer], :int, **opts attach_function :zloop_test, [:bool], :void, **opts require_relative 'ffi/zloop' attach_function :zmsg_new, [], :pointer, **opts attach_function :zmsg_recv, [:pointer], :pointer, **opts attach_function :zmsg_load, [:pointer], :pointer, **opts attach_function :zmsg_decode, [:pointer], :pointer, **opts attach_function :zmsg_new_signal, [:char], :pointer, **opts attach_function :zmsg_destroy, [:pointer], :void, **opts attach_function :zmsg_send, [:pointer, :pointer], :int, **opts attach_function :zmsg_sendm, [:pointer, :pointer], :int, **opts attach_function :zmsg_size, [:pointer], :size_t, **opts attach_function :zmsg_content_size, [:pointer], :size_t, **opts attach_function :zmsg_routing_id, [:pointer], :uint32, **opts attach_function :zmsg_set_routing_id, [:pointer, :uint32], :void, **opts attach_function :zmsg_prepend, [:pointer, :pointer], :int, **opts attach_function :zmsg_append, [:pointer, :pointer], :int, **opts attach_function :zmsg_pop, [:pointer], :pointer, **opts attach_function :zmsg_pushmem, [:pointer, :pointer, :size_t], :int, **opts attach_function :zmsg_addmem, [:pointer, :pointer, :size_t], :int, **opts attach_function :zmsg_pushstr, [:pointer, :string], :int, **opts attach_function :zmsg_addstr, [:pointer, :string], :int, **opts attach_function :zmsg_pushstrf, [:pointer, :string, :varargs], :int, **opts attach_function :zmsg_addstrf, [:pointer, :string, :varargs], :int, **opts attach_function :zmsg_popstr, [:pointer], :pointer, **opts attach_function :zmsg_addmsg, [:pointer, :pointer], :int, **opts attach_function :zmsg_popmsg, [:pointer], :pointer, **opts attach_function :zmsg_remove, [:pointer, :pointer], :void, **opts attach_function :zmsg_first, [:pointer], :pointer, **opts attach_function :zmsg_next, [:pointer], :pointer, **opts attach_function :zmsg_last, [:pointer], :pointer, **opts attach_function :zmsg_save, [:pointer, :pointer], :int, **opts attach_function :zmsg_encode, [:pointer], :pointer, **opts attach_function :zmsg_dup, [:pointer], :pointer, **opts attach_function :zmsg_print, [:pointer], :void, **opts attach_function :zmsg_eq, [:pointer, :pointer], :bool, **opts attach_function :zmsg_signal, [:pointer], :int, **opts attach_function :zmsg_is, [:pointer], :bool, **opts attach_function :zmsg_test, [:bool], :void, **opts require_relative 'ffi/zmsg' attach_function :zpoller_new, [:pointer, :varargs], :pointer, **opts attach_function :zpoller_destroy, [:pointer], :void, **opts attach_function :zpoller_add, [:pointer, :pointer], :int, **opts attach_function :zpoller_remove, [:pointer, :pointer], :int, **opts attach_function :zpoller_set_nonstop, [:pointer, :bool], :void, **opts attach_function :zpoller_wait, [:pointer, :int], :pointer, **opts attach_function :zpoller_expired, [:pointer], :bool, **opts attach_function :zpoller_terminated, [:pointer], :bool, **opts attach_function :zpoller_test, [:bool], :void, **opts require_relative 'ffi/zpoller' attach_function :zproc_new, [], :pointer, **opts attach_function :zproc_destroy, [:pointer], :void, **opts attach_function :zproc_set_args, [:pointer, :pointer], :void, **opts attach_function :zproc_set_env, [:pointer, :pointer], :void, **opts attach_function :zproc_set_stdin, [:pointer, :pointer], :void, **opts attach_function :zproc_set_stdout, [:pointer, :pointer], :void, **opts attach_function :zproc_set_stderr, [:pointer, :pointer], :void, **opts attach_function :zproc_stdin, [:pointer], :pointer, **opts attach_function :zproc_stdout, [:pointer], :pointer, **opts attach_function :zproc_stderr, [:pointer], :pointer, **opts attach_function :zproc_run, [:pointer], :int, **opts attach_function :zproc_returncode, [:pointer], :int, **opts attach_function :zproc_pid, [:pointer], :int, **opts attach_function :zproc_running, [:pointer], :bool, **opts attach_function :zproc_wait, [:pointer, :bool], :int, **opts attach_function :zproc_actor, [:pointer], :pointer, **opts attach_function :zproc_kill, [:pointer, :int], :void, **opts attach_function :zproc_set_verbose, [:pointer, :bool], :void, **opts attach_function :zproc_czmq_version, [], :int, **opts attach_function :zproc_interrupted, [], :bool, **opts attach_function :zproc_has_curve, [], :bool, **opts attach_function :zproc_hostname, [], :pointer, **opts attach_function :zproc_daemonize, [:string], :void, **opts attach_function :zproc_run_as, [:string, :string, :string], :void, **opts attach_function :zproc_set_io_threads, [:size_t], :void, **opts attach_function :zproc_set_max_sockets, [:size_t], :void, **opts attach_function :zproc_set_biface, [:string], :void, **opts attach_function :zproc_biface, [], :string, **opts attach_function :zproc_set_log_ident, [:string], :void, **opts attach_function :zproc_set_log_sender, [:string], :void, **opts attach_function :zproc_set_log_system, [:bool], :void, **opts attach_function :zproc_log_error, [:string, :varargs], :void, **opts attach_function :zproc_log_warning, [:string, :varargs], :void, **opts attach_function :zproc_log_notice, [:string, :varargs], :void, **opts attach_function :zproc_log_info, [:string, :varargs], :void, **opts attach_function :zproc_log_debug, [:string, :varargs], :void, **opts attach_function :zproc_test, [:bool], :void, **opts require_relative 'ffi/zproc' attach_function :zsock_new, [:int], :pointer, **opts attach_function :zsock_new_pub, [:string], :pointer, **opts attach_function :zsock_new_sub, [:string, :string], :pointer, **opts attach_function :zsock_new_req, [:string], :pointer, **opts attach_function :zsock_new_rep, [:string], :pointer, **opts attach_function :zsock_new_dealer, [:string], :pointer, **opts attach_function :zsock_new_router, [:string], :pointer, **opts attach_function :zsock_new_push, [:string], :pointer, **opts attach_function :zsock_new_pull, [:string], :pointer, **opts attach_function :zsock_new_xpub, [:string], :pointer, **opts attach_function :zsock_new_xsub, [:string], :pointer, **opts attach_function :zsock_new_pair, [:string], :pointer, **opts attach_function :zsock_new_stream, [:string], :pointer, **opts attach_function :zsock_new_server, [:string], :pointer, **opts attach_function :zsock_new_client, [:string], :pointer, **opts attach_function :zsock_new_radio, [:string], :pointer, **opts attach_function :zsock_new_dish, [:string], :pointer, **opts attach_function :zsock_new_gather, [:string], :pointer, **opts attach_function :zsock_new_scatter, [:string], :pointer, **opts attach_function :zsock_destroy, [:pointer], :void, **opts attach_function :zsock_bind, [:pointer, :string, :varargs], :int, **opts attach_function :zsock_endpoint, [:pointer], :string, **opts attach_function :zsock_unbind, [:pointer, :string, :varargs], :int, **opts attach_function :zsock_connect, [:pointer, :string, :varargs], :int, **opts attach_function :zsock_disconnect, [:pointer, :string, :varargs], :int, **opts attach_function :zsock_attach, [:pointer, :string, :bool], :int, **opts attach_function :zsock_type_str, [:pointer], :string, **opts attach_function :zsock_send, [:pointer, :string, :varargs], :int, **opts attach_function :zsock_vsend, [:pointer, :string, :pointer], :int, **opts attach_function :zsock_recv, [:pointer, :string, :varargs], :int, **opts attach_function :zsock_vrecv, [:pointer, :string, :pointer], :int, **opts attach_function :zsock_bsend, [:pointer, :string, :varargs], :int, **opts attach_function :zsock_brecv, [:pointer, :string, :varargs], :int, **opts attach_function :zsock_routing_id, [:pointer], :uint32, **opts attach_function :zsock_set_routing_id, [:pointer, :uint32], :void, **opts attach_function :zsock_set_unbounded, [:pointer], :void, **opts attach_function :zsock_signal, [:pointer, :char], :int, **opts attach_function :zsock_wait, [:pointer], :int, **opts attach_function :zsock_flush, [:pointer], :void, **opts attach_function :zsock_join, [:pointer, :string], :int, **opts attach_function :zsock_leave, [:pointer, :string], :int, **opts attach_function :zsock_is, [:pointer], :bool, **opts attach_function :zsock_resolve, [:pointer], :pointer, **opts attach_function :zsock_heartbeat_ivl, [:pointer], :int, **opts attach_function :zsock_set_heartbeat_ivl, [:pointer, :int], :void, **opts attach_function :zsock_heartbeat_ttl, [:pointer], :int, **opts attach_function :zsock_set_heartbeat_ttl, [:pointer, :int], :void, **opts attach_function :zsock_heartbeat_timeout, [:pointer], :int, **opts attach_function :zsock_set_heartbeat_timeout, [:pointer, :int], :void, **opts attach_function :zsock_use_fd, [:pointer], :int, **opts attach_function :zsock_set_use_fd, [:pointer, :int], :void, **opts attach_function :zsock_set_xpub_manual, [:pointer, :int], :void, **opts attach_function :zsock_set_xpub_welcome_msg, [:pointer, :string], :void, **opts attach_function :zsock_set_stream_notify, [:pointer, :int], :void, **opts attach_function :zsock_invert_matching, [:pointer], :int, **opts attach_function :zsock_set_invert_matching, [:pointer, :int], :void, **opts attach_function :zsock_set_xpub_verboser, [:pointer, :int], :void, **opts attach_function :zsock_connect_timeout, [:pointer], :int, **opts attach_function :zsock_set_connect_timeout, [:pointer, :int], :void, **opts attach_function :zsock_tcp_maxrt, [:pointer], :int, **opts attach_function :zsock_set_tcp_maxrt, [:pointer, :int], :void, **opts attach_function :zsock_thread_safe, [:pointer], :int, **opts attach_function :zsock_multicast_maxtpdu, [:pointer], :int, **opts attach_function :zsock_set_multicast_maxtpdu, [:pointer, :int], :void, **opts attach_function :zsock_vmci_buffer_size, [:pointer], :int, **opts attach_function :zsock_set_vmci_buffer_size, [:pointer, :int], :void, **opts attach_function :zsock_vmci_buffer_min_size, [:pointer], :int, **opts attach_function :zsock_set_vmci_buffer_min_size, [:pointer, :int], :void, **opts attach_function :zsock_vmci_buffer_max_size, [:pointer], :int, **opts attach_function :zsock_set_vmci_buffer_max_size, [:pointer, :int], :void, **opts attach_function :zsock_vmci_connect_timeout, [:pointer], :int, **opts attach_function :zsock_set_vmci_connect_timeout, [:pointer, :int], :void, **opts attach_function :zsock_tos, [:pointer], :int, **opts attach_function :zsock_set_tos, [:pointer, :int], :void, **opts attach_function :zsock_set_router_handover, [:pointer, :int], :void, **opts attach_function :zsock_set_connect_rid, [:pointer, :string], :void, **opts attach_function :zsock_set_connect_rid_bin, [:pointer, :pointer], :void, **opts attach_function :zsock_handshake_ivl, [:pointer], :int, **opts attach_function :zsock_set_handshake_ivl, [:pointer, :int], :void, **opts attach_function :zsock_socks_proxy, [:pointer], :pointer, **opts attach_function :zsock_set_socks_proxy, [:pointer, :string], :void, **opts attach_function :zsock_set_xpub_nodrop, [:pointer, :int], :void, **opts attach_function :zsock_set_router_mandatory, [:pointer, :int], :void, **opts attach_function :zsock_set_probe_router, [:pointer, :int], :void, **opts attach_function :zsock_set_req_relaxed, [:pointer, :int], :void, **opts attach_function :zsock_set_req_correlate, [:pointer, :int], :void, **opts attach_function :zsock_set_conflate, [:pointer, :int], :void, **opts attach_function :zsock_zap_domain, [:pointer], :pointer, **opts attach_function :zsock_set_zap_domain, [:pointer, :string], :void, **opts attach_function :zsock_mechanism, [:pointer], :int, **opts attach_function :zsock_plain_server, [:pointer], :int, **opts attach_function :zsock_set_plain_server, [:pointer, :int], :void, **opts attach_function :zsock_plain_username, [:pointer], :pointer, **opts attach_function :zsock_set_plain_username, [:pointer, :string], :void, **opts attach_function :zsock_plain_password, [:pointer], :pointer, **opts attach_function :zsock_set_plain_password, [:pointer, :string], :void, **opts attach_function :zsock_curve_server, [:pointer], :int, **opts attach_function :zsock_set_curve_server, [:pointer, :int], :void, **opts attach_function :zsock_curve_publickey, [:pointer], :pointer, **opts attach_function :zsock_set_curve_publickey, [:pointer, :string], :void, **opts attach_function :zsock_set_curve_publickey_bin, [:pointer, :pointer], :void, **opts attach_function :zsock_curve_secretkey, [:pointer], :pointer, **opts attach_function :zsock_set_curve_secretkey, [:pointer, :string], :void, **opts attach_function :zsock_set_curve_secretkey_bin, [:pointer, :pointer], :void, **opts attach_function :zsock_curve_serverkey, [:pointer], :pointer, **opts attach_function :zsock_set_curve_serverkey, [:pointer, :string], :void, **opts attach_function :zsock_set_curve_serverkey_bin, [:pointer, :pointer], :void, **opts attach_function :zsock_gssapi_server, [:pointer], :int, **opts attach_function :zsock_set_gssapi_server, [:pointer, :int], :void, **opts attach_function :zsock_gssapi_plaintext, [:pointer], :int, **opts attach_function :zsock_set_gssapi_plaintext, [:pointer, :int], :void, **opts attach_function :zsock_gssapi_principal, [:pointer], :pointer, **opts attach_function :zsock_set_gssapi_principal, [:pointer, :string], :void, **opts attach_function :zsock_gssapi_service_principal, [:pointer], :pointer, **opts attach_function :zsock_set_gssapi_service_principal, [:pointer, :string], :void, **opts attach_function :zsock_ipv6, [:pointer], :int, **opts attach_function :zsock_set_ipv6, [:pointer, :int], :void, **opts attach_function :zsock_immediate, [:pointer], :int, **opts attach_function :zsock_set_immediate, [:pointer, :int], :void, **opts attach_function :zsock_sndhwm, [:pointer], :int, **opts attach_function :zsock_set_sndhwm, [:pointer, :int], :void, **opts attach_function :zsock_rcvhwm, [:pointer], :int, **opts attach_function :zsock_set_rcvhwm, [:pointer, :int], :void, **opts attach_function :zsock_maxmsgsize, [:pointer], :int, **opts attach_function :zsock_set_maxmsgsize, [:pointer, :int], :void, **opts attach_function :zsock_multicast_hops, [:pointer], :int, **opts attach_function :zsock_set_multicast_hops, [:pointer, :int], :void, **opts attach_function :zsock_set_xpub_verbose, [:pointer, :int], :void, **opts attach_function :zsock_tcp_keepalive, [:pointer], :int, **opts attach_function :zsock_set_tcp_keepalive, [:pointer, :int], :void, **opts attach_function :zsock_tcp_keepalive_idle, [:pointer], :int, **opts attach_function :zsock_set_tcp_keepalive_idle, [:pointer, :int], :void, **opts attach_function :zsock_tcp_keepalive_cnt, [:pointer], :int, **opts attach_function :zsock_set_tcp_keepalive_cnt, [:pointer, :int], :void, **opts attach_function :zsock_tcp_keepalive_intvl, [:pointer], :int, **opts attach_function :zsock_set_tcp_keepalive_intvl, [:pointer, :int], :void, **opts attach_function :zsock_tcp_accept_filter, [:pointer], :pointer, **opts attach_function :zsock_set_tcp_accept_filter, [:pointer, :string], :void, **opts attach_function :zsock_last_endpoint, [:pointer], :pointer, **opts attach_function :zsock_set_router_raw, [:pointer, :int], :void, **opts attach_function :zsock_ipv4only, [:pointer], :int, **opts attach_function :zsock_set_ipv4only, [:pointer, :int], :void, **opts attach_function :zsock_set_delay_attach_on_connect, [:pointer, :int], :void, **opts attach_function :zsock_hwm, [:pointer], :int, **opts attach_function :zsock_set_hwm, [:pointer, :int], :void, **opts attach_function :zsock_swap, [:pointer], :int, **opts attach_function :zsock_set_swap, [:pointer, :int], :void, **opts attach_function :zsock_affinity, [:pointer], :int, **opts attach_function :zsock_set_affinity, [:pointer, :int], :void, **opts attach_function :zsock_identity, [:pointer], :pointer, **opts attach_function :zsock_set_identity, [:pointer, :string], :void, **opts attach_function :zsock_rate, [:pointer], :int, **opts attach_function :zsock_set_rate, [:pointer, :int], :void, **opts attach_function :zsock_recovery_ivl, [:pointer], :int, **opts attach_function :zsock_set_recovery_ivl, [:pointer, :int], :void, **opts attach_function :zsock_recovery_ivl_msec, [:pointer], :int, **opts attach_function :zsock_set_recovery_ivl_msec, [:pointer, :int], :void, **opts attach_function :zsock_mcast_loop, [:pointer], :int, **opts attach_function :zsock_set_mcast_loop, [:pointer, :int], :void, **opts attach_function :zsock_rcvtimeo, [:pointer], :int, **opts attach_function :zsock_set_rcvtimeo, [:pointer, :int], :void, **opts attach_function :zsock_sndtimeo, [:pointer], :int, **opts attach_function :zsock_set_sndtimeo, [:pointer, :int], :void, **opts attach_function :zsock_sndbuf, [:pointer], :int, **opts attach_function :zsock_set_sndbuf, [:pointer, :int], :void, **opts attach_function :zsock_rcvbuf, [:pointer], :int, **opts attach_function :zsock_set_rcvbuf, [:pointer, :int], :void, **opts attach_function :zsock_linger, [:pointer], :int, **opts attach_function :zsock_set_linger, [:pointer, :int], :void, **opts attach_function :zsock_reconnect_ivl, [:pointer], :int, **opts attach_function :zsock_set_reconnect_ivl, [:pointer, :int], :void, **opts attach_function :zsock_reconnect_ivl_max, [:pointer], :int, **opts attach_function :zsock_set_reconnect_ivl_max, [:pointer, :int], :void, **opts attach_function :zsock_backlog, [:pointer], :int, **opts attach_function :zsock_set_backlog, [:pointer, :int], :void, **opts attach_function :zsock_set_subscribe, [:pointer, :string], :void, **opts attach_function :zsock_set_unsubscribe, [:pointer, :string], :void, **opts attach_function :zsock_type, [:pointer], :int, **opts attach_function :zsock_rcvmore, [:pointer], :int, **opts attach_function :zsock_fd, [:pointer], (::FFI::Platform.unix? ? :int : :uint64), **opts attach_function :zsock_events, [:pointer], :int, **opts attach_function :zsock_test, [:bool], :void, **opts require_relative 'ffi/zsock' attach_function :zstr_recv, [:pointer], :pointer, **opts attach_function :zstr_recvx, [:pointer, :pointer, :varargs], :int, **opts attach_function :zstr_recv_compress, [:pointer], :pointer, **opts attach_function :zstr_send, [:pointer, :string], :int, **opts attach_function :zstr_sendm, [:pointer, :string], :int, **opts attach_function :zstr_sendf, [:pointer, :string, :varargs], :int, **opts attach_function :zstr_sendfm, [:pointer, :string, :varargs], :int, **opts attach_function :zstr_sendx, [:pointer, :string, :varargs], :int, **opts attach_function :zstr_send_compress, [:pointer, :string], :int, **opts attach_function :zstr_sendm_compress, [:pointer, :string], :int, **opts attach_function :zstr_str, [:pointer], :pointer, **opts attach_function :zstr_free, [:pointer], :void, **opts attach_function :zstr_test, [:bool], :void, **opts require_relative 'ffi/zstr' attach_function :zsys_init, [], :pointer, **opts attach_function :zsys_shutdown, [], :void, **opts attach_function :zsys_socket, [:int, :string, :size_t], :pointer, **opts attach_function :zsys_close, [:pointer, :string, :size_t], :int, **opts attach_function :zsys_sockname, [:int], :pointer, **opts attach_function :zsys_create_pipe, [:pointer], :pointer, **opts attach_function :zsys_handler_set, [:pointer], :void, **opts attach_function :zsys_handler_reset, [], :void, **opts attach_function :zsys_catch_interrupts, [], :void, **opts attach_function :zsys_file_exists, [:string], :bool, **opts attach_function :zsys_file_modified, [:string], :pointer, **opts attach_function :zsys_file_mode, [:string], :int, **opts attach_function :zsys_file_delete, [:string], :int, **opts attach_function :zsys_file_stable, [:string], :bool, **opts attach_function :zsys_dir_create, [:string, :varargs], :int, **opts attach_function :zsys_dir_delete, [:string, :varargs], :int, **opts attach_function :zsys_dir_change, [:string], :int, **opts attach_function :zsys_file_mode_private, [], :void, **opts attach_function :zsys_file_mode_default, [], :void, **opts attach_function :zsys_version, [:pointer, :pointer, :pointer], :void, **opts attach_function :zsys_sprintf, [:string, :varargs], :pointer, **opts attach_function :zsys_vprintf, [:string, :pointer], :pointer, **opts attach_function :zsys_udp_new, [:bool], (::FFI::Platform.unix? ? :int : :uint64), **opts attach_function :zsys_udp_close, [(::FFI::Platform.unix? ? :int : :uint64)], :int, **opts attach_function :zsys_udp_send, [(::FFI::Platform.unix? ? :int : :uint64), :pointer, :pointer, :int], :int, **opts attach_function :zsys_udp_recv, [(::FFI::Platform.unix? ? :int : :uint64), :pointer, :int], :pointer, **opts attach_function :zsys_socket_error, [:string], :void, **opts attach_function :zsys_hostname, [], :pointer, **opts attach_function :zsys_daemonize, [:string], :int, **opts attach_function :zsys_run_as, [:string, :string, :string], :int, **opts attach_function :zsys_has_curve, [], :bool, **opts attach_function :zsys_set_io_threads, [:size_t], :void, **opts attach_function :zsys_set_thread_sched_policy, [:int], :void, **opts attach_function :zsys_set_thread_priority, [:int], :void, **opts attach_function :zsys_set_max_sockets, [:size_t], :void, **opts attach_function :zsys_socket_limit, [], :size_t, **opts attach_function :zsys_set_max_msgsz, [:int], :void, **opts attach_function :zsys_max_msgsz, [], :int, **opts attach_function :zsys_set_file_stable_age_msec, [:pointer], :void, **opts attach_function :zsys_file_stable_age_msec, [], :pointer, **opts attach_function :zsys_set_linger, [:size_t], :void, **opts attach_function :zsys_set_sndhwm, [:size_t], :void, **opts attach_function :zsys_set_rcvhwm, [:size_t], :void, **opts attach_function :zsys_set_pipehwm, [:size_t], :void, **opts attach_function :zsys_pipehwm, [], :size_t, **opts attach_function :zsys_set_ipv6, [:int], :void, **opts attach_function :zsys_ipv6, [], :int, **opts attach_function :zsys_set_interface, [:string], :void, **opts attach_function :zsys_interface, [], :string, **opts attach_function :zsys_set_ipv6_address, [:string], :void, **opts attach_function :zsys_ipv6_address, [], :string, **opts attach_function :zsys_set_ipv6_mcast_address, [:string], :void, **opts attach_function :zsys_ipv6_mcast_address, [], :string, **opts attach_function :zsys_set_auto_use_fd, [:int], :void, **opts attach_function :zsys_auto_use_fd, [], :int, **opts attach_function :zsys_set_logident, [:string], :void, **opts attach_function :zsys_set_logstream, [:pointer], :void, **opts attach_function :zsys_set_logsender, [:string], :void, **opts attach_function :zsys_set_logsystem, [:bool], :void, **opts attach_function :zsys_error, [:string, :varargs], :void, **opts attach_function :zsys_warning, [:string, :varargs], :void, **opts attach_function :zsys_notice, [:string, :varargs], :void, **opts attach_function :zsys_info, [:string, :varargs], :void, **opts attach_function :zsys_debug, [:string, :varargs], :void, **opts attach_function :zsys_test, [:bool], :void, **opts require_relative 'ffi/zsys' attach_function :ztimerset_new, [], :pointer, **opts attach_function :ztimerset_destroy, [:pointer], :void, **opts attach_function :ztimerset_add, [:pointer, :size_t, :pointer, :pointer], :int, **opts attach_function :ztimerset_cancel, [:pointer, :int], :int, **opts attach_function :ztimerset_set_interval, [:pointer, :int, :size_t], :int, **opts attach_function :ztimerset_reset, [:pointer, :int], :int, **opts attach_function :ztimerset_timeout, [:pointer], :int, **opts attach_function :ztimerset_execute, [:pointer], :int, **opts attach_function :ztimerset_test, [:bool], :void, **opts require_relative 'ffi/ztimerset' attach_function :ztrie_new, [:pointer], :pointer, **opts attach_function :ztrie_destroy, [:pointer], :void, **opts attach_function :ztrie_insert_route, [:pointer, :string, :pointer, :pointer], :int, **opts attach_function :ztrie_remove_route, [:pointer, :string], :int, **opts attach_function :ztrie_matches, [:pointer, :string], :bool, **opts attach_function :ztrie_hit_data, [:pointer], :pointer, **opts attach_function :ztrie_hit_parameter_count, [:pointer], :size_t, **opts attach_function :ztrie_hit_parameters, [:pointer], :pointer, **opts attach_function :ztrie_hit_asterisk_match, [:pointer], :string, **opts attach_function :ztrie_print, [:pointer], :void, **opts attach_function :ztrie_test, [:bool], :void, **opts require_relative 'ffi/ztrie' attach_function :zuuid_new, [], :pointer, **opts attach_function :zuuid_new_from, [:pointer], :pointer, **opts attach_function :zuuid_destroy, [:pointer], :void, **opts attach_function :zuuid_set, [:pointer, :pointer], :void, **opts attach_function :zuuid_set_str, [:pointer, :string], :int, **opts attach_function :zuuid_data, [:pointer], :pointer, **opts attach_function :zuuid_size, [:pointer], :size_t, **opts attach_function :zuuid_str, [:pointer], :string, **opts attach_function :zuuid_str_canonical, [:pointer], :string, **opts attach_function :zuuid_export, [:pointer, :pointer], :void, **opts attach_function :zuuid_eq, [:pointer, :pointer], :bool, **opts attach_function :zuuid_neq, [:pointer, :pointer], :bool, **opts attach_function :zuuid_dup, [:pointer], :pointer, **opts attach_function :zuuid_test, [:bool], :void, **opts require_relative 'ffi/zuuid' end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/0000775000372000037200000000000013222211156020425 5ustar00travistravis00000000000000czmq-4.1.0/bindings/ruby/lib/czmq/ffi/ztrie.rb0000664000372000037200000001644413222211156022120 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # simple trie for tokenizable strings # @note This class is 100% generated using zproject. class Ztrie # Raised when one tries to use an instance of {Ztrie} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.ztrie_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new callback of the following type: # Callback function for ztrie_node to destroy node data. # typedef void (ztrie_destroy_data_fn) ( # void **data); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.destroy_data_fn ::FFI::Function.new :void, [:pointer], blocking: true do |data| result = yield data result end end # Creates a new ztrie. # @param delimiter [::FFI::Pointer, #to_ptr] # @return [CZMQ::Ztrie] def self.new(delimiter) ptr = ::CZMQ::FFI.ztrie_new(delimiter) __new ptr end # Destroy the ztrie. # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.ztrie_destroy(self_p) result end # Inserts a new route into the tree and attaches the data. Returns -1 # if the route already exists, otherwise 0. This method takes ownership of # the provided data if a destroy_data_fn is provided. # # @param path [String, #to_s, nil] # @param data [::FFI::Pointer, #to_ptr] # @param destroy_data_fn [::FFI::Pointer, #to_ptr] # @return [Integer] def insert_route(path, data, destroy_data_fn) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ztrie_insert_route(self_p, path, data, destroy_data_fn) result end # Removes a route from the trie and destroys its data. Returns -1 if the # route does not exists, otherwise 0. # the start of the list call zlist_first (). Advances the cursor. # # @param path [String, #to_s, nil] # @return [Integer] def remove_route(path) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ztrie_remove_route(self_p, path) result end # Returns true if the path matches a route in the tree, otherwise false. # # @param path [String, #to_s, nil] # @return [Boolean] def matches(path) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ztrie_matches(self_p, path) result end # Returns the data of a matched route from last ztrie_matches. If the path # did not match, returns NULL. Do not delete the data as it's owned by # ztrie. # # @return [::FFI::Pointer] def hit_data() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ztrie_hit_data(self_p) result end # Returns the count of parameters that a matched route has. # # @return [Integer] def hit_parameter_count() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ztrie_hit_parameter_count(self_p) result end # Returns the parameters of a matched route with named regexes from last # ztrie_matches. If the path did not match or the route did not contain any # named regexes, returns NULL. # # @return [Zhashx] def hit_parameters() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ztrie_hit_parameters(self_p) result = Zhashx.__new result, false result end # Returns the asterisk matched part of a route, if there has been no match # or no asterisk match, returns NULL. # # @return [String] def hit_asterisk_match() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ztrie_hit_asterisk_match(self_p) result end # Print the trie # # @return [void] def print() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ztrie_print(self_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.ztrie_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zcert.rb0000664000372000037200000002260713222211156022110 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # work with CURVE security certificates # @note This class is 100% generated using zproject. class Zcert # Raised when one tries to use an instance of {Zcert} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zcert_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create and initialize a new certificate in memory # @return [CZMQ::Zcert] def self.new() ptr = ::CZMQ::FFI.zcert_new() __new ptr end # Accepts public/secret key pair from caller # @param public_key [::FFI::Pointer, #to_ptr] # @param secret_key [::FFI::Pointer, #to_ptr] # @return [CZMQ::Zcert] def self.new_from(public_key, secret_key) ptr = ::CZMQ::FFI.zcert_new_from(public_key, secret_key) __new ptr end # Accepts public/secret key text pair from caller # @param public_txt [String, #to_s, nil] # @param secret_txt [String, #to_s, nil] # @return [CZMQ::Zcert] def self.new_from_txt(public_txt, secret_txt) ptr = ::CZMQ::FFI.zcert_new_from_txt(public_txt, secret_txt) __new ptr end # Load certificate from file # @param filename [String, #to_s, nil] # @return [CZMQ::Zcert] def self.load(filename) ptr = ::CZMQ::FFI.zcert_load(filename) __new ptr end # Destroy a certificate in memory # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zcert_destroy(self_p) result end # Return public part of key pair as 32-byte binary string # # @return [::FFI::Pointer] def public_key() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_public_key(self_p) result end # Return secret part of key pair as 32-byte binary string # # @return [::FFI::Pointer] def secret_key() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_secret_key(self_p) result end # Return public part of key pair as Z85 armored string # # @return [String] def public_txt() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_public_txt(self_p) result end # Return secret part of key pair as Z85 armored string # # @return [String] def secret_txt() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_secret_txt(self_p) result end # Set certificate metadata from formatted string. # # @param name [String, #to_s, nil] # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def set_meta(name, format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_set_meta(self_p, name, format, *args) result end # Unset certificate metadata. # # @param name [String, #to_s, nil] # @return [void] def unset_meta(name) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_unset_meta(self_p, name) result end # Get metadata value from certificate; if the metadata value doesn't # exist, returns NULL. # # @param name [String, #to_s, nil] # @return [String] def meta(name) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_meta(self_p, name) result end # Get list of metadata fields from certificate. Caller is responsible for # destroying list. Caller should not modify the values of list items. # # @return [Zlist] def meta_keys() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_meta_keys(self_p) result = Zlist.__new result, false result end # Save full certificate (public + secret) to file for persistent storage # This creates one public file and one secret file (filename + "_secret"). # # @param filename [String, #to_s, nil] # @return [Integer] def save(filename) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_save(self_p, filename) result end # Save public certificate only to file for persistent storage # # @param filename [String, #to_s, nil] # @return [Integer] def save_public(filename) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_save_public(self_p, filename) result end # Save secret certificate only to file for persistent storage # # @param filename [String, #to_s, nil] # @return [Integer] def save_secret(filename) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_save_secret(self_p, filename) result end # Apply certificate to socket, i.e. use for CURVE security on socket. # If certificate was loaded from public file, the secret key will be # undefined, and this certificate will not work successfully. # # @param socket [::FFI::Pointer, #to_ptr] # @return [void] def apply(socket) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_apply(self_p, socket) result end # Return copy of certificate; if certificate is NULL or we exhausted # heap memory, returns NULL. # # @return [Zcert] def dup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_dup(self_p) result = Zcert.__new result, true result end # Return true if two certificates have the same keys # # @param compare [Zcert, #__ptr] # @return [Boolean] def eq(compare) raise DestroyedError unless @ptr self_p = @ptr compare = compare.__ptr if compare result = ::CZMQ::FFI.zcert_eq(self_p, compare) result end # Print certificate contents to stdout # # @return [void] def print() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcert_print(self_p) result end # Self test of this class # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zcert_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zconfig.rb0000664000372000037200000003451213222211156022416 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # work with config files written in rfc.zeromq.org/spec:4/ZPL. # @note This class is 100% generated using zproject. class Zconfig # Raised when one tries to use an instance of {Zconfig} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zconfig_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new callback of the following type: # # typedef int (zconfig_fct) ( # zconfig_t *self, void *arg, int level); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.fct ::FFI::Function.new :int, [:pointer, :pointer, :int], blocking: true do |self_, arg, level| self_ = Zconfig.__new self_, false result = yield self_, arg, level result = Integer(result) result end end # Create new config item # @param name [String, #to_s, nil] # @param parent [Zconfig, #__ptr] # @return [CZMQ::Zconfig] def self.new(name, parent) parent = parent.__ptr if parent ptr = ::CZMQ::FFI.zconfig_new(name, parent) __new ptr end # Load a config tree from a specified ZPL text file; returns a zconfig_t # reference for the root, if the file exists and is readable. Returns NULL # if the file does not exist. # @param filename [String, #to_s, nil] # @return [CZMQ::Zconfig] def self.load(filename) ptr = ::CZMQ::FFI.zconfig_load(filename) __new ptr end # Equivalent to zconfig_load, taking a format string instead of a fixed # filename. # @param format [String, #to_s, nil] # @param args [Array] # @return [CZMQ::Zconfig] def self.loadf(format, *args) ptr = ::CZMQ::FFI.zconfig_loadf(format, *args) __new ptr end # Destroy a config item and all its children # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zconfig_destroy(self_p) result end # Return name of config item # # @return [::FFI::Pointer] def name() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_name(self_p) result end # Return value of config item # # @return [::FFI::Pointer] def value() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_value(self_p) result end # Insert or update configuration key with value # # @param path [String, #to_s, nil] # @param value [String, #to_s, nil] # @return [void] def put(path, value) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_put(self_p, path, value) result end # Equivalent to zconfig_put, accepting a format specifier and variable # argument list, instead of a single string value. # # @param path [String, #to_s, nil] # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def putf(path, format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_putf(self_p, path, format, *args) result end # Get value for config item into a string value; leading slash is optional # and ignored. # # @param path [String, #to_s, nil] # @param default_value [String, #to_s, nil] # @return [::FFI::Pointer] def get(path, default_value) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_get(self_p, path, default_value) result end # Set config item name, name may be NULL # # @param name [String, #to_s, nil] # @return [void] def set_name(name) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_set_name(self_p, name) result end # Set new value for config item. The new value may be a string, a printf # format, or NULL. Note that if string may possibly contain '%', or if it # comes from an insecure source, you must use '%s' as the format, followed # by the string. # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def set_value(format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_set_value(self_p, format, *args) result end # Find our first child, if any # # @return [Zconfig] def child() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_child(self_p) result = Zconfig.__new result, false result end # Find our first sibling, if any # # @return [Zconfig] def next() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_next(self_p) result = Zconfig.__new result, false result end # Find a config item along a path; leading slash is optional and ignored. # # @param path [String, #to_s, nil] # @return [Zconfig] def locate(path) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_locate(self_p, path) result = Zconfig.__new result, false result end # Locate the last config item at a specified depth # # @param level [Integer, #to_int, #to_i] # @return [Zconfig] def at_depth(level) raise DestroyedError unless @ptr self_p = @ptr level = Integer(level) result = ::CZMQ::FFI.zconfig_at_depth(self_p, level) result = Zconfig.__new result, false result end # Execute a callback for each config item in the tree; returns zero if # successful, else -1. # # @param handler [::FFI::Pointer, #to_ptr] # @param arg [::FFI::Pointer, #to_ptr] # @return [Integer] def execute(handler, arg) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_execute(self_p, handler, arg) result end # Add comment to config item before saving to disk. You can add as many # comment lines as you like. If you use a null format, all comments are # deleted. # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def set_comment(format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_set_comment(self_p, format, *args) result end # Return comments of config item, as zlist. # # @return [Zlist] def comments() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_comments(self_p) result = Zlist.__new result, false result end # Save a config tree to a specified ZPL text file, where a filename # "-" means dump to standard output. # # @param filename [String, #to_s, nil] # @return [Integer] def save(filename) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_save(self_p, filename) result end # Equivalent to zconfig_save, taking a format string instead of a fixed # filename. # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def savef(format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_savef(self_p, format, *args) result end # Report filename used during zconfig_load, or NULL if none # # @return [String] def filename() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_filename(self_p) result end # Reload config tree from same file that it was previously loaded from. # Returns 0 if OK, -1 if there was an error (and then does not change # existing data). # # @param self_p [#__ptr_give_ref] # @return [Integer] def self.reload(self_p) self_p = self_p.__ptr_give_ref result = ::CZMQ::FFI.zconfig_reload(self_p) result end # Load a config tree from a memory chunk # # @param chunk [Zchunk, #__ptr] # @return [Zconfig] def self.chunk_load(chunk) chunk = chunk.__ptr if chunk result = ::CZMQ::FFI.zconfig_chunk_load(chunk) result = Zconfig.__new result, false result end # Save a config tree to a new memory chunk # # @return [Zchunk] def chunk_save() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_chunk_save(self_p) result = Zchunk.__new result, false result end # Load a config tree from a null-terminated string # # @param string [String, #to_s, nil] # @return [Zconfig] def self.str_load(string) result = ::CZMQ::FFI.zconfig_str_load(string) result = Zconfig.__new result, true result end # Save a config tree to a new null terminated string # # @return [::FFI::AutoPointer] def str_save() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_str_save(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Return true if a configuration tree was loaded from a file and that # file has changed in since the tree was loaded. # # @return [Boolean] def has_changed() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_has_changed(self_p) result end # Destroy subtree (all children) # # @return [void] def remove_subtree() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_remove_subtree(self_p) result end # Destroy node and subtree (all children) # # @param self_p [#__ptr_give_ref] # @return [void] def self.remove(self_p) self_p = self_p.__ptr_give_ref result = ::CZMQ::FFI.zconfig_remove(self_p) result end # Print the config file to open stream # # @param file [::FFI::Pointer, #to_ptr] # @return [void] def fprint(file) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_fprint(self_p, file) result end # Print properties of object # # @return [void] def print() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zconfig_print(self_p) result end # Self test of this class # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zconfig_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zmsg.rb0000664000372000037200000004152413222211156021740 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # working with multipart messages # @note This class is 100% generated using zproject. class Zmsg # Raised when one tries to use an instance of {Zmsg} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zmsg_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new empty message object # @return [CZMQ::Zmsg] def self.new() ptr = ::CZMQ::FFI.zmsg_new() __new ptr end # Receive message from socket, returns zmsg_t object or NULL if the recv # was interrupted. Does a blocking recv. If you want to not block then use # the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input # before receiving. # @param source [::FFI::Pointer, #to_ptr] # @return [CZMQ::Zmsg] def self.recv(source) ptr = ::CZMQ::FFI.zmsg_recv(source) __new ptr end # Load/append an open file into new message, return the message. # Returns NULL if the message could not be loaded. # @param file [::FFI::Pointer, #to_ptr] # @return [CZMQ::Zmsg] def self.load(file) ptr = ::CZMQ::FFI.zmsg_load(file) __new ptr end # Decodes a serialized message frame created by zmsg_encode () and returns # a new zmsg_t object. Returns NULL if the frame was badly formatted or # there was insufficient memory to work. # @param frame [Zframe, #__ptr] # @return [CZMQ::Zmsg] def self.decode(frame) frame = frame.__ptr if frame ptr = ::CZMQ::FFI.zmsg_decode(frame) __new ptr end # Generate a signal message encoding the given status. A signal is a short # message carrying a 1-byte success/failure code (by convention, 0 means # OK). Signals are encoded to be distinguishable from "normal" messages. # @param status [Integer, #to_int, #to_i] # @return [CZMQ::Zmsg] def self.new_signal(status) status = Integer(status) ptr = ::CZMQ::FFI.zmsg_new_signal(status) __new ptr end # Destroy a message object and all frames it contains # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zmsg_destroy(self_p) result end # Send message to destination socket, and destroy the message after sending # it successfully. If the message has no frames, sends nothing but destroys # the message anyhow. Nullifies the caller's reference to the message (as # it is a destructor). # # @param self_p [#__ptr_give_ref] # @param dest [::FFI::Pointer, #to_ptr] # @return [Integer] def self.send(self_p, dest) self_p = self_p.__ptr_give_ref result = ::CZMQ::FFI.zmsg_send(self_p, dest) result end # Send message to destination socket as part of a multipart sequence, and # destroy the message after sending it successfully. Note that after a # zmsg_sendm, you must call zmsg_send or another method that sends a final # message part. If the message has no frames, sends nothing but destroys # the message anyhow. Nullifies the caller's reference to the message (as # it is a destructor). # # @param self_p [#__ptr_give_ref] # @param dest [::FFI::Pointer, #to_ptr] # @return [Integer] def self.sendm(self_p, dest) self_p = self_p.__ptr_give_ref result = ::CZMQ::FFI.zmsg_sendm(self_p, dest) result end # Return size of message, i.e. number of frames (0 or more). # # @return [Integer] def size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_size(self_p) result end # Return total size of all frames in message. # # @return [Integer] def content_size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_content_size(self_p) result end # Return message routing ID, if the message came from a ZMQ_SERVER socket. # Else returns zero. # # @return [Integer] def routing_id() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_routing_id(self_p) result end # Set routing ID on message. This is used if/when the message is sent to a # ZMQ_SERVER socket. # # @param routing_id [Integer, #to_int, #to_i] # @return [void] def set_routing_id(routing_id) raise DestroyedError unless @ptr self_p = @ptr routing_id = Integer(routing_id) result = ::CZMQ::FFI.zmsg_set_routing_id(self_p, routing_id) result end # Push frame to the front of the message, i.e. before all other frames. # Message takes ownership of frame, will destroy it when message is sent. # Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not # nullify the caller's frame reference. # # @param frame_p [#__ptr_give_ref] # @return [Integer] def prepend(frame_p) raise DestroyedError unless @ptr self_p = @ptr frame_p = frame_p.__ptr_give_ref result = ::CZMQ::FFI.zmsg_prepend(self_p, frame_p) result end # Add frame to the end of the message, i.e. after all other frames. # Message takes ownership of frame, will destroy it when message is sent. # Returns 0 on success. Deprecates zmsg_add, which did not nullify the # caller's frame reference. # # @param frame_p [#__ptr_give_ref] # @return [Integer] def append(frame_p) raise DestroyedError unless @ptr self_p = @ptr frame_p = frame_p.__ptr_give_ref result = ::CZMQ::FFI.zmsg_append(self_p, frame_p) result end # Remove first frame from message, if any. Returns frame, or NULL. # # @return [Zframe] def pop() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_pop(self_p) result = Zframe.__new result, true result end # Push block of memory to front of message, as a new frame. # Returns 0 on success, -1 on error. # # @param data [::FFI::Pointer, #to_ptr] # @param size [Integer, #to_int, #to_i] # @return [Integer] def pushmem(data, size) raise DestroyedError unless @ptr self_p = @ptr size = Integer(size) result = ::CZMQ::FFI.zmsg_pushmem(self_p, data, size) result end # Add block of memory to the end of the message, as a new frame. # Returns 0 on success, -1 on error. # # @param data [::FFI::Pointer, #to_ptr] # @param size [Integer, #to_int, #to_i] # @return [Integer] def addmem(data, size) raise DestroyedError unless @ptr self_p = @ptr size = Integer(size) result = ::CZMQ::FFI.zmsg_addmem(self_p, data, size) result end # Push string as new frame to front of message. # Returns 0 on success, -1 on error. # # @param string [String, #to_s, nil] # @return [Integer] def pushstr(string) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_pushstr(self_p, string) result end # Push string as new frame to end of message. # Returns 0 on success, -1 on error. # # @param string [String, #to_s, nil] # @return [Integer] def addstr(string) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_addstr(self_p, string) result end # Push formatted string as new frame to front of message. # Returns 0 on success, -1 on error. # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def pushstrf(format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_pushstrf(self_p, format, *args) result end # Push formatted string as new frame to end of message. # Returns 0 on success, -1 on error. # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def addstrf(format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_addstrf(self_p, format, *args) result end # Pop frame off front of message, return as fresh string. If there were # no more frames in the message, returns NULL. # # @return [::FFI::AutoPointer] def popstr() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_popstr(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Push encoded message as a new frame. Message takes ownership of # submessage, so the original is destroyed in this call. Returns 0 on # success, -1 on error. # # @param msg_p [#__ptr_give_ref] # @return [Integer] def addmsg(msg_p) raise DestroyedError unless @ptr self_p = @ptr msg_p = msg_p.__ptr_give_ref result = ::CZMQ::FFI.zmsg_addmsg(self_p, msg_p) result end # Remove first submessage from message, if any. Returns zmsg_t, or NULL if # decoding was not successful. # # @return [Zmsg] def popmsg() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_popmsg(self_p) result = Zmsg.__new result, true result end # Remove specified frame from list, if present. Does not destroy frame. # # @param frame [Zframe, #__ptr] # @return [void] def remove(frame) raise DestroyedError unless @ptr self_p = @ptr frame = frame.__ptr if frame result = ::CZMQ::FFI.zmsg_remove(self_p, frame) result end # Set cursor to first frame in message. Returns frame, or NULL, if the # message is empty. Use this to navigate the frames as a list. # # @return [Zframe] def first() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_first(self_p) result = Zframe.__new result, false result end # Return the next frame. If there are no more frames, returns NULL. To move # to the first frame call zmsg_first(). Advances the cursor. # # @return [Zframe] def next() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_next(self_p) result = Zframe.__new result, false result end # Return the last frame. If there are no frames, returns NULL. # # @return [Zframe] def last() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_last(self_p) result = Zframe.__new result, false result end # Save message to an open file, return 0 if OK, else -1. The message is # saved as a series of frames, each with length and data. Note that the # file is NOT guaranteed to be portable between operating systems, not # versions of CZMQ. The file format is at present undocumented and liable # to arbitrary change. # # @param file [::FFI::Pointer, #to_ptr] # @return [Integer] def save(file) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_save(self_p, file) result end # Serialize multipart message to a single message frame. Use this method # to send structured messages across transports that do not support # multipart data. Allocates and returns a new frame containing the # serialized message. To decode a serialized message frame, use # zmsg_decode (). # # @return [Zframe] def encode() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_encode(self_p) result = Zframe.__new result, true result end # Create copy of message, as new message object. Returns a fresh zmsg_t # object. If message is null, or memory was exhausted, returns null. # # @return [Zmsg] def dup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_dup(self_p) result = Zmsg.__new result, true result end # Send message to zsys log sink (may be stdout, or system facility as # configured by zsys_set_logstream). # # @return [void] def print() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_print(self_p) result end # Return true if the two messages have the same number of frames and each # frame in the first message is identical to the corresponding frame in the # other message. As with zframe_eq, return false if either message is NULL. # # @param other [Zmsg, #__ptr] # @return [Boolean] def eq(other) raise DestroyedError unless @ptr self_p = @ptr other = other.__ptr if other result = ::CZMQ::FFI.zmsg_eq(self_p, other) result end # Return signal value, 0 or greater, if message is a signal, -1 if not. # # @return [Integer] def signal() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zmsg_signal(self_p) result end # Probe the supplied object, and report if it looks like a zmsg_t. # # @param self_ [::FFI::Pointer, #to_ptr] # @return [Boolean] def self.is(self_) result = ::CZMQ::FFI.zmsg_is(self_) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zmsg_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zdir_patch.rb0000664000372000037200000001331113222211156023100 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # work with directory patches # @note This class is 100% generated using zproject. class ZdirPatch # Creates a new file CREATE = 1 # Delete a file DELETE = 2 # Raised when one tries to use an instance of {ZdirPatch} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zdir_patch_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create new patch # @param path [String, #to_s, nil] # @param file [Zfile, #__ptr] # @param op [Integer, #to_int, #to_i] # @param alias_ [String, #to_s, nil] # @return [CZMQ::ZdirPatch] def self.new(path, file, op, alias_) file = file.__ptr if file op = Integer(op) ptr = ::CZMQ::FFI.zdir_patch_new(path, file, op, alias_) __new ptr end # Destroy a patch # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zdir_patch_destroy(self_p) result end # Create copy of a patch. If the patch is null, or memory was exhausted, # returns null. # # @return [ZdirPatch] def dup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_patch_dup(self_p) result = ZdirPatch.__new result, true result end # Return patch file directory path # # @return [String] def path() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_patch_path(self_p) result end # Return patch file item # # @return [Zfile] def file() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_patch_file(self_p) result = Zfile.__new result, false result end # Return operation # # @return [Integer] def op() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_patch_op(self_p) result end # Return patch virtual file path # # @return [String] def vpath() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_patch_vpath(self_p) result end # Calculate hash digest for file (create only) # # @return [void] def digest_set() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_patch_digest_set(self_p) result end # Return hash digest for patch file # # @return [String] def digest() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_patch_digest(self_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zdir_patch_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/version.rb0000664000372000037200000000130313222211156022434 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI VERSION = '4.1.0' end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zargs.rb0000664000372000037200000002007213222211156022101 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # Platform independent command line argument parsing helpers # # There are two kind of elements provided by this class # foo --named-parameter --parameter with_value positional arguments -a gain-parameter # zargs keeps poision only for arguments, parameters are to be accessed like hash. # # It DOES: # * provide easy to use CLASS compatible API for accessing argv # * is platform independent # * provide getopt_long style -- argument, which delimits parameters from arguments # * makes parameters positon independent # # It does NOT # * change argv # * provide a "declarative" way to define command line interface # # In future it SHALL # * hide several formats of command line to one (-Idir, --include=dir, # --include dir are the same from API pov) # @note This class is 100% generated using zproject. class Zargs # Raised when one tries to use an instance of {Zargs} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zargs_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new zargs from command line arguments. # @param argc [Integer, #to_int, #to_i] # @param argv [::FFI::Pointer, #to_ptr] # @return [CZMQ::Zargs] def self.new(argc, argv) argc = Integer(argc) ptr = ::CZMQ::FFI.zargs_new(argc, argv) __new ptr end # Destroy zargs instance. # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zargs_destroy(self_p) result end # Return program name (argv[0]) # # @return [String] def progname() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zargs_progname(self_p) result end # Return number of positional arguments # # @return [Integer] def arguments() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zargs_arguments(self_p) result end # Return first positional argument or NULL # # @return [String] def first() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zargs_first(self_p) result end # Return next positional argument or NULL # # @return [String] def next() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zargs_next(self_p) result end # Return first named parameter value, or NULL if there are no named # parameters, or value for which zargs_param_empty (arg) returns true. # # @return [String] def param_first() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zargs_param_first(self_p) result end # Return next named parameter value, or NULL if there are no named # parameters, or value for which zargs_param_empty (arg) returns true. # # @return [String] def param_next() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zargs_param_next(self_p) result end # Return current parameter name, or NULL if there are no named # parameters. # # @return [String] def param_name() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zargs_param_name(self_p) result end # Return value of named parameter, NULL if no given parameter has # been specified, or special value for wich zargs_param_empty () # returns true. # # @param keys [String, #to_s, nil] # @return [String] def param_lookup(keys) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zargs_param_lookup(self_p, keys) result end # Return value of named parameter(s), NULL if no given parameter has # been specified, or special value for wich zargs_param_empty () # returns true. # # @param keys [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [String] def param_lookupx(keys, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zargs_param_lookupx(self_p, keys, *args) result end # Returns true if there are --help -h arguments # # @return [Boolean] def has_help() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zargs_has_help(self_p) result end # Returns true if parameter did not have a value # # @param arg [String, #to_s, nil] # @return [Boolean] def self.param_empty(arg) result = ::CZMQ::FFI.zargs_param_empty(arg) result end # Print an instance of zargs. # # @return [void] def print() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zargs_print(self_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zargs_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zcertstore.rb0000664000372000037200000001765113222211156023170 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # work with CURVE security certificate stores # @note This class is 100% generated using zproject. class Zcertstore # Raised when one tries to use an instance of {Zcertstore} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zcertstore_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new callback of the following type: # Loaders retrieve certificates from an arbitrary source. # typedef void (zcertstore_loader) ( # zcertstore_t *self); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.loader ::FFI::Function.new :void, [:pointer], blocking: true do |self_| self_ = Zcertstore.__new self_, false result = yield self_ result end end # Create a new callback of the following type: # Destructor for loader state. # typedef void (zcertstore_destructor) ( # void **self_p); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.destructor ::FFI::Function.new :void, [:pointer], blocking: true do |self_p| result = yield self_p result end end # Create a new certificate store from a disk directory, loading and # indexing all certificates in that location. The directory itself may be # absent, and created later, or modified at any time. The certificate store # is automatically refreshed on any zcertstore_lookup() call. If the # location is specified as NULL, creates a pure-memory store, which you # can work with by inserting certificates at runtime. # @param location [String, #to_s, nil] # @return [CZMQ::Zcertstore] def self.new(location) ptr = ::CZMQ::FFI.zcertstore_new(location) __new ptr end # Destroy a certificate store object in memory. Does not affect anything # stored on disk. # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zcertstore_destroy(self_p) result end # Override the default disk loader with a custom loader fn. # # @param loader [::FFI::Pointer, #to_ptr] # @param destructor [::FFI::Pointer, #to_ptr] # @param state [::FFI::Pointer, #to_ptr] # @return [void] def set_loader(loader, destructor, state) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcertstore_set_loader(self_p, loader, destructor, state) result end # Look up certificate by public key, returns zcert_t object if found, # else returns NULL. The public key is provided in Z85 text format. # # @param public_key [String, #to_s, nil] # @return [Zcert] def lookup(public_key) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcertstore_lookup(self_p, public_key) result = Zcert.__new result, false result end # Insert certificate into certificate store in memory. Note that this # does not save the certificate to disk. To do that, use zcert_save() # directly on the certificate. Takes ownership of zcert_t object. # # @param cert_p [#__ptr_give_ref] # @return [void] def insert(cert_p) raise DestroyedError unless @ptr self_p = @ptr cert_p = cert_p.__ptr_give_ref result = ::CZMQ::FFI.zcertstore_insert(self_p, cert_p) result end # Empty certificate hashtable. This wrapper exists to be friendly to bindings, # which don't usually have access to struct internals. # # @return [void] def empty() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcertstore_empty(self_p) result end # Print list of certificates in store to logging facility # # @return [void] def print() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcertstore_print(self_p) result end # Return a list of all the certificates in the store. # The caller takes ownership of the zlistx_t object and is responsible # for destroying it. The caller does not take ownership of the zcert_t # objects. # # @return [Zlistx] def certs() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcertstore_certs(self_p) result = Zlistx.__new result, true result end # Self test of this class # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zcertstore_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zhash.rb0000664000372000037200000003241313222211156022072 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # generic type-free hash container (simple) # @note This class is 100% generated using zproject. class Zhash # Raised when one tries to use an instance of {Zhash} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zhash_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new callback of the following type: # Callback function for zhash_freefn method # typedef void (zhash_free_fn) ( # void *data); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.free_fn ::FFI::Function.new :void, [:pointer], blocking: true do |data| result = yield data result end end # Create a new, empty hash container # @return [CZMQ::Zhash] def self.new() ptr = ::CZMQ::FFI.zhash_new() __new ptr end # Unpack binary frame into a new hash table. Packed data must follow format # defined by zhash_pack. Hash table is set to autofree. An empty frame # unpacks to an empty hash table. # @param frame [Zframe, #__ptr] # @return [CZMQ::Zhash] def self.unpack(frame) frame = frame.__ptr if frame ptr = ::CZMQ::FFI.zhash_unpack(frame) __new ptr end # Destroy a hash container and all items in it # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zhash_destroy(self_p) result end # Insert item into hash table with specified key and item. # If key is already present returns -1 and leaves existing item unchanged # Returns 0 on success. # # @param key [String, #to_s, nil] # @param item [::FFI::Pointer, #to_ptr] # @return [Integer] def insert(key, item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_insert(self_p, key, item) result end # Update item into hash table with specified key and item. # If key is already present, destroys old item and inserts new one. # Use free_fn method to ensure deallocator is properly called on item. # # @param key [String, #to_s, nil] # @param item [::FFI::Pointer, #to_ptr] # @return [void] def update(key, item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_update(self_p, key, item) result end # Remove an item specified by key from the hash table. If there was no such # item, this function does nothing. # # @param key [String, #to_s, nil] # @return [void] def delete(key) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_delete(self_p, key) result end # Return the item at the specified key, or null # # @param key [String, #to_s, nil] # @return [::FFI::Pointer] def lookup(key) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_lookup(self_p, key) result end # Reindexes an item from an old key to a new key. If there was no such # item, does nothing. Returns 0 if successful, else -1. # # @param old_key [String, #to_s, nil] # @param new_key [String, #to_s, nil] # @return [Integer] def rename(old_key, new_key) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_rename(self_p, old_key, new_key) result end # Set a free function for the specified hash table item. When the item is # destroyed, the free function, if any, is called on that item. # Use this when hash items are dynamically allocated, to ensure that # you don't have memory leaks. You can pass 'free' or NULL as a free_fn. # Returns the item, or NULL if there is no such item. # # @param key [String, #to_s, nil] # @param free_fn [::FFI::Pointer, #to_ptr] # @return [::FFI::Pointer] def freefn(key, free_fn) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_freefn(self_p, key, free_fn) result end # Return the number of keys/items in the hash table # # @return [Integer] def size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_size(self_p) result end # Make copy of hash table; if supplied table is null, returns null. # Does not copy items themselves. Rebuilds new table so may be slow on # very large tables. NOTE: only works with item values that are strings # since there's no other way to know how to duplicate the item value. # # @return [Zhash] def dup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_dup(self_p) result = Zhash.__new result, true result end # Return keys for items in table # # @return [Zlist] def keys() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_keys(self_p) result = Zlist.__new result, true result end # Simple iterator; returns first item in hash table, in no given order, # or NULL if the table is empty. This method is simpler to use than the # foreach() method, which is deprecated. To access the key for this item # use zhash_cursor(). NOTE: do NOT modify the table while iterating. # # @return [::FFI::Pointer] def first() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_first(self_p) result end # Simple iterator; returns next item in hash table, in no given order, # or NULL if the last item was already returned. Use this together with # zhash_first() to process all items in a hash table. If you need the # items in sorted order, use zhash_keys() and then zlist_sort(). To # access the key for this item use zhash_cursor(). NOTE: do NOT modify # the table while iterating. # # @return [::FFI::Pointer] def next() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_next(self_p) result end # After a successful first/next method, returns the key for the item that # was returned. This is a constant string that you may not modify or # deallocate, and which lasts as long as the item in the hash. After an # unsuccessful first/next, returns NULL. # # @return [String] def cursor() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_cursor(self_p) result end # Add a comment to hash table before saving to disk. You can add as many # comment lines as you like. These comment lines are discarded when loading # the file. If you use a null format, all comments are deleted. # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def comment(format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_comment(self_p, format, *args) result end # Serialize hash table to a binary frame that can be sent in a message. # The packed format is compatible with the 'dictionary' type defined in # http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: # # ; A list of name/value pairs # dictionary = dict-count *( dict-name dict-value ) # dict-count = number-4 # dict-value = longstr # dict-name = string # # ; Strings are always length + text contents # longstr = number-4 *VCHAR # string = number-1 *VCHAR # # ; Numbers are unsigned integers in network byte order # number-1 = 1OCTET # number-4 = 4OCTET # # Comments are not included in the packed data. Item values MUST be # strings. # # @return [Zframe] def pack() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_pack(self_p) result = Zframe.__new result, true result end # Save hash table to a text file in name=value format. Hash values must be # printable strings; keys may not contain '=' character. Returns 0 if OK, # else -1 if a file error occurred. # # @param filename [String, #to_s, nil] # @return [Integer] def save(filename) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_save(self_p, filename) result end # Load hash table from a text file in name=value format; hash table must # already exist. Hash values must printable strings; keys may not contain # '=' character. Returns 0 if OK, else -1 if a file was not readable. # # @param filename [String, #to_s, nil] # @return [Integer] def load(filename) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_load(self_p, filename) result end # When a hash table was loaded from a file by zhash_load, this method will # reload the file if it has been modified since, and is "stable", i.e. not # still changing. Returns 0 if OK, -1 if there was an error reloading the # file. # # @return [Integer] def refresh() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_refresh(self_p) result end # Set hash for automatic value destruction. Note that this assumes that # values are NULL-terminated strings. Do not use with different types. # # @return [void] def autofree() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhash_autofree(self_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zhash_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zchunk.rb0000664000372000037200000003020513222211156022254 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # work with memory chunks # @note This class is 100% generated using zproject. class Zchunk # Raised when one tries to use an instance of {Zchunk} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zchunk_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new chunk of the specified size. If you specify the data, it # is copied into the chunk. If you do not specify the data, the chunk is # allocated and left empty, and you can then add data using zchunk_append. # @param data [::FFI::Pointer, #to_ptr] # @param size [Integer, #to_int, #to_i] # @return [CZMQ::Zchunk] def self.new(data, size) size = Integer(size) ptr = ::CZMQ::FFI.zchunk_new(data, size) __new ptr end # Destroy a chunk # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zchunk_destroy(self_p) result end # Resizes chunk max_size as requested; chunk_cur size is set to zero # # @param size [Integer, #to_int, #to_i] # @return [void] def resize(size) raise DestroyedError unless @ptr self_p = @ptr size = Integer(size) result = ::CZMQ::FFI.zchunk_resize(self_p, size) result end # Return chunk cur size # # @return [Integer] def size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_size(self_p) result end # Return chunk max size # # @return [Integer] def max_size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_max_size(self_p) result end # Return chunk data # # @return [::FFI::Pointer] def data() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_data(self_p) result end # Set chunk data from user-supplied data; truncate if too large. Data may # be null. Returns actual size of chunk # # @param data [::FFI::Pointer, #to_ptr] # @param size [Integer, #to_int, #to_i] # @return [Integer] def set(data, size) raise DestroyedError unless @ptr self_p = @ptr size = Integer(size) result = ::CZMQ::FFI.zchunk_set(self_p, data, size) result end # Fill chunk data from user-supplied octet # # @param filler [Integer, #to_int, #to_i] # @param size [Integer, #to_int, #to_i] # @return [Integer] def fill(filler, size) raise DestroyedError unless @ptr self_p = @ptr filler = Integer(filler) size = Integer(size) result = ::CZMQ::FFI.zchunk_fill(self_p, filler, size) result end # Append user-supplied data to chunk, return resulting chunk size. If the # data would exceeded the available space, it is truncated. If you want to # grow the chunk to accommodate new data, use the zchunk_extend method. # # @param data [::FFI::Pointer, #to_ptr] # @param size [Integer, #to_int, #to_i] # @return [Integer] def append(data, size) raise DestroyedError unless @ptr self_p = @ptr size = Integer(size) result = ::CZMQ::FFI.zchunk_append(self_p, data, size) result end # Append user-supplied data to chunk, return resulting chunk size. If the # data would exceeded the available space, the chunk grows in size. # # @param data [::FFI::Pointer, #to_ptr] # @param size [Integer, #to_int, #to_i] # @return [Integer] def extend(data, size) raise DestroyedError unless @ptr self_p = @ptr size = Integer(size) result = ::CZMQ::FFI.zchunk_extend(self_p, data, size) result end # Copy as much data from 'source' into the chunk as possible; returns the # new size of chunk. If all data from 'source' is used, returns exhausted # on the source chunk. Source can be consumed as many times as needed until # it is exhausted. If source was already exhausted, does not change chunk. # # @param source [Zchunk, #__ptr] # @return [Integer] def consume(source) raise DestroyedError unless @ptr self_p = @ptr source = source.__ptr if source result = ::CZMQ::FFI.zchunk_consume(self_p, source) result end # Returns true if the chunk was exhausted by consume methods, or if the # chunk has a size of zero. # # @return [Boolean] def exhausted() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_exhausted(self_p) result end # Read chunk from an open file descriptor # # @param handle [::FFI::Pointer, #to_ptr] # @param bytes [Integer, #to_int, #to_i] # @return [Zchunk] def self.read(handle, bytes) bytes = Integer(bytes) result = ::CZMQ::FFI.zchunk_read(handle, bytes) result = Zchunk.__new result, true result end # Write chunk to an open file descriptor # # @param handle [::FFI::Pointer, #to_ptr] # @return [Integer] def write(handle) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_write(self_p, handle) result end # Try to slurp an entire file into a chunk. Will read up to maxsize of # the file. If maxsize is 0, will attempt to read the entire file and # fail with an assertion if that cannot fit into memory. Returns a new # chunk containing the file data, or NULL if the file could not be read. # # @param filename [String, #to_s, nil] # @param maxsize [Integer, #to_int, #to_i] # @return [Zchunk] def self.slurp(filename, maxsize) maxsize = Integer(maxsize) result = ::CZMQ::FFI.zchunk_slurp(filename, maxsize) result = Zchunk.__new result, true result end # Create copy of chunk, as new chunk object. Returns a fresh zchunk_t # object, or null if there was not enough heap memory. If chunk is null, # returns null. # # @return [Zchunk] def dup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_dup(self_p) result = Zchunk.__new result, true result end # Return chunk data encoded as printable hex string. Caller must free # string when finished with it. # # @return [::FFI::AutoPointer] def strhex() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_strhex(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Return chunk data copied into freshly allocated string # Caller must free string when finished with it. # # @return [::FFI::AutoPointer] def strdup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_strdup(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Return TRUE if chunk body is equal to string, excluding terminator # # @param string [String, #to_s, nil] # @return [Boolean] def streq(string) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_streq(self_p, string) result end # Transform zchunk into a zframe that can be sent in a message. # # @return [Zframe] def pack() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_pack(self_p) result = Zframe.__new result, true result end # Transform a zframe into a zchunk. # # @param frame [Zframe, #__ptr] # @return [Zchunk] def self.unpack(frame) frame = frame.__ptr if frame result = ::CZMQ::FFI.zchunk_unpack(frame) result = Zchunk.__new result, true result end # Calculate SHA1 digest for chunk, using zdigest class. # # @return [String] def digest() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_digest(self_p) result end # Dump chunk to FILE stream, for debugging and tracing. # # @param file [::FFI::Pointer, #to_ptr] # @return [void] def fprint(file) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_fprint(self_p, file) result end # Dump message to stderr, for debugging and tracing. # See zchunk_fprint for details # # @return [void] def print() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zchunk_print(self_p) result end # Probe the supplied object, and report if it looks like a zchunk_t. # # @param self_ [::FFI::Pointer, #to_ptr] # @return [Boolean] def self.is(self_) result = ::CZMQ::FFI.zchunk_is(self_) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zchunk_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zdir.rb0000664000372000037200000002175513222211156021734 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # work with file-system directories # @note This class is 100% generated using zproject. class Zdir # Raised when one tries to use an instance of {Zdir} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zdir_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new directory item that loads in the full tree of the specified # path, optionally located under some parent path. If parent is "-", then # loads only the top-level directory, and does not use parent as a path. # @param path [String, #to_s, nil] # @param parent [String, #to_s, nil] # @return [CZMQ::Zdir] def self.new(path, parent) ptr = ::CZMQ::FFI.zdir_new(path, parent) __new ptr end # Destroy a directory tree and all children it contains. # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zdir_destroy(self_p) result end # Return directory path # # @return [String] def path() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_path(self_p) result end # Return last modification time for directory. # # @return [::FFI::Pointer] def modified() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_modified(self_p) result end # Return total hierarchy size, in bytes of data contained in all files # in the directory tree. # # @return [::FFI::Pointer] def cursize() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_cursize(self_p) result end # Return directory count # # @return [Integer] def count() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_count(self_p) result end # Returns a sorted list of zfile objects; Each entry in the list is a pointer # to a zfile_t item already allocated in the zdir tree. Do not destroy the # original zdir tree until you are done with this list. # # @return [Zlist] def list() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_list(self_p) result = Zlist.__new result, true result end # Remove directory, optionally including all files that it contains, at # all levels. If force is false, will only remove the directory if empty. # If force is true, will remove all files and all subdirectories. # # @param force [Boolean] # @return [void] def remove(force) raise DestroyedError unless @ptr self_p = @ptr force = !(0==force||!force) # boolean result = ::CZMQ::FFI.zdir_remove(self_p, force) result end # Calculate differences between two versions of a directory tree. # Returns a list of zdir_patch_t patches. Either older or newer may # be null, indicating the directory is empty/absent. If alias is set, # generates virtual filename (minus path, plus alias). # # @param older [Zdir, #__ptr] # @param newer [Zdir, #__ptr] # @param alias_ [String, #to_s, nil] # @return [Zlist] def self.diff(older, newer, alias_) older = older.__ptr if older newer = newer.__ptr if newer result = ::CZMQ::FFI.zdir_diff(older, newer, alias_) result = Zlist.__new result, true result end # Return full contents of directory as a zdir_patch list. # # @param alias_ [String, #to_s, nil] # @return [Zlist] def resync(alias_) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_resync(self_p, alias_) result = Zlist.__new result, true result end # Load directory cache; returns a hash table containing the SHA-1 digests # of every file in the tree. The cache is saved between runs in .cache. # # @return [Zhash] def cache() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdir_cache(self_p) result = Zhash.__new result, true result end # Print contents of directory to open stream # # @param file [::FFI::Pointer, #to_ptr] # @param indent [Integer, #to_int, #to_i] # @return [void] def fprint(file, indent) raise DestroyedError unless @ptr self_p = @ptr indent = Integer(indent) result = ::CZMQ::FFI.zdir_fprint(self_p, file, indent) result end # Print contents of directory to stdout # # @param indent [Integer, #to_int, #to_i] # @return [void] def print(indent) raise DestroyedError unless @ptr self_p = @ptr indent = Integer(indent) result = ::CZMQ::FFI.zdir_print(self_p, indent) result end # Create a new zdir_watch actor instance: # # zactor_t *watch = zactor_new (zdir_watch, NULL); # # Destroy zdir_watch instance: # # zactor_destroy (&watch); # # Enable verbose logging of commands and activity: # # zstr_send (watch, "VERBOSE"); # # Subscribe to changes to a directory path: # # zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); # # Unsubscribe from changes to a directory path: # # zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); # # Receive directory changes: # zsock_recv (watch, "sp", &path, &patches); # # // Delete the received data. # free (path); # zlist_destroy (&patches); # # @param pipe [Zsock, #__ptr] # @param unused [::FFI::Pointer, #to_ptr] # @return [void] def self.watch(pipe, unused) pipe = pipe.__ptr if pipe result = ::CZMQ::FFI.zdir_watch(pipe, unused) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zdir_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zuuid.rb0000664000372000037200000001540613222211156022120 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # UUID support class # @note This class is 100% generated using zproject. class Zuuid # Raised when one tries to use an instance of {Zuuid} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zuuid_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new UUID object. # @return [CZMQ::Zuuid] def self.new() ptr = ::CZMQ::FFI.zuuid_new() __new ptr end # Create UUID object from supplied ZUUID_LEN-octet value. # @param source [::FFI::Pointer, #to_ptr] # @return [CZMQ::Zuuid] def self.new_from(source) ptr = ::CZMQ::FFI.zuuid_new_from(source) __new ptr end # Destroy a specified UUID object. # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zuuid_destroy(self_p) result end # Set UUID to new supplied ZUUID_LEN-octet value. # # @param source [::FFI::Pointer, #to_ptr] # @return [void] def set(source) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zuuid_set(self_p, source) result end # Set UUID to new supplied string value skipping '-' and '{' '}' # optional delimiters. Return 0 if OK, else returns -1. # # @param source [String, #to_s, nil] # @return [Integer] def set_str(source) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zuuid_set_str(self_p, source) result end # Return UUID binary data. # # @return [::FFI::Pointer] def data() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zuuid_data(self_p) result end # Return UUID binary size # # @return [Integer] def size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zuuid_size(self_p) result end # Returns UUID as string # # @return [String] def str() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zuuid_str(self_p) result end # Return UUID in the canonical string format: 8-4-4-4-12, in lower # case. Caller does not modify or free returned value. See # http://en.wikipedia.org/wiki/Universally_unique_identifier # # @return [String] def str_canonical() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zuuid_str_canonical(self_p) result end # Store UUID blob in target array # # @param target [::FFI::Pointer, #to_ptr] # @return [void] def export(target) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zuuid_export(self_p, target) result end # Check if UUID is same as supplied value # # @param compare [::FFI::Pointer, #to_ptr] # @return [Boolean] def eq(compare) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zuuid_eq(self_p, compare) result end # Check if UUID is different from supplied value # # @param compare [::FFI::Pointer, #to_ptr] # @return [Boolean] def neq(compare) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zuuid_neq(self_p, compare) result end # Make copy of UUID object; if uuid is null, or memory was exhausted, # returns null. # # @return [Zuuid] def dup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zuuid_dup(self_p) result = Zuuid.__new result, false result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zuuid_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/ziflist.rb0000664000372000037200000001471013222211156022441 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # List of network interfaces available on system # @note This class is 100% generated using zproject. class Ziflist # Raised when one tries to use an instance of {Ziflist} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.ziflist_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Get a list of network interfaces currently defined on the system # @return [CZMQ::Ziflist] def self.new() ptr = ::CZMQ::FFI.ziflist_new() __new ptr end # Destroy a ziflist instance # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.ziflist_destroy(self_p) result end # Reload network interfaces from system # # @return [void] def reload() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ziflist_reload(self_p) result end # Return the number of network interfaces on system # # @return [Integer] def size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ziflist_size(self_p) result end # Get first network interface, return NULL if there are none # # @return [String] def first() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ziflist_first(self_p) result end # Get next network interface, return NULL if we hit the last one # # @return [String] def next() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ziflist_next(self_p) result end # Return the current interface IP address as a printable string # # @return [String] def address() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ziflist_address(self_p) result end # Return the current interface broadcast address as a printable string # # @return [String] def broadcast() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ziflist_broadcast(self_p) result end # Return the current interface network mask as a printable string # # @return [String] def netmask() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ziflist_netmask(self_p) result end # Return the list of interfaces. # # @return [void] def print() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ziflist_print(self_p) result end # Get a list of network interfaces currently defined on the system # Includes IPv6 interfaces # # @return [Ziflist] def self.new_ipv6() result = ::CZMQ::FFI.ziflist_new_ipv6() result = Ziflist.__new result, true result end # Reload network interfaces from system, including IPv6 # # @return [void] def reload_ipv6() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ziflist_reload_ipv6(self_p) result end # Return true if the current interface uses IPv6 # # @return [Boolean] def is_ipv6() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ziflist_is_ipv6(self_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.ziflist_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zactor.rb0000664000372000037200000001677013222211156022267 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # provides a simple actor framework # @note This class is 100% generated using zproject. class Zactor # Raised when one tries to use an instance of {Zactor} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zactor_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new callback of the following type: # Actors get a pipe and arguments from caller # typedef void (zactor_fn) ( # zsock_t *pipe, void *args); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.fn ::FFI::Function.new :void, [:pointer, :pointer], blocking: true do |pipe, args| pipe = Zsock.__new pipe, false result = yield pipe, args result end end # Create a new callback of the following type: # Function to be called on zactor_destroy. Default behavior is to send zmsg_t with string "$TERM" in a first frame. # # An example - to send $KTHXBAI string # # if (zstr_send (self->pipe, "$KTHXBAI") == 0) # zsock_wait (self->pipe); # typedef void (zactor_destructor_fn) ( # zactor_t *self); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.destructor_fn ::FFI::Function.new :void, [:pointer], blocking: true do |self_| self_ = Zactor.__new self_, false result = yield self_ result end end # Create a new actor passing arbitrary arguments reference. # @param task [::FFI::Pointer, #to_ptr] # @param args [::FFI::Pointer, #to_ptr] # @return [CZMQ::Zactor] def self.new(task, args) ptr = ::CZMQ::FFI.zactor_new(task, args) __new ptr end # Destroy an actor. # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zactor_destroy(self_p) result end # Send a zmsg message to the actor, take ownership of the message # and destroy when it has been sent. # # @param msg_p [#__ptr_give_ref] # @return [Integer] def send(msg_p) raise DestroyedError unless @ptr self_p = @ptr msg_p = msg_p.__ptr_give_ref result = ::CZMQ::FFI.zactor_send(self_p, msg_p) result end # Receive a zmsg message from the actor. Returns NULL if the actor # was interrupted before the message could be received, or if there # was a timeout on the actor. # # @return [Zmsg] def recv() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zactor_recv(self_p) result = Zmsg.__new result, true result end # Probe the supplied object, and report if it looks like a zactor_t. # # @param self_ [::FFI::Pointer, #to_ptr] # @return [Boolean] def self.is(self_) result = ::CZMQ::FFI.zactor_is(self_) result end # Probe the supplied reference. If it looks like a zactor_t instance, # return the underlying libzmq actor handle; else if it looks like # a libzmq actor handle, return the supplied value. # # @param self_ [::FFI::Pointer, #to_ptr] # @return [::FFI::Pointer] def self.resolve(self_) result = ::CZMQ::FFI.zactor_resolve(self_) result end # Return the actor's zsock handle. Use this when you absolutely need # to work with the zsock instance rather than the actor. # # @return [Zsock] def sock() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zactor_sock(self_p) result = Zsock.__new result, false result end # Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. # # @param destructor [::FFI::Pointer, #to_ptr] # @return [void] def set_destructor(destructor) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zactor_set_destructor(self_p, destructor) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zactor_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zlist.rb0000664000372000037200000003045213222211156022123 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # simple generic list container # @note This class is 100% generated using zproject. class Zlist # Raised when one tries to use an instance of {Zlist} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zlist_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new callback of the following type: # Comparison function e.g. for sorting and removing. # typedef int (zlist_compare_fn) ( # void *item1, void *item2); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.compare_fn ::FFI::Function.new :int, [:pointer, :pointer], blocking: true do |item1, item2| result = yield item1, item2 result = Integer(result) result end end # Create a new callback of the following type: # Callback function for zlist_freefn method # typedef void (zlist_free_fn) ( # void *data); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.free_fn ::FFI::Function.new :void, [:pointer], blocking: true do |data| result = yield data result end end # Create a new list container # @return [CZMQ::Zlist] def self.new() ptr = ::CZMQ::FFI.zlist_new() __new ptr end # Destroy a list container # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zlist_destroy(self_p) result end # Return the item at the head of list. If the list is empty, returns NULL. # Leaves cursor pointing at the head item, or NULL if the list is empty. # # @return [::FFI::Pointer] def first() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_first(self_p) result end # Return the next item. If the list is empty, returns NULL. To move to # the start of the list call zlist_first (). Advances the cursor. # # @return [::FFI::Pointer] def next() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_next(self_p) result end # Return the item at the tail of list. If the list is empty, returns NULL. # Leaves cursor pointing at the tail item, or NULL if the list is empty. # # @return [::FFI::Pointer] def last() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_last(self_p) result end # Return first item in the list, or null, leaves the cursor # # @return [::FFI::Pointer] def head() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_head(self_p) result end # Return last item in the list, or null, leaves the cursor # # @return [::FFI::Pointer] def tail() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_tail(self_p) result end # Return the current item of list. If the list is empty, returns NULL. # Leaves cursor pointing at the current item, or NULL if the list is empty. # # @return [::FFI::Pointer] def item() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_item(self_p) result end # Append an item to the end of the list, return 0 if OK or -1 if this # failed for some reason (out of memory). Note that if a duplicator has # been set, this method will also duplicate the item. # # @param item [::FFI::Pointer, #to_ptr] # @return [Integer] def append(item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_append(self_p, item) result end # Push an item to the start of the list, return 0 if OK or -1 if this # failed for some reason (out of memory). Note that if a duplicator has # been set, this method will also duplicate the item. # # @param item [::FFI::Pointer, #to_ptr] # @return [Integer] def push(item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_push(self_p, item) result end # Pop the item off the start of the list, if any # # @return [::FFI::Pointer] def pop() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_pop(self_p) result end # Checks if an item already is present. Uses compare method to determine if # items are equal. If the compare method is NULL the check will only compare # pointers. Returns true if item is present else false. # # @param item [::FFI::Pointer, #to_ptr] # @return [Boolean] def exists(item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_exists(self_p, item) result end # Remove the specified item from the list if present # # @param item [::FFI::Pointer, #to_ptr] # @return [void] def remove(item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_remove(self_p, item) result end # Make a copy of list. If the list has autofree set, the copied list will # duplicate all items, which must be strings. Otherwise, the list will hold # pointers back to the items in the original list. If list is null, returns # NULL. # # @return [Zlist] def dup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_dup(self_p) result = Zlist.__new result, true result end # Purge all items from list # # @return [void] def purge() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_purge(self_p) result end # Return number of items in the list # # @return [Integer] def size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_size(self_p) result end # Sort the list. If the compare function is null, sorts the list by # ascending key value using a straight ASCII comparison. If you specify # a compare function, this decides how items are sorted. The sort is not # stable, so may reorder items with the same keys. The algorithm used is # combsort, a compromise between performance and simplicity. # # @param compare [::FFI::Pointer, #to_ptr] # @return [void] def sort(compare) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_sort(self_p, compare) result end # Set list for automatic item destruction; item values MUST be strings. # By default a list item refers to a value held elsewhere. When you set # this, each time you append or push a list item, zlist will take a copy # of the string value. Then, when you destroy the list, it will free all # item values automatically. If you use any other technique to allocate # list values, you must free them explicitly before destroying the list. # The usual technique is to pop list items and destroy them, until the # list is empty. # # @return [void] def autofree() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_autofree(self_p) result end # Sets a compare function for this list. The function compares two items. # It returns an integer less than, equal to, or greater than zero if the # first item is found, respectively, to be less than, to match, or be # greater than the second item. # This function is used for sorting, removal and exists checking. # # @param fn [::FFI::Pointer, #to_ptr] # @return [void] def comparefn(fn) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlist_comparefn(self_p, fn) result end # Set a free function for the specified list item. When the item is # destroyed, the free function, if any, is called on that item. # Use this when list items are dynamically allocated, to ensure that # you don't have memory leaks. You can pass 'free' or NULL as a free_fn. # Returns the item, or NULL if there is no such item. # # @param item [::FFI::Pointer, #to_ptr] # @param fn [::FFI::Pointer, #to_ptr] # @param at_tail [Boolean] # @return [::FFI::Pointer] def freefn(item, fn, at_tail) raise DestroyedError unless @ptr self_p = @ptr at_tail = !(0==at_tail||!at_tail) # boolean result = ::CZMQ::FFI.zlist_freefn(self_p, item, fn, at_tail) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zlist_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zsock.rb0000664000372000037200000047453213222211156022122 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # high-level socket API that hides libzmq contexts and sockets # @note This class is 100% generated using zproject. class Zsock # Raised when one tries to use an instance of {Zsock} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zsock_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new socket. Returns the new socket, or NULL if the new socket # could not be created. Note that the symbol zsock_new (and other # constructors/destructors for zsock) are redirected to the *_checked # variant, enabling intelligent socket leak detection. This can have # performance implications if you use a LOT of sockets. To turn off this # redirection behaviour, define ZSOCK_NOCHECK. # @param type [Integer, #to_int, #to_i] # @return [CZMQ::Zsock] def self.new(type) type = Integer(type) ptr = ::CZMQ::FFI.zsock_new(type) __new ptr end # Create a PUB socket. Default action is bind. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_pub(endpoint) ptr = ::CZMQ::FFI.zsock_new_pub(endpoint) __new ptr end # Create a SUB socket, and optionally subscribe to some prefix string. Default # action is connect. # @param endpoint [String, #to_s, nil] # @param subscribe [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_sub(endpoint, subscribe) ptr = ::CZMQ::FFI.zsock_new_sub(endpoint, subscribe) __new ptr end # Create a REQ socket. Default action is connect. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_req(endpoint) ptr = ::CZMQ::FFI.zsock_new_req(endpoint) __new ptr end # Create a REP socket. Default action is bind. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_rep(endpoint) ptr = ::CZMQ::FFI.zsock_new_rep(endpoint) __new ptr end # Create a DEALER socket. Default action is connect. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_dealer(endpoint) ptr = ::CZMQ::FFI.zsock_new_dealer(endpoint) __new ptr end # Create a ROUTER socket. Default action is bind. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_router(endpoint) ptr = ::CZMQ::FFI.zsock_new_router(endpoint) __new ptr end # Create a PUSH socket. Default action is connect. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_push(endpoint) ptr = ::CZMQ::FFI.zsock_new_push(endpoint) __new ptr end # Create a PULL socket. Default action is bind. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_pull(endpoint) ptr = ::CZMQ::FFI.zsock_new_pull(endpoint) __new ptr end # Create an XPUB socket. Default action is bind. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_xpub(endpoint) ptr = ::CZMQ::FFI.zsock_new_xpub(endpoint) __new ptr end # Create an XSUB socket. Default action is connect. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_xsub(endpoint) ptr = ::CZMQ::FFI.zsock_new_xsub(endpoint) __new ptr end # Create a PAIR socket. Default action is connect. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_pair(endpoint) ptr = ::CZMQ::FFI.zsock_new_pair(endpoint) __new ptr end # Create a STREAM socket. Default action is connect. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_stream(endpoint) ptr = ::CZMQ::FFI.zsock_new_stream(endpoint) __new ptr end # Create a SERVER socket. Default action is bind. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_server(endpoint) ptr = ::CZMQ::FFI.zsock_new_server(endpoint) __new ptr end # Create a CLIENT socket. Default action is connect. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_client(endpoint) ptr = ::CZMQ::FFI.zsock_new_client(endpoint) __new ptr end # Create a RADIO socket. Default action is bind. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_radio(endpoint) ptr = ::CZMQ::FFI.zsock_new_radio(endpoint) __new ptr end # Create a DISH socket. Default action is connect. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_dish(endpoint) ptr = ::CZMQ::FFI.zsock_new_dish(endpoint) __new ptr end # Create a GATHER socket. Default action is bind. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_gather(endpoint) ptr = ::CZMQ::FFI.zsock_new_gather(endpoint) __new ptr end # Create a SCATTER socket. Default action is connect. # @param endpoint [String, #to_s, nil] # @return [CZMQ::Zsock] def self.new_scatter(endpoint) ptr = ::CZMQ::FFI.zsock_new_scatter(endpoint) __new ptr end # Destroy the socket. You must use this for any socket created via the # zsock_new method. # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zsock_destroy(self_p) result end # Bind a socket to a formatted endpoint. For tcp:// endpoints, supports # ephemeral ports, if you specify the port number as "*". By default # zsock uses the IANA designated range from C000 (49152) to FFFF (65535). # To override this range, follow the "*" with "[first-last]". Either or # both first and last may be empty. To bind to a random port within the # range, use "!" in place of "*". # # Examples: # tcp://127.0.0.1:* bind to first free port from C000 up # tcp://127.0.0.1:! bind to random port from C000 to FFFF # tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up # tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 # tcp://127.0.0.1:![55000-55999] # bind to random port from 55000 to 55999 # # On success, returns the actual port number used, for tcp:// endpoints, # and 0 for other transports. On failure, returns -1. Note that when using # ephemeral ports, a port may be reused by different services without # clients being aware. Protocols that run on ephemeral ports should take # this into account. # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def bind(format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_bind(self_p, format, *args) result end # Returns last bound endpoint, if any. # # @return [String] def endpoint() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_endpoint(self_p) result end # Unbind a socket from a formatted endpoint. # Returns 0 if OK, -1 if the endpoint was invalid or the function # isn't supported. # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def unbind(format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_unbind(self_p, format, *args) result end # Connect a socket to a formatted endpoint # Returns 0 if OK, -1 if the endpoint was invalid. # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def connect(format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_connect(self_p, format, *args) result end # Disconnect a socket from a formatted endpoint # Returns 0 if OK, -1 if the endpoint was invalid or the function # isn't supported. # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def disconnect(format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_disconnect(self_p, format, *args) result end # Attach a socket to zero or more endpoints. If endpoints is not null, # parses as list of ZeroMQ endpoints, separated by commas, and prefixed by # '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all # endpoints were valid, or -1 if there was a syntax error. If the endpoint # does not start with '@' or '>', the serverish argument defines whether # it is used to bind (serverish = true) or connect (serverish = false). # # @param endpoints [String, #to_s, nil] # @param serverish [Boolean] # @return [Integer] def attach(endpoints, serverish) raise DestroyedError unless @ptr self_p = @ptr serverish = !(0==serverish||!serverish) # boolean result = ::CZMQ::FFI.zsock_attach(self_p, endpoints, serverish) result end # Returns socket type as printable constant string. # # @return [String] def type_str() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_type_str(self_p) result end # Send a 'picture' message to the socket (or actor). The picture is a # string that defines the type of each frame. This makes it easy to send # a complex multiframe message in one call. The picture can contain any # of these characters, each corresponding to one or two arguments: # # i = int (signed) # 1 = uint8_t # 2 = uint16_t # 4 = uint32_t # 8 = uint64_t # s = char * # b = byte *, size_t (2 arguments) # c = zchunk_t * # f = zframe_t * # h = zhashx_t * # U = zuuid_t * # p = void * (sends the pointer value, only meaningful over inproc) # m = zmsg_t * (sends all frames in the zmsg) # z = sends zero-sized frame (0 arguments) # u = uint (deprecated) # # Note that s, b, c, and f are encoded the same way and the choice is # offered as a convenience to the sender, which may or may not already # have data in a zchunk or zframe. Does not change or take ownership of # any arguments. Returns 0 if successful, -1 if sending failed for any # reason. # # @param picture [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def send(picture, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_send(self_p, picture, *args) result end # Send a 'picture' message to the socket (or actor). The picture is a # string that defines the type of each frame. This makes it easy to send # a complex multiframe message in one call. The picture can contain any # of these characters, each corresponding to one or two arguments: # # i = int (signed) # 1 = uint8_t # 2 = uint16_t # 4 = uint32_t # 8 = uint64_t # s = char * # b = byte *, size_t (2 arguments) # c = zchunk_t * # f = zframe_t * # h = zhashx_t * # U = zuuid_t * # p = void * (sends the pointer value, only meaningful over inproc) # m = zmsg_t * (sends all frames in the zmsg) # z = sends zero-sized frame (0 arguments) # u = uint (deprecated) # # Note that s, b, c, and f are encoded the same way and the choice is # offered as a convenience to the sender, which may or may not already # have data in a zchunk or zframe. Does not change or take ownership of # any arguments. Returns 0 if successful, -1 if sending failed for any # reason. # # This is the polymorphic version of #send. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param picture [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def self.send(self_p, picture, *args) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_send(self_p, picture, *args) result end # Send a 'picture' message to the socket (or actor). This is a va_list # version of zsock_send (), so please consult its documentation for the # details. # # @param picture [String, #to_s, nil] # @param argptr [::FFI::Pointer, #to_ptr] # @return [Integer] def vsend(picture, argptr) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_vsend(self_p, picture, argptr) result end # Send a 'picture' message to the socket (or actor). This is a va_list # version of zsock_send (), so please consult its documentation for the # details. # # This is the polymorphic version of #vsend. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param picture [String, #to_s, nil] # @param argptr [::FFI::Pointer, #to_ptr] # @return [Integer] def self.vsend(self_p, picture, argptr) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_vsend(self_p, picture, argptr) result end # Receive a 'picture' message to the socket (or actor). See zsock_send for # the format and meaning of the picture. Returns the picture elements into # a series of pointers as provided by the caller: # # i = int * (stores signed integer) # 4 = uint32_t * (stores 32-bit unsigned integer) # 8 = uint64_t * (stores 64-bit unsigned integer) # s = char ** (allocates new string) # b = byte **, size_t * (2 arguments) (allocates memory) # c = zchunk_t ** (creates zchunk) # f = zframe_t ** (creates zframe) # U = zuuid_t * (creates a zuuid with the data) # h = zhashx_t ** (creates zhashx) # p = void ** (stores pointer) # m = zmsg_t ** (creates a zmsg with the remaing frames) # z = null, asserts empty frame (0 arguments) # u = uint * (stores unsigned integer, deprecated) # # Note that zsock_recv creates the returned objects, and the caller must # destroy them when finished with them. The supplied pointers do not need # to be initialized. Returns 0 if successful, or -1 if it failed to recv # a message, in which case the pointers are not modified. When message # frames are truncated (a short message), sets return values to zero/null. # If an argument pointer is NULL, does not store any value (skips it). # An 'n' picture matches an empty frame; if the message does not match, # the method will return -1. # # @param picture [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def recv(picture, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_recv(self_p, picture, *args) result end # Receive a 'picture' message to the socket (or actor). See zsock_send for # the format and meaning of the picture. Returns the picture elements into # a series of pointers as provided by the caller: # # i = int * (stores signed integer) # 4 = uint32_t * (stores 32-bit unsigned integer) # 8 = uint64_t * (stores 64-bit unsigned integer) # s = char ** (allocates new string) # b = byte **, size_t * (2 arguments) (allocates memory) # c = zchunk_t ** (creates zchunk) # f = zframe_t ** (creates zframe) # U = zuuid_t * (creates a zuuid with the data) # h = zhashx_t ** (creates zhashx) # p = void ** (stores pointer) # m = zmsg_t ** (creates a zmsg with the remaing frames) # z = null, asserts empty frame (0 arguments) # u = uint * (stores unsigned integer, deprecated) # # Note that zsock_recv creates the returned objects, and the caller must # destroy them when finished with them. The supplied pointers do not need # to be initialized. Returns 0 if successful, or -1 if it failed to recv # a message, in which case the pointers are not modified. When message # frames are truncated (a short message), sets return values to zero/null. # If an argument pointer is NULL, does not store any value (skips it). # An 'n' picture matches an empty frame; if the message does not match, # the method will return -1. # # This is the polymorphic version of #recv. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param picture [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def self.recv(self_p, picture, *args) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_recv(self_p, picture, *args) result end # Receive a 'picture' message from the socket (or actor). This is a # va_list version of zsock_recv (), so please consult its documentation # for the details. # # @param picture [String, #to_s, nil] # @param argptr [::FFI::Pointer, #to_ptr] # @return [Integer] def vrecv(picture, argptr) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_vrecv(self_p, picture, argptr) result end # Receive a 'picture' message from the socket (or actor). This is a # va_list version of zsock_recv (), so please consult its documentation # for the details. # # This is the polymorphic version of #vrecv. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param picture [String, #to_s, nil] # @param argptr [::FFI::Pointer, #to_ptr] # @return [Integer] def self.vrecv(self_p, picture, argptr) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_vrecv(self_p, picture, argptr) result end # Send a binary encoded 'picture' message to the socket (or actor). This # method is similar to zsock_send, except the arguments are encoded in a # binary format that is compatible with zproto, and is designed to reduce # memory allocations. The pattern argument is a string that defines the # type of each argument. Supports these argument types: # # pattern C type zproto type: # 1 uint8_t type = "number" size = "1" # 2 uint16_t type = "number" size = "2" # 4 uint32_t type = "number" size = "3" # 8 uint64_t type = "number" size = "4" # s char *, 0-255 chars type = "string" # S char *, 0-2^32-1 chars type = "longstr" # c zchunk_t * type = "chunk" # f zframe_t * type = "frame" # u zuuid_t * type = "uuid" # m zmsg_t * type = "msg" # p void *, sends pointer value, only over inproc # # Does not change or take ownership of any arguments. Returns 0 if # successful, -1 if sending failed for any reason. # # @param picture [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def bsend(picture, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_bsend(self_p, picture, *args) result end # Send a binary encoded 'picture' message to the socket (or actor). This # method is similar to zsock_send, except the arguments are encoded in a # binary format that is compatible with zproto, and is designed to reduce # memory allocations. The pattern argument is a string that defines the # type of each argument. Supports these argument types: # # pattern C type zproto type: # 1 uint8_t type = "number" size = "1" # 2 uint16_t type = "number" size = "2" # 4 uint32_t type = "number" size = "3" # 8 uint64_t type = "number" size = "4" # s char *, 0-255 chars type = "string" # S char *, 0-2^32-1 chars type = "longstr" # c zchunk_t * type = "chunk" # f zframe_t * type = "frame" # u zuuid_t * type = "uuid" # m zmsg_t * type = "msg" # p void *, sends pointer value, only over inproc # # Does not change or take ownership of any arguments. Returns 0 if # successful, -1 if sending failed for any reason. # # This is the polymorphic version of #bsend. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param picture [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def self.bsend(self_p, picture, *args) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_bsend(self_p, picture, *args) result end # Receive a binary encoded 'picture' message from the socket (or actor). # This method is similar to zsock_recv, except the arguments are encoded # in a binary format that is compatible with zproto, and is designed to # reduce memory allocations. The pattern argument is a string that defines # the type of each argument. See zsock_bsend for the supported argument # types. All arguments must be pointers; this call sets them to point to # values held on a per-socket basis. # For types 1, 2, 4 and 8 the caller must allocate the memory itself before # calling zsock_brecv. # For types S, the caller must free the value once finished with it, as # zsock_brecv will allocate the buffer. # For type s, the caller must not free the value as it is stored in a # local cache for performance purposes. # For types c, f, u and m the caller must call the appropriate destructor # depending on the object as zsock_brecv will create new objects. # For type p the caller must coordinate with the sender, as it is just a # pointer value being passed. # # @param picture [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def brecv(picture, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_brecv(self_p, picture, *args) result end # Receive a binary encoded 'picture' message from the socket (or actor). # This method is similar to zsock_recv, except the arguments are encoded # in a binary format that is compatible with zproto, and is designed to # reduce memory allocations. The pattern argument is a string that defines # the type of each argument. See zsock_bsend for the supported argument # types. All arguments must be pointers; this call sets them to point to # values held on a per-socket basis. # For types 1, 2, 4 and 8 the caller must allocate the memory itself before # calling zsock_brecv. # For types S, the caller must free the value once finished with it, as # zsock_brecv will allocate the buffer. # For type s, the caller must not free the value as it is stored in a # local cache for performance purposes. # For types c, f, u and m the caller must call the appropriate destructor # depending on the object as zsock_brecv will create new objects. # For type p the caller must coordinate with the sender, as it is just a # pointer value being passed. # # This is the polymorphic version of #brecv. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param picture [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def self.brecv(self_p, picture, *args) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_brecv(self_p, picture, *args) result end # Return socket routing ID if any. This returns 0 if the socket is not # of type ZMQ_SERVER or if no request was already received on it. # # @return [Integer] def routing_id() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_routing_id(self_p) result end # Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. # This will be used when sending messages on the socket via the zsock API. # # @param routing_id [Integer, #to_int, #to_i] # @return [void] def set_routing_id(routing_id) raise DestroyedError unless @ptr self_p = @ptr routing_id = Integer(routing_id) result = ::CZMQ::FFI.zsock_set_routing_id(self_p, routing_id) result end # Set socket to use unbounded pipes (HWM=0); use this in cases when you are # totally certain the message volume can fit in memory. This method works # across all versions of ZeroMQ. Takes a polymorphic socket reference. # # @return [void] def set_unbounded() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_unbounded(self_p) result end # Set socket to use unbounded pipes (HWM=0); use this in cases when you are # totally certain the message volume can fit in memory. This method works # across all versions of ZeroMQ. Takes a polymorphic socket reference. # # This is the polymorphic version of #set_unbounded. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [void] def self.set_unbounded(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_unbounded(self_p) result end # Send a signal over a socket. A signal is a short message carrying a # success/failure code (by convention, 0 means OK). Signals are encoded # to be distinguishable from "normal" messages. Accepts a zsock_t or a # zactor_t argument, and returns 0 if successful, -1 if the signal could # not be sent. Takes a polymorphic socket reference. # # @param status [Integer, #to_int, #to_i] # @return [Integer] def signal(status) raise DestroyedError unless @ptr self_p = @ptr status = Integer(status) result = ::CZMQ::FFI.zsock_signal(self_p, status) result end # Send a signal over a socket. A signal is a short message carrying a # success/failure code (by convention, 0 means OK). Signals are encoded # to be distinguishable from "normal" messages. Accepts a zsock_t or a # zactor_t argument, and returns 0 if successful, -1 if the signal could # not be sent. Takes a polymorphic socket reference. # # This is the polymorphic version of #signal. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param status [Integer, #to_int, #to_i] # @return [Integer] def self.signal(self_p, status) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) status = Integer(status) result = ::CZMQ::FFI.zsock_signal(self_p, status) result end # Wait on a signal. Use this to coordinate between threads, over pipe # pairs. Blocks until the signal is received. Returns -1 on error, 0 or # greater on success. Accepts a zsock_t or a zactor_t as argument. # Takes a polymorphic socket reference. # # @return [Integer] def wait() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_wait(self_p) result end # Wait on a signal. Use this to coordinate between threads, over pipe # pairs. Blocks until the signal is received. Returns -1 on error, 0 or # greater on success. Accepts a zsock_t or a zactor_t as argument. # Takes a polymorphic socket reference. # # This is the polymorphic version of #wait. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.wait(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_wait(self_p) result end # If there is a partial message still waiting on the socket, remove and # discard it. This is useful when reading partial messages, to get specific # message types. # # @return [void] def flush() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_flush(self_p) result end # If there is a partial message still waiting on the socket, remove and # discard it. This is useful when reading partial messages, to get specific # message types. # # This is the polymorphic version of #flush. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [void] def self.flush(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_flush(self_p) result end # Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. # Returns 0 if OK, -1 if failed. # # @param group [String, #to_s, nil] # @return [Integer] def join(group) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_join(self_p, group) result end # Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. # Returns 0 if OK, -1 if failed. # # This is the polymorphic version of #join. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param group [String, #to_s, nil] # @return [Integer] def self.join(self_p, group) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_join(self_p, group) result end # Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. # Returns 0 if OK, -1 if failed. # # @param group [String, #to_s, nil] # @return [Integer] def leave(group) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_leave(self_p, group) result end # Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. # Returns 0 if OK, -1 if failed. # # This is the polymorphic version of #leave. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param group [String, #to_s, nil] # @return [Integer] def self.leave(self_p, group) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_leave(self_p, group) result end # Probe the supplied object, and report if it looks like a zsock_t. # Takes a polymorphic socket reference. # # @param self_ [::FFI::Pointer, #to_ptr] # @return [Boolean] def self.is(self_) result = ::CZMQ::FFI.zsock_is(self_) result end # Probe the supplied reference. If it looks like a zsock_t instance, return # the underlying libzmq socket handle; else if it looks like a file # descriptor, return NULL; else if it looks like a libzmq socket handle, # return the supplied value. Takes a polymorphic socket reference. # # @param self_ [::FFI::Pointer, #to_ptr] # @return [::FFI::Pointer] def self.resolve(self_) result = ::CZMQ::FFI.zsock_resolve(self_) result end # Get socket option `heartbeat_ivl`. # Available from libzmq 4.2.0. # # @return [Integer] def heartbeat_ivl() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_heartbeat_ivl(self_p) result end # Get socket option `heartbeat_ivl`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #heartbeat_ivl. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.heartbeat_ivl(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_heartbeat_ivl(self_p) result end # Set socket option `heartbeat_ivl`. # Available from libzmq 4.2.0. # # @param heartbeat_ivl [Integer, #to_int, #to_i] # @return [void] def set_heartbeat_ivl(heartbeat_ivl) raise DestroyedError unless @ptr self_p = @ptr heartbeat_ivl = Integer(heartbeat_ivl) result = ::CZMQ::FFI.zsock_set_heartbeat_ivl(self_p, heartbeat_ivl) result end # Set socket option `heartbeat_ivl`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_heartbeat_ivl. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param heartbeat_ivl [Integer, #to_int, #to_i] # @return [void] def self.set_heartbeat_ivl(self_p, heartbeat_ivl) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) heartbeat_ivl = Integer(heartbeat_ivl) result = ::CZMQ::FFI.zsock_set_heartbeat_ivl(self_p, heartbeat_ivl) result end # Get socket option `heartbeat_ttl`. # Available from libzmq 4.2.0. # # @return [Integer] def heartbeat_ttl() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_heartbeat_ttl(self_p) result end # Get socket option `heartbeat_ttl`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #heartbeat_ttl. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.heartbeat_ttl(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_heartbeat_ttl(self_p) result end # Set socket option `heartbeat_ttl`. # Available from libzmq 4.2.0. # # @param heartbeat_ttl [Integer, #to_int, #to_i] # @return [void] def set_heartbeat_ttl(heartbeat_ttl) raise DestroyedError unless @ptr self_p = @ptr heartbeat_ttl = Integer(heartbeat_ttl) result = ::CZMQ::FFI.zsock_set_heartbeat_ttl(self_p, heartbeat_ttl) result end # Set socket option `heartbeat_ttl`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_heartbeat_ttl. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param heartbeat_ttl [Integer, #to_int, #to_i] # @return [void] def self.set_heartbeat_ttl(self_p, heartbeat_ttl) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) heartbeat_ttl = Integer(heartbeat_ttl) result = ::CZMQ::FFI.zsock_set_heartbeat_ttl(self_p, heartbeat_ttl) result end # Get socket option `heartbeat_timeout`. # Available from libzmq 4.2.0. # # @return [Integer] def heartbeat_timeout() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_heartbeat_timeout(self_p) result end # Get socket option `heartbeat_timeout`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #heartbeat_timeout. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.heartbeat_timeout(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_heartbeat_timeout(self_p) result end # Set socket option `heartbeat_timeout`. # Available from libzmq 4.2.0. # # @param heartbeat_timeout [Integer, #to_int, #to_i] # @return [void] def set_heartbeat_timeout(heartbeat_timeout) raise DestroyedError unless @ptr self_p = @ptr heartbeat_timeout = Integer(heartbeat_timeout) result = ::CZMQ::FFI.zsock_set_heartbeat_timeout(self_p, heartbeat_timeout) result end # Set socket option `heartbeat_timeout`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_heartbeat_timeout. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param heartbeat_timeout [Integer, #to_int, #to_i] # @return [void] def self.set_heartbeat_timeout(self_p, heartbeat_timeout) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) heartbeat_timeout = Integer(heartbeat_timeout) result = ::CZMQ::FFI.zsock_set_heartbeat_timeout(self_p, heartbeat_timeout) result end # Get socket option `use_fd`. # Available from libzmq 4.2.0. # # @return [Integer] def use_fd() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_use_fd(self_p) result end # Get socket option `use_fd`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #use_fd. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.use_fd(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_use_fd(self_p) result end # Set socket option `use_fd`. # Available from libzmq 4.2.0. # # @param use_fd [Integer, #to_int, #to_i] # @return [void] def set_use_fd(use_fd) raise DestroyedError unless @ptr self_p = @ptr use_fd = Integer(use_fd) result = ::CZMQ::FFI.zsock_set_use_fd(self_p, use_fd) result end # Set socket option `use_fd`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_use_fd. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param use_fd [Integer, #to_int, #to_i] # @return [void] def self.set_use_fd(self_p, use_fd) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) use_fd = Integer(use_fd) result = ::CZMQ::FFI.zsock_set_use_fd(self_p, use_fd) result end # Set socket option `xpub_manual`. # Available from libzmq 4.2.0. # # @param xpub_manual [Integer, #to_int, #to_i] # @return [void] def set_xpub_manual(xpub_manual) raise DestroyedError unless @ptr self_p = @ptr xpub_manual = Integer(xpub_manual) result = ::CZMQ::FFI.zsock_set_xpub_manual(self_p, xpub_manual) result end # Set socket option `xpub_manual`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_xpub_manual. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param xpub_manual [Integer, #to_int, #to_i] # @return [void] def self.set_xpub_manual(self_p, xpub_manual) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) xpub_manual = Integer(xpub_manual) result = ::CZMQ::FFI.zsock_set_xpub_manual(self_p, xpub_manual) result end # Set socket option `xpub_welcome_msg`. # Available from libzmq 4.2.0. # # @param xpub_welcome_msg [String, #to_s, nil] # @return [void] def set_xpub_welcome_msg(xpub_welcome_msg) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_xpub_welcome_msg(self_p, xpub_welcome_msg) result end # Set socket option `xpub_welcome_msg`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_xpub_welcome_msg. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param xpub_welcome_msg [String, #to_s, nil] # @return [void] def self.set_xpub_welcome_msg(self_p, xpub_welcome_msg) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_xpub_welcome_msg(self_p, xpub_welcome_msg) result end # Set socket option `stream_notify`. # Available from libzmq 4.2.0. # # @param stream_notify [Integer, #to_int, #to_i] # @return [void] def set_stream_notify(stream_notify) raise DestroyedError unless @ptr self_p = @ptr stream_notify = Integer(stream_notify) result = ::CZMQ::FFI.zsock_set_stream_notify(self_p, stream_notify) result end # Set socket option `stream_notify`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_stream_notify. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param stream_notify [Integer, #to_int, #to_i] # @return [void] def self.set_stream_notify(self_p, stream_notify) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) stream_notify = Integer(stream_notify) result = ::CZMQ::FFI.zsock_set_stream_notify(self_p, stream_notify) result end # Get socket option `invert_matching`. # Available from libzmq 4.2.0. # # @return [Integer] def invert_matching() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_invert_matching(self_p) result end # Get socket option `invert_matching`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #invert_matching. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.invert_matching(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_invert_matching(self_p) result end # Set socket option `invert_matching`. # Available from libzmq 4.2.0. # # @param invert_matching [Integer, #to_int, #to_i] # @return [void] def set_invert_matching(invert_matching) raise DestroyedError unless @ptr self_p = @ptr invert_matching = Integer(invert_matching) result = ::CZMQ::FFI.zsock_set_invert_matching(self_p, invert_matching) result end # Set socket option `invert_matching`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_invert_matching. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param invert_matching [Integer, #to_int, #to_i] # @return [void] def self.set_invert_matching(self_p, invert_matching) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) invert_matching = Integer(invert_matching) result = ::CZMQ::FFI.zsock_set_invert_matching(self_p, invert_matching) result end # Set socket option `xpub_verboser`. # Available from libzmq 4.2.0. # # @param xpub_verboser [Integer, #to_int, #to_i] # @return [void] def set_xpub_verboser(xpub_verboser) raise DestroyedError unless @ptr self_p = @ptr xpub_verboser = Integer(xpub_verboser) result = ::CZMQ::FFI.zsock_set_xpub_verboser(self_p, xpub_verboser) result end # Set socket option `xpub_verboser`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_xpub_verboser. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param xpub_verboser [Integer, #to_int, #to_i] # @return [void] def self.set_xpub_verboser(self_p, xpub_verboser) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) xpub_verboser = Integer(xpub_verboser) result = ::CZMQ::FFI.zsock_set_xpub_verboser(self_p, xpub_verboser) result end # Get socket option `connect_timeout`. # Available from libzmq 4.2.0. # # @return [Integer] def connect_timeout() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_connect_timeout(self_p) result end # Get socket option `connect_timeout`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #connect_timeout. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.connect_timeout(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_connect_timeout(self_p) result end # Set socket option `connect_timeout`. # Available from libzmq 4.2.0. # # @param connect_timeout [Integer, #to_int, #to_i] # @return [void] def set_connect_timeout(connect_timeout) raise DestroyedError unless @ptr self_p = @ptr connect_timeout = Integer(connect_timeout) result = ::CZMQ::FFI.zsock_set_connect_timeout(self_p, connect_timeout) result end # Set socket option `connect_timeout`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_connect_timeout. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param connect_timeout [Integer, #to_int, #to_i] # @return [void] def self.set_connect_timeout(self_p, connect_timeout) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) connect_timeout = Integer(connect_timeout) result = ::CZMQ::FFI.zsock_set_connect_timeout(self_p, connect_timeout) result end # Get socket option `tcp_maxrt`. # Available from libzmq 4.2.0. # # @return [Integer] def tcp_maxrt() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_tcp_maxrt(self_p) result end # Get socket option `tcp_maxrt`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #tcp_maxrt. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.tcp_maxrt(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_tcp_maxrt(self_p) result end # Set socket option `tcp_maxrt`. # Available from libzmq 4.2.0. # # @param tcp_maxrt [Integer, #to_int, #to_i] # @return [void] def set_tcp_maxrt(tcp_maxrt) raise DestroyedError unless @ptr self_p = @ptr tcp_maxrt = Integer(tcp_maxrt) result = ::CZMQ::FFI.zsock_set_tcp_maxrt(self_p, tcp_maxrt) result end # Set socket option `tcp_maxrt`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_tcp_maxrt. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param tcp_maxrt [Integer, #to_int, #to_i] # @return [void] def self.set_tcp_maxrt(self_p, tcp_maxrt) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) tcp_maxrt = Integer(tcp_maxrt) result = ::CZMQ::FFI.zsock_set_tcp_maxrt(self_p, tcp_maxrt) result end # Get socket option `thread_safe`. # Available from libzmq 4.2.0. # # @return [Integer] def thread_safe() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_thread_safe(self_p) result end # Get socket option `thread_safe`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #thread_safe. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.thread_safe(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_thread_safe(self_p) result end # Get socket option `multicast_maxtpdu`. # Available from libzmq 4.2.0. # # @return [Integer] def multicast_maxtpdu() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_multicast_maxtpdu(self_p) result end # Get socket option `multicast_maxtpdu`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #multicast_maxtpdu. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.multicast_maxtpdu(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_multicast_maxtpdu(self_p) result end # Set socket option `multicast_maxtpdu`. # Available from libzmq 4.2.0. # # @param multicast_maxtpdu [Integer, #to_int, #to_i] # @return [void] def set_multicast_maxtpdu(multicast_maxtpdu) raise DestroyedError unless @ptr self_p = @ptr multicast_maxtpdu = Integer(multicast_maxtpdu) result = ::CZMQ::FFI.zsock_set_multicast_maxtpdu(self_p, multicast_maxtpdu) result end # Set socket option `multicast_maxtpdu`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_multicast_maxtpdu. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param multicast_maxtpdu [Integer, #to_int, #to_i] # @return [void] def self.set_multicast_maxtpdu(self_p, multicast_maxtpdu) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) multicast_maxtpdu = Integer(multicast_maxtpdu) result = ::CZMQ::FFI.zsock_set_multicast_maxtpdu(self_p, multicast_maxtpdu) result end # Get socket option `vmci_buffer_size`. # Available from libzmq 4.2.0. # # @return [Integer] def vmci_buffer_size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_vmci_buffer_size(self_p) result end # Get socket option `vmci_buffer_size`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #vmci_buffer_size. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.vmci_buffer_size(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_vmci_buffer_size(self_p) result end # Set socket option `vmci_buffer_size`. # Available from libzmq 4.2.0. # # @param vmci_buffer_size [Integer, #to_int, #to_i] # @return [void] def set_vmci_buffer_size(vmci_buffer_size) raise DestroyedError unless @ptr self_p = @ptr vmci_buffer_size = Integer(vmci_buffer_size) result = ::CZMQ::FFI.zsock_set_vmci_buffer_size(self_p, vmci_buffer_size) result end # Set socket option `vmci_buffer_size`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_vmci_buffer_size. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param vmci_buffer_size [Integer, #to_int, #to_i] # @return [void] def self.set_vmci_buffer_size(self_p, vmci_buffer_size) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) vmci_buffer_size = Integer(vmci_buffer_size) result = ::CZMQ::FFI.zsock_set_vmci_buffer_size(self_p, vmci_buffer_size) result end # Get socket option `vmci_buffer_min_size`. # Available from libzmq 4.2.0. # # @return [Integer] def vmci_buffer_min_size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_vmci_buffer_min_size(self_p) result end # Get socket option `vmci_buffer_min_size`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #vmci_buffer_min_size. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.vmci_buffer_min_size(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_vmci_buffer_min_size(self_p) result end # Set socket option `vmci_buffer_min_size`. # Available from libzmq 4.2.0. # # @param vmci_buffer_min_size [Integer, #to_int, #to_i] # @return [void] def set_vmci_buffer_min_size(vmci_buffer_min_size) raise DestroyedError unless @ptr self_p = @ptr vmci_buffer_min_size = Integer(vmci_buffer_min_size) result = ::CZMQ::FFI.zsock_set_vmci_buffer_min_size(self_p, vmci_buffer_min_size) result end # Set socket option `vmci_buffer_min_size`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_vmci_buffer_min_size. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param vmci_buffer_min_size [Integer, #to_int, #to_i] # @return [void] def self.set_vmci_buffer_min_size(self_p, vmci_buffer_min_size) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) vmci_buffer_min_size = Integer(vmci_buffer_min_size) result = ::CZMQ::FFI.zsock_set_vmci_buffer_min_size(self_p, vmci_buffer_min_size) result end # Get socket option `vmci_buffer_max_size`. # Available from libzmq 4.2.0. # # @return [Integer] def vmci_buffer_max_size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_vmci_buffer_max_size(self_p) result end # Get socket option `vmci_buffer_max_size`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #vmci_buffer_max_size. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.vmci_buffer_max_size(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_vmci_buffer_max_size(self_p) result end # Set socket option `vmci_buffer_max_size`. # Available from libzmq 4.2.0. # # @param vmci_buffer_max_size [Integer, #to_int, #to_i] # @return [void] def set_vmci_buffer_max_size(vmci_buffer_max_size) raise DestroyedError unless @ptr self_p = @ptr vmci_buffer_max_size = Integer(vmci_buffer_max_size) result = ::CZMQ::FFI.zsock_set_vmci_buffer_max_size(self_p, vmci_buffer_max_size) result end # Set socket option `vmci_buffer_max_size`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_vmci_buffer_max_size. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param vmci_buffer_max_size [Integer, #to_int, #to_i] # @return [void] def self.set_vmci_buffer_max_size(self_p, vmci_buffer_max_size) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) vmci_buffer_max_size = Integer(vmci_buffer_max_size) result = ::CZMQ::FFI.zsock_set_vmci_buffer_max_size(self_p, vmci_buffer_max_size) result end # Get socket option `vmci_connect_timeout`. # Available from libzmq 4.2.0. # # @return [Integer] def vmci_connect_timeout() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_vmci_connect_timeout(self_p) result end # Get socket option `vmci_connect_timeout`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #vmci_connect_timeout. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.vmci_connect_timeout(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_vmci_connect_timeout(self_p) result end # Set socket option `vmci_connect_timeout`. # Available from libzmq 4.2.0. # # @param vmci_connect_timeout [Integer, #to_int, #to_i] # @return [void] def set_vmci_connect_timeout(vmci_connect_timeout) raise DestroyedError unless @ptr self_p = @ptr vmci_connect_timeout = Integer(vmci_connect_timeout) result = ::CZMQ::FFI.zsock_set_vmci_connect_timeout(self_p, vmci_connect_timeout) result end # Set socket option `vmci_connect_timeout`. # Available from libzmq 4.2.0. # # This is the polymorphic version of #set_vmci_connect_timeout. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param vmci_connect_timeout [Integer, #to_int, #to_i] # @return [void] def self.set_vmci_connect_timeout(self_p, vmci_connect_timeout) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) vmci_connect_timeout = Integer(vmci_connect_timeout) result = ::CZMQ::FFI.zsock_set_vmci_connect_timeout(self_p, vmci_connect_timeout) result end # Get socket option `tos`. # Available from libzmq 4.1.0. # # @return [Integer] def tos() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_tos(self_p) result end # Get socket option `tos`. # Available from libzmq 4.1.0. # # This is the polymorphic version of #tos. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.tos(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_tos(self_p) result end # Set socket option `tos`. # Available from libzmq 4.1.0. # # @param tos [Integer, #to_int, #to_i] # @return [void] def set_tos(tos) raise DestroyedError unless @ptr self_p = @ptr tos = Integer(tos) result = ::CZMQ::FFI.zsock_set_tos(self_p, tos) result end # Set socket option `tos`. # Available from libzmq 4.1.0. # # This is the polymorphic version of #set_tos. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param tos [Integer, #to_int, #to_i] # @return [void] def self.set_tos(self_p, tos) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) tos = Integer(tos) result = ::CZMQ::FFI.zsock_set_tos(self_p, tos) result end # Set socket option `router_handover`. # Available from libzmq 4.1.0. # # @param router_handover [Integer, #to_int, #to_i] # @return [void] def set_router_handover(router_handover) raise DestroyedError unless @ptr self_p = @ptr router_handover = Integer(router_handover) result = ::CZMQ::FFI.zsock_set_router_handover(self_p, router_handover) result end # Set socket option `router_handover`. # Available from libzmq 4.1.0. # # This is the polymorphic version of #set_router_handover. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param router_handover [Integer, #to_int, #to_i] # @return [void] def self.set_router_handover(self_p, router_handover) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) router_handover = Integer(router_handover) result = ::CZMQ::FFI.zsock_set_router_handover(self_p, router_handover) result end # Set socket option `connect_rid`. # Available from libzmq 4.1.0. # # @param connect_rid [String, #to_s, nil] # @return [void] def set_connect_rid(connect_rid) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_connect_rid(self_p, connect_rid) result end # Set socket option `connect_rid`. # Available from libzmq 4.1.0. # # This is the polymorphic version of #set_connect_rid. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param connect_rid [String, #to_s, nil] # @return [void] def self.set_connect_rid(self_p, connect_rid) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_connect_rid(self_p, connect_rid) result end # Set socket option `connect_rid` from 32-octet binary # Available from libzmq 4.1.0. # # @param connect_rid [::FFI::Pointer, #to_ptr] # @return [void] def set_connect_rid_bin(connect_rid) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_connect_rid_bin(self_p, connect_rid) result end # Set socket option `connect_rid` from 32-octet binary # Available from libzmq 4.1.0. # # This is the polymorphic version of #set_connect_rid_bin. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param connect_rid [::FFI::Pointer, #to_ptr] # @return [void] def self.set_connect_rid_bin(self_p, connect_rid) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_connect_rid_bin(self_p, connect_rid) result end # Get socket option `handshake_ivl`. # Available from libzmq 4.1.0. # # @return [Integer] def handshake_ivl() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_handshake_ivl(self_p) result end # Get socket option `handshake_ivl`. # Available from libzmq 4.1.0. # # This is the polymorphic version of #handshake_ivl. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.handshake_ivl(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_handshake_ivl(self_p) result end # Set socket option `handshake_ivl`. # Available from libzmq 4.1.0. # # @param handshake_ivl [Integer, #to_int, #to_i] # @return [void] def set_handshake_ivl(handshake_ivl) raise DestroyedError unless @ptr self_p = @ptr handshake_ivl = Integer(handshake_ivl) result = ::CZMQ::FFI.zsock_set_handshake_ivl(self_p, handshake_ivl) result end # Set socket option `handshake_ivl`. # Available from libzmq 4.1.0. # # This is the polymorphic version of #set_handshake_ivl. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param handshake_ivl [Integer, #to_int, #to_i] # @return [void] def self.set_handshake_ivl(self_p, handshake_ivl) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) handshake_ivl = Integer(handshake_ivl) result = ::CZMQ::FFI.zsock_set_handshake_ivl(self_p, handshake_ivl) result end # Get socket option `socks_proxy`. # Available from libzmq 4.1.0. # # @return [::FFI::AutoPointer] def socks_proxy() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_socks_proxy(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Get socket option `socks_proxy`. # Available from libzmq 4.1.0. # # This is the polymorphic version of #socks_proxy. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [::FFI::AutoPointer] def self.socks_proxy(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_socks_proxy(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Set socket option `socks_proxy`. # Available from libzmq 4.1.0. # # @param socks_proxy [String, #to_s, nil] # @return [void] def set_socks_proxy(socks_proxy) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_socks_proxy(self_p, socks_proxy) result end # Set socket option `socks_proxy`. # Available from libzmq 4.1.0. # # This is the polymorphic version of #set_socks_proxy. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param socks_proxy [String, #to_s, nil] # @return [void] def self.set_socks_proxy(self_p, socks_proxy) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_socks_proxy(self_p, socks_proxy) result end # Set socket option `xpub_nodrop`. # Available from libzmq 4.1.0. # # @param xpub_nodrop [Integer, #to_int, #to_i] # @return [void] def set_xpub_nodrop(xpub_nodrop) raise DestroyedError unless @ptr self_p = @ptr xpub_nodrop = Integer(xpub_nodrop) result = ::CZMQ::FFI.zsock_set_xpub_nodrop(self_p, xpub_nodrop) result end # Set socket option `xpub_nodrop`. # Available from libzmq 4.1.0. # # This is the polymorphic version of #set_xpub_nodrop. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param xpub_nodrop [Integer, #to_int, #to_i] # @return [void] def self.set_xpub_nodrop(self_p, xpub_nodrop) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) xpub_nodrop = Integer(xpub_nodrop) result = ::CZMQ::FFI.zsock_set_xpub_nodrop(self_p, xpub_nodrop) result end # Set socket option `router_mandatory`. # Available from libzmq 4.0.0. # # @param router_mandatory [Integer, #to_int, #to_i] # @return [void] def set_router_mandatory(router_mandatory) raise DestroyedError unless @ptr self_p = @ptr router_mandatory = Integer(router_mandatory) result = ::CZMQ::FFI.zsock_set_router_mandatory(self_p, router_mandatory) result end # Set socket option `router_mandatory`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_router_mandatory. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param router_mandatory [Integer, #to_int, #to_i] # @return [void] def self.set_router_mandatory(self_p, router_mandatory) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) router_mandatory = Integer(router_mandatory) result = ::CZMQ::FFI.zsock_set_router_mandatory(self_p, router_mandatory) result end # Set socket option `probe_router`. # Available from libzmq 4.0.0. # # @param probe_router [Integer, #to_int, #to_i] # @return [void] def set_probe_router(probe_router) raise DestroyedError unless @ptr self_p = @ptr probe_router = Integer(probe_router) result = ::CZMQ::FFI.zsock_set_probe_router(self_p, probe_router) result end # Set socket option `probe_router`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_probe_router. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param probe_router [Integer, #to_int, #to_i] # @return [void] def self.set_probe_router(self_p, probe_router) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) probe_router = Integer(probe_router) result = ::CZMQ::FFI.zsock_set_probe_router(self_p, probe_router) result end # Set socket option `req_relaxed`. # Available from libzmq 4.0.0. # # @param req_relaxed [Integer, #to_int, #to_i] # @return [void] def set_req_relaxed(req_relaxed) raise DestroyedError unless @ptr self_p = @ptr req_relaxed = Integer(req_relaxed) result = ::CZMQ::FFI.zsock_set_req_relaxed(self_p, req_relaxed) result end # Set socket option `req_relaxed`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_req_relaxed. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param req_relaxed [Integer, #to_int, #to_i] # @return [void] def self.set_req_relaxed(self_p, req_relaxed) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) req_relaxed = Integer(req_relaxed) result = ::CZMQ::FFI.zsock_set_req_relaxed(self_p, req_relaxed) result end # Set socket option `req_correlate`. # Available from libzmq 4.0.0. # # @param req_correlate [Integer, #to_int, #to_i] # @return [void] def set_req_correlate(req_correlate) raise DestroyedError unless @ptr self_p = @ptr req_correlate = Integer(req_correlate) result = ::CZMQ::FFI.zsock_set_req_correlate(self_p, req_correlate) result end # Set socket option `req_correlate`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_req_correlate. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param req_correlate [Integer, #to_int, #to_i] # @return [void] def self.set_req_correlate(self_p, req_correlate) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) req_correlate = Integer(req_correlate) result = ::CZMQ::FFI.zsock_set_req_correlate(self_p, req_correlate) result end # Set socket option `conflate`. # Available from libzmq 4.0.0. # # @param conflate [Integer, #to_int, #to_i] # @return [void] def set_conflate(conflate) raise DestroyedError unless @ptr self_p = @ptr conflate = Integer(conflate) result = ::CZMQ::FFI.zsock_set_conflate(self_p, conflate) result end # Set socket option `conflate`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_conflate. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param conflate [Integer, #to_int, #to_i] # @return [void] def self.set_conflate(self_p, conflate) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) conflate = Integer(conflate) result = ::CZMQ::FFI.zsock_set_conflate(self_p, conflate) result end # Get socket option `zap_domain`. # Available from libzmq 4.0.0. # # @return [::FFI::AutoPointer] def zap_domain() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_zap_domain(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Get socket option `zap_domain`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #zap_domain. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [::FFI::AutoPointer] def self.zap_domain(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_zap_domain(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Set socket option `zap_domain`. # Available from libzmq 4.0.0. # # @param zap_domain [String, #to_s, nil] # @return [void] def set_zap_domain(zap_domain) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_zap_domain(self_p, zap_domain) result end # Set socket option `zap_domain`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_zap_domain. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param zap_domain [String, #to_s, nil] # @return [void] def self.set_zap_domain(self_p, zap_domain) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_zap_domain(self_p, zap_domain) result end # Get socket option `mechanism`. # Available from libzmq 4.0.0. # # @return [Integer] def mechanism() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_mechanism(self_p) result end # Get socket option `mechanism`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #mechanism. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.mechanism(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_mechanism(self_p) result end # Get socket option `plain_server`. # Available from libzmq 4.0.0. # # @return [Integer] def plain_server() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_plain_server(self_p) result end # Get socket option `plain_server`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #plain_server. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.plain_server(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_plain_server(self_p) result end # Set socket option `plain_server`. # Available from libzmq 4.0.0. # # @param plain_server [Integer, #to_int, #to_i] # @return [void] def set_plain_server(plain_server) raise DestroyedError unless @ptr self_p = @ptr plain_server = Integer(plain_server) result = ::CZMQ::FFI.zsock_set_plain_server(self_p, plain_server) result end # Set socket option `plain_server`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_plain_server. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param plain_server [Integer, #to_int, #to_i] # @return [void] def self.set_plain_server(self_p, plain_server) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) plain_server = Integer(plain_server) result = ::CZMQ::FFI.zsock_set_plain_server(self_p, plain_server) result end # Get socket option `plain_username`. # Available from libzmq 4.0.0. # # @return [::FFI::AutoPointer] def plain_username() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_plain_username(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Get socket option `plain_username`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #plain_username. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [::FFI::AutoPointer] def self.plain_username(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_plain_username(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Set socket option `plain_username`. # Available from libzmq 4.0.0. # # @param plain_username [String, #to_s, nil] # @return [void] def set_plain_username(plain_username) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_plain_username(self_p, plain_username) result end # Set socket option `plain_username`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_plain_username. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param plain_username [String, #to_s, nil] # @return [void] def self.set_plain_username(self_p, plain_username) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_plain_username(self_p, plain_username) result end # Get socket option `plain_password`. # Available from libzmq 4.0.0. # # @return [::FFI::AutoPointer] def plain_password() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_plain_password(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Get socket option `plain_password`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #plain_password. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [::FFI::AutoPointer] def self.plain_password(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_plain_password(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Set socket option `plain_password`. # Available from libzmq 4.0.0. # # @param plain_password [String, #to_s, nil] # @return [void] def set_plain_password(plain_password) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_plain_password(self_p, plain_password) result end # Set socket option `plain_password`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_plain_password. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param plain_password [String, #to_s, nil] # @return [void] def self.set_plain_password(self_p, plain_password) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_plain_password(self_p, plain_password) result end # Get socket option `curve_server`. # Available from libzmq 4.0.0. # # @return [Integer] def curve_server() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_curve_server(self_p) result end # Get socket option `curve_server`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #curve_server. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.curve_server(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_curve_server(self_p) result end # Set socket option `curve_server`. # Available from libzmq 4.0.0. # # @param curve_server [Integer, #to_int, #to_i] # @return [void] def set_curve_server(curve_server) raise DestroyedError unless @ptr self_p = @ptr curve_server = Integer(curve_server) result = ::CZMQ::FFI.zsock_set_curve_server(self_p, curve_server) result end # Set socket option `curve_server`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_curve_server. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param curve_server [Integer, #to_int, #to_i] # @return [void] def self.set_curve_server(self_p, curve_server) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) curve_server = Integer(curve_server) result = ::CZMQ::FFI.zsock_set_curve_server(self_p, curve_server) result end # Get socket option `curve_publickey`. # Available from libzmq 4.0.0. # # @return [::FFI::AutoPointer] def curve_publickey() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_curve_publickey(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Get socket option `curve_publickey`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #curve_publickey. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [::FFI::AutoPointer] def self.curve_publickey(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_curve_publickey(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Set socket option `curve_publickey`. # Available from libzmq 4.0.0. # # @param curve_publickey [String, #to_s, nil] # @return [void] def set_curve_publickey(curve_publickey) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_curve_publickey(self_p, curve_publickey) result end # Set socket option `curve_publickey`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_curve_publickey. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param curve_publickey [String, #to_s, nil] # @return [void] def self.set_curve_publickey(self_p, curve_publickey) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_curve_publickey(self_p, curve_publickey) result end # Set socket option `curve_publickey` from 32-octet binary # Available from libzmq 4.0.0. # # @param curve_publickey [::FFI::Pointer, #to_ptr] # @return [void] def set_curve_publickey_bin(curve_publickey) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_curve_publickey_bin(self_p, curve_publickey) result end # Set socket option `curve_publickey` from 32-octet binary # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_curve_publickey_bin. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param curve_publickey [::FFI::Pointer, #to_ptr] # @return [void] def self.set_curve_publickey_bin(self_p, curve_publickey) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_curve_publickey_bin(self_p, curve_publickey) result end # Get socket option `curve_secretkey`. # Available from libzmq 4.0.0. # # @return [::FFI::AutoPointer] def curve_secretkey() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_curve_secretkey(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Get socket option `curve_secretkey`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #curve_secretkey. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [::FFI::AutoPointer] def self.curve_secretkey(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_curve_secretkey(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Set socket option `curve_secretkey`. # Available from libzmq 4.0.0. # # @param curve_secretkey [String, #to_s, nil] # @return [void] def set_curve_secretkey(curve_secretkey) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_curve_secretkey(self_p, curve_secretkey) result end # Set socket option `curve_secretkey`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_curve_secretkey. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param curve_secretkey [String, #to_s, nil] # @return [void] def self.set_curve_secretkey(self_p, curve_secretkey) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_curve_secretkey(self_p, curve_secretkey) result end # Set socket option `curve_secretkey` from 32-octet binary # Available from libzmq 4.0.0. # # @param curve_secretkey [::FFI::Pointer, #to_ptr] # @return [void] def set_curve_secretkey_bin(curve_secretkey) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_curve_secretkey_bin(self_p, curve_secretkey) result end # Set socket option `curve_secretkey` from 32-octet binary # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_curve_secretkey_bin. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param curve_secretkey [::FFI::Pointer, #to_ptr] # @return [void] def self.set_curve_secretkey_bin(self_p, curve_secretkey) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_curve_secretkey_bin(self_p, curve_secretkey) result end # Get socket option `curve_serverkey`. # Available from libzmq 4.0.0. # # @return [::FFI::AutoPointer] def curve_serverkey() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_curve_serverkey(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Get socket option `curve_serverkey`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #curve_serverkey. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [::FFI::AutoPointer] def self.curve_serverkey(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_curve_serverkey(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Set socket option `curve_serverkey`. # Available from libzmq 4.0.0. # # @param curve_serverkey [String, #to_s, nil] # @return [void] def set_curve_serverkey(curve_serverkey) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_curve_serverkey(self_p, curve_serverkey) result end # Set socket option `curve_serverkey`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_curve_serverkey. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param curve_serverkey [String, #to_s, nil] # @return [void] def self.set_curve_serverkey(self_p, curve_serverkey) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_curve_serverkey(self_p, curve_serverkey) result end # Set socket option `curve_serverkey` from 32-octet binary # Available from libzmq 4.0.0. # # @param curve_serverkey [::FFI::Pointer, #to_ptr] # @return [void] def set_curve_serverkey_bin(curve_serverkey) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_curve_serverkey_bin(self_p, curve_serverkey) result end # Set socket option `curve_serverkey` from 32-octet binary # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_curve_serverkey_bin. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param curve_serverkey [::FFI::Pointer, #to_ptr] # @return [void] def self.set_curve_serverkey_bin(self_p, curve_serverkey) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_curve_serverkey_bin(self_p, curve_serverkey) result end # Get socket option `gssapi_server`. # Available from libzmq 4.0.0. # # @return [Integer] def gssapi_server() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_gssapi_server(self_p) result end # Get socket option `gssapi_server`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #gssapi_server. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.gssapi_server(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_gssapi_server(self_p) result end # Set socket option `gssapi_server`. # Available from libzmq 4.0.0. # # @param gssapi_server [Integer, #to_int, #to_i] # @return [void] def set_gssapi_server(gssapi_server) raise DestroyedError unless @ptr self_p = @ptr gssapi_server = Integer(gssapi_server) result = ::CZMQ::FFI.zsock_set_gssapi_server(self_p, gssapi_server) result end # Set socket option `gssapi_server`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_gssapi_server. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param gssapi_server [Integer, #to_int, #to_i] # @return [void] def self.set_gssapi_server(self_p, gssapi_server) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) gssapi_server = Integer(gssapi_server) result = ::CZMQ::FFI.zsock_set_gssapi_server(self_p, gssapi_server) result end # Get socket option `gssapi_plaintext`. # Available from libzmq 4.0.0. # # @return [Integer] def gssapi_plaintext() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_gssapi_plaintext(self_p) result end # Get socket option `gssapi_plaintext`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #gssapi_plaintext. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.gssapi_plaintext(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_gssapi_plaintext(self_p) result end # Set socket option `gssapi_plaintext`. # Available from libzmq 4.0.0. # # @param gssapi_plaintext [Integer, #to_int, #to_i] # @return [void] def set_gssapi_plaintext(gssapi_plaintext) raise DestroyedError unless @ptr self_p = @ptr gssapi_plaintext = Integer(gssapi_plaintext) result = ::CZMQ::FFI.zsock_set_gssapi_plaintext(self_p, gssapi_plaintext) result end # Set socket option `gssapi_plaintext`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_gssapi_plaintext. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param gssapi_plaintext [Integer, #to_int, #to_i] # @return [void] def self.set_gssapi_plaintext(self_p, gssapi_plaintext) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) gssapi_plaintext = Integer(gssapi_plaintext) result = ::CZMQ::FFI.zsock_set_gssapi_plaintext(self_p, gssapi_plaintext) result end # Get socket option `gssapi_principal`. # Available from libzmq 4.0.0. # # @return [::FFI::AutoPointer] def gssapi_principal() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_gssapi_principal(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Get socket option `gssapi_principal`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #gssapi_principal. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [::FFI::AutoPointer] def self.gssapi_principal(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_gssapi_principal(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Set socket option `gssapi_principal`. # Available from libzmq 4.0.0. # # @param gssapi_principal [String, #to_s, nil] # @return [void] def set_gssapi_principal(gssapi_principal) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_gssapi_principal(self_p, gssapi_principal) result end # Set socket option `gssapi_principal`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_gssapi_principal. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param gssapi_principal [String, #to_s, nil] # @return [void] def self.set_gssapi_principal(self_p, gssapi_principal) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_gssapi_principal(self_p, gssapi_principal) result end # Get socket option `gssapi_service_principal`. # Available from libzmq 4.0.0. # # @return [::FFI::AutoPointer] def gssapi_service_principal() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_gssapi_service_principal(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Get socket option `gssapi_service_principal`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #gssapi_service_principal. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [::FFI::AutoPointer] def self.gssapi_service_principal(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_gssapi_service_principal(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Set socket option `gssapi_service_principal`. # Available from libzmq 4.0.0. # # @param gssapi_service_principal [String, #to_s, nil] # @return [void] def set_gssapi_service_principal(gssapi_service_principal) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_gssapi_service_principal(self_p, gssapi_service_principal) result end # Set socket option `gssapi_service_principal`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_gssapi_service_principal. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param gssapi_service_principal [String, #to_s, nil] # @return [void] def self.set_gssapi_service_principal(self_p, gssapi_service_principal) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_gssapi_service_principal(self_p, gssapi_service_principal) result end # Get socket option `ipv6`. # Available from libzmq 4.0.0. # # @return [Integer] def ipv6() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_ipv6(self_p) result end # Get socket option `ipv6`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #ipv6. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.ipv6(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_ipv6(self_p) result end # Set socket option `ipv6`. # Available from libzmq 4.0.0. # # @param ipv6 [Integer, #to_int, #to_i] # @return [void] def set_ipv6(ipv6) raise DestroyedError unless @ptr self_p = @ptr ipv6 = Integer(ipv6) result = ::CZMQ::FFI.zsock_set_ipv6(self_p, ipv6) result end # Set socket option `ipv6`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_ipv6. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param ipv6 [Integer, #to_int, #to_i] # @return [void] def self.set_ipv6(self_p, ipv6) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) ipv6 = Integer(ipv6) result = ::CZMQ::FFI.zsock_set_ipv6(self_p, ipv6) result end # Get socket option `immediate`. # Available from libzmq 4.0.0. # # @return [Integer] def immediate() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_immediate(self_p) result end # Get socket option `immediate`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #immediate. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.immediate(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_immediate(self_p) result end # Set socket option `immediate`. # Available from libzmq 4.0.0. # # @param immediate [Integer, #to_int, #to_i] # @return [void] def set_immediate(immediate) raise DestroyedError unless @ptr self_p = @ptr immediate = Integer(immediate) result = ::CZMQ::FFI.zsock_set_immediate(self_p, immediate) result end # Set socket option `immediate`. # Available from libzmq 4.0.0. # # This is the polymorphic version of #set_immediate. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param immediate [Integer, #to_int, #to_i] # @return [void] def self.set_immediate(self_p, immediate) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) immediate = Integer(immediate) result = ::CZMQ::FFI.zsock_set_immediate(self_p, immediate) result end # Get socket option `sndhwm`. # Available from libzmq 3.0.0. # # @return [Integer] def sndhwm() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_sndhwm(self_p) result end # Get socket option `sndhwm`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #sndhwm. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.sndhwm(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_sndhwm(self_p) result end # Set socket option `sndhwm`. # Available from libzmq 3.0.0. # # @param sndhwm [Integer, #to_int, #to_i] # @return [void] def set_sndhwm(sndhwm) raise DestroyedError unless @ptr self_p = @ptr sndhwm = Integer(sndhwm) result = ::CZMQ::FFI.zsock_set_sndhwm(self_p, sndhwm) result end # Set socket option `sndhwm`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_sndhwm. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param sndhwm [Integer, #to_int, #to_i] # @return [void] def self.set_sndhwm(self_p, sndhwm) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) sndhwm = Integer(sndhwm) result = ::CZMQ::FFI.zsock_set_sndhwm(self_p, sndhwm) result end # Get socket option `rcvhwm`. # Available from libzmq 3.0.0. # # @return [Integer] def rcvhwm() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_rcvhwm(self_p) result end # Get socket option `rcvhwm`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #rcvhwm. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.rcvhwm(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_rcvhwm(self_p) result end # Set socket option `rcvhwm`. # Available from libzmq 3.0.0. # # @param rcvhwm [Integer, #to_int, #to_i] # @return [void] def set_rcvhwm(rcvhwm) raise DestroyedError unless @ptr self_p = @ptr rcvhwm = Integer(rcvhwm) result = ::CZMQ::FFI.zsock_set_rcvhwm(self_p, rcvhwm) result end # Set socket option `rcvhwm`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_rcvhwm. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param rcvhwm [Integer, #to_int, #to_i] # @return [void] def self.set_rcvhwm(self_p, rcvhwm) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) rcvhwm = Integer(rcvhwm) result = ::CZMQ::FFI.zsock_set_rcvhwm(self_p, rcvhwm) result end # Get socket option `maxmsgsize`. # Available from libzmq 3.0.0. # # @return [Integer] def maxmsgsize() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_maxmsgsize(self_p) result end # Get socket option `maxmsgsize`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #maxmsgsize. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.maxmsgsize(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_maxmsgsize(self_p) result end # Set socket option `maxmsgsize`. # Available from libzmq 3.0.0. # # @param maxmsgsize [Integer, #to_int, #to_i] # @return [void] def set_maxmsgsize(maxmsgsize) raise DestroyedError unless @ptr self_p = @ptr maxmsgsize = Integer(maxmsgsize) result = ::CZMQ::FFI.zsock_set_maxmsgsize(self_p, maxmsgsize) result end # Set socket option `maxmsgsize`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_maxmsgsize. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param maxmsgsize [Integer, #to_int, #to_i] # @return [void] def self.set_maxmsgsize(self_p, maxmsgsize) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) maxmsgsize = Integer(maxmsgsize) result = ::CZMQ::FFI.zsock_set_maxmsgsize(self_p, maxmsgsize) result end # Get socket option `multicast_hops`. # Available from libzmq 3.0.0. # # @return [Integer] def multicast_hops() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_multicast_hops(self_p) result end # Get socket option `multicast_hops`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #multicast_hops. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.multicast_hops(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_multicast_hops(self_p) result end # Set socket option `multicast_hops`. # Available from libzmq 3.0.0. # # @param multicast_hops [Integer, #to_int, #to_i] # @return [void] def set_multicast_hops(multicast_hops) raise DestroyedError unless @ptr self_p = @ptr multicast_hops = Integer(multicast_hops) result = ::CZMQ::FFI.zsock_set_multicast_hops(self_p, multicast_hops) result end # Set socket option `multicast_hops`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_multicast_hops. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param multicast_hops [Integer, #to_int, #to_i] # @return [void] def self.set_multicast_hops(self_p, multicast_hops) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) multicast_hops = Integer(multicast_hops) result = ::CZMQ::FFI.zsock_set_multicast_hops(self_p, multicast_hops) result end # Set socket option `xpub_verbose`. # Available from libzmq 3.0.0. # # @param xpub_verbose [Integer, #to_int, #to_i] # @return [void] def set_xpub_verbose(xpub_verbose) raise DestroyedError unless @ptr self_p = @ptr xpub_verbose = Integer(xpub_verbose) result = ::CZMQ::FFI.zsock_set_xpub_verbose(self_p, xpub_verbose) result end # Set socket option `xpub_verbose`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_xpub_verbose. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param xpub_verbose [Integer, #to_int, #to_i] # @return [void] def self.set_xpub_verbose(self_p, xpub_verbose) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) xpub_verbose = Integer(xpub_verbose) result = ::CZMQ::FFI.zsock_set_xpub_verbose(self_p, xpub_verbose) result end # Get socket option `tcp_keepalive`. # Available from libzmq 3.0.0. # # @return [Integer] def tcp_keepalive() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_tcp_keepalive(self_p) result end # Get socket option `tcp_keepalive`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #tcp_keepalive. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.tcp_keepalive(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_tcp_keepalive(self_p) result end # Set socket option `tcp_keepalive`. # Available from libzmq 3.0.0. # # @param tcp_keepalive [Integer, #to_int, #to_i] # @return [void] def set_tcp_keepalive(tcp_keepalive) raise DestroyedError unless @ptr self_p = @ptr tcp_keepalive = Integer(tcp_keepalive) result = ::CZMQ::FFI.zsock_set_tcp_keepalive(self_p, tcp_keepalive) result end # Set socket option `tcp_keepalive`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_tcp_keepalive. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param tcp_keepalive [Integer, #to_int, #to_i] # @return [void] def self.set_tcp_keepalive(self_p, tcp_keepalive) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) tcp_keepalive = Integer(tcp_keepalive) result = ::CZMQ::FFI.zsock_set_tcp_keepalive(self_p, tcp_keepalive) result end # Get socket option `tcp_keepalive_idle`. # Available from libzmq 3.0.0. # # @return [Integer] def tcp_keepalive_idle() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_tcp_keepalive_idle(self_p) result end # Get socket option `tcp_keepalive_idle`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #tcp_keepalive_idle. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.tcp_keepalive_idle(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_tcp_keepalive_idle(self_p) result end # Set socket option `tcp_keepalive_idle`. # Available from libzmq 3.0.0. # # @param tcp_keepalive_idle [Integer, #to_int, #to_i] # @return [void] def set_tcp_keepalive_idle(tcp_keepalive_idle) raise DestroyedError unless @ptr self_p = @ptr tcp_keepalive_idle = Integer(tcp_keepalive_idle) result = ::CZMQ::FFI.zsock_set_tcp_keepalive_idle(self_p, tcp_keepalive_idle) result end # Set socket option `tcp_keepalive_idle`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_tcp_keepalive_idle. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param tcp_keepalive_idle [Integer, #to_int, #to_i] # @return [void] def self.set_tcp_keepalive_idle(self_p, tcp_keepalive_idle) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) tcp_keepalive_idle = Integer(tcp_keepalive_idle) result = ::CZMQ::FFI.zsock_set_tcp_keepalive_idle(self_p, tcp_keepalive_idle) result end # Get socket option `tcp_keepalive_cnt`. # Available from libzmq 3.0.0. # # @return [Integer] def tcp_keepalive_cnt() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_tcp_keepalive_cnt(self_p) result end # Get socket option `tcp_keepalive_cnt`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #tcp_keepalive_cnt. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.tcp_keepalive_cnt(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_tcp_keepalive_cnt(self_p) result end # Set socket option `tcp_keepalive_cnt`. # Available from libzmq 3.0.0. # # @param tcp_keepalive_cnt [Integer, #to_int, #to_i] # @return [void] def set_tcp_keepalive_cnt(tcp_keepalive_cnt) raise DestroyedError unless @ptr self_p = @ptr tcp_keepalive_cnt = Integer(tcp_keepalive_cnt) result = ::CZMQ::FFI.zsock_set_tcp_keepalive_cnt(self_p, tcp_keepalive_cnt) result end # Set socket option `tcp_keepalive_cnt`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_tcp_keepalive_cnt. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param tcp_keepalive_cnt [Integer, #to_int, #to_i] # @return [void] def self.set_tcp_keepalive_cnt(self_p, tcp_keepalive_cnt) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) tcp_keepalive_cnt = Integer(tcp_keepalive_cnt) result = ::CZMQ::FFI.zsock_set_tcp_keepalive_cnt(self_p, tcp_keepalive_cnt) result end # Get socket option `tcp_keepalive_intvl`. # Available from libzmq 3.0.0. # # @return [Integer] def tcp_keepalive_intvl() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_tcp_keepalive_intvl(self_p) result end # Get socket option `tcp_keepalive_intvl`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #tcp_keepalive_intvl. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.tcp_keepalive_intvl(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_tcp_keepalive_intvl(self_p) result end # Set socket option `tcp_keepalive_intvl`. # Available from libzmq 3.0.0. # # @param tcp_keepalive_intvl [Integer, #to_int, #to_i] # @return [void] def set_tcp_keepalive_intvl(tcp_keepalive_intvl) raise DestroyedError unless @ptr self_p = @ptr tcp_keepalive_intvl = Integer(tcp_keepalive_intvl) result = ::CZMQ::FFI.zsock_set_tcp_keepalive_intvl(self_p, tcp_keepalive_intvl) result end # Set socket option `tcp_keepalive_intvl`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_tcp_keepalive_intvl. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param tcp_keepalive_intvl [Integer, #to_int, #to_i] # @return [void] def self.set_tcp_keepalive_intvl(self_p, tcp_keepalive_intvl) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) tcp_keepalive_intvl = Integer(tcp_keepalive_intvl) result = ::CZMQ::FFI.zsock_set_tcp_keepalive_intvl(self_p, tcp_keepalive_intvl) result end # Get socket option `tcp_accept_filter`. # Available from libzmq 3.0.0. # # @return [::FFI::AutoPointer] def tcp_accept_filter() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_tcp_accept_filter(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Get socket option `tcp_accept_filter`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #tcp_accept_filter. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [::FFI::AutoPointer] def self.tcp_accept_filter(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_tcp_accept_filter(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Set socket option `tcp_accept_filter`. # Available from libzmq 3.0.0. # # @param tcp_accept_filter [String, #to_s, nil] # @return [void] def set_tcp_accept_filter(tcp_accept_filter) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_tcp_accept_filter(self_p, tcp_accept_filter) result end # Set socket option `tcp_accept_filter`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_tcp_accept_filter. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param tcp_accept_filter [String, #to_s, nil] # @return [void] def self.set_tcp_accept_filter(self_p, tcp_accept_filter) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_tcp_accept_filter(self_p, tcp_accept_filter) result end # Get socket option `last_endpoint`. # Available from libzmq 3.0.0. # # @return [::FFI::AutoPointer] def last_endpoint() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_last_endpoint(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Get socket option `last_endpoint`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #last_endpoint. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [::FFI::AutoPointer] def self.last_endpoint(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_last_endpoint(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Set socket option `router_raw`. # Available from libzmq 3.0.0. # # @param router_raw [Integer, #to_int, #to_i] # @return [void] def set_router_raw(router_raw) raise DestroyedError unless @ptr self_p = @ptr router_raw = Integer(router_raw) result = ::CZMQ::FFI.zsock_set_router_raw(self_p, router_raw) result end # Set socket option `router_raw`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_router_raw. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param router_raw [Integer, #to_int, #to_i] # @return [void] def self.set_router_raw(self_p, router_raw) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) router_raw = Integer(router_raw) result = ::CZMQ::FFI.zsock_set_router_raw(self_p, router_raw) result end # Get socket option `ipv4only`. # Available from libzmq 3.0.0. # # @return [Integer] def ipv4only() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_ipv4only(self_p) result end # Get socket option `ipv4only`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #ipv4only. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.ipv4only(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_ipv4only(self_p) result end # Set socket option `ipv4only`. # Available from libzmq 3.0.0. # # @param ipv4only [Integer, #to_int, #to_i] # @return [void] def set_ipv4only(ipv4only) raise DestroyedError unless @ptr self_p = @ptr ipv4only = Integer(ipv4only) result = ::CZMQ::FFI.zsock_set_ipv4only(self_p, ipv4only) result end # Set socket option `ipv4only`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_ipv4only. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param ipv4only [Integer, #to_int, #to_i] # @return [void] def self.set_ipv4only(self_p, ipv4only) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) ipv4only = Integer(ipv4only) result = ::CZMQ::FFI.zsock_set_ipv4only(self_p, ipv4only) result end # Set socket option `delay_attach_on_connect`. # Available from libzmq 3.0.0. # # @param delay_attach_on_connect [Integer, #to_int, #to_i] # @return [void] def set_delay_attach_on_connect(delay_attach_on_connect) raise DestroyedError unless @ptr self_p = @ptr delay_attach_on_connect = Integer(delay_attach_on_connect) result = ::CZMQ::FFI.zsock_set_delay_attach_on_connect(self_p, delay_attach_on_connect) result end # Set socket option `delay_attach_on_connect`. # Available from libzmq 3.0.0. # # This is the polymorphic version of #set_delay_attach_on_connect. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param delay_attach_on_connect [Integer, #to_int, #to_i] # @return [void] def self.set_delay_attach_on_connect(self_p, delay_attach_on_connect) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) delay_attach_on_connect = Integer(delay_attach_on_connect) result = ::CZMQ::FFI.zsock_set_delay_attach_on_connect(self_p, delay_attach_on_connect) result end # Get socket option `hwm`. # Available from libzmq 2.0.0 to 3.0.0. # # @return [Integer] def hwm() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_hwm(self_p) result end # Get socket option `hwm`. # Available from libzmq 2.0.0 to 3.0.0. # # This is the polymorphic version of #hwm. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.hwm(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_hwm(self_p) result end # Set socket option `hwm`. # Available from libzmq 2.0.0 to 3.0.0. # # @param hwm [Integer, #to_int, #to_i] # @return [void] def set_hwm(hwm) raise DestroyedError unless @ptr self_p = @ptr hwm = Integer(hwm) result = ::CZMQ::FFI.zsock_set_hwm(self_p, hwm) result end # Set socket option `hwm`. # Available from libzmq 2.0.0 to 3.0.0. # # This is the polymorphic version of #set_hwm. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param hwm [Integer, #to_int, #to_i] # @return [void] def self.set_hwm(self_p, hwm) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) hwm = Integer(hwm) result = ::CZMQ::FFI.zsock_set_hwm(self_p, hwm) result end # Get socket option `swap`. # Available from libzmq 2.0.0 to 3.0.0. # # @return [Integer] def swap() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_swap(self_p) result end # Get socket option `swap`. # Available from libzmq 2.0.0 to 3.0.0. # # This is the polymorphic version of #swap. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.swap(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_swap(self_p) result end # Set socket option `swap`. # Available from libzmq 2.0.0 to 3.0.0. # # @param swap [Integer, #to_int, #to_i] # @return [void] def set_swap(swap) raise DestroyedError unless @ptr self_p = @ptr swap = Integer(swap) result = ::CZMQ::FFI.zsock_set_swap(self_p, swap) result end # Set socket option `swap`. # Available from libzmq 2.0.0 to 3.0.0. # # This is the polymorphic version of #set_swap. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param swap [Integer, #to_int, #to_i] # @return [void] def self.set_swap(self_p, swap) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) swap = Integer(swap) result = ::CZMQ::FFI.zsock_set_swap(self_p, swap) result end # Get socket option `affinity`. # Available from libzmq 2.0.0. # # @return [Integer] def affinity() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_affinity(self_p) result end # Get socket option `affinity`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #affinity. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.affinity(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_affinity(self_p) result end # Set socket option `affinity`. # Available from libzmq 2.0.0. # # @param affinity [Integer, #to_int, #to_i] # @return [void] def set_affinity(affinity) raise DestroyedError unless @ptr self_p = @ptr affinity = Integer(affinity) result = ::CZMQ::FFI.zsock_set_affinity(self_p, affinity) result end # Set socket option `affinity`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #set_affinity. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param affinity [Integer, #to_int, #to_i] # @return [void] def self.set_affinity(self_p, affinity) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) affinity = Integer(affinity) result = ::CZMQ::FFI.zsock_set_affinity(self_p, affinity) result end # Get socket option `identity`. # Available from libzmq 2.0.0. # # @return [::FFI::AutoPointer] def identity() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_identity(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Get socket option `identity`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #identity. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [::FFI::AutoPointer] def self.identity(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_identity(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Set socket option `identity`. # Available from libzmq 2.0.0. # # @param identity [String, #to_s, nil] # @return [void] def set_identity(identity) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_identity(self_p, identity) result end # Set socket option `identity`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #set_identity. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param identity [String, #to_s, nil] # @return [void] def self.set_identity(self_p, identity) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_identity(self_p, identity) result end # Get socket option `rate`. # Available from libzmq 2.0.0. # # @return [Integer] def rate() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_rate(self_p) result end # Get socket option `rate`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #rate. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.rate(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_rate(self_p) result end # Set socket option `rate`. # Available from libzmq 2.0.0. # # @param rate [Integer, #to_int, #to_i] # @return [void] def set_rate(rate) raise DestroyedError unless @ptr self_p = @ptr rate = Integer(rate) result = ::CZMQ::FFI.zsock_set_rate(self_p, rate) result end # Set socket option `rate`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #set_rate. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param rate [Integer, #to_int, #to_i] # @return [void] def self.set_rate(self_p, rate) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) rate = Integer(rate) result = ::CZMQ::FFI.zsock_set_rate(self_p, rate) result end # Get socket option `recovery_ivl`. # Available from libzmq 2.0.0. # # @return [Integer] def recovery_ivl() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_recovery_ivl(self_p) result end # Get socket option `recovery_ivl`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #recovery_ivl. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.recovery_ivl(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_recovery_ivl(self_p) result end # Set socket option `recovery_ivl`. # Available from libzmq 2.0.0. # # @param recovery_ivl [Integer, #to_int, #to_i] # @return [void] def set_recovery_ivl(recovery_ivl) raise DestroyedError unless @ptr self_p = @ptr recovery_ivl = Integer(recovery_ivl) result = ::CZMQ::FFI.zsock_set_recovery_ivl(self_p, recovery_ivl) result end # Set socket option `recovery_ivl`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #set_recovery_ivl. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param recovery_ivl [Integer, #to_int, #to_i] # @return [void] def self.set_recovery_ivl(self_p, recovery_ivl) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) recovery_ivl = Integer(recovery_ivl) result = ::CZMQ::FFI.zsock_set_recovery_ivl(self_p, recovery_ivl) result end # Get socket option `recovery_ivl_msec`. # Available from libzmq 2.0.0 to 3.0.0. # # @return [Integer] def recovery_ivl_msec() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_recovery_ivl_msec(self_p) result end # Get socket option `recovery_ivl_msec`. # Available from libzmq 2.0.0 to 3.0.0. # # This is the polymorphic version of #recovery_ivl_msec. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.recovery_ivl_msec(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_recovery_ivl_msec(self_p) result end # Set socket option `recovery_ivl_msec`. # Available from libzmq 2.0.0 to 3.0.0. # # @param recovery_ivl_msec [Integer, #to_int, #to_i] # @return [void] def set_recovery_ivl_msec(recovery_ivl_msec) raise DestroyedError unless @ptr self_p = @ptr recovery_ivl_msec = Integer(recovery_ivl_msec) result = ::CZMQ::FFI.zsock_set_recovery_ivl_msec(self_p, recovery_ivl_msec) result end # Set socket option `recovery_ivl_msec`. # Available from libzmq 2.0.0 to 3.0.0. # # This is the polymorphic version of #set_recovery_ivl_msec. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param recovery_ivl_msec [Integer, #to_int, #to_i] # @return [void] def self.set_recovery_ivl_msec(self_p, recovery_ivl_msec) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) recovery_ivl_msec = Integer(recovery_ivl_msec) result = ::CZMQ::FFI.zsock_set_recovery_ivl_msec(self_p, recovery_ivl_msec) result end # Get socket option `mcast_loop`. # Available from libzmq 2.0.0 to 3.0.0. # # @return [Integer] def mcast_loop() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_mcast_loop(self_p) result end # Get socket option `mcast_loop`. # Available from libzmq 2.0.0 to 3.0.0. # # This is the polymorphic version of #mcast_loop. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.mcast_loop(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_mcast_loop(self_p) result end # Set socket option `mcast_loop`. # Available from libzmq 2.0.0 to 3.0.0. # # @param mcast_loop [Integer, #to_int, #to_i] # @return [void] def set_mcast_loop(mcast_loop) raise DestroyedError unless @ptr self_p = @ptr mcast_loop = Integer(mcast_loop) result = ::CZMQ::FFI.zsock_set_mcast_loop(self_p, mcast_loop) result end # Set socket option `mcast_loop`. # Available from libzmq 2.0.0 to 3.0.0. # # This is the polymorphic version of #set_mcast_loop. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param mcast_loop [Integer, #to_int, #to_i] # @return [void] def self.set_mcast_loop(self_p, mcast_loop) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) mcast_loop = Integer(mcast_loop) result = ::CZMQ::FFI.zsock_set_mcast_loop(self_p, mcast_loop) result end # Get socket option `rcvtimeo`. # Available from libzmq 2.2.0. # # @return [Integer] def rcvtimeo() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_rcvtimeo(self_p) result end # Get socket option `rcvtimeo`. # Available from libzmq 2.2.0. # # This is the polymorphic version of #rcvtimeo. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.rcvtimeo(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_rcvtimeo(self_p) result end # Set socket option `rcvtimeo`. # Available from libzmq 2.2.0. # # @param rcvtimeo [Integer, #to_int, #to_i] # @return [void] def set_rcvtimeo(rcvtimeo) raise DestroyedError unless @ptr self_p = @ptr rcvtimeo = Integer(rcvtimeo) result = ::CZMQ::FFI.zsock_set_rcvtimeo(self_p, rcvtimeo) result end # Set socket option `rcvtimeo`. # Available from libzmq 2.2.0. # # This is the polymorphic version of #set_rcvtimeo. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param rcvtimeo [Integer, #to_int, #to_i] # @return [void] def self.set_rcvtimeo(self_p, rcvtimeo) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) rcvtimeo = Integer(rcvtimeo) result = ::CZMQ::FFI.zsock_set_rcvtimeo(self_p, rcvtimeo) result end # Get socket option `sndtimeo`. # Available from libzmq 2.2.0. # # @return [Integer] def sndtimeo() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_sndtimeo(self_p) result end # Get socket option `sndtimeo`. # Available from libzmq 2.2.0. # # This is the polymorphic version of #sndtimeo. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.sndtimeo(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_sndtimeo(self_p) result end # Set socket option `sndtimeo`. # Available from libzmq 2.2.0. # # @param sndtimeo [Integer, #to_int, #to_i] # @return [void] def set_sndtimeo(sndtimeo) raise DestroyedError unless @ptr self_p = @ptr sndtimeo = Integer(sndtimeo) result = ::CZMQ::FFI.zsock_set_sndtimeo(self_p, sndtimeo) result end # Set socket option `sndtimeo`. # Available from libzmq 2.2.0. # # This is the polymorphic version of #set_sndtimeo. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param sndtimeo [Integer, #to_int, #to_i] # @return [void] def self.set_sndtimeo(self_p, sndtimeo) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) sndtimeo = Integer(sndtimeo) result = ::CZMQ::FFI.zsock_set_sndtimeo(self_p, sndtimeo) result end # Get socket option `sndbuf`. # Available from libzmq 2.0.0. # # @return [Integer] def sndbuf() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_sndbuf(self_p) result end # Get socket option `sndbuf`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #sndbuf. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.sndbuf(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_sndbuf(self_p) result end # Set socket option `sndbuf`. # Available from libzmq 2.0.0. # # @param sndbuf [Integer, #to_int, #to_i] # @return [void] def set_sndbuf(sndbuf) raise DestroyedError unless @ptr self_p = @ptr sndbuf = Integer(sndbuf) result = ::CZMQ::FFI.zsock_set_sndbuf(self_p, sndbuf) result end # Set socket option `sndbuf`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #set_sndbuf. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param sndbuf [Integer, #to_int, #to_i] # @return [void] def self.set_sndbuf(self_p, sndbuf) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) sndbuf = Integer(sndbuf) result = ::CZMQ::FFI.zsock_set_sndbuf(self_p, sndbuf) result end # Get socket option `rcvbuf`. # Available from libzmq 2.0.0. # # @return [Integer] def rcvbuf() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_rcvbuf(self_p) result end # Get socket option `rcvbuf`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #rcvbuf. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.rcvbuf(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_rcvbuf(self_p) result end # Set socket option `rcvbuf`. # Available from libzmq 2.0.0. # # @param rcvbuf [Integer, #to_int, #to_i] # @return [void] def set_rcvbuf(rcvbuf) raise DestroyedError unless @ptr self_p = @ptr rcvbuf = Integer(rcvbuf) result = ::CZMQ::FFI.zsock_set_rcvbuf(self_p, rcvbuf) result end # Set socket option `rcvbuf`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #set_rcvbuf. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param rcvbuf [Integer, #to_int, #to_i] # @return [void] def self.set_rcvbuf(self_p, rcvbuf) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) rcvbuf = Integer(rcvbuf) result = ::CZMQ::FFI.zsock_set_rcvbuf(self_p, rcvbuf) result end # Get socket option `linger`. # Available from libzmq 2.0.0. # # @return [Integer] def linger() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_linger(self_p) result end # Get socket option `linger`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #linger. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.linger(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_linger(self_p) result end # Set socket option `linger`. # Available from libzmq 2.0.0. # # @param linger [Integer, #to_int, #to_i] # @return [void] def set_linger(linger) raise DestroyedError unless @ptr self_p = @ptr linger = Integer(linger) result = ::CZMQ::FFI.zsock_set_linger(self_p, linger) result end # Set socket option `linger`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #set_linger. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param linger [Integer, #to_int, #to_i] # @return [void] def self.set_linger(self_p, linger) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) linger = Integer(linger) result = ::CZMQ::FFI.zsock_set_linger(self_p, linger) result end # Get socket option `reconnect_ivl`. # Available from libzmq 2.0.0. # # @return [Integer] def reconnect_ivl() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_reconnect_ivl(self_p) result end # Get socket option `reconnect_ivl`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #reconnect_ivl. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.reconnect_ivl(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_reconnect_ivl(self_p) result end # Set socket option `reconnect_ivl`. # Available from libzmq 2.0.0. # # @param reconnect_ivl [Integer, #to_int, #to_i] # @return [void] def set_reconnect_ivl(reconnect_ivl) raise DestroyedError unless @ptr self_p = @ptr reconnect_ivl = Integer(reconnect_ivl) result = ::CZMQ::FFI.zsock_set_reconnect_ivl(self_p, reconnect_ivl) result end # Set socket option `reconnect_ivl`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #set_reconnect_ivl. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param reconnect_ivl [Integer, #to_int, #to_i] # @return [void] def self.set_reconnect_ivl(self_p, reconnect_ivl) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) reconnect_ivl = Integer(reconnect_ivl) result = ::CZMQ::FFI.zsock_set_reconnect_ivl(self_p, reconnect_ivl) result end # Get socket option `reconnect_ivl_max`. # Available from libzmq 2.0.0. # # @return [Integer] def reconnect_ivl_max() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_reconnect_ivl_max(self_p) result end # Get socket option `reconnect_ivl_max`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #reconnect_ivl_max. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.reconnect_ivl_max(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_reconnect_ivl_max(self_p) result end # Set socket option `reconnect_ivl_max`. # Available from libzmq 2.0.0. # # @param reconnect_ivl_max [Integer, #to_int, #to_i] # @return [void] def set_reconnect_ivl_max(reconnect_ivl_max) raise DestroyedError unless @ptr self_p = @ptr reconnect_ivl_max = Integer(reconnect_ivl_max) result = ::CZMQ::FFI.zsock_set_reconnect_ivl_max(self_p, reconnect_ivl_max) result end # Set socket option `reconnect_ivl_max`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #set_reconnect_ivl_max. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param reconnect_ivl_max [Integer, #to_int, #to_i] # @return [void] def self.set_reconnect_ivl_max(self_p, reconnect_ivl_max) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) reconnect_ivl_max = Integer(reconnect_ivl_max) result = ::CZMQ::FFI.zsock_set_reconnect_ivl_max(self_p, reconnect_ivl_max) result end # Get socket option `backlog`. # Available from libzmq 2.0.0. # # @return [Integer] def backlog() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_backlog(self_p) result end # Get socket option `backlog`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #backlog. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.backlog(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_backlog(self_p) result end # Set socket option `backlog`. # Available from libzmq 2.0.0. # # @param backlog [Integer, #to_int, #to_i] # @return [void] def set_backlog(backlog) raise DestroyedError unless @ptr self_p = @ptr backlog = Integer(backlog) result = ::CZMQ::FFI.zsock_set_backlog(self_p, backlog) result end # Set socket option `backlog`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #set_backlog. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param backlog [Integer, #to_int, #to_i] # @return [void] def self.set_backlog(self_p, backlog) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) backlog = Integer(backlog) result = ::CZMQ::FFI.zsock_set_backlog(self_p, backlog) result end # Set socket option `subscribe`. # Available from libzmq 2.0.0. # # @param subscribe [String, #to_s, nil] # @return [void] def set_subscribe(subscribe) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_subscribe(self_p, subscribe) result end # Set socket option `subscribe`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #set_subscribe. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param subscribe [String, #to_s, nil] # @return [void] def self.set_subscribe(self_p, subscribe) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_subscribe(self_p, subscribe) result end # Set socket option `unsubscribe`. # Available from libzmq 2.0.0. # # @param unsubscribe [String, #to_s, nil] # @return [void] def set_unsubscribe(unsubscribe) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_set_unsubscribe(self_p, unsubscribe) result end # Set socket option `unsubscribe`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #set_unsubscribe. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @param unsubscribe [String, #to_s, nil] # @return [void] def self.set_unsubscribe(self_p, unsubscribe) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_set_unsubscribe(self_p, unsubscribe) result end # Get socket option `type`. # Available from libzmq 2.0.0. # # @return [Integer] def type() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_type(self_p) result end # Get socket option `type`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #type. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.type(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_type(self_p) result end # Get socket option `rcvmore`. # Available from libzmq 2.0.0. # # @return [Integer] def rcvmore() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_rcvmore(self_p) result end # Get socket option `rcvmore`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #rcvmore. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.rcvmore(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_rcvmore(self_p) result end # Get socket option `fd`. # Available from libzmq 2.0.0. # # @return [Integer or FFI::Pointer] def fd() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_fd(self_p) result end # Get socket option `fd`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #fd. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer or FFI::Pointer] def self.fd(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_fd(self_p) result end # Get socket option `events`. # Available from libzmq 2.0.0. # # @return [Integer] def events() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zsock_events(self_p) result end # Get socket option `events`. # Available from libzmq 2.0.0. # # This is the polymorphic version of #events. # # @param self_p [CZMQ::Zsock, #__ptr, ::FFI::Pointer, nil] # object reference to use this method on # @return [Integer] def self.events(self_p) self_p = self_p.__ptr if self_p.respond_to?(:__ptr) result = ::CZMQ::FFI.zsock_events(self_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zsock_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zfile.rb0000664000372000037200000002614713222211156022075 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # helper functions for working with files. # @note This class is 100% generated using zproject. class Zfile # Raised when one tries to use an instance of {Zfile} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zfile_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # If file exists, populates properties. CZMQ supports portable symbolic # links, which are files with the extension ".ln". A symbolic link is a # text file containing one line, the filename of a target file. Reading # data from the symbolic link actually reads from the target file. Path # may be NULL, in which case it is not used. # @param path [String, #to_s, nil] # @param name [String, #to_s, nil] # @return [CZMQ::Zfile] def self.new(path, name) ptr = ::CZMQ::FFI.zfile_new(path, name) __new ptr end # Create new temporary file for writing via tmpfile. File is automaticaly # deleted on destroy # @return [CZMQ::Zfile] def self.tmp() ptr = ::CZMQ::FFI.zfile_tmp() __new ptr end # Destroy a file item # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zfile_destroy(self_p) result end # Duplicate a file item, returns a newly constructed item. If the file # is null, or memory was exhausted, returns null. # # @return [Zfile] def dup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_dup(self_p) result = Zfile.__new result, true result end # Return file name, remove path if provided # # @param path [String, #to_s, nil] # @return [String] def filename(path) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_filename(self_p, path) result end # Refresh file properties from disk; this is not done automatically # on access methods, otherwise it is not possible to compare directory # snapshots. # # @return [void] def restat() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_restat(self_p) result end # Return when the file was last modified. If you want this to reflect the # current situation, call zfile_restat before checking this property. # # @return [::FFI::Pointer] def modified() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_modified(self_p) result end # Return the last-known size of the file. If you want this to reflect the # current situation, call zfile_restat before checking this property. # # @return [::FFI::Pointer] def cursize() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_cursize(self_p) result end # Return true if the file is a directory. If you want this to reflect # any external changes, call zfile_restat before checking this property. # # @return [Boolean] def is_directory() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_is_directory(self_p) result end # Return true if the file is a regular file. If you want this to reflect # any external changes, call zfile_restat before checking this property. # # @return [Boolean] def is_regular() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_is_regular(self_p) result end # Return true if the file is readable by this process. If you want this to # reflect any external changes, call zfile_restat before checking this # property. # # @return [Boolean] def is_readable() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_is_readable(self_p) result end # Return true if the file is writeable by this process. If you want this # to reflect any external changes, call zfile_restat before checking this # property. # # @return [Boolean] def is_writeable() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_is_writeable(self_p) result end # Check if file has stopped changing and can be safely processed. # Updates the file statistics from disk at every call. # # @return [Boolean] def is_stable() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_is_stable(self_p) result end # Return true if the file was changed on disk since the zfile_t object # was created, or the last zfile_restat() call made on it. # # @return [Boolean] def has_changed() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_has_changed(self_p) result end # Remove the file from disk # # @return [void] def remove() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_remove(self_p) result end # Open file for reading # Returns 0 if OK, -1 if not found or not accessible # # @return [Integer] def input() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_input(self_p) result end # Open file for writing, creating directory if needed # File is created if necessary; chunks can be written to file at any # location. Returns 0 if OK, -1 if error. # # @return [Integer] def output() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_output(self_p) result end # Read chunk from file at specified position. If this was the last chunk, # sets the eof property. Returns a null chunk in case of error. # # @param bytes [Integer, #to_int, #to_i] # @param offset [::FFI::Pointer, #to_ptr] # @return [Zchunk] def read(bytes, offset) raise DestroyedError unless @ptr self_p = @ptr bytes = Integer(bytes) result = ::CZMQ::FFI.zfile_read(self_p, bytes, offset) result = Zchunk.__new result, true result end # Returns true if zfile_read() just read the last chunk in the file. # # @return [Boolean] def eof() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_eof(self_p) result end # Write chunk to file at specified position # Return 0 if OK, else -1 # # @param chunk [Zchunk, #__ptr] # @param offset [::FFI::Pointer, #to_ptr] # @return [Integer] def write(chunk, offset) raise DestroyedError unless @ptr self_p = @ptr chunk = chunk.__ptr if chunk result = ::CZMQ::FFI.zfile_write(self_p, chunk, offset) result end # Read next line of text from file. Returns a pointer to the text line, # or NULL if there was nothing more to read from the file. # # @return [String] def readln() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_readln(self_p) result end # Close file, if open # # @return [void] def close() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_close(self_p) result end # Return file handle, if opened # # @return [::FFI::Pointer] def handle() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_handle(self_p) result end # Calculate SHA1 digest for file, using zdigest class. # # @return [String] def digest() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zfile_digest(self_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zfile_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/ztimerset.rb0000664000372000037200000001547213222211156023011 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # timer set # @note This class is 100% generated using zproject. class Ztimerset # Raised when one tries to use an instance of {Ztimerset} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.ztimerset_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new callback of the following type: # Callback function for timer event. # typedef void (ztimerset_fn) ( # int timer_id, void *arg); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.fn ::FFI::Function.new :void, [:int, :pointer], blocking: true do |timer_id, arg| result = yield timer_id, arg result end end # Create new timer set. # @return [CZMQ::Ztimerset] def self.new() ptr = ::CZMQ::FFI.ztimerset_new() __new ptr end # Destroy a timer set # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.ztimerset_destroy(self_p) result end # Add a timer to the set. Returns timer id if OK, -1 on failure. # # @param interval [Integer, #to_int, #to_i] # @param handler [::FFI::Pointer, #to_ptr] # @param arg [::FFI::Pointer, #to_ptr] # @return [Integer] def add(interval, handler, arg) raise DestroyedError unless @ptr self_p = @ptr interval = Integer(interval) result = ::CZMQ::FFI.ztimerset_add(self_p, interval, handler, arg) result end # Cancel a timer. Returns 0 if OK, -1 on failure. # # @param timer_id [Integer, #to_int, #to_i] # @return [Integer] def cancel(timer_id) raise DestroyedError unless @ptr self_p = @ptr timer_id = Integer(timer_id) result = ::CZMQ::FFI.ztimerset_cancel(self_p, timer_id) result end # Set timer interval. Returns 0 if OK, -1 on failure. # This method is slow, canceling the timer and adding a new one yield better performance. # # @param timer_id [Integer, #to_int, #to_i] # @param interval [Integer, #to_int, #to_i] # @return [Integer] def set_interval(timer_id, interval) raise DestroyedError unless @ptr self_p = @ptr timer_id = Integer(timer_id) interval = Integer(interval) result = ::CZMQ::FFI.ztimerset_set_interval(self_p, timer_id, interval) result end # Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. # This method is slow, canceling the timer and adding a new one yield better performance. # # @param timer_id [Integer, #to_int, #to_i] # @return [Integer] def reset(timer_id) raise DestroyedError unless @ptr self_p = @ptr timer_id = Integer(timer_id) result = ::CZMQ::FFI.ztimerset_reset(self_p, timer_id) result end # Return the time until the next interval. # Should be used as timeout parameter for the zpoller wait method. # The timeout is in msec. # # @return [Integer] def timeout() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ztimerset_timeout(self_p) result end # Invoke callback function of all timers which their interval has elapsed. # Should be call after zpoller wait method. # Returns 0 if OK, -1 on failure. # # @return [Integer] def execute() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.ztimerset_execute(self_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.ztimerset_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zframe.rb0000664000372000037200000002567513222211156022255 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # working with single message frames # @note This class is 100% generated using zproject. class Zframe # MORE = 1 # REUSE = 2 # DONTWAIT = 4 # Raised when one tries to use an instance of {Zframe} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zframe_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new frame. If size is not null, allocates the frame data # to the specified size. If additionally, data is not null, copies # size octets from the specified data into the frame body. # @param data [::FFI::Pointer, #to_ptr] # @param size [Integer, #to_int, #to_i] # @return [CZMQ::Zframe] def self.new(data, size) size = Integer(size) ptr = ::CZMQ::FFI.zframe_new(data, size) __new ptr end # Create an empty (zero-sized) frame # @return [CZMQ::Zframe] def self.new_empty() ptr = ::CZMQ::FFI.zframe_new_empty() __new ptr end # Create a frame with a specified string content. # @param string [String, #to_s, nil] # @return [CZMQ::Zframe] def self.from(string) ptr = ::CZMQ::FFI.zframe_from(string) __new ptr end # Receive frame from socket, returns zframe_t object or NULL if the recv # was interrupted. Does a blocking recv, if you want to not block then use # zpoller or zloop. # @param source [::FFI::Pointer, #to_ptr] # @return [CZMQ::Zframe] def self.recv(source) ptr = ::CZMQ::FFI.zframe_recv(source) __new ptr end # Destroy a frame # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zframe_destroy(self_p) result end # Send a frame to a socket, destroy frame after sending. # Return -1 on error, 0 on success. # # @param self_p [#__ptr_give_ref] # @param dest [::FFI::Pointer, #to_ptr] # @param flags [Integer, #to_int, #to_i] # @return [Integer] def self.send(self_p, dest, flags) self_p = self_p.__ptr_give_ref flags = Integer(flags) result = ::CZMQ::FFI.zframe_send(self_p, dest, flags) result end # Return number of bytes in frame data # # @return [Integer] def size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zframe_size(self_p) result end # Return address of frame data # # @return [::FFI::Pointer] def data() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zframe_data(self_p) result end # Return meta data property for frame # The caller shall not modify or free the returned value, which shall be # owned by the message. # # @param property [String, #to_s, nil] # @return [String] def meta(property) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zframe_meta(self_p, property) result end # Create a new frame that duplicates an existing frame. If frame is null, # or memory was exhausted, returns null. # # @return [Zframe] def dup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zframe_dup(self_p) result = Zframe.__new result, true result end # Return frame data encoded as printable hex string, useful for 0MQ UUIDs. # Caller must free string when finished with it. # # @return [::FFI::AutoPointer] def strhex() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zframe_strhex(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Return frame data copied into freshly allocated string # Caller must free string when finished with it. # # @return [::FFI::AutoPointer] def strdup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zframe_strdup(self_p) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Return TRUE if frame body is equal to string, excluding terminator # # @param string [String, #to_s, nil] # @return [Boolean] def streq(string) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zframe_streq(self_p, string) result end # Return frame MORE indicator (1 or 0), set when reading frame from socket # or by the zframe_set_more() method # # @return [Integer] def more() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zframe_more(self_p) result end # Set frame MORE indicator (1 or 0). Note this is NOT used when sending # frame to socket, you have to specify flag explicitly. # # @param more [Integer, #to_int, #to_i] # @return [void] def set_more(more) raise DestroyedError unless @ptr self_p = @ptr more = Integer(more) result = ::CZMQ::FFI.zframe_set_more(self_p, more) result end # Return frame routing ID, if the frame came from a ZMQ_SERVER socket. # Else returns zero. # # @return [Integer] def routing_id() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zframe_routing_id(self_p) result end # Set routing ID on frame. This is used if/when the frame is sent to a # ZMQ_SERVER socket. # # @param routing_id [Integer, #to_int, #to_i] # @return [void] def set_routing_id(routing_id) raise DestroyedError unless @ptr self_p = @ptr routing_id = Integer(routing_id) result = ::CZMQ::FFI.zframe_set_routing_id(self_p, routing_id) result end # Return frame group of radio-dish pattern. # # @return [String] def group() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zframe_group(self_p) result end # Set group on frame. This is used if/when the frame is sent to a # ZMQ_RADIO socket. # Return -1 on error, 0 on success. # # @param group [String, #to_s, nil] # @return [Integer] def set_group(group) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zframe_set_group(self_p, group) result end # Return TRUE if two frames have identical size and data # If either frame is NULL, equality is always false. # # @param other [Zframe, #__ptr] # @return [Boolean] def eq(other) raise DestroyedError unless @ptr self_p = @ptr other = other.__ptr if other result = ::CZMQ::FFI.zframe_eq(self_p, other) result end # Set new contents for frame # # @param data [::FFI::Pointer, #to_ptr] # @param size [Integer, #to_int, #to_i] # @return [void] def reset(data, size) raise DestroyedError unless @ptr self_p = @ptr size = Integer(size) result = ::CZMQ::FFI.zframe_reset(self_p, data, size) result end # Send message to zsys log sink (may be stdout, or system facility as # configured by zsys_set_logstream). Prefix shows before frame, if not null. # # @param prefix [String, #to_s, nil] # @return [void] def print(prefix) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zframe_print(self_p, prefix) result end # Probe the supplied object, and report if it looks like a zframe_t. # # @param self_ [::FFI::Pointer, #to_ptr] # @return [Boolean] def self.is(self_) result = ::CZMQ::FFI.zframe_is(self_) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zframe_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zclock.rb0000664000372000037200000001151713222211156022244 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # millisecond clocks and delays # @note This class is 100% generated using zproject. class Zclock # Raised when one tries to use an instance of {Zclock} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do "WARNING: "\ "Objects of type #{self} cannot be destroyed implicitly. "\ "Please call the correct destroy method with the relevant arguments." end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Sleep for a number of milliseconds # # @param msecs [Integer, #to_int, #to_i] # @return [void] def self.sleep(msecs) msecs = Integer(msecs) result = ::CZMQ::FFI.zclock_sleep(msecs) result end # Return current system clock as milliseconds. Note that this clock can # jump backwards (if the system clock is changed) so is unsafe to use for # timers and time offsets. Use zclock_mono for that instead. # # @return [::FFI::Pointer] def self.time() result = ::CZMQ::FFI.zclock_time() result end # Return current monotonic clock in milliseconds. Use this when you compute # time offsets. The monotonic clock is not affected by system changes and # so will never be reset backwards, unlike a system clock. # # @return [::FFI::Pointer] def self.mono() result = ::CZMQ::FFI.zclock_mono() result end # Return current monotonic clock in microseconds. Use this when you compute # time offsets. The monotonic clock is not affected by system changes and # so will never be reset backwards, unlike a system clock. # # @return [::FFI::Pointer] def self.usecs() result = ::CZMQ::FFI.zclock_usecs() result end # Return formatted date/time as fresh string. Free using zstr_free(). # # @return [::FFI::AutoPointer] def self.timestr() result = ::CZMQ::FFI.zclock_timestr() result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zclock_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zhashx.rb0000664000372000037200000005341613222211156022270 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # extended generic type-free hash container # @note This class is 100% generated using zproject. class Zhashx # Raised when one tries to use an instance of {Zhashx} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zhashx_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new callback of the following type: # Destroy an item # typedef void (zhashx_destructor_fn) ( # void **item); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.destructor_fn ::FFI::Function.new :void, [:pointer], blocking: true do |item| result = yield item result end end # Create a new callback of the following type: # Duplicate an item # typedef void * (zhashx_duplicator_fn) ( # const void *item); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.duplicator_fn ::FFI::Function.new :pointer, [:pointer], blocking: true do |item| result = yield item result end end # Create a new callback of the following type: # Compare two items, for sorting # typedef int (zhashx_comparator_fn) ( # const void *item1, const void *item2); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.comparator_fn ::FFI::Function.new :int, [:pointer, :pointer], blocking: true do |item1, item2| result = yield item1, item2 result = Integer(result) result end end # Create a new callback of the following type: # Destroy an item. # typedef void (zhashx_free_fn) ( # void *data); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.free_fn ::FFI::Function.new :void, [:pointer], blocking: true do |data| result = yield data result end end # Create a new callback of the following type: # Hash function for keys. # typedef size_t (zhashx_hash_fn) ( # const void *key); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.hash_fn ::FFI::Function.new :size_t, [:pointer], blocking: true do |key| result = yield key result = Integer(result) result end end # Create a new callback of the following type: # Serializes an item to a longstr. # The caller takes ownership of the newly created object. # typedef char * (zhashx_serializer_fn) ( # const void *item); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.serializer_fn ::FFI::Function.new :pointer, [:pointer], blocking: true do |item| result = yield item result end end # Create a new callback of the following type: # Deserializes a longstr into an item. # The caller takes ownership of the newly created object. # typedef void * (zhashx_deserializer_fn) ( # const char *item_str); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.deserializer_fn ::FFI::Function.new :pointer, [:string], blocking: true do |item_str| result = yield item_str result end end # Create a new, empty hash container # @return [CZMQ::Zhashx] def self.new() ptr = ::CZMQ::FFI.zhashx_new() __new ptr end # Unpack binary frame into a new hash table. Packed data must follow format # defined by zhashx_pack. Hash table is set to autofree. An empty frame # unpacks to an empty hash table. # @param frame [Zframe, #__ptr] # @return [CZMQ::Zhashx] def self.unpack(frame) frame = frame.__ptr if frame ptr = ::CZMQ::FFI.zhashx_unpack(frame) __new ptr end # Same as unpack but uses a user-defined deserializer function to convert # a longstr back into item format. # @param frame [Zframe, #__ptr] # @param deserializer [::FFI::Pointer, #to_ptr] # @return [CZMQ::Zhashx] def self.unpack_own(frame, deserializer) frame = frame.__ptr if frame ptr = ::CZMQ::FFI.zhashx_unpack_own(frame, deserializer) __new ptr end # Destroy a hash container and all items in it # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zhashx_destroy(self_p) result end # Insert item into hash table with specified key and item. # If key is already present returns -1 and leaves existing item unchanged # Returns 0 on success. # # @param key [::FFI::Pointer, #to_ptr] # @param item [::FFI::Pointer, #to_ptr] # @return [Integer] def insert(key, item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_insert(self_p, key, item) result end # Update or insert item into hash table with specified key and item. If the # key is already present, destroys old item and inserts new one. If you set # a container item destructor, this is called on the old value. If the key # was not already present, inserts a new item. Sets the hash cursor to the # new item. # # @param key [::FFI::Pointer, #to_ptr] # @param item [::FFI::Pointer, #to_ptr] # @return [void] def update(key, item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_update(self_p, key, item) result end # Remove an item specified by key from the hash table. If there was no such # item, this function does nothing. # # @param key [::FFI::Pointer, #to_ptr] # @return [void] def delete(key) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_delete(self_p, key) result end # Delete all items from the hash table. If the key destructor is # set, calls it on every key. If the item destructor is set, calls # it on every item. # # @return [void] def purge() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_purge(self_p) result end # Return the item at the specified key, or null # # @param key [::FFI::Pointer, #to_ptr] # @return [::FFI::Pointer] def lookup(key) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_lookup(self_p, key) result end # Reindexes an item from an old key to a new key. If there was no such # item, does nothing. Returns 0 if successful, else -1. # # @param old_key [::FFI::Pointer, #to_ptr] # @param new_key [::FFI::Pointer, #to_ptr] # @return [Integer] def rename(old_key, new_key) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_rename(self_p, old_key, new_key) result end # Set a free function for the specified hash table item. When the item is # destroyed, the free function, if any, is called on that item. # Use this when hash items are dynamically allocated, to ensure that # you don't have memory leaks. You can pass 'free' or NULL as a free_fn. # Returns the item, or NULL if there is no such item. # # @param key [::FFI::Pointer, #to_ptr] # @param free_fn [::FFI::Pointer, #to_ptr] # @return [::FFI::Pointer] def freefn(key, free_fn) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_freefn(self_p, key, free_fn) result end # Return the number of keys/items in the hash table # # @return [Integer] def size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_size(self_p) result end # Return a zlistx_t containing the keys for the items in the # table. Uses the key_duplicator to duplicate all keys and sets the # key_destructor as destructor for the list. # # @return [Zlistx] def keys() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_keys(self_p) result = Zlistx.__new result, true result end # Return a zlistx_t containing the values for the items in the # table. Uses the duplicator to duplicate all items and sets the # destructor as destructor for the list. # # @return [Zlistx] def values() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_values(self_p) result = Zlistx.__new result, true result end # Simple iterator; returns first item in hash table, in no given order, # or NULL if the table is empty. This method is simpler to use than the # foreach() method, which is deprecated. To access the key for this item # use zhashx_cursor(). NOTE: do NOT modify the table while iterating. # # @return [::FFI::Pointer] def first() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_first(self_p) result end # Simple iterator; returns next item in hash table, in no given order, # or NULL if the last item was already returned. Use this together with # zhashx_first() to process all items in a hash table. If you need the # items in sorted order, use zhashx_keys() and then zlistx_sort(). To # access the key for this item use zhashx_cursor(). NOTE: do NOT modify # the table while iterating. # # @return [::FFI::Pointer] def next() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_next(self_p) result end # After a successful first/next method, returns the key for the item that # was returned. This is a constant string that you may not modify or # deallocate, and which lasts as long as the item in the hash. After an # unsuccessful first/next, returns NULL. # # @return [::FFI::Pointer] def cursor() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_cursor(self_p) result end # Add a comment to hash table before saving to disk. You can add as many # comment lines as you like. These comment lines are discarded when loading # the file. If you use a null format, all comments are deleted. # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def comment(format, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_comment(self_p, format, *args) result end # Save hash table to a text file in name=value format. Hash values must be # printable strings; keys may not contain '=' character. Returns 0 if OK, # else -1 if a file error occurred. # # @param filename [String, #to_s, nil] # @return [Integer] def save(filename) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_save(self_p, filename) result end # Load hash table from a text file in name=value format; hash table must # already exist. Hash values must printable strings; keys may not contain # '=' character. Returns 0 if OK, else -1 if a file was not readable. # # @param filename [String, #to_s, nil] # @return [Integer] def load(filename) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_load(self_p, filename) result end # When a hash table was loaded from a file by zhashx_load, this method will # reload the file if it has been modified since, and is "stable", i.e. not # still changing. Returns 0 if OK, -1 if there was an error reloading the # file. # # @return [Integer] def refresh() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_refresh(self_p) result end # Serialize hash table to a binary frame that can be sent in a message. # The packed format is compatible with the 'dictionary' type defined in # http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: # # ; A list of name/value pairs # dictionary = dict-count *( dict-name dict-value ) # dict-count = number-4 # dict-value = longstr # dict-name = string # # ; Strings are always length + text contents # longstr = number-4 *VCHAR # string = number-1 *VCHAR # # ; Numbers are unsigned integers in network byte order # number-1 = 1OCTET # number-4 = 4OCTET # # Comments are not included in the packed data. Item values MUST be # strings. # # @return [Zframe] def pack() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_pack(self_p) result = Zframe.__new result, true result end # Same as pack but uses a user-defined serializer function to convert items # into longstr. # # @param serializer [::FFI::Pointer, #to_ptr] # @return [Zframe] def pack_own(serializer) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_pack_own(self_p, serializer) result = Zframe.__new result, true result end # Make a copy of the list; items are duplicated if you set a duplicator # for the list, otherwise not. Copying a null reference returns a null # reference. Note that this method's behavior changed slightly for CZMQ # v3.x, as it does not set nor respect autofree. It does however let you # duplicate any hash table safely. The old behavior is in zhashx_dup_v2. # # @return [Zhashx] def dup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_dup(self_p) result = Zhashx.__new result, true result end # Set a user-defined deallocator for hash items; by default items are not # freed when the hash is destroyed. # # @param destructor [::FFI::Pointer, #to_ptr] # @return [void] def set_destructor(destructor) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_set_destructor(self_p, destructor) result end # Set a user-defined duplicator for hash items; by default items are not # copied when the hash is duplicated. # # @param duplicator [::FFI::Pointer, #to_ptr] # @return [void] def set_duplicator(duplicator) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_set_duplicator(self_p, duplicator) result end # Set a user-defined deallocator for keys; by default keys are freed # when the hash is destroyed using free(). # # @param destructor [::FFI::Pointer, #to_ptr] # @return [void] def set_key_destructor(destructor) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_set_key_destructor(self_p, destructor) result end # Set a user-defined duplicator for keys; by default keys are duplicated # using strdup. # # @param duplicator [::FFI::Pointer, #to_ptr] # @return [void] def set_key_duplicator(duplicator) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_set_key_duplicator(self_p, duplicator) result end # Set a user-defined comparator for keys; by default keys are # compared using strcmp. # The callback function should return zero (0) on matching # items. # # @param comparator [::FFI::Pointer, #to_ptr] # @return [void] def set_key_comparator(comparator) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_set_key_comparator(self_p, comparator) result end # Set a user-defined hash function for keys; by default keys are # hashed by a modified Bernstein hashing function. # # @param hasher [::FFI::Pointer, #to_ptr] # @return [void] def set_key_hasher(hasher) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_set_key_hasher(self_p, hasher) result end # Make copy of hash table; if supplied table is null, returns null. # Does not copy items themselves. Rebuilds new table so may be slow on # very large tables. NOTE: only works with item values that are strings # since there's no other way to know how to duplicate the item value. # # @return [Zhashx] def dup_v2() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zhashx_dup_v2(self_p) result = Zhashx.__new result, false result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zhashx_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zlistx.rb0000664000372000037200000004040513222211156022312 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # extended generic list container # @note This class is 100% generated using zproject. class Zlistx # Raised when one tries to use an instance of {Zlistx} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zlistx_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new callback of the following type: # Destroy an item # typedef void (zlistx_destructor_fn) ( # void **item); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.destructor_fn ::FFI::Function.new :void, [:pointer], blocking: true do |item| result = yield item result end end # Create a new callback of the following type: # Duplicate an item # typedef void * (zlistx_duplicator_fn) ( # const void *item); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.duplicator_fn ::FFI::Function.new :pointer, [:pointer], blocking: true do |item| result = yield item result end end # Create a new callback of the following type: # Compare two items, for sorting # typedef int (zlistx_comparator_fn) ( # const void *item1, const void *item2); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.comparator_fn ::FFI::Function.new :int, [:pointer, :pointer], blocking: true do |item1, item2| result = yield item1, item2 result = Integer(result) result end end # Create a new, empty list. # @return [CZMQ::Zlistx] def self.new() ptr = ::CZMQ::FFI.zlistx_new() __new ptr end # Destroy a list. If an item destructor was specified, all items in the # list are automatically destroyed as well. # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zlistx_destroy(self_p) result end # Add an item to the head of the list. Calls the item duplicator, if any, # on the item. Resets cursor to list head. Returns an item handle on # success, NULL if memory was exhausted. # # @param item [::FFI::Pointer, #to_ptr] # @return [::FFI::Pointer] def add_start(item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_add_start(self_p, item) result end # Add an item to the tail of the list. Calls the item duplicator, if any, # on the item. Resets cursor to list head. Returns an item handle on # success, NULL if memory was exhausted. # # @param item [::FFI::Pointer, #to_ptr] # @return [::FFI::Pointer] def add_end(item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_add_end(self_p, item) result end # Return the number of items in the list # # @return [Integer] def size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_size(self_p) result end # Return first item in the list, or null, leaves the cursor # # @return [::FFI::Pointer] def head() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_head(self_p) result end # Return last item in the list, or null, leaves the cursor # # @return [::FFI::Pointer] def tail() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_tail(self_p) result end # Return the item at the head of list. If the list is empty, returns NULL. # Leaves cursor pointing at the head item, or NULL if the list is empty. # # @return [::FFI::Pointer] def first() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_first(self_p) result end # Return the next item. At the end of the list (or in an empty list), # returns NULL. Use repeated zlistx_next () calls to work through the list # from zlistx_first (). First time, acts as zlistx_first(). # # @return [::FFI::Pointer] def next() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_next(self_p) result end # Return the previous item. At the start of the list (or in an empty list), # returns NULL. Use repeated zlistx_prev () calls to work through the list # backwards from zlistx_last (). First time, acts as zlistx_last(). # # @return [::FFI::Pointer] def prev() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_prev(self_p) result end # Return the item at the tail of list. If the list is empty, returns NULL. # Leaves cursor pointing at the tail item, or NULL if the list is empty. # # @return [::FFI::Pointer] def last() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_last(self_p) result end # Returns the value of the item at the cursor, or NULL if the cursor is # not pointing to an item. # # @return [::FFI::Pointer] def item() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_item(self_p) result end # Returns the handle of the item at the cursor, or NULL if the cursor is # not pointing to an item. # # @return [::FFI::Pointer] def cursor() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_cursor(self_p) result end # Returns the item associated with the given list handle, or NULL if passed # in handle is NULL. Asserts that the passed in handle points to a list element. # # @param handle [::FFI::Pointer, #to_ptr] # @return [::FFI::Pointer] def self.handle_item(handle) result = ::CZMQ::FFI.zlistx_handle_item(handle) result end # Find an item in the list, searching from the start. Uses the item # comparator, if any, else compares item values directly. Returns the # item handle found, or NULL. Sets the cursor to the found item, if any. # # @param item [::FFI::Pointer, #to_ptr] # @return [::FFI::Pointer] def find(item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_find(self_p, item) result end # Detach an item from the list, using its handle. The item is not modified, # and the caller is responsible for destroying it if necessary. If handle is # null, detaches the first item on the list. Returns item that was detached, # or null if none was. If cursor was at item, moves cursor to previous item, # so you can detach items while iterating forwards through a list. # # @param handle [::FFI::Pointer, #to_ptr] # @return [::FFI::Pointer] def detach(handle) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_detach(self_p, handle) result end # Detach item at the cursor, if any, from the list. The item is not modified, # and the caller is responsible for destroying it as necessary. Returns item # that was detached, or null if none was. Moves cursor to previous item, so # you can detach items while iterating forwards through a list. # # @return [::FFI::Pointer] def detach_cur() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_detach_cur(self_p) result end # Delete an item, using its handle. Calls the item destructor is any is # set. If handle is null, deletes the first item on the list. Returns 0 # if an item was deleted, -1 if not. If cursor was at item, moves cursor # to previous item, so you can delete items while iterating forwards # through a list. # # @param handle [::FFI::Pointer, #to_ptr] # @return [Integer] def delete(handle) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_delete(self_p, handle) result end # Move an item to the start of the list, via its handle. # # @param handle [::FFI::Pointer, #to_ptr] # @return [void] def move_start(handle) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_move_start(self_p, handle) result end # Move an item to the end of the list, via its handle. # # @param handle [::FFI::Pointer, #to_ptr] # @return [void] def move_end(handle) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_move_end(self_p, handle) result end # Remove all items from the list, and destroy them if the item destructor # is set. # # @return [void] def purge() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_purge(self_p) result end # Sort the list. If an item comparator was set, calls that to compare # items, otherwise compares on item value. The sort is not stable, so may # reorder equal items. # # @return [void] def sort() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_sort(self_p) result end # Create a new node and insert it into a sorted list. Calls the item # duplicator, if any, on the item. If low_value is true, starts searching # from the start of the list, otherwise searches from the end. Use the item # comparator, if any, to find where to place the new node. Returns a handle # to the new node, or NULL if memory was exhausted. Resets the cursor to the # list head. # # @param item [::FFI::Pointer, #to_ptr] # @param low_value [Boolean] # @return [::FFI::Pointer] def insert(item, low_value) raise DestroyedError unless @ptr self_p = @ptr low_value = !(0==low_value||!low_value) # boolean result = ::CZMQ::FFI.zlistx_insert(self_p, item, low_value) result end # Move an item, specified by handle, into position in a sorted list. Uses # the item comparator, if any, to determine the new location. If low_value # is true, starts searching from the start of the list, otherwise searches # from the end. # # @param handle [::FFI::Pointer, #to_ptr] # @param low_value [Boolean] # @return [void] def reorder(handle, low_value) raise DestroyedError unless @ptr self_p = @ptr low_value = !(0==low_value||!low_value) # boolean result = ::CZMQ::FFI.zlistx_reorder(self_p, handle, low_value) result end # Make a copy of the list; items are duplicated if you set a duplicator # for the list, otherwise not. Copying a null reference returns a null # reference. # # @return [Zlistx] def dup() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_dup(self_p) result = Zlistx.__new result, false result end # Set a user-defined deallocator for list items; by default items are not # freed when the list is destroyed. # # @param destructor [::FFI::Pointer, #to_ptr] # @return [void] def set_destructor(destructor) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_set_destructor(self_p, destructor) result end # Set a user-defined duplicator for list items; by default items are not # copied when the list is duplicated. # # @param duplicator [::FFI::Pointer, #to_ptr] # @return [void] def set_duplicator(duplicator) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_set_duplicator(self_p, duplicator) result end # Set a user-defined comparator for zlistx_find and zlistx_sort; the method # must return -1, 0, or 1 depending on whether item1 is less than, equal to, # or greater than, item2. # # @param comparator [::FFI::Pointer, #to_ptr] # @return [void] def set_comparator(comparator) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zlistx_set_comparator(self_p, comparator) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zlistx_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zloop.rb0000664000372000037200000003505013222211156022120 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # event-driven reactor # @note This class is 100% generated using zproject. class Zloop # Raised when one tries to use an instance of {Zloop} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zloop_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new callback of the following type: # Callback function for reactor socket activity # typedef int (zloop_reader_fn) ( # zloop_t *loop, zsock_t *reader, void *arg); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.reader_fn ::FFI::Function.new :int, [:pointer, :pointer, :pointer], blocking: true do |loop, reader, arg| loop = Zloop.__new loop, false reader = Zsock.__new reader, false result = yield loop, reader, arg result = Integer(result) result end end # Create a new callback of the following type: # Callback function for reactor events (low-level) # typedef int (zloop_fn) ( # zloop_t *loop, zmq_pollitem_t *item, void *arg); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.fn ::FFI::Function.new :int, [:pointer, :pointer, :pointer], blocking: true do |loop, item, arg| loop = Zloop.__new loop, false result = yield loop, item, arg result = Integer(result) result end end # Create a new callback of the following type: # Callback for reactor timer events # typedef int (zloop_timer_fn) ( # zloop_t *loop, int timer_id, void *arg); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.timer_fn ::FFI::Function.new :int, [:pointer, :int, :pointer], blocking: true do |loop, timer_id, arg| loop = Zloop.__new loop, false result = yield loop, timer_id, arg result = Integer(result) result end end # Create a new zloop reactor # @return [CZMQ::Zloop] def self.new() ptr = ::CZMQ::FFI.zloop_new() __new ptr end # Destroy a reactor # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zloop_destroy(self_p) result end # Register socket reader with the reactor. When the reader has messages, # the reactor will call the handler, passing the arg. Returns 0 if OK, -1 # if there was an error. If you register the same socket more than once, # each instance will invoke its corresponding handler. # # @param sock [Zsock, #__ptr] # @param handler [::FFI::Pointer, #to_ptr] # @param arg [::FFI::Pointer, #to_ptr] # @return [Integer] def reader(sock, handler, arg) raise DestroyedError unless @ptr self_p = @ptr sock = sock.__ptr if sock result = ::CZMQ::FFI.zloop_reader(self_p, sock, handler, arg) result end # Cancel a socket reader from the reactor. If multiple readers exist for # same socket, cancels ALL of them. # # @param sock [Zsock, #__ptr] # @return [void] def reader_end(sock) raise DestroyedError unless @ptr self_p = @ptr sock = sock.__ptr if sock result = ::CZMQ::FFI.zloop_reader_end(self_p, sock) result end # Configure a registered reader to ignore errors. If you do not set this, # then readers that have errors are removed from the reactor silently. # # @param sock [Zsock, #__ptr] # @return [void] def reader_set_tolerant(sock) raise DestroyedError unless @ptr self_p = @ptr sock = sock.__ptr if sock result = ::CZMQ::FFI.zloop_reader_set_tolerant(self_p, sock) result end # Register low-level libzmq pollitem with the reactor. When the pollitem # is ready, will call the handler, passing the arg. Returns 0 if OK, -1 # if there was an error. If you register the pollitem more than once, each # instance will invoke its corresponding handler. A pollitem with # socket=NULL and fd=0 means 'poll on FD zero'. # # @param item [::FFI::Pointer, #to_ptr] # @param handler [::FFI::Pointer, #to_ptr] # @param arg [::FFI::Pointer, #to_ptr] # @return [Integer] def poller(item, handler, arg) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zloop_poller(self_p, item, handler, arg) result end # Cancel a pollitem from the reactor, specified by socket or FD. If both # are specified, uses only socket. If multiple poll items exist for same # socket/FD, cancels ALL of them. # # @param item [::FFI::Pointer, #to_ptr] # @return [void] def poller_end(item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zloop_poller_end(self_p, item) result end # Configure a registered poller to ignore errors. If you do not set this, # then poller that have errors are removed from the reactor silently. # # @param item [::FFI::Pointer, #to_ptr] # @return [void] def poller_set_tolerant(item) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zloop_poller_set_tolerant(self_p, item) result end # Register a timer that expires after some delay and repeats some number of # times. At each expiry, will call the handler, passing the arg. To run a # timer forever, use 0 times. Returns a timer_id that is used to cancel the # timer in the future. Returns -1 if there was an error. # # @param delay [Integer, #to_int, #to_i] # @param times [Integer, #to_int, #to_i] # @param handler [::FFI::Pointer, #to_ptr] # @param arg [::FFI::Pointer, #to_ptr] # @return [Integer] def timer(delay, times, handler, arg) raise DestroyedError unless @ptr self_p = @ptr delay = Integer(delay) times = Integer(times) result = ::CZMQ::FFI.zloop_timer(self_p, delay, times, handler, arg) result end # Cancel a specific timer identified by a specific timer_id (as returned by # zloop_timer). # # @param timer_id [Integer, #to_int, #to_i] # @return [Integer] def timer_end(timer_id) raise DestroyedError unless @ptr self_p = @ptr timer_id = Integer(timer_id) result = ::CZMQ::FFI.zloop_timer_end(self_p, timer_id) result end # Register a ticket timer. Ticket timers are very fast in the case where # you use a lot of timers (thousands), and frequently remove and add them. # The main use case is expiry timers for servers that handle many clients, # and which reset the expiry timer for each message received from a client. # Whereas normal timers perform poorly as the number of clients grows, the # cost of ticket timers is constant, no matter the number of clients. You # must set the ticket delay using zloop_set_ticket_delay before creating a # ticket. Returns a handle to the timer that you should use in # zloop_ticket_reset and zloop_ticket_delete. # # @param handler [::FFI::Pointer, #to_ptr] # @param arg [::FFI::Pointer, #to_ptr] # @return [::FFI::Pointer] def ticket(handler, arg) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zloop_ticket(self_p, handler, arg) result end # Reset a ticket timer, which moves it to the end of the ticket list and # resets its execution time. This is a very fast operation. # # @param handle [::FFI::Pointer, #to_ptr] # @return [void] def ticket_reset(handle) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zloop_ticket_reset(self_p, handle) result end # Delete a ticket timer. We do not actually delete the ticket here, as # other code may still refer to the ticket. We mark as deleted, and remove # later and safely. # # @param handle [::FFI::Pointer, #to_ptr] # @return [void] def ticket_delete(handle) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zloop_ticket_delete(self_p, handle) result end # Set the ticket delay, which applies to all tickets. If you lower the # delay and there are already tickets created, the results are undefined. # # @param ticket_delay [Integer, #to_int, #to_i] # @return [void] def set_ticket_delay(ticket_delay) raise DestroyedError unless @ptr self_p = @ptr ticket_delay = Integer(ticket_delay) result = ::CZMQ::FFI.zloop_set_ticket_delay(self_p, ticket_delay) result end # Set hard limit on number of timers allowed. Setting more than a small # number of timers (10-100) can have a dramatic impact on the performance # of the reactor. For high-volume cases, use ticket timers. If the hard # limit is reached, the reactor stops creating new timers and logs an # error. # # @param max_timers [Integer, #to_int, #to_i] # @return [void] def set_max_timers(max_timers) raise DestroyedError unless @ptr self_p = @ptr max_timers = Integer(max_timers) result = ::CZMQ::FFI.zloop_set_max_timers(self_p, max_timers) result end # Set verbose tracing of reactor on/off. The default verbose setting is # off (false). # # @param verbose [Boolean] # @return [void] def set_verbose(verbose) raise DestroyedError unless @ptr self_p = @ptr verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zloop_set_verbose(self_p, verbose) result end # By default the reactor stops if the process receives a SIGINT or SIGTERM # signal. This makes it impossible to shut-down message based architectures # like zactors. This method lets you switch off break handling. The default # nonstop setting is off (false). # # @param nonstop [Boolean] # @return [void] def set_nonstop(nonstop) raise DestroyedError unless @ptr self_p = @ptr nonstop = !(0==nonstop||!nonstop) # boolean result = ::CZMQ::FFI.zloop_set_nonstop(self_p, nonstop) result end # Start the reactor. Takes control of the thread and returns when the 0MQ # context is terminated or the process is interrupted, or any event handler # returns -1. Event handlers may register new sockets and timers, and # cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. # # @return [Integer] def start() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zloop_start(self_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zloop_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zsys.rb0000664000372000037200000007523513222211156021776 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # # @note This class is 100% generated using zproject. class Zsys # Raised when one tries to use an instance of {Zsys} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do "WARNING: "\ "Objects of type #{self} cannot be destroyed implicitly. "\ "Please call the correct destroy method with the relevant arguments." end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new callback of the following type: # Callback for interrupt signal handler # typedef void (zsys_handler_fn) ( # int signal_value); # # @note WARNING: If your Ruby code doesn't retain a reference to the # FFI::Function object after passing it to a C function call, # it may be garbage collected while C still holds the pointer, # potentially resulting in a segmentation fault. def self.handler_fn ::FFI::Function.new :void, [:int], blocking: true do |signal_value| result = yield signal_value result end end # Initialize CZMQ zsys layer; this happens automatically when you create # a socket or an actor; however this call lets you force initialization # earlier, so e.g. logging is properly set-up before you start working. # Not threadsafe, so call only from main thread. Safe to call multiple # times. Returns global CZMQ context. # # @return [::FFI::Pointer] def self.init() result = ::CZMQ::FFI.zsys_init() result end # Optionally shut down the CZMQ zsys layer; this normally happens automatically # when the process exits; however this call lets you force a shutdown # earlier, avoiding any potential problems with atexit() ordering, especially # with Windows dlls. # # @return [void] def self.shutdown() result = ::CZMQ::FFI.zsys_shutdown() result end # Get a new ZMQ socket, automagically creating a ZMQ context if this is # the first time. Caller is responsible for destroying the ZMQ socket # before process exits, to avoid a ZMQ deadlock. Note: you should not use # this method in CZMQ apps, use zsock_new() instead. # *** This is for CZMQ internal use only and may change arbitrarily *** # # @param type [Integer, #to_int, #to_i] # @param filename [String, #to_s, nil] # @param line_nbr [Integer, #to_int, #to_i] # @return [::FFI::Pointer] def self.socket(type, filename, line_nbr) type = Integer(type) line_nbr = Integer(line_nbr) result = ::CZMQ::FFI.zsys_socket(type, filename, line_nbr) result end # Destroy/close a ZMQ socket. You should call this for every socket you # create using zsys_socket(). # *** This is for CZMQ internal use only and may change arbitrarily *** # # @param handle [::FFI::Pointer, #to_ptr] # @param filename [String, #to_s, nil] # @param line_nbr [Integer, #to_int, #to_i] # @return [Integer] def self.close(handle, filename, line_nbr) line_nbr = Integer(line_nbr) result = ::CZMQ::FFI.zsys_close(handle, filename, line_nbr) result end # Return ZMQ socket name for socket type # *** This is for CZMQ internal use only and may change arbitrarily *** # # @param socktype [Integer, #to_int, #to_i] # @return [::FFI::Pointer] def self.sockname(socktype) socktype = Integer(socktype) result = ::CZMQ::FFI.zsys_sockname(socktype) result end # Create a pipe, which consists of two PAIR sockets connected over inproc. # The pipe is configured to use the zsys_pipehwm setting. Returns the # frontend socket successful, NULL if failed. # # @param backend_p [#__ptr_give_ref] # @return [Zsock] def self.create_pipe(backend_p) backend_p = backend_p.__ptr_give_ref result = ::CZMQ::FFI.zsys_create_pipe(backend_p) result = Zsock.__new result, false result end # Set interrupt handler; this saves the default handlers so that a # zsys_handler_reset () can restore them. If you call this multiple times # then the last handler will take affect. If handler_fn is NULL, disables # default SIGINT/SIGTERM handling in CZMQ. # # @param handler_fn [::FFI::Pointer, #to_ptr] # @return [void] def self.handler_set(handler_fn) result = ::CZMQ::FFI.zsys_handler_set(handler_fn) result end # Reset interrupt handler, call this at exit if needed # # @return [void] def self.handler_reset() result = ::CZMQ::FFI.zsys_handler_reset() result end # Set default interrupt handler, so Ctrl-C or SIGTERM will set # zsys_interrupted. Idempotent; safe to call multiple times. # Can be supressed by ZSYS_SIGHANDLER=false # *** This is for CZMQ internal use only and may change arbitrarily *** # # @return [void] def self.catch_interrupts() result = ::CZMQ::FFI.zsys_catch_interrupts() result end # Return 1 if file exists, else zero # # @param filename [String, #to_s, nil] # @return [Boolean] def self.file_exists(filename) result = ::CZMQ::FFI.zsys_file_exists(filename) result end # Return file modification time. Returns 0 if the file does not exist. # # @param filename [String, #to_s, nil] # @return [::FFI::Pointer] def self.file_modified(filename) result = ::CZMQ::FFI.zsys_file_modified(filename) result end # Return file mode; provides at least support for the POSIX S_ISREG(m) # and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. # Returns a mode_t cast to int, or -1 in case of error. # # @param filename [String, #to_s, nil] # @return [Integer] def self.file_mode(filename) result = ::CZMQ::FFI.zsys_file_mode(filename) result end # Delete file. Does not complain if the file is absent # # @param filename [String, #to_s, nil] # @return [Integer] def self.file_delete(filename) result = ::CZMQ::FFI.zsys_file_delete(filename) result end # Check if file is 'stable' # # @param filename [String, #to_s, nil] # @return [Boolean] def self.file_stable(filename) result = ::CZMQ::FFI.zsys_file_stable(filename) result end # Create a file path if it doesn't exist. The file path is treated as # printf format. # # @param pathname [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def self.dir_create(pathname, *args) result = ::CZMQ::FFI.zsys_dir_create(pathname, *args) result end # Remove a file path if empty; the pathname is treated as printf format. # # @param pathname [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def self.dir_delete(pathname, *args) result = ::CZMQ::FFI.zsys_dir_delete(pathname, *args) result end # Move to a specified working directory. Returns 0 if OK, -1 if this failed. # # @param pathname [String, #to_s, nil] # @return [Integer] def self.dir_change(pathname) result = ::CZMQ::FFI.zsys_dir_change(pathname) result end # Set private file creation mode; all files created from here will be # readable/writable by the owner only. # # @return [void] def self.file_mode_private() result = ::CZMQ::FFI.zsys_file_mode_private() result end # Reset default file creation mode; all files created from here will use # process file mode defaults. # # @return [void] def self.file_mode_default() result = ::CZMQ::FFI.zsys_file_mode_default() result end # Return the CZMQ version for run-time API detection; returns version # number into provided fields, providing reference isn't null in each case. # # @param major [::FFI::Pointer, #to_ptr] # @param minor [::FFI::Pointer, #to_ptr] # @param patch [::FFI::Pointer, #to_ptr] # @return [void] def self.version(major, minor, patch) result = ::CZMQ::FFI.zsys_version(major, minor, patch) result end # 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(). # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [::FFI::Pointer] def self.sprintf(format, *args) result = ::CZMQ::FFI.zsys_sprintf(format, *args) result end # Format a string with a va_list argument, returning a freshly allocated # buffer. If there was insufficient memory, returns NULL. Free the returned # string using zstr_free(). # # @param format [String, #to_s, nil] # @param argptr [::FFI::Pointer, #to_ptr] # @return [::FFI::Pointer] def self.vprintf(format, argptr) result = ::CZMQ::FFI.zsys_vprintf(format, argptr) result end # Create UDP beacon socket; if the routable option is true, uses # multicast (not yet implemented), else uses broadcast. This method # and related ones might _eventually_ be moved to a zudp class. # *** This is for CZMQ internal use only and may change arbitrarily *** # # @param routable [Boolean] # @return [Integer or FFI::Pointer] def self.udp_new(routable) routable = !(0==routable||!routable) # boolean result = ::CZMQ::FFI.zsys_udp_new(routable) result end # Close a UDP socket # *** This is for CZMQ internal use only and may change arbitrarily *** # # @param handle [Integer or FFI::Pointer] # @return [Integer] def self.udp_close(handle) result = ::CZMQ::FFI.zsys_udp_close(handle) result end # Send zframe to UDP socket, return -1 if sending failed due to # interface having disappeared (happens easily with WiFi) # *** This is for CZMQ internal use only and may change arbitrarily *** # # @param udpsock [Integer or FFI::Pointer] # @param frame [Zframe, #__ptr] # @param address [::FFI::Pointer, #to_ptr] # @param addrlen [Integer, #to_int, #to_i] # @return [Integer] def self.udp_send(udpsock, frame, address, addrlen) frame = frame.__ptr if frame addrlen = Integer(addrlen) result = ::CZMQ::FFI.zsys_udp_send(udpsock, frame, address, addrlen) result end # Receive zframe from UDP socket, and set address of peer that sent it # The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or # NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. # *** This is for CZMQ internal use only and may change arbitrarily *** # # @param udpsock [Integer or FFI::Pointer] # @param peername [::FFI::Pointer, #to_ptr] # @param peerlen [Integer, #to_int, #to_i] # @return [Zframe] def self.udp_recv(udpsock, peername, peerlen) peerlen = Integer(peerlen) result = ::CZMQ::FFI.zsys_udp_recv(udpsock, peername, peerlen) result = Zframe.__new result, false result end # Handle an I/O error on some socket operation; will report and die on # fatal errors, and continue silently on "try again" errors. # *** This is for CZMQ internal use only and may change arbitrarily *** # # @param reason [String, #to_s, nil] # @return [void] def self.socket_error(reason) result = ::CZMQ::FFI.zsys_socket_error(reason) result end # Return current host name, for use in public tcp:// endpoints. Caller gets # a freshly allocated string, should free it using zstr_free(). If the host # name is not resolvable, returns NULL. # # @return [::FFI::Pointer] def self.hostname() result = ::CZMQ::FFI.zsys_hostname() result end # Move the current process into the background. The precise effect depends # on the operating system. On POSIX boxes, moves to a specified working # directory (if specified), closes all file handles, reopens stdin, stdout, # and stderr to the null device, and sets the process to ignore SIGHUP. On # Windows, does nothing. Returns 0 if OK, -1 if there was an error. # # @param workdir [String, #to_s, nil] # @return [Integer] def self.daemonize(workdir) result = ::CZMQ::FFI.zsys_daemonize(workdir) result end # Drop the process ID into the lockfile, with exclusive lock, and switch # the process to the specified group and/or user. Any of the arguments # may be null, indicating a no-op. Returns 0 on success, -1 on failure. # Note if you combine this with zsys_daemonize, run after, not before # that method, or the lockfile will hold the wrong process ID. # # @param lockfile [String, #to_s, nil] # @param group [String, #to_s, nil] # @param user [String, #to_s, nil] # @return [Integer] def self.run_as(lockfile, group, user) result = ::CZMQ::FFI.zsys_run_as(lockfile, group, user) result end # Returns true if the underlying libzmq supports CURVE security. # Uses a heuristic probe according to the version of libzmq being used. # # @return [Boolean] def self.has_curve() result = ::CZMQ::FFI.zsys_has_curve() result end # Configure the number of I/O threads that ZeroMQ will use. A good # rule of thumb is one thread per gigabit of traffic in or out. The # default is 1, sufficient for most applications. If the environment # variable ZSYS_IO_THREADS is defined, that provides the default. # Note that this method is valid only before any socket is created. # # @param io_threads [Integer, #to_int, #to_i] # @return [void] def self.set_io_threads(io_threads) io_threads = Integer(io_threads) result = ::CZMQ::FFI.zsys_set_io_threads(io_threads) result end # Configure the scheduling policy of the ZMQ context thread pool. # Not available on Windows. See the sched_setscheduler man page or sched.h # for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY # is defined, that provides the default. # Note that this method is valid only before any socket is created. # # @param policy [Integer, #to_int, #to_i] # @return [void] def self.set_thread_sched_policy(policy) policy = Integer(policy) result = ::CZMQ::FFI.zsys_set_thread_sched_policy(policy) result end # Configure the scheduling priority of the ZMQ context thread pool. # Not available on Windows. See the sched_setscheduler man page or sched.h # for more information. If the environment variable ZSYS_THREAD_PRIORITY is # defined, that provides the default. # Note that this method is valid only before any socket is created. # # @param priority [Integer, #to_int, #to_i] # @return [void] def self.set_thread_priority(priority) priority = Integer(priority) result = ::CZMQ::FFI.zsys_set_thread_priority(priority) result end # Configure the number of sockets that ZeroMQ will allow. The default # is 1024. The actual limit depends on the system, and you can query it # by using zsys_socket_limit (). A value of zero means "maximum". # Note that this method is valid only before any socket is created. # # @param max_sockets [Integer, #to_int, #to_i] # @return [void] def self.set_max_sockets(max_sockets) max_sockets = Integer(max_sockets) result = ::CZMQ::FFI.zsys_set_max_sockets(max_sockets) result end # Return maximum number of ZeroMQ sockets that the system will support. # # @return [Integer] def self.socket_limit() result = ::CZMQ::FFI.zsys_socket_limit() result end # Configure the maximum allowed size of a message sent. # The default is INT_MAX. # # @param max_msgsz [Integer, #to_int, #to_i] # @return [void] def self.set_max_msgsz(max_msgsz) max_msgsz = Integer(max_msgsz) result = ::CZMQ::FFI.zsys_set_max_msgsz(max_msgsz) result end # Return maximum message size. # # @return [Integer] def self.max_msgsz() result = ::CZMQ::FFI.zsys_max_msgsz() result end # Configure the threshold value of filesystem object age per st_mtime # that should elapse until we consider that object "stable" at the # current zclock_time() moment. # The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c # which generally depends on host OS, with fallback value of 5000. # # @param file_stable_age_msec [::FFI::Pointer, #to_ptr] # @return [void] def self.set_file_stable_age_msec(file_stable_age_msec) result = ::CZMQ::FFI.zsys_set_file_stable_age_msec(file_stable_age_msec) result end # Return current threshold value of file stable age in msec. # This can be used in code that chooses to wait for this timeout # before testing if a filesystem object is "stable" or not. # # @return [::FFI::Pointer] def self.file_stable_age_msec() result = ::CZMQ::FFI.zsys_file_stable_age_msec() result end # Configure the default linger timeout in msecs for new zsock instances. # You can also set this separately on each zsock_t instance. The default # linger time is zero, i.e. any pending messages will be dropped. If the # environment variable ZSYS_LINGER is defined, that provides the default. # Note that process exit will typically be delayed by the linger time. # # @param linger [Integer, #to_int, #to_i] # @return [void] def self.set_linger(linger) linger = Integer(linger) result = ::CZMQ::FFI.zsys_set_linger(linger) result end # Configure the default outgoing pipe limit (HWM) for new zsock instances. # You can also set this separately on each zsock_t instance. The default # HWM is 1,000, on all versions of ZeroMQ. If the environment variable # ZSYS_SNDHWM is defined, that provides the default. Note that a value of # zero means no limit, i.e. infinite memory consumption. # # @param sndhwm [Integer, #to_int, #to_i] # @return [void] def self.set_sndhwm(sndhwm) sndhwm = Integer(sndhwm) result = ::CZMQ::FFI.zsys_set_sndhwm(sndhwm) result end # Configure the default incoming pipe limit (HWM) for new zsock instances. # You can also set this separately on each zsock_t instance. The default # HWM is 1,000, on all versions of ZeroMQ. If the environment variable # ZSYS_RCVHWM is defined, that provides the default. Note that a value of # zero means no limit, i.e. infinite memory consumption. # # @param rcvhwm [Integer, #to_int, #to_i] # @return [void] def self.set_rcvhwm(rcvhwm) rcvhwm = Integer(rcvhwm) result = ::CZMQ::FFI.zsys_set_rcvhwm(rcvhwm) result end # Configure the default HWM for zactor internal pipes; this is set on both # ends of the pipe, for outgoing messages only (sndhwm). The default HWM is # 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is # defined, that provides the default. Note that a value of zero means no # limit, i.e. infinite memory consumption. # # @param pipehwm [Integer, #to_int, #to_i] # @return [void] def self.set_pipehwm(pipehwm) pipehwm = Integer(pipehwm) result = ::CZMQ::FFI.zsys_set_pipehwm(pipehwm) result end # Return the HWM for zactor internal pipes. # # @return [Integer] def self.pipehwm() result = ::CZMQ::FFI.zsys_pipehwm() result end # Configure use of IPv6 for new zsock instances. By default sockets accept # and make only IPv4 connections. When you enable IPv6, sockets will accept # and connect to both IPv4 and IPv6 peers. You can override the setting on # each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the # environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the # default. Note: has no effect on ZMQ v2. # # @param ipv6 [Integer, #to_int, #to_i] # @return [void] def self.set_ipv6(ipv6) ipv6 = Integer(ipv6) result = ::CZMQ::FFI.zsys_set_ipv6(ipv6) result end # Return use of IPv6 for zsock instances. # # @return [Integer] def self.ipv6() result = ::CZMQ::FFI.zsys_ipv6() result end # Set network interface name to use for broadcasts, particularly zbeacon. # This lets the interface be configured for test environments where required. # For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is # the default when there is no specified interface. If the environment # variable ZSYS_INTERFACE is set, use that as the default interface name. # Setting the interface to "*" means "use all available interfaces". # # @param value [String, #to_s, nil] # @return [void] def self.set_interface(value) result = ::CZMQ::FFI.zsys_set_interface(value) result end # Return network interface to use for broadcasts, or "" if none was set. # # @return [String] def self.interface() result = ::CZMQ::FFI.zsys_interface() result end # Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. # This needs to be set IPv6 is enabled as IPv6 can have multiple addresses # on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, # use that as the default IPv6 address. # # @param value [String, #to_s, nil] # @return [void] def self.set_ipv6_address(value) result = ::CZMQ::FFI.zsys_set_ipv6_address(value) result end # Return IPv6 address to use for zbeacon reception, or "" if none was set. # # @return [String] def self.ipv6_address() result = ::CZMQ::FFI.zsys_ipv6_address() result end # Set IPv6 milticast address to use for sending zbeacon messages. This needs # to be set if IPv6 is enabled. If the environment variable # ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast # address. # # @param value [String, #to_s, nil] # @return [void] def self.set_ipv6_mcast_address(value) result = ::CZMQ::FFI.zsys_set_ipv6_mcast_address(value) result end # Return IPv6 multicast address to use for sending zbeacon, or "" if none was # set. # # @return [String] def self.ipv6_mcast_address() result = ::CZMQ::FFI.zsys_ipv6_mcast_address() result end # Configure the automatic use of pre-allocated FDs when creating new sockets. # If 0 (default), nothing will happen. Else, when a new socket is bound, the # system API will be used to check if an existing pre-allocated FD with a # matching port (if TCP) or path (if IPC) exists, and if it does it will be # set via the ZMQ_USE_FD socket option so that the library will use it # instead of creating a new socket. # # @param auto_use_fd [Integer, #to_int, #to_i] # @return [void] def self.set_auto_use_fd(auto_use_fd) auto_use_fd = Integer(auto_use_fd) result = ::CZMQ::FFI.zsys_set_auto_use_fd(auto_use_fd) result end # Return use of automatic pre-allocated FDs for zsock instances. # # @return [Integer] def self.auto_use_fd() result = ::CZMQ::FFI.zsys_auto_use_fd() result end # Set log identity, which is a string that prefixes all log messages sent # by this process. The log identity defaults to the environment variable # ZSYS_LOGIDENT, if that is set. # # @param value [String, #to_s, nil] # @return [void] def self.set_logident(value) result = ::CZMQ::FFI.zsys_set_logident(value) result end # Set stream to receive log traffic. By default, log traffic is sent to # stdout. If you set the stream to NULL, no stream will receive the log # traffic (it may still be sent to the system facility). # # @param stream [::FFI::Pointer, #to_ptr] # @return [void] def self.set_logstream(stream) result = ::CZMQ::FFI.zsys_set_logstream(stream) result end # Sends log output to a PUB socket bound to the specified endpoint. To # collect such log output, create a SUB socket, subscribe to the traffic # you care about, and connect to the endpoint. Log traffic is sent as a # single string frame, in the same format as when sent to stdout. The # log system supports a single sender; multiple calls to this method will # bind the same sender to multiple endpoints. To disable the sender, call # this method with a null argument. # # @param endpoint [String, #to_s, nil] # @return [void] def self.set_logsender(endpoint) result = ::CZMQ::FFI.zsys_set_logsender(endpoint) result end # Enable or disable logging to the system facility (syslog on POSIX boxes, # event log on Windows). By default this is disabled. # # @param logsystem [Boolean] # @return [void] def self.set_logsystem(logsystem) logsystem = !(0==logsystem||!logsystem) # boolean result = ::CZMQ::FFI.zsys_set_logsystem(logsystem) result end # Log error condition - highest priority # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def self.error(format, *args) result = ::CZMQ::FFI.zsys_error(format, *args) result end # Log warning condition - high priority # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def self.warning(format, *args) result = ::CZMQ::FFI.zsys_warning(format, *args) result end # Log normal, but significant, condition - normal priority # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def self.notice(format, *args) result = ::CZMQ::FFI.zsys_notice(format, *args) result end # Log informational message - low priority # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def self.info(format, *args) result = ::CZMQ::FFI.zsys_info(format, *args) result end # Log debug-level message - lowest priority # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def self.debug(format, *args) result = ::CZMQ::FFI.zsys_debug(format, *args) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zsys_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zstr.rb0000664000372000037200000002215113222211156021755 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # sending and receiving strings # @note This class is 100% generated using zproject. class Zstr # Raised when one tries to use an instance of {Zstr} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do "WARNING: "\ "Objects of type #{self} cannot be destroyed implicitly. "\ "Please call the correct destroy method with the relevant arguments." end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Receive C string from socket. Caller must free returned string using # zstr_free(). Returns NULL if the context is being terminated or the # process was interrupted. # # @param source [::FFI::Pointer, #to_ptr] # @return [::FFI::AutoPointer] def self.recv(source) result = ::CZMQ::FFI.zstr_recv(source) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Receive a series of strings (until NULL) from multipart data. # Each string is allocated and filled with string data; if there # are not enough frames, unallocated strings are set to NULL. # Returns -1 if the message could not be read, else returns the # number of strings filled, zero or more. Free each returned string # using zstr_free(). If not enough strings are provided, remaining # multipart frames in the message are dropped. # # @param source [::FFI::Pointer, #to_ptr] # @param string_p [::FFI::Pointer, #to_ptr] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def self.recvx(source, string_p, *args) result = ::CZMQ::FFI.zstr_recvx(source, string_p, *args) result end # De-compress and receive C string from socket, received as a message # with two frames: size of the uncompressed string, and the string itself. # Caller must free returned string using zstr_free(). Returns NULL if the # context is being terminated or the process was interrupted. # # @param source [::FFI::Pointer, #to_ptr] # @return [::FFI::AutoPointer] def self.recv_compress(source) result = ::CZMQ::FFI.zstr_recv_compress(source) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Send a C string to a socket, as a frame. The string is sent without # trailing null byte; to read this you can use zstr_recv, or a similar # method that adds a null terminator on the received string. String # may be NULL, which is sent as "". # # @param dest [::FFI::Pointer, #to_ptr] # @param string [String, #to_s, nil] # @return [Integer] def self.send(dest, string) result = ::CZMQ::FFI.zstr_send(dest, string) result end # Send a C string to a socket, as zstr_send(), with a MORE flag, so that # you can send further strings in the same multi-part message. # # @param dest [::FFI::Pointer, #to_ptr] # @param string [String, #to_s, nil] # @return [Integer] def self.sendm(dest, string) result = ::CZMQ::FFI.zstr_sendm(dest, string) result end # Send a formatted string to a socket. Note that you should NOT use # user-supplied strings in the format (they may contain '%' which # will create security holes). # # @param dest [::FFI::Pointer, #to_ptr] # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def self.sendf(dest, format, *args) result = ::CZMQ::FFI.zstr_sendf(dest, format, *args) result end # Send a formatted string to a socket, as for zstr_sendf(), with a # MORE flag, so that you can send further strings in the same multi-part # message. # # @param dest [::FFI::Pointer, #to_ptr] # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def self.sendfm(dest, format, *args) result = ::CZMQ::FFI.zstr_sendfm(dest, format, *args) result end # Send a series of strings (until NULL) as multipart data # Returns 0 if the strings could be sent OK, or -1 on error. # # @param dest [::FFI::Pointer, #to_ptr] # @param string [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [Integer] def self.sendx(dest, string, *args) result = ::CZMQ::FFI.zstr_sendx(dest, string, *args) result end # Compress and send a C string to a socket, as a message with two frames: # size of the uncompressed string, and the string itself. The string is # sent without trailing null byte; to read this you can use # zstr_recv_compress, or a similar method that de-compresses and adds a # null terminator on the received string. # # @param dest [::FFI::Pointer, #to_ptr] # @param string [String, #to_s, nil] # @return [Integer] def self.send_compress(dest, string) result = ::CZMQ::FFI.zstr_send_compress(dest, string) result end # Compress and send a C string to a socket, as zstr_send_compress(), # with a MORE flag, so that you can send further strings in the same # multi-part message. # # @param dest [::FFI::Pointer, #to_ptr] # @param string [String, #to_s, nil] # @return [Integer] def self.sendm_compress(dest, string) result = ::CZMQ::FFI.zstr_sendm_compress(dest, string) result end # Accepts a void pointer and returns a fresh character string. If source # is null, returns an empty string. # # @param source [::FFI::Pointer, #to_ptr] # @return [::FFI::AutoPointer] def self.str(source) result = ::CZMQ::FFI.zstr_str(source) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Free a provided string, and nullify the parent pointer. Safe to call on # a null pointer. # # @param string_p [::FFI::Pointer, #to_ptr] # @return [void] def self.free(string_p) result = ::CZMQ::FFI.zstr_free(string_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zstr_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zdigest.rb0000664000372000037200000001207313222211156022426 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # provides hashing functions (SHA-1 at present) # @note This class is 100% generated using zproject. class Zdigest # Raised when one tries to use an instance of {Zdigest} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zdigest_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Constructor - creates new digest object, which you use to build up a # digest by repeatedly calling zdigest_update() on chunks of data. # @return [CZMQ::Zdigest] def self.new() ptr = ::CZMQ::FFI.zdigest_new() __new ptr end # Destroy a digest object # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zdigest_destroy(self_p) result end # Add buffer into digest calculation # # @param buffer [::FFI::Pointer, #to_ptr] # @param length [Integer, #to_int, #to_i] # @return [void] def update(buffer, length) raise DestroyedError unless @ptr self_p = @ptr length = Integer(length) result = ::CZMQ::FFI.zdigest_update(self_p, buffer, length) result end # Return final digest hash data. If built without crypto support, # returns NULL. # # @return [::FFI::Pointer] def data() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdigest_data(self_p) result end # Return final digest hash size # # @return [Integer] def size() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdigest_size(self_p) result end # Return digest as printable hex string; caller should not modify nor # free this string. After calling this, you may not use zdigest_update() # on the same digest. If built without crypto support, returns NULL. # # @return [::FFI::Pointer] def string() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zdigest_string(self_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zdigest_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zarmour.rb0000664000372000037200000002044513222211156022456 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # armoured text encoding and decoding # @note This class is 100% generated using zproject. class Zarmour # Standard base 64 MODE_BASE64_STD = 0 # URL and filename friendly base 64 MODE_BASE64_URL = 1 # Standard base 32 MODE_BASE32_STD = 2 # Extended hex base 32 MODE_BASE32_HEX = 3 # Standard base 16 MODE_BASE16 = 4 # Z85 from ZeroMQ RFC 32 MODE_Z85 = 5 # Raised when one tries to use an instance of {Zarmour} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zarmour_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new zarmour # @return [CZMQ::Zarmour] def self.new() ptr = ::CZMQ::FFI.zarmour_new() __new ptr end # Destroy the zarmour # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zarmour_destroy(self_p) result end # Encode a stream of bytes into an armoured string. Returns the armoured # string, or NULL if there was insufficient memory available to allocate # a new string. # # @param data [::FFI::Pointer, #to_ptr] # @param size [Integer, #to_int, #to_i] # @return [::FFI::AutoPointer] def encode(data, size) raise DestroyedError unless @ptr self_p = @ptr size = Integer(size) result = ::CZMQ::FFI.zarmour_encode(self_p, data, size) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Decode an armoured string into a chunk. The decoded output is # null-terminated, so it may be treated as a string, if that's what # it was prior to encoding. # # @param data [String, #to_s, nil] # @return [Zchunk] def decode(data) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_decode(self_p, data) result = Zchunk.__new result, true result end # Get the mode property. # # @return [Integer] def mode() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_mode(self_p) result end # Get printable string for mode. # # @return [String] def mode_str() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_mode_str(self_p) result end # Set the mode property. # # @param mode [Integer, #to_int, #to_i] # @return [void] def set_mode(mode) raise DestroyedError unless @ptr self_p = @ptr mode = Integer(mode) result = ::CZMQ::FFI.zarmour_set_mode(self_p, mode) result end # Return true if padding is turned on. # # @return [Boolean] def pad() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_pad(self_p) result end # Turn padding on or off. Default is on. # # @param pad [Boolean] # @return [void] def set_pad(pad) raise DestroyedError unless @ptr self_p = @ptr pad = !(0==pad||!pad) # boolean result = ::CZMQ::FFI.zarmour_set_pad(self_p, pad) result end # Get the padding character. # # @return [::FFI::Pointer] def pad_char() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_pad_char(self_p) result end # Set the padding character. # # @param pad_char [::FFI::Pointer, #to_ptr] # @return [void] def set_pad_char(pad_char) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_set_pad_char(self_p, pad_char) result end # Return if splitting output into lines is turned on. Default is off. # # @return [Boolean] def line_breaks() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_line_breaks(self_p) result end # Turn splitting output into lines on or off. # # @param line_breaks [Boolean] # @return [void] def set_line_breaks(line_breaks) raise DestroyedError unless @ptr self_p = @ptr line_breaks = !(0==line_breaks||!line_breaks) # boolean result = ::CZMQ::FFI.zarmour_set_line_breaks(self_p, line_breaks) result end # Get the line length used for splitting lines. # # @return [Integer] def line_length() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_line_length(self_p) result end # Set the line length used for splitting lines. # # @param line_length [Integer, #to_int, #to_i] # @return [void] def set_line_length(line_length) raise DestroyedError unless @ptr self_p = @ptr line_length = Integer(line_length) result = ::CZMQ::FFI.zarmour_set_line_length(self_p, line_length) result end # Print properties of object # # @return [void] def print() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_print(self_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zarmour_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zpoller.rb0000664000372000037200000001560713222211156022452 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # event-driven reactor # @note This class is 100% generated using zproject. class Zpoller # Raised when one tries to use an instance of {Zpoller} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zpoller_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create new poller, specifying zero or more readers. The list of # readers ends in a NULL. Each reader can be a zsock_t instance, a # zactor_t instance, a libzmq socket (void *), or a file handle. # @param reader [::FFI::Pointer, #to_ptr] # @param args [Array] # @return [CZMQ::Zpoller] def self.new(reader, *args) ptr = ::CZMQ::FFI.zpoller_new(reader, *args) __new ptr end # Destroy a poller # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zpoller_destroy(self_p) result end # Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may # be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. # # @param reader [::FFI::Pointer, #to_ptr] # @return [Integer] def add(reader) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zpoller_add(self_p, reader) result end # Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader # must have been passed during construction, or in an zpoller_add () call. # # @param reader [::FFI::Pointer, #to_ptr] # @return [Integer] def remove(reader) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zpoller_remove(self_p, reader) result end # By default the poller stops if the process receives a SIGINT or SIGTERM # signal. This makes it impossible to shut-down message based architectures # like zactors. This method lets you switch off break handling. The default # nonstop setting is off (false). # # @param nonstop [Boolean] # @return [void] def set_nonstop(nonstop) raise DestroyedError unless @ptr self_p = @ptr nonstop = !(0==nonstop||!nonstop) # boolean result = ::CZMQ::FFI.zpoller_set_nonstop(self_p, nonstop) result end # Poll the registered readers for I/O, return first reader that has input. # The reader will be a libzmq void * socket, or a zsock_t or zactor_t # instance as specified in zpoller_new/zpoller_add. The timeout should be # zero or greater, or -1 to wait indefinitely. Socket priority is defined # by their order in the poll list. If you need a balanced poll, use the low # level zmq_poll method directly. If the poll call was interrupted (SIGINT), # or the ZMQ context was destroyed, or the timeout expired, returns NULL. # You can test the actual exit condition by calling zpoller_expired () and # zpoller_terminated (). The timeout is in msec. # # @param timeout [Integer, #to_int, #to_i] # @return [::FFI::Pointer] def wait(timeout) raise DestroyedError unless @ptr self_p = @ptr timeout = Integer(timeout) result = ::CZMQ::FFI.zpoller_wait(self_p, timeout) result end # Return true if the last zpoller_wait () call ended because the timeout # expired, without any error. # # @return [Boolean] def expired() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zpoller_expired(self_p) result end # Return true if the last zpoller_wait () call ended because the process # was interrupted, or the parent context was destroyed. # # @return [Boolean] def terminated() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zpoller_terminated(self_p) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zpoller_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zproc.rb0000664000372000037200000004060513222211156022114 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ module CZMQ module FFI # process configuration and status # @note This class is 100% generated using zproject. class Zproc # Raised when one tries to use an instance of {Zproc} after # the internal pointer to the native object has been nullified. class DestroyedError < RuntimeError; end # Boilerplate for self pointer, initializer, and finalizer class << self alias :__new :new end # Attaches the pointer _ptr_ to this instance and defines a finalizer for # it if necessary. # @param ptr [::FFI::Pointer] # @param finalize [Boolean] def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end # @param ptr [::FFI::Pointer] # @return [Proc] def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zproc_destroy ptr_ptr end end # @return [Boolean] def null? !@ptr or @ptr.null? end # Return internal pointer # @return [::FFI::Pointer] def __ptr raise DestroyedError unless @ptr @ptr end # So external Libraries can just pass the Object to a FFI function which expects a :pointer alias_method :to_ptr, :__ptr # Nullify internal pointer and return pointer pointer. # @note This detaches the current instance from the native object # and thus makes it unusable. # @return [::FFI::MemoryPointer] the pointer pointing to a pointer # pointing to the native object def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end # Undefines the finalizer for this object. # @note Only use this if you need to and can guarantee that the native # object will be freed by other means. # @return [void] def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end # Create a new zproc. # NOTE: On Windows and with libzmq3 and libzmq2 this function # returns NULL. Code needs to be ported there. # @return [CZMQ::Zproc] def self.new() ptr = ::CZMQ::FFI.zproc_new() __new ptr end # Destroy zproc, wait until process ends. # # @return [void] def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zproc_destroy(self_p) result end # Setup the command line arguments, the first item must be an (absolute) filename # to run. # # @param args [Zlistx, #__ptr] # @return [void] def set_args(args) raise DestroyedError unless @ptr self_p = @ptr args = args.__ptr if args result = ::CZMQ::FFI.zproc_set_args(self_p, args) result end # Setup the environment variables for the process. # # @param args [Zhashx, #__ptr] # @return [void] def set_env(args) raise DestroyedError unless @ptr self_p = @ptr args = args.__ptr if args result = ::CZMQ::FFI.zproc_set_env(self_p, args) result end # Connects process stdin with a readable ('>', connect) zeromq socket. If # socket argument is NULL, zproc creates own managed pair of inproc # sockets. The writable one is then accessbile via zproc_stdin method. # # @param socket [::FFI::Pointer, #to_ptr] # @return [void] def set_stdin(socket) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_set_stdin(self_p, socket) result end # Connects process stdout with a writable ('@', bind) zeromq socket. If # socket argument is NULL, zproc creates own managed pair of inproc # sockets. The readable one is then accessbile via zproc_stdout method. # # @param socket [::FFI::Pointer, #to_ptr] # @return [void] def set_stdout(socket) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_set_stdout(self_p, socket) result end # Connects process stderr with a writable ('@', bind) zeromq socket. If # socket argument is NULL, zproc creates own managed pair of inproc # sockets. The readable one is then accessbile via zproc_stderr method. # # @param socket [::FFI::Pointer, #to_ptr] # @return [void] def set_stderr(socket) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_set_stderr(self_p, socket) result end # Return subprocess stdin writable socket. NULL for # not initialized or external sockets. # # @return [::FFI::Pointer] def stdin() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_stdin(self_p) result end # Return subprocess stdout readable socket. NULL for # not initialized or external sockets. # # @return [::FFI::Pointer] def stdout() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_stdout(self_p) result end # Return subprocess stderr readable socket. NULL for # not initialized or external sockets. # # @return [::FFI::Pointer] def stderr() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_stderr(self_p) result end # Starts the process. # # @return [Integer] def run() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_run(self_p) result end # process exit code # # @return [Integer] def returncode() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_returncode(self_p) result end # PID of the process # # @return [Integer] def pid() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_pid(self_p) result end # return true if process is running, false if not yet started or finished # # @return [Boolean] def running() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_running(self_p) result end # wait or poll process status, return return code # # @param hang [Boolean] # @return [Integer] def wait(hang) raise DestroyedError unless @ptr self_p = @ptr hang = !(0==hang||!hang) # boolean result = ::CZMQ::FFI.zproc_wait(self_p, hang) result end # return internal actor, usefull for the polling if process died # # @return [::FFI::Pointer] def actor() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_actor(self_p) result end # send a signal to the subprocess # # @param signal [Integer, #to_int, #to_i] # @return [void] def kill(signal) raise DestroyedError unless @ptr self_p = @ptr signal = Integer(signal) result = ::CZMQ::FFI.zproc_kill(self_p, signal) result end # set verbose mode # # @param verbose [Boolean] # @return [void] def set_verbose(verbose) raise DestroyedError unless @ptr self_p = @ptr verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zproc_set_verbose(self_p, verbose) result end # Returns CZMQ version as a single 6-digit integer encoding the major # version (x 10000), the minor version (x 100) and the patch. # # @return [Integer] def self.czmq_version() result = ::CZMQ::FFI.zproc_czmq_version() result end # Returns true if the process received a SIGINT or SIGTERM signal. # It is good practice to use this method to exit any infinite loop # processing messages. # # @return [Boolean] def self.interrupted() result = ::CZMQ::FFI.zproc_interrupted() result end # Returns true if the underlying libzmq supports CURVE security. # # @return [Boolean] def self.has_curve() result = ::CZMQ::FFI.zproc_has_curve() result end # Return current host name, for use in public tcp:// endpoints. # If the host name is not resolvable, returns NULL. # # @return [::FFI::AutoPointer] def self.hostname() result = ::CZMQ::FFI.zproc_hostname() result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end # Move the current process into the background. The precise effect # depends on the operating system. On POSIX boxes, moves to a specified # working directory (if specified), closes all file handles, reopens # stdin, stdout, and stderr to the null device, and sets the process to # ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there # was an error. # # @param workdir [String, #to_s, nil] # @return [void] def self.daemonize(workdir) result = ::CZMQ::FFI.zproc_daemonize(workdir) result end # Drop the process ID into the lockfile, with exclusive lock, and # switch the process to the specified group and/or user. Any of the # arguments may be null, indicating a no-op. Returns 0 on success, # -1 on failure. Note if you combine this with zsys_daemonize, run # after, not before that method, or the lockfile will hold the wrong # process ID. # # @param lockfile [String, #to_s, nil] # @param group [String, #to_s, nil] # @param user [String, #to_s, nil] # @return [void] def self.run_as(lockfile, group, user) result = ::CZMQ::FFI.zproc_run_as(lockfile, group, user) result end # Configure the number of I/O threads that ZeroMQ will use. A good # rule of thumb is one thread per gigabit of traffic in or out. The # default is 1, sufficient for most applications. If the environment # variable ZSYS_IO_THREADS is defined, that provides the default. # Note that this method is valid only before any socket is created. # # @param io_threads [Integer, #to_int, #to_i] # @return [void] def self.set_io_threads(io_threads) io_threads = Integer(io_threads) result = ::CZMQ::FFI.zproc_set_io_threads(io_threads) result end # Configure the number of sockets that ZeroMQ will allow. The default # is 1024. The actual limit depends on the system, and you can query it # by using zsys_socket_limit (). A value of zero means "maximum". # Note that this method is valid only before any socket is created. # # @param max_sockets [Integer, #to_int, #to_i] # @return [void] def self.set_max_sockets(max_sockets) max_sockets = Integer(max_sockets) result = ::CZMQ::FFI.zproc_set_max_sockets(max_sockets) result end # Set network interface name to use for broadcasts, particularly zbeacon. # This lets the interface be configured for test environments where required. # For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is # the default when there is no specified interface. If the environment # variable ZSYS_INTERFACE is set, use that as the default interface name. # Setting the interface to "*" means "use all available interfaces". # # @param value [String, #to_s, nil] # @return [void] def self.set_biface(value) result = ::CZMQ::FFI.zproc_set_biface(value) result end # Return network interface to use for broadcasts, or "" if none was set. # # @return [String] def self.biface() result = ::CZMQ::FFI.zproc_biface() result end # Set log identity, which is a string that prefixes all log messages sent # by this process. The log identity defaults to the environment variable # ZSYS_LOGIDENT, if that is set. # # @param value [String, #to_s, nil] # @return [void] def self.set_log_ident(value) result = ::CZMQ::FFI.zproc_set_log_ident(value) result end # Sends log output to a PUB socket bound to the specified endpoint. To # collect such log output, create a SUB socket, subscribe to the traffic # you care about, and connect to the endpoint. Log traffic is sent as a # single string frame, in the same format as when sent to stdout. The # log system supports a single sender; multiple calls to this method will # bind the same sender to multiple endpoints. To disable the sender, call # this method with a null argument. # # @param endpoint [String, #to_s, nil] # @return [void] def self.set_log_sender(endpoint) result = ::CZMQ::FFI.zproc_set_log_sender(endpoint) result end # Enable or disable logging to the system facility (syslog on POSIX boxes, # event log on Windows). By default this is disabled. # # @param logsystem [Boolean] # @return [void] def self.set_log_system(logsystem) logsystem = !(0==logsystem||!logsystem) # boolean result = ::CZMQ::FFI.zproc_set_log_system(logsystem) result end # Log error condition - highest priority # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def self.log_error(format, *args) result = ::CZMQ::FFI.zproc_log_error(format, *args) result end # Log warning condition - high priority # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def self.log_warning(format, *args) result = ::CZMQ::FFI.zproc_log_warning(format, *args) result end # Log normal, but significant, condition - normal priority # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def self.log_notice(format, *args) result = ::CZMQ::FFI.zproc_log_notice(format, *args) result end # Log informational message - low priority # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def self.log_info(format, *args) result = ::CZMQ::FFI.zproc_log_info(format, *args) result end # Log debug-level message - lowest priority # # @param format [String, #to_s, nil] # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs # @return [void] def self.log_debug(format, *args) result = ::CZMQ::FFI.zproc_log_debug(format, *args) result end # Self test of this class. # # @param verbose [Boolean] # @return [void] def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zproc_test(verbose) result end end end end ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/jni/0000775000372000037200000000000013222211156015740 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/README.md0000664000372000037200000001034413222211156017221 0ustar00travistravis00000000000000# czmq-jni [ ![Download](https://api.bintray.com/packages/zeromq/maven/czmq-jni/images/download.svg) ](https://bintray.com/zeromq/maven/czmq-jni/_latestVersion) JNI Binding for CZMQ ## Building the JNI Layer for Linux Ensure you have gradle and cmake installed, then run: gradle build jar gradle test If you don't like to install gradle beforehand just use the gradle wrapper. ./gradlew build jar ./gradlew test This calls javah to build the headers in src/native/include, and then compiles the C and Java pieces to create a jar file a sharable library (.so). ## Installing the JNI Layer for Linux If you like to use this JNI Layer in another project you'll need to distribute it to a location where the other project can locate it. The easiest way to do this is by leveraging maven and install to the local maven repository located at $HOME/.m2. Therefore simply run: ./gradlew publishToMavenLocal ## Building the JNI Layer for Android See bindings/jni/android/build.sh. You need the Android Native Development Kit (NDK) installed. Set these environment variables, e.g: ANDROID_NDK_ROOT=$HOME/android-ndk-r11c TOOLCHAIN_VERSION=4.9 TOOLCHAIN_HOST=arm-linux-androideabi TOOLCHAIN_NAME=$TOOLCHAIN_HOST-$TOOLCHAIN_VERSION TOOLCHAIN_ARCH=arm TOOLCHAIN_PATH=$ANDROID_NDK_ROOT/toolchains/$TOOLCHAIN_NAME/prebuilt/linux-x86_64/bin Then in the android directory, run: ./build.sh This does the following: * It compiles the CZMQ C sources for Android, into a native library libczmq.so in builds/android/ * It compiles the JNI Java classes into a jar file czmq-jni-4.1.0.jar in bindings/jni/build/libs * It compiles the JNI C sources for Android, into a native library libczmqjni.so. * It combines all these into czmq-android.jar, which you can use in your Android projects. ## Building the JNI Layer for Windows You need MS Visual Studio 2010 or later. You need the Java SDK. Set the JAVA_HOME environment to the installation location, e.g. C:Program FilesJavajdk1.8.0_66. 1. Check out all dependent projects from github, at the same level as this project. E.g.: libzmq, czmq. 2. In each project, open a console in builds/msvc/vs2010 and run the build.bat batch file. 3. In this project, open a console in bindings/jni/msvc/vs2010 and run the build.bat batch file. The resulting libraries (czmqjni.dll, czmqjni.lib) are created in bindings/jni/msvc/bin. ## Using the JNI API - to be written. ## License Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ## Information for maintainers ### Building the gradle wrapper The gradle wrapper is a tool that allows to use gradle on multiple platforms without installing it beforehand. Make sure you have installed a version of gradle that is at least the version the wrapper should have (local version >= wrapper version). Then just run gradle wrapper Now commit all generated files to the project. Yes the jar file as well! Users will now be able to call the gradle wrapper (gradlew) which will install gradle for them. ### Travis build Travis can build and check this jni layer there add the following line to your travis environment matrix - BUILD_TYPE=bindings BINDING=jni ### Travis deploy to bintray When tagging a release travis can automatically deploy this jni layer to bintray. Therefore you'll need to supply travis with three environment variables: * BINTRAY_USER - your personal user name * BINTRAY_KEY - your personal api key * BINTRAY_USER_ORG - the organisation you like to publish to You may extent .travis.yml as follows - BUILD_TYPE=bindings BINDING=jni BINTRAY_USER= BINTRAY_KEY= BINTRAY_USER_ORG= But I recommend to encrypt your bintray api key. This can be done with the travis commandline client travis encrypt BINTRAY_KEY=123... Please be aware that secure environmental variables can only be added as global. global: - secure: "ZMvDhR..." matrix: - BUILD_TYPE=bindings BINDING=jni BINTRAY_USER= BINTRAY_USER_ORG= czmq-4.1.0/bindings/jni/settings.gradle0000664000372000037200000000003613222211156020757 0ustar00travistravis00000000000000rootProject.name = 'czmq-jni' czmq-4.1.0/bindings/jni/msvc/0000775000372000037200000000000013222211156016710 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/msvc/vs2012/0000775000372000037200000000000013222211156017645 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/msvc/vs2012/libczmqjni/0000775000372000037200000000000013222211156022007 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/msvc/vs2012/libczmqjni/libczmqjni.vcxproj.filters0000664000372000037200000002047713222211156027247 0ustar00travistravis00000000000000 src src src src src src src src src src src src src src src src src src src src src src src src src src include include include include include include include include include include include include include include include include include include include include include include include include include include include src\include resource resource {48f852d3-9723-4499-bf1a-35c0234b8ba9} {95e5d24a-57a2-429a-a1f1-304165f2e3da} {d0c837b5-cb58-4b82-b9bf-38727c7b25bd} {48e93f8c-156c-4379-a901-4b5ad39a4eac} {04a473ca-1d88-4e12-9190-8d9cc20efd74} czmq-4.1.0/bindings/jni/msvc/vs2012/libczmqjni/libczmqjni.vcxproj0000664000372000037200000002012613222211156025567 0ustar00travistravis00000000000000 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7} libczmqjni v110 DebugDLL Win32 ReleaseDLL Win32 DebugDLL x64 ReleaseDLL x64 StaticLibrary DynamicLibrary CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC czmq-4.1.0/bindings/jni/msvc/vs2012/libczmqjni/libczmqjni.props0000664000372000037200000001054713222211156025245 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>CZMQ Common Settings AllRules.ruleset false <_PropertySheetDisplayName>Output Settings ..\..\bin\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ ..\..\obj\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ $(OutDir) $(TargetName) $(TargetDir)$(TargetName)$(TargetExt) copy ..\..\platform.h ..\..\..\..\..\include\ ..\call_javah.bat ..\..\..\..\..\include;%(AdditionalIncludeDirectories) $(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;%(AdditionalIncludeDirectories) ..\..\..\..\..\..\libzmq\include;%(AdditionalIncludeDirectories) CompileAsC %(DisableSpecificWarnings) false _CRT_SECURE_NO_WARNINGS;BASE_THREADSAFE;%(PreprocessorDefinitions) CZMQJNI_STATIC;%(PreprocessorDefinitions) CZMQJNI_EXPORTS;%(PreprocessorDefinitions) Rpcrt4.lib;Ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies) libczmq.lib;%(AdditionalDependencies) ..\..\..\..\..\..\czmq\bin\$(PlatformName)\Debug\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) ..\..\..\..\..\..\czmq\bin\$(PlatformName)\Release\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) libzmq.lib;%(AdditionalDependencies) ..\..\..\..\..\..\libzmq\bin\$(PlatformName)\Debug\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) ..\..\..\..\..\..\libzmq\bin\$(PlatformName)\Release\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) czmq-4.1.0/bindings/jni/msvc/vs2012/build.bat0000664000372000037200000000342613222211156021441 0ustar00travistravis00000000000000@if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @:: THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY :: @:: Read the zproject/README.md for information about making permanent changes. :: @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: SET solution=czmq.sln SET version=11 SET log=build.log SET tools=Microsoft Visual Studio %version%.0\VC\vcvarsall.bat SET environment="%programfiles(x86)%\%tools%" IF NOT EXIST %environment% SET environment="%programfiles%\%tools%" IF NOT EXIST %environment% GOTO no_tools ECHO Building %solution%... CALL %environment% x86 > nul @if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script ECHO Platform=x86 ECHO Configuration=DynDebug msbuild /m /v:n /p:Configuration=DynDebug /p:Platform=Win32 %solution% > %log% IF errorlevel 1 GOTO error ECHO Configuration=DynRelease msbuild /m /v:n /p:Configuration=DynRelease /p:Platform=Win32 %solution% >> %log% IF errorlevel 1 GOTO error CALL %environment% x86_amd64 > nul @if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script ECHO Platform=x64 ECHO Configuration=DynDebug msbuild /m /v:n /p:Configuration=DynDebug /p:Platform=x64 %solution% > %log% IF errorlevel 1 GOTO error ECHO Configuration=DynRelease msbuild /m /v:n /p:Configuration=DynRelease /p:Platform=x64 %solution% >> %log% IF errorlevel 1 GOTO error ECHO Complete: %solution% GOTO end :error ECHO *** ERROR, build terminated early: see %log% GOTO end :no_tools ECHO *** ERROR, build tools not found: %tools% :end czmq-4.1.0/bindings/jni/msvc/vs2012/call_javah.bat0000664000372000037200000001351313222211156022424 0ustar00travistravis00000000000000@if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @:: THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY :: @:: Read the zproject/README.md for information about making permanent changes. :: @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ECHO Generating native JNI headers... IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zarmour.h GOTO HAVE_Zarmour "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zarmour :HAVE_Zarmour IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zcert.h GOTO HAVE_Zcert "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zcert :HAVE_Zcert IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zcertstore.h GOTO HAVE_Zcertstore "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zcertstore :HAVE_Zcertstore IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zchunk.h GOTO HAVE_Zchunk "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zchunk :HAVE_Zchunk IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zclock.h GOTO HAVE_Zclock "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zclock :HAVE_Zclock IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zconfig.h GOTO HAVE_Zconfig "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zconfig :HAVE_Zconfig IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zdigest.h GOTO HAVE_Zdigest "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zdigest :HAVE_Zdigest IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zdir.h GOTO HAVE_Zdir "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zdir :HAVE_Zdir IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_ZdirPatch.h GOTO HAVE_ZdirPatch "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.ZdirPatch :HAVE_ZdirPatch IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zfile.h GOTO HAVE_Zfile "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zfile :HAVE_Zfile IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zframe.h GOTO HAVE_Zframe "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zframe :HAVE_Zframe IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zhash.h GOTO HAVE_Zhash "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zhash :HAVE_Zhash IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zhashx.h GOTO HAVE_Zhashx "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zhashx :HAVE_Zhashx IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Ziflist.h GOTO HAVE_Ziflist "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Ziflist :HAVE_Ziflist IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zlist.h GOTO HAVE_Zlist "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zlist :HAVE_Zlist IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zlistx.h GOTO HAVE_Zlistx "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zlistx :HAVE_Zlistx IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zloop.h GOTO HAVE_Zloop "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zloop :HAVE_Zloop IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zmsg.h GOTO HAVE_Zmsg "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zmsg :HAVE_Zmsg IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zpoller.h GOTO HAVE_Zpoller "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zpoller :HAVE_Zpoller IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zproc.h GOTO HAVE_Zproc "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zproc :HAVE_Zproc IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zsock.h GOTO HAVE_Zsock "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zsock :HAVE_Zsock IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zstr.h GOTO HAVE_Zstr "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zstr :HAVE_Zstr IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zsys.h GOTO HAVE_Zsys "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zsys :HAVE_Zsys IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Ztimerset.h GOTO HAVE_Ztimerset "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Ztimerset :HAVE_Ztimerset IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Ztrie.h GOTO HAVE_Ztrie "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Ztrie :HAVE_Ztrie IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zuuid.h GOTO HAVE_Zuuid "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zuuid :HAVE_Zuuid czmq-4.1.0/bindings/jni/msvc/vs2012/czmq.sln0000664000372000037200000000261413222211156021340 0ustar00travistravis00000000000000Microsoft Visual Studio Solution File, Format Version 11.00 # bindings/jni/msvc/vs2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libczmqjni", "libczmqjni\libczmqjni.vcxproj", "{0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution DynDebug|Win32 = DynDebug|Win32 DynDebug|x64 = DynDebug|x64 DynRelease|Win32 = DynRelease|Win32 DynRelease|x64 = DynRelease|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|Win32.ActiveCfg = DebugDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|Win32.Build.0 = DebugDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|x64.ActiveCfg = DebugDLL|x64 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|x64.Build.0 = DebugDLL|x64 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|Win32.ActiveCfg = ReleaseDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|Win32.Build.0 = ReleaseDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|x64.ActiveCfg = ReleaseDLL|x64 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|x64.Build.0 = ReleaseDLL|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal czmq-4.1.0/bindings/jni/msvc/vs2013/0000775000372000037200000000000013222211156017646 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/msvc/vs2013/libczmqjni/0000775000372000037200000000000013222211156022010 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/msvc/vs2013/libczmqjni/libczmqjni.vcxproj.filters0000664000372000037200000002047713222211156027250 0ustar00travistravis00000000000000 src src src src src src src src src src src src src src src src src src src src src src src src src src include include include include include include include include include include include include include include include include include include include include include include include include include include include src\include resource resource {48f852d3-9723-4499-bf1a-35c0234b8ba9} {95e5d24a-57a2-429a-a1f1-304165f2e3da} {d0c837b5-cb58-4b82-b9bf-38727c7b25bd} {48e93f8c-156c-4379-a901-4b5ad39a4eac} {04a473ca-1d88-4e12-9190-8d9cc20efd74} czmq-4.1.0/bindings/jni/msvc/vs2013/libczmqjni/libczmqjni.vcxproj0000664000372000037200000002012613222211156025570 0ustar00travistravis00000000000000 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7} libczmqjni v120 DebugDLL Win32 ReleaseDLL Win32 DebugDLL x64 ReleaseDLL x64 StaticLibrary DynamicLibrary CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC czmq-4.1.0/bindings/jni/msvc/vs2013/libczmqjni/libczmqjni.props0000664000372000037200000001054713222211156025246 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>CZMQ Common Settings AllRules.ruleset false <_PropertySheetDisplayName>Output Settings ..\..\bin\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ ..\..\obj\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ $(OutDir) $(TargetName) $(TargetDir)$(TargetName)$(TargetExt) copy ..\..\platform.h ..\..\..\..\..\include\ ..\call_javah.bat ..\..\..\..\..\include;%(AdditionalIncludeDirectories) $(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;%(AdditionalIncludeDirectories) ..\..\..\..\..\..\libzmq\include;%(AdditionalIncludeDirectories) CompileAsC %(DisableSpecificWarnings) false _CRT_SECURE_NO_WARNINGS;BASE_THREADSAFE;%(PreprocessorDefinitions) CZMQJNI_STATIC;%(PreprocessorDefinitions) CZMQJNI_EXPORTS;%(PreprocessorDefinitions) Rpcrt4.lib;Ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies) libczmq.lib;%(AdditionalDependencies) ..\..\..\..\..\..\czmq\bin\$(PlatformName)\Debug\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) ..\..\..\..\..\..\czmq\bin\$(PlatformName)\Release\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) libzmq.lib;%(AdditionalDependencies) ..\..\..\..\..\..\libzmq\bin\$(PlatformName)\Debug\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) ..\..\..\..\..\..\libzmq\bin\$(PlatformName)\Release\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) czmq-4.1.0/bindings/jni/msvc/vs2013/build.bat0000664000372000037200000000342613222211156021442 0ustar00travistravis00000000000000@if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @:: THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY :: @:: Read the zproject/README.md for information about making permanent changes. :: @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: SET solution=czmq.sln SET version=12 SET log=build.log SET tools=Microsoft Visual Studio %version%.0\VC\vcvarsall.bat SET environment="%programfiles(x86)%\%tools%" IF NOT EXIST %environment% SET environment="%programfiles%\%tools%" IF NOT EXIST %environment% GOTO no_tools ECHO Building %solution%... CALL %environment% x86 > nul @if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script ECHO Platform=x86 ECHO Configuration=DynDebug msbuild /m /v:n /p:Configuration=DynDebug /p:Platform=Win32 %solution% > %log% IF errorlevel 1 GOTO error ECHO Configuration=DynRelease msbuild /m /v:n /p:Configuration=DynRelease /p:Platform=Win32 %solution% >> %log% IF errorlevel 1 GOTO error CALL %environment% x86_amd64 > nul @if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script ECHO Platform=x64 ECHO Configuration=DynDebug msbuild /m /v:n /p:Configuration=DynDebug /p:Platform=x64 %solution% > %log% IF errorlevel 1 GOTO error ECHO Configuration=DynRelease msbuild /m /v:n /p:Configuration=DynRelease /p:Platform=x64 %solution% >> %log% IF errorlevel 1 GOTO error ECHO Complete: %solution% GOTO end :error ECHO *** ERROR, build terminated early: see %log% GOTO end :no_tools ECHO *** ERROR, build tools not found: %tools% :end czmq-4.1.0/bindings/jni/msvc/vs2013/call_javah.bat0000664000372000037200000001351313222211156022425 0ustar00travistravis00000000000000@if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @:: THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY :: @:: Read the zproject/README.md for information about making permanent changes. :: @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ECHO Generating native JNI headers... IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zarmour.h GOTO HAVE_Zarmour "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zarmour :HAVE_Zarmour IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zcert.h GOTO HAVE_Zcert "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zcert :HAVE_Zcert IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zcertstore.h GOTO HAVE_Zcertstore "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zcertstore :HAVE_Zcertstore IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zchunk.h GOTO HAVE_Zchunk "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zchunk :HAVE_Zchunk IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zclock.h GOTO HAVE_Zclock "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zclock :HAVE_Zclock IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zconfig.h GOTO HAVE_Zconfig "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zconfig :HAVE_Zconfig IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zdigest.h GOTO HAVE_Zdigest "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zdigest :HAVE_Zdigest IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zdir.h GOTO HAVE_Zdir "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zdir :HAVE_Zdir IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_ZdirPatch.h GOTO HAVE_ZdirPatch "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.ZdirPatch :HAVE_ZdirPatch IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zfile.h GOTO HAVE_Zfile "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zfile :HAVE_Zfile IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zframe.h GOTO HAVE_Zframe "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zframe :HAVE_Zframe IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zhash.h GOTO HAVE_Zhash "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zhash :HAVE_Zhash IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zhashx.h GOTO HAVE_Zhashx "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zhashx :HAVE_Zhashx IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Ziflist.h GOTO HAVE_Ziflist "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Ziflist :HAVE_Ziflist IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zlist.h GOTO HAVE_Zlist "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zlist :HAVE_Zlist IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zlistx.h GOTO HAVE_Zlistx "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zlistx :HAVE_Zlistx IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zloop.h GOTO HAVE_Zloop "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zloop :HAVE_Zloop IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zmsg.h GOTO HAVE_Zmsg "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zmsg :HAVE_Zmsg IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zpoller.h GOTO HAVE_Zpoller "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zpoller :HAVE_Zpoller IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zproc.h GOTO HAVE_Zproc "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zproc :HAVE_Zproc IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zsock.h GOTO HAVE_Zsock "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zsock :HAVE_Zsock IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zstr.h GOTO HAVE_Zstr "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zstr :HAVE_Zstr IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zsys.h GOTO HAVE_Zsys "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zsys :HAVE_Zsys IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Ztimerset.h GOTO HAVE_Ztimerset "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Ztimerset :HAVE_Ztimerset IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Ztrie.h GOTO HAVE_Ztrie "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Ztrie :HAVE_Ztrie IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zuuid.h GOTO HAVE_Zuuid "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zuuid :HAVE_Zuuid czmq-4.1.0/bindings/jni/msvc/vs2013/czmq.sln0000664000372000037200000000261413222211156021341 0ustar00travistravis00000000000000Microsoft Visual Studio Solution File, Format Version 12.00 # bindings/jni/msvc/vs2013 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libczmqjni", "libczmqjni\libczmqjni.vcxproj", "{0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution DynDebug|Win32 = DynDebug|Win32 DynDebug|x64 = DynDebug|x64 DynRelease|Win32 = DynRelease|Win32 DynRelease|x64 = DynRelease|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|Win32.ActiveCfg = DebugDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|Win32.Build.0 = DebugDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|x64.ActiveCfg = DebugDLL|x64 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|x64.Build.0 = DebugDLL|x64 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|Win32.ActiveCfg = ReleaseDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|Win32.Build.0 = ReleaseDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|x64.ActiveCfg = ReleaseDLL|x64 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|x64.Build.0 = ReleaseDLL|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal czmq-4.1.0/bindings/jni/msvc/vs2010/0000775000372000037200000000000013222211156017643 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/msvc/vs2010/libczmqjni/0000775000372000037200000000000013222211156022005 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/msvc/vs2010/libczmqjni/libczmqjni.vcxproj.filters0000664000372000037200000002047713222211156027245 0ustar00travistravis00000000000000 src src src src src src src src src src src src src src src src src src src src src src src src src src include include include include include include include include include include include include include include include include include include include include include include include include include include include src\include resource resource {48f852d3-9723-4499-bf1a-35c0234b8ba9} {95e5d24a-57a2-429a-a1f1-304165f2e3da} {d0c837b5-cb58-4b82-b9bf-38727c7b25bd} {48e93f8c-156c-4379-a901-4b5ad39a4eac} {04a473ca-1d88-4e12-9190-8d9cc20efd74} czmq-4.1.0/bindings/jni/msvc/vs2010/libczmqjni/libczmqjni.vcxproj0000664000372000037200000002012613222211156025565 0ustar00travistravis00000000000000 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7} libczmqjni v100 DebugDLL Win32 ReleaseDLL Win32 DebugDLL x64 ReleaseDLL x64 StaticLibrary DynamicLibrary CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC czmq-4.1.0/bindings/jni/msvc/vs2010/libczmqjni/libczmqjni.props0000664000372000037200000001054713222211156025243 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>CZMQ Common Settings AllRules.ruleset false <_PropertySheetDisplayName>Output Settings ..\..\bin\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ ..\..\obj\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ $(OutDir) $(TargetName) $(TargetDir)$(TargetName)$(TargetExt) copy ..\..\platform.h ..\..\..\..\..\include\ ..\call_javah.bat ..\..\..\..\..\include;%(AdditionalIncludeDirectories) $(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;%(AdditionalIncludeDirectories) ..\..\..\..\..\..\libzmq\include;%(AdditionalIncludeDirectories) CompileAsC %(DisableSpecificWarnings) false _CRT_SECURE_NO_WARNINGS;BASE_THREADSAFE;%(PreprocessorDefinitions) CZMQJNI_STATIC;%(PreprocessorDefinitions) CZMQJNI_EXPORTS;%(PreprocessorDefinitions) Rpcrt4.lib;Ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies) libczmq.lib;%(AdditionalDependencies) ..\..\..\..\..\..\czmq\bin\$(PlatformName)\Debug\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) ..\..\..\..\..\..\czmq\bin\$(PlatformName)\Release\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) libzmq.lib;%(AdditionalDependencies) ..\..\..\..\..\..\libzmq\bin\$(PlatformName)\Debug\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) ..\..\..\..\..\..\libzmq\bin\$(PlatformName)\Release\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) czmq-4.1.0/bindings/jni/msvc/vs2010/build.bat0000664000372000037200000000342613222211156021437 0ustar00travistravis00000000000000@if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @:: THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY :: @:: Read the zproject/README.md for information about making permanent changes. :: @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: SET solution=czmq.sln SET version=10 SET log=build.log SET tools=Microsoft Visual Studio %version%.0\VC\vcvarsall.bat SET environment="%programfiles(x86)%\%tools%" IF NOT EXIST %environment% SET environment="%programfiles%\%tools%" IF NOT EXIST %environment% GOTO no_tools ECHO Building %solution%... CALL %environment% x86 > nul @if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script ECHO Platform=x86 ECHO Configuration=DynDebug msbuild /m /v:n /p:Configuration=DynDebug /p:Platform=Win32 %solution% > %log% IF errorlevel 1 GOTO error ECHO Configuration=DynRelease msbuild /m /v:n /p:Configuration=DynRelease /p:Platform=Win32 %solution% >> %log% IF errorlevel 1 GOTO error CALL %environment% x86_amd64 > nul @if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script ECHO Platform=x64 ECHO Configuration=DynDebug msbuild /m /v:n /p:Configuration=DynDebug /p:Platform=x64 %solution% > %log% IF errorlevel 1 GOTO error ECHO Configuration=DynRelease msbuild /m /v:n /p:Configuration=DynRelease /p:Platform=x64 %solution% >> %log% IF errorlevel 1 GOTO error ECHO Complete: %solution% GOTO end :error ECHO *** ERROR, build terminated early: see %log% GOTO end :no_tools ECHO *** ERROR, build tools not found: %tools% :end czmq-4.1.0/bindings/jni/msvc/vs2010/call_javah.bat0000664000372000037200000001351313222211156022422 0ustar00travistravis00000000000000@if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @:: THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY :: @:: Read the zproject/README.md for information about making permanent changes. :: @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ECHO Generating native JNI headers... IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zarmour.h GOTO HAVE_Zarmour "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zarmour :HAVE_Zarmour IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zcert.h GOTO HAVE_Zcert "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zcert :HAVE_Zcert IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zcertstore.h GOTO HAVE_Zcertstore "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zcertstore :HAVE_Zcertstore IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zchunk.h GOTO HAVE_Zchunk "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zchunk :HAVE_Zchunk IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zclock.h GOTO HAVE_Zclock "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zclock :HAVE_Zclock IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zconfig.h GOTO HAVE_Zconfig "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zconfig :HAVE_Zconfig IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zdigest.h GOTO HAVE_Zdigest "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zdigest :HAVE_Zdigest IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zdir.h GOTO HAVE_Zdir "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zdir :HAVE_Zdir IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_ZdirPatch.h GOTO HAVE_ZdirPatch "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.ZdirPatch :HAVE_ZdirPatch IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zfile.h GOTO HAVE_Zfile "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zfile :HAVE_Zfile IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zframe.h GOTO HAVE_Zframe "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zframe :HAVE_Zframe IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zhash.h GOTO HAVE_Zhash "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zhash :HAVE_Zhash IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zhashx.h GOTO HAVE_Zhashx "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zhashx :HAVE_Zhashx IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Ziflist.h GOTO HAVE_Ziflist "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Ziflist :HAVE_Ziflist IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zlist.h GOTO HAVE_Zlist "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zlist :HAVE_Zlist IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zlistx.h GOTO HAVE_Zlistx "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zlistx :HAVE_Zlistx IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zloop.h GOTO HAVE_Zloop "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zloop :HAVE_Zloop IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zmsg.h GOTO HAVE_Zmsg "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zmsg :HAVE_Zmsg IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zpoller.h GOTO HAVE_Zpoller "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zpoller :HAVE_Zpoller IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zproc.h GOTO HAVE_Zproc "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zproc :HAVE_Zproc IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zsock.h GOTO HAVE_Zsock "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zsock :HAVE_Zsock IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zstr.h GOTO HAVE_Zstr "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zstr :HAVE_Zstr IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zsys.h GOTO HAVE_Zsys "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zsys :HAVE_Zsys IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Ztimerset.h GOTO HAVE_Ztimerset "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Ztimerset :HAVE_Ztimerset IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Ztrie.h GOTO HAVE_Ztrie "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Ztrie :HAVE_Ztrie IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zuuid.h GOTO HAVE_Zuuid "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zuuid :HAVE_Zuuid czmq-4.1.0/bindings/jni/msvc/vs2010/czmq.sln0000664000372000037200000000261413222211156021336 0ustar00travistravis00000000000000Microsoft Visual Studio Solution File, Format Version 10.00 # bindings/jni/msvc/vs2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libczmqjni", "libczmqjni\libczmqjni.vcxproj", "{0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution DynDebug|Win32 = DynDebug|Win32 DynDebug|x64 = DynDebug|x64 DynRelease|Win32 = DynRelease|Win32 DynRelease|x64 = DynRelease|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|Win32.ActiveCfg = DebugDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|Win32.Build.0 = DebugDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|x64.ActiveCfg = DebugDLL|x64 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|x64.Build.0 = DebugDLL|x64 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|Win32.ActiveCfg = ReleaseDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|Win32.Build.0 = ReleaseDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|x64.ActiveCfg = ReleaseDLL|x64 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|x64.Build.0 = ReleaseDLL|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal czmq-4.1.0/bindings/jni/msvc/resource.h0000664000372000037200000000062113222211156020707 0ustar00travistravis00000000000000//{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by resource.rc // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 101 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif czmq-4.1.0/bindings/jni/msvc/.gitignore0000664000372000037200000000006613222211156020702 0ustar00travistravis00000000000000*.opensdf *.suo *.sdf *.user *.aps *.log *.tlog ipch/ czmq-4.1.0/bindings/jni/msvc/platform.h0000664000372000037200000000006113222211156020702 0ustar00travistravis00000000000000#error "Run configure.bat to create platform.h" czmq-4.1.0/bindings/jni/msvc/configure.bat0000664000372000037200000000636013222211156021366 0ustar00travistravis00000000000000@if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @:: THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY :: @:: Read the zproject/README.md for information about making permanent changes. :: @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @setlocal :- configure.bat creates platform.h and configures the build process :- You MUST run this before building via msbuild or VisualStudio. IF %1.==--help. ( ECHO Syntax: configure [ switch ] ECHO --help show this help ECHO --enable-drafts from zip package, enables DRAFT API ECHO --disable-drafts from git repository, disables DRAFT API ECHO --without-zmakecert do not build zmakecert.exe ECHO --without-zsp do not build zsp.exe ECHO --without-test_randof do not build test_randof.exe ECHO --without-czmq_selftest do not build czmq_selftest.exe GOTO :eof ) ECHO Configuring CZMQ... :- make sure our directory is builds\msvc no matter where user is when executing it from @pushd %~dp0% ECHO // Generated by configure.bat> platform.h ECHO. >> platform.h ECHO #ifndef __PLATFORM_H_INCLUDED__>> platform.h ECHO #define __PLATFORM_H_INCLUDED__>> platform.h ECHO. >> platform.h ECHO #define CZMQ_HAVE_WINDOWS 1>> platform.h :- Check for dependencies IF EXIST "..\..\..\libzmq" ( ECHO Building with libzmq ECHO #define HAVE_LIBZMQ 1>> platform.h ) ELSE ( ECHO Building without libzmq ECHO CZMQ cannot build without libzmq ECHO Please clone https://github.com/zeromq/libzmq.git, and then configure ^& build ECHO TODO: resolve this problem automatically. GOTO error ) IF EXIST "..\..\..\uuid" ( ECHO Building with uuid ECHO #define HAVE_UUID 1>> platform.h ) ELSE ( ECHO Building without uuid ECHO #undef HAVE_UUID>> platform.h ) IF EXIST "..\..\..\systemd" ( ECHO Building with systemd ECHO #define HAVE_SYSTEMD 1>> platform.h ) ELSE ( ECHO Building without systemd ECHO #undef HAVE_SYSTEMD>> platform.h ) IF EXIST "..\..\..\lz4" ( ECHO Building with lz4 ECHO #define HAVE_LZ4 1>> platform.h ) ELSE ( ECHO Building without lz4 ECHO #undef HAVE_LZ4>> platform.h ) :- Check if we want to build the draft API if "%1" == "--enable-drafts" goto :with_draft if "%1" == "--disable-drafts" goto :no_draft IF NOT EXIST "..\..\.git" GOTO no_draft :with_draft ECHO Building with draft API (stable + legacy + draft API) ECHO // Provide draft classes and methods>>platform.h ECHO #define CZMQ_BUILD_DRAFT_API 1>>platform.h GOTO end_draft :no_draft ECHO Building without draft API (stable + legacy API) ECHO #undef CZMQ_BUILD_DRAFT_API 1>>platform.h :end_draft ECHO. >> platform.h ECHO #endif>> platform.h goto :done :done popd @endlocal :: this is how you code a return in a windows batch script... "goto :eof" :: you see after a "call :label", %0 == ":label" inside :label, until "goto :eof" happens. @if "%0:~1,1" == ":" @goto :eof @exit /b 0 :error call :done @exit /b 1 czmq-4.1.0/bindings/jni/msvc/resource.rc0000664000372000037200000000435113222211156021070 0ustar00travistravis00000000000000// Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "winres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (United States) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE BEGIN "resource.h\0" END 2 TEXTINCLUDE BEGIN "#include ""winres.h""\r\n" "\0" END 3 TEXTINCLUDE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 4,1,0,0 PRODUCTVERSION 4,1,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x40004L FILETYPE 0x7L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "The AUTHORS" VALUE "FileDescription", "The high-level C binding for 0MQ" VALUE "FileVersion", "4.1.0.0" VALUE "InternalName", "CZMQ" VALUE "LegalCopyright", "Copyright (c) the Authors" VALUE "OriginalFilename", "libczmq.dll" VALUE "ProductName", "CZMQ" VALUE "ProductVersion", "4.1.0.0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED czmq-4.1.0/bindings/jni/msvc/vs2015/0000775000372000037200000000000013222211156017650 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/msvc/vs2015/libczmqjni/0000775000372000037200000000000013222211156022012 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/msvc/vs2015/libczmqjni/libczmqjni.vcxproj.filters0000664000372000037200000002047713222211156027252 0ustar00travistravis00000000000000 src src src src src src src src src src src src src src src src src src src src src src src src src src include include include include include include include include include include include include include include include include include include include include include include include include include include include src\include resource resource {48f852d3-9723-4499-bf1a-35c0234b8ba9} {95e5d24a-57a2-429a-a1f1-304165f2e3da} {d0c837b5-cb58-4b82-b9bf-38727c7b25bd} {48e93f8c-156c-4379-a901-4b5ad39a4eac} {04a473ca-1d88-4e12-9190-8d9cc20efd74} czmq-4.1.0/bindings/jni/msvc/vs2015/libczmqjni/libczmqjni.vcxproj0000664000372000037200000002012613222211156025572 0ustar00travistravis00000000000000 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7} libczmqjni v140 DebugDLL Win32 ReleaseDLL Win32 DebugDLL x64 ReleaseDLL x64 StaticLibrary DynamicLibrary CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC CompileAsC czmq-4.1.0/bindings/jni/msvc/vs2015/libczmqjni/libczmqjni.props0000664000372000037200000001054713222211156025250 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>CZMQ Common Settings AllRules.ruleset false <_PropertySheetDisplayName>Output Settings ..\..\bin\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ ..\..\obj\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ $(OutDir) $(TargetName) $(TargetDir)$(TargetName)$(TargetExt) copy ..\..\platform.h ..\..\..\..\..\include\ ..\call_javah.bat ..\..\..\..\..\include;%(AdditionalIncludeDirectories) $(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;%(AdditionalIncludeDirectories) ..\..\..\..\..\..\libzmq\include;%(AdditionalIncludeDirectories) CompileAsC %(DisableSpecificWarnings) false _CRT_SECURE_NO_WARNINGS;BASE_THREADSAFE;%(PreprocessorDefinitions) CZMQJNI_STATIC;%(PreprocessorDefinitions) CZMQJNI_EXPORTS;%(PreprocessorDefinitions) Rpcrt4.lib;Ws2_32.lib;Iphlpapi.lib;%(AdditionalDependencies) libczmq.lib;%(AdditionalDependencies) ..\..\..\..\..\..\czmq\bin\$(PlatformName)\Debug\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) ..\..\..\..\..\..\czmq\bin\$(PlatformName)\Release\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) libzmq.lib;%(AdditionalDependencies) ..\..\..\..\..\..\libzmq\bin\$(PlatformName)\Debug\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) ..\..\..\..\..\..\libzmq\bin\$(PlatformName)\Release\$(PlatformToolset)\dynamic\;%(AdditionalLibraryDirectories) czmq-4.1.0/bindings/jni/msvc/vs2015/build.bat0000664000372000037200000000342613222211156021444 0ustar00travistravis00000000000000@if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @:: THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY :: @:: Read the zproject/README.md for information about making permanent changes. :: @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: SET solution=czmq.sln SET version=14 SET log=build.log SET tools=Microsoft Visual Studio %version%.0\VC\vcvarsall.bat SET environment="%programfiles(x86)%\%tools%" IF NOT EXIST %environment% SET environment="%programfiles%\%tools%" IF NOT EXIST %environment% GOTO no_tools ECHO Building %solution%... CALL %environment% x86 > nul @if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script ECHO Platform=x86 ECHO Configuration=DynDebug msbuild /m /v:n /p:Configuration=DynDebug /p:Platform=Win32 %solution% > %log% IF errorlevel 1 GOTO error ECHO Configuration=DynRelease msbuild /m /v:n /p:Configuration=DynRelease /p:Platform=Win32 %solution% >> %log% IF errorlevel 1 GOTO error CALL %environment% x86_amd64 > nul @if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script ECHO Platform=x64 ECHO Configuration=DynDebug msbuild /m /v:n /p:Configuration=DynDebug /p:Platform=x64 %solution% > %log% IF errorlevel 1 GOTO error ECHO Configuration=DynRelease msbuild /m /v:n /p:Configuration=DynRelease /p:Platform=x64 %solution% >> %log% IF errorlevel 1 GOTO error ECHO Complete: %solution% GOTO end :error ECHO *** ERROR, build terminated early: see %log% GOTO end :no_tools ECHO *** ERROR, build tools not found: %tools% :end czmq-4.1.0/bindings/jni/msvc/vs2015/call_javah.bat0000664000372000037200000001351313222211156022427 0ustar00travistravis00000000000000@if "%ECHOON%" == "" (@echo off) else (@echo %ECHOON%)&:: set ECHOON=on if you want to debug this script @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @:: THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY :: @:: Read the zproject/README.md for information about making permanent changes. :: @:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ECHO Generating native JNI headers... IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zarmour.h GOTO HAVE_Zarmour "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zarmour :HAVE_Zarmour IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zcert.h GOTO HAVE_Zcert "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zcert :HAVE_Zcert IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zcertstore.h GOTO HAVE_Zcertstore "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zcertstore :HAVE_Zcertstore IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zchunk.h GOTO HAVE_Zchunk "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zchunk :HAVE_Zchunk IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zclock.h GOTO HAVE_Zclock "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zclock :HAVE_Zclock IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zconfig.h GOTO HAVE_Zconfig "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zconfig :HAVE_Zconfig IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zdigest.h GOTO HAVE_Zdigest "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zdigest :HAVE_Zdigest IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zdir.h GOTO HAVE_Zdir "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zdir :HAVE_Zdir IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_ZdirPatch.h GOTO HAVE_ZdirPatch "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.ZdirPatch :HAVE_ZdirPatch IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zfile.h GOTO HAVE_Zfile "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zfile :HAVE_Zfile IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zframe.h GOTO HAVE_Zframe "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zframe :HAVE_Zframe IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zhash.h GOTO HAVE_Zhash "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zhash :HAVE_Zhash IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zhashx.h GOTO HAVE_Zhashx "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zhashx :HAVE_Zhashx IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Ziflist.h GOTO HAVE_Ziflist "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Ziflist :HAVE_Ziflist IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zlist.h GOTO HAVE_Zlist "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zlist :HAVE_Zlist IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zlistx.h GOTO HAVE_Zlistx "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zlistx :HAVE_Zlistx IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zloop.h GOTO HAVE_Zloop "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zloop :HAVE_Zloop IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zmsg.h GOTO HAVE_Zmsg "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zmsg :HAVE_Zmsg IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zpoller.h GOTO HAVE_Zpoller "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zpoller :HAVE_Zpoller IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zproc.h GOTO HAVE_Zproc "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zproc :HAVE_Zproc IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zsock.h GOTO HAVE_Zsock "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zsock :HAVE_Zsock IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zstr.h GOTO HAVE_Zstr "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zstr :HAVE_Zstr IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zsys.h GOTO HAVE_Zsys "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zsys :HAVE_Zsys IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Ztimerset.h GOTO HAVE_Ztimerset "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Ztimerset :HAVE_Ztimerset IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Ztrie.h GOTO HAVE_Ztrie "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Ztrie :HAVE_Ztrie IF EXIST ..\..\..\src\native\include\org_zeromq_czmq_Zuuid.h GOTO HAVE_Zuuid "%JAVA_HOME%\bin\javah.exe" -d ..\..\..\src\native\include -classpath ..\..\..\src\main\java org.zeromq.czmq.Zuuid :HAVE_Zuuid czmq-4.1.0/bindings/jni/msvc/vs2015/czmq.sln0000664000372000037200000000261413222211156021343 0ustar00travistravis00000000000000Microsoft Visual Studio Solution File, Format Version 14.00 # bindings/jni/msvc/vs2015 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libczmqjni", "libczmqjni\libczmqjni.vcxproj", "{0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution DynDebug|Win32 = DynDebug|Win32 DynDebug|x64 = DynDebug|x64 DynRelease|Win32 = DynRelease|Win32 DynRelease|x64 = DynRelease|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|Win32.ActiveCfg = DebugDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|Win32.Build.0 = DebugDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|x64.ActiveCfg = DebugDLL|x64 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynDebug|x64.Build.0 = DebugDLL|x64 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|Win32.ActiveCfg = ReleaseDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|Win32.Build.0 = ReleaseDLL|Win32 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|x64.ActiveCfg = ReleaseDLL|x64 {0C4A2E28-8C9E-4B27-85D9-BB679AD84AC7}.DynRelease|x64.Build.0 = ReleaseDLL|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal czmq-4.1.0/bindings/jni/msvc/properties/0000775000372000037200000000000013222211156021104 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/msvc/properties/Win32.props0000664000372000037200000000116113222211156023072 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>x86 Settings WIN32;_WIN32;%(PreprocessorDefinitions) MachineX86 /MACHINE:X86 %(AdditionalOptions) czmq-4.1.0/bindings/jni/msvc/properties/LTCG.props0000664000372000037200000000064013222211156022722 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Link Time Code Generation Library czmq-4.1.0/bindings/jni/msvc/properties/DebugDLL.props0000664000372000037200000000113213222211156023550 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Dynamic Debug Library MultiThreadedDebugDLL true czmq-4.1.0/bindings/jni/msvc/properties/DebugLIB.props0000664000372000037200000000122713222211156023550 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Static Debug Library OldStyle MultiThreadedDebug true czmq-4.1.0/bindings/jni/msvc/properties/DebugLTCG.props0000664000372000037200000000120313222211156023665 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Static Debug Link Time Code Generation Library OldStyle MultiThreadedDebug czmq-4.1.0/bindings/jni/msvc/properties/Link.props0000664000372000037200000000123713222211156023071 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Link Time Code Generation Settings ltcg true UseLinkTimeCodeGeneration true czmq-4.1.0/bindings/jni/msvc/properties/ReleaseDEXE.props0000664000372000037200000000113013222211156024212 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Console Release Dynamic dynamic MultiThreadedDLL czmq-4.1.0/bindings/jni/msvc/properties/Output.props0000664000372000037200000000247213222211156023476 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Output Settings $(ProjectDir)..\..\ $(ProjectDir)..\..\..\..\ $(ProjectDir)..\..\..\..\..\ $(ProjectDir)..\..\..\..\bin\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ $(ProjectDir)..\..\..\..\obj\$(TargetName)\$(PlatformName)\$(DebugOrRelease)\$(PlatformToolset)\$(DefaultLinkage)\ $(OutDir) $(TargetName) $(TargetDir)$(TargetName)$(TargetExt) $(OutDir)$(TargetName).lib $(OutDir)$(TargetName).log czmq-4.1.0/bindings/jni/msvc/properties/Messages.props0000664000372000037200000000122013222211156023733 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Build Messages czmq-4.1.0/bindings/jni/msvc/properties/Common.props0000664000372000037200000000130713222211156023422 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Common Settings Unicode true UNICODE;_UNICODE;%(PreprocessorDefinitions) Level3 czmq-4.1.0/bindings/jni/msvc/properties/DLL.props0000664000372000037200000000102213222211156022577 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Dynamic Library dynamic .dll _DLL;_WINDLL;%(PreprocessorDefinitions) czmq-4.1.0/bindings/jni/msvc/properties/Release.props0000664000372000037200000000311513222211156023551 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Release Settings Release false /Oy- %(AdditionalOptions) ProgramDatabase true true OnlyExplicitInline false MaxSpeed NDEBUG;%(PreprocessorDefinitions) NDEBUG;%(PreprocessorDefinitions) true true true StreamingSIMDExtensions2 czmq-4.1.0/bindings/jni/msvc/properties/ReleaseLEXE.props0000664000372000037200000000113613222211156024230 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Console Release Link Time Code Generation MultiThreaded czmq-4.1.0/bindings/jni/msvc/properties/DebugLEXE.props0000664000372000037200000000113713222211156023677 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Console Debug Link Time Code Generation MultiThreadedDebug czmq-4.1.0/bindings/jni/msvc/properties/ReleaseDLL.props0000664000372000037200000000105213222211156024103 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Dynamic Release Library MultiThreadedDLL czmq-4.1.0/bindings/jni/msvc/properties/x64.props0000664000372000037200000000163513222211156022617 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>x64 Settings WIN32;_WIN32;WIN64;_WIN64;%(PreprocessorDefinitions) MachineX64 /MACHINE:X64 %(AdditionalOptions) czmq-4.1.0/bindings/jni/msvc/properties/Debug.props0000664000372000037200000000203713222211156023221 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Debug Settings Debug EnableFastChecks ProgramDatabase true Disabled _DEBUG;%(PreprocessorDefinitions) _DEBUG;%(PreprocessorDefinitions) true czmq-4.1.0/bindings/jni/msvc/properties/ReleaseSEXE.props0000664000372000037200000000112313222211156024233 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Console Release Static static MultiThreaded czmq-4.1.0/bindings/jni/msvc/properties/ReleaseLTCG.props0000664000372000037200000000110113222211156024214 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Static Release Link Time Code Generation Library MultiThreaded czmq-4.1.0/bindings/jni/msvc/properties/LIB.props0000664000372000037200000000101013222211156022567 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Static Library static .lib _LIB;%(PreprocessorDefinitions) czmq-4.1.0/bindings/jni/msvc/properties/DebugSEXE.props0000664000372000037200000000120313222211156023700 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Console Debug Static static MultiThreadedDebug true czmq-4.1.0/bindings/jni/msvc/properties/DebugDEXE.props0000664000372000037200000000121013222211156023657 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Console Debug Dynamic dynamic MultiThreadedDebugDLL true czmq-4.1.0/bindings/jni/msvc/properties/EXE.props0000664000372000037200000000103113222211156022605 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Console Application true _CONSOLE;%(PreprocessorDefinitions) Console czmq-4.1.0/bindings/jni/msvc/properties/ReleaseLIB.props0000664000372000037200000000104613222211156024101 0ustar00travistravis00000000000000 <_PropertySheetDisplayName>Static Release Library MultiThreaded czmq-4.1.0/bindings/jni/gradlew0000775000372000037200000001166613222211156017325 0ustar00travistravis00000000000000#!/usr/bin/env bash ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn ( ) { echo "$*" } die ( ) { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules function splitJvmOpts() { JVM_OPTS=("$@") } eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" czmq-4.1.0/bindings/jni/.gitignore0000664000372000037200000000015213222211156017726 0ustar00travistravis00000000000000CMakeCache.txt CMakeFiles/ cmake_install.cmake .gradle build/ src/native gradle-app.setting libczmqjni.so czmq-4.1.0/bindings/jni/android/0000775000372000037200000000000013222211156017360 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/android/build.sh0000775000372000037200000000444713222211156021027 0ustar00travistravis00000000000000#!/bin/bash ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ # Build JNI interface for Android # Targets Android API level 8, ARM architecture (see below) # # Requires these environment variables be set, e.g.: # # ANDROID_NDK_ROOT=$HOME/android-ndk-r11c # TOOLCHAIN_NAME=arm-linux-androideabi-4.9 # TOOLCHAIN_VERSION=4.9 # TOOLCHAIN_HOST=arm-linux-androideabi # TOOLCHAIN_ARCH=arm # TOOLCHAIN_PATH=$ANDROID_NDK_ROOT/toolchains/$TOOLCHAIN_NAME/prebuilt/linux-x86_64/bin # # Exit if any step fails set -e set -x export ANDROID_API_LEVEL=android-8 export ANDROID_SYS_ROOT=$ANDROID_NDK_ROOT/platforms/$ANDROID_API_LEVEL/arch-$TOOLCHAIN_ARCH if [ "$1" = "-d" ]; then MAKE_OPTIONS=VERBOSE=1 fi source ../../../builds/android/android_build_helper.sh android_build_env # Build any dependent libraries # Ensure we've built dependencies for Android echo "******** Building CZMQ Android native libraries" ( cd ../../../builds/android && ./build.sh ) # Ensure we've built JNI interface echo "******** Building CZMQ JNI interface & classes" ( cd .. && ./gradlew build jar ) echo "******** Building CZMQ JNI for Android" rm -rf build && mkdir build && cd build export ANDROID_BUILD_PREFIX=$ANDROID_BUILD_PREFIX cmake -v -DCMAKE_TOOLCHAIN_FILE=../android_toolchain.cmake .. # CMake wrongly searches current directory and then toolchain path instead # of lib path for these files, so make them available temporarily ln -s $ANDROID_SYS_ROOT/usr/lib/crtend_so.o ln -s $ANDROID_SYS_ROOT/usr/lib/crtbegin_so.o make $MAKE_OPTIONS echo "******** Building czmq.jar for Android" # Copy class files into org/zeromq/etc. unzip -q ../../build/libs/czmq-jni-4.1.0.jar # Copy native libraries into lib/armeabi mkdir -p lib/armeabi mv libczmqjni.so lib/armeabi cp ../../../../builds/android/prefix/*/lib/*.so lib/armeabi cp $ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$TOOLCHAIN_VERSION/libs/armeabi/libgnustl_shared.so lib/armeabi zip -r -m ../czmq-android.jar lib/ org/ META-INF/ cd .. rm -rf build echo "******** Complete" czmq-4.1.0/bindings/jni/android/CMakeLists.txt0000664000372000037200000000617413222211156022130 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ cmake_minimum_required (VERSION 2.8) project (czmqjni CXX) enable_language (C) # Search for Find*.cmake files in the following locations list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/..") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../..") ######################################################################## # JNI dependency ######################################################################## find_package (JNI REQUIRED) include_directories (${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2} ../src/native/include) ######################################################################## # LIBZMQ dependency ######################################################################## find_package(libzmq REQUIRED) IF (LIBZMQ_FOUND) include_directories(${LIBZMQ_INCLUDE_DIRS}) list(APPEND MORE_LIBRARIES ${LIBZMQ_LIBRARIES}) ELSE (LIBZMQ_FOUND) message( FATAL_ERROR "libzmq not found." ) ENDIF (LIBZMQ_FOUND) ######################################################################## # CZMQ dependency ######################################################################## find_package(czmq REQUIRED) IF (CZMQ_FOUND) include_directories(${CZMQ_INCLUDE_DIRS}) list(APPEND MORE_LIBRARIES ${CZMQ_LIBRARIES}) ELSE (CZMQ_FOUND) message( FATAL_ERROR "czmq not found." ) ENDIF (CZMQ_FOUND) set (czmqjni_sources ../src/main/c/org_zeromq_czmq_Zarmour.c ../src/main/c/org_zeromq_czmq_Zcert.c ../src/main/c/org_zeromq_czmq_Zcertstore.c ../src/main/c/org_zeromq_czmq_Zchunk.c ../src/main/c/org_zeromq_czmq_Zclock.c ../src/main/c/org_zeromq_czmq_Zconfig.c ../src/main/c/org_zeromq_czmq_Zdigest.c ../src/main/c/org_zeromq_czmq_Zdir.c ../src/main/c/org_zeromq_czmq_ZdirPatch.c ../src/main/c/org_zeromq_czmq_Zfile.c ../src/main/c/org_zeromq_czmq_Zframe.c ../src/main/c/org_zeromq_czmq_Zhash.c ../src/main/c/org_zeromq_czmq_Zhashx.c ../src/main/c/org_zeromq_czmq_Ziflist.c ../src/main/c/org_zeromq_czmq_Zlist.c ../src/main/c/org_zeromq_czmq_Zlistx.c ../src/main/c/org_zeromq_czmq_Zloop.c ../src/main/c/org_zeromq_czmq_Zmsg.c ../src/main/c/org_zeromq_czmq_Zpoller.c ../src/main/c/org_zeromq_czmq_Zproc.c ../src/main/c/org_zeromq_czmq_Zsock.c ../src/main/c/org_zeromq_czmq_Zstr.c ../src/main/c/org_zeromq_czmq_Zsys.c ../src/main/c/org_zeromq_czmq_Ztimerset.c ../src/main/c/org_zeromq_czmq_Ztrie.c ../src/main/c/org_zeromq_czmq_Zuuid.c ) add_library (czmqjni SHARED ${czmqjni_sources}) add_definitions (-DCZMQ_BUILD_DRAFT_API) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -O2") set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build) set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build) set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build) target_link_libraries (czmqjni ${MORE_LIBRARIES}) czmq-4.1.0/bindings/jni/android/android_toolchain.cmake0000664000372000037200000000413013222211156024040 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ # CMake toolchain script # # Targets Android 8, ARM # Called from build.sh via cmake set (CMAKE_SYSTEM_NAME Linux) # Tell CMake we're cross-compiling set (ANDROID True) set (BUILD_ANDROID True) include (CMakeForceCompiler) include (FindPkgConfig) # Where is the target environment set (ANDROID_NDK_ROOT $ENV{ANDROID_NDK_ROOT}) set (ANDROID_SYS_ROOT $ENV{ANDROID_SYS_ROOT}) set (ANDROID_API_LEVEL $ENV{ANDROID_API_LEVEL}) set (TOOLCHAIN_PATH $ENV{TOOLCHAIN_PATH}) set (TOOLCHAIN_HOST $ENV{TOOLCHAIN_HOST}) set (TOOLCHAIN_ARCH $ENV{TOOLCHAIN_ARCH}) set (LIBRARIES_BUILD_PREFIX $ENV{ANDROID_BUILD_PREFIX}) # Here is the target environment located set (CMAKE_INSTALL_PREFIX "${LIBRARIES_BUILD_PREFIX}") set (CMAKE_FIND_ROOT_PATH "${TOOLCHAIN_PATH}" "${LIBRARIES_BUILD_PREFIX}" "${LIBRARIES_BUILD_PREFIX}/share") # pkg_config should not search for packages of the host system, # but for the target system. To do this, there is the environment variable # PKG_CONFIG_LIBDIR, which was added to pkg_config explicitely for crosscompiling. # So set this here to point inside the CMAKE_FIND_ROOT_PATH so it can find # only packages for the target system when crosscompiling. set(pkgconfigLibDir) foreach(currentFindRoot ${CMAKE_FIND_ROOT_PATH}) set(pkgconfigLibDir "${pkgconfigLibDir}:${currentFindRoot}/lib/pkgconfig") endforeach(currentFindRoot) set(ENV{PKG_CONFIG_LIBDIR} "${pkgconfigLibDir}") set(ENV{PKG_CONFIG_PATH} "") # Prefix detection only works with compiler id "GNU" # CMake will look for prefixed g++, cpp, ld, etc. automatically CMAKE_FORCE_C_COMPILER (${TOOLCHAIN_PATH}/arm-linux-androideabi-gcc GNU) cmake_policy (SET CMP0015 NEW) # Use relative paths in link_directories include_directories (${ANDROID_SYS_ROOT}/usr/include) link_directories (${ANDROID_SYS_ROOT}/usr/lib) czmq-4.1.0/bindings/jni/gradlew.bat0000664000372000037200000000454413222211156020064 0ustar00travistravis00000000000000@if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS= @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :init @rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. set CMD_LINE_ARGS= set _SKIP=2 :win9xME_args_slurp if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* goto execute :4NT_args @rem Get arguments from the 4NT Shell from JP Software set CMD_LINE_ARGS=%$ :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega czmq-4.1.0/bindings/jni/CMakeLists.txt0000664000372000037200000000604513222211156020505 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ cmake_minimum_required (VERSION 2.8) project (czmqjni CXX) enable_language (C) # Search for Find*.cmake files in the following locations list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../..") ######################################################################## # JNI dependency ######################################################################## find_package (JNI REQUIRED) include_directories (${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2} src/native/include) ######################################################################## # LIBZMQ dependency ######################################################################## find_package(libzmq REQUIRED) IF (LIBZMQ_FOUND) include_directories(${LIBZMQ_INCLUDE_DIRS}) list(APPEND MORE_LIBRARIES ${LIBZMQ_LIBRARIES}) ELSE (LIBZMQ_FOUND) message( FATAL_ERROR "libzmq not found." ) ENDIF (LIBZMQ_FOUND) ######################################################################## # CZMQ dependency ######################################################################## find_package(czmq REQUIRED) IF (CZMQ_FOUND) include_directories(${CZMQ_INCLUDE_DIRS}) list(APPEND MORE_LIBRARIES ${CZMQ_LIBRARIES}) ELSE (CZMQ_FOUND) message( FATAL_ERROR "czmq not found." ) ENDIF (CZMQ_FOUND) set (czmqjni_sources src/main/c/org_zeromq_czmq_Zarmour.c src/main/c/org_zeromq_czmq_Zcert.c src/main/c/org_zeromq_czmq_Zcertstore.c src/main/c/org_zeromq_czmq_Zchunk.c src/main/c/org_zeromq_czmq_Zclock.c src/main/c/org_zeromq_czmq_Zconfig.c src/main/c/org_zeromq_czmq_Zdigest.c src/main/c/org_zeromq_czmq_Zdir.c src/main/c/org_zeromq_czmq_ZdirPatch.c src/main/c/org_zeromq_czmq_Zfile.c src/main/c/org_zeromq_czmq_Zframe.c src/main/c/org_zeromq_czmq_Zhash.c src/main/c/org_zeromq_czmq_Zhashx.c src/main/c/org_zeromq_czmq_Ziflist.c src/main/c/org_zeromq_czmq_Zlist.c src/main/c/org_zeromq_czmq_Zlistx.c src/main/c/org_zeromq_czmq_Zloop.c src/main/c/org_zeromq_czmq_Zmsg.c src/main/c/org_zeromq_czmq_Zpoller.c src/main/c/org_zeromq_czmq_Zproc.c src/main/c/org_zeromq_czmq_Zsock.c src/main/c/org_zeromq_czmq_Zstr.c src/main/c/org_zeromq_czmq_Zsys.c src/main/c/org_zeromq_czmq_Ztimerset.c src/main/c/org_zeromq_czmq_Ztrie.c src/main/c/org_zeromq_czmq_Zuuid.c ) add_library (czmqjni SHARED ${czmqjni_sources}) add_definitions (-DCZMQ_BUILD_DRAFT_API) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -O2") set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build) set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build) set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build) target_link_libraries (czmqjni ${MORE_LIBRARIES}) czmq-4.1.0/bindings/jni/Findczmq.cmake0000664000372000037200000000316413222211156020521 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ if (NOT MSVC) include(FindPkgConfig) pkg_check_modules(PC_CZMQ "libczmq") if (NOT PC_CZMQ_FOUND) pkg_check_modules(PC_CZMQ "libczmq") endif (NOT PC_CZMQ_FOUND) if (PC_CZMQ_FOUND) # some libraries install the headers is a subdirectory of the include dir # returned by pkg-config, so use a wildcard match to improve chances of finding # headers and SOs. set(PC_CZMQ_INCLUDE_HINTS ${PC_CZMQ_INCLUDE_DIRS} ${PC_CZMQ_INCLUDE_DIRS}/*) set(PC_CZMQ_LIBRARY_HINTS ${PC_CZMQ_LIBRARY_DIRS} ${PC_CZMQ_LIBRARY_DIRS}/*) endif(PC_CZMQ_FOUND) endif (NOT MSVC) find_path ( CZMQ_INCLUDE_DIRS NAMES czmq.h HINTS ${PC_CZMQ_INCLUDE_HINTS} ) find_library ( CZMQ_LIBRARIES NAMES czmq HINTS ${PC_CZMQ_LIBRARY_HINTS} ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args( CZMQ REQUIRED_VARS CZMQ_LIBRARIES CZMQ_INCLUDE_DIRS ) mark_as_advanced( CZMQ_FOUND CZMQ_LIBRARIES CZMQ_INCLUDE_DIRS ) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/jni/gradle/0000775000372000037200000000000013222211156017176 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/gradle/wrapper/0000775000372000037200000000000013222211156020656 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/gradle/wrapper/gradle-wrapper.properties0000664000372000037200000000035013222211156025706 0ustar00travistravis00000000000000#Tue May 31 16:38:50 CEST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip czmq-4.1.0/bindings/jni/gradle/wrapper/gradle-wrapper.jar0000664000372000037200000015046413222211156024302 0ustar00travistravis00000000000000PK w1H META-INF/PK w1H8@UMETA-INF/MANIFEST.MFMLK-. K-*ϳR03-IM+I, dZ)%bµrrPK k1Horg/PK k1H org/gradle/PK k1Horg/gradle/wrapper/PK k1Hhdf#org/gradle/wrapper/Download$1.class}M 0h5Z+v/ ׆p!.H3SK;a(Id0®lWO*i)2Xsd1,:"! G5=R+ȃɹws??~XªQx)I)`^F\F ṂzQFRhMK K [A*_ɮoANϖvӟtp854˰ZsM0ݍ+e錞K{zahӱa{jr⿅ >4fڦ?(06 %L7k}8e*)v0 DqZ5*>F]m4xqNuj}g'-mZ0Zjw䜦[b!ڋ3)UD0A\>yIA$Rf MxfFӴ*e]ӫxwԯ x wuH𘗽P`{!!}%nx/ q}Jhͮ0,މ=q@{,Qzii“G7 !8CH3 `_[(`+8$U)<$4OZd4}/z@:CYׅ"D "Vv I (&%꿮)[|SW/9s ,n%BrUv/PK k1H] 3org/gradle/wrapper/ExclusiveFileAccessManager.classVKpem&im!@!PlP(ӂbhZ 6]ݍMK} >u蝣2#-XGGǃ://߷6?  Gw^D>tIq WiA9% NߏQ#583x6HSq0(3dD-*pWb~~֤':u$SzOut$%R1%+F.k[kP0vU 6E AJJΛ4lStAjfPM&$xf5)PVuU33ާX^{XXʴrdu56n)j/dbAS;4]mdBK1jOqڢnr-hkz,ceK(.<4̋y5cӘ![vnfF$Թ gPaL13 aД 5R96YK,Ap/]l \ak:rAC}ѫ .ZjMǗf}uUQebPMfA=YT[ {[K8Lb<sHi"3+/a2FXY22֯u{(2NS)G//T> 3h ڸ7B(^:Ga*{Pl6\;#4͠v )l y&ͳ`sua$&&s"\^&x3^9O&39qߝ}~9z(sL7R <7o :ǐG3ăVL=W_ߠ(~׉_hy?;Cr|1C_JV,9fx6'2!Ƽ!09'($)^RV-=wj$\7ud/j-'I%4۵ 2ۤG*1 <PK k1H ^F-org/gradle/wrapper/WrapperConfiguration.classmOAփ>"!3 U1U H|Cp#]5Si"1e[733\_(K`6 q?<7yBiƻR'A#CuZlyz"Ls}-D(؆ 4MYfLgEKeu 4k{ڠy0hvk].Yq-نn'id,;JFJmZ:ۡnѷm3IS8(kX# ӬcBZ뼆cږ 1Y"L0#daz'2swH-t9ZXQuE#nk%?>YnMCyE.LV×.91a({7'\mƀ 1#ajNfgs}☾zT<(Z2I b\Q TZF" CnQrėcl%ήSMfԆn \mNfo6=[]rU&IRS&dH# Y/F戠]3お/𥂯T|oOR-X@-mn+6Pyds 9vDx)+#tLbGbT$5\/۳^*x;@"kdPbYNֶ|xXfMًeǠ*$LTaS?zeZ*g?e̪$"OfBX:]w"5Yr%.G5\k p82z ϯ%ZBG>yH?e}GR-0A 0Q\,HCԭ57GxCC!5FFGrh׷u-zPDZ5}?ΡёxT~wg9t?z=~9]g=9V9z Gq9?1q4#E;Yxq䱕 _Yg9Q'-aش> aWI\b>t.awCtGzm2)p+G%qg\k,s0K0Q,Nwڵ|_F^{_PK k1Hy0Vorg/gradle/wrapper/Logger.classoPǿ*1pL EWo1&d  f&Ki Xs9* OHfp+ۨ&Q,D];Bܕp A`w 32 I^m{]⯧>wީ}N6Ǫc;8ƄԵ]u`r壣FQs5mP힩TT-]鹎a-PDս +TYb|Tuz|<[(N$&cbXC3RWu:+mf=mdϞ:?2RlDLBZB3{/AQHGB< 2og\+j/>M\> {JQV \ZWHcHXŠ\_)Gt } РF If:B~@R &~ 6H#J2b&J9򼉖ekY4|3}(4y0 TРJ =-u/g5ېur Bwek++ܥ~FLMvo 3zgF{(lMtwoIlquu 9&ilb\cEx{q֩|d/k%З˺h}(莫WrŒmkS? ;(PmVW ?suS^uu2(̆c΂9 s.nxSWXvq`w*CRPJ.d pQy<ŏT *5sxZSEnYO,Jע(żn ?gF*~! _k̻gMU1YN$K\E1pC_tCFGŸUU_xG.;`rkp Ⲃu;Y2]cYgU*擦&HܤaܤO>]aF(TdžKF Irfח7(In 3%I$K u`obM%Tw-5ִp-UhWf^A;]Tp!joCb1 Cݾ۫S(#-S:^p>if~y"c<{Fw12~C %FJ+yͥpD"s( 6]eL/-yk63u1Y;)-lé\}j_,iEfӚ~'lpv2:oFx *W p}nۺ?vV1r WpV8(z t ~J rC')q1μ}$i8ӳt,$0m6KOQηә2+{*{3D΅6b@|&2&qh q(c›v&vzROPdҭH-[!1PiaуUfWB 6.q\Kȱ [Fͅ=$Oq|}t]s,v玬s@14:,v-21)hbf1C,]gM>|C _kdqB]32Rռ$hbFhy'[ZpU<ћ!/b机A==HW=fd`TaF2fƓ jUڶaGy\Qy}ĿT8yN22IAүa=VBD=d+xﺔ%|4#j>K>GXy B:|P;XLJ|PK k1H8޶) org/gradle/wrapper/Install.classY |?',+kD"y7 I0 dw#ΒDZJվP[Vb-UQI(j}Vko*fv7d/f{|_^Gh!>Η'"_4iɧ2(el4\S";X 4g aMt ->Zk k67ouƦ՛75otCݦL͗ifsx,i1kIAk|xg`Ott&pĨIFJ80lM qҭ[]uɤmn 6ӌP$4wk̈Q :=۲ոQh<4cҏ59e[4ٌ-hؤcP<-z”t2L3]9o"H% 2̤t['avec+";TvʤQf{J7'"L1êټ Srv鋖.kME&GDACwn&)0KNjy@Ei0YLڲl3lnYT3C#T܂e2_aϋ"Bf9ӓF(0u&p`vIKVvAt0u$`>J*ИiXu#avjc<H-hF!8 F20zfLrV`ѨCXOzLn5cئl'[tYY6"ӄ0QIb О5B(?҄s\c)FJe}aKkeD8"s6dcP)Y8rc,5I\2GsOCtb(ݗK]sT`-&OD,m[`SƜzHPEC +2u8Bʱʭ2IsKU5Zۆ/ռC\ cvwndH-NjJwU:L*~ =ukUzUFTpʢϪnPz»UoT&ޣfo[U<ߊJI}A/EֵuUS{6vpzAUWN].ew5~oHs ⍩eFlf|['-V$kḑbqKCAjfLc}~V57_͊kHы}:ҧ-F1}V|@ L;N(Dw,ZIm! GG`+-3d]-ޡСAKb%6uNTӺ]n1ңݲgk=U]KDTt w-k݉8Z},'UVښԭq#%h˵D<隕H%^N U-iŦV+I2QPCvhuv6j@G|W ~C.$}<@?S?6ћ@Kl'q.S~燺q!K,*GU>)]'`,kiZaarN紎xV{^T>?QSevT~_^az*{PS?$^L^6k6x*C=y[ozRpɹXbNGę6{%ј_:b67!(du ??柨S~c=N% ?GZ!BUWNң4 o;3G:cmznJ?+nyO?G V*w"x[@鑐Gͷhgm 岔MMW(qNRi;#&itXD>эBCVb4y˅ݟnSVν$LF6P ?fC8a g|]P/ ]e' Ⓘ &.kFnIpZoi\L{qV|}IQi+|8tZ]v/0g֏b2n GD_s(GU"72i^ zQȺg\A%NNaډd< d*у-" `:Nq9+"WKFi{8W W3hlԝ83ِ) 38XLNz,C)qVr `K>a[2אCwGuƤ^dsJܱOxr#w\`ebN dWՔM%렕cBK%ɗ;ҥ*әd9$[.6f3$NCJW} xB9kO'xN&{u(xW>@h+7^ 0/8LJyaW lC{JaͦI7cܡIЭDHg\~HsUE?M\fRK4/kAo?cJヾAV++=Gŏ :r%dT rue\E_/A|:L{A%@K6׃t; f@}tfͥt7|5bױUGnB_#7N?ButZ[h,NDkyifU0f.y9`J:p~] - VxAhd:_sN-\4.LZOgl *5on?8zP駒!hBh"4."deA&uhw-Elv@˰^. t֬70"!DEߤ0k!%!FEìxṊw\?B Fj-k~KSt&7i~[aY*kT!F+JF{zsޒմo"yXe{DON?ӳpmz+[%_p- n-\آWyѱ-*RZ6sm\ 88b*"1X< loc> ~>fV1f#=eyoOq (<%i9|h1-UGy= VUӊ}V}O<ں;H~r7mA;*΅X/ﷃt*UG~:p~F 9pY~x//=I|6{^p).:gy Rq[E:w ymgS+࿆jt7 $8eXMӧxSs?;@kmַ tmLъj1ZTT 8P[iVIimx^ؕ21 ^Cнr<@qv  ݇M~{bD}-~5ִ#{!oALG<(x~a wK| p O/ay^=4^W5xvdG;l؆YSEyÆv\f7m؟Vxq0O({s0z61MjDi4o&[vXɅyσRŽjХb@Ļۆ @JW2 K:@ূʱooAt9`AY3\x7J7"4 zp_/ tǍ/_`I5~+%hg)Aws9wMڴYV5#nͬI,_ m5F:-HO͌i:tV"0 ! a\~X@]T-B4 3L5HpO̎JTpP;"%5)%YҎ:l/O~1yn$۷5JьTL]f9dzByd.hNuT'[UzifJ9TV"܃ )xt\:JFvhؓDA| KAt'zEܪE=gϱ()xCM{T G >Ed4Ѕ׵m _+5rÏÏFyK7 wT92`fg̜ ԩ6 ڻ,R}5(Nimm;==荜+AU*tS(\z&+PUYȲ"Z?,S*O8TTp#]p7ZLgw)⾵,+̞;CנӺBͧ`Z%ܮqfLUE:jښq`>;|4{Dj6R\a(\K$"\&T)3զ@j1-2 X#5E|@-봋,:u;O`L!&;͡cԭ“?G1&1_҄7_&ƄM<'|@3LZ p0b CyJ&_1@$CҊC4}xWnM+vuon$"I&/OP1EѼtİyt,mbiory\ ˿+Z$|cqVv (Aq=:Mawxq1):L%>=ZYJDvPK k1HHַ$ #(org/gradle/wrapper/WrapperExecutor.classWy`UMn6ӄn)),%mEݖ#ISlҚ4Y ((*"DEA>oL6m }{s? `-~[(~DnYǏpoxg/J]AT`9-{d8${dx| Ca}$/G|20+ex(;'x$GŊDŽAOS2tdY?>8|_|)/*O OUH % ~4)=:ܷ{hxpgxdLA2m֑RQL&6)XmҖvhɌ`ehGBP6押$ SK؋v-;EߟD=cTT ֓+Hz;<ɤwzSICEHnvCr_>Uq@9O+砌͡d,*oec(oƖX3@3t˜Sc됙haU`"';"pV̡b,=ʱHAXUWRF:ENRYl}`!Tl)Sfr)~ ,oc彗^\Mog>euH\ Jj췛AGJb![51|q Cȷy[BPG:Ƶ.SAVQaTo6ԫrE?%x9]w̺?_ eN;ສЙk29_x*kqIFK :6Zd5Zur/^E{v=#Rb^lfHP|9$7:-@Ea8Ї=%i vEMTHj-&FO$7rVb˼ٕy 2QX6l7ze3DEmFYз@XMY!‹6&ܿÃccΖƜ--2{O +)aFzC`72t ڐVh?PK k1H B*org/gradle/wrapper/GradleWrapperMain.classXxNjU8 Ô Ԑ΀Y fmVQb؉H8=N8'يM'Nwz;gwu:-B_yy O>֋*.2\.PJ\W)8ǫxܽVpzoPQ&Fyx7 ޢUM|\!wRn~ zxXX PQ#܇*ŇU1!&\cʏT9c*T|PIb3T|֏I__O/KFO~|Mץ-w~.ǷT|Q]?'\~g ~ypoǁûz;+:1=>635R@(=çEї.#*Gm |m0uE#ѧRI3DT]&vHB }|HwAg׭G47_%uM8P]λ@5;1 VHJ0M=Jq=4:[H,n34vCFE3~$e1/#*A4y(e<u1{':bWrM<4A^`ܰ:{O-TFacL[IU3`$6F崌xApUII3InIIEc2h6l-7]8M>/rBp˒ ,jj-nM&V ]$ tU;5;M)b62)4 V s\x*jg+?O /+jBғjH l T/ zSX<0ksrRq36MOF[Ic5!˅.@UiI^KB,`eu(gʢdP>MBM(S5QXFa5$BŒNcOWD&JE"5HQJXK4Q%9+=/Rq+:fdAE,ER_Qeb6=7аAw1BLӳf"bMc=ij$kgiϑcF RJ ib 7)\Y>Z-.fh!%䢄UHŇ)ҫkFZQ+q5KcѨuQmX6E:DRo!3OoL74Br`=ut2/ՓԘ.Z FGR ^5ye7 cxYdvc+1X=ݱŝcGʸ>g/*^.Ʈ(Aeys;Sv{NďyӻO,zE)]7'cV1͇yVƒ#e4̝j;Þ7<ƘlTB3r0 pwzv qơ`Va! rD(~(kr0k_}))|p0 4L@<`ZhWzG[Ebq {| 'o &P PGZ(4f%\*S(#eyKA@. NE *N(XFU'-iAYR.X4ZԠ0eC),X1MaP?x 5&3F:z-mQ,G#.:B3mWc= b3nG ^8+Zm;"Q;|99J!D%C XH9Ĉ18~=nK!9\Kh eq(6і"3N2"l9 t𷖾BPCn\Pch!T hG:QKVJ:f+27ɮw6': VV8uk 4i\2캳Uez46qii}( \q2Z[z%0plZ;x9W \u֖UN\j2^C%:LyfWɐ݊琾I\whJl}:%v0uwv5R]4vw#1QWys{쳽=}%m/c*%,ULLs#}`Է0mw3a0Y HKoJx!+ }Xx$pg.(Jcݨti>DL(!L Xa_..)i %L?7nRrjPK k1Hx"org/gradle/wrapper/Install$1.classWkwY3瞳9>|rF}qXwD|WD< ˆcdc"C c2xPz(ƥD3![d ppePĺhp j6?p~bx\()&FF\'#x^}ʰ;m7kأVN6Vd&)#mi)M*pYmYc%r=71}J̲/y)te\/{F6G=P0Hכr~1ѻipiR! 'V*vnPhe)m6˱ '2\fZ/zQQwT2c9PircRxFr,WR 0m&5,΍\Fg,T{10WPNbu*\2vz7 I;bzr4scFNA2i/D^& u} WxP[庆)B!(v˚k1J~0iٰw uqlLO3SYae`z5=bv[das:~ulVQG[pMج6ܮ/W}(/c•U9^ zGtL˸xoxS[{({ _3ZbtN<&wuS:V{:|Os?ea0`ڦ/NH&FpV'8_t癹CV $:ߥLB,c)M5TXd r~ipz–E-hoǗM!D82&Ff~N695Ĩ*N*JW j+sXѵKǙ#5_ƂURK\ScLqpr@vk;`k Wт (IGwy#7A*]}0yb>2/r{!]hNU`v_ LܼuFC$h̹ Z YozW]r !󨨰>Chmo `[myUZ^r\Et}ۋDޘZ?y-R mZ*A8hAk "Ѳ;([9|^߈o8MB+zo%[=-e,;ء3h Fz+(XyjCeƚeħ %et03")hӘXsX=">gqe0~?SUW߿!;pff ZZB; ^.k>Ctk!usjDx׏U4,YVe-x2VfW]Z%6s~$B:ՔHC[Ȣ sȜdICV<7v+8TkqjȨأ^z<㯠I8s=b//ə1MRQRM~U8v^biaaU_5z|~QQ3ܾ~\^QSe|z "PHULs;PK k1Hj jV8org/gradle/wrapper/PathAssembler$LocalDistribution.classR[KAftq[yk[KA!|(L!N MJP?U<3Ҩ|ؙs.s˿ū9`OM}Q&m5ȏT0芟"VY~ܪ+Mc56-ډiK` {DjyT򏄽Ilֲ$,4T*? {M Fɡkmjs M%ydw-~[ؑ%Ru<[5'_n$6E<`=fAxwZIDډ?7 U46?S@h=W-ĝPK k1HcJK!org/gradle/wrapper/Download.classWg~f3; 9X( l" $v4, ]Pq;,lgf TmnU^[l(UT#bσ*Ge|LU4*ISb Q|V4Sy|A%<|YW𸌯*zDoxT-TSL-S TU=WOe<# Aafu1 k,췭a;on&-qS#wNO-AIX=j "J FMh[`J Z8n遴q`[yV8X愾`HՏYL];c-\mưvtqk̸{$DZsJf$G7gLc"0k٬Գ3gMͬ I˜ˤ2 ³*)H-gTjd /LYOláڭD!e8n,nՕ;4rbё nckئe1^?ً}l8s~}uECwY) vl7qfhF+E;.ﭺ/y#8Ǯbph%!-!tj{#w|roרQ+23wavb#v&J2pÄގy  S(a8IfUVe`->Cx d~M"ɾ|X,HיHxT'v"v] /`x@trfelO4P!H F 7h!mʩLA-^8LB-JAPK k1Hם_QO#gradle-wrapper-classpath.propertiesSO)IUHIM,RSp,(R02U002422Vpv Q0204*(JM.)M/JLIM**+MPK `1H(fbuild-receipt.properties5n Td Ko^6:Rh?>XgmyQ1)'bn!Rm6.F `>hSB;THjR h ҟvp}١g\[Hq&BHv̏+r25o,.~ių/9J=&JTgK77R?yۇnrFOPPK `1Horg/gradle/cli/PK `1H<S1org/gradle/cli/AbstractCommandLineConverter.classT]oA= +mt>BHhBem` Cߢ/42YPa9{s?p# 5ϕBy9yEx\Ye ZpՆaEjw I7|ZU c:tiw]HaٲzQdu;BrQfظ&DV\%6# ǹƙun]s̷X3ػe9H%ҲIk.=,ȍ-1ak^1蔕)9(id0^}y_7бp:%`i6t*㰊jBL F vUWm_ImuוD I8H7Լ&%DDՄ3qONB :ACvsπb0\8y 3CEw&T*kY+$@B!K͡5IYF6VANwh`+&XEKH,έQFV# J#hRq +dAy ~#TN*)oްOOSxΑ 86'??'k<ų@zV`PK `1H2_e(org/gradle/cli/CommandLineParser$1.classA 0EhZ v庈kCPEv-iIp.<S\p>?fxCDlnmMJ]k'iu#0BWՔ!f,By@wZ͕t!BI]#HI9|g|{ -|PK `1HRB <org/gradle/cli/CommandLineParser$MissingOptionArgState.class]O`6d 2 c&/1N4`W5S/ ^H#2-sKƖ&9O״ 1UQ4%ի*gE)D15u KD10ؓp :@^3\ٲŪ+^1UqQ)B&@)ʊ! B@n!fU(AiW|ۤᲵMnR# yd8!>] ZEGO*%UoulGQ/\TMn˹-02#/hAlu@t%-q*2Nw e&BgsQ\gݧ-F͌& nX{~ϐ2zfZC R6A Ӱἆ%GAa3@Lv0Lc8~csC7]Saf=/b !i!WiXN$!9!:">i!z&|'d&w`8Ig9NOXFiХ uD5x Rl( 38qhKCO p:mO.6p'%0o %rC?7o@Ӹ<=@QO b쫇|CMa"!˰߰d^7Uܰ^t^EY3G5Dh8%h+aVE3D*PK `1HM2=org/gradle/cli/CommandLineParser$OptionStringComparator.classTOAfeam`ZPd) HJ  ަ Yvɛ{&ƳvBkj8tޛyo/ jѱcр%:UlQNJU-`!?`nbHzT(gHuO:{|"<Cbq,l ߷YqDݶ̚-M oyޕJ z-Qӹ|H Nl#Kݑ]:Պ}^!C ެ\kW=jA;W{D9!ŒeAS/@%ئRƾj n5nIJ dOcy_e[o9 =}&fH]ͰqiR-x/ rahf2=BF=Y \ KaڙdiZ_L*SHhpPsED?!Fq`pZl{ݺ=1#[s!B{./zi|CG1ǐIVy&$nR$B;C'r."{i"Llr".03m`Y(N͒V055QM<3t Ʃ`1< mcd3B= `OPK `1H# GK1org/gradle/cli/CommandLineArgumentException.classJ1O3Zm+Uו0tD23k*|(1IK-Y  2aEE9炧=OQzTqvK9fU v#tiˀFCb!ė*BE{2ȅ 9`)K,Ihh\x &J>p1YITةQcBW~ͿDcD y f@]tӻLA^%6uV18(c]3 2gy=ݴoa̝̩ kqv>PK `1H?h=org/gradle/cli/CommandLineParser$KnownOptionParserState.classXkx~dY&Vdsд!@LawL73ۙJ[^6V{zJB^֢Oy<}ߟ=gfvݰ?ܾs@;ޕw%!cL!XIy^l^^\OIcB w10X/LtL{$|Uz|={el}2oɷd|a=_P8? cu 'yy(agL K%yT¯$PkXk戄ٗmivOBsh['Xh43g~vt&@A˰qlŀ1bjn&5 wfbqԴ]L0 KB}qeF;zylXqLҟ;C Dl2XwiMU9^܀¬[2ԘnհT ky|qG\R-VlFtw[^ZpwL&tJ%Fڬuu[s-ά }A*I/m^E> @YK#m^:y}` b(`Vʎ7hZ8h W '̇۶g vGVlWpv(؉)BA 4.nS:vA :WV:ujմ\UTBq>:ȲI6)Oݦ%ݣ6uBsԤmq=ajl-N+8*7+xC bH”.k8e9tTij$ *9 cNsxF ^ ~ڛJjFN趾d/?BQ2xEE*~!Ů656ד#f"zHxS[,mUbj%pAMi /}2h4i-lӨo/F[Xulxz o,<#^Z<;^=F݉5y豖 g7eÿ%8#^+XLw6j=K֕ xr^ i/=Tqܼ42b6vc&>ܰh0g|,eŨCgm}C~Rqᦊl>hAdf^]2gbV% %jO2!ǃL&~spfc9OvtYSr\w 7V*9dpŮ[ [3Gҩ7~vOrDx (Sl}izKg:$D)ahJb9gP6hhVD +$D땐h<Y<*6JBx M'X>bAlwĶ%Y9!e} n/*XO߯i;BPK `1Hk7org/gradle/cli/CommandLineParser$OptionComparator.classUmOP~nQ:oSD oe b0!c,Zvğ_Hb"6sJC{=9Ϲ~P4dW%,(c ^JX^IXu E ^3tmm2$r}d }w5C}5\ޱgVnkR,)XN];ڡ5P ЬC渺3y  ,#e}0Ђ/]i'jjV]zaՋ S6^~ u- TtY+y&duK< Y$jj7cv 2W[VAۛ+mS*(uB1lņ,i^\r 8;c =x\8npﹸvr CQo *]] 4|[Tuޒ%`anot.AAiU WGŵ S/co4<}u!TZi>Jv!a<@*QȒ̜!q ;G'.!v {nD<|ڊ֋1(Н0Q I9b|b$m:ݳtBHO\g3(W`iL9I k aXtβE$i,:AyLS)""J?QAX_PK `1Hb'n?org/gradle/cli/CommandLineParser$UnknownOptionParserState.classURA==$a2@(""UZ`$SdL__\H*~7= B%q}q[A :0A0iDq5k rCw˺& ezabq [vJ%nWL[F ! ɕgY6rkk X>O 6E=}9A{gN)Ҧ>曖.^]S`{jHO~噎-pe}^^rJI=R7٠cSޒ{2iOcinی1^#r޲t1b7?4yvo=)L^)aFZ֜[c9*z'̼n$T BAa F&00 mGd6a4j3 C'/n{._VƵձ+1DX UR%H}4+.L_c=:"L32}F7>L`g%.dJ\)+QLgq.:K^dI׵{""¾j4e8 ț#u`@Ts䥓?|pP{fr mEhQr!"XOٯUVH/.\ 鋘6?9R?SͩUÕ@FcH:U1-NcjXc4Uy<blfq=PK `1H"zZ &org/gradle/cli/CommandLineOption.classV[sV˱E  cP@HICEUGT\Y S¤tCg'C~GVdٲKΞ՞ow=m;0%c:6Lu`; fx%p -xK ܆*cAF>ꩂ4!#x,ƠpG(ߍ%qKFI{dY5~G*n4gXBǔ^4Ubkֿn ,[7'yBQbeI3%5r&u#q2Qy[wHHSYJWɬjJf@H7h[Ҭ,J8ڲ -7ܨq&nԝR1GC (ONT4{Zj̨.2jyi~\PSDz5,žcKBO}p,̮V!^ԜUmH(Q"lbQ-#a("Zrw6 ivΝ=w _|dŦmTҜ1d{mC);BNDfQkikɄaXq2ЯܵRB7"$(XAy/A7A#>;:|(F ͹=U&KcEZP|yq- S+·\U|HQS$dú݄31TMZ@wťK) sAChU0^]<. uʓGa(M"%z.업cg"W=d1fIٔd}F6,O).a9Ţ,se,~Bٿŋ#Hp+o(8Y:nY XGQWwe|W}?%d735V?6FeTs q83x[S/W&SwE>F)L+5VeF'1Gy݌`RͫW5OޞJo0LA E.ȸ:V61'!unQúwTK7rXr̐[1E0w$DϞCόm  kV%8py'ЃZT1жO~0͢˚QX|l%>ow l (t((TyN,x0^*QpKWj'DG \! ׇ6!$>!À40d)w[@bbu1NbkP$LװMUWlV Gn"{$ G^FHbp,>"]vqvοVw΄1(|v3A?w2{10]/~ ^&IC9$Egd$}uvNrg5&<gSF2#SӤXLBi ,A|;"AmȜ2BXiL8 G:m$x0$aOI(>*A[Ue/3n3̎Hm ߗzck쉡-,N3U?ϗ^i e;^{*΅e gl͑HC9Y\Y,X f.Ggab@HFSϢ/@tOL]u(#_k#ܩ7onaܾN25h8)Jeb[11_b7İ#j1lFד>^I>7ʢ0uI;, W/pdiM O: 䡟 I%'/;Lق)<$O#30VQ+qvC#B7>8^C~,rPK `1Hg*&org/gradle/cli/CommandLineParser.classY xTյ^+8$<"cB2DT0xHNLQ*Q`}WVEIQbm}>l[{o{zk[L&={wD4OE>-NS:`ҩYti]:^4i:TNDOnvsS\stZ5^qNxNHkD KuPft0\s|\'V9OfhH9_>|!E_Gx5n*kDK|(j|NWu\ ⊀_&Zy6xXr:͢ Ѣŭ>nvLdh]ȌŬӘU`$muN3j#Q1M3c֊p ǂN+)^n;ӸKÑ]a{rYƸ4Aŧ`*p3c1gkmj {m[Q{4qi9?B3ˬH׸3e]fʐ<~tk1j4/߲v40Wn3wU]`*jYVqh^4*b+;cTu `[،wE噳!3Ve3X2mj-!9Jme0l.\f(Um$5/XQT(ڲ*5>0X1MB)[C,] K\%uK6 :ZѵBQ+#fh Ġ;S>aogD|IJJ"/?{)KlllQK@pk lw7[ɀ旤Q&3 1exp 2^Њ$W,fHB9iȰTA/L gnqי1:m^W y^937=&3; Y9lays@ 㴒A^WV![Nlf4 wCVMAs6l|r%%,X2ѭъc9#_z`Υ1 N{ng߈d HŊ&oɑ4Vck i cQn2yU@C8dq~r4#3rafmA𝖵Ӑ-tچ1zǓ:H$m}]$ǝB<8&Hj60S+e1+UxvO L͈V)2dcKw$ԧT*fsM;s&A@+srPђd@X%~R,>AŅoBBotEQ ĢRtmAӠ/mAw2O^æa8nˠüzP>6xk&q;( winҠ1⡎A_e+ ?#<ZY} x ˎ-o ?71U )4Y7x `mEo;h%Kc ŕe.Cm5/2Kiy͕eH48MVˣHâY HB3u{>COicOYS}q1y)V\, >!i85~Q迁"%Fڶ!]8S8j/{3fcf]܂" lT/i$jp8/6[Z#ikM 'GmX܌Ƌw3*fTt ݪ¯jdLɱ8u7Gq3fۉfX )TeF'|_7 QdBɦ{6u^U߽S-J ~S%\hC8KpiG OF1wxp:bp4}GR/ŭA qp:UY?z-g= hະtp?"@4t44Ə(J}T0qefl/*_8xnqV?F:fVGdQCYA'vtXA] X1jM4XX"JV8#$Ӷa fdBYs@ֳ X]-pޚ J%+2'|Zy3+vܚ]yZ?IKUfQ S4p[])  7DI+6~6v=N Uҹp#ڢA[ !q7cODh$J5煰PcC`Ff"mXs4|'6ۭneX# kA:ŋ>+ Az /)2{ <dMÌOkfP;#\2fVZwE}Q*Fn2ld/-t\7*błQ%u„֌pUOHzYKxF/GnEտqW-{>Q8+(ڎk1hY?y^=܋h)s> 6GN,\ӛz)5ݽ4BH&Z t0f !Gӗ1gkrʏTW*UnU.=Bb w?7SASٳB^:FSQSY{iLCyw8C|Rz~oOCg' =4Ӥ&Y:ߋ:)=44tEP/6e(fB- T-:KѺ= R{)G0ԇ)TŋXlDMHTѻ 5* fB<Αvj9Kn-U?D+}ͨ3Y z܆|Gh)tIW71e|<$\*Rߍ46Tx-]NZKWi+uS3]M-tYHVDY=K黴~(DR0NH;\JqG]H;y#m͝t%參Gi/?h?O񫴟ߦO7V+9=HndWkIqzGl2A3Þ.6iS$C?jAnnWJӠӠևzk9z=;1Iw2{EnGN_Q='1FQ=6Ľ z1:s1"!llJJ.-\Y bq/Xb%MDU)BJyfxܪv/}[ł0Zre19& D[ /7w5 q`{EG$\hT@'5x^b@̥8$sӇ IyyCMm*[|V5z鼆r·.qW(k8)A6 QH(b0Yl.uK@. R~}NG`v&LO<}Q8ZؾJya `}tKg" h=v^ $%ӊB|L'Y|zw\].J?W:OKb8)`E%ds!1z 5HCo#<ߧi'1;Ԋ(K5dC ~ORiq >5$i\~~D?FY 4plFnJ3I9hm=U[/0fx#=./ˉh]OWf{Ik-\&4=Qx&9ZRV&"s$Яy@( oh9}Pn+G?8*uzö?#܅ϝ頯ֆG med''EѮ@{vG!'Q-KAT8ے۳RH,C H6~7~Z$g/uT*^@ /4?h3 COm>o("N{0w-r 3=81EIBhG1 hAv|v7*8 D O$Wr"'߇LXV<#v?UgWaKwX.ҝQr$a1C2ԭZ?vPX>Bn3TV;Ng(!j<$}E]bݍ;[7+.C{=hg^uuv?ϢEh?7sσ&7no?PK `1H_>ң)3org/gradle/cli/CommandLineParser$AfterOptions.classmOP( @ 1Q|Dt1wkծ5wE#]|!Je<1Mz99s۟PƊ'IW1!y &TU,2~=x6x !fu'\lkug!s6tL![/Hvfe׹[‘zdL[N!e`oyXuyej&!&)bA02]yr^5Vf6R\4dr] C0ԖQi26{{J.-ߏ޺&Ww{Ֆ/IU0ᘓ*3Le o13/#|]ˣ%D3zaS2u7XMc qaA78yWN*%1|avť-N x!*JB)>#iIShln|AjTDVИF(J9DRR; %܊1C!˩1(|GFJfKmt$F5kj|EFߧjr dY+!kmrQ>э=ep2n&0ft9\9E'tN* iϤK49hPK `1HGf3org/gradle/cli/CommandLineParser$OptionString.classSNA=]ʗ(U-e)'#  XlwD w+Bs;s=??~ &cAYs)TҘa! ei,pW]p_8 =[wfnsak璳bv0[=כ)m1$j^C0dlWv8Bv-(wAP ;e(|¯9<Zkߴ>o8ª;UZ-6d7_8'_AyKBkxy>Eӂ4Ui 1 z]A@Z Moz~]{*Ka:r摎, b^hxc+ ݥNC:`U L1r) ;{2̜?3zE9nB;;esy-w'i< MI^NN֤ʍЛh8Yq|9wvc 91Ȩ(` (OaʓbmDm>X1#Ka ~B>FJg!6l|;4 kaCԍx0r/iA';`CG G¡c#'30@ÌnmaF⺙igM1*[Ĥ=\E7i PK `1Hx&T` ;org/gradle/cli/AbstractPropertiesCommandLineConverter.classV[wU L2悡5&I  i-4J`Ei+v fpfD{_ m\KWu dY\go}_p?H8"%ެHO%"ͧ= IX6@7=q|';y !H"r k7b0tuVɫ}%_&I cbj| f1\f)^2bYZ ڦbZ:c듶r*&2 M n8&M2jV)DĜ2W5( ,MIzn)嚺Re9hst4%D  Tmgv֭ttKzAm" e7tv٧) ٹW v"Qys;]^W/ypF,w5h}ے6&FOڕ.e`ZcCQ@Q,_Q+WDh2DDYFCF0-6j qdqțt+#y:*[0JZEf~]r~N WScXD\/ô.'Ƕk_4ЫTS!Wn[0( 5R%պ<a՝ISؾꢦ.Ci$h{wfЪCMx(t'9%f9o=,N=M柃B&; ﭣ/ N?gyO:aeJ^/F}o b b4kt"tZ3 яU0fx'ySr 6 aadB3 /)LF}Atc^l?$ͼA_ !7Vkg렾@ ‡CGGDoЅph.` (rroYJ]kKIrIn#)`,r|4 mYYBY-B1>q?PK `1H ,org/gradle/cli/ParsedCommandLineOption.classS[OA-"\A(-ʊP1!iĤoC;Ylw- &JD}G.I|9|93|`+)dPPQL!B0冊I,-,&q[~器+䲤⾊ {lqWAW-+ b^ f~,Cz2$J^YA4_T[Wjls6)5fn2Gsy;+c&k_2U`V]Rm4=a[T.ipoSP0/DND=t=Z+jpS0? KOrbjrjd0ajWKp &N&7YָE4Wl/xY92,BS*jx<Iy2=4yt Zce[ZҚE̙swy' :iB&1!CŴ3*f5$0b^E!YsMKc2\(4ff[\xf}f!?\t]($zr,.épx| luj6%;fOxզPɭq…% v2^l"P+ܧ8ش癄[2۟kVMa*W`sQ(r Q.$uv\ y;>ަVv[fnYx2=Y#X13:ncTŢ%,Xѱ5Pg),V5H3 K; 3'<<JڵSΐ!/g&W;;^ݸ v,ly/x-/TQZ]܉\E/˕=lk<RwgrŁtZ.=EPhh+"J6mL+"F~OA-, f1B 娆E$5"y  3@AU'2P*= QE3D5@}C2Pw'3y=RHI8[-vtn5@ $}_+:)+C EoPK `1H'H g)org/gradle/cli/CommandLineConverter.classQMK@}ԯ'"4 FM)HQ ޷lI7ݔ6MBya=t$S l)8A {Oyb :˄3I5' JXdT"qx{a/4OR1=Q615 ڹ6ƇEWbRh{'qj1M8zta,gZTRwZ\SYVSݜnhUYB/n/1Oz_G86\fjAʚajJuG-UʙeZ7^[u(5}2(Y٪Zk$N(@yA(تeٺip|0Xh5UUJ`[QtZw&~ժ:ѷ3<MSn9j*ߌq\6 G J*yN;{2#hfc f*SL Èaq!y" Ǘ axIbtxh.x%0&X}?:Ui4^}R֚Be*"nE& ̗he;*J"b68pÕ7rC.?V-0fO~^y뱉6{*B^*Y-z=:7CRyʍհjHC*dfN͔W{M ^pCMPzkt_gBR,]x;^Vw+eM+" ;zf7i^/O3}xb]C[B]d5c|Q%G7GO=m~} ҈'ҮOC.i^yb;30rؑ^!yڢ{f U5$:2lދ9eX Lm1 }IbR$Yy|M7PK `1H;|9org/gradle/cli/SystemPropertiesCommandLineConverter.classJ@ثmjE5BDąR/P~ӑ$&BJW 'iAY3͜l "lYlE <& d@HgL{:rRs:C*X4NĬQ ۴;hZ3a ѽG!]Gv7S"5eb o}ɸGtFMz9y~X{()spL`7e.KV, TXxɢfDTEGPWJmh~49AjxѰ sh gԙn85].FԒs9Q΢*s/@Ug J*ce+s+1 $p6/t-,;h-.Z >kZPK `1H-h2org/gradle/cli/CommandLineParser$ParserState.classSoPN) sT4706|3M$m f{@ú[s-?&>GmdiҞ|~pF62΢jv,-4WׄTqB0;%v=^(>{J` aŴ9,D!PK `1HF= ;org/gradle/cli/CommandLineParser$AfterFirstSubCommand.classVRPN[J;be-x)U.R(XE_( |gtPq猏C8I K0㟳{v|gw9| E͈4тHA/pK\3*B;ExqOH0ԛoB Нҍ\$gȫy%ͫ!k)USdqW5ռ0l%^--1x[+T^ɓğҳr~I6T/ =]kS1&U`fV Ҍ)F2/ Y88f-IMy$ M1eLo H2ڼ})MzٛZʑ"P\\y6O\}9ݲ'JBKeվm gËYzK/ Z1}**2 ~CG&1%`Z 3t9eaёgںokǔ@g%Ku`|G%E5e uS閻5ϗ4ڪ۲b}B\EU6:YPFJjh>3L578")&COH)YslH#?nA;ΙZwQW+S ^ͼ8W'AE[=|>>Јs6MMT > wH{im::^A:HG8d"Fx&O+\AX!vѸq HW69Z e+˝}с; \G7Ĺ(( ]LSh`cB p.9Bj1 D'($U<"z@'bj']GZ f<_PK `1H壪GEgradle-cli-classpath.propertiesSO)IUHIM,RSp,(R02U002420Ppv Q0204*(JM.)**+MPK w1H AMETA-INF/PK w1H8@U)META-INF/MANIFEST.MFPK k1HAorg/PK k1H Aorg/gradle/PK k1HAorg/gradle/wrapper/PK k1Hhdf#org/gradle/wrapper/Download$1.classPK k1HޅpDorg/gradle/wrapper/Download$SystemPropertiesProxyAuthenticator.classPK k1HXs"worg/gradle/wrapper/IDownload.classPK k1Hz\Q-aorg/gradle/wrapper/GradleUserHomeLookup.classPK k1H] 3org/gradle/wrapper/ExclusiveFileAccessManager.classPK k1H ^F-org/gradle/wrapper/WrapperConfiguration.classPK k1Hdzߒ= 0org/gradle/wrapper/SystemPropertiesHandler.classPK k1Hy0Vorg/gradle/wrapper/Logger.classPK k1Hrn&morg/gradle/wrapper/PathAssembler.classPK k1H8޶) org/gradle/wrapper/Install.classPK k1HL -3org/gradle/wrapper/BootstrapMainStarter.classPK k1HHַ$ #(.8org/gradle/wrapper/WrapperExecutor.classPK k1H B*GCorg/gradle/wrapper/GradleWrapperMain.classPK k1Hx"ANorg/gradle/wrapper/Install$1.classPK k1Hj jV8!Uorg/gradle/wrapper/PathAssembler$LocalDistribution.classPK k1HcJK!+Worg/gradle/wrapper/Download.classPK k1Hם_QO#_gradle-wrapper-classpath.propertiesPK `1H(f`build-receipt.propertiesPK `1HAaorg/gradle/cli/PK `1H<S1Haorg/gradle/cli/AbstractCommandLineConverter.classPK `1H2_e(corg/gradle/cli/CommandLineParser$1.classPK `1HRB <dorg/gradle/cli/CommandLineParser$MissingOptionArgState.classPK `1HM2=gorg/gradle/cli/CommandLineParser$OptionStringComparator.classPK `1H# GK1jorg/gradle/cli/CommandLineArgumentException.classPK `1H?h=Clorg/gradle/cli/CommandLineParser$KnownOptionParserState.classPK `1Hk7etorg/gradle/cli/CommandLineParser$OptionComparator.classPK `1Hb'n?worg/gradle/cli/CommandLineParser$UnknownOptionParserState.classPK `1H"zZ &zorg/gradle/cli/CommandLineOption.classPK `1Hl\ϧ8org/gradle/cli/CommandLineParser$OptionParserState.classPK `1H[xn&org/gradle/cli/ParsedCommandLine.classPK `1HA5l| :porg/gradle/cli/ProjectPropertiesCommandLineConverter.classPK `1H2lWJFDorg/gradle/cli/CommandLineParser$CaseInsensitiveStringComparator.classPK `1Hg*&org/gradle/cli/CommandLineParser.classPK `1H_>ң)3org/gradle/cli/CommandLineParser$AfterOptions.classPK `1HGf3org/gradle/cli/CommandLineParser$OptionString.classPK `1Hx&T` ;torg/gradle/cli/AbstractPropertiesCommandLineConverter.classPK `1H ,-org/gradle/cli/ParsedCommandLineOption.classPK `1Hs=3org/gradle/cli/CommandLineParser$OptionAwareParserState.classPK `1H'H g)&org/gradle/cli/CommandLineConverter.classPK `1HC| <org/gradle/cli/CommandLineParser$BeforeFirstSubCommand.classPK `1H;|9ʷorg/gradle/cli/SystemPropertiesCommandLineConverter.classPK `1H-h2org/gradle/cli/CommandLineParser$ParserState.classPK `1HF= ;org/gradle/cli/CommandLineParser$AfterFirstSubCommand.classPK `1H壪GEgradle-cli-classpath.propertiesPK11czmq-4.1.0/bindings/jni/build.gradle0000664000372000037200000001126213222211156020221 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ plugins { id 'java' id 'maven-publish' id "com.jfrog.bintray" version "1.7.3" } group = "org.zeromq" version = "4.1.0" repositories { mavenLocal() mavenCentral() jcenter() } sourceCompatibility = 1.7 targetCompatibility = 1.7 dependencies { testCompile 'junit:junit:4.12' testCompile 'org.hamcrest:hamcrest-all:1.3' } task wrapper(type: Wrapper) { gradleVersion = '2.13' } // ------------------------------------------------------------------ // Build section task generateJniHeaders(type: Exec, dependsOn: 'classes') { def classpath = sourceSets.main.output.classesDir def appclasspath = configurations.runtime.files*.getAbsolutePath().join(":") def nativeIncludes = "src/native/include" def jniClasses = [ 'org.zeromq.czmq.Zarmour', 'org.zeromq.czmq.Zcert', 'org.zeromq.czmq.Zcertstore', 'org.zeromq.czmq.Zchunk', 'org.zeromq.czmq.Zclock', 'org.zeromq.czmq.Zconfig', 'org.zeromq.czmq.Zdigest', 'org.zeromq.czmq.Zdir', 'org.zeromq.czmq.ZdirPatch', 'org.zeromq.czmq.Zfile', 'org.zeromq.czmq.Zframe', 'org.zeromq.czmq.Zhash', 'org.zeromq.czmq.Zhashx', 'org.zeromq.czmq.Ziflist', 'org.zeromq.czmq.Zlist', 'org.zeromq.czmq.Zlistx', 'org.zeromq.czmq.Zloop', 'org.zeromq.czmq.Zmsg', 'org.zeromq.czmq.Zpoller', 'org.zeromq.czmq.Zproc', 'org.zeromq.czmq.Zsock', 'org.zeromq.czmq.Zstr', 'org.zeromq.czmq.Zsys', 'org.zeromq.czmq.Ztimerset', 'org.zeromq.czmq.Ztrie', 'org.zeromq.czmq.Zuuid' ] commandLine("javah", "-d", "$nativeIncludes", "-classpath", "$classpath:$appclasspath", *jniClasses) } tasks.withType(Test) { systemProperty "java.library.path", "/usr/lib:/usr/local/lib:$projectDir" } task initCMake(type: Exec, dependsOn: 'generateJniHeaders') { commandLine "cmake", "." } task buildNative(type: Exec, dependsOn: 'initCMake') { commandLine "make" } jar.dependsOn buildNative test.dependsOn buildNative // ------------------------------------------------------------------ // Install and Publish section task sourcesJar(type: Jar, dependsOn: 'classes') { classifier = 'sources' from sourceSets.main.allSource } task javadocJar(type: Jar, dependsOn: 'javadoc') { classifier = 'javadoc' from javadoc.destinationDir } publishing { publications { mavenJava(MavenPublication) { from components.java artifact sourcesJar artifact javadocJar pom.withXml { asNode().appendNode('packaging', 'jar') asNode().appendNode('name', 'czmq-jni') asNode().appendNode('description', 'The high-level C binding for 0MQ') asNode().appendNode('url', 'https://github.com/zeromq/czmq') def license = asNode().appendNode('licenses').appendNode('license') license.appendNode('name', 'Mozilla Public License Version 2.0') license.appendNode('url', 'https://www.mozilla.org/en-US/MPL/2.0/') def scm = asNode().appendNode('scm') scm.appendNode('connection', 'https://github.com/zeromq/czmq.git') scm.appendNode('developerConnection', 'https://github.com/zeromq/czmq.git') scm.appendNode('url', 'https://github.com/zeromq/czmq') } } } } bintray { user = System.getenv('BINTRAY_USER') key = System.getenv('BINTRAY_KEY') publications = ['mavenJava'] publish = true override = true pkg { repo = "maven" name = "czmq-jni" desc = "The high-level C binding for 0MQ" userOrg = System.getenv('BINTRAY_USER_ORG') licenses = ["MPL-2.0"] websiteUrl = 'https://github.com/zeromq/czmq' issueTrackerUrl = 'https://github.com/zeromq/czmq/issues' vcsUrl = 'https://github.com/zeromq/czmq.git' githubRepo = System.getenv('BINTRAY_USER_ORG') + '/czmq' version { name = '4.1.0' vcsTag= '4.1.0' } } } // ------------------------------------------------------------------ // Cleanup section clean.doFirst { delete "${rootDir}/CMakeCache.txt" delete "${rootDir}/libczmqjni.so" } czmq-4.1.0/bindings/jni/ci_build.sh0000775000372000037200000000525613222211156020061 0ustar00travistravis00000000000000#!/usr/bin/env bash set -e # Set this to enable verbose profiling [ -n "${CI_TIME-}" ] || CI_TIME="" case "$CI_TIME" in [Yy][Ee][Ss]|[Oo][Nn]|[Tt][Rr][Uu][Ee]) CI_TIME="time -p " ;; [Nn][Oo]|[Oo][Ff][Ff]|[Ff][Aa][Ll][Ss][Ee]) CI_TIME="" ;; esac # Set this to enable verbose tracing [ -n "${CI_TRACE-}" ] || CI_TRACE="no" case "$CI_TRACE" in [Nn][Oo]|[Oo][Ff][Ff]|[Ff][Aa][Ll][Ss][Ee]) set +x ;; [Yy][Ee][Ss]|[Oo][Nn]|[Tt][Rr][Uu][Ee]) set -x ;; esac ######################################################################## # Build and check the jni binding ######################################################################## BUILD_PREFIX=/tmp CONFIG_OPTS=() CONFIG_OPTS+=("CFLAGS=-I${BUILD_PREFIX}/include") CONFIG_OPTS+=("CPPFLAGS=-I${BUILD_PREFIX}/include") CONFIG_OPTS+=("CXXFLAGS=-I${BUILD_PREFIX}/include") CONFIG_OPTS+=("LDFLAGS=-L${BUILD_PREFIX}/lib") CONFIG_OPTS+=("PKG_CONFIG_PATH=${BUILD_PREFIX}/lib/pkgconfig") CONFIG_OPTS+=("--prefix=${BUILD_PREFIX}") CONFIG_OPTS+=("--with-docs=no") if [ -z "${CI_CONFIG_QUIET-}" ] || [ "${CI_CONFIG_QUIET-}" = yes ] || [ "${CI_CONFIG_QUIET-}" = true ]; then CONFIG_OPTS+=("--quiet") fi pushd ../../.. # Clone and build dependencies [ -z "$CI_TIME" ] || echo "`date`: Starting build of dependencies (if any)..." $CI_TIME git clone --quiet --depth 1 https://github.com/zeromq/libzmq.git libzmq cd libzmq git --no-pager log --oneline -n1 if [ -e autogen.sh ]; then $CI_TIME ./autogen.sh 2> /dev/null fi if [ -e buildconf ]; then $CI_TIME ./buildconf 2> /dev/null fi if [ ! -e autogen.sh ] && [ ! -e buildconf ] && [ ! -e ./configure ] && [ -s ./configure.ac ]; then $CI_TIME libtoolize --copy --force && \ $CI_TIME aclocal -I . && \ $CI_TIME autoheader && \ $CI_TIME automake --add-missing --copy && \ $CI_TIME autoconf || \ $CI_TIME autoreconf -fiv fi $CI_TIME ./configure "${CONFIG_OPTS[@]}" $CI_TIME make -j4 $CI_TIME make install cd .. popd pushd ../.. [ -z "$CI_TIME" ] || echo "`date`: Starting build of currently tested project..." $CI_TIME ./autogen.sh 2> /dev/null $CI_TIME ./configure "${CONFIG_OPTS[@]}" $CI_TIME make -j4 $CI_TIME make install [ -z "$CI_TIME" ] || echo "`date`: Build completed without fatal errors!" popd TERM=dumb PKG_CONFIG_PATH=$BUILD_PREFIX/lib/pkgconfig $CI_TIME ./gradlew build jar TERM=dumb $CI_TIME ./gradlew clean ######################################################################## # Build and check the jni android binding ######################################################################## pushd ../../builds/android . ./ci_build.sh popd pushd android TERM=dumb PKG_CONFIG_PATH=$BUILD_PREFIX/lib/pkgconfig $CI_TIME ./build.sh popd czmq-4.1.0/bindings/jni/src/0000775000372000037200000000000013222211156016527 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/src/test/0000775000372000037200000000000013222211156017506 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/src/test/java/0000775000372000037200000000000013222211156020427 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/src/test/java/org/0000775000372000037200000000000013222211156021216 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/0000775000372000037200000000000013222211156022533 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/0000775000372000037200000000000013222211156023505 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZlistxTest.java0000664000372000037200000000122513222211156026505 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZlistxTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zlistx.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZiflistTest.java0000664000372000037200000000122713222211156026636 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZiflistTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Ziflist.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZconfigTest.java0000664000372000037200000000122713222211156026611 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZconfigTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zconfig.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZpollerTest.java0000664000372000037200000000122713222211156026641 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZpollerTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zpoller.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZloopTest.java0000664000372000037200000000122313222211156026311 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZloopTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zloop.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZdigestTest.java0000664000372000037200000000122713222211156026623 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZdigestTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zdigest.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZcertTest.java0000664000372000037200000000122313222211156026275 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZcertTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zcert.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZchunkTest.java0000664000372000037200000000122513222211156026452 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZchunkTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zchunk.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZfileTest.java0000664000372000037200000000122313222211156026257 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZfileTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zfile.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZstrTest.java0000664000372000037200000000122113222211156026146 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZstrTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zstr.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZdirTest.java0000664000372000037200000000122113222211156026114 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZdirTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zdir.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZclockTest.java0000664000372000037200000000122513222211156026435 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZclockTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zclock.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZuuidTest.java0000664000372000037200000000122313222211156026306 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZuuidTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zuuid.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZmsgTest.java0000664000372000037200000000122113222211156026124 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZmsgTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zmsg.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZarmourTest.java0000664000372000037200000000122713222211156026651 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZarmourTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zarmour.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZsockTest.java0000664000372000037200000000122313222211156026277 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZsockTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zsock.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZtrieTest.java0000664000372000037200000000122313222211156026303 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZtrieTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Ztrie.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZhashTest.java0000664000372000037200000000122313222211156026263 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZhashTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zhash.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZlistTest.java0000664000372000037200000000122313222211156026313 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZlistTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zlist.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZsysTest.java0000664000372000037200000000122113222211156026154 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZsysTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zsys.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZcertstoreTest.java0000664000372000037200000000123513222211156027355 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZcertstoreTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zcertstore.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZtimersetTest.java0000664000372000037200000000123313222211156027175 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZtimersetTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Ztimerset.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZhashxTest.java0000664000372000037200000000122513222211156026455 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZhashxTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zhashx.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZprocTest.java0000664000372000037200000000122313222211156026303 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZprocTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zproc.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZframeTest.java0000664000372000037200000000122513222211156026434 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZframeTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { Zframe.test (false); } } czmq-4.1.0/bindings/jni/src/test/java/org/zeromq/czmq/ZdirPatchTest.java0000664000372000037200000000123313222211156027077 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; import org.junit.Assert; import org.junit.Test; public class ZdirPatchTest { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } @Test public void test () { ZdirPatch.test (false); } } czmq-4.1.0/bindings/jni/src/main/0000775000372000037200000000000013222211156017453 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/src/main/java/0000775000372000037200000000000013222211156020374 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/src/main/java/org/0000775000372000037200000000000013222211156021163 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/0000775000372000037200000000000013222211156022500 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/0000775000372000037200000000000013222211156023452 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zdigest.java0000664000372000037200000000431113222211156025725 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zdigest implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Constructor - creates new digest object, which you use to build up a digest by repeatedly calling zdigest_update() on chunks of data. */ native static long __new (); public Zdigest () { /* TODO: if __new fails, self is null... */ self = __new (); } public Zdigest (long pointer) { self = pointer; } /* Destroy a digest object */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Add buffer into digest calculation */ native static void __update (long self, byte [] buffer, long length); public void update (byte [] buffer, long length) { __update (self, buffer, length); } /* Return final digest hash data. If built without crypto support, returns NULL. */ native static byte [] __data (long self); public byte [] data () { return __data (self); } /* Return final digest hash size */ native static long __size (long self); public long size () { return __size (self); } /* Return digest as printable hex string; caller should not modify nor free this string. After calling this, you may not use zdigest_update() on the same digest. If built without crypto support, returns NULL. */ native static String __string (long self); public String string () { return __string (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zcert.java0000664000372000037200000001255513222211156025414 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zcert implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create and initialize a new certificate in memory */ native static long __new (); public Zcert () { /* TODO: if __new fails, self is null... */ self = __new (); } public Zcert (long pointer) { self = pointer; } /* Accepts public/secret key pair from caller */ native static long __newFrom (byte [] publicKey, byte [] secretKey); public static Zcert newFrom (byte [] publicKey, byte [] secretKey) { return new Zcert (__newFrom (publicKey, secretKey)); } /* Accepts public/secret key text pair from caller */ native static long __newFromTxt (String publicTxt, String secretTxt); public static Zcert newFromTxt (String publicTxt, String secretTxt) { return new Zcert (__newFromTxt (publicTxt, secretTxt)); } /* Load certificate from file */ native static long __load (String filename); public static Zcert load (String filename) { return new Zcert (__load (filename)); } /* Destroy a certificate in memory */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Return public part of key pair as 32-byte binary string */ native static byte [] __publicKey (long self); public byte [] publicKey () { return __publicKey (self); } /* Return secret part of key pair as 32-byte binary string */ native static byte [] __secretKey (long self); public byte [] secretKey () { return __secretKey (self); } /* Return public part of key pair as Z85 armored string */ native static String __publicTxt (long self); public String publicTxt () { return __publicTxt (self); } /* Return secret part of key pair as Z85 armored string */ native static String __secretTxt (long self); public String secretTxt () { return __secretTxt (self); } /* Set certificate metadata from formatted string. */ native static void __setMeta (long self, String name, String format); public void setMeta (String name, String format) { __setMeta (self, name, format); } /* Unset certificate metadata. */ native static void __unsetMeta (long self, String name); public void unsetMeta (String name) { __unsetMeta (self, name); } /* Get metadata value from certificate; if the metadata value doesn't exist, returns NULL. */ native static String __meta (long self, String name); public String meta (String name) { return __meta (self, name); } /* Get list of metadata fields from certificate. Caller is responsible for destroying list. Caller should not modify the values of list items. */ native static long __metaKeys (long self); public Zlist metaKeys () { return new Zlist (__metaKeys (self)); } /* Save full certificate (public + secret) to file for persistent storage This creates one public file and one secret file (filename + "_secret"). */ native static int __save (long self, String filename); public int save (String filename) { return __save (self, filename); } /* Save public certificate only to file for persistent storage */ native static int __savePublic (long self, String filename); public int savePublic (String filename) { return __savePublic (self, filename); } /* Save secret certificate only to file for persistent storage */ native static int __saveSecret (long self, String filename); public int saveSecret (String filename) { return __saveSecret (self, filename); } /* Apply certificate to socket, i.e. use for CURVE security on socket. If certificate was loaded from public file, the secret key will be undefined, and this certificate will not work successfully. */ native static void __apply (long self, long socket); public void apply (long socket) { __apply (self, socket); } /* Return copy of certificate; if certificate is NULL or we exhausted heap memory, returns NULL. */ native static long __dup (long self); public Zcert dup () { return new Zcert (__dup (self)); } /* Return true if two certificates have the same keys */ native static boolean __eq (long self, long compare); public boolean eq (Zcert compare) { return __eq (self, compare.self); } /* Print certificate contents to stdout */ native static void __print (long self); public void print () { __print (self); } /* Self test of this class */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zsock.java0000664000372000037200000014266513222211156025424 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zsock implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new socket. Returns the new socket, or NULL if the new socket could not be created. Note that the symbol zsock_new (and other constructors/destructors for zsock) are redirected to the *_checked variant, enabling intelligent socket leak detection. This can have performance implications if you use a LOT of sockets. To turn off this redirection behaviour, define ZSOCK_NOCHECK. */ native static long __new (int type); public Zsock (int type) { /* TODO: if __new fails, self is null... */ self = __new (type); } public Zsock (long pointer) { self = pointer; } /* Create a PUB socket. Default action is bind. */ native static long __newPub (String endpoint); public static Zsock newPub (String endpoint) { return new Zsock (__newPub (endpoint)); } /* Create a SUB socket, and optionally subscribe to some prefix string. Default action is connect. */ native static long __newSub (String endpoint, String subscribe); public static Zsock newSub (String endpoint, String subscribe) { return new Zsock (__newSub (endpoint, subscribe)); } /* Create a REQ socket. Default action is connect. */ native static long __newReq (String endpoint); public static Zsock newReq (String endpoint) { return new Zsock (__newReq (endpoint)); } /* Create a REP socket. Default action is bind. */ native static long __newRep (String endpoint); public static Zsock newRep (String endpoint) { return new Zsock (__newRep (endpoint)); } /* Create a DEALER socket. Default action is connect. */ native static long __newDealer (String endpoint); public static Zsock newDealer (String endpoint) { return new Zsock (__newDealer (endpoint)); } /* Create a ROUTER socket. Default action is bind. */ native static long __newRouter (String endpoint); public static Zsock newRouter (String endpoint) { return new Zsock (__newRouter (endpoint)); } /* Create a PUSH socket. Default action is connect. */ native static long __newPush (String endpoint); public static Zsock newPush (String endpoint) { return new Zsock (__newPush (endpoint)); } /* Create a PULL socket. Default action is bind. */ native static long __newPull (String endpoint); public static Zsock newPull (String endpoint) { return new Zsock (__newPull (endpoint)); } /* Create an XPUB socket. Default action is bind. */ native static long __newXpub (String endpoint); public static Zsock newXpub (String endpoint) { return new Zsock (__newXpub (endpoint)); } /* Create an XSUB socket. Default action is connect. */ native static long __newXsub (String endpoint); public static Zsock newXsub (String endpoint) { return new Zsock (__newXsub (endpoint)); } /* Create a PAIR socket. Default action is connect. */ native static long __newPair (String endpoint); public static Zsock newPair (String endpoint) { return new Zsock (__newPair (endpoint)); } /* Create a STREAM socket. Default action is connect. */ native static long __newStream (String endpoint); public static Zsock newStream (String endpoint) { return new Zsock (__newStream (endpoint)); } /* Create a SERVER socket. Default action is bind. */ native static long __newServer (String endpoint); public static Zsock newServer (String endpoint) { return new Zsock (__newServer (endpoint)); } /* Create a CLIENT socket. Default action is connect. */ native static long __newClient (String endpoint); public static Zsock newClient (String endpoint) { return new Zsock (__newClient (endpoint)); } /* Create a RADIO socket. Default action is bind. */ native static long __newRadio (String endpoint); public static Zsock newRadio (String endpoint) { return new Zsock (__newRadio (endpoint)); } /* Create a DISH socket. Default action is connect. */ native static long __newDish (String endpoint); public static Zsock newDish (String endpoint) { return new Zsock (__newDish (endpoint)); } /* Create a GATHER socket. Default action is bind. */ native static long __newGather (String endpoint); public static Zsock newGather (String endpoint) { return new Zsock (__newGather (endpoint)); } /* Create a SCATTER socket. Default action is connect. */ native static long __newScatter (String endpoint); public static Zsock newScatter (String endpoint) { return new Zsock (__newScatter (endpoint)); } /* Destroy the socket. You must use this for any socket created via the zsock_new method. */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Bind a socket to a formatted endpoint. For tcp:// endpoints, supports ephemeral ports, if you specify the port number as "*". By default zsock uses the IANA designated range from C000 (49152) to FFFF (65535). To override this range, follow the "*" with "[first-last]". Either or both first and last may be empty. To bind to a random port within the range, use "!" in place of "*". Examples: tcp://127.0.0.1:* bind to first free port from C000 up tcp://127.0.0.1:! bind to random port from C000 to FFFF tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 tcp://127.0.0.1:![55000-55999] bind to random port from 55000 to 55999 On success, returns the actual port number used, for tcp:// endpoints, and 0 for other transports. On failure, returns -1. Note that when using ephemeral ports, a port may be reused by different services without clients being aware. Protocols that run on ephemeral ports should take this into account. */ native static int __bind (long self, String format); public int bind (String format) { return __bind (self, format); } /* Returns last bound endpoint, if any. */ native static String __endpoint (long self); public String endpoint () { return __endpoint (self); } /* Unbind a socket from a formatted endpoint. Returns 0 if OK, -1 if the endpoint was invalid or the function isn't supported. */ native static int __unbind (long self, String format); public int unbind (String format) { return __unbind (self, format); } /* Connect a socket to a formatted endpoint Returns 0 if OK, -1 if the endpoint was invalid. */ native static int __connect (long self, String format); public int connect (String format) { return __connect (self, format); } /* Disconnect a socket from a formatted endpoint Returns 0 if OK, -1 if the endpoint was invalid or the function isn't supported. */ native static int __disconnect (long self, String format); public int disconnect (String format) { return __disconnect (self, format); } /* Attach a socket to zero or more endpoints. If endpoints is not null, parses as list of ZeroMQ endpoints, separated by commas, and prefixed by '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all endpoints were valid, or -1 if there was a syntax error. If the endpoint does not start with '@' or '>', the serverish argument defines whether it is used to bind (serverish = true) or connect (serverish = false). */ native static int __attach (long self, String endpoints, boolean serverish); public int attach (String endpoints, boolean serverish) { return __attach (self, endpoints, serverish); } /* Returns socket type as printable constant string. */ native static String __typeStr (long self); public String typeStr () { return __typeStr (self); } /* Send a 'picture' message to the socket (or actor). The picture is a string that defines the type of each frame. This makes it easy to send a complex multiframe message in one call. The picture can contain any of these characters, each corresponding to one or two arguments: i = int (signed) 1 = uint8_t 2 = uint16_t 4 = uint32_t 8 = uint64_t s = char * b = byte *, size_t (2 arguments) c = zchunk_t * f = zframe_t * h = zhashx_t * U = zuuid_t * p = void * (sends the pointer value, only meaningful over inproc) m = zmsg_t * (sends all frames in the zmsg) z = sends zero-sized frame (0 arguments) u = uint (deprecated) Note that s, b, c, and f are encoded the same way and the choice is offered as a convenience to the sender, which may or may not already have data in a zchunk or zframe. Does not change or take ownership of any arguments. Returns 0 if successful, -1 if sending failed for any reason. */ native static int __send (long self, String picture); public int send (String picture []) { return __send (self, picture [0]); } /* Receive a 'picture' message to the socket (or actor). See zsock_send for the format and meaning of the picture. Returns the picture elements into a series of pointers as provided by the caller: i = int * (stores signed integer) 4 = uint32_t * (stores 32-bit unsigned integer) 8 = uint64_t * (stores 64-bit unsigned integer) s = char ** (allocates new string) b = byte **, size_t * (2 arguments) (allocates memory) c = zchunk_t ** (creates zchunk) f = zframe_t ** (creates zframe) U = zuuid_t * (creates a zuuid with the data) h = zhashx_t ** (creates zhashx) p = void ** (stores pointer) m = zmsg_t ** (creates a zmsg with the remaing frames) z = null, asserts empty frame (0 arguments) u = uint * (stores unsigned integer, deprecated) Note that zsock_recv creates the returned objects, and the caller must destroy them when finished with them. The supplied pointers do not need to be initialized. Returns 0 if successful, or -1 if it failed to recv a message, in which case the pointers are not modified. When message frames are truncated (a short message), sets return values to zero/null. If an argument pointer is NULL, does not store any value (skips it). An 'n' picture matches an empty frame; if the message does not match, the method will return -1. */ native static int __recv (long self, String picture); public int recv (String picture []) { return __recv (self, picture [0]); } /* Send a binary encoded 'picture' message to the socket (or actor). This method is similar to zsock_send, except the arguments are encoded in a binary format that is compatible with zproto, and is designed to reduce memory allocations. The pattern argument is a string that defines the type of each argument. Supports these argument types: pattern C type zproto type: 1 uint8_t type = "number" size = "1" 2 uint16_t type = "number" size = "2" 4 uint32_t type = "number" size = "3" 8 uint64_t type = "number" size = "4" s char *, 0-255 chars type = "string" S char *, 0-2^32-1 chars type = "longstr" c zchunk_t * type = "chunk" f zframe_t * type = "frame" u zuuid_t * type = "uuid" m zmsg_t * type = "msg" p void *, sends pointer value, only over inproc Does not change or take ownership of any arguments. Returns 0 if successful, -1 if sending failed for any reason. */ native static int __bsend (long self, String picture); public int bsend (String picture []) { return __bsend (self, picture [0]); } /* Receive a binary encoded 'picture' message from the socket (or actor). This method is similar to zsock_recv, except the arguments are encoded in a binary format that is compatible with zproto, and is designed to reduce memory allocations. The pattern argument is a string that defines the type of each argument. See zsock_bsend for the supported argument types. All arguments must be pointers; this call sets them to point to values held on a per-socket basis. For types 1, 2, 4 and 8 the caller must allocate the memory itself before calling zsock_brecv. For types S, the caller must free the value once finished with it, as zsock_brecv will allocate the buffer. For type s, the caller must not free the value as it is stored in a local cache for performance purposes. For types c, f, u and m the caller must call the appropriate destructor depending on the object as zsock_brecv will create new objects. For type p the caller must coordinate with the sender, as it is just a pointer value being passed. */ native static int __brecv (long self, String picture); public int brecv (String picture []) { return __brecv (self, picture [0]); } /* Return socket routing ID if any. This returns 0 if the socket is not of type ZMQ_SERVER or if no request was already received on it. */ native static int __routingId (long self); public int routingId () { return __routingId (self); } /* Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. This will be used when sending messages on the socket via the zsock API. */ native static void __setRoutingId (long self, int routingId); public void setRoutingId (int routingId) { __setRoutingId (self, routingId); } /* Set socket to use unbounded pipes (HWM=0); use this in cases when you are totally certain the message volume can fit in memory. This method works across all versions of ZeroMQ. Takes a polymorphic socket reference. */ native static void __setUnbounded (long self); public void setUnbounded () { __setUnbounded (self); } /* Send a signal over a socket. A signal is a short message carrying a success/failure code (by convention, 0 means OK). Signals are encoded to be distinguishable from "normal" messages. Accepts a zsock_t or a zactor_t argument, and returns 0 if successful, -1 if the signal could not be sent. Takes a polymorphic socket reference. */ native static int __signal (long self, byte status); public int signal (byte status) { return __signal (self, status); } /* Wait on a signal. Use this to coordinate between threads, over pipe pairs. Blocks until the signal is received. Returns -1 on error, 0 or greater on success. Accepts a zsock_t or a zactor_t as argument. Takes a polymorphic socket reference. */ native static int __wait (long self); public int Wait () { return __wait (self); } /* If there is a partial message still waiting on the socket, remove and discard it. This is useful when reading partial messages, to get specific message types. */ native static void __flush (long self); public void flush () { __flush (self); } /* Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. Returns 0 if OK, -1 if failed. */ native static int __join (long self, String group); public int join (String group) { return __join (self, group); } /* Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. Returns 0 if OK, -1 if failed. */ native static int __leave (long self, String group); public int leave (String group) { return __leave (self, group); } /* Probe the supplied object, and report if it looks like a zsock_t. Takes a polymorphic socket reference. */ native static boolean __is (long self); public boolean is (long self) { return __is (self); } /* Probe the supplied reference. If it looks like a zsock_t instance, return the underlying libzmq socket handle; else if it looks like a file descriptor, return NULL; else if it looks like a libzmq socket handle, return the supplied value. Takes a polymorphic socket reference. */ native static long __resolve (long self); public long resolve (long self) { return __resolve (self); } /* Get socket option `heartbeat_ivl`. Available from libzmq 4.2.0. */ native static int __heartbeatIvl (long self); public int heartbeatIvl () { return __heartbeatIvl (self); } /* Set socket option `heartbeat_ivl`. Available from libzmq 4.2.0. */ native static void __setHeartbeatIvl (long self, int heartbeatIvl); public void setHeartbeatIvl (int heartbeatIvl) { __setHeartbeatIvl (self, heartbeatIvl); } /* Get socket option `heartbeat_ttl`. Available from libzmq 4.2.0. */ native static int __heartbeatTtl (long self); public int heartbeatTtl () { return __heartbeatTtl (self); } /* Set socket option `heartbeat_ttl`. Available from libzmq 4.2.0. */ native static void __setHeartbeatTtl (long self, int heartbeatTtl); public void setHeartbeatTtl (int heartbeatTtl) { __setHeartbeatTtl (self, heartbeatTtl); } /* Get socket option `heartbeat_timeout`. Available from libzmq 4.2.0. */ native static int __heartbeatTimeout (long self); public int heartbeatTimeout () { return __heartbeatTimeout (self); } /* Set socket option `heartbeat_timeout`. Available from libzmq 4.2.0. */ native static void __setHeartbeatTimeout (long self, int heartbeatTimeout); public void setHeartbeatTimeout (int heartbeatTimeout) { __setHeartbeatTimeout (self, heartbeatTimeout); } /* Get socket option `use_fd`. Available from libzmq 4.2.0. */ native static int __useFd (long self); public int useFd () { return __useFd (self); } /* Set socket option `use_fd`. Available from libzmq 4.2.0. */ native static void __setUseFd (long self, int useFd); public void setUseFd (int useFd) { __setUseFd (self, useFd); } /* Set socket option `xpub_manual`. Available from libzmq 4.2.0. */ native static void __setXpubManual (long self, int xpubManual); public void setXpubManual (int xpubManual) { __setXpubManual (self, xpubManual); } /* Set socket option `xpub_welcome_msg`. Available from libzmq 4.2.0. */ native static void __setXpubWelcomeMsg (long self, String xpubWelcomeMsg); public void setXpubWelcomeMsg (String xpubWelcomeMsg) { __setXpubWelcomeMsg (self, xpubWelcomeMsg); } /* Set socket option `stream_notify`. Available from libzmq 4.2.0. */ native static void __setStreamNotify (long self, int streamNotify); public void setStreamNotify (int streamNotify) { __setStreamNotify (self, streamNotify); } /* Get socket option `invert_matching`. Available from libzmq 4.2.0. */ native static int __invertMatching (long self); public int invertMatching () { return __invertMatching (self); } /* Set socket option `invert_matching`. Available from libzmq 4.2.0. */ native static void __setInvertMatching (long self, int invertMatching); public void setInvertMatching (int invertMatching) { __setInvertMatching (self, invertMatching); } /* Set socket option `xpub_verboser`. Available from libzmq 4.2.0. */ native static void __setXpubVerboser (long self, int xpubVerboser); public void setXpubVerboser (int xpubVerboser) { __setXpubVerboser (self, xpubVerboser); } /* Get socket option `connect_timeout`. Available from libzmq 4.2.0. */ native static int __connectTimeout (long self); public int connectTimeout () { return __connectTimeout (self); } /* Set socket option `connect_timeout`. Available from libzmq 4.2.0. */ native static void __setConnectTimeout (long self, int connectTimeout); public void setConnectTimeout (int connectTimeout) { __setConnectTimeout (self, connectTimeout); } /* Get socket option `tcp_maxrt`. Available from libzmq 4.2.0. */ native static int __tcpMaxrt (long self); public int tcpMaxrt () { return __tcpMaxrt (self); } /* Set socket option `tcp_maxrt`. Available from libzmq 4.2.0. */ native static void __setTcpMaxrt (long self, int tcpMaxrt); public void setTcpMaxrt (int tcpMaxrt) { __setTcpMaxrt (self, tcpMaxrt); } /* Get socket option `thread_safe`. Available from libzmq 4.2.0. */ native static int __threadSafe (long self); public int threadSafe () { return __threadSafe (self); } /* Get socket option `multicast_maxtpdu`. Available from libzmq 4.2.0. */ native static int __multicastMaxtpdu (long self); public int multicastMaxtpdu () { return __multicastMaxtpdu (self); } /* Set socket option `multicast_maxtpdu`. Available from libzmq 4.2.0. */ native static void __setMulticastMaxtpdu (long self, int multicastMaxtpdu); public void setMulticastMaxtpdu (int multicastMaxtpdu) { __setMulticastMaxtpdu (self, multicastMaxtpdu); } /* Get socket option `vmci_buffer_size`. Available from libzmq 4.2.0. */ native static int __vmciBufferSize (long self); public int vmciBufferSize () { return __vmciBufferSize (self); } /* Set socket option `vmci_buffer_size`. Available from libzmq 4.2.0. */ native static void __setVmciBufferSize (long self, int vmciBufferSize); public void setVmciBufferSize (int vmciBufferSize) { __setVmciBufferSize (self, vmciBufferSize); } /* Get socket option `vmci_buffer_min_size`. Available from libzmq 4.2.0. */ native static int __vmciBufferMinSize (long self); public int vmciBufferMinSize () { return __vmciBufferMinSize (self); } /* Set socket option `vmci_buffer_min_size`. Available from libzmq 4.2.0. */ native static void __setVmciBufferMinSize (long self, int vmciBufferMinSize); public void setVmciBufferMinSize (int vmciBufferMinSize) { __setVmciBufferMinSize (self, vmciBufferMinSize); } /* Get socket option `vmci_buffer_max_size`. Available from libzmq 4.2.0. */ native static int __vmciBufferMaxSize (long self); public int vmciBufferMaxSize () { return __vmciBufferMaxSize (self); } /* Set socket option `vmci_buffer_max_size`. Available from libzmq 4.2.0. */ native static void __setVmciBufferMaxSize (long self, int vmciBufferMaxSize); public void setVmciBufferMaxSize (int vmciBufferMaxSize) { __setVmciBufferMaxSize (self, vmciBufferMaxSize); } /* Get socket option `vmci_connect_timeout`. Available from libzmq 4.2.0. */ native static int __vmciConnectTimeout (long self); public int vmciConnectTimeout () { return __vmciConnectTimeout (self); } /* Set socket option `vmci_connect_timeout`. Available from libzmq 4.2.0. */ native static void __setVmciConnectTimeout (long self, int vmciConnectTimeout); public void setVmciConnectTimeout (int vmciConnectTimeout) { __setVmciConnectTimeout (self, vmciConnectTimeout); } /* Get socket option `tos`. Available from libzmq 4.1.0. */ native static int __tos (long self); public int tos () { return __tos (self); } /* Set socket option `tos`. Available from libzmq 4.1.0. */ native static void __setTos (long self, int tos); public void setTos (int tos) { __setTos (self, tos); } /* Set socket option `router_handover`. Available from libzmq 4.1.0. */ native static void __setRouterHandover (long self, int routerHandover); public void setRouterHandover (int routerHandover) { __setRouterHandover (self, routerHandover); } /* Set socket option `connect_rid`. Available from libzmq 4.1.0. */ native static void __setConnectRid (long self, String connectRid); public void setConnectRid (String connectRid) { __setConnectRid (self, connectRid); } /* Set socket option `connect_rid` from 32-octet binary Available from libzmq 4.1.0. */ native static void __setConnectRidBin (long self, byte [] connectRid); public void setConnectRidBin (byte [] connectRid) { __setConnectRidBin (self, connectRid); } /* Get socket option `handshake_ivl`. Available from libzmq 4.1.0. */ native static int __handshakeIvl (long self); public int handshakeIvl () { return __handshakeIvl (self); } /* Set socket option `handshake_ivl`. Available from libzmq 4.1.0. */ native static void __setHandshakeIvl (long self, int handshakeIvl); public void setHandshakeIvl (int handshakeIvl) { __setHandshakeIvl (self, handshakeIvl); } /* Get socket option `socks_proxy`. Available from libzmq 4.1.0. */ native static String __socksProxy (long self); public String socksProxy () { return __socksProxy (self); } /* Set socket option `socks_proxy`. Available from libzmq 4.1.0. */ native static void __setSocksProxy (long self, String socksProxy); public void setSocksProxy (String socksProxy) { __setSocksProxy (self, socksProxy); } /* Set socket option `xpub_nodrop`. Available from libzmq 4.1.0. */ native static void __setXpubNodrop (long self, int xpubNodrop); public void setXpubNodrop (int xpubNodrop) { __setXpubNodrop (self, xpubNodrop); } /* Set socket option `router_mandatory`. Available from libzmq 4.0.0. */ native static void __setRouterMandatory (long self, int routerMandatory); public void setRouterMandatory (int routerMandatory) { __setRouterMandatory (self, routerMandatory); } /* Set socket option `probe_router`. Available from libzmq 4.0.0. */ native static void __setProbeRouter (long self, int probeRouter); public void setProbeRouter (int probeRouter) { __setProbeRouter (self, probeRouter); } /* Set socket option `req_relaxed`. Available from libzmq 4.0.0. */ native static void __setReqRelaxed (long self, int reqRelaxed); public void setReqRelaxed (int reqRelaxed) { __setReqRelaxed (self, reqRelaxed); } /* Set socket option `req_correlate`. Available from libzmq 4.0.0. */ native static void __setReqCorrelate (long self, int reqCorrelate); public void setReqCorrelate (int reqCorrelate) { __setReqCorrelate (self, reqCorrelate); } /* Set socket option `conflate`. Available from libzmq 4.0.0. */ native static void __setConflate (long self, int conflate); public void setConflate (int conflate) { __setConflate (self, conflate); } /* Get socket option `zap_domain`. Available from libzmq 4.0.0. */ native static String __zapDomain (long self); public String zapDomain () { return __zapDomain (self); } /* Set socket option `zap_domain`. Available from libzmq 4.0.0. */ native static void __setZapDomain (long self, String zapDomain); public void setZapDomain (String zapDomain) { __setZapDomain (self, zapDomain); } /* Get socket option `mechanism`. Available from libzmq 4.0.0. */ native static int __mechanism (long self); public int mechanism () { return __mechanism (self); } /* Get socket option `plain_server`. Available from libzmq 4.0.0. */ native static int __plainServer (long self); public int plainServer () { return __plainServer (self); } /* Set socket option `plain_server`. Available from libzmq 4.0.0. */ native static void __setPlainServer (long self, int plainServer); public void setPlainServer (int plainServer) { __setPlainServer (self, plainServer); } /* Get socket option `plain_username`. Available from libzmq 4.0.0. */ native static String __plainUsername (long self); public String plainUsername () { return __plainUsername (self); } /* Set socket option `plain_username`. Available from libzmq 4.0.0. */ native static void __setPlainUsername (long self, String plainUsername); public void setPlainUsername (String plainUsername) { __setPlainUsername (self, plainUsername); } /* Get socket option `plain_password`. Available from libzmq 4.0.0. */ native static String __plainPassword (long self); public String plainPassword () { return __plainPassword (self); } /* Set socket option `plain_password`. Available from libzmq 4.0.0. */ native static void __setPlainPassword (long self, String plainPassword); public void setPlainPassword (String plainPassword) { __setPlainPassword (self, plainPassword); } /* Get socket option `curve_server`. Available from libzmq 4.0.0. */ native static int __curveServer (long self); public int curveServer () { return __curveServer (self); } /* Set socket option `curve_server`. Available from libzmq 4.0.0. */ native static void __setCurveServer (long self, int curveServer); public void setCurveServer (int curveServer) { __setCurveServer (self, curveServer); } /* Get socket option `curve_publickey`. Available from libzmq 4.0.0. */ native static String __curvePublickey (long self); public String curvePublickey () { return __curvePublickey (self); } /* Set socket option `curve_publickey`. Available from libzmq 4.0.0. */ native static void __setCurvePublickey (long self, String curvePublickey); public void setCurvePublickey (String curvePublickey) { __setCurvePublickey (self, curvePublickey); } /* Set socket option `curve_publickey` from 32-octet binary Available from libzmq 4.0.0. */ native static void __setCurvePublickeyBin (long self, byte [] curvePublickey); public void setCurvePublickeyBin (byte [] curvePublickey) { __setCurvePublickeyBin (self, curvePublickey); } /* Get socket option `curve_secretkey`. Available from libzmq 4.0.0. */ native static String __curveSecretkey (long self); public String curveSecretkey () { return __curveSecretkey (self); } /* Set socket option `curve_secretkey`. Available from libzmq 4.0.0. */ native static void __setCurveSecretkey (long self, String curveSecretkey); public void setCurveSecretkey (String curveSecretkey) { __setCurveSecretkey (self, curveSecretkey); } /* Set socket option `curve_secretkey` from 32-octet binary Available from libzmq 4.0.0. */ native static void __setCurveSecretkeyBin (long self, byte [] curveSecretkey); public void setCurveSecretkeyBin (byte [] curveSecretkey) { __setCurveSecretkeyBin (self, curveSecretkey); } /* Get socket option `curve_serverkey`. Available from libzmq 4.0.0. */ native static String __curveServerkey (long self); public String curveServerkey () { return __curveServerkey (self); } /* Set socket option `curve_serverkey`. Available from libzmq 4.0.0. */ native static void __setCurveServerkey (long self, String curveServerkey); public void setCurveServerkey (String curveServerkey) { __setCurveServerkey (self, curveServerkey); } /* Set socket option `curve_serverkey` from 32-octet binary Available from libzmq 4.0.0. */ native static void __setCurveServerkeyBin (long self, byte [] curveServerkey); public void setCurveServerkeyBin (byte [] curveServerkey) { __setCurveServerkeyBin (self, curveServerkey); } /* Get socket option `gssapi_server`. Available from libzmq 4.0.0. */ native static int __gssapiServer (long self); public int gssapiServer () { return __gssapiServer (self); } /* Set socket option `gssapi_server`. Available from libzmq 4.0.0. */ native static void __setGssapiServer (long self, int gssapiServer); public void setGssapiServer (int gssapiServer) { __setGssapiServer (self, gssapiServer); } /* Get socket option `gssapi_plaintext`. Available from libzmq 4.0.0. */ native static int __gssapiPlaintext (long self); public int gssapiPlaintext () { return __gssapiPlaintext (self); } /* Set socket option `gssapi_plaintext`. Available from libzmq 4.0.0. */ native static void __setGssapiPlaintext (long self, int gssapiPlaintext); public void setGssapiPlaintext (int gssapiPlaintext) { __setGssapiPlaintext (self, gssapiPlaintext); } /* Get socket option `gssapi_principal`. Available from libzmq 4.0.0. */ native static String __gssapiPrincipal (long self); public String gssapiPrincipal () { return __gssapiPrincipal (self); } /* Set socket option `gssapi_principal`. Available from libzmq 4.0.0. */ native static void __setGssapiPrincipal (long self, String gssapiPrincipal); public void setGssapiPrincipal (String gssapiPrincipal) { __setGssapiPrincipal (self, gssapiPrincipal); } /* Get socket option `gssapi_service_principal`. Available from libzmq 4.0.0. */ native static String __gssapiServicePrincipal (long self); public String gssapiServicePrincipal () { return __gssapiServicePrincipal (self); } /* Set socket option `gssapi_service_principal`. Available from libzmq 4.0.0. */ native static void __setGssapiServicePrincipal (long self, String gssapiServicePrincipal); public void setGssapiServicePrincipal (String gssapiServicePrincipal) { __setGssapiServicePrincipal (self, gssapiServicePrincipal); } /* Get socket option `ipv6`. Available from libzmq 4.0.0. */ native static int __ipv6 (long self); public int ipv6 () { return __ipv6 (self); } /* Set socket option `ipv6`. Available from libzmq 4.0.0. */ native static void __setIpv6 (long self, int ipv6); public void setIpv6 (int ipv6) { __setIpv6 (self, ipv6); } /* Get socket option `immediate`. Available from libzmq 4.0.0. */ native static int __immediate (long self); public int immediate () { return __immediate (self); } /* Set socket option `immediate`. Available from libzmq 4.0.0. */ native static void __setImmediate (long self, int immediate); public void setImmediate (int immediate) { __setImmediate (self, immediate); } /* Get socket option `sndhwm`. Available from libzmq 3.0.0. */ native static int __sndhwm (long self); public int sndhwm () { return __sndhwm (self); } /* Set socket option `sndhwm`. Available from libzmq 3.0.0. */ native static void __setSndhwm (long self, int sndhwm); public void setSndhwm (int sndhwm) { __setSndhwm (self, sndhwm); } /* Get socket option `rcvhwm`. Available from libzmq 3.0.0. */ native static int __rcvhwm (long self); public int rcvhwm () { return __rcvhwm (self); } /* Set socket option `rcvhwm`. Available from libzmq 3.0.0. */ native static void __setRcvhwm (long self, int rcvhwm); public void setRcvhwm (int rcvhwm) { __setRcvhwm (self, rcvhwm); } /* Get socket option `maxmsgsize`. Available from libzmq 3.0.0. */ native static int __maxmsgsize (long self); public int maxmsgsize () { return __maxmsgsize (self); } /* Set socket option `maxmsgsize`. Available from libzmq 3.0.0. */ native static void __setMaxmsgsize (long self, int maxmsgsize); public void setMaxmsgsize (int maxmsgsize) { __setMaxmsgsize (self, maxmsgsize); } /* Get socket option `multicast_hops`. Available from libzmq 3.0.0. */ native static int __multicastHops (long self); public int multicastHops () { return __multicastHops (self); } /* Set socket option `multicast_hops`. Available from libzmq 3.0.0. */ native static void __setMulticastHops (long self, int multicastHops); public void setMulticastHops (int multicastHops) { __setMulticastHops (self, multicastHops); } /* Set socket option `xpub_verbose`. Available from libzmq 3.0.0. */ native static void __setXpubVerbose (long self, int xpubVerbose); public void setXpubVerbose (int xpubVerbose) { __setXpubVerbose (self, xpubVerbose); } /* Get socket option `tcp_keepalive`. Available from libzmq 3.0.0. */ native static int __tcpKeepalive (long self); public int tcpKeepalive () { return __tcpKeepalive (self); } /* Set socket option `tcp_keepalive`. Available from libzmq 3.0.0. */ native static void __setTcpKeepalive (long self, int tcpKeepalive); public void setTcpKeepalive (int tcpKeepalive) { __setTcpKeepalive (self, tcpKeepalive); } /* Get socket option `tcp_keepalive_idle`. Available from libzmq 3.0.0. */ native static int __tcpKeepaliveIdle (long self); public int tcpKeepaliveIdle () { return __tcpKeepaliveIdle (self); } /* Set socket option `tcp_keepalive_idle`. Available from libzmq 3.0.0. */ native static void __setTcpKeepaliveIdle (long self, int tcpKeepaliveIdle); public void setTcpKeepaliveIdle (int tcpKeepaliveIdle) { __setTcpKeepaliveIdle (self, tcpKeepaliveIdle); } /* Get socket option `tcp_keepalive_cnt`. Available from libzmq 3.0.0. */ native static int __tcpKeepaliveCnt (long self); public int tcpKeepaliveCnt () { return __tcpKeepaliveCnt (self); } /* Set socket option `tcp_keepalive_cnt`. Available from libzmq 3.0.0. */ native static void __setTcpKeepaliveCnt (long self, int tcpKeepaliveCnt); public void setTcpKeepaliveCnt (int tcpKeepaliveCnt) { __setTcpKeepaliveCnt (self, tcpKeepaliveCnt); } /* Get socket option `tcp_keepalive_intvl`. Available from libzmq 3.0.0. */ native static int __tcpKeepaliveIntvl (long self); public int tcpKeepaliveIntvl () { return __tcpKeepaliveIntvl (self); } /* Set socket option `tcp_keepalive_intvl`. Available from libzmq 3.0.0. */ native static void __setTcpKeepaliveIntvl (long self, int tcpKeepaliveIntvl); public void setTcpKeepaliveIntvl (int tcpKeepaliveIntvl) { __setTcpKeepaliveIntvl (self, tcpKeepaliveIntvl); } /* Get socket option `tcp_accept_filter`. Available from libzmq 3.0.0. */ native static String __tcpAcceptFilter (long self); public String tcpAcceptFilter () { return __tcpAcceptFilter (self); } /* Set socket option `tcp_accept_filter`. Available from libzmq 3.0.0. */ native static void __setTcpAcceptFilter (long self, String tcpAcceptFilter); public void setTcpAcceptFilter (String tcpAcceptFilter) { __setTcpAcceptFilter (self, tcpAcceptFilter); } /* Get socket option `last_endpoint`. Available from libzmq 3.0.0. */ native static String __lastEndpoint (long self); public String lastEndpoint () { return __lastEndpoint (self); } /* Set socket option `router_raw`. Available from libzmq 3.0.0. */ native static void __setRouterRaw (long self, int routerRaw); public void setRouterRaw (int routerRaw) { __setRouterRaw (self, routerRaw); } /* Get socket option `ipv4only`. Available from libzmq 3.0.0. */ native static int __ipv4only (long self); public int ipv4only () { return __ipv4only (self); } /* Set socket option `ipv4only`. Available from libzmq 3.0.0. */ native static void __setIpv4only (long self, int ipv4only); public void setIpv4only (int ipv4only) { __setIpv4only (self, ipv4only); } /* Set socket option `delay_attach_on_connect`. Available from libzmq 3.0.0. */ native static void __setDelayAttachOnConnect (long self, int delayAttachOnConnect); public void setDelayAttachOnConnect (int delayAttachOnConnect) { __setDelayAttachOnConnect (self, delayAttachOnConnect); } /* Get socket option `hwm`. Available from libzmq 2.0.0 to 3.0.0. */ native static int __hwm (long self); public int hwm () { return __hwm (self); } /* Set socket option `hwm`. Available from libzmq 2.0.0 to 3.0.0. */ native static void __setHwm (long self, int hwm); public void setHwm (int hwm) { __setHwm (self, hwm); } /* Get socket option `swap`. Available from libzmq 2.0.0 to 3.0.0. */ native static int __swap (long self); public int swap () { return __swap (self); } /* Set socket option `swap`. Available from libzmq 2.0.0 to 3.0.0. */ native static void __setSwap (long self, int swap); public void setSwap (int swap) { __setSwap (self, swap); } /* Get socket option `affinity`. Available from libzmq 2.0.0. */ native static int __affinity (long self); public int affinity () { return __affinity (self); } /* Set socket option `affinity`. Available from libzmq 2.0.0. */ native static void __setAffinity (long self, int affinity); public void setAffinity (int affinity) { __setAffinity (self, affinity); } /* Get socket option `identity`. Available from libzmq 2.0.0. */ native static String __identity (long self); public String identity () { return __identity (self); } /* Set socket option `identity`. Available from libzmq 2.0.0. */ native static void __setIdentity (long self, String identity); public void setIdentity (String identity) { __setIdentity (self, identity); } /* Get socket option `rate`. Available from libzmq 2.0.0. */ native static int __rate (long self); public int rate () { return __rate (self); } /* Set socket option `rate`. Available from libzmq 2.0.0. */ native static void __setRate (long self, int rate); public void setRate (int rate) { __setRate (self, rate); } /* Get socket option `recovery_ivl`. Available from libzmq 2.0.0. */ native static int __recoveryIvl (long self); public int recoveryIvl () { return __recoveryIvl (self); } /* Set socket option `recovery_ivl`. Available from libzmq 2.0.0. */ native static void __setRecoveryIvl (long self, int recoveryIvl); public void setRecoveryIvl (int recoveryIvl) { __setRecoveryIvl (self, recoveryIvl); } /* Get socket option `recovery_ivl_msec`. Available from libzmq 2.0.0 to 3.0.0. */ native static int __recoveryIvlMsec (long self); public int recoveryIvlMsec () { return __recoveryIvlMsec (self); } /* Set socket option `recovery_ivl_msec`. Available from libzmq 2.0.0 to 3.0.0. */ native static void __setRecoveryIvlMsec (long self, int recoveryIvlMsec); public void setRecoveryIvlMsec (int recoveryIvlMsec) { __setRecoveryIvlMsec (self, recoveryIvlMsec); } /* Get socket option `mcast_loop`. Available from libzmq 2.0.0 to 3.0.0. */ native static int __mcastLoop (long self); public int mcastLoop () { return __mcastLoop (self); } /* Set socket option `mcast_loop`. Available from libzmq 2.0.0 to 3.0.0. */ native static void __setMcastLoop (long self, int mcastLoop); public void setMcastLoop (int mcastLoop) { __setMcastLoop (self, mcastLoop); } /* Get socket option `rcvtimeo`. Available from libzmq 2.2.0. */ native static int __rcvtimeo (long self); public int rcvtimeo () { return __rcvtimeo (self); } /* Set socket option `rcvtimeo`. Available from libzmq 2.2.0. */ native static void __setRcvtimeo (long self, int rcvtimeo); public void setRcvtimeo (int rcvtimeo) { __setRcvtimeo (self, rcvtimeo); } /* Get socket option `sndtimeo`. Available from libzmq 2.2.0. */ native static int __sndtimeo (long self); public int sndtimeo () { return __sndtimeo (self); } /* Set socket option `sndtimeo`. Available from libzmq 2.2.0. */ native static void __setSndtimeo (long self, int sndtimeo); public void setSndtimeo (int sndtimeo) { __setSndtimeo (self, sndtimeo); } /* Get socket option `sndbuf`. Available from libzmq 2.0.0. */ native static int __sndbuf (long self); public int sndbuf () { return __sndbuf (self); } /* Set socket option `sndbuf`. Available from libzmq 2.0.0. */ native static void __setSndbuf (long self, int sndbuf); public void setSndbuf (int sndbuf) { __setSndbuf (self, sndbuf); } /* Get socket option `rcvbuf`. Available from libzmq 2.0.0. */ native static int __rcvbuf (long self); public int rcvbuf () { return __rcvbuf (self); } /* Set socket option `rcvbuf`. Available from libzmq 2.0.0. */ native static void __setRcvbuf (long self, int rcvbuf); public void setRcvbuf (int rcvbuf) { __setRcvbuf (self, rcvbuf); } /* Get socket option `linger`. Available from libzmq 2.0.0. */ native static int __linger (long self); public int linger () { return __linger (self); } /* Set socket option `linger`. Available from libzmq 2.0.0. */ native static void __setLinger (long self, int linger); public void setLinger (int linger) { __setLinger (self, linger); } /* Get socket option `reconnect_ivl`. Available from libzmq 2.0.0. */ native static int __reconnectIvl (long self); public int reconnectIvl () { return __reconnectIvl (self); } /* Set socket option `reconnect_ivl`. Available from libzmq 2.0.0. */ native static void __setReconnectIvl (long self, int reconnectIvl); public void setReconnectIvl (int reconnectIvl) { __setReconnectIvl (self, reconnectIvl); } /* Get socket option `reconnect_ivl_max`. Available from libzmq 2.0.0. */ native static int __reconnectIvlMax (long self); public int reconnectIvlMax () { return __reconnectIvlMax (self); } /* Set socket option `reconnect_ivl_max`. Available from libzmq 2.0.0. */ native static void __setReconnectIvlMax (long self, int reconnectIvlMax); public void setReconnectIvlMax (int reconnectIvlMax) { __setReconnectIvlMax (self, reconnectIvlMax); } /* Get socket option `backlog`. Available from libzmq 2.0.0. */ native static int __backlog (long self); public int backlog () { return __backlog (self); } /* Set socket option `backlog`. Available from libzmq 2.0.0. */ native static void __setBacklog (long self, int backlog); public void setBacklog (int backlog) { __setBacklog (self, backlog); } /* Set socket option `subscribe`. Available from libzmq 2.0.0. */ native static void __setSubscribe (long self, String subscribe); public void setSubscribe (String subscribe) { __setSubscribe (self, subscribe); } /* Set socket option `unsubscribe`. Available from libzmq 2.0.0. */ native static void __setUnsubscribe (long self, String unsubscribe); public void setUnsubscribe (String unsubscribe) { __setUnsubscribe (self, unsubscribe); } /* Get socket option `type`. Available from libzmq 2.0.0. */ native static int __type (long self); public int type () { return __type (self); } /* Get socket option `rcvmore`. Available from libzmq 2.0.0. */ native static int __rcvmore (long self); public int rcvmore () { return __rcvmore (self); } /* Get socket option `events`. Available from libzmq 2.0.0. */ native static int __events (long self); public int events () { return __events (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zlist.java0000664000372000037200000001243113222211156025423 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zlist implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new list container */ native static long __new (); public Zlist () { /* TODO: if __new fails, self is null... */ self = __new (); } public Zlist (long pointer) { self = pointer; } /* Destroy a list container */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Return the item at the head of list. If the list is empty, returns NULL. Leaves cursor pointing at the head item, or NULL if the list is empty. */ native static long __first (long self); public long first () { return __first (self); } /* Return the next item. If the list is empty, returns NULL. To move to the start of the list call zlist_first (). Advances the cursor. */ native static long __next (long self); public long next () { return __next (self); } /* Return the item at the tail of list. If the list is empty, returns NULL. Leaves cursor pointing at the tail item, or NULL if the list is empty. */ native static long __last (long self); public long last () { return __last (self); } /* Return first item in the list, or null, leaves the cursor */ native static long __head (long self); public long head () { return __head (self); } /* Return last item in the list, or null, leaves the cursor */ native static long __tail (long self); public long tail () { return __tail (self); } /* Return the current item of list. If the list is empty, returns NULL. Leaves cursor pointing at the current item, or NULL if the list is empty. */ native static long __item (long self); public long item () { return __item (self); } /* Append an item to the end of the list, return 0 if OK or -1 if this failed for some reason (out of memory). Note that if a duplicator has been set, this method will also duplicate the item. */ native static int __append (long self, long item); public int append (long item) { return __append (self, item); } /* Push an item to the start of the list, return 0 if OK or -1 if this failed for some reason (out of memory). Note that if a duplicator has been set, this method will also duplicate the item. */ native static int __push (long self, long item); public int push (long item) { return __push (self, item); } /* Pop the item off the start of the list, if any */ native static long __pop (long self); public long pop () { return __pop (self); } /* Checks if an item already is present. Uses compare method to determine if items are equal. If the compare method is NULL the check will only compare pointers. Returns true if item is present else false. */ native static boolean __exists (long self, long item); public boolean exists (long item) { return __exists (self, item); } /* Remove the specified item from the list if present */ native static void __remove (long self, long item); public void remove (long item) { __remove (self, item); } /* Make a copy of list. If the list has autofree set, the copied list will duplicate all items, which must be strings. Otherwise, the list will hold pointers back to the items in the original list. If list is null, returns NULL. */ native static long __dup (long self); public Zlist dup () { return new Zlist (__dup (self)); } /* Purge all items from list */ native static void __purge (long self); public void purge () { __purge (self); } /* Return number of items in the list */ native static long __size (long self); public long size () { return __size (self); } /* Set list for automatic item destruction; item values MUST be strings. By default a list item refers to a value held elsewhere. When you set this, each time you append or push a list item, zlist will take a copy of the string value. Then, when you destroy the list, it will free all item values automatically. If you use any other technique to allocate list values, you must free them explicitly before destroying the list. The usual technique is to pop list items and destroy them, until the list is empty. */ native static void __autofree (long self); public void autofree () { __autofree (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zhash.java0000664000372000037200000001716613222211156025405 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zhash implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new, empty hash container */ native static long __new (); public Zhash () { /* TODO: if __new fails, self is null... */ self = __new (); } public Zhash (long pointer) { self = pointer; } /* Unpack binary frame into a new hash table. Packed data must follow format defined by zhash_pack. Hash table is set to autofree. An empty frame unpacks to an empty hash table. */ native static long __unpack (long frame); public static Zhash unpack (Zframe frame) { return new Zhash (__unpack (frame.self)); } /* Destroy a hash container and all items in it */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Insert item into hash table with specified key and item. If key is already present returns -1 and leaves existing item unchanged Returns 0 on success. */ native static int __insert (long self, String key, long item); public int insert (String key, long item) { return __insert (self, key, item); } /* Update item into hash table with specified key and item. If key is already present, destroys old item and inserts new one. Use free_fn method to ensure deallocator is properly called on item. */ native static void __update (long self, String key, long item); public void update (String key, long item) { __update (self, key, item); } /* Remove an item specified by key from the hash table. If there was no such item, this function does nothing. */ native static void __delete (long self, String key); public void delete (String key) { __delete (self, key); } /* Return the item at the specified key, or null */ native static long __lookup (long self, String key); public long lookup (String key) { return __lookup (self, key); } /* Reindexes an item from an old key to a new key. If there was no such item, does nothing. Returns 0 if successful, else -1. */ native static int __rename (long self, String oldKey, String newKey); public int rename (String oldKey, String newKey) { return __rename (self, oldKey, newKey); } /* Return the number of keys/items in the hash table */ native static long __size (long self); public long size () { return __size (self); } /* Make copy of hash table; if supplied table is null, returns null. Does not copy items themselves. Rebuilds new table so may be slow on very large tables. NOTE: only works with item values that are strings since there's no other way to know how to duplicate the item value. */ native static long __dup (long self); public Zhash dup () { return new Zhash (__dup (self)); } /* Return keys for items in table */ native static long __keys (long self); public Zlist keys () { return new Zlist (__keys (self)); } /* Simple iterator; returns first item in hash table, in no given order, or NULL if the table is empty. This method is simpler to use than the foreach() method, which is deprecated. To access the key for this item use zhash_cursor(). NOTE: do NOT modify the table while iterating. */ native static long __first (long self); public long first () { return __first (self); } /* Simple iterator; returns next item in hash table, in no given order, or NULL if the last item was already returned. Use this together with zhash_first() to process all items in a hash table. If you need the items in sorted order, use zhash_keys() and then zlist_sort(). To access the key for this item use zhash_cursor(). NOTE: do NOT modify the table while iterating. */ native static long __next (long self); public long next () { return __next (self); } /* After a successful first/next method, returns the key for the item that was returned. This is a constant string that you may not modify or deallocate, and which lasts as long as the item in the hash. After an unsuccessful first/next, returns NULL. */ native static String __cursor (long self); public String cursor () { return __cursor (self); } /* Add a comment to hash table before saving to disk. You can add as many comment lines as you like. These comment lines are discarded when loading the file. If you use a null format, all comments are deleted. */ native static void __comment (long self, String format); public void comment (String format) { __comment (self, format); } /* Serialize hash table to a binary frame that can be sent in a message. The packed format is compatible with the 'dictionary' type defined in http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: ; A list of name/value pairs dictionary = dict-count *( dict-name dict-value ) dict-count = number-4 dict-value = longstr dict-name = string ; Strings are always length + text contents longstr = number-4 *VCHAR string = number-1 *VCHAR ; Numbers are unsigned integers in network byte order number-1 = 1OCTET number-4 = 4OCTET Comments are not included in the packed data. Item values MUST be strings. */ native static long __pack (long self); public Zframe pack () { return new Zframe (__pack (self)); } /* Save hash table to a text file in name=value format. Hash values must be printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file error occurred. */ native static int __save (long self, String filename); public int save (String filename) { return __save (self, filename); } /* Load hash table from a text file in name=value format; hash table must already exist. Hash values must printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file was not readable. */ native static int __load (long self, String filename); public int load (String filename) { return __load (self, filename); } /* When a hash table was loaded from a file by zhash_load, this method will reload the file if it has been modified since, and is "stable", i.e. not still changing. Returns 0 if OK, -1 if there was an error reloading the file. */ native static int __refresh (long self); public int refresh () { return __refresh (self); } /* Set hash for automatic value destruction. Note that this assumes that values are NULL-terminated strings. Do not use with different types. */ native static void __autofree (long self); public void autofree () { __autofree (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zconfig.java0000664000372000037200000001666313222211156025730 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zconfig implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create new config item */ native static long __new (String name, long parent); public Zconfig (String name, Zconfig parent) { /* TODO: if __new fails, self is null... */ self = __new (name, parent.self); } public Zconfig (long pointer) { self = pointer; } /* Load a config tree from a specified ZPL text file; returns a zconfig_t reference for the root, if the file exists and is readable. Returns NULL if the file does not exist. */ native static long __load (String filename); public static Zconfig load (String filename) { return new Zconfig (__load (filename)); } /* Equivalent to zconfig_load, taking a format string instead of a fixed filename. */ native static long __loadf (String format); public static Zconfig loadf (String format) { return new Zconfig (__loadf (format)); } /* Destroy a config item and all its children */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Return name of config item */ native static String __name (long self); public String name () { return __name (self); } /* Return value of config item */ native static String __value (long self); public String value () { return __value (self); } /* Insert or update configuration key with value */ native static void __put (long self, String path, String value); public void put (String path, String value) { __put (self, path, value); } /* Equivalent to zconfig_put, accepting a format specifier and variable argument list, instead of a single string value. */ native static void __putf (long self, String path, String format); public void putf (String path, String format) { __putf (self, path, format); } /* Get value for config item into a string value; leading slash is optional and ignored. */ native static String __get (long self, String path, String defaultValue); public String get (String path, String defaultValue) { return __get (self, path, defaultValue); } /* Set config item name, name may be NULL */ native static void __setName (long self, String name); public void setName (String name) { __setName (self, name); } /* Set new value for config item. The new value may be a string, a printf format, or NULL. Note that if string may possibly contain '%', or if it comes from an insecure source, you must use '%s' as the format, followed by the string. */ native static void __setValue (long self, String format); public void setValue (String format) { __setValue (self, format); } /* Find our first child, if any */ native static long __child (long self); public Zconfig child () { return new Zconfig (__child (self)); } /* Find our first sibling, if any */ native static long __next (long self); public Zconfig next () { return new Zconfig (__next (self)); } /* Find a config item along a path; leading slash is optional and ignored. */ native static long __locate (long self, String path); public Zconfig locate (String path) { return new Zconfig (__locate (self, path)); } /* Locate the last config item at a specified depth */ native static long __atDepth (long self, int level); public Zconfig atDepth (int level) { return new Zconfig (__atDepth (self, level)); } /* Add comment to config item before saving to disk. You can add as many comment lines as you like. If you use a null format, all comments are deleted. */ native static void __setComment (long self, String format); public void setComment (String format) { __setComment (self, format); } /* Return comments of config item, as zlist. */ native static long __comments (long self); public Zlist comments () { return new Zlist (__comments (self)); } /* Save a config tree to a specified ZPL text file, where a filename "-" means dump to standard output. */ native static int __save (long self, String filename); public int save (String filename) { return __save (self, filename); } /* Equivalent to zconfig_save, taking a format string instead of a fixed filename. */ native static int __savef (long self, String format); public int savef (String format) { return __savef (self, format); } /* Report filename used during zconfig_load, or NULL if none */ native static String __filename (long self); public String filename () { return __filename (self); } /* Reload config tree from same file that it was previously loaded from. Returns 0 if OK, -1 if there was an error (and then does not change existing data). */ native static long __reload (long self); public int reload () { self = __reload (self); return 0; } /* Load a config tree from a memory chunk */ native static long __chunkLoad (long chunk); public Zconfig chunkLoad (Zchunk chunk) { return new Zconfig (__chunkLoad (chunk.self)); } /* Save a config tree to a new memory chunk */ native static long __chunkSave (long self); public Zchunk chunkSave () { return new Zchunk (__chunkSave (self)); } /* Load a config tree from a null-terminated string */ native static long __strLoad (String string); public Zconfig strLoad (String string) { return new Zconfig (__strLoad (string)); } /* Save a config tree to a new null terminated string */ native static String __strSave (long self); public String strSave () { return __strSave (self); } /* Return true if a configuration tree was loaded from a file and that file has changed in since the tree was loaded. */ native static boolean __hasChanged (long self); public boolean hasChanged () { return __hasChanged (self); } /* Destroy subtree (all children) */ native static void __removeSubtree (long self); public void removeSubtree () { __removeSubtree (self); } /* Destroy node and subtree (all children) WARNING: manually fixed void -> long */ native static long __remove (long self); public long remove () { self = __remove (self); return 0; } /* Print properties of object */ native static void __print (long self); public void print () { __print (self); } /* Self test of this class */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zdir.java0000664000372000037200000001150213222211156025224 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zdir implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new directory item that loads in the full tree of the specified path, optionally located under some parent path. If parent is "-", then loads only the top-level directory, and does not use parent as a path. */ native static long __new (String path, String parent); public Zdir (String path, String parent) { /* TODO: if __new fails, self is null... */ self = __new (path, parent); } public Zdir (long pointer) { self = pointer; } /* Destroy a directory tree and all children it contains. */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Return directory path */ native static String __path (long self); public String path () { return __path (self); } /* Return last modification time for directory. */ native static long __modified (long self); public long modified () { return __modified (self); } /* Return total hierarchy size, in bytes of data contained in all files in the directory tree. */ native static long __cursize (long self); public long cursize () { return __cursize (self); } /* Return directory count */ native static long __count (long self); public long count () { return __count (self); } /* Returns a sorted list of zfile objects; Each entry in the list is a pointer to a zfile_t item already allocated in the zdir tree. Do not destroy the original zdir tree until you are done with this list. */ native static long __list (long self); public Zlist list () { return new Zlist (__list (self)); } /* Remove directory, optionally including all files that it contains, at all levels. If force is false, will only remove the directory if empty. If force is true, will remove all files and all subdirectories. */ native static void __remove (long self, boolean force); public void remove (boolean force) { __remove (self, force); } /* Calculate differences between two versions of a directory tree. Returns a list of zdir_patch_t patches. Either older or newer may be null, indicating the directory is empty/absent. If alias is set, generates virtual filename (minus path, plus alias). */ native static long __diff (long older, long newer, String alias); public Zlist diff (Zdir older, Zdir newer, String alias) { return new Zlist (__diff (older.self, newer.self, alias)); } /* Return full contents of directory as a zdir_patch list. */ native static long __resync (long self, String alias); public Zlist resync (String alias) { return new Zlist (__resync (self, alias)); } /* Load directory cache; returns a hash table containing the SHA-1 digests of every file in the tree. The cache is saved between runs in .cache. */ native static long __cache (long self); public Zhash cache () { return new Zhash (__cache (self)); } /* Print contents of directory to stdout */ native static void __print (long self, int indent); public void print (int indent) { __print (self, indent); } /* Create a new zdir_watch actor instance: zactor_t *watch = zactor_new (zdir_watch, NULL); Destroy zdir_watch instance: zactor_destroy (&watch); Enable verbose logging of commands and activity: zstr_send (watch, "VERBOSE"); Subscribe to changes to a directory path: zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); Unsubscribe from changes to a directory path: zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); Receive directory changes: zsock_recv (watch, "sp", &path, &patches); // Delete the received data. free (path); zlist_destroy (&patches); */ native static void __watch (long pipe, long unused); public void watch (Zsock pipe, long unused) { __watch (pipe.self, unused); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Ztimerset.java0000664000372000037200000000513613222211156026310 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Ztimerset implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create new timer set. */ native static long __new (); public Ztimerset () { /* TODO: if __new fails, self is null... */ self = __new (); } public Ztimerset (long pointer) { self = pointer; } /* Destroy a timer set */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Cancel a timer. Returns 0 if OK, -1 on failure. */ native static int __cancel (long self, int timerId); public int cancel (int timerId) { return __cancel (self, timerId); } /* Set timer interval. Returns 0 if OK, -1 on failure. This method is slow, canceling the timer and adding a new one yield better performance. */ native static int __setInterval (long self, int timerId, long interval); public int setInterval (int timerId, long interval) { return __setInterval (self, timerId, interval); } /* Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. This method is slow, canceling the timer and adding a new one yield better performance. */ native static int __reset (long self, int timerId); public int reset (int timerId) { return __reset (self, timerId); } /* Return the time until the next interval. Should be used as timeout parameter for the zpoller wait method. The timeout is in msec. */ native static int __timeout (long self); public int timeout () { return __timeout (self); } /* Invoke callback function of all timers which their interval has elapsed. Should be call after zpoller wait method. Returns 0 if OK, -1 on failure. */ native static int __execute (long self); public int execute () { return __execute (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zuuid.java0000664000372000037200000000671113222211156025422 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zuuid implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new UUID object. */ native static long __new (); public Zuuid () { /* TODO: if __new fails, self is null... */ self = __new (); } public Zuuid (long pointer) { self = pointer; } /* Create UUID object from supplied ZUUID_LEN-octet value. */ native static long __newFrom (byte [] source); public static Zuuid newFrom (byte [] source) { return new Zuuid (__newFrom (source)); } /* Destroy a specified UUID object. */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Set UUID to new supplied ZUUID_LEN-octet value. */ native static void __set (long self, byte [] source); public void set (byte [] source) { __set (self, source); } /* Set UUID to new supplied string value skipping '-' and '{' '}' optional delimiters. Return 0 if OK, else returns -1. */ native static int __setStr (long self, String source); public int setStr (String source) { return __setStr (self, source); } /* Return UUID binary data. */ native static byte [] __data (long self); public byte [] data () { return __data (self); } /* Return UUID binary size */ native static long __size (long self); public long size () { return __size (self); } /* Returns UUID as string */ native static String __str (long self); public String str () { return __str (self); } /* Return UUID in the canonical string format: 8-4-4-4-12, in lower case. Caller does not modify or free returned value. See http://en.wikipedia.org/wiki/Universally_unique_identifier */ native static String __strCanonical (long self); public String strCanonical () { return __strCanonical (self); } /* Store UUID blob in target array */ native static void __export (long self, byte [] target); public void export (byte [] target) { __export (self, target); } /* Check if UUID is same as supplied value */ native static boolean __eq (long self, byte [] compare); public boolean eq (byte [] compare) { return __eq (self, compare); } /* Check if UUID is different from supplied value */ native static boolean __neq (long self, byte [] compare); public boolean neq (byte [] compare) { return __neq (self, compare); } /* Make copy of UUID object; if uuid is null, or memory was exhausted, returns null. */ native static long __dup (long self); public Zuuid dup () { return new Zuuid (__dup (self)); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zmsg.java0000664000372000037200000002423013222211156025236 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zmsg implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new empty message object */ native static long __new (); public Zmsg () { /* TODO: if __new fails, self is null... */ self = __new (); } public Zmsg (long pointer) { self = pointer; } /* Receive message from socket, returns zmsg_t object or NULL if the recv was interrupted. Does a blocking recv. If you want to not block then use the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input before receiving. */ native static long __recv (long source); public static Zmsg recv (long source) { return new Zmsg (__recv (source)); } /* Decodes a serialized message frame created by zmsg_encode () and returns a new zmsg_t object. Returns NULL if the frame was badly formatted or there was insufficient memory to work. */ native static long __decode (long frame); public static Zmsg decode (Zframe frame) { return new Zmsg (__decode (frame.self)); } /* Generate a signal message encoding the given status. A signal is a short message carrying a 1-byte success/failure code (by convention, 0 means OK). Signals are encoded to be distinguishable from "normal" messages. */ native static long __newSignal (byte status); public static Zmsg newSignal (byte status) { return new Zmsg (__newSignal (status)); } /* Destroy a message object and all frames it contains */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Send message to destination socket, and destroy the message after sending it successfully. If the message has no frames, sends nothing but destroys the message anyhow. Nullifies the caller's reference to the message (as it is a destructor). */ native static long __send (long self, long dest); public int send (long dest) { self = __send (self, dest); return 0; } /* Send message to destination socket as part of a multipart sequence, and destroy the message after sending it successfully. Note that after a zmsg_sendm, you must call zmsg_send or another method that sends a final message part. If the message has no frames, sends nothing but destroys the message anyhow. Nullifies the caller's reference to the message (as it is a destructor). */ native static long __sendm (long self, long dest); public int sendm (long dest) { self = __sendm (self, dest); return 0; } /* Return size of message, i.e. number of frames (0 or more). */ native static long __size (long self); public long size () { return __size (self); } /* Return total size of all frames in message. */ native static long __contentSize (long self); public long contentSize () { return __contentSize (self); } /* Return message routing ID, if the message came from a ZMQ_SERVER socket. Else returns zero. */ native static int __routingId (long self); public int routingId () { return __routingId (self); } /* Set routing ID on message. This is used if/when the message is sent to a ZMQ_SERVER socket. */ native static void __setRoutingId (long self, int routingId); public void setRoutingId (int routingId) { __setRoutingId (self, routingId); } /* Push frame to the front of the message, i.e. before all other frames. Message takes ownership of frame, will destroy it when message is sent. Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not nullify the caller's frame reference. */ native static int __prepend (long self, long frameP); public int prepend (Zframe frameP) { return __prepend (self, frameP.self); } /* Add frame to the end of the message, i.e. after all other frames. Message takes ownership of frame, will destroy it when message is sent. Returns 0 on success. Deprecates zmsg_add, which did not nullify the caller's frame reference. */ native static int __append (long self, long frameP); public int append (Zframe frameP) { return __append (self, frameP.self); } /* Remove first frame from message, if any. Returns frame, or NULL. */ native static long __pop (long self); public Zframe pop () { return new Zframe (__pop (self)); } /* Push block of memory to front of message, as a new frame. Returns 0 on success, -1 on error. */ native static int __pushmem (long self, byte [] data, long size); public int pushmem (byte [] data, long size) { return __pushmem (self, data, size); } /* Add block of memory to the end of the message, as a new frame. Returns 0 on success, -1 on error. */ native static int __addmem (long self, byte [] data, long size); public int addmem (byte [] data, long size) { return __addmem (self, data, size); } /* Push string as new frame to front of message. Returns 0 on success, -1 on error. */ native static int __pushstr (long self, String string); public int pushstr (String string) { return __pushstr (self, string); } /* Push string as new frame to end of message. Returns 0 on success, -1 on error. */ native static int __addstr (long self, String string); public int addstr (String string) { return __addstr (self, string); } /* Push formatted string as new frame to front of message. Returns 0 on success, -1 on error. */ native static int __pushstrf (long self, String format); public int pushstrf (String format) { return __pushstrf (self, format); } /* Push formatted string as new frame to end of message. Returns 0 on success, -1 on error. */ native static int __addstrf (long self, String format); public int addstrf (String format) { return __addstrf (self, format); } /* Pop frame off front of message, return as fresh string. If there were no more frames in the message, returns NULL. */ native static String __popstr (long self); public String popstr () { return __popstr (self); } /* Push encoded message as a new frame. Message takes ownership of submessage, so the original is destroyed in this call. Returns 0 on success, -1 on error. */ native static int __addmsg (long self, long msgP); public int addmsg (Zmsg msgP) { return __addmsg (self, msgP.self); } /* Remove first submessage from message, if any. Returns zmsg_t, or NULL if decoding was not successful. */ native static long __popmsg (long self); public Zmsg popmsg () { return new Zmsg (__popmsg (self)); } /* Remove specified frame from list, if present. Does not destroy frame. */ native static void __remove (long self, long frame); public void remove (Zframe frame) { __remove (self, frame.self); } /* Set cursor to first frame in message. Returns frame, or NULL, if the message is empty. Use this to navigate the frames as a list. */ native static long __first (long self); public Zframe first () { return new Zframe (__first (self)); } /* Return the next frame. If there are no more frames, returns NULL. To move to the first frame call zmsg_first(). Advances the cursor. */ native static long __next (long self); public Zframe next () { return new Zframe (__next (self)); } /* Return the last frame. If there are no frames, returns NULL. */ native static long __last (long self); public Zframe last () { return new Zframe (__last (self)); } /* Serialize multipart message to a single message frame. Use this method to send structured messages across transports that do not support multipart data. Allocates and returns a new frame containing the serialized message. To decode a serialized message frame, use zmsg_decode (). */ native static long __encode (long self); public Zframe encode () { return new Zframe (__encode (self)); } /* Create copy of message, as new message object. Returns a fresh zmsg_t object. If message is null, or memory was exhausted, returns null. */ native static long __dup (long self); public Zmsg dup () { return new Zmsg (__dup (self)); } /* Send message to zsys log sink (may be stdout, or system facility as configured by zsys_set_logstream). */ native static void __print (long self); public void print () { __print (self); } /* Return true if the two messages have the same number of frames and each frame in the first message is identical to the corresponding frame in the other message. As with zframe_eq, return false if either message is NULL. */ native static boolean __eq (long self, long other); public boolean eq (Zmsg other) { return __eq (self, other.self); } /* Return signal value, 0 or greater, if message is a signal, -1 if not. */ native static int __signal (long self); public int signal () { return __signal (self); } /* Probe the supplied object, and report if it looks like a zmsg_t. */ native static boolean __is (long self); public boolean is (long self) { return __is (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zclock.java0000664000372000037200000000400213222211156025536 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zclock { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Sleep for a number of milliseconds */ native static void __sleep (int msecs); public void sleep (int msecs) { __sleep (msecs); } /* Return current system clock as milliseconds. Note that this clock can jump backwards (if the system clock is changed) so is unsafe to use for timers and time offsets. Use zclock_mono for that instead. */ native static long __time (); public long time () { return __time (); } /* Return current monotonic clock in milliseconds. Use this when you compute time offsets. The monotonic clock is not affected by system changes and so will never be reset backwards, unlike a system clock. */ native static long __mono (); public long mono () { return __mono (); } /* Return current monotonic clock in microseconds. Use this when you compute time offsets. The monotonic clock is not affected by system changes and so will never be reset backwards, unlike a system clock. */ native static long __usecs (); public long usecs () { return __usecs (); } /* Return formatted date/time as fresh string. Free using zstr_free(). */ native static String __timestr (); public String timestr () { return __timestr (); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zhashx.java0000664000372000037200000002125413222211156025566 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zhashx implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new, empty hash container */ native static long __new (); public Zhashx () { /* TODO: if __new fails, self is null... */ self = __new (); } public Zhashx (long pointer) { self = pointer; } /* Unpack binary frame into a new hash table. Packed data must follow format defined by zhashx_pack. Hash table is set to autofree. An empty frame unpacks to an empty hash table. */ native static long __unpack (long frame); public static Zhashx unpack (Zframe frame) { return new Zhashx (__unpack (frame.self)); } /* Destroy a hash container and all items in it */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Insert item into hash table with specified key and item. If key is already present returns -1 and leaves existing item unchanged Returns 0 on success. */ native static int __insert (long self, long key, long item); public int insert (long key, long item) { return __insert (self, key, item); } /* Update or insert item into hash table with specified key and item. If the key is already present, destroys old item and inserts new one. If you set a container item destructor, this is called on the old value. If the key was not already present, inserts a new item. Sets the hash cursor to the new item. */ native static void __update (long self, long key, long item); public void update (long key, long item) { __update (self, key, item); } /* Remove an item specified by key from the hash table. If there was no such item, this function does nothing. */ native static void __delete (long self, long key); public void delete (long key) { __delete (self, key); } /* Delete all items from the hash table. If the key destructor is set, calls it on every key. If the item destructor is set, calls it on every item. */ native static void __purge (long self); public void purge () { __purge (self); } /* Return the item at the specified key, or null */ native static long __lookup (long self, long key); public long lookup (long key) { return __lookup (self, key); } /* Reindexes an item from an old key to a new key. If there was no such item, does nothing. Returns 0 if successful, else -1. */ native static int __rename (long self, long oldKey, long newKey); public int rename (long oldKey, long newKey) { return __rename (self, oldKey, newKey); } /* Return the number of keys/items in the hash table */ native static long __size (long self); public long size () { return __size (self); } /* Return a zlistx_t containing the keys for the items in the table. Uses the key_duplicator to duplicate all keys and sets the key_destructor as destructor for the list. */ native static long __keys (long self); public Zlistx keys () { return new Zlistx (__keys (self)); } /* Return a zlistx_t containing the values for the items in the table. Uses the duplicator to duplicate all items and sets the destructor as destructor for the list. */ native static long __values (long self); public Zlistx values () { return new Zlistx (__values (self)); } /* Simple iterator; returns first item in hash table, in no given order, or NULL if the table is empty. This method is simpler to use than the foreach() method, which is deprecated. To access the key for this item use zhashx_cursor(). NOTE: do NOT modify the table while iterating. */ native static long __first (long self); public long first () { return __first (self); } /* Simple iterator; returns next item in hash table, in no given order, or NULL if the last item was already returned. Use this together with zhashx_first() to process all items in a hash table. If you need the items in sorted order, use zhashx_keys() and then zlistx_sort(). To access the key for this item use zhashx_cursor(). NOTE: do NOT modify the table while iterating. */ native static long __next (long self); public long next () { return __next (self); } /* After a successful first/next method, returns the key for the item that was returned. This is a constant string that you may not modify or deallocate, and which lasts as long as the item in the hash. After an unsuccessful first/next, returns NULL. */ native static long __cursor (long self); public long cursor () { return __cursor (self); } /* Add a comment to hash table before saving to disk. You can add as many comment lines as you like. These comment lines are discarded when loading the file. If you use a null format, all comments are deleted. */ native static void __comment (long self, String format); public void comment (String format) { __comment (self, format); } /* Save hash table to a text file in name=value format. Hash values must be printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file error occurred. */ native static int __save (long self, String filename); public int save (String filename) { return __save (self, filename); } /* Load hash table from a text file in name=value format; hash table must already exist. Hash values must printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file was not readable. */ native static int __load (long self, String filename); public int load (String filename) { return __load (self, filename); } /* When a hash table was loaded from a file by zhashx_load, this method will reload the file if it has been modified since, and is "stable", i.e. not still changing. Returns 0 if OK, -1 if there was an error reloading the file. */ native static int __refresh (long self); public int refresh () { return __refresh (self); } /* Serialize hash table to a binary frame that can be sent in a message. The packed format is compatible with the 'dictionary' type defined in http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: ; A list of name/value pairs dictionary = dict-count *( dict-name dict-value ) dict-count = number-4 dict-value = longstr dict-name = string ; Strings are always length + text contents longstr = number-4 *VCHAR string = number-1 *VCHAR ; Numbers are unsigned integers in network byte order number-1 = 1OCTET number-4 = 4OCTET Comments are not included in the packed data. Item values MUST be strings. */ native static long __pack (long self); public Zframe pack () { return new Zframe (__pack (self)); } /* Make a copy of the list; items are duplicated if you set a duplicator for the list, otherwise not. Copying a null reference returns a null reference. Note that this method's behavior changed slightly for CZMQ v3.x, as it does not set nor respect autofree. It does however let you duplicate any hash table safely. The old behavior is in zhashx_dup_v2. */ native static long __dup (long self); public Zhashx dup () { return new Zhashx (__dup (self)); } /* Make copy of hash table; if supplied table is null, returns null. Does not copy items themselves. Rebuilds new table so may be slow on very large tables. NOTE: only works with item values that are strings since there's no other way to know how to duplicate the item value. */ native static long __dupV2 (long self); public Zhashx dupV2 () { return new Zhashx (__dupV2 (self)); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Ziflist.java0000664000372000037200000000635613222211156025753 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Ziflist implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Get a list of network interfaces currently defined on the system */ native static long __new (); public Ziflist () { /* TODO: if __new fails, self is null... */ self = __new (); } public Ziflist (long pointer) { self = pointer; } /* Destroy a ziflist instance */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Reload network interfaces from system */ native static void __reload (long self); public void reload () { __reload (self); } /* Return the number of network interfaces on system */ native static long __size (long self); public long size () { return __size (self); } /* Get first network interface, return NULL if there are none */ native static String __first (long self); public String first () { return __first (self); } /* Get next network interface, return NULL if we hit the last one */ native static String __next (long self); public String next () { return __next (self); } /* Return the current interface IP address as a printable string */ native static String __address (long self); public String address () { return __address (self); } /* Return the current interface broadcast address as a printable string */ native static String __broadcast (long self); public String broadcast () { return __broadcast (self); } /* Return the current interface network mask as a printable string */ native static String __netmask (long self); public String netmask () { return __netmask (self); } /* Return the list of interfaces. */ native static void __print (long self); public void print () { __print (self); } /* Get a list of network interfaces currently defined on the system Includes IPv6 interfaces */ native static long __newIpv6 (); public Ziflist newIpv6 () { return new Ziflist (__newIpv6 ()); } /* Reload network interfaces from system, including IPv6 */ native static void __reloadIpv6 (long self); public void reloadIpv6 () { __reloadIpv6 (self); } /* Return true if the current interface uses IPv6 */ native static boolean __isIpv6 (long self); public boolean isIpv6 () { return __isIpv6 (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zproc.java0000664000372000037200000002543113222211156025417 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zproc implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new zproc. NOTE: On Windows and with libzmq3 and libzmq2 this function returns NULL. Code needs to be ported there. */ native static long __new (); public Zproc () { /* TODO: if __new fails, self is null... */ self = __new (); } public Zproc (long pointer) { self = pointer; } /* Destroy zproc, wait until process ends. */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Setup the command line arguments, the first item must be an (absolute) filename to run. */ native static void __setArgs (long self, long args); public void setArgs (Zlistx args) { __setArgs (self, args.self); } /* Setup the environment variables for the process. */ native static void __setEnv (long self, long args); public void setEnv (Zhashx args) { __setEnv (self, args.self); } /* Connects process stdin with a readable ('>', connect) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The writable one is then accessbile via zproc_stdin method. */ native static void __setStdin (long self, long socket); public void setStdin (long socket) { __setStdin (self, socket); } /* Connects process stdout with a writable ('@', bind) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The readable one is then accessbile via zproc_stdout method. */ native static void __setStdout (long self, long socket); public void setStdout (long socket) { __setStdout (self, socket); } /* Connects process stderr with a writable ('@', bind) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The readable one is then accessbile via zproc_stderr method. */ native static void __setStderr (long self, long socket); public void setStderr (long socket) { __setStderr (self, socket); } /* Return subprocess stdin writable socket. NULL for not initialized or external sockets. */ native static long __stdin (long self); public long stdin () { return __stdin (self); } /* Return subprocess stdout readable socket. NULL for not initialized or external sockets. */ native static long __stdout (long self); public long stdout () { return __stdout (self); } /* Return subprocess stderr readable socket. NULL for not initialized or external sockets. */ native static long __stderr (long self); public long stderr () { return __stderr (self); } /* Starts the process. */ native static int __run (long self); public int run () { return __run (self); } /* process exit code */ native static int __returncode (long self); public int returncode () { return __returncode (self); } /* PID of the process */ native static int __pid (long self); public int pid () { return __pid (self); } /* return true if process is running, false if not yet started or finished */ native static boolean __running (long self); public boolean running () { return __running (self); } /* wait or poll process status, return return code */ native static int __wait (long self, boolean hang); public int Wait (boolean hang) { return __wait (self, hang); } /* return internal actor, usefull for the polling if process died */ native static long __actor (long self); public long actor () { return __actor (self); } /* send a signal to the subprocess */ native static void __kill (long self, int signal); public void kill (int signal) { __kill (self, signal); } /* set verbose mode */ native static void __setVerbose (long self, boolean verbose); public void setVerbose (boolean verbose) { __setVerbose (self, verbose); } /* Returns CZMQ version as a single 6-digit integer encoding the major version (x 10000), the minor version (x 100) and the patch. */ native static int __czmqVersion (); public int czmqVersion () { return __czmqVersion (); } /* Returns true if the process received a SIGINT or SIGTERM signal. It is good practice to use this method to exit any infinite loop processing messages. */ native static boolean __interrupted (); public boolean interrupted () { return __interrupted (); } /* Returns true if the underlying libzmq supports CURVE security. */ native static boolean __hasCurve (); public boolean hasCurve () { return __hasCurve (); } /* Return current host name, for use in public tcp:// endpoints. If the host name is not resolvable, returns NULL. */ native static String __hostname (); public String hostname () { return __hostname (); } /* Move the current process into the background. The precise effect depends on the operating system. On POSIX boxes, moves to a specified working directory (if specified), closes all file handles, reopens stdin, stdout, and stderr to the null device, and sets the process to ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there was an error. */ native static void __daemonize (String workdir); public void daemonize (String workdir) { __daemonize (workdir); } /* Drop the process ID into the lockfile, with exclusive lock, and switch the process to the specified group and/or user. Any of the arguments may be null, indicating a no-op. Returns 0 on success, -1 on failure. Note if you combine this with zsys_daemonize, run after, not before that method, or the lockfile will hold the wrong process ID. */ native static void __runAs (String lockfile, String group, String user); public void runAs (String lockfile, String group, String user) { __runAs (lockfile, group, user); } /* Configure the number of I/O threads that ZeroMQ will use. A good rule of thumb is one thread per gigabit of traffic in or out. The default is 1, sufficient for most applications. If the environment variable ZSYS_IO_THREADS is defined, that provides the default. Note that this method is valid only before any socket is created. */ native static void __setIoThreads (long ioThreads); public void setIoThreads (long ioThreads) { __setIoThreads (ioThreads); } /* Configure the number of sockets that ZeroMQ will allow. The default is 1024. The actual limit depends on the system, and you can query it by using zsys_socket_limit (). A value of zero means "maximum". Note that this method is valid only before any socket is created. */ native static void __setMaxSockets (long maxSockets); public void setMaxSockets (long maxSockets) { __setMaxSockets (maxSockets); } /* Set network interface name to use for broadcasts, particularly zbeacon. This lets the interface be configured for test environments where required. For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is the default when there is no specified interface. If the environment variable ZSYS_INTERFACE is set, use that as the default interface name. Setting the interface to "*" means "use all available interfaces". */ native static void __setBiface (String value); public void setBiface (String value) { __setBiface (value); } /* Return network interface to use for broadcasts, or "" if none was set. */ native static String __biface (); public String biface () { return __biface (); } /* Set log identity, which is a string that prefixes all log messages sent by this process. The log identity defaults to the environment variable ZSYS_LOGIDENT, if that is set. */ native static void __setLogIdent (String value); public void setLogIdent (String value) { __setLogIdent (value); } /* Sends log output to a PUB socket bound to the specified endpoint. To collect such log output, create a SUB socket, subscribe to the traffic you care about, and connect to the endpoint. Log traffic is sent as a single string frame, in the same format as when sent to stdout. The log system supports a single sender; multiple calls to this method will bind the same sender to multiple endpoints. To disable the sender, call this method with a null argument. */ native static void __setLogSender (String endpoint); public void setLogSender (String endpoint) { __setLogSender (endpoint); } /* Enable or disable logging to the system facility (syslog on POSIX boxes, event log on Windows). By default this is disabled. */ native static void __setLogSystem (boolean logsystem); public void setLogSystem (boolean logsystem) { __setLogSystem (logsystem); } /* Log error condition - highest priority */ native static void __logError (String format); public void logError (String format) { __logError (format); } /* Log warning condition - high priority */ native static void __logWarning (String format); public void logWarning (String format) { __logWarning (format); } /* Log normal, but significant, condition - normal priority */ native static void __logNotice (String format); public void logNotice (String format) { __logNotice (format); } /* Log informational message - low priority */ native static void __logInfo (String format); public void logInfo (String format) { __logInfo (format); } /* Log debug-level message - lowest priority */ native static void __logDebug (String format); public void logDebug (String format) { __logDebug (format); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zcertstore.java0000664000372000037200000000615013222211156026463 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zcertstore implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new certificate store from a disk directory, loading and indexing all certificates in that location. The directory itself may be absent, and created later, or modified at any time. The certificate store is automatically refreshed on any zcertstore_lookup() call. If the location is specified as NULL, creates a pure-memory store, which you can work with by inserting certificates at runtime. */ native static long __new (String location); public Zcertstore (String location) { /* TODO: if __new fails, self is null... */ self = __new (location); } public Zcertstore (long pointer) { self = pointer; } /* Destroy a certificate store object in memory. Does not affect anything stored on disk. */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Look up certificate by public key, returns zcert_t object if found, else returns NULL. The public key is provided in Z85 text format. */ native static long __lookup (long self, String publicKey); public Zcert lookup (String publicKey) { return new Zcert (__lookup (self, publicKey)); } /* Insert certificate into certificate store in memory. Note that this does not save the certificate to disk. To do that, use zcert_save() directly on the certificate. Takes ownership of zcert_t object. */ native static void __insert (long self, long certP); public void insert (Zcert certP) { __insert (self, certP.self); } /* Empty certificate hashtable. This wrapper exists to be friendly to bindings, which don't usually have access to struct internals. */ native static void __empty (long self); public void empty () { __empty (self); } /* Print list of certificates in store to logging facility */ native static void __print (long self); public void print () { __print (self); } /* Return a list of all the certificates in the store. The caller takes ownership of the zlistx_t object and is responsible for destroying it. The caller does not take ownership of the zcert_t objects. */ native static long __certs (long self); public Zlistx certs () { return new Zlistx (__certs (self)); } /* Self test of this class */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Ztrie.java0000664000372000037200000000600213222211156025410 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Ztrie implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Creates a new ztrie. */ native static long __new (char delimiter); public Ztrie (char delimiter) { /* TODO: if __new fails, self is null... */ self = __new (delimiter); } public Ztrie (long pointer) { self = pointer; } /* Destroy the ztrie. */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Removes a route from the trie and destroys its data. Returns -1 if the route does not exists, otherwise 0. the start of the list call zlist_first (). Advances the cursor. */ native static int __removeRoute (long self, String path); public int removeRoute (String path) { return __removeRoute (self, path); } /* Returns true if the path matches a route in the tree, otherwise false. */ native static boolean __matches (long self, String path); public boolean matches (String path) { return __matches (self, path); } /* Returns the data of a matched route from last ztrie_matches. If the path did not match, returns NULL. Do not delete the data as it's owned by ztrie. */ native static long __hitData (long self); public long hitData () { return __hitData (self); } /* Returns the count of parameters that a matched route has. */ native static long __hitParameterCount (long self); public long hitParameterCount () { return __hitParameterCount (self); } /* Returns the parameters of a matched route with named regexes from last ztrie_matches. If the path did not match or the route did not contain any named regexes, returns NULL. */ native static long __hitParameters (long self); public Zhashx hitParameters () { return new Zhashx (__hitParameters (self)); } /* Returns the asterisk matched part of a route, if there has been no match or no asterisk match, returns NULL. */ native static String __hitAsteriskMatch (long self); public String hitAsteriskMatch () { return __hitAsteriskMatch (self); } /* Print the trie */ native static void __print (long self); public void print () { __print (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zloop.java0000664000372000037200000001103313222211156025416 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zloop implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new zloop reactor */ native static long __new (); public Zloop () { /* TODO: if __new fails, self is null... */ self = __new (); } public Zloop (long pointer) { self = pointer; } /* Destroy a reactor */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Cancel a socket reader from the reactor. If multiple readers exist for same socket, cancels ALL of them. */ native static void __readerEnd (long self, long sock); public void readerEnd (Zsock sock) { __readerEnd (self, sock.self); } /* Configure a registered reader to ignore errors. If you do not set this, then readers that have errors are removed from the reactor silently. */ native static void __readerSetTolerant (long self, long sock); public void readerSetTolerant (Zsock sock) { __readerSetTolerant (self, sock.self); } /* Cancel a specific timer identified by a specific timer_id (as returned by zloop_timer). */ native static int __timerEnd (long self, int timerId); public int timerEnd (int timerId) { return __timerEnd (self, timerId); } /* Reset a ticket timer, which moves it to the end of the ticket list and resets its execution time. This is a very fast operation. */ native static void __ticketReset (long self, long handle); public void ticketReset (long handle) { __ticketReset (self, handle); } /* Delete a ticket timer. We do not actually delete the ticket here, as other code may still refer to the ticket. We mark as deleted, and remove later and safely. */ native static void __ticketDelete (long self, long handle); public void ticketDelete (long handle) { __ticketDelete (self, handle); } /* Set the ticket delay, which applies to all tickets. If you lower the delay and there are already tickets created, the results are undefined. */ native static void __setTicketDelay (long self, long ticketDelay); public void setTicketDelay (long ticketDelay) { __setTicketDelay (self, ticketDelay); } /* Set hard limit on number of timers allowed. Setting more than a small number of timers (10-100) can have a dramatic impact on the performance of the reactor. For high-volume cases, use ticket timers. If the hard limit is reached, the reactor stops creating new timers and logs an error. */ native static void __setMaxTimers (long self, long maxTimers); public void setMaxTimers (long maxTimers) { __setMaxTimers (self, maxTimers); } /* Set verbose tracing of reactor on/off. The default verbose setting is off (false). */ native static void __setVerbose (long self, boolean verbose); public void setVerbose (boolean verbose) { __setVerbose (self, verbose); } /* By default the reactor stops if the process receives a SIGINT or SIGTERM signal. This makes it impossible to shut-down message based architectures like zactors. This method lets you switch off break handling. The default nonstop setting is off (false). */ native static void __setNonstop (long self, boolean nonstop); public void setNonstop (boolean nonstop) { __setNonstop (self, nonstop); } /* Start the reactor. Takes control of the thread and returns when the 0MQ context is terminated or the process is interrupted, or any event handler returns -1. Event handlers may register new sockets and timers, and cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. */ native static int __start (long self); public int start () { return __start (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zchunk.java0000664000372000037200000001464213222211156025566 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zchunk implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new chunk of the specified size. If you specify the data, it is copied into the chunk. If you do not specify the data, the chunk is allocated and left empty, and you can then add data using zchunk_append. */ native static long __new (byte [] data, long size); public Zchunk (byte [] data, long size) { /* TODO: if __new fails, self is null... */ self = __new (data, size); } public Zchunk (long pointer) { self = pointer; } /* Destroy a chunk */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Resizes chunk max_size as requested; chunk_cur size is set to zero */ native static void __resize (long self, long size); public void resize (long size) { __resize (self, size); } /* Return chunk cur size */ native static long __size (long self); public long size () { return __size (self); } /* Return chunk max size */ native static long __maxSize (long self); public long maxSize () { return __maxSize (self); } /* Return chunk data */ native static byte [] __data (long self); public byte [] data () { return __data (self); } /* Set chunk data from user-supplied data; truncate if too large. Data may be null. Returns actual size of chunk */ native static long __set (long self, byte [] data, long size); public long set (byte [] data, long size) { return __set (self, data, size); } /* Fill chunk data from user-supplied octet */ native static long __fill (long self, byte filler, long size); public long fill (byte filler, long size) { return __fill (self, filler, size); } /* Append user-supplied data to chunk, return resulting chunk size. If the data would exceeded the available space, it is truncated. If you want to grow the chunk to accommodate new data, use the zchunk_extend method. */ native static long __append (long self, byte [] data, long size); public long append (byte [] data, long size) { return __append (self, data, size); } /* Append user-supplied data to chunk, return resulting chunk size. If the data would exceeded the available space, the chunk grows in size. */ native static long __extend (long self, byte [] data, long size); public long extend (byte [] data, long size) { return __extend (self, data, size); } /* Copy as much data from 'source' into the chunk as possible; returns the new size of chunk. If all data from 'source' is used, returns exhausted on the source chunk. Source can be consumed as many times as needed until it is exhausted. If source was already exhausted, does not change chunk. */ native static long __consume (long self, long source); public long consume (Zchunk source) { return __consume (self, source.self); } /* Returns true if the chunk was exhausted by consume methods, or if the chunk has a size of zero. */ native static boolean __exhausted (long self); public boolean exhausted () { return __exhausted (self); } /* Try to slurp an entire file into a chunk. Will read up to maxsize of the file. If maxsize is 0, will attempt to read the entire file and fail with an assertion if that cannot fit into memory. Returns a new chunk containing the file data, or NULL if the file could not be read. */ native static long __slurp (String filename, long maxsize); public Zchunk slurp (String filename, long maxsize) { return new Zchunk (__slurp (filename, maxsize)); } /* Create copy of chunk, as new chunk object. Returns a fresh zchunk_t object, or null if there was not enough heap memory. If chunk is null, returns null. */ native static long __dup (long self); public Zchunk dup () { return new Zchunk (__dup (self)); } /* Return chunk data encoded as printable hex string. Caller must free string when finished with it. */ native static String __strhex (long self); public String strhex () { return __strhex (self); } /* Return chunk data copied into freshly allocated string Caller must free string when finished with it. */ native static String __strdup (long self); public String strdup () { return __strdup (self); } /* Return TRUE if chunk body is equal to string, excluding terminator */ native static boolean __streq (long self, String string); public boolean streq (String string) { return __streq (self, string); } /* Transform zchunk into a zframe that can be sent in a message. */ native static long __pack (long self); public Zframe pack () { return new Zframe (__pack (self)); } /* Transform a zframe into a zchunk. */ native static long __unpack (long frame); public Zchunk unpack (Zframe frame) { return new Zchunk (__unpack (frame.self)); } /* Calculate SHA1 digest for chunk, using zdigest class. */ native static String __digest (long self); public String digest () { return __digest (self); } /* Dump message to stderr, for debugging and tracing. See zchunk_fprint for details */ native static void __print (long self); public void print () { __print (self); } /* Probe the supplied object, and report if it looks like a zchunk_t. */ native static boolean __is (long self); public boolean is (long self) { return __is (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zstr.java0000664000372000037200000001031513222211156025257 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zstr { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Receive C string from socket. Caller must free returned string using zstr_free(). Returns NULL if the context is being terminated or the process was interrupted. */ native static String __recv (long source); public String recv (long source) { return __recv (source); } /* De-compress and receive C string from socket, received as a message with two frames: size of the uncompressed string, and the string itself. Caller must free returned string using zstr_free(). Returns NULL if the context is being terminated or the process was interrupted. */ native static String __recvCompress (long source); public String recvCompress (long source) { return __recvCompress (source); } /* Send a C string to a socket, as a frame. The string is sent without trailing null byte; to read this you can use zstr_recv, or a similar method that adds a null terminator on the received string. String may be NULL, which is sent as "". */ native static int __send (long dest, String string); public int send (long dest, String string) { return __send (dest, string); } /* Send a C string to a socket, as zstr_send(), with a MORE flag, so that you can send further strings in the same multi-part message. */ native static int __sendm (long dest, String string); public int sendm (long dest, String string) { return __sendm (dest, string); } /* Send a formatted string to a socket. Note that you should NOT use user-supplied strings in the format (they may contain '%' which will create security holes). */ native static int __sendf (long dest, String format); public int sendf (long dest, String format) { return __sendf (dest, format); } /* Send a formatted string to a socket, as for zstr_sendf(), with a MORE flag, so that you can send further strings in the same multi-part message. */ native static int __sendfm (long dest, String format); public int sendfm (long dest, String format) { return __sendfm (dest, format); } /* Send a series of strings (until NULL) as multipart data Returns 0 if the strings could be sent OK, or -1 on error. */ native static int __sendx (long dest, String string); public int sendx (long dest, String string []) { return __sendx (dest, string [0]); } /* Compress and send a C string to a socket, as a message with two frames: size of the uncompressed string, and the string itself. The string is sent without trailing null byte; to read this you can use zstr_recv_compress, or a similar method that de-compresses and adds a null terminator on the received string. */ native static int __sendCompress (long dest, String string); public int sendCompress (long dest, String string) { return __sendCompress (dest, string); } /* Compress and send a C string to a socket, as zstr_send_compress(), with a MORE flag, so that you can send further strings in the same multi-part message. */ native static int __sendmCompress (long dest, String string); public int sendmCompress (long dest, String string) { return __sendmCompress (dest, string); } /* Accepts a void pointer and returns a fresh character string. If source is null, returns an empty string. */ native static String __str (long source); public String str (long source) { return __str (source); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zarmour.java0000664000372000037200000000777213222211156025771 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zarmour implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new zarmour */ native static long __new (); public Zarmour () { /* TODO: if __new fails, self is null... */ self = __new (); } public Zarmour (long pointer) { self = pointer; } /* Destroy the zarmour */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Encode a stream of bytes into an armoured string. Returns the armoured string, or NULL if there was insufficient memory available to allocate a new string. */ native static String __encode (long self, byte [] data, long size); public String encode (byte [] data, long size) { return __encode (self, data, size); } /* Decode an armoured string into a chunk. The decoded output is null-terminated, so it may be treated as a string, if that's what it was prior to encoding. */ native static long __decode (long self, String data); public Zchunk decode (String data) { return new Zchunk (__decode (self, data)); } /* Get the mode property. */ native static int __mode (long self); public int mode () { return __mode (self); } /* Get printable string for mode. */ native static String __modeStr (long self); public String modeStr () { return __modeStr (self); } /* Set the mode property. */ native static void __setMode (long self, int mode); public void setMode (int mode) { __setMode (self, mode); } /* Return true if padding is turned on. */ native static boolean __pad (long self); public boolean pad () { return __pad (self); } /* Turn padding on or off. Default is on. */ native static void __setPad (long self, boolean pad); public void setPad (boolean pad) { __setPad (self, pad); } /* Get the padding character. */ native static char __padChar (long self); public char padChar () { return __padChar (self); } /* Set the padding character. */ native static void __setPadChar (long self, char padChar); public void setPadChar (char padChar) { __setPadChar (self, padChar); } /* Return if splitting output into lines is turned on. Default is off. */ native static boolean __lineBreaks (long self); public boolean lineBreaks () { return __lineBreaks (self); } /* Turn splitting output into lines on or off. */ native static void __setLineBreaks (long self, boolean lineBreaks); public void setLineBreaks (boolean lineBreaks) { __setLineBreaks (self, lineBreaks); } /* Get the line length used for splitting lines. */ native static long __lineLength (long self); public long lineLength () { return __lineLength (self); } /* Set the line length used for splitting lines. */ native static void __setLineLength (long self, long lineLength); public void setLineLength (long lineLength) { __setLineLength (self, lineLength); } /* Print properties of object */ native static void __print (long self); public void print () { __print (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/ZdirPatch.java0000664000372000037200000000466613222211156026221 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class ZdirPatch implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create new patch */ native static long __new (String path, long file, int op, String alias); public ZdirPatch (String path, Zfile file, int op, String alias) { /* TODO: if __new fails, self is null... */ self = __new (path, file.self, op, alias); } public ZdirPatch (long pointer) { self = pointer; } /* Destroy a patch */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Create copy of a patch. If the patch is null, or memory was exhausted, returns null. */ native static long __dup (long self); public ZdirPatch dup () { return new ZdirPatch (__dup (self)); } /* Return patch file directory path */ native static String __path (long self); public String path () { return __path (self); } /* Return patch file item */ native static long __file (long self); public Zfile file () { return new Zfile (__file (self)); } /* Return operation */ native static int __op (long self); public int op () { return __op (self); } /* Return patch virtual file path */ native static String __vpath (long self); public String vpath () { return __vpath (self); } /* Calculate hash digest for file (create only) */ native static void __digestSet (long self); public void digestSet () { __digestSet (self); } /* Return hash digest for patch file */ native static String __digest (long self); public String digest () { return __digest (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zsys.java0000664000372000037200000004737313222211156025303 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zsys { static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Initialize CZMQ zsys layer; this happens automatically when you create a socket or an actor; however this call lets you force initialization earlier, so e.g. logging is properly set-up before you start working. Not threadsafe, so call only from main thread. Safe to call multiple times. Returns global CZMQ context. */ native static long __init (); public long init () { return __init (); } /* Optionally shut down the CZMQ zsys layer; this normally happens automatically when the process exits; however this call lets you force a shutdown earlier, avoiding any potential problems with atexit() ordering, especially with Windows dlls. */ native static void __shutdown (); public void shutdown () { __shutdown (); } /* Get a new ZMQ socket, automagically creating a ZMQ context if this is the first time. Caller is responsible for destroying the ZMQ socket before process exits, to avoid a ZMQ deadlock. Note: you should not use this method in CZMQ apps, use zsock_new() instead. *** This is for CZMQ internal use only and may change arbitrarily *** */ native static long __socket (int type, String filename, long lineNbr); public long socket (int type, String filename, long lineNbr) { return __socket (type, filename, lineNbr); } /* Destroy/close a ZMQ socket. You should call this for every socket you create using zsys_socket(). *** This is for CZMQ internal use only and may change arbitrarily *** */ native static int __close (long handle, String filename, long lineNbr); public int Close (long handle, String filename, long lineNbr) { return __close (handle, filename, lineNbr); } /* Return ZMQ socket name for socket type *** This is for CZMQ internal use only and may change arbitrarily *** */ native static String __sockname (int socktype); public String sockname (int socktype) { return __sockname (socktype); } /* Create a pipe, which consists of two PAIR sockets connected over inproc. The pipe is configured to use the zsys_pipehwm setting. Returns the frontend socket successful, NULL if failed. */ native static long __createPipe (long backendP); public Zsock createPipe (Zsock backendP) { return new Zsock (__createPipe (backendP.self)); } /* Reset interrupt handler, call this at exit if needed */ native static void __handlerReset (); public void handlerReset () { __handlerReset (); } /* Set default interrupt handler, so Ctrl-C or SIGTERM will set zsys_interrupted. Idempotent; safe to call multiple times. Can be supressed by ZSYS_SIGHANDLER=false *** This is for CZMQ internal use only and may change arbitrarily *** */ native static void __catchInterrupts (); public void catchInterrupts () { __catchInterrupts (); } /* Return 1 if file exists, else zero */ native static boolean __fileExists (String filename); public boolean fileExists (String filename) { return __fileExists (filename); } /* Return file modification time. Returns 0 if the file does not exist. */ native static long __fileModified (String filename); public long fileModified (String filename) { return __fileModified (filename); } /* Return file mode; provides at least support for the POSIX S_ISREG(m) and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. Returns a mode_t cast to int, or -1 in case of error. */ native static int __fileMode (String filename); public int fileMode (String filename) { return __fileMode (filename); } /* Delete file. Does not complain if the file is absent */ native static int __fileDelete (String filename); public int fileDelete (String filename) { return __fileDelete (filename); } /* Check if file is 'stable' */ native static boolean __fileStable (String filename); public boolean fileStable (String filename) { return __fileStable (filename); } /* Create a file path if it doesn't exist. The file path is treated as printf format. */ native static int __dirCreate (String pathname); public int dirCreate (String pathname []) { return __dirCreate (pathname [0]); } /* Remove a file path if empty; the pathname is treated as printf format. */ native static int __dirDelete (String pathname); public int dirDelete (String pathname []) { return __dirDelete (pathname [0]); } /* Move to a specified working directory. Returns 0 if OK, -1 if this failed. */ native static int __dirChange (String pathname); public int dirChange (String pathname) { return __dirChange (pathname); } /* Set private file creation mode; all files created from here will be readable/writable by the owner only. */ native static void __fileModePrivate (); public void fileModePrivate () { __fileModePrivate (); } /* Reset default file creation mode; all files created from here will use process file mode defaults. */ native static void __fileModeDefault (); public void fileModeDefault () { __fileModeDefault (); } /* Return the CZMQ version for run-time API detection; returns version number into provided fields, providing reference isn't null in each case. */ native static void __version (int major, int minor, int patch); public void version (int major, int minor, int patch) { __version (major, minor, 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(). */ native static String __sprintf (String format); public String sprintf (String format) { return __sprintf (format); } /* Handle an I/O error on some socket operation; will report and die on fatal errors, and continue silently on "try again" errors. *** This is for CZMQ internal use only and may change arbitrarily *** */ native static void __socketError (String reason); public void socketError (String reason) { __socketError (reason); } /* Return current host name, for use in public tcp:// endpoints. Caller gets a freshly allocated string, should free it using zstr_free(). If the host name is not resolvable, returns NULL. */ native static String __hostname (); public String hostname () { return __hostname (); } /* Move the current process into the background. The precise effect depends on the operating system. On POSIX boxes, moves to a specified working directory (if specified), closes all file handles, reopens stdin, stdout, and stderr to the null device, and sets the process to ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there was an error. */ native static int __daemonize (String workdir); public int daemonize (String workdir) { return __daemonize (workdir); } /* Drop the process ID into the lockfile, with exclusive lock, and switch the process to the specified group and/or user. Any of the arguments may be null, indicating a no-op. Returns 0 on success, -1 on failure. Note if you combine this with zsys_daemonize, run after, not before that method, or the lockfile will hold the wrong process ID. */ native static int __runAs (String lockfile, String group, String user); public int runAs (String lockfile, String group, String user) { return __runAs (lockfile, group, user); } /* Returns true if the underlying libzmq supports CURVE security. Uses a heuristic probe according to the version of libzmq being used. */ native static boolean __hasCurve (); public boolean hasCurve () { return __hasCurve (); } /* Configure the number of I/O threads that ZeroMQ will use. A good rule of thumb is one thread per gigabit of traffic in or out. The default is 1, sufficient for most applications. If the environment variable ZSYS_IO_THREADS is defined, that provides the default. Note that this method is valid only before any socket is created. */ native static void __setIoThreads (long ioThreads); public void setIoThreads (long ioThreads) { __setIoThreads (ioThreads); } /* Configure the scheduling policy of the ZMQ context thread pool. Not available on Windows. See the sched_setscheduler man page or sched.h for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY is defined, that provides the default. Note that this method is valid only before any socket is created. */ native static void __setThreadSchedPolicy (int policy); public void setThreadSchedPolicy (int policy) { __setThreadSchedPolicy (policy); } /* Configure the scheduling priority of the ZMQ context thread pool. Not available on Windows. See the sched_setscheduler man page or sched.h for more information. If the environment variable ZSYS_THREAD_PRIORITY is defined, that provides the default. Note that this method is valid only before any socket is created. */ native static void __setThreadPriority (int priority); public void setThreadPriority (int priority) { __setThreadPriority (priority); } /* Configure the number of sockets that ZeroMQ will allow. The default is 1024. The actual limit depends on the system, and you can query it by using zsys_socket_limit (). A value of zero means "maximum". Note that this method is valid only before any socket is created. */ native static void __setMaxSockets (long maxSockets); public void setMaxSockets (long maxSockets) { __setMaxSockets (maxSockets); } /* Return maximum number of ZeroMQ sockets that the system will support. */ native static long __socketLimit (); public long socketLimit () { return __socketLimit (); } /* Configure the maximum allowed size of a message sent. The default is INT_MAX. */ native static void __setMaxMsgsz (int maxMsgsz); public void setMaxMsgsz (int maxMsgsz) { __setMaxMsgsz (maxMsgsz); } /* Return maximum message size. */ native static int __maxMsgsz (); public int maxMsgsz () { return __maxMsgsz (); } /* Configure the threshold value of filesystem object age per st_mtime that should elapse until we consider that object "stable" at the current zclock_time() moment. The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c which generally depends on host OS, with fallback value of 5000. */ native static void __setFileStableAgeMsec (long fileStableAgeMsec); public void setFileStableAgeMsec (long fileStableAgeMsec) { __setFileStableAgeMsec (fileStableAgeMsec); } /* Return current threshold value of file stable age in msec. This can be used in code that chooses to wait for this timeout before testing if a filesystem object is "stable" or not. */ native static long __fileStableAgeMsec (); public long fileStableAgeMsec () { return __fileStableAgeMsec (); } /* Configure the default linger timeout in msecs for new zsock instances. You can also set this separately on each zsock_t instance. The default linger time is zero, i.e. any pending messages will be dropped. If the environment variable ZSYS_LINGER is defined, that provides the default. Note that process exit will typically be delayed by the linger time. */ native static void __setLinger (long linger); public void setLinger (long linger) { __setLinger (linger); } /* Configure the default outgoing pipe limit (HWM) for new zsock instances. You can also set this separately on each zsock_t instance. The default HWM is 1,000, on all versions of ZeroMQ. If the environment variable ZSYS_SNDHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. */ native static void __setSndhwm (long sndhwm); public void setSndhwm (long sndhwm) { __setSndhwm (sndhwm); } /* Configure the default incoming pipe limit (HWM) for new zsock instances. You can also set this separately on each zsock_t instance. The default HWM is 1,000, on all versions of ZeroMQ. If the environment variable ZSYS_RCVHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. */ native static void __setRcvhwm (long rcvhwm); public void setRcvhwm (long rcvhwm) { __setRcvhwm (rcvhwm); } /* Configure the default HWM for zactor internal pipes; this is set on both ends of the pipe, for outgoing messages only (sndhwm). The default HWM is 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. */ native static void __setPipehwm (long pipehwm); public void setPipehwm (long pipehwm) { __setPipehwm (pipehwm); } /* Return the HWM for zactor internal pipes. */ native static long __pipehwm (); public long pipehwm () { return __pipehwm (); } /* Configure use of IPv6 for new zsock instances. By default sockets accept and make only IPv4 connections. When you enable IPv6, sockets will accept and connect to both IPv4 and IPv6 peers. You can override the setting on each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the default. Note: has no effect on ZMQ v2. */ native static void __setIpv6 (int ipv6); public void setIpv6 (int ipv6) { __setIpv6 (ipv6); } /* Return use of IPv6 for zsock instances. */ native static int __ipv6 (); public int ipv6 () { return __ipv6 (); } /* Set network interface name to use for broadcasts, particularly zbeacon. This lets the interface be configured for test environments where required. For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is the default when there is no specified interface. If the environment variable ZSYS_INTERFACE is set, use that as the default interface name. Setting the interface to "*" means "use all available interfaces". */ native static void __setInterface (String value); public void setInterface (String value) { __setInterface (value); } /* Return network interface to use for broadcasts, or "" if none was set. */ native static String __interface (); public String Interface () { return __interface (); } /* Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. This needs to be set IPv6 is enabled as IPv6 can have multiple addresses on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, use that as the default IPv6 address. */ native static void __setIpv6Address (String value); public void setIpv6Address (String value) { __setIpv6Address (value); } /* Return IPv6 address to use for zbeacon reception, or "" if none was set. */ native static String __ipv6Address (); public String ipv6Address () { return __ipv6Address (); } /* Set IPv6 milticast address to use for sending zbeacon messages. This needs to be set if IPv6 is enabled. If the environment variable ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast address. */ native static void __setIpv6McastAddress (String value); public void setIpv6McastAddress (String value) { __setIpv6McastAddress (value); } /* Return IPv6 multicast address to use for sending zbeacon, or "" if none was set. */ native static String __ipv6McastAddress (); public String ipv6McastAddress () { return __ipv6McastAddress (); } /* Configure the automatic use of pre-allocated FDs when creating new sockets. If 0 (default), nothing will happen. Else, when a new socket is bound, the system API will be used to check if an existing pre-allocated FD with a matching port (if TCP) or path (if IPC) exists, and if it does it will be set via the ZMQ_USE_FD socket option so that the library will use it instead of creating a new socket. */ native static void __setAutoUseFd (int autoUseFd); public void setAutoUseFd (int autoUseFd) { __setAutoUseFd (autoUseFd); } /* Return use of automatic pre-allocated FDs for zsock instances. */ native static int __autoUseFd (); public int autoUseFd () { return __autoUseFd (); } /* Set log identity, which is a string that prefixes all log messages sent by this process. The log identity defaults to the environment variable ZSYS_LOGIDENT, if that is set. */ native static void __setLogident (String value); public void setLogident (String value) { __setLogident (value); } /* Sends log output to a PUB socket bound to the specified endpoint. To collect such log output, create a SUB socket, subscribe to the traffic you care about, and connect to the endpoint. Log traffic is sent as a single string frame, in the same format as when sent to stdout. The log system supports a single sender; multiple calls to this method will bind the same sender to multiple endpoints. To disable the sender, call this method with a null argument. */ native static void __setLogsender (String endpoint); public void setLogsender (String endpoint) { __setLogsender (endpoint); } /* Enable or disable logging to the system facility (syslog on POSIX boxes, event log on Windows). By default this is disabled. */ native static void __setLogsystem (boolean logsystem); public void setLogsystem (boolean logsystem) { __setLogsystem (logsystem); } /* Log error condition - highest priority */ native static void __error (String format); public void error (String format) { __error (format); } /* Log warning condition - high priority */ native static void __warning (String format); public void warning (String format) { __warning (format); } /* Log normal, but significant, condition - normal priority */ native static void __notice (String format); public void notice (String format) { __notice (format); } /* Log informational message - low priority */ native static void __info (String format); public void info (String format) { __info (format); } /* Log debug-level message - lowest priority */ native static void __debug (String format); public void debug (String format) { __debug (format); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zframe.java0000664000372000037200000001451113222211156025543 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zframe implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new frame. If size is not null, allocates the frame data to the specified size. If additionally, data is not null, copies size octets from the specified data into the frame body. */ native static long __new (byte [] data, long size); public Zframe (byte [] data, long size) { /* TODO: if __new fails, self is null... */ self = __new (data, size); } public Zframe (long pointer) { self = pointer; } /* Create an empty (zero-sized) frame */ native static long __newEmpty (); public static Zframe newEmpty () { return new Zframe (__newEmpty ()); } /* Create a frame with a specified string content. */ native static long __from (String string); public static Zframe from (String string) { return new Zframe (__from (string)); } /* Receive frame from socket, returns zframe_t object or NULL if the recv was interrupted. Does a blocking recv, if you want to not block then use zpoller or zloop. */ native static long __recv (long source); public static Zframe recv (long source) { return new Zframe (__recv (source)); } /* Destroy a frame */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Send a frame to a socket, destroy frame after sending. Return -1 on error, 0 on success. */ native static long __send (long self, long dest, int flags); public int send (long dest, int flags) { self = __send (self, dest, flags); return 0; } /* Return number of bytes in frame data */ native static long __size (long self); public long size () { return __size (self); } /* Return address of frame data */ native static byte [] __data (long self); public byte [] data () { return __data (self); } /* Return meta data property for frame The caller shall not modify or free the returned value, which shall be owned by the message. */ native static String __meta (long self, String property); public String meta (String property) { return __meta (self, property); } /* Create a new frame that duplicates an existing frame. If frame is null, or memory was exhausted, returns null. */ native static long __dup (long self); public Zframe dup () { return new Zframe (__dup (self)); } /* Return frame data encoded as printable hex string, useful for 0MQ UUIDs. Caller must free string when finished with it. */ native static String __strhex (long self); public String strhex () { return __strhex (self); } /* Return frame data copied into freshly allocated string Caller must free string when finished with it. */ native static String __strdup (long self); public String strdup () { return __strdup (self); } /* Return TRUE if frame body is equal to string, excluding terminator */ native static boolean __streq (long self, String string); public boolean streq (String string) { return __streq (self, string); } /* Return frame MORE indicator (1 or 0), set when reading frame from socket or by the zframe_set_more() method */ native static int __more (long self); public int more () { return __more (self); } /* Set frame MORE indicator (1 or 0). Note this is NOT used when sending frame to socket, you have to specify flag explicitly. */ native static void __setMore (long self, int more); public void setMore (int more) { __setMore (self, more); } /* Return frame routing ID, if the frame came from a ZMQ_SERVER socket. Else returns zero. */ native static int __routingId (long self); public int routingId () { return __routingId (self); } /* Set routing ID on frame. This is used if/when the frame is sent to a ZMQ_SERVER socket. */ native static void __setRoutingId (long self, int routingId); public void setRoutingId (int routingId) { __setRoutingId (self, routingId); } /* Return frame group of radio-dish pattern. */ native static String __group (long self); public String group () { return __group (self); } /* Set group on frame. This is used if/when the frame is sent to a ZMQ_RADIO socket. Return -1 on error, 0 on success. */ native static int __setGroup (long self, String group); public int setGroup (String group) { return __setGroup (self, group); } /* Return TRUE if two frames have identical size and data If either frame is NULL, equality is always false. */ native static boolean __eq (long self, long other); public boolean eq (Zframe other) { return __eq (self, other.self); } /* Set new contents for frame */ native static void __reset (long self, byte [] data, long size); public void reset (byte [] data, long size) { __reset (self, data, size); } /* Send message to zsys log sink (may be stdout, or system facility as configured by zsys_set_logstream). Prefix shows before frame, if not null. */ native static void __print (long self, String prefix); public void print (String prefix) { __print (self, prefix); } /* Probe the supplied object, and report if it looks like a zframe_t. */ native static boolean __is (long self); public boolean is (long self) { return __is (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zfile.java0000664000372000037200000001527413222211156025377 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zfile implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* If file exists, populates properties. CZMQ supports portable symbolic links, which are files with the extension ".ln". A symbolic link is a text file containing one line, the filename of a target file. Reading data from the symbolic link actually reads from the target file. Path may be NULL, in which case it is not used. */ native static long __new (String path, String name); public Zfile (String path, String name) { /* TODO: if __new fails, self is null... */ self = __new (path, name); } public Zfile (long pointer) { self = pointer; } /* Create new temporary file for writing via tmpfile. File is automaticaly deleted on destroy */ native static long __tmp (); public static Zfile tmp () { return new Zfile (__tmp ()); } /* Destroy a file item */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Duplicate a file item, returns a newly constructed item. If the file is null, or memory was exhausted, returns null. */ native static long __dup (long self); public Zfile dup () { return new Zfile (__dup (self)); } /* Return file name, remove path if provided */ native static String __filename (long self, String path); public String filename (String path) { return __filename (self, path); } /* Refresh file properties from disk; this is not done automatically on access methods, otherwise it is not possible to compare directory snapshots. */ native static void __restat (long self); public void restat () { __restat (self); } /* Return when the file was last modified. If you want this to reflect the current situation, call zfile_restat before checking this property. */ native static long __modified (long self); public long modified () { return __modified (self); } /* Return the last-known size of the file. If you want this to reflect the current situation, call zfile_restat before checking this property. */ native static long __cursize (long self); public long cursize () { return __cursize (self); } /* Return true if the file is a directory. If you want this to reflect any external changes, call zfile_restat before checking this property. */ native static boolean __isDirectory (long self); public boolean isDirectory () { return __isDirectory (self); } /* Return true if the file is a regular file. If you want this to reflect any external changes, call zfile_restat before checking this property. */ native static boolean __isRegular (long self); public boolean isRegular () { return __isRegular (self); } /* Return true if the file is readable by this process. If you want this to reflect any external changes, call zfile_restat before checking this property. */ native static boolean __isReadable (long self); public boolean isReadable () { return __isReadable (self); } /* Return true if the file is writeable by this process. If you want this to reflect any external changes, call zfile_restat before checking this property. */ native static boolean __isWriteable (long self); public boolean isWriteable () { return __isWriteable (self); } /* Check if file has stopped changing and can be safely processed. Updates the file statistics from disk at every call. */ native static boolean __isStable (long self); public boolean isStable () { return __isStable (self); } /* Return true if the file was changed on disk since the zfile_t object was created, or the last zfile_restat() call made on it. */ native static boolean __hasChanged (long self); public boolean hasChanged () { return __hasChanged (self); } /* Remove the file from disk */ native static void __remove (long self); public void remove () { __remove (self); } /* Open file for reading Returns 0 if OK, -1 if not found or not accessible */ native static int __input (long self); public int input () { return __input (self); } /* Open file for writing, creating directory if needed File is created if necessary; chunks can be written to file at any location. Returns 0 if OK, -1 if error. */ native static int __output (long self); public int output () { return __output (self); } /* Read chunk from file at specified position. If this was the last chunk, sets the eof property. Returns a null chunk in case of error. */ native static long __read (long self, long bytes, long offset); public Zchunk read (long bytes, long offset) { return new Zchunk (__read (self, bytes, offset)); } /* Returns true if zfile_read() just read the last chunk in the file. */ native static boolean __eof (long self); public boolean eof () { return __eof (self); } /* Write chunk to file at specified position Return 0 if OK, else -1 */ native static int __write (long self, long chunk, long offset); public int write (Zchunk chunk, long offset) { return __write (self, chunk.self, offset); } /* Read next line of text from file. Returns a pointer to the text line, or NULL if there was nothing more to read from the file. */ native static String __readln (long self); public String readln () { return __readln (self); } /* Close file, if open */ native static void __close (long self); public void Close () { __close (self); } /* Calculate SHA1 digest for file, using zdigest class. */ native static String __digest (long self); public String digest () { return __digest (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zlistx.java0000664000372000037200000002053313222211156025615 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zlistx implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create a new, empty list. */ native static long __new (); public Zlistx () { /* TODO: if __new fails, self is null... */ self = __new (); } public Zlistx (long pointer) { self = pointer; } /* Destroy a list. If an item destructor was specified, all items in the list are automatically destroyed as well. */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Add an item to the head of the list. Calls the item duplicator, if any, on the item. Resets cursor to list head. Returns an item handle on success, NULL if memory was exhausted. */ native static long __addStart (long self, long item); public long addStart (long item) { return __addStart (self, item); } /* Add an item to the tail of the list. Calls the item duplicator, if any, on the item. Resets cursor to list head. Returns an item handle on success, NULL if memory was exhausted. */ native static long __addEnd (long self, long item); public long addEnd (long item) { return __addEnd (self, item); } /* Return the number of items in the list */ native static long __size (long self); public long size () { return __size (self); } /* Return first item in the list, or null, leaves the cursor */ native static long __head (long self); public long head () { return __head (self); } /* Return last item in the list, or null, leaves the cursor */ native static long __tail (long self); public long tail () { return __tail (self); } /* Return the item at the head of list. If the list is empty, returns NULL. Leaves cursor pointing at the head item, or NULL if the list is empty. */ native static long __first (long self); public long first () { return __first (self); } /* Return the next item. At the end of the list (or in an empty list), returns NULL. Use repeated zlistx_next () calls to work through the list from zlistx_first (). First time, acts as zlistx_first(). */ native static long __next (long self); public long next () { return __next (self); } /* Return the previous item. At the start of the list (or in an empty list), returns NULL. Use repeated zlistx_prev () calls to work through the list backwards from zlistx_last (). First time, acts as zlistx_last(). */ native static long __prev (long self); public long prev () { return __prev (self); } /* Return the item at the tail of list. If the list is empty, returns NULL. Leaves cursor pointing at the tail item, or NULL if the list is empty. */ native static long __last (long self); public long last () { return __last (self); } /* Returns the value of the item at the cursor, or NULL if the cursor is not pointing to an item. */ native static long __item (long self); public long item () { return __item (self); } /* Returns the handle of the item at the cursor, or NULL if the cursor is not pointing to an item. */ native static long __cursor (long self); public long cursor () { return __cursor (self); } /* Returns the item associated with the given list handle, or NULL if passed in handle is NULL. Asserts that the passed in handle points to a list element. */ native static long __handleItem (long handle); public long handleItem (long handle) { return __handleItem (handle); } /* Find an item in the list, searching from the start. Uses the item comparator, if any, else compares item values directly. Returns the item handle found, or NULL. Sets the cursor to the found item, if any. */ native static long __find (long self, long item); public long find (long item) { return __find (self, item); } /* Detach an item from the list, using its handle. The item is not modified, and the caller is responsible for destroying it if necessary. If handle is null, detaches the first item on the list. Returns item that was detached, or null if none was. If cursor was at item, moves cursor to previous item, so you can detach items while iterating forwards through a list. */ native static long __detach (long self, long handle); public long detach (long handle) { return __detach (self, handle); } /* Detach item at the cursor, if any, from the list. The item is not modified, and the caller is responsible for destroying it as necessary. Returns item that was detached, or null if none was. Moves cursor to previous item, so you can detach items while iterating forwards through a list. */ native static long __detachCur (long self); public long detachCur () { return __detachCur (self); } /* Delete an item, using its handle. Calls the item destructor is any is set. If handle is null, deletes the first item on the list. Returns 0 if an item was deleted, -1 if not. If cursor was at item, moves cursor to previous item, so you can delete items while iterating forwards through a list. */ native static int __delete (long self, long handle); public int delete (long handle) { return __delete (self, handle); } /* Move an item to the start of the list, via its handle. */ native static void __moveStart (long self, long handle); public void moveStart (long handle) { __moveStart (self, handle); } /* Move an item to the end of the list, via its handle. */ native static void __moveEnd (long self, long handle); public void moveEnd (long handle) { __moveEnd (self, handle); } /* Remove all items from the list, and destroy them if the item destructor is set. */ native static void __purge (long self); public void purge () { __purge (self); } /* Sort the list. If an item comparator was set, calls that to compare items, otherwise compares on item value. The sort is not stable, so may reorder equal items. */ native static void __sort (long self); public void sort () { __sort (self); } /* Create a new node and insert it into a sorted list. Calls the item duplicator, if any, on the item. If low_value is true, starts searching from the start of the list, otherwise searches from the end. Use the item comparator, if any, to find where to place the new node. Returns a handle to the new node, or NULL if memory was exhausted. Resets the cursor to the list head. */ native static long __insert (long self, long item, boolean lowValue); public long insert (long item, boolean lowValue) { return __insert (self, item, lowValue); } /* Move an item, specified by handle, into position in a sorted list. Uses the item comparator, if any, to determine the new location. If low_value is true, starts searching from the start of the list, otherwise searches from the end. */ native static void __reorder (long self, long handle, boolean lowValue); public void reorder (long handle, boolean lowValue) { __reorder (self, handle, lowValue); } /* Make a copy of the list; items are duplicated if you set a duplicator for the list, otherwise not. Copying a null reference returns a null reference. */ native static long __dup (long self); public Zlistx dup () { return new Zlistx (__dup (self)); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zpoller.java0000664000372000037200000000730413222211156025750 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ package org.zeromq.czmq; public class Zpoller implements AutoCloseable{ static { try { System.loadLibrary ("czmqjni"); } catch (Exception e) { System.exit (-1); } } public long self; /* Create new poller, specifying zero or more readers. The list of readers ends in a NULL. Each reader can be a zsock_t instance, a zactor_t instance, a libzmq socket (void *), or a file handle. */ native static long __new (long reader); public Zpoller (long reader []) { /* TODO: if __new fails, self is null... */ self = __new (reader [0]); } public Zpoller (long pointer) { self = pointer; } /* Destroy a poller */ native static void __destroy (long self); @Override public void close () { __destroy (self); self = 0; } /* Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. */ native static int __add (long self, long reader); public int add (long reader) { return __add (self, reader); } /* Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader must have been passed during construction, or in an zpoller_add () call. */ native static int __remove (long self, long reader); public int remove (long reader) { return __remove (self, reader); } /* By default the poller stops if the process receives a SIGINT or SIGTERM signal. This makes it impossible to shut-down message based architectures like zactors. This method lets you switch off break handling. The default nonstop setting is off (false). */ native static void __setNonstop (long self, boolean nonstop); public void setNonstop (boolean nonstop) { __setNonstop (self, nonstop); } /* Poll the registered readers for I/O, return first reader that has input. The reader will be a libzmq void * socket, or a zsock_t or zactor_t instance as specified in zpoller_new/zpoller_add. The timeout should be zero or greater, or -1 to wait indefinitely. Socket priority is defined by their order in the poll list. If you need a balanced poll, use the low level zmq_poll method directly. If the poll call was interrupted (SIGINT), or the ZMQ context was destroyed, or the timeout expired, returns NULL. You can test the actual exit condition by calling zpoller_expired () and zpoller_terminated (). The timeout is in msec. */ native static long __wait (long self, int timeout); public long Wait (int timeout) { return __wait (self, timeout); } /* Return true if the last zpoller_wait () call ended because the timeout expired, without any error. */ native static boolean __expired (long self); public boolean expired () { return __expired (self); } /* Return true if the last zpoller_wait () call ended because the process was interrupted, or the parent context was destroyed. */ native static boolean __terminated (long self); public boolean terminated () { return __terminated (self); } /* Self test of this class. */ native static void __test (boolean verbose); public static void test (boolean verbose) { __test (verbose); } } czmq-4.1.0/bindings/jni/src/main/c/0000775000372000037200000000000013222211156017675 5ustar00travistravis00000000000000czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zcertstore.c0000664000372000037200000000444313222211156025510 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zcertstore.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zcertstore__1_1new (JNIEnv *env, jclass c, jstring location) { char *location_ = (char *) (*env)->GetStringUTFChars (env, location, NULL); // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zcertstore_new (location_); (*env)->ReleaseStringUTFChars (env, location, location_); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zcertstore__1_1destroy (JNIEnv *env, jclass c, jlong self) { zcertstore_destroy ((zcertstore_t **) &self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zcertstore__1_1lookup (JNIEnv *env, jclass c, jlong self, jstring public_key) { char *public_key_ = (char *) (*env)->GetStringUTFChars (env, public_key, NULL); jlong lookup_ = (jlong) (intptr_t) zcertstore_lookup ((zcertstore_t *) (intptr_t) self, public_key_); (*env)->ReleaseStringUTFChars (env, public_key, public_key_); return lookup_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zcertstore__1_1insert (JNIEnv *env, jclass c, jlong self, jlong cert_p) { zcertstore_insert ((zcertstore_t *) (intptr_t) self, (zcert_t **) (intptr_t) &cert_p); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zcertstore__1_1empty (JNIEnv *env, jclass c, jlong self) { zcertstore_empty ((zcertstore_t *) (intptr_t) self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zcertstore__1_1print (JNIEnv *env, jclass c, jlong self) { zcertstore_print ((zcertstore_t *) (intptr_t) self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zcertstore__1_1certs (JNIEnv *env, jclass c, jlong self) { jlong certs_ = (jlong) (intptr_t) zcertstore_certs ((zcertstore_t *) (intptr_t) self); return certs_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zcertstore__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zcertstore_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zsys.c0000664000372000037200000003353013222211156024313 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zsys.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsys__1_1init (JNIEnv *env, jclass c) { jlong init_ = (jlong) (intptr_t) zsys_init (); return init_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1shutdown (JNIEnv *env, jclass c) { zsys_shutdown (); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsys__1_1socket (JNIEnv *env, jclass c, jint type, jstring filename, jlong line_nbr) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jlong socket_ = (jlong) (intptr_t) zsys_socket ((int) type, filename_, (size_t) line_nbr); (*env)->ReleaseStringUTFChars (env, filename, filename_); return socket_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsys__1_1close (JNIEnv *env, jclass c, jlong handle, jstring filename, jlong line_nbr) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jint close_ = (jint) zsys_close ((void *) (intptr_t) handle, filename_, (size_t) line_nbr); (*env)->ReleaseStringUTFChars (env, filename, filename_); return close_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsys__1_1sockname (JNIEnv *env, jclass c, jint socktype) { char *sockname_ = (char *) zsys_sockname ((int) socktype); jstring return_string_ = (*env)->NewStringUTF (env, sockname_); return return_string_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsys__1_1createPipe (JNIEnv *env, jclass c, jlong backend_p) { jlong create_pipe_ = (jlong) (intptr_t) zsys_create_pipe ((zsock_t **) (intptr_t) &backend_p); return create_pipe_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1handlerReset (JNIEnv *env, jclass c) { zsys_handler_reset (); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1catchInterrupts (JNIEnv *env, jclass c) { zsys_catch_interrupts (); } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zsys__1_1fileExists (JNIEnv *env, jclass c, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jboolean file_exists_ = (jboolean) zsys_file_exists (filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return file_exists_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsys__1_1fileModified (JNIEnv *env, jclass c, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jlong file_modified_ = (jlong) zsys_file_modified (filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return file_modified_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsys__1_1fileMode (JNIEnv *env, jclass c, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jint file_mode_ = (jint) zsys_file_mode (filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return file_mode_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsys__1_1fileDelete (JNIEnv *env, jclass c, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jint file_delete_ = (jint) zsys_file_delete (filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return file_delete_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zsys__1_1fileStable (JNIEnv *env, jclass c, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jboolean file_stable_ = (jboolean) zsys_file_stable (filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return file_stable_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsys__1_1dirCreate (JNIEnv *env, jclass c, jstring pathname) { char *pathname_ = (char *) (*env)->GetStringUTFChars (env, pathname, NULL); jint dir_create_ = (jint) zsys_dir_create (pathname_); (*env)->ReleaseStringUTFChars (env, pathname, pathname_); return dir_create_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsys__1_1dirDelete (JNIEnv *env, jclass c, jstring pathname) { char *pathname_ = (char *) (*env)->GetStringUTFChars (env, pathname, NULL); jint dir_delete_ = (jint) zsys_dir_delete (pathname_); (*env)->ReleaseStringUTFChars (env, pathname, pathname_); return dir_delete_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsys__1_1dirChange (JNIEnv *env, jclass c, jstring pathname) { char *pathname_ = (char *) (*env)->GetStringUTFChars (env, pathname, NULL); jint dir_change_ = (jint) zsys_dir_change (pathname_); (*env)->ReleaseStringUTFChars (env, pathname, pathname_); return dir_change_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1fileModePrivate (JNIEnv *env, jclass c) { zsys_file_mode_private (); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1fileModeDefault (JNIEnv *env, jclass c) { zsys_file_mode_default (); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1version (JNIEnv *env, jclass c, jint major, jint minor, jint patch) { zsys_version ((int *) (intptr_t) &major, (int *) (intptr_t) &minor, (int *) (intptr_t) &patch); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsys__1_1sprintf (JNIEnv *env, jclass c, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); char *sprintf_ = (char *) zsys_sprintf (format_); jstring return_string_ = (*env)->NewStringUTF (env, sprintf_); (*env)->ReleaseStringUTFChars (env, format, format_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1socketError (JNIEnv *env, jclass c, jstring reason) { char *reason_ = (char *) (*env)->GetStringUTFChars (env, reason, NULL); zsys_socket_error (reason_); (*env)->ReleaseStringUTFChars (env, reason, reason_); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsys__1_1hostname (JNIEnv *env, jclass c) { char *hostname_ = (char *) zsys_hostname (); jstring return_string_ = (*env)->NewStringUTF (env, hostname_); return return_string_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsys__1_1daemonize (JNIEnv *env, jclass c, jstring workdir) { char *workdir_ = (char *) (*env)->GetStringUTFChars (env, workdir, NULL); jint daemonize_ = (jint) zsys_daemonize (workdir_); (*env)->ReleaseStringUTFChars (env, workdir, workdir_); return daemonize_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsys__1_1runAs (JNIEnv *env, jclass c, jstring lockfile, jstring group, jstring user) { char *lockfile_ = (char *) (*env)->GetStringUTFChars (env, lockfile, NULL); char *group_ = (char *) (*env)->GetStringUTFChars (env, group, NULL); char *user_ = (char *) (*env)->GetStringUTFChars (env, user, NULL); jint run_as_ = (jint) zsys_run_as (lockfile_, group_, user_); (*env)->ReleaseStringUTFChars (env, lockfile, lockfile_); (*env)->ReleaseStringUTFChars (env, group, group_); (*env)->ReleaseStringUTFChars (env, user, user_); return run_as_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zsys__1_1hasCurve (JNIEnv *env, jclass c) { jboolean has_curve_ = (jboolean) zsys_has_curve (); return has_curve_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setIoThreads (JNIEnv *env, jclass c, jlong io_threads) { zsys_set_io_threads ((size_t) io_threads); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setThreadSchedPolicy (JNIEnv *env, jclass c, jint policy) { zsys_set_thread_sched_policy ((int) policy); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setThreadPriority (JNIEnv *env, jclass c, jint priority) { zsys_set_thread_priority ((int) priority); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setMaxSockets (JNIEnv *env, jclass c, jlong max_sockets) { zsys_set_max_sockets ((size_t) max_sockets); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsys__1_1socketLimit (JNIEnv *env, jclass c) { jlong socket_limit_ = (jlong) zsys_socket_limit (); return socket_limit_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setMaxMsgsz (JNIEnv *env, jclass c, jint max_msgsz) { zsys_set_max_msgsz ((int) max_msgsz); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsys__1_1maxMsgsz (JNIEnv *env, jclass c) { jint max_msgsz_ = (jint) zsys_max_msgsz (); return max_msgsz_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setFileStableAgeMsec (JNIEnv *env, jclass c, jlong file_stable_age_msec) { zsys_set_file_stable_age_msec ((int64_t) file_stable_age_msec); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsys__1_1fileStableAgeMsec (JNIEnv *env, jclass c) { jlong file_stable_age_msec_ = (jlong) zsys_file_stable_age_msec (); return file_stable_age_msec_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setLinger (JNIEnv *env, jclass c, jlong linger) { zsys_set_linger ((size_t) linger); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setSndhwm (JNIEnv *env, jclass c, jlong sndhwm) { zsys_set_sndhwm ((size_t) sndhwm); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setRcvhwm (JNIEnv *env, jclass c, jlong rcvhwm) { zsys_set_rcvhwm ((size_t) rcvhwm); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setPipehwm (JNIEnv *env, jclass c, jlong pipehwm) { zsys_set_pipehwm ((size_t) pipehwm); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsys__1_1pipehwm (JNIEnv *env, jclass c) { jlong pipehwm_ = (jlong) zsys_pipehwm (); return pipehwm_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setIpv6 (JNIEnv *env, jclass c, jint ipv6) { zsys_set_ipv6 ((int) ipv6); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsys__1_1ipv6 (JNIEnv *env, jclass c) { jint ipv6_ = (jint) zsys_ipv6 (); return ipv6_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setInterface (JNIEnv *env, jclass c, jstring value) { char *value_ = (char *) (*env)->GetStringUTFChars (env, value, NULL); zsys_set_interface (value_); (*env)->ReleaseStringUTFChars (env, value, value_); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsys__1_1interface (JNIEnv *env, jclass c) { char *interface_ = (char *) zsys_interface (); jstring return_string_ = (*env)->NewStringUTF (env, interface_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setIpv6Address (JNIEnv *env, jclass c, jstring value) { char *value_ = (char *) (*env)->GetStringUTFChars (env, value, NULL); zsys_set_ipv6_address (value_); (*env)->ReleaseStringUTFChars (env, value, value_); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsys__1_1ipv6Address (JNIEnv *env, jclass c) { char *ipv6_address_ = (char *) zsys_ipv6_address (); jstring return_string_ = (*env)->NewStringUTF (env, ipv6_address_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setIpv6McastAddress (JNIEnv *env, jclass c, jstring value) { char *value_ = (char *) (*env)->GetStringUTFChars (env, value, NULL); zsys_set_ipv6_mcast_address (value_); (*env)->ReleaseStringUTFChars (env, value, value_); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsys__1_1ipv6McastAddress (JNIEnv *env, jclass c) { char *ipv6_mcast_address_ = (char *) zsys_ipv6_mcast_address (); jstring return_string_ = (*env)->NewStringUTF (env, ipv6_mcast_address_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setAutoUseFd (JNIEnv *env, jclass c, jint auto_use_fd) { zsys_set_auto_use_fd ((int) auto_use_fd); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsys__1_1autoUseFd (JNIEnv *env, jclass c) { jint auto_use_fd_ = (jint) zsys_auto_use_fd (); return auto_use_fd_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setLogident (JNIEnv *env, jclass c, jstring value) { char *value_ = (char *) (*env)->GetStringUTFChars (env, value, NULL); zsys_set_logident (value_); (*env)->ReleaseStringUTFChars (env, value, value_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setLogsender (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); zsys_set_logsender (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1setLogsystem (JNIEnv *env, jclass c, jboolean logsystem) { zsys_set_logsystem ((bool) logsystem); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1error (JNIEnv *env, jclass c, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zsys_error (format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1warning (JNIEnv *env, jclass c, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zsys_warning (format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1notice (JNIEnv *env, jclass c, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zsys_notice (format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1info (JNIEnv *env, jclass c, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zsys_info (format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1debug (JNIEnv *env, jclass c, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zsys_debug (format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsys__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zsys_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zmsg.c0000664000372000037200000002017013222211156024257 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zmsg.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zmsg_new (); return new_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1recv (JNIEnv *env, jclass c, jlong source) { jlong recv_ = (jlong) (intptr_t) zmsg_recv ((void *) (intptr_t) source); return recv_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1decode (JNIEnv *env, jclass c, jlong frame) { jlong decode_ = (jlong) (intptr_t) zmsg_decode ((zframe_t *) (intptr_t) frame); return decode_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1newSignal (JNIEnv *env, jclass c, jbyte status) { jlong new_signal_ = (jlong) (intptr_t) zmsg_new_signal ((byte) status); return new_signal_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zmsg__1_1destroy (JNIEnv *env, jclass c, jlong self) { zmsg_destroy ((zmsg_t **) &self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1send (JNIEnv *env, jclass c, jlong self, jlong dest) { jint send_ = (jint) zmsg_send ((zmsg_t **) &self, (void *) (intptr_t) dest); return self; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1sendm (JNIEnv *env, jclass c, jlong self, jlong dest) { jint sendm_ = (jint) zmsg_sendm ((zmsg_t **) &self, (void *) (intptr_t) dest); return self; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1size (JNIEnv *env, jclass c, jlong self) { jlong size_ = (jlong) zmsg_size ((zmsg_t *) (intptr_t) self); return size_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1contentSize (JNIEnv *env, jclass c, jlong self) { jlong content_size_ = (jlong) zmsg_content_size ((zmsg_t *) (intptr_t) self); return content_size_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zmsg__1_1routingId (JNIEnv *env, jclass c, jlong self) { jint routing_id_ = (jint) zmsg_routing_id ((zmsg_t *) (intptr_t) self); return routing_id_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zmsg__1_1setRoutingId (JNIEnv *env, jclass c, jlong self, jint routing_id) { zmsg_set_routing_id ((zmsg_t *) (intptr_t) self, (uint32_t) routing_id); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zmsg__1_1prepend (JNIEnv *env, jclass c, jlong self, jlong frame_p) { jint prepend_ = (jint) zmsg_prepend ((zmsg_t *) (intptr_t) self, (zframe_t **) (intptr_t) &frame_p); return prepend_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zmsg__1_1append (JNIEnv *env, jclass c, jlong self, jlong frame_p) { jint append_ = (jint) zmsg_append ((zmsg_t *) (intptr_t) self, (zframe_t **) (intptr_t) &frame_p); return append_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1pop (JNIEnv *env, jclass c, jlong self) { jlong pop_ = (jlong) (intptr_t) zmsg_pop ((zmsg_t *) (intptr_t) self); return pop_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zmsg__1_1pushmem (JNIEnv *env, jclass c, jlong self, jbyteArray data, jlong size) { jbyte *data_ = (byte *) (*env)->GetByteArrayElements (env, data, 0); jint pushmem_ = (jint) zmsg_pushmem ((zmsg_t *) (intptr_t) self, data_, (size_t) size); (*env)->ReleaseByteArrayElements (env, data, (jbyte *) data_, 0); return pushmem_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zmsg__1_1addmem (JNIEnv *env, jclass c, jlong self, jbyteArray data, jlong size) { jbyte *data_ = (byte *) (*env)->GetByteArrayElements (env, data, 0); jint addmem_ = (jint) zmsg_addmem ((zmsg_t *) (intptr_t) self, data_, (size_t) size); (*env)->ReleaseByteArrayElements (env, data, (jbyte *) data_, 0); return addmem_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zmsg__1_1pushstr (JNIEnv *env, jclass c, jlong self, jstring string) { char *string_ = (char *) (*env)->GetStringUTFChars (env, string, NULL); jint pushstr_ = (jint) zmsg_pushstr ((zmsg_t *) (intptr_t) self, string_); (*env)->ReleaseStringUTFChars (env, string, string_); return pushstr_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zmsg__1_1addstr (JNIEnv *env, jclass c, jlong self, jstring string) { char *string_ = (char *) (*env)->GetStringUTFChars (env, string, NULL); jint addstr_ = (jint) zmsg_addstr ((zmsg_t *) (intptr_t) self, string_); (*env)->ReleaseStringUTFChars (env, string, string_); return addstr_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zmsg__1_1pushstrf (JNIEnv *env, jclass c, jlong self, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); jint pushstrf_ = (jint) zmsg_pushstrf ((zmsg_t *) (intptr_t) self, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); return pushstrf_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zmsg__1_1addstrf (JNIEnv *env, jclass c, jlong self, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); jint addstrf_ = (jint) zmsg_addstrf ((zmsg_t *) (intptr_t) self, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); return addstrf_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zmsg__1_1popstr (JNIEnv *env, jclass c, jlong self) { char *popstr_ = (char *) zmsg_popstr ((zmsg_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, popstr_); zstr_free (&popstr_); return return_string_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zmsg__1_1addmsg (JNIEnv *env, jclass c, jlong self, jlong msg_p) { jint addmsg_ = (jint) zmsg_addmsg ((zmsg_t *) (intptr_t) self, (zmsg_t **) (intptr_t) &msg_p); return addmsg_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1popmsg (JNIEnv *env, jclass c, jlong self) { jlong popmsg_ = (jlong) (intptr_t) zmsg_popmsg ((zmsg_t *) (intptr_t) self); return popmsg_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zmsg__1_1remove (JNIEnv *env, jclass c, jlong self, jlong frame) { zmsg_remove ((zmsg_t *) (intptr_t) self, (zframe_t *) (intptr_t) frame); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1first (JNIEnv *env, jclass c, jlong self) { jlong first_ = (jlong) (intptr_t) zmsg_first ((zmsg_t *) (intptr_t) self); return first_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1next (JNIEnv *env, jclass c, jlong self) { jlong next_ = (jlong) (intptr_t) zmsg_next ((zmsg_t *) (intptr_t) self); return next_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1last (JNIEnv *env, jclass c, jlong self) { jlong last_ = (jlong) (intptr_t) zmsg_last ((zmsg_t *) (intptr_t) self); return last_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1encode (JNIEnv *env, jclass c, jlong self) { jlong encode_ = (jlong) (intptr_t) zmsg_encode ((zmsg_t *) (intptr_t) self); return encode_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zmsg__1_1dup (JNIEnv *env, jclass c, jlong self) { jlong dup_ = (jlong) (intptr_t) zmsg_dup ((zmsg_t *) (intptr_t) self); return dup_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zmsg__1_1print (JNIEnv *env, jclass c, jlong self) { zmsg_print ((zmsg_t *) (intptr_t) self); } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zmsg__1_1eq (JNIEnv *env, jclass c, jlong self, jlong other) { jboolean eq_ = (jboolean) zmsg_eq ((zmsg_t *) (intptr_t) self, (zmsg_t *) (intptr_t) other); return eq_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zmsg__1_1signal (JNIEnv *env, jclass c, jlong self) { jint signal_ = (jint) zmsg_signal ((zmsg_t *) (intptr_t) self); return signal_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zmsg__1_1is (JNIEnv *env, jclass c, jlong self) { jboolean is_ = (jboolean) zmsg_is ((void *) (intptr_t) self); return is_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zmsg__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zmsg_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zclock.c0000664000372000037200000000263313222211156024570 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zclock.h" JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zclock__1_1sleep (JNIEnv *env, jclass c, jint msecs) { zclock_sleep ((int) msecs); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zclock__1_1time (JNIEnv *env, jclass c) { jlong time_ = (jlong) zclock_time (); return time_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zclock__1_1mono (JNIEnv *env, jclass c) { jlong mono_ = (jlong) zclock_mono (); return mono_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zclock__1_1usecs (JNIEnv *env, jclass c) { jlong usecs_ = (jlong) zclock_usecs (); return usecs_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zclock__1_1timestr (JNIEnv *env, jclass c) { char *timestr_ = (char *) zclock_timestr (); jstring return_string_ = (*env)->NewStringUTF (env, timestr_); zstr_free (×tr_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zclock__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zclock_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Ztrie.c0000664000372000037200000000550113222211156024435 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Ztrie.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Ztrie__1_1new (JNIEnv *env, jclass c, jchar delimiter) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) ztrie_new ((char) delimiter); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Ztrie__1_1destroy (JNIEnv *env, jclass c, jlong self) { ztrie_destroy ((ztrie_t **) &self); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Ztrie__1_1removeRoute (JNIEnv *env, jclass c, jlong self, jstring path) { char *path_ = (char *) (*env)->GetStringUTFChars (env, path, NULL); jint remove_route_ = (jint) ztrie_remove_route ((ztrie_t *) (intptr_t) self, path_); (*env)->ReleaseStringUTFChars (env, path, path_); return remove_route_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Ztrie__1_1matches (JNIEnv *env, jclass c, jlong self, jstring path) { char *path_ = (char *) (*env)->GetStringUTFChars (env, path, NULL); jboolean matches_ = (jboolean) ztrie_matches ((ztrie_t *) (intptr_t) self, path_); (*env)->ReleaseStringUTFChars (env, path, path_); return matches_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Ztrie__1_1hitData (JNIEnv *env, jclass c, jlong self) { jlong hit_data_ = (jlong) (intptr_t) ztrie_hit_data ((ztrie_t *) (intptr_t) self); return hit_data_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Ztrie__1_1hitParameterCount (JNIEnv *env, jclass c, jlong self) { jlong hit_parameter_count_ = (jlong) ztrie_hit_parameter_count ((ztrie_t *) (intptr_t) self); return hit_parameter_count_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Ztrie__1_1hitParameters (JNIEnv *env, jclass c, jlong self) { jlong hit_parameters_ = (jlong) (intptr_t) ztrie_hit_parameters ((ztrie_t *) (intptr_t) self); return hit_parameters_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Ztrie__1_1hitAsteriskMatch (JNIEnv *env, jclass c, jlong self) { char *hit_asterisk_match_ = (char *) ztrie_hit_asterisk_match ((ztrie_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, hit_asterisk_match_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Ztrie__1_1print (JNIEnv *env, jclass c, jlong self) { ztrie_print ((ztrie_t *) (intptr_t) self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Ztrie__1_1test (JNIEnv *env, jclass c, jboolean verbose) { ztrie_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zarmour.c0000664000372000037200000001033513222211156025000 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zarmour.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zarmour__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zarmour_new (); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zarmour__1_1destroy (JNIEnv *env, jclass c, jlong self) { zarmour_destroy ((zarmour_t **) &self); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zarmour__1_1encode (JNIEnv *env, jclass c, jlong self, jbyteArray data, jlong size) { jbyte *data_ = (byte *) (*env)->GetByteArrayElements (env, data, 0); char *encode_ = (char *) zarmour_encode ((zarmour_t *) (intptr_t) self, data_, (size_t) size); jstring return_string_ = (*env)->NewStringUTF (env, encode_); zstr_free (&encode_); (*env)->ReleaseByteArrayElements (env, data, (jbyte *) data_, 0); return return_string_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zarmour__1_1decode (JNIEnv *env, jclass c, jlong self, jstring data) { char *data_ = (char *) (*env)->GetStringUTFChars (env, data, NULL); jlong decode_ = (jlong) (intptr_t) zarmour_decode ((zarmour_t *) (intptr_t) self, data_); (*env)->ReleaseStringUTFChars (env, data, data_); return decode_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zarmour__1_1mode (JNIEnv *env, jclass c, jlong self) { jint mode_ = (jint) zarmour_mode ((zarmour_t *) (intptr_t) self); return mode_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zarmour__1_1modeStr (JNIEnv *env, jclass c, jlong self) { char *mode_str_ = (char *) zarmour_mode_str ((zarmour_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, mode_str_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zarmour__1_1setMode (JNIEnv *env, jclass c, jlong self, jint mode) { zarmour_set_mode ((zarmour_t *) (intptr_t) self, (int) mode); } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zarmour__1_1pad (JNIEnv *env, jclass c, jlong self) { jboolean pad_ = (jboolean) zarmour_pad ((zarmour_t *) (intptr_t) self); return pad_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zarmour__1_1setPad (JNIEnv *env, jclass c, jlong self, jboolean pad) { zarmour_set_pad ((zarmour_t *) (intptr_t) self, (bool) pad); } JNIEXPORT jchar JNICALL Java_org_zeromq_czmq_Zarmour__1_1padChar (JNIEnv *env, jclass c, jlong self) { jchar pad_char_ = (jchar) zarmour_pad_char ((zarmour_t *) (intptr_t) self); return pad_char_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zarmour__1_1setPadChar (JNIEnv *env, jclass c, jlong self, jchar pad_char) { zarmour_set_pad_char ((zarmour_t *) (intptr_t) self, (char) pad_char); } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zarmour__1_1lineBreaks (JNIEnv *env, jclass c, jlong self) { jboolean line_breaks_ = (jboolean) zarmour_line_breaks ((zarmour_t *) (intptr_t) self); return line_breaks_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zarmour__1_1setLineBreaks (JNIEnv *env, jclass c, jlong self, jboolean line_breaks) { zarmour_set_line_breaks ((zarmour_t *) (intptr_t) self, (bool) line_breaks); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zarmour__1_1lineLength (JNIEnv *env, jclass c, jlong self) { jlong line_length_ = (jlong) zarmour_line_length ((zarmour_t *) (intptr_t) self); return line_length_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zarmour__1_1setLineLength (JNIEnv *env, jclass c, jlong self, jlong line_length) { zarmour_set_line_length ((zarmour_t *) (intptr_t) self, (size_t) line_length); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zarmour__1_1print (JNIEnv *env, jclass c, jlong self) { zarmour_print ((zarmour_t *) (intptr_t) self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zarmour__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zarmour_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zsock.c0000664000372000037200000013335513222211156024442 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zsock.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1new (JNIEnv *env, jclass c, jint type) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zsock_new ((int) type); return new_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newPub (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_pub_ = (jlong) (intptr_t) zsock_new_pub (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_pub_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newSub (JNIEnv *env, jclass c, jstring endpoint, jstring subscribe) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); char *subscribe_ = (char *) (*env)->GetStringUTFChars (env, subscribe, NULL); jlong new_sub_ = (jlong) (intptr_t) zsock_new_sub (endpoint_, subscribe_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); (*env)->ReleaseStringUTFChars (env, subscribe, subscribe_); return new_sub_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newReq (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_req_ = (jlong) (intptr_t) zsock_new_req (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_req_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newRep (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_rep_ = (jlong) (intptr_t) zsock_new_rep (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_rep_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newDealer (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_dealer_ = (jlong) (intptr_t) zsock_new_dealer (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_dealer_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newRouter (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_router_ = (jlong) (intptr_t) zsock_new_router (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_router_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newPush (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_push_ = (jlong) (intptr_t) zsock_new_push (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_push_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newPull (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_pull_ = (jlong) (intptr_t) zsock_new_pull (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_pull_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newXpub (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_xpub_ = (jlong) (intptr_t) zsock_new_xpub (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_xpub_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newXsub (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_xsub_ = (jlong) (intptr_t) zsock_new_xsub (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_xsub_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newPair (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_pair_ = (jlong) (intptr_t) zsock_new_pair (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_pair_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newStream (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_stream_ = (jlong) (intptr_t) zsock_new_stream (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_stream_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newServer (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_server_ = (jlong) (intptr_t) zsock_new_server (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_server_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newClient (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_client_ = (jlong) (intptr_t) zsock_new_client (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_client_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newRadio (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_radio_ = (jlong) (intptr_t) zsock_new_radio (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_radio_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newDish (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_dish_ = (jlong) (intptr_t) zsock_new_dish (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_dish_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newGather (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_gather_ = (jlong) (intptr_t) zsock_new_gather (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_gather_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1newScatter (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); jlong new_scatter_ = (jlong) (intptr_t) zsock_new_scatter (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); return new_scatter_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1destroy (JNIEnv *env, jclass c, jlong self) { zsock_destroy ((zsock_t **) &self); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1bind (JNIEnv *env, jclass c, jlong self, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); jint bind_ = (jint) zsock_bind ((zsock_t *) (intptr_t) self, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); return bind_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1endpoint (JNIEnv *env, jclass c, jlong self) { char *endpoint_ = (char *) zsock_endpoint ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, endpoint_); return return_string_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1unbind (JNIEnv *env, jclass c, jlong self, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); jint unbind_ = (jint) zsock_unbind ((zsock_t *) (intptr_t) self, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); return unbind_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1connect (JNIEnv *env, jclass c, jlong self, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); jint connect_ = (jint) zsock_connect ((zsock_t *) (intptr_t) self, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); return connect_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1disconnect (JNIEnv *env, jclass c, jlong self, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); jint disconnect_ = (jint) zsock_disconnect ((zsock_t *) (intptr_t) self, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); return disconnect_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1attach (JNIEnv *env, jclass c, jlong self, jstring endpoints, jboolean serverish) { char *endpoints_ = (char *) (*env)->GetStringUTFChars (env, endpoints, NULL); jint attach_ = (jint) zsock_attach ((zsock_t *) (intptr_t) self, endpoints_, (bool) serverish); (*env)->ReleaseStringUTFChars (env, endpoints, endpoints_); return attach_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1typeStr (JNIEnv *env, jclass c, jlong self) { char *type_str_ = (char *) zsock_type_str ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, type_str_); return return_string_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1send (JNIEnv *env, jclass c, jlong self, jstring picture) { char *picture_ = (char *) (*env)->GetStringUTFChars (env, picture, NULL); jint send_ = (jint) zsock_send ((zsock_t *) (intptr_t) self, picture_); (*env)->ReleaseStringUTFChars (env, picture, picture_); return send_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1recv (JNIEnv *env, jclass c, jlong self, jstring picture) { char *picture_ = (char *) (*env)->GetStringUTFChars (env, picture, NULL); jint recv_ = (jint) zsock_recv ((zsock_t *) (intptr_t) self, picture_); (*env)->ReleaseStringUTFChars (env, picture, picture_); return recv_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1bsend (JNIEnv *env, jclass c, jlong self, jstring picture) { char *picture_ = (char *) (*env)->GetStringUTFChars (env, picture, NULL); jint bsend_ = (jint) zsock_bsend ((zsock_t *) (intptr_t) self, picture_); (*env)->ReleaseStringUTFChars (env, picture, picture_); return bsend_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1brecv (JNIEnv *env, jclass c, jlong self, jstring picture) { char *picture_ = (char *) (*env)->GetStringUTFChars (env, picture, NULL); jint brecv_ = (jint) zsock_brecv ((zsock_t *) (intptr_t) self, picture_); (*env)->ReleaseStringUTFChars (env, picture, picture_); return brecv_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1routingId (JNIEnv *env, jclass c, jlong self) { jint routing_id_ = (jint) zsock_routing_id ((zsock_t *) (intptr_t) self); return routing_id_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setRoutingId (JNIEnv *env, jclass c, jlong self, jint routing_id) { zsock_set_routing_id ((zsock_t *) (intptr_t) self, (uint32_t) routing_id); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setUnbounded (JNIEnv *env, jclass c, jlong self) { zsock_set_unbounded ((zsock_t *) (intptr_t) self); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1signal (JNIEnv *env, jclass c, jlong self, jbyte status) { jint signal_ = (jint) zsock_signal ((zsock_t *) (intptr_t) self, (byte) status); return signal_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1wait (JNIEnv *env, jclass c, jlong self) { jint wait_ = (jint) zsock_wait ((zsock_t *) (intptr_t) self); return wait_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1flush (JNIEnv *env, jclass c, jlong self) { zsock_flush ((zsock_t *) (intptr_t) self); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1join (JNIEnv *env, jclass c, jlong self, jstring group) { char *group_ = (char *) (*env)->GetStringUTFChars (env, group, NULL); jint join_ = (jint) zsock_join ((zsock_t *) (intptr_t) self, group_); (*env)->ReleaseStringUTFChars (env, group, group_); return join_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1leave (JNIEnv *env, jclass c, jlong self, jstring group) { char *group_ = (char *) (*env)->GetStringUTFChars (env, group, NULL); jint leave_ = (jint) zsock_leave ((zsock_t *) (intptr_t) self, group_); (*env)->ReleaseStringUTFChars (env, group, group_); return leave_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zsock__1_1is (JNIEnv *env, jclass c, jlong self) { jboolean is_ = (jboolean) zsock_is ((void *) (intptr_t) self); return is_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zsock__1_1resolve (JNIEnv *env, jclass c, jlong self) { jlong resolve_ = (jlong) (intptr_t) zsock_resolve ((void *) (intptr_t) self); return resolve_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1heartbeatIvl (JNIEnv *env, jclass c, jlong self) { jint heartbeat_ivl_ = (jint) zsock_heartbeat_ivl ((zsock_t *) (intptr_t) self); return heartbeat_ivl_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setHeartbeatIvl (JNIEnv *env, jclass c, jlong self, jint heartbeat_ivl) { zsock_set_heartbeat_ivl ((zsock_t *) (intptr_t) self, (int) heartbeat_ivl); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1heartbeatTtl (JNIEnv *env, jclass c, jlong self) { jint heartbeat_ttl_ = (jint) zsock_heartbeat_ttl ((zsock_t *) (intptr_t) self); return heartbeat_ttl_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setHeartbeatTtl (JNIEnv *env, jclass c, jlong self, jint heartbeat_ttl) { zsock_set_heartbeat_ttl ((zsock_t *) (intptr_t) self, (int) heartbeat_ttl); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1heartbeatTimeout (JNIEnv *env, jclass c, jlong self) { jint heartbeat_timeout_ = (jint) zsock_heartbeat_timeout ((zsock_t *) (intptr_t) self); return heartbeat_timeout_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setHeartbeatTimeout (JNIEnv *env, jclass c, jlong self, jint heartbeat_timeout) { zsock_set_heartbeat_timeout ((zsock_t *) (intptr_t) self, (int) heartbeat_timeout); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1useFd (JNIEnv *env, jclass c, jlong self) { jint use_fd_ = (jint) zsock_use_fd ((zsock_t *) (intptr_t) self); return use_fd_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setUseFd (JNIEnv *env, jclass c, jlong self, jint use_fd) { zsock_set_use_fd ((zsock_t *) (intptr_t) self, (int) use_fd); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setXpubManual (JNIEnv *env, jclass c, jlong self, jint xpub_manual) { zsock_set_xpub_manual ((zsock_t *) (intptr_t) self, (int) xpub_manual); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setXpubWelcomeMsg (JNIEnv *env, jclass c, jlong self, jstring xpub_welcome_msg) { char *xpub_welcome_msg_ = (char *) (*env)->GetStringUTFChars (env, xpub_welcome_msg, NULL); zsock_set_xpub_welcome_msg ((zsock_t *) (intptr_t) self, xpub_welcome_msg_); (*env)->ReleaseStringUTFChars (env, xpub_welcome_msg, xpub_welcome_msg_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setStreamNotify (JNIEnv *env, jclass c, jlong self, jint stream_notify) { zsock_set_stream_notify ((zsock_t *) (intptr_t) self, (int) stream_notify); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1invertMatching (JNIEnv *env, jclass c, jlong self) { jint invert_matching_ = (jint) zsock_invert_matching ((zsock_t *) (intptr_t) self); return invert_matching_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setInvertMatching (JNIEnv *env, jclass c, jlong self, jint invert_matching) { zsock_set_invert_matching ((zsock_t *) (intptr_t) self, (int) invert_matching); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setXpubVerboser (JNIEnv *env, jclass c, jlong self, jint xpub_verboser) { zsock_set_xpub_verboser ((zsock_t *) (intptr_t) self, (int) xpub_verboser); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1connectTimeout (JNIEnv *env, jclass c, jlong self) { jint connect_timeout_ = (jint) zsock_connect_timeout ((zsock_t *) (intptr_t) self); return connect_timeout_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setConnectTimeout (JNIEnv *env, jclass c, jlong self, jint connect_timeout) { zsock_set_connect_timeout ((zsock_t *) (intptr_t) self, (int) connect_timeout); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1tcpMaxrt (JNIEnv *env, jclass c, jlong self) { jint tcp_maxrt_ = (jint) zsock_tcp_maxrt ((zsock_t *) (intptr_t) self); return tcp_maxrt_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setTcpMaxrt (JNIEnv *env, jclass c, jlong self, jint tcp_maxrt) { zsock_set_tcp_maxrt ((zsock_t *) (intptr_t) self, (int) tcp_maxrt); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1threadSafe (JNIEnv *env, jclass c, jlong self) { jint thread_safe_ = (jint) zsock_thread_safe ((zsock_t *) (intptr_t) self); return thread_safe_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1multicastMaxtpdu (JNIEnv *env, jclass c, jlong self) { jint multicast_maxtpdu_ = (jint) zsock_multicast_maxtpdu ((zsock_t *) (intptr_t) self); return multicast_maxtpdu_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setMulticastMaxtpdu (JNIEnv *env, jclass c, jlong self, jint multicast_maxtpdu) { zsock_set_multicast_maxtpdu ((zsock_t *) (intptr_t) self, (int) multicast_maxtpdu); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1vmciBufferSize (JNIEnv *env, jclass c, jlong self) { jint vmci_buffer_size_ = (jint) zsock_vmci_buffer_size ((zsock_t *) (intptr_t) self); return vmci_buffer_size_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setVmciBufferSize (JNIEnv *env, jclass c, jlong self, jint vmci_buffer_size) { zsock_set_vmci_buffer_size ((zsock_t *) (intptr_t) self, (int) vmci_buffer_size); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1vmciBufferMinSize (JNIEnv *env, jclass c, jlong self) { jint vmci_buffer_min_size_ = (jint) zsock_vmci_buffer_min_size ((zsock_t *) (intptr_t) self); return vmci_buffer_min_size_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setVmciBufferMinSize (JNIEnv *env, jclass c, jlong self, jint vmci_buffer_min_size) { zsock_set_vmci_buffer_min_size ((zsock_t *) (intptr_t) self, (int) vmci_buffer_min_size); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1vmciBufferMaxSize (JNIEnv *env, jclass c, jlong self) { jint vmci_buffer_max_size_ = (jint) zsock_vmci_buffer_max_size ((zsock_t *) (intptr_t) self); return vmci_buffer_max_size_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setVmciBufferMaxSize (JNIEnv *env, jclass c, jlong self, jint vmci_buffer_max_size) { zsock_set_vmci_buffer_max_size ((zsock_t *) (intptr_t) self, (int) vmci_buffer_max_size); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1vmciConnectTimeout (JNIEnv *env, jclass c, jlong self) { jint vmci_connect_timeout_ = (jint) zsock_vmci_connect_timeout ((zsock_t *) (intptr_t) self); return vmci_connect_timeout_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setVmciConnectTimeout (JNIEnv *env, jclass c, jlong self, jint vmci_connect_timeout) { zsock_set_vmci_connect_timeout ((zsock_t *) (intptr_t) self, (int) vmci_connect_timeout); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1tos (JNIEnv *env, jclass c, jlong self) { jint tos_ = (jint) zsock_tos ((zsock_t *) (intptr_t) self); return tos_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setTos (JNIEnv *env, jclass c, jlong self, jint tos) { zsock_set_tos ((zsock_t *) (intptr_t) self, (int) tos); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setRouterHandover (JNIEnv *env, jclass c, jlong self, jint router_handover) { zsock_set_router_handover ((zsock_t *) (intptr_t) self, (int) router_handover); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setConnectRid (JNIEnv *env, jclass c, jlong self, jstring connect_rid) { char *connect_rid_ = (char *) (*env)->GetStringUTFChars (env, connect_rid, NULL); zsock_set_connect_rid ((zsock_t *) (intptr_t) self, connect_rid_); (*env)->ReleaseStringUTFChars (env, connect_rid, connect_rid_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setConnectRidBin (JNIEnv *env, jclass c, jlong self, jbyteArray connect_rid) { jbyte *connect_rid_ = (byte *) (*env)->GetByteArrayElements (env, connect_rid, 0); zsock_set_connect_rid_bin ((zsock_t *) (intptr_t) self, connect_rid_); (*env)->ReleaseByteArrayElements (env, connect_rid, (jbyte *) connect_rid_, 0); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1handshakeIvl (JNIEnv *env, jclass c, jlong self) { jint handshake_ivl_ = (jint) zsock_handshake_ivl ((zsock_t *) (intptr_t) self); return handshake_ivl_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setHandshakeIvl (JNIEnv *env, jclass c, jlong self, jint handshake_ivl) { zsock_set_handshake_ivl ((zsock_t *) (intptr_t) self, (int) handshake_ivl); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1socksProxy (JNIEnv *env, jclass c, jlong self) { char *socks_proxy_ = (char *) zsock_socks_proxy ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, socks_proxy_); zstr_free (&socks_proxy_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setSocksProxy (JNIEnv *env, jclass c, jlong self, jstring socks_proxy) { char *socks_proxy_ = (char *) (*env)->GetStringUTFChars (env, socks_proxy, NULL); zsock_set_socks_proxy ((zsock_t *) (intptr_t) self, socks_proxy_); (*env)->ReleaseStringUTFChars (env, socks_proxy, socks_proxy_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setXpubNodrop (JNIEnv *env, jclass c, jlong self, jint xpub_nodrop) { zsock_set_xpub_nodrop ((zsock_t *) (intptr_t) self, (int) xpub_nodrop); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setRouterMandatory (JNIEnv *env, jclass c, jlong self, jint router_mandatory) { zsock_set_router_mandatory ((zsock_t *) (intptr_t) self, (int) router_mandatory); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setProbeRouter (JNIEnv *env, jclass c, jlong self, jint probe_router) { zsock_set_probe_router ((zsock_t *) (intptr_t) self, (int) probe_router); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setReqRelaxed (JNIEnv *env, jclass c, jlong self, jint req_relaxed) { zsock_set_req_relaxed ((zsock_t *) (intptr_t) self, (int) req_relaxed); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setReqCorrelate (JNIEnv *env, jclass c, jlong self, jint req_correlate) { zsock_set_req_correlate ((zsock_t *) (intptr_t) self, (int) req_correlate); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setConflate (JNIEnv *env, jclass c, jlong self, jint conflate) { zsock_set_conflate ((zsock_t *) (intptr_t) self, (int) conflate); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1zapDomain (JNIEnv *env, jclass c, jlong self) { char *zap_domain_ = (char *) zsock_zap_domain ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, zap_domain_); zstr_free (&zap_domain_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setZapDomain (JNIEnv *env, jclass c, jlong self, jstring zap_domain) { char *zap_domain_ = (char *) (*env)->GetStringUTFChars (env, zap_domain, NULL); zsock_set_zap_domain ((zsock_t *) (intptr_t) self, zap_domain_); (*env)->ReleaseStringUTFChars (env, zap_domain, zap_domain_); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1mechanism (JNIEnv *env, jclass c, jlong self) { jint mechanism_ = (jint) zsock_mechanism ((zsock_t *) (intptr_t) self); return mechanism_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1plainServer (JNIEnv *env, jclass c, jlong self) { jint plain_server_ = (jint) zsock_plain_server ((zsock_t *) (intptr_t) self); return plain_server_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setPlainServer (JNIEnv *env, jclass c, jlong self, jint plain_server) { zsock_set_plain_server ((zsock_t *) (intptr_t) self, (int) plain_server); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1plainUsername (JNIEnv *env, jclass c, jlong self) { char *plain_username_ = (char *) zsock_plain_username ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, plain_username_); zstr_free (&plain_username_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setPlainUsername (JNIEnv *env, jclass c, jlong self, jstring plain_username) { char *plain_username_ = (char *) (*env)->GetStringUTFChars (env, plain_username, NULL); zsock_set_plain_username ((zsock_t *) (intptr_t) self, plain_username_); (*env)->ReleaseStringUTFChars (env, plain_username, plain_username_); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1plainPassword (JNIEnv *env, jclass c, jlong self) { char *plain_password_ = (char *) zsock_plain_password ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, plain_password_); zstr_free (&plain_password_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setPlainPassword (JNIEnv *env, jclass c, jlong self, jstring plain_password) { char *plain_password_ = (char *) (*env)->GetStringUTFChars (env, plain_password, NULL); zsock_set_plain_password ((zsock_t *) (intptr_t) self, plain_password_); (*env)->ReleaseStringUTFChars (env, plain_password, plain_password_); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1curveServer (JNIEnv *env, jclass c, jlong self) { jint curve_server_ = (jint) zsock_curve_server ((zsock_t *) (intptr_t) self); return curve_server_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setCurveServer (JNIEnv *env, jclass c, jlong self, jint curve_server) { zsock_set_curve_server ((zsock_t *) (intptr_t) self, (int) curve_server); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1curvePublickey (JNIEnv *env, jclass c, jlong self) { char *curve_publickey_ = (char *) zsock_curve_publickey ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, curve_publickey_); zstr_free (&curve_publickey_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setCurvePublickey (JNIEnv *env, jclass c, jlong self, jstring curve_publickey) { char *curve_publickey_ = (char *) (*env)->GetStringUTFChars (env, curve_publickey, NULL); zsock_set_curve_publickey ((zsock_t *) (intptr_t) self, curve_publickey_); (*env)->ReleaseStringUTFChars (env, curve_publickey, curve_publickey_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setCurvePublickeyBin (JNIEnv *env, jclass c, jlong self, jbyteArray curve_publickey) { jbyte *curve_publickey_ = (byte *) (*env)->GetByteArrayElements (env, curve_publickey, 0); zsock_set_curve_publickey_bin ((zsock_t *) (intptr_t) self, curve_publickey_); (*env)->ReleaseByteArrayElements (env, curve_publickey, (jbyte *) curve_publickey_, 0); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1curveSecretkey (JNIEnv *env, jclass c, jlong self) { char *curve_secretkey_ = (char *) zsock_curve_secretkey ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, curve_secretkey_); zstr_free (&curve_secretkey_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setCurveSecretkey (JNIEnv *env, jclass c, jlong self, jstring curve_secretkey) { char *curve_secretkey_ = (char *) (*env)->GetStringUTFChars (env, curve_secretkey, NULL); zsock_set_curve_secretkey ((zsock_t *) (intptr_t) self, curve_secretkey_); (*env)->ReleaseStringUTFChars (env, curve_secretkey, curve_secretkey_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setCurveSecretkeyBin (JNIEnv *env, jclass c, jlong self, jbyteArray curve_secretkey) { jbyte *curve_secretkey_ = (byte *) (*env)->GetByteArrayElements (env, curve_secretkey, 0); zsock_set_curve_secretkey_bin ((zsock_t *) (intptr_t) self, curve_secretkey_); (*env)->ReleaseByteArrayElements (env, curve_secretkey, (jbyte *) curve_secretkey_, 0); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1curveServerkey (JNIEnv *env, jclass c, jlong self) { char *curve_serverkey_ = (char *) zsock_curve_serverkey ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, curve_serverkey_); zstr_free (&curve_serverkey_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setCurveServerkey (JNIEnv *env, jclass c, jlong self, jstring curve_serverkey) { char *curve_serverkey_ = (char *) (*env)->GetStringUTFChars (env, curve_serverkey, NULL); zsock_set_curve_serverkey ((zsock_t *) (intptr_t) self, curve_serverkey_); (*env)->ReleaseStringUTFChars (env, curve_serverkey, curve_serverkey_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setCurveServerkeyBin (JNIEnv *env, jclass c, jlong self, jbyteArray curve_serverkey) { jbyte *curve_serverkey_ = (byte *) (*env)->GetByteArrayElements (env, curve_serverkey, 0); zsock_set_curve_serverkey_bin ((zsock_t *) (intptr_t) self, curve_serverkey_); (*env)->ReleaseByteArrayElements (env, curve_serverkey, (jbyte *) curve_serverkey_, 0); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1gssapiServer (JNIEnv *env, jclass c, jlong self) { jint gssapi_server_ = (jint) zsock_gssapi_server ((zsock_t *) (intptr_t) self); return gssapi_server_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setGssapiServer (JNIEnv *env, jclass c, jlong self, jint gssapi_server) { zsock_set_gssapi_server ((zsock_t *) (intptr_t) self, (int) gssapi_server); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1gssapiPlaintext (JNIEnv *env, jclass c, jlong self) { jint gssapi_plaintext_ = (jint) zsock_gssapi_plaintext ((zsock_t *) (intptr_t) self); return gssapi_plaintext_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setGssapiPlaintext (JNIEnv *env, jclass c, jlong self, jint gssapi_plaintext) { zsock_set_gssapi_plaintext ((zsock_t *) (intptr_t) self, (int) gssapi_plaintext); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1gssapiPrincipal (JNIEnv *env, jclass c, jlong self) { char *gssapi_principal_ = (char *) zsock_gssapi_principal ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, gssapi_principal_); zstr_free (&gssapi_principal_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setGssapiPrincipal (JNIEnv *env, jclass c, jlong self, jstring gssapi_principal) { char *gssapi_principal_ = (char *) (*env)->GetStringUTFChars (env, gssapi_principal, NULL); zsock_set_gssapi_principal ((zsock_t *) (intptr_t) self, gssapi_principal_); (*env)->ReleaseStringUTFChars (env, gssapi_principal, gssapi_principal_); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1gssapiServicePrincipal (JNIEnv *env, jclass c, jlong self) { char *gssapi_service_principal_ = (char *) zsock_gssapi_service_principal ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, gssapi_service_principal_); zstr_free (&gssapi_service_principal_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setGssapiServicePrincipal (JNIEnv *env, jclass c, jlong self, jstring gssapi_service_principal) { char *gssapi_service_principal_ = (char *) (*env)->GetStringUTFChars (env, gssapi_service_principal, NULL); zsock_set_gssapi_service_principal ((zsock_t *) (intptr_t) self, gssapi_service_principal_); (*env)->ReleaseStringUTFChars (env, gssapi_service_principal, gssapi_service_principal_); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1ipv6 (JNIEnv *env, jclass c, jlong self) { jint ipv6_ = (jint) zsock_ipv6 ((zsock_t *) (intptr_t) self); return ipv6_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setIpv6 (JNIEnv *env, jclass c, jlong self, jint ipv6) { zsock_set_ipv6 ((zsock_t *) (intptr_t) self, (int) ipv6); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1immediate (JNIEnv *env, jclass c, jlong self) { jint immediate_ = (jint) zsock_immediate ((zsock_t *) (intptr_t) self); return immediate_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setImmediate (JNIEnv *env, jclass c, jlong self, jint immediate) { zsock_set_immediate ((zsock_t *) (intptr_t) self, (int) immediate); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1sndhwm (JNIEnv *env, jclass c, jlong self) { jint sndhwm_ = (jint) zsock_sndhwm ((zsock_t *) (intptr_t) self); return sndhwm_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setSndhwm (JNIEnv *env, jclass c, jlong self, jint sndhwm) { zsock_set_sndhwm ((zsock_t *) (intptr_t) self, (int) sndhwm); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1rcvhwm (JNIEnv *env, jclass c, jlong self) { jint rcvhwm_ = (jint) zsock_rcvhwm ((zsock_t *) (intptr_t) self); return rcvhwm_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setRcvhwm (JNIEnv *env, jclass c, jlong self, jint rcvhwm) { zsock_set_rcvhwm ((zsock_t *) (intptr_t) self, (int) rcvhwm); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1maxmsgsize (JNIEnv *env, jclass c, jlong self) { jint maxmsgsize_ = (jint) zsock_maxmsgsize ((zsock_t *) (intptr_t) self); return maxmsgsize_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setMaxmsgsize (JNIEnv *env, jclass c, jlong self, jint maxmsgsize) { zsock_set_maxmsgsize ((zsock_t *) (intptr_t) self, (int) maxmsgsize); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1multicastHops (JNIEnv *env, jclass c, jlong self) { jint multicast_hops_ = (jint) zsock_multicast_hops ((zsock_t *) (intptr_t) self); return multicast_hops_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setMulticastHops (JNIEnv *env, jclass c, jlong self, jint multicast_hops) { zsock_set_multicast_hops ((zsock_t *) (intptr_t) self, (int) multicast_hops); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setXpubVerbose (JNIEnv *env, jclass c, jlong self, jint xpub_verbose) { zsock_set_xpub_verbose ((zsock_t *) (intptr_t) self, (int) xpub_verbose); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1tcpKeepalive (JNIEnv *env, jclass c, jlong self) { jint tcp_keepalive_ = (jint) zsock_tcp_keepalive ((zsock_t *) (intptr_t) self); return tcp_keepalive_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setTcpKeepalive (JNIEnv *env, jclass c, jlong self, jint tcp_keepalive) { zsock_set_tcp_keepalive ((zsock_t *) (intptr_t) self, (int) tcp_keepalive); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1tcpKeepaliveIdle (JNIEnv *env, jclass c, jlong self) { jint tcp_keepalive_idle_ = (jint) zsock_tcp_keepalive_idle ((zsock_t *) (intptr_t) self); return tcp_keepalive_idle_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setTcpKeepaliveIdle (JNIEnv *env, jclass c, jlong self, jint tcp_keepalive_idle) { zsock_set_tcp_keepalive_idle ((zsock_t *) (intptr_t) self, (int) tcp_keepalive_idle); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1tcpKeepaliveCnt (JNIEnv *env, jclass c, jlong self) { jint tcp_keepalive_cnt_ = (jint) zsock_tcp_keepalive_cnt ((zsock_t *) (intptr_t) self); return tcp_keepalive_cnt_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setTcpKeepaliveCnt (JNIEnv *env, jclass c, jlong self, jint tcp_keepalive_cnt) { zsock_set_tcp_keepalive_cnt ((zsock_t *) (intptr_t) self, (int) tcp_keepalive_cnt); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1tcpKeepaliveIntvl (JNIEnv *env, jclass c, jlong self) { jint tcp_keepalive_intvl_ = (jint) zsock_tcp_keepalive_intvl ((zsock_t *) (intptr_t) self); return tcp_keepalive_intvl_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setTcpKeepaliveIntvl (JNIEnv *env, jclass c, jlong self, jint tcp_keepalive_intvl) { zsock_set_tcp_keepalive_intvl ((zsock_t *) (intptr_t) self, (int) tcp_keepalive_intvl); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1tcpAcceptFilter (JNIEnv *env, jclass c, jlong self) { char *tcp_accept_filter_ = (char *) zsock_tcp_accept_filter ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, tcp_accept_filter_); zstr_free (&tcp_accept_filter_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setTcpAcceptFilter (JNIEnv *env, jclass c, jlong self, jstring tcp_accept_filter) { char *tcp_accept_filter_ = (char *) (*env)->GetStringUTFChars (env, tcp_accept_filter, NULL); zsock_set_tcp_accept_filter ((zsock_t *) (intptr_t) self, tcp_accept_filter_); (*env)->ReleaseStringUTFChars (env, tcp_accept_filter, tcp_accept_filter_); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1lastEndpoint (JNIEnv *env, jclass c, jlong self) { char *last_endpoint_ = (char *) zsock_last_endpoint ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, last_endpoint_); zstr_free (&last_endpoint_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setRouterRaw (JNIEnv *env, jclass c, jlong self, jint router_raw) { zsock_set_router_raw ((zsock_t *) (intptr_t) self, (int) router_raw); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1ipv4only (JNIEnv *env, jclass c, jlong self) { jint ipv4only_ = (jint) zsock_ipv4only ((zsock_t *) (intptr_t) self); return ipv4only_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setIpv4only (JNIEnv *env, jclass c, jlong self, jint ipv4only) { zsock_set_ipv4only ((zsock_t *) (intptr_t) self, (int) ipv4only); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setDelayAttachOnConnect (JNIEnv *env, jclass c, jlong self, jint delay_attach_on_connect) { zsock_set_delay_attach_on_connect ((zsock_t *) (intptr_t) self, (int) delay_attach_on_connect); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1hwm (JNIEnv *env, jclass c, jlong self) { jint hwm_ = (jint) zsock_hwm ((zsock_t *) (intptr_t) self); return hwm_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setHwm (JNIEnv *env, jclass c, jlong self, jint hwm) { zsock_set_hwm ((zsock_t *) (intptr_t) self, (int) hwm); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1swap (JNIEnv *env, jclass c, jlong self) { jint swap_ = (jint) zsock_swap ((zsock_t *) (intptr_t) self); return swap_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setSwap (JNIEnv *env, jclass c, jlong self, jint swap) { zsock_set_swap ((zsock_t *) (intptr_t) self, (int) swap); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1affinity (JNIEnv *env, jclass c, jlong self) { jint affinity_ = (jint) zsock_affinity ((zsock_t *) (intptr_t) self); return affinity_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setAffinity (JNIEnv *env, jclass c, jlong self, jint affinity) { zsock_set_affinity ((zsock_t *) (intptr_t) self, (int) affinity); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zsock__1_1identity (JNIEnv *env, jclass c, jlong self) { char *identity_ = (char *) zsock_identity ((zsock_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, identity_); zstr_free (&identity_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setIdentity (JNIEnv *env, jclass c, jlong self, jstring identity) { char *identity_ = (char *) (*env)->GetStringUTFChars (env, identity, NULL); zsock_set_identity ((zsock_t *) (intptr_t) self, identity_); (*env)->ReleaseStringUTFChars (env, identity, identity_); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1rate (JNIEnv *env, jclass c, jlong self) { jint rate_ = (jint) zsock_rate ((zsock_t *) (intptr_t) self); return rate_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setRate (JNIEnv *env, jclass c, jlong self, jint rate) { zsock_set_rate ((zsock_t *) (intptr_t) self, (int) rate); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1recoveryIvl (JNIEnv *env, jclass c, jlong self) { jint recovery_ivl_ = (jint) zsock_recovery_ivl ((zsock_t *) (intptr_t) self); return recovery_ivl_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setRecoveryIvl (JNIEnv *env, jclass c, jlong self, jint recovery_ivl) { zsock_set_recovery_ivl ((zsock_t *) (intptr_t) self, (int) recovery_ivl); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1recoveryIvlMsec (JNIEnv *env, jclass c, jlong self) { jint recovery_ivl_msec_ = (jint) zsock_recovery_ivl_msec ((zsock_t *) (intptr_t) self); return recovery_ivl_msec_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setRecoveryIvlMsec (JNIEnv *env, jclass c, jlong self, jint recovery_ivl_msec) { zsock_set_recovery_ivl_msec ((zsock_t *) (intptr_t) self, (int) recovery_ivl_msec); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1mcastLoop (JNIEnv *env, jclass c, jlong self) { jint mcast_loop_ = (jint) zsock_mcast_loop ((zsock_t *) (intptr_t) self); return mcast_loop_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setMcastLoop (JNIEnv *env, jclass c, jlong self, jint mcast_loop) { zsock_set_mcast_loop ((zsock_t *) (intptr_t) self, (int) mcast_loop); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1rcvtimeo (JNIEnv *env, jclass c, jlong self) { jint rcvtimeo_ = (jint) zsock_rcvtimeo ((zsock_t *) (intptr_t) self); return rcvtimeo_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setRcvtimeo (JNIEnv *env, jclass c, jlong self, jint rcvtimeo) { zsock_set_rcvtimeo ((zsock_t *) (intptr_t) self, (int) rcvtimeo); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1sndtimeo (JNIEnv *env, jclass c, jlong self) { jint sndtimeo_ = (jint) zsock_sndtimeo ((zsock_t *) (intptr_t) self); return sndtimeo_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setSndtimeo (JNIEnv *env, jclass c, jlong self, jint sndtimeo) { zsock_set_sndtimeo ((zsock_t *) (intptr_t) self, (int) sndtimeo); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1sndbuf (JNIEnv *env, jclass c, jlong self) { jint sndbuf_ = (jint) zsock_sndbuf ((zsock_t *) (intptr_t) self); return sndbuf_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setSndbuf (JNIEnv *env, jclass c, jlong self, jint sndbuf) { zsock_set_sndbuf ((zsock_t *) (intptr_t) self, (int) sndbuf); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1rcvbuf (JNIEnv *env, jclass c, jlong self) { jint rcvbuf_ = (jint) zsock_rcvbuf ((zsock_t *) (intptr_t) self); return rcvbuf_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setRcvbuf (JNIEnv *env, jclass c, jlong self, jint rcvbuf) { zsock_set_rcvbuf ((zsock_t *) (intptr_t) self, (int) rcvbuf); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1linger (JNIEnv *env, jclass c, jlong self) { jint linger_ = (jint) zsock_linger ((zsock_t *) (intptr_t) self); return linger_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setLinger (JNIEnv *env, jclass c, jlong self, jint linger) { zsock_set_linger ((zsock_t *) (intptr_t) self, (int) linger); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1reconnectIvl (JNIEnv *env, jclass c, jlong self) { jint reconnect_ivl_ = (jint) zsock_reconnect_ivl ((zsock_t *) (intptr_t) self); return reconnect_ivl_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setReconnectIvl (JNIEnv *env, jclass c, jlong self, jint reconnect_ivl) { zsock_set_reconnect_ivl ((zsock_t *) (intptr_t) self, (int) reconnect_ivl); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1reconnectIvlMax (JNIEnv *env, jclass c, jlong self) { jint reconnect_ivl_max_ = (jint) zsock_reconnect_ivl_max ((zsock_t *) (intptr_t) self); return reconnect_ivl_max_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setReconnectIvlMax (JNIEnv *env, jclass c, jlong self, jint reconnect_ivl_max) { zsock_set_reconnect_ivl_max ((zsock_t *) (intptr_t) self, (int) reconnect_ivl_max); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1backlog (JNIEnv *env, jclass c, jlong self) { jint backlog_ = (jint) zsock_backlog ((zsock_t *) (intptr_t) self); return backlog_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setBacklog (JNIEnv *env, jclass c, jlong self, jint backlog) { zsock_set_backlog ((zsock_t *) (intptr_t) self, (int) backlog); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setSubscribe (JNIEnv *env, jclass c, jlong self, jstring subscribe) { char *subscribe_ = (char *) (*env)->GetStringUTFChars (env, subscribe, NULL); zsock_set_subscribe ((zsock_t *) (intptr_t) self, subscribe_); (*env)->ReleaseStringUTFChars (env, subscribe, subscribe_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1setUnsubscribe (JNIEnv *env, jclass c, jlong self, jstring unsubscribe) { char *unsubscribe_ = (char *) (*env)->GetStringUTFChars (env, unsubscribe, NULL); zsock_set_unsubscribe ((zsock_t *) (intptr_t) self, unsubscribe_); (*env)->ReleaseStringUTFChars (env, unsubscribe, unsubscribe_); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1type (JNIEnv *env, jclass c, jlong self) { jint type_ = (jint) zsock_type ((zsock_t *) (intptr_t) self); return type_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1rcvmore (JNIEnv *env, jclass c, jlong self) { jint rcvmore_ = (jint) zsock_rcvmore ((zsock_t *) (intptr_t) self); return rcvmore_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zsock__1_1events (JNIEnv *env, jclass c, jlong self) { jint events_ = (jint) zsock_events ((zsock_t *) (intptr_t) self); return events_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zsock__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zsock_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zstr.c0000664000372000037200000000755113222211156024311 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zstr.h" JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zstr__1_1recv (JNIEnv *env, jclass c, jlong source) { char *recv_ = (char *) zstr_recv ((void *) (intptr_t) source); jstring return_string_ = (*env)->NewStringUTF (env, recv_); zstr_free (&recv_); return return_string_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zstr__1_1recvCompress (JNIEnv *env, jclass c, jlong source) { char *recv_compress_ = (char *) zstr_recv_compress ((void *) (intptr_t) source); jstring return_string_ = (*env)->NewStringUTF (env, recv_compress_); zstr_free (&recv_compress_); return return_string_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zstr__1_1send (JNIEnv *env, jclass c, jlong dest, jstring string) { char *string_ = (char *) (*env)->GetStringUTFChars (env, string, NULL); jint send_ = (jint) zstr_send ((void *) (intptr_t) dest, string_); (*env)->ReleaseStringUTFChars (env, string, string_); return send_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zstr__1_1sendm (JNIEnv *env, jclass c, jlong dest, jstring string) { char *string_ = (char *) (*env)->GetStringUTFChars (env, string, NULL); jint sendm_ = (jint) zstr_sendm ((void *) (intptr_t) dest, string_); (*env)->ReleaseStringUTFChars (env, string, string_); return sendm_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zstr__1_1sendf (JNIEnv *env, jclass c, jlong dest, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); jint sendf_ = (jint) zstr_sendf ((void *) (intptr_t) dest, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); return sendf_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zstr__1_1sendfm (JNIEnv *env, jclass c, jlong dest, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); jint sendfm_ = (jint) zstr_sendfm ((void *) (intptr_t) dest, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); return sendfm_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zstr__1_1sendx (JNIEnv *env, jclass c, jlong dest, jstring string) { char *string_ = (char *) (*env)->GetStringUTFChars (env, string, NULL); jint sendx_ = (jint) zstr_sendx ((void *) (intptr_t) dest, string_); (*env)->ReleaseStringUTFChars (env, string, string_); return sendx_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zstr__1_1sendCompress (JNIEnv *env, jclass c, jlong dest, jstring string) { char *string_ = (char *) (*env)->GetStringUTFChars (env, string, NULL); jint send_compress_ = (jint) zstr_send_compress ((void *) (intptr_t) dest, string_); (*env)->ReleaseStringUTFChars (env, string, string_); return send_compress_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zstr__1_1sendmCompress (JNIEnv *env, jclass c, jlong dest, jstring string) { char *string_ = (char *) (*env)->GetStringUTFChars (env, string, NULL); jint sendm_compress_ = (jint) zstr_sendm_compress ((void *) (intptr_t) dest, string_); (*env)->ReleaseStringUTFChars (env, string, string_); return sendm_compress_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zstr__1_1str (JNIEnv *env, jclass c, jlong source) { char *str_ = (char *) zstr_str ((void *) (intptr_t) source); jstring return_string_ = (*env)->NewStringUTF (env, str_); zstr_free (&str_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zstr__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zstr_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zconfig.c0000664000372000037200000002161713222211156024745 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zconfig.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1new (JNIEnv *env, jclass c, jstring name, jlong parent) { char *name_ = (char *) (*env)->GetStringUTFChars (env, name, NULL); // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zconfig_new (name_, (zconfig_t *) (intptr_t) parent); (*env)->ReleaseStringUTFChars (env, name, name_); return new_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1load (JNIEnv *env, jclass c, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jlong load_ = (jlong) (intptr_t) zconfig_load (filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return load_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1loadf (JNIEnv *env, jclass c, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); jlong loadf_ = (jlong) (intptr_t) zconfig_loadf ("%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); return loadf_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zconfig__1_1destroy (JNIEnv *env, jclass c, jlong self) { zconfig_destroy ((zconfig_t **) &self); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zconfig__1_1name (JNIEnv *env, jclass c, jlong self) { char *name_ = (char *) zconfig_name ((zconfig_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, name_); return return_string_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zconfig__1_1value (JNIEnv *env, jclass c, jlong self) { char *value_ = (char *) zconfig_value ((zconfig_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, value_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zconfig__1_1put (JNIEnv *env, jclass c, jlong self, jstring path, jstring value) { char *path_ = (char *) (*env)->GetStringUTFChars (env, path, NULL); char *value_ = (char *) (*env)->GetStringUTFChars (env, value, NULL); zconfig_put ((zconfig_t *) (intptr_t) self, path_, value_); (*env)->ReleaseStringUTFChars (env, path, path_); (*env)->ReleaseStringUTFChars (env, value, value_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zconfig__1_1putf (JNIEnv *env, jclass c, jlong self, jstring path, jstring format) { char *path_ = (char *) (*env)->GetStringUTFChars (env, path, NULL); char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zconfig_putf ((zconfig_t *) (intptr_t) self, path_, "%s", format_); (*env)->ReleaseStringUTFChars (env, path, path_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zconfig__1_1get (JNIEnv *env, jclass c, jlong self, jstring path, jstring default_value) { char *path_ = (char *) (*env)->GetStringUTFChars (env, path, NULL); char *default_value_ = (char *) (*env)->GetStringUTFChars (env, default_value, NULL); char *get_ = (char *) zconfig_get ((zconfig_t *) (intptr_t) self, path_, default_value_); jstring return_string_ = (*env)->NewStringUTF (env, get_); (*env)->ReleaseStringUTFChars (env, path, path_); (*env)->ReleaseStringUTFChars (env, default_value, default_value_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zconfig__1_1setName (JNIEnv *env, jclass c, jlong self, jstring name) { char *name_ = (char *) (*env)->GetStringUTFChars (env, name, NULL); zconfig_set_name ((zconfig_t *) (intptr_t) self, name_); (*env)->ReleaseStringUTFChars (env, name, name_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zconfig__1_1setValue (JNIEnv *env, jclass c, jlong self, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zconfig_set_value ((zconfig_t *) (intptr_t) self, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1child (JNIEnv *env, jclass c, jlong self) { jlong child_ = (jlong) (intptr_t) zconfig_child ((zconfig_t *) (intptr_t) self); return child_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1next (JNIEnv *env, jclass c, jlong self) { jlong next_ = (jlong) (intptr_t) zconfig_next ((zconfig_t *) (intptr_t) self); return next_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1locate (JNIEnv *env, jclass c, jlong self, jstring path) { char *path_ = (char *) (*env)->GetStringUTFChars (env, path, NULL); jlong locate_ = (jlong) (intptr_t) zconfig_locate ((zconfig_t *) (intptr_t) self, path_); (*env)->ReleaseStringUTFChars (env, path, path_); return locate_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1atDepth (JNIEnv *env, jclass c, jlong self, jint level) { jlong at_depth_ = (jlong) (intptr_t) zconfig_at_depth ((zconfig_t *) (intptr_t) self, (int) level); return at_depth_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zconfig__1_1setComment (JNIEnv *env, jclass c, jlong self, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zconfig_set_comment ((zconfig_t *) (intptr_t) self, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1comments (JNIEnv *env, jclass c, jlong self) { jlong comments_ = (jlong) (intptr_t) zconfig_comments ((zconfig_t *) (intptr_t) self); return comments_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zconfig__1_1save (JNIEnv *env, jclass c, jlong self, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jint save_ = (jint) zconfig_save ((zconfig_t *) (intptr_t) self, filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return save_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zconfig__1_1savef (JNIEnv *env, jclass c, jlong self, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); jint savef_ = (jint) zconfig_savef ((zconfig_t *) (intptr_t) self, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); return savef_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zconfig__1_1filename (JNIEnv *env, jclass c, jlong self) { char *filename_ = (char *) zconfig_filename ((zconfig_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, filename_); return return_string_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1reload (JNIEnv *env, jclass c, jlong self) { jint reload_ = (jint) zconfig_reload ((zconfig_t **) &self); return self; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1chunkLoad (JNIEnv *env, jclass c, jlong chunk) { jlong chunk_load_ = (jlong) (intptr_t) zconfig_chunk_load ((zchunk_t *) (intptr_t) chunk); return chunk_load_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1chunkSave (JNIEnv *env, jclass c, jlong self) { jlong chunk_save_ = (jlong) (intptr_t) zconfig_chunk_save ((zconfig_t *) (intptr_t) self); return chunk_save_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1strLoad (JNIEnv *env, jclass c, jstring string) { char *string_ = (char *) (*env)->GetStringUTFChars (env, string, NULL); jlong str_load_ = (jlong) (intptr_t) zconfig_str_load (string_); (*env)->ReleaseStringUTFChars (env, string, string_); return str_load_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zconfig__1_1strSave (JNIEnv *env, jclass c, jlong self) { char *str_save_ = (char *) zconfig_str_save ((zconfig_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, str_save_); zstr_free (&str_save_); return return_string_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zconfig__1_1hasChanged (JNIEnv *env, jclass c, jlong self) { jboolean has_changed_ = (jboolean) zconfig_has_changed ((zconfig_t *) (intptr_t) self); return has_changed_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zconfig__1_1removeSubtree (JNIEnv *env, jclass c, jlong self) { zconfig_remove_subtree ((zconfig_t *) (intptr_t) self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zconfig__1_1remove (JNIEnv *env, jclass c, jlong self) { zconfig_remove ((zconfig_t **) &self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zconfig__1_1print (JNIEnv *env, jclass c, jlong self) { zconfig_print ((zconfig_t *) (intptr_t) self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zconfig__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zconfig_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zcert.c0000664000372000037200000001572013222211156024433 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zcert.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zcert__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zcert_new (); return new_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zcert__1_1newFrom (JNIEnv *env, jclass c, jbyteArray public_key, jbyteArray secret_key) { jbyte *public_key_ = (byte *) (*env)->GetByteArrayElements (env, public_key, 0); jbyte *secret_key_ = (byte *) (*env)->GetByteArrayElements (env, secret_key, 0); jlong new_from_ = (jlong) (intptr_t) zcert_new_from (public_key_, secret_key_); (*env)->ReleaseByteArrayElements (env, public_key, (jbyte *) public_key_, 0); (*env)->ReleaseByteArrayElements (env, secret_key, (jbyte *) secret_key_, 0); return new_from_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zcert__1_1newFromTxt (JNIEnv *env, jclass c, jstring public_txt, jstring secret_txt) { char *public_txt_ = (char *) (*env)->GetStringUTFChars (env, public_txt, NULL); char *secret_txt_ = (char *) (*env)->GetStringUTFChars (env, secret_txt, NULL); jlong new_from_txt_ = (jlong) (intptr_t) zcert_new_from_txt (public_txt_, secret_txt_); (*env)->ReleaseStringUTFChars (env, public_txt, public_txt_); (*env)->ReleaseStringUTFChars (env, secret_txt, secret_txt_); return new_from_txt_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zcert__1_1load (JNIEnv *env, jclass c, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jlong load_ = (jlong) (intptr_t) zcert_load (filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return load_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zcert__1_1destroy (JNIEnv *env, jclass c, jlong self) { zcert_destroy ((zcert_t **) &self); } JNIEXPORT jbyteArray JNICALL Java_org_zeromq_czmq_Zcert__1_1publicKey (JNIEnv *env, jclass c, jlong self) { jbyte *public_key_ = (jbyte *) zcert_public_key ((zcert_t *) (intptr_t) self); jint return_size_ = (jint) 32; jbyteArray return_data_ = (*env)->NewByteArray (env, return_size_); (*env)->SetByteArrayRegion (env, return_data_, 0, return_size_, (jbyte *) public_key_); return return_data_; } JNIEXPORT jbyteArray JNICALL Java_org_zeromq_czmq_Zcert__1_1secretKey (JNIEnv *env, jclass c, jlong self) { jbyte *secret_key_ = (jbyte *) zcert_secret_key ((zcert_t *) (intptr_t) self); jint return_size_ = (jint) 32; jbyteArray return_data_ = (*env)->NewByteArray (env, return_size_); (*env)->SetByteArrayRegion (env, return_data_, 0, return_size_, (jbyte *) secret_key_); return return_data_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zcert__1_1publicTxt (JNIEnv *env, jclass c, jlong self) { char *public_txt_ = (char *) zcert_public_txt ((zcert_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, public_txt_); return return_string_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zcert__1_1secretTxt (JNIEnv *env, jclass c, jlong self) { char *secret_txt_ = (char *) zcert_secret_txt ((zcert_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, secret_txt_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zcert__1_1setMeta (JNIEnv *env, jclass c, jlong self, jstring name, jstring format) { char *name_ = (char *) (*env)->GetStringUTFChars (env, name, NULL); char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zcert_set_meta ((zcert_t *) (intptr_t) self, name_, "%s", format_); (*env)->ReleaseStringUTFChars (env, name, name_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zcert__1_1unsetMeta (JNIEnv *env, jclass c, jlong self, jstring name) { char *name_ = (char *) (*env)->GetStringUTFChars (env, name, NULL); zcert_unset_meta ((zcert_t *) (intptr_t) self, name_); (*env)->ReleaseStringUTFChars (env, name, name_); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zcert__1_1meta (JNIEnv *env, jclass c, jlong self, jstring name) { char *name_ = (char *) (*env)->GetStringUTFChars (env, name, NULL); char *meta_ = (char *) zcert_meta ((zcert_t *) (intptr_t) self, name_); jstring return_string_ = (*env)->NewStringUTF (env, meta_); (*env)->ReleaseStringUTFChars (env, name, name_); return return_string_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zcert__1_1metaKeys (JNIEnv *env, jclass c, jlong self) { jlong meta_keys_ = (jlong) (intptr_t) zcert_meta_keys ((zcert_t *) (intptr_t) self); return meta_keys_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zcert__1_1save (JNIEnv *env, jclass c, jlong self, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jint save_ = (jint) zcert_save ((zcert_t *) (intptr_t) self, filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return save_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zcert__1_1savePublic (JNIEnv *env, jclass c, jlong self, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jint save_public_ = (jint) zcert_save_public ((zcert_t *) (intptr_t) self, filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return save_public_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zcert__1_1saveSecret (JNIEnv *env, jclass c, jlong self, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jint save_secret_ = (jint) zcert_save_secret ((zcert_t *) (intptr_t) self, filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return save_secret_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zcert__1_1apply (JNIEnv *env, jclass c, jlong self, jlong socket) { zcert_apply ((zcert_t *) (intptr_t) self, (void *) (intptr_t) socket); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zcert__1_1dup (JNIEnv *env, jclass c, jlong self) { jlong dup_ = (jlong) (intptr_t) zcert_dup ((zcert_t *) (intptr_t) self); return dup_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zcert__1_1eq (JNIEnv *env, jclass c, jlong self, jlong compare) { jboolean eq_ = (jboolean) zcert_eq ((zcert_t *) (intptr_t) self, (zcert_t *) (intptr_t) compare); return eq_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zcert__1_1print (JNIEnv *env, jclass c, jlong self) { zcert_print ((zcert_t *) (intptr_t) self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zcert__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zcert_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zhashx.c0000664000372000037200000001301613222211156024605 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zhashx.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhashx__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zhashx_new (); return new_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhashx__1_1unpack (JNIEnv *env, jclass c, jlong frame) { jlong unpack_ = (jlong) (intptr_t) zhashx_unpack ((zframe_t *) (intptr_t) frame); return unpack_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zhashx__1_1destroy (JNIEnv *env, jclass c, jlong self) { zhashx_destroy ((zhashx_t **) &self); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zhashx__1_1insert (JNIEnv *env, jclass c, jlong self, jlong key, jlong item) { jint insert_ = (jint) zhashx_insert ((zhashx_t *) (intptr_t) self, (const void *) (intptr_t) key, (void *) (intptr_t) item); return insert_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zhashx__1_1update (JNIEnv *env, jclass c, jlong self, jlong key, jlong item) { zhashx_update ((zhashx_t *) (intptr_t) self, (const void *) (intptr_t) key, (void *) (intptr_t) item); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zhashx__1_1delete (JNIEnv *env, jclass c, jlong self, jlong key) { zhashx_delete ((zhashx_t *) (intptr_t) self, (const void *) (intptr_t) key); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zhashx__1_1purge (JNIEnv *env, jclass c, jlong self) { zhashx_purge ((zhashx_t *) (intptr_t) self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhashx__1_1lookup (JNIEnv *env, jclass c, jlong self, jlong key) { jlong lookup_ = (jlong) (intptr_t) zhashx_lookup ((zhashx_t *) (intptr_t) self, (const void *) (intptr_t) key); return lookup_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zhashx__1_1rename (JNIEnv *env, jclass c, jlong self, jlong old_key, jlong new_key) { jint rename_ = (jint) zhashx_rename ((zhashx_t *) (intptr_t) self, (const void *) (intptr_t) old_key, (const void *) (intptr_t) new_key); return rename_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhashx__1_1size (JNIEnv *env, jclass c, jlong self) { jlong size_ = (jlong) zhashx_size ((zhashx_t *) (intptr_t) self); return size_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhashx__1_1keys (JNIEnv *env, jclass c, jlong self) { jlong keys_ = (jlong) (intptr_t) zhashx_keys ((zhashx_t *) (intptr_t) self); return keys_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhashx__1_1values (JNIEnv *env, jclass c, jlong self) { jlong values_ = (jlong) (intptr_t) zhashx_values ((zhashx_t *) (intptr_t) self); return values_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhashx__1_1first (JNIEnv *env, jclass c, jlong self) { jlong first_ = (jlong) (intptr_t) zhashx_first ((zhashx_t *) (intptr_t) self); return first_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhashx__1_1next (JNIEnv *env, jclass c, jlong self) { jlong next_ = (jlong) (intptr_t) zhashx_next ((zhashx_t *) (intptr_t) self); return next_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhashx__1_1cursor (JNIEnv *env, jclass c, jlong self) { jlong cursor_ = (jlong) (intptr_t) zhashx_cursor ((zhashx_t *) (intptr_t) self); return cursor_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zhashx__1_1comment (JNIEnv *env, jclass c, jlong self, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zhashx_comment ((zhashx_t *) (intptr_t) self, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zhashx__1_1save (JNIEnv *env, jclass c, jlong self, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jint save_ = (jint) zhashx_save ((zhashx_t *) (intptr_t) self, filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return save_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zhashx__1_1load (JNIEnv *env, jclass c, jlong self, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jint load_ = (jint) zhashx_load ((zhashx_t *) (intptr_t) self, filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return load_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zhashx__1_1refresh (JNIEnv *env, jclass c, jlong self) { jint refresh_ = (jint) zhashx_refresh ((zhashx_t *) (intptr_t) self); return refresh_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhashx__1_1pack (JNIEnv *env, jclass c, jlong self) { jlong pack_ = (jlong) (intptr_t) zhashx_pack ((zhashx_t *) (intptr_t) self); return pack_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhashx__1_1dup (JNIEnv *env, jclass c, jlong self) { jlong dup_ = (jlong) (intptr_t) zhashx_dup ((zhashx_t *) (intptr_t) self); return dup_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhashx__1_1dupV2 (JNIEnv *env, jclass c, jlong self) { jlong dup_v2_ = (jlong) (intptr_t) zhashx_dup_v2 ((zhashx_t *) (intptr_t) self); return dup_v2_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zhashx__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zhashx_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Ztimerset.c0000664000372000037200000000420213222211156025323 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Ztimerset.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Ztimerset__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) ztimerset_new (); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Ztimerset__1_1destroy (JNIEnv *env, jclass c, jlong self) { ztimerset_destroy ((ztimerset_t **) &self); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Ztimerset__1_1cancel (JNIEnv *env, jclass c, jlong self, jint timer_id) { jint cancel_ = (jint) ztimerset_cancel ((ztimerset_t *) (intptr_t) self, (int) timer_id); return cancel_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Ztimerset__1_1setInterval (JNIEnv *env, jclass c, jlong self, jint timer_id, jlong interval) { jint set_interval_ = (jint) ztimerset_set_interval ((ztimerset_t *) (intptr_t) self, (int) timer_id, (size_t) interval); return set_interval_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Ztimerset__1_1reset (JNIEnv *env, jclass c, jlong self, jint timer_id) { jint reset_ = (jint) ztimerset_reset ((ztimerset_t *) (intptr_t) self, (int) timer_id); return reset_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Ztimerset__1_1timeout (JNIEnv *env, jclass c, jlong self) { jint timeout_ = (jint) ztimerset_timeout ((ztimerset_t *) (intptr_t) self); return timeout_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Ztimerset__1_1execute (JNIEnv *env, jclass c, jlong self) { jint execute_ = (jint) ztimerset_execute ((ztimerset_t *) (intptr_t) self); return execute_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Ztimerset__1_1test (JNIEnv *env, jclass c, jboolean verbose) { ztimerset_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zdir.c0000664000372000037200000000731613222211156024256 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zdir.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zdir__1_1new (JNIEnv *env, jclass c, jstring path, jstring parent) { char *path_ = (char *) (*env)->GetStringUTFChars (env, path, NULL); char *parent_ = (char *) (*env)->GetStringUTFChars (env, parent, NULL); // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zdir_new (path_, parent_); (*env)->ReleaseStringUTFChars (env, path, path_); (*env)->ReleaseStringUTFChars (env, parent, parent_); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zdir__1_1destroy (JNIEnv *env, jclass c, jlong self) { zdir_destroy ((zdir_t **) &self); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zdir__1_1path (JNIEnv *env, jclass c, jlong self) { char *path_ = (char *) zdir_path ((zdir_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, path_); return return_string_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zdir__1_1modified (JNIEnv *env, jclass c, jlong self) { jlong modified_ = (jlong) zdir_modified ((zdir_t *) (intptr_t) self); return modified_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zdir__1_1cursize (JNIEnv *env, jclass c, jlong self) { jlong cursize_ = (jlong) zdir_cursize ((zdir_t *) (intptr_t) self); return cursize_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zdir__1_1count (JNIEnv *env, jclass c, jlong self) { jlong count_ = (jlong) zdir_count ((zdir_t *) (intptr_t) self); return count_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zdir__1_1list (JNIEnv *env, jclass c, jlong self) { jlong list_ = (jlong) (intptr_t) zdir_list ((zdir_t *) (intptr_t) self); return list_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zdir__1_1remove (JNIEnv *env, jclass c, jlong self, jboolean force) { zdir_remove ((zdir_t *) (intptr_t) self, (bool) force); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zdir__1_1diff (JNIEnv *env, jclass c, jlong older, jlong newer, jstring alias) { char *alias_ = (char *) (*env)->GetStringUTFChars (env, alias, NULL); jlong diff_ = (jlong) (intptr_t) zdir_diff ((zdir_t *) (intptr_t) older, (zdir_t *) (intptr_t) newer, alias_); (*env)->ReleaseStringUTFChars (env, alias, alias_); return diff_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zdir__1_1resync (JNIEnv *env, jclass c, jlong self, jstring alias) { char *alias_ = (char *) (*env)->GetStringUTFChars (env, alias, NULL); jlong resync_ = (jlong) (intptr_t) zdir_resync ((zdir_t *) (intptr_t) self, alias_); (*env)->ReleaseStringUTFChars (env, alias, alias_); return resync_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zdir__1_1cache (JNIEnv *env, jclass c, jlong self) { jlong cache_ = (jlong) (intptr_t) zdir_cache ((zdir_t *) (intptr_t) self); return cache_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zdir__1_1print (JNIEnv *env, jclass c, jlong self, jint indent) { zdir_print ((zdir_t *) (intptr_t) self, (int) indent); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zdir__1_1watch (JNIEnv *env, jclass c, jlong pipe, jlong unused) { zdir_watch ((zsock_t *) (intptr_t) pipe, (void *) (intptr_t) unused); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zdir__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zdir_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zloop.c0000664000372000037200000000570613222211156024452 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zloop.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zloop__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zloop_new (); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zloop__1_1destroy (JNIEnv *env, jclass c, jlong self) { zloop_destroy ((zloop_t **) &self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zloop__1_1readerEnd (JNIEnv *env, jclass c, jlong self, jlong sock) { zloop_reader_end ((zloop_t *) (intptr_t) self, (zsock_t *) (intptr_t) sock); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zloop__1_1readerSetTolerant (JNIEnv *env, jclass c, jlong self, jlong sock) { zloop_reader_set_tolerant ((zloop_t *) (intptr_t) self, (zsock_t *) (intptr_t) sock); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zloop__1_1timerEnd (JNIEnv *env, jclass c, jlong self, jint timer_id) { jint timer_end_ = (jint) zloop_timer_end ((zloop_t *) (intptr_t) self, (int) timer_id); return timer_end_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zloop__1_1ticketReset (JNIEnv *env, jclass c, jlong self, jlong handle) { zloop_ticket_reset ((zloop_t *) (intptr_t) self, (void *) (intptr_t) handle); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zloop__1_1ticketDelete (JNIEnv *env, jclass c, jlong self, jlong handle) { zloop_ticket_delete ((zloop_t *) (intptr_t) self, (void *) (intptr_t) handle); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zloop__1_1setTicketDelay (JNIEnv *env, jclass c, jlong self, jlong ticket_delay) { zloop_set_ticket_delay ((zloop_t *) (intptr_t) self, (size_t) ticket_delay); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zloop__1_1setMaxTimers (JNIEnv *env, jclass c, jlong self, jlong max_timers) { zloop_set_max_timers ((zloop_t *) (intptr_t) self, (size_t) max_timers); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zloop__1_1setVerbose (JNIEnv *env, jclass c, jlong self, jboolean verbose) { zloop_set_verbose ((zloop_t *) (intptr_t) self, (bool) verbose); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zloop__1_1setNonstop (JNIEnv *env, jclass c, jlong self, jboolean nonstop) { zloop_set_nonstop ((zloop_t *) (intptr_t) self, (bool) nonstop); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zloop__1_1start (JNIEnv *env, jclass c, jlong self) { jint start_ = (jint) zloop_start ((zloop_t *) (intptr_t) self); return start_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zloop__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zloop_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Ziflist.c0000664000372000037200000000655713222211156025000 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Ziflist.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Ziflist__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) ziflist_new (); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Ziflist__1_1destroy (JNIEnv *env, jclass c, jlong self) { ziflist_destroy ((ziflist_t **) &self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Ziflist__1_1reload (JNIEnv *env, jclass c, jlong self) { ziflist_reload ((ziflist_t *) (intptr_t) self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Ziflist__1_1size (JNIEnv *env, jclass c, jlong self) { jlong size_ = (jlong) ziflist_size ((ziflist_t *) (intptr_t) self); return size_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Ziflist__1_1first (JNIEnv *env, jclass c, jlong self) { char *first_ = (char *) ziflist_first ((ziflist_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, first_); return return_string_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Ziflist__1_1next (JNIEnv *env, jclass c, jlong self) { char *next_ = (char *) ziflist_next ((ziflist_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, next_); return return_string_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Ziflist__1_1address (JNIEnv *env, jclass c, jlong self) { char *address_ = (char *) ziflist_address ((ziflist_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, address_); return return_string_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Ziflist__1_1broadcast (JNIEnv *env, jclass c, jlong self) { char *broadcast_ = (char *) ziflist_broadcast ((ziflist_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, broadcast_); return return_string_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Ziflist__1_1netmask (JNIEnv *env, jclass c, jlong self) { char *netmask_ = (char *) ziflist_netmask ((ziflist_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, netmask_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Ziflist__1_1print (JNIEnv *env, jclass c, jlong self) { ziflist_print ((ziflist_t *) (intptr_t) self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Ziflist__1_1newIpv6 (JNIEnv *env, jclass c) { jlong new_ipv6_ = (jlong) (intptr_t) ziflist_new_ipv6 (); return new_ipv6_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Ziflist__1_1reloadIpv6 (JNIEnv *env, jclass c, jlong self) { ziflist_reload_ipv6 ((ziflist_t *) (intptr_t) self); } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Ziflist__1_1isIpv6 (JNIEnv *env, jclass c, jlong self) { jboolean is_ipv6_ = (jboolean) ziflist_is_ipv6 ((ziflist_t *) (intptr_t) self); return is_ipv6_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Ziflist__1_1test (JNIEnv *env, jclass c, jboolean verbose) { ziflist_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zproc.c0000664000372000037200000002105113222211156024433 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zproc.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zproc__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zproc_new (); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1destroy (JNIEnv *env, jclass c, jlong self) { zproc_destroy ((zproc_t **) &self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1setArgs (JNIEnv *env, jclass c, jlong self, jlong args) { zproc_set_args ((zproc_t *) (intptr_t) self, (zlistx_t *) (intptr_t) args); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1setEnv (JNIEnv *env, jclass c, jlong self, jlong args) { zproc_set_env ((zproc_t *) (intptr_t) self, (zhashx_t *) (intptr_t) args); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1setStdin (JNIEnv *env, jclass c, jlong self, jlong socket) { zproc_set_stdin ((zproc_t *) (intptr_t) self, (void *) (intptr_t) socket); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1setStdout (JNIEnv *env, jclass c, jlong self, jlong socket) { zproc_set_stdout ((zproc_t *) (intptr_t) self, (void *) (intptr_t) socket); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1setStderr (JNIEnv *env, jclass c, jlong self, jlong socket) { zproc_set_stderr ((zproc_t *) (intptr_t) self, (void *) (intptr_t) socket); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zproc__1_1stdin (JNIEnv *env, jclass c, jlong self) { jlong stdin_ = (jlong) (intptr_t) zproc_stdin ((zproc_t *) (intptr_t) self); return stdin_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zproc__1_1stdout (JNIEnv *env, jclass c, jlong self) { jlong stdout_ = (jlong) (intptr_t) zproc_stdout ((zproc_t *) (intptr_t) self); return stdout_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zproc__1_1stderr (JNIEnv *env, jclass c, jlong self) { jlong stderr_ = (jlong) (intptr_t) zproc_stderr ((zproc_t *) (intptr_t) self); return stderr_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zproc__1_1run (JNIEnv *env, jclass c, jlong self) { jint run_ = (jint) zproc_run ((zproc_t *) (intptr_t) self); return run_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zproc__1_1returncode (JNIEnv *env, jclass c, jlong self) { jint returncode_ = (jint) zproc_returncode ((zproc_t *) (intptr_t) self); return returncode_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zproc__1_1pid (JNIEnv *env, jclass c, jlong self) { jint pid_ = (jint) zproc_pid ((zproc_t *) (intptr_t) self); return pid_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zproc__1_1running (JNIEnv *env, jclass c, jlong self) { jboolean running_ = (jboolean) zproc_running ((zproc_t *) (intptr_t) self); return running_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zproc__1_1wait (JNIEnv *env, jclass c, jlong self, jboolean hang) { jint wait_ = (jint) zproc_wait ((zproc_t *) (intptr_t) self, (bool) hang); return wait_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zproc__1_1actor (JNIEnv *env, jclass c, jlong self) { jlong actor_ = (jlong) (intptr_t) zproc_actor ((zproc_t *) (intptr_t) self); return actor_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1kill (JNIEnv *env, jclass c, jlong self, jint signal) { zproc_kill ((zproc_t *) (intptr_t) self, (int) signal); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1setVerbose (JNIEnv *env, jclass c, jlong self, jboolean verbose) { zproc_set_verbose ((zproc_t *) (intptr_t) self, (bool) verbose); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zproc__1_1czmqVersion (JNIEnv *env, jclass c) { jint czmq_version_ = (jint) zproc_czmq_version (); return czmq_version_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zproc__1_1interrupted (JNIEnv *env, jclass c) { jboolean interrupted_ = (jboolean) zproc_interrupted (); return interrupted_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zproc__1_1hasCurve (JNIEnv *env, jclass c) { jboolean has_curve_ = (jboolean) zproc_has_curve (); return has_curve_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zproc__1_1hostname (JNIEnv *env, jclass c) { char *hostname_ = (char *) zproc_hostname (); jstring return_string_ = (*env)->NewStringUTF (env, hostname_); zstr_free (&hostname_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1daemonize (JNIEnv *env, jclass c, jstring workdir) { char *workdir_ = (char *) (*env)->GetStringUTFChars (env, workdir, NULL); zproc_daemonize (workdir_); (*env)->ReleaseStringUTFChars (env, workdir, workdir_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1runAs (JNIEnv *env, jclass c, jstring lockfile, jstring group, jstring user) { char *lockfile_ = (char *) (*env)->GetStringUTFChars (env, lockfile, NULL); char *group_ = (char *) (*env)->GetStringUTFChars (env, group, NULL); char *user_ = (char *) (*env)->GetStringUTFChars (env, user, NULL); zproc_run_as (lockfile_, group_, user_); (*env)->ReleaseStringUTFChars (env, lockfile, lockfile_); (*env)->ReleaseStringUTFChars (env, group, group_); (*env)->ReleaseStringUTFChars (env, user, user_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1setIoThreads (JNIEnv *env, jclass c, jlong io_threads) { zproc_set_io_threads ((size_t) io_threads); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1setMaxSockets (JNIEnv *env, jclass c, jlong max_sockets) { zproc_set_max_sockets ((size_t) max_sockets); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1setBiface (JNIEnv *env, jclass c, jstring value) { char *value_ = (char *) (*env)->GetStringUTFChars (env, value, NULL); zproc_set_biface (value_); (*env)->ReleaseStringUTFChars (env, value, value_); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zproc__1_1biface (JNIEnv *env, jclass c) { char *biface_ = (char *) zproc_biface (); jstring return_string_ = (*env)->NewStringUTF (env, biface_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1setLogIdent (JNIEnv *env, jclass c, jstring value) { char *value_ = (char *) (*env)->GetStringUTFChars (env, value, NULL); zproc_set_log_ident (value_); (*env)->ReleaseStringUTFChars (env, value, value_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1setLogSender (JNIEnv *env, jclass c, jstring endpoint) { char *endpoint_ = (char *) (*env)->GetStringUTFChars (env, endpoint, NULL); zproc_set_log_sender (endpoint_); (*env)->ReleaseStringUTFChars (env, endpoint, endpoint_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1setLogSystem (JNIEnv *env, jclass c, jboolean logsystem) { zproc_set_log_system ((bool) logsystem); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1logError (JNIEnv *env, jclass c, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zproc_log_error ("%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1logWarning (JNIEnv *env, jclass c, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zproc_log_warning ("%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1logNotice (JNIEnv *env, jclass c, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zproc_log_notice ("%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1logInfo (JNIEnv *env, jclass c, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zproc_log_info ("%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1logDebug (JNIEnv *env, jclass c, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zproc_log_debug ("%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zproc__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zproc_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zdigest.c0000664000372000037200000000433213222211156024752 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zdigest.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zdigest__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zdigest_new (); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zdigest__1_1destroy (JNIEnv *env, jclass c, jlong self) { zdigest_destroy ((zdigest_t **) &self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zdigest__1_1update (JNIEnv *env, jclass c, jlong self, jbyteArray buffer, jlong length) { jbyte *buffer_ = (byte *) (*env)->GetByteArrayElements (env, buffer, 0); zdigest_update ((zdigest_t *) (intptr_t) self, buffer_, (size_t) length); (*env)->ReleaseByteArrayElements (env, buffer, (jbyte *) buffer_, 0); } JNIEXPORT jbyteArray JNICALL Java_org_zeromq_czmq_Zdigest__1_1data (JNIEnv *env, jclass c, jlong self) { jbyte *data_ = (jbyte *) zdigest_data ((zdigest_t *) (intptr_t) self); jint return_size_ = (jint) zdigest_size ((zdigest_t *) (intptr_t) self); jbyteArray return_data_ = (*env)->NewByteArray (env, return_size_); (*env)->SetByteArrayRegion (env, return_data_, 0, return_size_, (jbyte *) data_); return return_data_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zdigest__1_1size (JNIEnv *env, jclass c, jlong self) { jlong size_ = (jlong) zdigest_size ((zdigest_t *) (intptr_t) self); return size_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zdigest__1_1string (JNIEnv *env, jclass c, jlong self) { char *string_ = (char *) zdigest_string ((zdigest_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, string_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zdigest__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zdigest_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zhash.c0000664000372000037200000001335113222211156024417 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zhash.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhash__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zhash_new (); return new_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhash__1_1unpack (JNIEnv *env, jclass c, jlong frame) { jlong unpack_ = (jlong) (intptr_t) zhash_unpack ((zframe_t *) (intptr_t) frame); return unpack_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zhash__1_1destroy (JNIEnv *env, jclass c, jlong self) { zhash_destroy ((zhash_t **) &self); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zhash__1_1insert (JNIEnv *env, jclass c, jlong self, jstring key, jlong item) { char *key_ = (char *) (*env)->GetStringUTFChars (env, key, NULL); jint insert_ = (jint) zhash_insert ((zhash_t *) (intptr_t) self, key_, (void *) (intptr_t) item); (*env)->ReleaseStringUTFChars (env, key, key_); return insert_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zhash__1_1update (JNIEnv *env, jclass c, jlong self, jstring key, jlong item) { char *key_ = (char *) (*env)->GetStringUTFChars (env, key, NULL); zhash_update ((zhash_t *) (intptr_t) self, key_, (void *) (intptr_t) item); (*env)->ReleaseStringUTFChars (env, key, key_); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zhash__1_1delete (JNIEnv *env, jclass c, jlong self, jstring key) { char *key_ = (char *) (*env)->GetStringUTFChars (env, key, NULL); zhash_delete ((zhash_t *) (intptr_t) self, key_); (*env)->ReleaseStringUTFChars (env, key, key_); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhash__1_1lookup (JNIEnv *env, jclass c, jlong self, jstring key) { char *key_ = (char *) (*env)->GetStringUTFChars (env, key, NULL); jlong lookup_ = (jlong) (intptr_t) zhash_lookup ((zhash_t *) (intptr_t) self, key_); (*env)->ReleaseStringUTFChars (env, key, key_); return lookup_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zhash__1_1rename (JNIEnv *env, jclass c, jlong self, jstring old_key, jstring new_key) { char *old_key_ = (char *) (*env)->GetStringUTFChars (env, old_key, NULL); char *new_key_ = (char *) (*env)->GetStringUTFChars (env, new_key, NULL); jint rename_ = (jint) zhash_rename ((zhash_t *) (intptr_t) self, old_key_, new_key_); (*env)->ReleaseStringUTFChars (env, old_key, old_key_); (*env)->ReleaseStringUTFChars (env, new_key, new_key_); return rename_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhash__1_1size (JNIEnv *env, jclass c, jlong self) { jlong size_ = (jlong) zhash_size ((zhash_t *) (intptr_t) self); return size_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhash__1_1dup (JNIEnv *env, jclass c, jlong self) { jlong dup_ = (jlong) (intptr_t) zhash_dup ((zhash_t *) (intptr_t) self); return dup_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhash__1_1keys (JNIEnv *env, jclass c, jlong self) { jlong keys_ = (jlong) (intptr_t) zhash_keys ((zhash_t *) (intptr_t) self); return keys_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhash__1_1first (JNIEnv *env, jclass c, jlong self) { jlong first_ = (jlong) (intptr_t) zhash_first ((zhash_t *) (intptr_t) self); return first_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhash__1_1next (JNIEnv *env, jclass c, jlong self) { jlong next_ = (jlong) (intptr_t) zhash_next ((zhash_t *) (intptr_t) self); return next_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zhash__1_1cursor (JNIEnv *env, jclass c, jlong self) { char *cursor_ = (char *) zhash_cursor ((zhash_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, cursor_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zhash__1_1comment (JNIEnv *env, jclass c, jlong self, jstring format) { char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL); zhash_comment ((zhash_t *) (intptr_t) self, "%s", format_); (*env)->ReleaseStringUTFChars (env, format, format_); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zhash__1_1pack (JNIEnv *env, jclass c, jlong self) { jlong pack_ = (jlong) (intptr_t) zhash_pack ((zhash_t *) (intptr_t) self); return pack_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zhash__1_1save (JNIEnv *env, jclass c, jlong self, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jint save_ = (jint) zhash_save ((zhash_t *) (intptr_t) self, filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return save_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zhash__1_1load (JNIEnv *env, jclass c, jlong self, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jint load_ = (jint) zhash_load ((zhash_t *) (intptr_t) self, filename_); (*env)->ReleaseStringUTFChars (env, filename, filename_); return load_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zhash__1_1refresh (JNIEnv *env, jclass c, jlong self) { jint refresh_ = (jint) zhash_refresh ((zhash_t *) (intptr_t) self); return refresh_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zhash__1_1autofree (JNIEnv *env, jclass c, jlong self) { zhash_autofree ((zhash_t *) (intptr_t) self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zhash__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zhash_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zfile.c0000664000372000037200000001333713222211156024417 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zfile.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zfile__1_1new (JNIEnv *env, jclass c, jstring path, jstring name) { char *path_ = (char *) (*env)->GetStringUTFChars (env, path, NULL); char *name_ = (char *) (*env)->GetStringUTFChars (env, name, NULL); // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zfile_new (path_, name_); (*env)->ReleaseStringUTFChars (env, path, path_); (*env)->ReleaseStringUTFChars (env, name, name_); return new_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zfile__1_1tmp (JNIEnv *env, jclass c) { jlong tmp_ = (jlong) (intptr_t) zfile_tmp (); return tmp_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zfile__1_1destroy (JNIEnv *env, jclass c, jlong self) { zfile_destroy ((zfile_t **) &self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zfile__1_1dup (JNIEnv *env, jclass c, jlong self) { jlong dup_ = (jlong) (intptr_t) zfile_dup ((zfile_t *) (intptr_t) self); return dup_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zfile__1_1filename (JNIEnv *env, jclass c, jlong self, jstring path) { char *path_ = (char *) (*env)->GetStringUTFChars (env, path, NULL); char *filename_ = (char *) zfile_filename ((zfile_t *) (intptr_t) self, path_); jstring return_string_ = (*env)->NewStringUTF (env, filename_); (*env)->ReleaseStringUTFChars (env, path, path_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zfile__1_1restat (JNIEnv *env, jclass c, jlong self) { zfile_restat ((zfile_t *) (intptr_t) self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zfile__1_1modified (JNIEnv *env, jclass c, jlong self) { jlong modified_ = (jlong) zfile_modified ((zfile_t *) (intptr_t) self); return modified_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zfile__1_1cursize (JNIEnv *env, jclass c, jlong self) { jlong cursize_ = (jlong) zfile_cursize ((zfile_t *) (intptr_t) self); return cursize_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zfile__1_1isDirectory (JNIEnv *env, jclass c, jlong self) { jboolean is_directory_ = (jboolean) zfile_is_directory ((zfile_t *) (intptr_t) self); return is_directory_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zfile__1_1isRegular (JNIEnv *env, jclass c, jlong self) { jboolean is_regular_ = (jboolean) zfile_is_regular ((zfile_t *) (intptr_t) self); return is_regular_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zfile__1_1isReadable (JNIEnv *env, jclass c, jlong self) { jboolean is_readable_ = (jboolean) zfile_is_readable ((zfile_t *) (intptr_t) self); return is_readable_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zfile__1_1isWriteable (JNIEnv *env, jclass c, jlong self) { jboolean is_writeable_ = (jboolean) zfile_is_writeable ((zfile_t *) (intptr_t) self); return is_writeable_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zfile__1_1isStable (JNIEnv *env, jclass c, jlong self) { jboolean is_stable_ = (jboolean) zfile_is_stable ((zfile_t *) (intptr_t) self); return is_stable_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zfile__1_1hasChanged (JNIEnv *env, jclass c, jlong self) { jboolean has_changed_ = (jboolean) zfile_has_changed ((zfile_t *) (intptr_t) self); return has_changed_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zfile__1_1remove (JNIEnv *env, jclass c, jlong self) { zfile_remove ((zfile_t *) (intptr_t) self); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zfile__1_1input (JNIEnv *env, jclass c, jlong self) { jint input_ = (jint) zfile_input ((zfile_t *) (intptr_t) self); return input_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zfile__1_1output (JNIEnv *env, jclass c, jlong self) { jint output_ = (jint) zfile_output ((zfile_t *) (intptr_t) self); return output_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zfile__1_1read (JNIEnv *env, jclass c, jlong self, jlong bytes, jlong offset) { jlong read_ = (jlong) (intptr_t) zfile_read ((zfile_t *) (intptr_t) self, (size_t) bytes, (off_t) offset); return read_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zfile__1_1eof (JNIEnv *env, jclass c, jlong self) { jboolean eof_ = (jboolean) zfile_eof ((zfile_t *) (intptr_t) self); return eof_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zfile__1_1write (JNIEnv *env, jclass c, jlong self, jlong chunk, jlong offset) { jint write_ = (jint) zfile_write ((zfile_t *) (intptr_t) self, (zchunk_t *) (intptr_t) chunk, (off_t) offset); return write_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zfile__1_1readln (JNIEnv *env, jclass c, jlong self) { char *readln_ = (char *) zfile_readln ((zfile_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, readln_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zfile__1_1close (JNIEnv *env, jclass c, jlong self) { zfile_close ((zfile_t *) (intptr_t) self); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zfile__1_1digest (JNIEnv *env, jclass c, jlong self) { char *digest_ = (char *) zfile_digest ((zfile_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, digest_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zfile__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zfile_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_ZdirPatch.c0000664000372000037200000000565513222211156025242 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_ZdirPatch.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_ZdirPatch__1_1new (JNIEnv *env, jclass c, jstring path, jlong file, jint op, jstring alias) { char *path_ = (char *) (*env)->GetStringUTFChars (env, path, NULL); char *alias_ = (char *) (*env)->GetStringUTFChars (env, alias, NULL); // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zdir_patch_new (path_, (zfile_t *) (intptr_t) file, (int) op, alias_); (*env)->ReleaseStringUTFChars (env, path, path_); (*env)->ReleaseStringUTFChars (env, alias, alias_); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_ZdirPatch__1_1destroy (JNIEnv *env, jclass c, jlong self) { zdir_patch_destroy ((zdir_patch_t **) &self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_ZdirPatch__1_1dup (JNIEnv *env, jclass c, jlong self) { jlong dup_ = (jlong) (intptr_t) zdir_patch_dup ((zdir_patch_t *) (intptr_t) self); return dup_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_ZdirPatch__1_1path (JNIEnv *env, jclass c, jlong self) { char *path_ = (char *) zdir_patch_path ((zdir_patch_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, path_); return return_string_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_ZdirPatch__1_1file (JNIEnv *env, jclass c, jlong self) { jlong file_ = (jlong) (intptr_t) zdir_patch_file ((zdir_patch_t *) (intptr_t) self); return file_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_ZdirPatch__1_1op (JNIEnv *env, jclass c, jlong self) { jint op_ = (jint) zdir_patch_op ((zdir_patch_t *) (intptr_t) self); return op_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_ZdirPatch__1_1vpath (JNIEnv *env, jclass c, jlong self) { char *vpath_ = (char *) zdir_patch_vpath ((zdir_patch_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, vpath_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_ZdirPatch__1_1digestSet (JNIEnv *env, jclass c, jlong self) { zdir_patch_digest_set ((zdir_patch_t *) (intptr_t) self); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_ZdirPatch__1_1digest (JNIEnv *env, jclass c, jlong self) { char *digest_ = (char *) zdir_patch_digest ((zdir_patch_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, digest_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_ZdirPatch__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zdir_patch_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zuuid.c0000664000372000037200000001054113222211156024440 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zuuid.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zuuid__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zuuid_new (); return new_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zuuid__1_1newFrom (JNIEnv *env, jclass c, jbyteArray source) { jbyte *source_ = (byte *) (*env)->GetByteArrayElements (env, source, 0); jlong new_from_ = (jlong) (intptr_t) zuuid_new_from (source_); (*env)->ReleaseByteArrayElements (env, source, (jbyte *) source_, 0); return new_from_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zuuid__1_1destroy (JNIEnv *env, jclass c, jlong self) { zuuid_destroy ((zuuid_t **) &self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zuuid__1_1set (JNIEnv *env, jclass c, jlong self, jbyteArray source) { jbyte *source_ = (byte *) (*env)->GetByteArrayElements (env, source, 0); zuuid_set ((zuuid_t *) (intptr_t) self, source_); (*env)->ReleaseByteArrayElements (env, source, (jbyte *) source_, 0); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zuuid__1_1setStr (JNIEnv *env, jclass c, jlong self, jstring source) { char *source_ = (char *) (*env)->GetStringUTFChars (env, source, NULL); jint set_str_ = (jint) zuuid_set_str ((zuuid_t *) (intptr_t) self, source_); (*env)->ReleaseStringUTFChars (env, source, source_); return set_str_; } JNIEXPORT jbyteArray JNICALL Java_org_zeromq_czmq_Zuuid__1_1data (JNIEnv *env, jclass c, jlong self) { jbyte *data_ = (jbyte *) zuuid_data ((zuuid_t *) (intptr_t) self); jint return_size_ = (jint) zuuid_size ((zuuid_t *) (intptr_t) self); jbyteArray return_data_ = (*env)->NewByteArray (env, return_size_); (*env)->SetByteArrayRegion (env, return_data_, 0, return_size_, (jbyte *) data_); return return_data_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zuuid__1_1size (JNIEnv *env, jclass c, jlong self) { jlong size_ = (jlong) zuuid_size ((zuuid_t *) (intptr_t) self); return size_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zuuid__1_1str (JNIEnv *env, jclass c, jlong self) { char *str_ = (char *) zuuid_str ((zuuid_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, str_); return return_string_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zuuid__1_1strCanonical (JNIEnv *env, jclass c, jlong self) { char *str_canonical_ = (char *) zuuid_str_canonical ((zuuid_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, str_canonical_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zuuid__1_1export (JNIEnv *env, jclass c, jlong self, jbyteArray target) { jbyte *target_ = (byte *) (*env)->GetByteArrayElements (env, target, 0); zuuid_export ((zuuid_t *) (intptr_t) self, target_); (*env)->ReleaseByteArrayElements (env, target, (jbyte *) target_, 0); } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zuuid__1_1eq (JNIEnv *env, jclass c, jlong self, jbyteArray compare) { jbyte *compare_ = (byte *) (*env)->GetByteArrayElements (env, compare, 0); jboolean eq_ = (jboolean) zuuid_eq ((zuuid_t *) (intptr_t) self, compare_); (*env)->ReleaseByteArrayElements (env, compare, (jbyte *) compare_, 0); return eq_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zuuid__1_1neq (JNIEnv *env, jclass c, jlong self, jbyteArray compare) { jbyte *compare_ = (byte *) (*env)->GetByteArrayElements (env, compare, 0); jboolean neq_ = (jboolean) zuuid_neq ((zuuid_t *) (intptr_t) self, compare_); (*env)->ReleaseByteArrayElements (env, compare, (jbyte *) compare_, 0); return neq_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zuuid__1_1dup (JNIEnv *env, jclass c, jlong self) { jlong dup_ = (jlong) (intptr_t) zuuid_dup ((zuuid_t *) (intptr_t) self); return dup_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zuuid__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zuuid_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zchunk.c0000664000372000037200000001472313222211156024610 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zchunk.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zchunk__1_1new (JNIEnv *env, jclass c, jbyteArray data, jlong size) { jbyte *data_ = (byte *) (*env)->GetByteArrayElements (env, data, 0); // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zchunk_new (data_, (size_t) size); (*env)->ReleaseByteArrayElements (env, data, (jbyte *) data_, 0); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zchunk__1_1destroy (JNIEnv *env, jclass c, jlong self) { zchunk_destroy ((zchunk_t **) &self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zchunk__1_1resize (JNIEnv *env, jclass c, jlong self, jlong size) { zchunk_resize ((zchunk_t *) (intptr_t) self, (size_t) size); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zchunk__1_1size (JNIEnv *env, jclass c, jlong self) { jlong size_ = (jlong) zchunk_size ((zchunk_t *) (intptr_t) self); return size_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zchunk__1_1maxSize (JNIEnv *env, jclass c, jlong self) { jlong max_size_ = (jlong) zchunk_max_size ((zchunk_t *) (intptr_t) self); return max_size_; } JNIEXPORT jbyteArray JNICALL Java_org_zeromq_czmq_Zchunk__1_1data (JNIEnv *env, jclass c, jlong self) { jbyte *data_ = (jbyte *) zchunk_data ((zchunk_t *) (intptr_t) self); jint return_size_ = (jint) zchunk_size ((zchunk_t *) (intptr_t) self); jbyteArray return_data_ = (*env)->NewByteArray (env, return_size_); (*env)->SetByteArrayRegion (env, return_data_, 0, return_size_, (jbyte *) data_); return return_data_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zchunk__1_1set (JNIEnv *env, jclass c, jlong self, jbyteArray data, jlong size) { jbyte *data_ = (byte *) (*env)->GetByteArrayElements (env, data, 0); jlong set_ = (jlong) zchunk_set ((zchunk_t *) (intptr_t) self, data_, (size_t) size); (*env)->ReleaseByteArrayElements (env, data, (jbyte *) data_, 0); return set_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zchunk__1_1fill (JNIEnv *env, jclass c, jlong self, jbyte filler, jlong size) { jlong fill_ = (jlong) zchunk_fill ((zchunk_t *) (intptr_t) self, (byte) filler, (size_t) size); return fill_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zchunk__1_1append (JNIEnv *env, jclass c, jlong self, jbyteArray data, jlong size) { jbyte *data_ = (byte *) (*env)->GetByteArrayElements (env, data, 0); jlong append_ = (jlong) zchunk_append ((zchunk_t *) (intptr_t) self, data_, (size_t) size); (*env)->ReleaseByteArrayElements (env, data, (jbyte *) data_, 0); return append_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zchunk__1_1extend (JNIEnv *env, jclass c, jlong self, jbyteArray data, jlong size) { jbyte *data_ = (byte *) (*env)->GetByteArrayElements (env, data, 0); jlong extend_ = (jlong) zchunk_extend ((zchunk_t *) (intptr_t) self, data_, (size_t) size); (*env)->ReleaseByteArrayElements (env, data, (jbyte *) data_, 0); return extend_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zchunk__1_1consume (JNIEnv *env, jclass c, jlong self, jlong source) { jlong consume_ = (jlong) zchunk_consume ((zchunk_t *) (intptr_t) self, (zchunk_t *) (intptr_t) source); return consume_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zchunk__1_1exhausted (JNIEnv *env, jclass c, jlong self) { jboolean exhausted_ = (jboolean) zchunk_exhausted ((zchunk_t *) (intptr_t) self); return exhausted_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zchunk__1_1slurp (JNIEnv *env, jclass c, jstring filename, jlong maxsize) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); jlong slurp_ = (jlong) (intptr_t) zchunk_slurp (filename_, (size_t) maxsize); (*env)->ReleaseStringUTFChars (env, filename, filename_); return slurp_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zchunk__1_1dup (JNIEnv *env, jclass c, jlong self) { jlong dup_ = (jlong) (intptr_t) zchunk_dup ((zchunk_t *) (intptr_t) self); return dup_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zchunk__1_1strhex (JNIEnv *env, jclass c, jlong self) { char *strhex_ = (char *) zchunk_strhex ((zchunk_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, strhex_); zstr_free (&strhex_); return return_string_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zchunk__1_1strdup (JNIEnv *env, jclass c, jlong self) { char *strdup_ = (char *) zchunk_strdup ((zchunk_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, strdup_); zstr_free (&strdup_); return return_string_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zchunk__1_1streq (JNIEnv *env, jclass c, jlong self, jstring string) { char *string_ = (char *) (*env)->GetStringUTFChars (env, string, NULL); jboolean streq_ = (jboolean) zchunk_streq ((zchunk_t *) (intptr_t) self, string_); (*env)->ReleaseStringUTFChars (env, string, string_); return streq_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zchunk__1_1pack (JNIEnv *env, jclass c, jlong self) { jlong pack_ = (jlong) (intptr_t) zchunk_pack ((zchunk_t *) (intptr_t) self); return pack_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zchunk__1_1unpack (JNIEnv *env, jclass c, jlong frame) { jlong unpack_ = (jlong) (intptr_t) zchunk_unpack ((zframe_t *) (intptr_t) frame); return unpack_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zchunk__1_1digest (JNIEnv *env, jclass c, jlong self) { char *digest_ = (char *) zchunk_digest ((zchunk_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, digest_); return return_string_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zchunk__1_1print (JNIEnv *env, jclass c, jlong self) { zchunk_print ((zchunk_t *) (intptr_t) self); } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zchunk__1_1is (JNIEnv *env, jclass c, jlong self) { jboolean is_ = (jboolean) zchunk_is ((void *) (intptr_t) self); return is_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zchunk__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zchunk_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zlistx.c0000664000372000037200000001340513222211156024637 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zlistx.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zlistx_new (); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zlistx__1_1destroy (JNIEnv *env, jclass c, jlong self) { zlistx_destroy ((zlistx_t **) &self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1addStart (JNIEnv *env, jclass c, jlong self, jlong item) { jlong add_start_ = (jlong) (intptr_t) zlistx_add_start ((zlistx_t *) (intptr_t) self, (void *) (intptr_t) item); return add_start_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1addEnd (JNIEnv *env, jclass c, jlong self, jlong item) { jlong add_end_ = (jlong) (intptr_t) zlistx_add_end ((zlistx_t *) (intptr_t) self, (void *) (intptr_t) item); return add_end_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1size (JNIEnv *env, jclass c, jlong self) { jlong size_ = (jlong) zlistx_size ((zlistx_t *) (intptr_t) self); return size_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1head (JNIEnv *env, jclass c, jlong self) { jlong head_ = (jlong) (intptr_t) zlistx_head ((zlistx_t *) (intptr_t) self); return head_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1tail (JNIEnv *env, jclass c, jlong self) { jlong tail_ = (jlong) (intptr_t) zlistx_tail ((zlistx_t *) (intptr_t) self); return tail_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1first (JNIEnv *env, jclass c, jlong self) { jlong first_ = (jlong) (intptr_t) zlistx_first ((zlistx_t *) (intptr_t) self); return first_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1next (JNIEnv *env, jclass c, jlong self) { jlong next_ = (jlong) (intptr_t) zlistx_next ((zlistx_t *) (intptr_t) self); return next_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1prev (JNIEnv *env, jclass c, jlong self) { jlong prev_ = (jlong) (intptr_t) zlistx_prev ((zlistx_t *) (intptr_t) self); return prev_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1last (JNIEnv *env, jclass c, jlong self) { jlong last_ = (jlong) (intptr_t) zlistx_last ((zlistx_t *) (intptr_t) self); return last_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1item (JNIEnv *env, jclass c, jlong self) { jlong item_ = (jlong) (intptr_t) zlistx_item ((zlistx_t *) (intptr_t) self); return item_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1cursor (JNIEnv *env, jclass c, jlong self) { jlong cursor_ = (jlong) (intptr_t) zlistx_cursor ((zlistx_t *) (intptr_t) self); return cursor_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1handleItem (JNIEnv *env, jclass c, jlong handle) { jlong handle_item_ = (jlong) (intptr_t) zlistx_handle_item ((void *) (intptr_t) handle); return handle_item_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1find (JNIEnv *env, jclass c, jlong self, jlong item) { jlong find_ = (jlong) (intptr_t) zlistx_find ((zlistx_t *) (intptr_t) self, (void *) (intptr_t) item); return find_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1detach (JNIEnv *env, jclass c, jlong self, jlong handle) { jlong detach_ = (jlong) (intptr_t) zlistx_detach ((zlistx_t *) (intptr_t) self, (void *) (intptr_t) handle); return detach_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1detachCur (JNIEnv *env, jclass c, jlong self) { jlong detach_cur_ = (jlong) (intptr_t) zlistx_detach_cur ((zlistx_t *) (intptr_t) self); return detach_cur_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zlistx__1_1delete (JNIEnv *env, jclass c, jlong self, jlong handle) { jint delete_ = (jint) zlistx_delete ((zlistx_t *) (intptr_t) self, (void *) (intptr_t) handle); return delete_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zlistx__1_1moveStart (JNIEnv *env, jclass c, jlong self, jlong handle) { zlistx_move_start ((zlistx_t *) (intptr_t) self, (void *) (intptr_t) handle); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zlistx__1_1moveEnd (JNIEnv *env, jclass c, jlong self, jlong handle) { zlistx_move_end ((zlistx_t *) (intptr_t) self, (void *) (intptr_t) handle); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zlistx__1_1purge (JNIEnv *env, jclass c, jlong self) { zlistx_purge ((zlistx_t *) (intptr_t) self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zlistx__1_1sort (JNIEnv *env, jclass c, jlong self) { zlistx_sort ((zlistx_t *) (intptr_t) self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1insert (JNIEnv *env, jclass c, jlong self, jlong item, jboolean low_value) { jlong insert_ = (jlong) (intptr_t) zlistx_insert ((zlistx_t *) (intptr_t) self, (void *) (intptr_t) item, (bool) low_value); return insert_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zlistx__1_1reorder (JNIEnv *env, jclass c, jlong self, jlong handle, jboolean low_value) { zlistx_reorder ((zlistx_t *) (intptr_t) self, (void *) (intptr_t) handle, (bool) low_value); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlistx__1_1dup (JNIEnv *env, jclass c, jlong self) { jlong dup_ = (jlong) (intptr_t) zlistx_dup ((zlistx_t *) (intptr_t) self); return dup_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zlistx__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zlistx_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zframe.c0000664000372000037200000001525013222211156024566 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zframe.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zframe__1_1new (JNIEnv *env, jclass c, jbyteArray data, jlong size) { jbyte *data_ = (byte *) (*env)->GetByteArrayElements (env, data, 0); // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zframe_new (data_, (size_t) size); (*env)->ReleaseByteArrayElements (env, data, (jbyte *) data_, 0); return new_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zframe__1_1newEmpty (JNIEnv *env, jclass c) { jlong new_empty_ = (jlong) (intptr_t) zframe_new_empty (); return new_empty_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zframe__1_1from (JNIEnv *env, jclass c, jstring string) { char *string_ = (char *) (*env)->GetStringUTFChars (env, string, NULL); jlong from_ = (jlong) (intptr_t) zframe_from (string_); (*env)->ReleaseStringUTFChars (env, string, string_); return from_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zframe__1_1recv (JNIEnv *env, jclass c, jlong source) { jlong recv_ = (jlong) (intptr_t) zframe_recv ((void *) (intptr_t) source); return recv_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zframe__1_1destroy (JNIEnv *env, jclass c, jlong self) { zframe_destroy ((zframe_t **) &self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zframe__1_1send (JNIEnv *env, jclass c, jlong self, jlong dest, jint flags) { jint send_ = (jint) zframe_send ((zframe_t **) &self, (void *) (intptr_t) dest, (int) flags); return self; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zframe__1_1size (JNIEnv *env, jclass c, jlong self) { jlong size_ = (jlong) zframe_size ((zframe_t *) (intptr_t) self); return size_; } JNIEXPORT jbyteArray JNICALL Java_org_zeromq_czmq_Zframe__1_1data (JNIEnv *env, jclass c, jlong self) { jbyte *data_ = (jbyte *) zframe_data ((zframe_t *) (intptr_t) self); jint return_size_ = (jint) zframe_size ((zframe_t *) (intptr_t) self); jbyteArray return_data_ = (*env)->NewByteArray (env, return_size_); (*env)->SetByteArrayRegion (env, return_data_, 0, return_size_, (jbyte *) data_); return return_data_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zframe__1_1meta (JNIEnv *env, jclass c, jlong self, jstring property) { char *property_ = (char *) (*env)->GetStringUTFChars (env, property, NULL); char *meta_ = (char *) zframe_meta ((zframe_t *) (intptr_t) self, property_); jstring return_string_ = (*env)->NewStringUTF (env, meta_); (*env)->ReleaseStringUTFChars (env, property, property_); return return_string_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zframe__1_1dup (JNIEnv *env, jclass c, jlong self) { jlong dup_ = (jlong) (intptr_t) zframe_dup ((zframe_t *) (intptr_t) self); return dup_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zframe__1_1strhex (JNIEnv *env, jclass c, jlong self) { char *strhex_ = (char *) zframe_strhex ((zframe_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, strhex_); zstr_free (&strhex_); return return_string_; } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zframe__1_1strdup (JNIEnv *env, jclass c, jlong self) { char *strdup_ = (char *) zframe_strdup ((zframe_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, strdup_); zstr_free (&strdup_); return return_string_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zframe__1_1streq (JNIEnv *env, jclass c, jlong self, jstring string) { char *string_ = (char *) (*env)->GetStringUTFChars (env, string, NULL); jboolean streq_ = (jboolean) zframe_streq ((zframe_t *) (intptr_t) self, string_); (*env)->ReleaseStringUTFChars (env, string, string_); return streq_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zframe__1_1more (JNIEnv *env, jclass c, jlong self) { jint more_ = (jint) zframe_more ((zframe_t *) (intptr_t) self); return more_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zframe__1_1setMore (JNIEnv *env, jclass c, jlong self, jint more) { zframe_set_more ((zframe_t *) (intptr_t) self, (int) more); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zframe__1_1routingId (JNIEnv *env, jclass c, jlong self) { jint routing_id_ = (jint) zframe_routing_id ((zframe_t *) (intptr_t) self); return routing_id_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zframe__1_1setRoutingId (JNIEnv *env, jclass c, jlong self, jint routing_id) { zframe_set_routing_id ((zframe_t *) (intptr_t) self, (uint32_t) routing_id); } JNIEXPORT jstring JNICALL Java_org_zeromq_czmq_Zframe__1_1group (JNIEnv *env, jclass c, jlong self) { char *group_ = (char *) zframe_group ((zframe_t *) (intptr_t) self); jstring return_string_ = (*env)->NewStringUTF (env, group_); return return_string_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zframe__1_1setGroup (JNIEnv *env, jclass c, jlong self, jstring group) { char *group_ = (char *) (*env)->GetStringUTFChars (env, group, NULL); jint set_group_ = (jint) zframe_set_group ((zframe_t *) (intptr_t) self, group_); (*env)->ReleaseStringUTFChars (env, group, group_); return set_group_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zframe__1_1eq (JNIEnv *env, jclass c, jlong self, jlong other) { jboolean eq_ = (jboolean) zframe_eq ((zframe_t *) (intptr_t) self, (zframe_t *) (intptr_t) other); return eq_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zframe__1_1reset (JNIEnv *env, jclass c, jlong self, jbyteArray data, jlong size) { jbyte *data_ = (byte *) (*env)->GetByteArrayElements (env, data, 0); zframe_reset ((zframe_t *) (intptr_t) self, data_, (size_t) size); (*env)->ReleaseByteArrayElements (env, data, (jbyte *) data_, 0); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zframe__1_1print (JNIEnv *env, jclass c, jlong self, jstring prefix) { char *prefix_ = (char *) (*env)->GetStringUTFChars (env, prefix, NULL); zframe_print ((zframe_t *) (intptr_t) self, prefix_); (*env)->ReleaseStringUTFChars (env, prefix, prefix_); } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zframe__1_1is (JNIEnv *env, jclass c, jlong self) { jboolean is_ = (jboolean) zframe_is ((void *) (intptr_t) self); return is_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zframe__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zframe_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zpoller.c0000664000372000037200000000446413222211156024776 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zpoller.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zpoller__1_1new (JNIEnv *env, jclass c, jlong reader) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zpoller_new ((void *) (intptr_t) reader); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zpoller__1_1destroy (JNIEnv *env, jclass c, jlong self) { zpoller_destroy ((zpoller_t **) &self); } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zpoller__1_1add (JNIEnv *env, jclass c, jlong self, jlong reader) { jint add_ = (jint) zpoller_add ((zpoller_t *) (intptr_t) self, (void *) (intptr_t) reader); return add_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zpoller__1_1remove (JNIEnv *env, jclass c, jlong self, jlong reader) { jint remove_ = (jint) zpoller_remove ((zpoller_t *) (intptr_t) self, (void *) (intptr_t) reader); return remove_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zpoller__1_1setNonstop (JNIEnv *env, jclass c, jlong self, jboolean nonstop) { zpoller_set_nonstop ((zpoller_t *) (intptr_t) self, (bool) nonstop); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zpoller__1_1wait (JNIEnv *env, jclass c, jlong self, jint timeout) { jlong wait_ = (jlong) zpoller_wait ((zpoller_t *) (intptr_t) self, (int) timeout); return wait_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zpoller__1_1expired (JNIEnv *env, jclass c, jlong self) { jboolean expired_ = (jboolean) zpoller_expired ((zpoller_t *) (intptr_t) self); return expired_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zpoller__1_1terminated (JNIEnv *env, jclass c, jlong self) { jboolean terminated_ = (jboolean) zpoller_terminated ((zpoller_t *) (intptr_t) self); return terminated_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zpoller__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zpoller_test ((bool) verbose); } czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zlist.c0000664000372000037200000000752213222211156024452 0ustar00travistravis00000000000000/* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ #include #include #include #include "czmq.h" #include "org_zeromq_czmq_Zlist.h" JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlist__1_1new (JNIEnv *env, jclass c) { // Disable CZMQ signal handling; allow Java to deal with it zsys_handler_set (NULL); jlong new_ = (jlong) (intptr_t) zlist_new (); return new_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zlist__1_1destroy (JNIEnv *env, jclass c, jlong self) { zlist_destroy ((zlist_t **) &self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlist__1_1first (JNIEnv *env, jclass c, jlong self) { jlong first_ = (jlong) (intptr_t) zlist_first ((zlist_t *) (intptr_t) self); return first_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlist__1_1next (JNIEnv *env, jclass c, jlong self) { jlong next_ = (jlong) (intptr_t) zlist_next ((zlist_t *) (intptr_t) self); return next_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlist__1_1last (JNIEnv *env, jclass c, jlong self) { jlong last_ = (jlong) (intptr_t) zlist_last ((zlist_t *) (intptr_t) self); return last_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlist__1_1head (JNIEnv *env, jclass c, jlong self) { jlong head_ = (jlong) (intptr_t) zlist_head ((zlist_t *) (intptr_t) self); return head_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlist__1_1tail (JNIEnv *env, jclass c, jlong self) { jlong tail_ = (jlong) (intptr_t) zlist_tail ((zlist_t *) (intptr_t) self); return tail_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlist__1_1item (JNIEnv *env, jclass c, jlong self) { jlong item_ = (jlong) (intptr_t) zlist_item ((zlist_t *) (intptr_t) self); return item_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zlist__1_1append (JNIEnv *env, jclass c, jlong self, jlong item) { jint append_ = (jint) zlist_append ((zlist_t *) (intptr_t) self, (void *) (intptr_t) item); return append_; } JNIEXPORT jint JNICALL Java_org_zeromq_czmq_Zlist__1_1push (JNIEnv *env, jclass c, jlong self, jlong item) { jint push_ = (jint) zlist_push ((zlist_t *) (intptr_t) self, (void *) (intptr_t) item); return push_; } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlist__1_1pop (JNIEnv *env, jclass c, jlong self) { jlong pop_ = (jlong) (intptr_t) zlist_pop ((zlist_t *) (intptr_t) self); return pop_; } JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zlist__1_1exists (JNIEnv *env, jclass c, jlong self, jlong item) { jboolean exists_ = (jboolean) zlist_exists ((zlist_t *) (intptr_t) self, (void *) (intptr_t) item); return exists_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zlist__1_1remove (JNIEnv *env, jclass c, jlong self, jlong item) { zlist_remove ((zlist_t *) (intptr_t) self, (void *) (intptr_t) item); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlist__1_1dup (JNIEnv *env, jclass c, jlong self) { jlong dup_ = (jlong) (intptr_t) zlist_dup ((zlist_t *) (intptr_t) self); return dup_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zlist__1_1purge (JNIEnv *env, jclass c, jlong self) { zlist_purge ((zlist_t *) (intptr_t) self); } JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zlist__1_1size (JNIEnv *env, jclass c, jlong self) { jlong size_ = (jlong) zlist_size ((zlist_t *) (intptr_t) self); return size_; } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zlist__1_1autofree (JNIEnv *env, jclass c, jlong self) { zlist_autofree ((zlist_t *) (intptr_t) self); } JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zlist__1_1test (JNIEnv *env, jclass c, jboolean verbose) { zlist_test ((bool) verbose); } czmq-4.1.0/bindings/python_cffi/0000775000372000037200000000000013222211156017470 5ustar00travistravis00000000000000czmq-4.1.0/bindings/python_cffi/README.md0000664000372000037200000000304713222211156020753 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ #czmq cffi bindings This package contains low level python bindings for czmq based on cffi library. Module is compatible with * The “in-line”, “ABI mode”, which simply **dlopen** main library and parse C declaration on runtime * The “out-of-line”, “API mode”, which build C **native** Python extension #Build the native extension python setup.py build Note you need to have setuptools and cffi packages installed. As well as a checkout of all dependencies at the same level as this project, because all dependant defs.py will be included in project cdefs.py. #Using more cffi modules together While zproject and CLASS encourages you to split your dependencies to smaller libraries, this does not work well for cffi. zproject generated backends have own private cffi instance, which can't be easily combined with others in one function call. See ML thread about topic https://groups.google.com/forum/#!topic/python-cffi/JtAKU-g9Exg This is the reason the Lib and CompiledFFi objects are referenced from utils module and dynamically accessed on each call. Calling `lower.utils.rebind (higher.utils.lib, higher.utils.ffi)' you can change instance used by lower module and enforce all Python classes will use single instance. czmq-4.1.0/bindings/python_cffi/setup.py0000664000372000037200000000203713222211156021204 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ from setuptools import setup setup( name = "czmq_cffi", version = "4.1.0", license = "mplv2", description = """Python cffi bindings of: the high-level c binding for 0mq""", packages = ["czmq_cffi", ], setup_requires=["cffi"], cffi_modules=[ "czmq_cffi/build.py:ffibuilder", "czmq_cffi/build.py:ffidestructorbuilder" ], install_requires=["cffi"], ) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/0000775000372000037200000000000013222211156021431 5ustar00travistravis00000000000000czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zconfig.py0000664000372000037200000001500413222211156023402 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zconfig(object): """ work with config files written in rfc.zeromq.org/spec:4/ZPL. """ def __init__(self, name, parent): """ Create new config item """ p = utils.lib.zconfig_new(utils.to_bytes(name), parent._p) if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zconfig_destroy_py) def name(self): """ Return name of config item """ return utils.lib.zconfig_name(self._p) def value(self): """ Return value of config item """ return utils.lib.zconfig_value(self._p) def put(self, path, value): """ Insert or update configuration key with value """ utils.lib.zconfig_put(self._p, utils.to_bytes(path), utils.to_bytes(value)) def putf(self, path, format, ): """ Equivalent to zconfig_put, accepting a format specifier and variable argument list, instead of a single string value. """ utils.lib.zconfig_putf(self._p, utils.to_bytes(path), format, ) def get(self, path, default_value): """ Get value for config item into a string value; leading slash is optional and ignored. """ return utils.lib.zconfig_get(self._p, utils.to_bytes(path), utils.to_bytes(default_value)) def set_name(self, name): """ Set config item name, name may be NULL """ utils.lib.zconfig_set_name(self._p, utils.to_bytes(name)) def set_value(self, format, ): """ Set new value for config item. The new value may be a string, a printf format, or NULL. Note that if string may possibly contain '%', or if it comes from an insecure source, you must use '%s' as the format, followed by the string. """ utils.lib.zconfig_set_value(self._p, format, ) def child(self): """ Find our first child, if any """ return utils.lib.zconfig_child(self._p) def next(self): """ Find our first sibling, if any """ return utils.lib.zconfig_next(self._p) def locate(self, path): """ Find a config item along a path; leading slash is optional and ignored. """ return utils.lib.zconfig_locate(self._p, utils.to_bytes(path)) def at_depth(self, level): """ Locate the last config item at a specified depth """ return utils.lib.zconfig_at_depth(self._p, level) def execute(self, handler, arg): """ Execute a callback for each config item in the tree; returns zero if successful, else -1. """ return utils.lib.zconfig_execute(self._p, handler, arg._p) def set_comment(self, format, ): """ Add comment to config item before saving to disk. You can add as many comment lines as you like. If you use a null format, all comments are deleted. """ utils.lib.zconfig_set_comment(self._p, format, ) def comments(self): """ Return comments of config item, as zlist. """ return utils.lib.zconfig_comments(self._p) def save(self, filename): """ Save a config tree to a specified ZPL text file, where a filename "-" means dump to standard output. """ return utils.lib.zconfig_save(self._p, utils.to_bytes(filename)) def savef(self, format, ): """ Equivalent to zconfig_save, taking a format string instead of a fixed filename. """ return utils.lib.zconfig_savef(self._p, format, ) def filename(self): """ Report filename used during zconfig_load, or NULL if none """ return utils.lib.zconfig_filename(self._p) def reload(self_p): """ Reload config tree from same file that it was previously loaded from. Returns 0 if OK, -1 if there was an error (and then does not change existing data). """ return utils.lib.zconfig_reload(self_p._p) def chunk_load(chunk): """ Load a config tree from a memory chunk """ return utils.lib.zconfig_chunk_load(chunk._p) def chunk_save(self): """ Save a config tree to a new memory chunk """ return utils.lib.zconfig_chunk_save(self._p) def str_load(string): """ Load a config tree from a null-terminated string """ return utils.lib.zconfig_str_load(utils.to_bytes(string)) def str_save(self): """ Save a config tree to a new null terminated string """ return utils.lib.zconfig_str_save(self._p) def has_changed(self): """ Return true if a configuration tree was loaded from a file and that file has changed in since the tree was loaded. """ return utils.lib.zconfig_has_changed(self._p) def remove_subtree(self): """ Destroy subtree (all children) """ utils.lib.zconfig_remove_subtree(self._p) def remove(self_p): """ Destroy node and subtree (all children) """ utils.lib.zconfig_remove(self_p._p) def fprint(self, file): """ Print the config file to open stream """ utils.lib.zconfig_fprint(self._p, file) def print_py(self): """ Print properties of object """ utils.lib.zconfig_print(self._p) def test(verbose): """ Self test of this class """ utils.lib.zconfig_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zloop.py0000664000372000037200000001615413222211156023115 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zloop(object): """ event-driven reactor """ def __init__(self): """ Create a new zloop reactor """ p = utils.lib.zloop_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zloop_destroy_py) def reader(self, sock, handler, arg): """ Register socket reader with the reactor. When the reader has messages, the reactor will call the handler, passing the arg. Returns 0 if OK, -1 if there was an error. If you register the same socket more than once, each instance will invoke its corresponding handler. """ return utils.lib.zloop_reader(self._p, sock._p, handler, arg._p) def reader_end(self, sock): """ Cancel a socket reader from the reactor. If multiple readers exist for same socket, cancels ALL of them. """ utils.lib.zloop_reader_end(self._p, sock._p) def reader_set_tolerant(self, sock): """ Configure a registered reader to ignore errors. If you do not set this, then readers that have errors are removed from the reactor silently. """ utils.lib.zloop_reader_set_tolerant(self._p, sock._p) def poller(self, item, handler, arg): """ Register low-level libzmq pollitem with the reactor. When the pollitem is ready, will call the handler, passing the arg. Returns 0 if OK, -1 if there was an error. If you register the pollitem more than once, each instance will invoke its corresponding handler. A pollitem with socket=NULL and fd=0 means 'poll on FD zero'. """ return utils.lib.zloop_poller(self._p, item._p, handler, arg._p) def poller_end(self, item): """ Cancel a pollitem from the reactor, specified by socket or FD. If both are specified, uses only socket. If multiple poll items exist for same socket/FD, cancels ALL of them. """ utils.lib.zloop_poller_end(self._p, item._p) def poller_set_tolerant(self, item): """ Configure a registered poller to ignore errors. If you do not set this, then poller that have errors are removed from the reactor silently. """ utils.lib.zloop_poller_set_tolerant(self._p, item._p) def timer(self, delay, times, handler, arg): """ Register a timer that expires after some delay and repeats some number of times. At each expiry, will call the handler, passing the arg. To run a timer forever, use 0 times. Returns a timer_id that is used to cancel the timer in the future. Returns -1 if there was an error. """ return utils.lib.zloop_timer(self._p, delay, times, handler, arg._p) def timer_end(self, timer_id): """ Cancel a specific timer identified by a specific timer_id (as returned by zloop_timer). """ return utils.lib.zloop_timer_end(self._p, timer_id) def ticket(self, handler, arg): """ Register a ticket timer. Ticket timers are very fast in the case where you use a lot of timers (thousands), and frequently remove and add them. The main use case is expiry timers for servers that handle many clients, and which reset the expiry timer for each message received from a client. Whereas normal timers perform poorly as the number of clients grows, the cost of ticket timers is constant, no matter the number of clients. You must set the ticket delay using zloop_set_ticket_delay before creating a ticket. Returns a handle to the timer that you should use in zloop_ticket_reset and zloop_ticket_delete. """ return utils.lib.zloop_ticket(self._p, handler, arg._p) def ticket_reset(self, handle): """ Reset a ticket timer, which moves it to the end of the ticket list and resets its execution time. This is a very fast operation. """ utils.lib.zloop_ticket_reset(self._p, handle._p) def ticket_delete(self, handle): """ Delete a ticket timer. We do not actually delete the ticket here, as other code may still refer to the ticket. We mark as deleted, and remove later and safely. """ utils.lib.zloop_ticket_delete(self._p, handle._p) def set_ticket_delay(self, ticket_delay): """ Set the ticket delay, which applies to all tickets. If you lower the delay and there are already tickets created, the results are undefined. """ utils.lib.zloop_set_ticket_delay(self._p, ticket_delay) def set_max_timers(self, max_timers): """ Set hard limit on number of timers allowed. Setting more than a small number of timers (10-100) can have a dramatic impact on the performance of the reactor. For high-volume cases, use ticket timers. If the hard limit is reached, the reactor stops creating new timers and logs an error. """ utils.lib.zloop_set_max_timers(self._p, max_timers) def set_verbose(self, verbose): """ Set verbose tracing of reactor on/off. The default verbose setting is off (false). """ utils.lib.zloop_set_verbose(self._p, verbose) def set_nonstop(self, nonstop): """ By default the reactor stops if the process receives a SIGINT or SIGTERM signal. This makes it impossible to shut-down message based architectures like zactors. This method lets you switch off break handling. The default nonstop setting is off (false). """ utils.lib.zloop_set_nonstop(self._p, nonstop) def start(self): """ Start the reactor. Takes control of the thread and returns when the 0MQ context is terminated or the process is interrupted, or any event handler returns -1. Event handlers may register new sockets and timers, and cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. """ return utils.lib.zloop_start(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zloop_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/cdefs.py0000664000372000037200000041072013222211156023073 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import re czmq_cdefs = list () # Custom setup for czmq czmq_cdefs.append (''' typedef int time_t; typedef int off_t; typedef unsigned char byte; // Single unsigned byte = 8 bits typedef unsigned short dbyte; // Double byte = 16 bits typedef unsigned int qbyte; // Quad byte = 32 bits typedef int SOCKET; typedef struct sockaddr_in inaddr_t; // -- destroy an item typedef void (czmq_destructor) (void **item); // -- duplicate an item typedef void *(czmq_duplicator) (const void *item); // - compare two items, for sorting typedef int (czmq_comparator) (const void *item1, const void *item2); ''') #Import definitions from dependent projects czmq_cdefs.append (''' typedef struct _zsock_t zsock_t; typedef struct _zactor_t zactor_t; typedef struct _zmsg_t zmsg_t; typedef struct _zargs_t zargs_t; typedef struct _zarmour_t zarmour_t; typedef struct _zchunk_t zchunk_t; typedef struct _char_t char_t; typedef struct _zcert_t zcert_t; typedef struct _zlist_t zlist_t; typedef struct _zcertstore_t zcertstore_t; typedef struct _zlistx_t zlistx_t; typedef struct _zframe_t zframe_t; typedef struct _msecs_t msecs_t; typedef struct _zclock_t zclock_t; typedef struct _zconfig_t zconfig_t; typedef struct _zdigest_t zdigest_t; typedef struct _zdir_t zdir_t; typedef struct _zhash_t zhash_t; typedef struct _zfile_t zfile_t; typedef struct _zdir_patch_t zdir_patch_t; typedef struct _zhashx_t zhashx_t; typedef struct _ziflist_t ziflist_t; typedef struct _zloop_t zloop_t; typedef struct _zmq_pollitem_t zmq_pollitem_t; typedef struct _zpoller_t zpoller_t; typedef struct _zproc_t zproc_t; typedef struct _va_list_t va_list_t; typedef struct _socket_t socket_t; typedef struct _zstr_t zstr_t; typedef struct _zsys_t zsys_t; typedef struct _ztimerset_t ztimerset_t; typedef struct _ztrie_t ztrie_t; typedef struct _zuuid_t zuuid_t; // Actors get a pipe and arguments from caller typedef void (zactor_fn) ( zsock_t *pipe, void *args); // Function to be called on zactor_destroy. Default behavior is to send zmsg_t with string "$TERM" in a first frame. // // An example - to send $KTHXBAI string // // if (zstr_send (self->pipe, "$KTHXBAI") == 0) // zsock_wait (self->pipe); typedef void (zactor_destructor_fn) ( zactor_t *self); // Loaders retrieve certificates from an arbitrary source. typedef void (zcertstore_loader) ( zcertstore_t *self); // Destructor for loader state. typedef void (zcertstore_destructor) ( void **self_p); // typedef int (zconfig_fct) ( zconfig_t *self, void *arg, int level); // Callback function for zhash_freefn method typedef void (zhash_free_fn) ( void *data); // Destroy an item typedef void (zhashx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zhashx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zhashx_comparator_fn) ( const void *item1, const void *item2); // Destroy an item. typedef void (zhashx_free_fn) ( void *data); // Hash function for keys. typedef size_t (zhashx_hash_fn) ( const void *key); // Serializes an item to a longstr. // The caller takes ownership of the newly created object. typedef char * (zhashx_serializer_fn) ( const void *item); // Deserializes a longstr into an item. // The caller takes ownership of the newly created object. typedef void * (zhashx_deserializer_fn) ( const char *item_str); // Comparison function e.g. for sorting and removing. typedef int (zlist_compare_fn) ( void *item1, void *item2); // Callback function for zlist_freefn method typedef void (zlist_free_fn) ( void *data); // Destroy an item typedef void (zlistx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zlistx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zlistx_comparator_fn) ( const void *item1, const void *item2); // Callback function for reactor socket activity typedef int (zloop_reader_fn) ( zloop_t *loop, zsock_t *reader, void *arg); // Callback function for reactor events (low-level) typedef int (zloop_fn) ( zloop_t *loop, zmq_pollitem_t *item, void *arg); // Callback for reactor timer events typedef int (zloop_timer_fn) ( zloop_t *loop, int timer_id, void *arg); // Callback for interrupt signal handler typedef void (zsys_handler_fn) ( int signal_value); // Callback function for timer event. typedef void (ztimerset_fn) ( int timer_id, void *arg); // Callback function for ztrie_node to destroy node data. typedef void (ztrie_destroy_data_fn) ( void **data); // CLASS: zactor // Create a new actor passing arbitrary arguments reference. zactor_t * zactor_new (zactor_fn task, void *args); // Destroy an actor. void zactor_destroy (zactor_t **self_p); // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. int zactor_send (zactor_t *self, zmsg_t **msg_p); // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. zmsg_t * zactor_recv (zactor_t *self); // Probe the supplied object, and report if it looks like a zactor_t. bool zactor_is (void *self); // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. void * zactor_resolve (void *self); // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. zsock_t * zactor_sock (zactor_t *self); // Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. void zactor_set_destructor (zactor_t *self, zactor_destructor_fn destructor); // Self test of this class. void zactor_test (bool verbose); // CLASS: zargs // Create a new zargs from command line arguments. zargs_t * zargs_new (int argc, char **argv); // Destroy zargs instance. void zargs_destroy (zargs_t **self_p); // Return program name (argv[0]) const char * zargs_progname (zargs_t *self); // Return number of positional arguments size_t zargs_arguments (zargs_t *self); // Return first positional argument or NULL const char * zargs_first (zargs_t *self); // Return next positional argument or NULL const char * zargs_next (zargs_t *self); // Return first named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const char * zargs_param_first (zargs_t *self); // Return next named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const char * zargs_param_next (zargs_t *self); // Return current parameter name, or NULL if there are no named // parameters. const char * zargs_param_name (zargs_t *self); // Return value of named parameter, NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const char * zargs_param_lookup (zargs_t *self, const char *keys); // Return value of named parameter(s), NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const char * zargs_param_lookupx (zargs_t *self, const char *keys, ...); // Returns true if there are --help -h arguments bool zargs_has_help (zargs_t *self); // Returns true if parameter did not have a value bool zargs_param_empty (const char *arg); // Print an instance of zargs. void zargs_print (zargs_t *self); // Self test of this class. void zargs_test (bool verbose); // CLASS: zarmour // Create a new zarmour zarmour_t * zarmour_new (void); // Destroy the zarmour void zarmour_destroy (zarmour_t **self_p); // Encode a stream of bytes into an armoured string. Returns the armoured // string, or NULL if there was insufficient memory available to allocate // a new string. char * zarmour_encode (zarmour_t *self, const byte *data, size_t size); // Decode an armoured string into a chunk. The decoded output is // null-terminated, so it may be treated as a string, if that's what // it was prior to encoding. zchunk_t * zarmour_decode (zarmour_t *self, const char *data); // Get the mode property. int zarmour_mode (zarmour_t *self); // Get printable string for mode. const char * zarmour_mode_str (zarmour_t *self); // Set the mode property. void zarmour_set_mode (zarmour_t *self, int mode); // Return true if padding is turned on. bool zarmour_pad (zarmour_t *self); // Turn padding on or off. Default is on. void zarmour_set_pad (zarmour_t *self, bool pad); // Get the padding character. char zarmour_pad_char (zarmour_t *self); // Set the padding character. void zarmour_set_pad_char (zarmour_t *self, char pad_char); // Return if splitting output into lines is turned on. Default is off. bool zarmour_line_breaks (zarmour_t *self); // Turn splitting output into lines on or off. void zarmour_set_line_breaks (zarmour_t *self, bool line_breaks); // Get the line length used for splitting lines. size_t zarmour_line_length (zarmour_t *self); // Set the line length used for splitting lines. void zarmour_set_line_length (zarmour_t *self, size_t line_length); // Print properties of object void zarmour_print (zarmour_t *self); // Self test of this class. void zarmour_test (bool verbose); // CLASS: zcert // Create and initialize a new certificate in memory zcert_t * zcert_new (void); // Accepts public/secret key pair from caller zcert_t * zcert_new_from (const byte *public_key, const byte *secret_key); // Accepts public/secret key text pair from caller zcert_t * zcert_new_from_txt (const char *public_txt, const char *secret_txt); // Load certificate from file zcert_t * zcert_load (const char *filename); // Destroy a certificate in memory void zcert_destroy (zcert_t **self_p); // Return public part of key pair as 32-byte binary string const byte * zcert_public_key (zcert_t *self); // Return secret part of key pair as 32-byte binary string const byte * zcert_secret_key (zcert_t *self); // Return public part of key pair as Z85 armored string const char * zcert_public_txt (zcert_t *self); // Return secret part of key pair as Z85 armored string const char * zcert_secret_txt (zcert_t *self); // Set certificate metadata from formatted string. void zcert_set_meta (zcert_t *self, const char *name, const char *format, ...); // Unset certificate metadata. void zcert_unset_meta (zcert_t *self, const char *name); // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. const char * zcert_meta (zcert_t *self, const char *name); // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. zlist_t * zcert_meta_keys (zcert_t *self); // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). int zcert_save (zcert_t *self, const char *filename); // Save public certificate only to file for persistent storage int zcert_save_public (zcert_t *self, const char *filename); // Save secret certificate only to file for persistent storage int zcert_save_secret (zcert_t *self, const char *filename); // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. void zcert_apply (zcert_t *self, void *socket); // Return copy of certificate; if certificate is NULL or we exhausted // heap memory, returns NULL. zcert_t * zcert_dup (zcert_t *self); // Return true if two certificates have the same keys bool zcert_eq (zcert_t *self, zcert_t *compare); // Print certificate contents to stdout void zcert_print (zcert_t *self); // Self test of this class void zcert_test (bool verbose); // CLASS: zcertstore // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. zcertstore_t * zcertstore_new (const char *location); // Destroy a certificate store object in memory. Does not affect anything // stored on disk. void zcertstore_destroy (zcertstore_t **self_p); // Override the default disk loader with a custom loader fn. void zcertstore_set_loader (zcertstore_t *self, zcertstore_loader loader, zcertstore_destructor destructor, void *state); // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. zcert_t * zcertstore_lookup (zcertstore_t *self, const char *public_key); // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. void zcertstore_insert (zcertstore_t *self, zcert_t **cert_p); // Empty certificate hashtable. This wrapper exists to be friendly to bindings, // which don't usually have access to struct internals. void zcertstore_empty (zcertstore_t *self); // Print list of certificates in store to logging facility void zcertstore_print (zcertstore_t *self); // Return a list of all the certificates in the store. // The caller takes ownership of the zlistx_t object and is responsible // for destroying it. The caller does not take ownership of the zcert_t // objects. zlistx_t * zcertstore_certs (zcertstore_t *self); // Self test of this class void zcertstore_test (bool verbose); // CLASS: zchunk // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. zchunk_t * zchunk_new (const void *data, size_t size); // Destroy a chunk void zchunk_destroy (zchunk_t **self_p); // Resizes chunk max_size as requested; chunk_cur size is set to zero void zchunk_resize (zchunk_t *self, size_t size); // Return chunk cur size size_t zchunk_size (zchunk_t *self); // Return chunk max size size_t zchunk_max_size (zchunk_t *self); // Return chunk data byte * zchunk_data (zchunk_t *self); // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk size_t zchunk_set (zchunk_t *self, const void *data, size_t size); // Fill chunk data from user-supplied octet size_t zchunk_fill (zchunk_t *self, byte filler, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, it is truncated. If you want to // grow the chunk to accommodate new data, use the zchunk_extend method. size_t zchunk_append (zchunk_t *self, const void *data, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, the chunk grows in size. size_t zchunk_extend (zchunk_t *self, const void *data, size_t size); // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. size_t zchunk_consume (zchunk_t *self, zchunk_t *source); // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. bool zchunk_exhausted (zchunk_t *self); // Read chunk from an open file descriptor zchunk_t * zchunk_read (FILE *handle, size_t bytes); // Write chunk to an open file descriptor int zchunk_write (zchunk_t *self, FILE *handle); // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. zchunk_t * zchunk_slurp (const char *filename, size_t maxsize); // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // returns null. zchunk_t * zchunk_dup (zchunk_t *self); // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. char * zchunk_strhex (zchunk_t *self); // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. char * zchunk_strdup (zchunk_t *self); // Return TRUE if chunk body is equal to string, excluding terminator bool zchunk_streq (zchunk_t *self, const char *string); // Transform zchunk into a zframe that can be sent in a message. zframe_t * zchunk_pack (zchunk_t *self); // Transform a zframe into a zchunk. zchunk_t * zchunk_unpack (zframe_t *frame); // Calculate SHA1 digest for chunk, using zdigest class. const char * zchunk_digest (zchunk_t *self); // Dump chunk to FILE stream, for debugging and tracing. void zchunk_fprint (zchunk_t *self, FILE *file); // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details void zchunk_print (zchunk_t *self); // Probe the supplied object, and report if it looks like a zchunk_t. bool zchunk_is (void *self); // Self test of this class. void zchunk_test (bool verbose); // CLASS: zclock // Sleep for a number of milliseconds void zclock_sleep (int msecs); // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. int64_t zclock_time (void); // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t zclock_mono (void); // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t zclock_usecs (void); // Return formatted date/time as fresh string. Free using zstr_free(). char * zclock_timestr (void); // Self test of this class. void zclock_test (bool verbose); // CLASS: zconfig // Create new config item zconfig_t * zconfig_new (const char *name, zconfig_t *parent); // Destroy a config item and all its children void zconfig_destroy (zconfig_t **self_p); // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. zconfig_t * zconfig_load (const char *filename); // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. zconfig_t * zconfig_loadf (const char *format, ...); // Return name of config item char * zconfig_name (zconfig_t *self); // Return value of config item char * zconfig_value (zconfig_t *self); // Insert or update configuration key with value void zconfig_put (zconfig_t *self, const char *path, const char *value); // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. void zconfig_putf (zconfig_t *self, const char *path, const char *format, ...); // Get value for config item into a string value; leading slash is optional // and ignored. char * zconfig_get (zconfig_t *self, const char *path, const char *default_value); // Set config item name, name may be NULL void zconfig_set_name (zconfig_t *self, const char *name); // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. void zconfig_set_value (zconfig_t *self, const char *format, ...); // Find our first child, if any zconfig_t * zconfig_child (zconfig_t *self); // Find our first sibling, if any zconfig_t * zconfig_next (zconfig_t *self); // Find a config item along a path; leading slash is optional and ignored. zconfig_t * zconfig_locate (zconfig_t *self, const char *path); // Locate the last config item at a specified depth zconfig_t * zconfig_at_depth (zconfig_t *self, int level); // Execute a callback for each config item in the tree; returns zero if // successful, else -1. int zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg); // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. void zconfig_set_comment (zconfig_t *self, const char *format, ...); // Return comments of config item, as zlist. zlist_t * zconfig_comments (zconfig_t *self); // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. int zconfig_save (zconfig_t *self, const char *filename); // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. int zconfig_savef (zconfig_t *self, const char *format, ...); // Report filename used during zconfig_load, or NULL if none const char * zconfig_filename (zconfig_t *self); // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). int zconfig_reload (zconfig_t **self_p); // Load a config tree from a memory chunk zconfig_t * zconfig_chunk_load (zchunk_t *chunk); // Save a config tree to a new memory chunk zchunk_t * zconfig_chunk_save (zconfig_t *self); // Load a config tree from a null-terminated string zconfig_t * zconfig_str_load (const char *string); // Save a config tree to a new null terminated string char * zconfig_str_save (zconfig_t *self); // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. bool zconfig_has_changed (zconfig_t *self); // Destroy subtree (all children) void zconfig_remove_subtree (zconfig_t *self); // Destroy node and subtree (all children) void zconfig_remove (zconfig_t **self_p); // Print the config file to open stream void zconfig_fprint (zconfig_t *self, FILE *file); // Print properties of object void zconfig_print (zconfig_t *self); // Self test of this class void zconfig_test (bool verbose); // CLASS: zdigest // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. zdigest_t * zdigest_new (void); // Destroy a digest object void zdigest_destroy (zdigest_t **self_p); // Add buffer into digest calculation void zdigest_update (zdigest_t *self, const byte *buffer, size_t length); // Return final digest hash data. If built without crypto support, // returns NULL. const byte * zdigest_data (zdigest_t *self); // Return final digest hash size size_t zdigest_size (zdigest_t *self); // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. char * zdigest_string (zdigest_t *self); // Self test of this class. void zdigest_test (bool verbose); // CLASS: zdir // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. zdir_t * zdir_new (const char *path, const char *parent); // Destroy a directory tree and all children it contains. void zdir_destroy (zdir_t **self_p); // Return directory path const char * zdir_path (zdir_t *self); // Return last modification time for directory. time_t zdir_modified (zdir_t *self); // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. off_t zdir_cursize (zdir_t *self); // Return directory count size_t zdir_count (zdir_t *self); // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. zlist_t * zdir_list (zdir_t *self); // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. void zdir_remove (zdir_t *self, bool force); // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). zlist_t * zdir_diff (zdir_t *older, zdir_t *newer, const char *alias); // Return full contents of directory as a zdir_patch list. zlist_t * zdir_resync (zdir_t *self, const char *alias); // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. zhash_t * zdir_cache (zdir_t *self); // Print contents of directory to open stream void zdir_fprint (zdir_t *self, FILE *file, int indent); // Print contents of directory to stdout void zdir_print (zdir_t *self, int indent); // Create a new zdir_watch actor instance: // // zactor_t *watch = zactor_new (zdir_watch, NULL); // // Destroy zdir_watch instance: // // zactor_destroy (&watch); // // Enable verbose logging of commands and activity: // // zstr_send (watch, "VERBOSE"); // // Subscribe to changes to a directory path: // // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); // // Unsubscribe from changes to a directory path: // // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); // // Receive directory changes: // zsock_recv (watch, "sp", &path, &patches); // // // Delete the received data. // free (path); // zlist_destroy (&patches); void zdir_watch (zsock_t *pipe, void *unused); // Self test of this class. void zdir_test (bool verbose); // CLASS: zdir_patch // Create new patch zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, int op, const char *alias); // Destroy a patch void zdir_patch_destroy (zdir_patch_t **self_p); // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. zdir_patch_t * zdir_patch_dup (zdir_patch_t *self); // Return patch file directory path const char * zdir_patch_path (zdir_patch_t *self); // Return patch file item zfile_t * zdir_patch_file (zdir_patch_t *self); // Return operation int zdir_patch_op (zdir_patch_t *self); // Return patch virtual file path const char * zdir_patch_vpath (zdir_patch_t *self); // Calculate hash digest for file (create only) void zdir_patch_digest_set (zdir_patch_t *self); // Return hash digest for patch file const char * zdir_patch_digest (zdir_patch_t *self); // Self test of this class. void zdir_patch_test (bool verbose); // CLASS: zfile // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. zfile_t * zfile_new (const char *path, const char *name); // Create new temporary file for writing via tmpfile. File is automaticaly // deleted on destroy zfile_t * zfile_tmp (void); // Destroy a file item void zfile_destroy (zfile_t **self_p); // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. zfile_t * zfile_dup (zfile_t *self); // Return file name, remove path if provided const char * zfile_filename (zfile_t *self, const char *path); // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. void zfile_restat (zfile_t *self); // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. time_t zfile_modified (zfile_t *self); // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. off_t zfile_cursize (zfile_t *self); // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool zfile_is_directory (zfile_t *self); // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool zfile_is_regular (zfile_t *self); // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. bool zfile_is_readable (zfile_t *self); // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. bool zfile_is_writeable (zfile_t *self); // Check if file has stopped changing and can be safely processed. // Updates the file statistics from disk at every call. bool zfile_is_stable (zfile_t *self); // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. bool zfile_has_changed (zfile_t *self); // Remove the file from disk void zfile_remove (zfile_t *self); // Open file for reading // Returns 0 if OK, -1 if not found or not accessible int zfile_input (zfile_t *self); // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. int zfile_output (zfile_t *self); // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. zchunk_t * zfile_read (zfile_t *self, size_t bytes, off_t offset); // Returns true if zfile_read() just read the last chunk in the file. bool zfile_eof (zfile_t *self); // Write chunk to file at specified position // Return 0 if OK, else -1 int zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset); // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. const char * zfile_readln (zfile_t *self); // Close file, if open void zfile_close (zfile_t *self); // Return file handle, if opened FILE * zfile_handle (zfile_t *self); // Calculate SHA1 digest for file, using zdigest class. const char * zfile_digest (zfile_t *self); // Self test of this class. void zfile_test (bool verbose); // CLASS: zframe // Create a new frame. If size is not null, allocates the frame data // to the specified size. If additionally, data is not null, copies // size octets from the specified data into the frame body. zframe_t * zframe_new (const void *data, size_t size); // Destroy a frame void zframe_destroy (zframe_t **self_p); // Create an empty (zero-sized) frame zframe_t * zframe_new_empty (void); // Create a frame with a specified string content. zframe_t * zframe_from (const char *string); // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. zframe_t * zframe_recv (void *source); // Send a frame to a socket, destroy frame after sending. // Return -1 on error, 0 on success. int zframe_send (zframe_t **self_p, void *dest, int flags); // Return number of bytes in frame data size_t zframe_size (zframe_t *self); // Return address of frame data byte * zframe_data (zframe_t *self); // Return meta data property for frame // The caller shall not modify or free the returned value, which shall be // owned by the message. const char * zframe_meta (zframe_t *self, const char *property); // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. zframe_t * zframe_dup (zframe_t *self); // Return frame data encoded as printable hex string, useful for 0MQ UUIDs. // Caller must free string when finished with it. char * zframe_strhex (zframe_t *self); // Return frame data copied into freshly allocated string // Caller must free string when finished with it. char * zframe_strdup (zframe_t *self); // Return TRUE if frame body is equal to string, excluding terminator bool zframe_streq (zframe_t *self, const char *string); // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method int zframe_more (zframe_t *self); // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. void zframe_set_more (zframe_t *self, int more); // Return frame routing ID, if the frame came from a ZMQ_SERVER socket. // Else returns zero. uint32_t zframe_routing_id (zframe_t *self); // Set routing ID on frame. This is used if/when the frame is sent to a // ZMQ_SERVER socket. void zframe_set_routing_id (zframe_t *self, uint32_t routing_id); // Return frame group of radio-dish pattern. const char * zframe_group (zframe_t *self); // Set group on frame. This is used if/when the frame is sent to a // ZMQ_RADIO socket. // Return -1 on error, 0 on success. int zframe_set_group (zframe_t *self, const char *group); // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false. bool zframe_eq (zframe_t *self, zframe_t *other); // Set new contents for frame void zframe_reset (zframe_t *self, const void *data, size_t size); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. void zframe_print (zframe_t *self, const char *prefix); // Probe the supplied object, and report if it looks like a zframe_t. bool zframe_is (void *self); // Self test of this class. void zframe_test (bool verbose); // CLASS: zhash // Create a new, empty hash container zhash_t * zhash_new (void); // Destroy a hash container and all items in it void zhash_destroy (zhash_t **self_p); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. zhash_t * zhash_unpack (zframe_t *frame); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int zhash_insert (zhash_t *self, const char *key, void *item); // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. void zhash_update (zhash_t *self, const char *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void zhash_delete (zhash_t *self, const char *key); // Return the item at the specified key, or null void * zhash_lookup (zhash_t *self, const char *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int zhash_rename (zhash_t *self, const char *old_key, const char *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn); // Return the number of keys/items in the hash table size_t zhash_size (zhash_t *self); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. zhash_t * zhash_dup (zhash_t *self); // Return keys for items in table zlist_t * zhash_keys (zhash_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhash_cursor(). NOTE: do NOT modify the table while iterating. void * zhash_first (zhash_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). To // access the key for this item use zhash_cursor(). NOTE: do NOT modify // the table while iterating. void * zhash_next (zhash_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const char * zhash_cursor (zhash_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void zhash_comment (zhash_t *self, const char *format, ...); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. zframe_t * zhash_pack (zhash_t *self); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int zhash_save (zhash_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int zhash_load (zhash_t *self, const char *filename); // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int zhash_refresh (zhash_t *self); // Set hash for automatic value destruction. Note that this assumes that // values are NULL-terminated strings. Do not use with different types. void zhash_autofree (zhash_t *self); // Self test of this class. void zhash_test (bool verbose); // CLASS: zhashx // Create a new, empty hash container zhashx_t * zhashx_new (void); // Destroy a hash container and all items in it void zhashx_destroy (zhashx_t **self_p); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. zhashx_t * zhashx_unpack (zframe_t *frame); // Same as unpack but uses a user-defined deserializer function to convert // a longstr back into item format. zhashx_t * zhashx_unpack_own (zframe_t *frame, zhashx_deserializer_fn deserializer); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int zhashx_insert (zhashx_t *self, const void *key, void *item); // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. void zhashx_update (zhashx_t *self, const void *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void zhashx_delete (zhashx_t *self, const void *key); // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. void zhashx_purge (zhashx_t *self); // Return the item at the specified key, or null void * zhashx_lookup (zhashx_t *self, const void *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn free_fn); // Return the number of keys/items in the hash table size_t zhashx_size (zhashx_t *self); // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. zlistx_t * zhashx_keys (zhashx_t *self); // Return a zlistx_t containing the values for the items in the // table. Uses the duplicator to duplicate all items and sets the // destructor as destructor for the list. zlistx_t * zhashx_values (zhashx_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhashx_cursor(). NOTE: do NOT modify the table while iterating. void * zhashx_first (zhashx_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). To // access the key for this item use zhashx_cursor(). NOTE: do NOT modify // the table while iterating. void * zhashx_next (zhashx_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const void * zhashx_cursor (zhashx_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void zhashx_comment (zhashx_t *self, const char *format, ...); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int zhashx_save (zhashx_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int zhashx_load (zhashx_t *self, const char *filename); // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int zhashx_refresh (zhashx_t *self); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. zframe_t * zhashx_pack (zhashx_t *self); // Same as pack but uses a user-defined serializer function to convert items // into longstr. zframe_t * zhashx_pack_own (zhashx_t *self, zhashx_serializer_fn serializer); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. zhashx_t * zhashx_dup (zhashx_t *self); // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. void zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. void zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined deallocator for keys; by default keys are freed // when the hash is destroyed using free(). void zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for keys; by default keys are duplicated // using strdup. void zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined comparator for keys; by default keys are // compared using strcmp. // The callback function should return zero (0) on matching // items. void zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator); // Set a user-defined hash function for keys; by default keys are // hashed by a modified Bernstein hashing function. void zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. zhashx_t * zhashx_dup_v2 (zhashx_t *self); // Self test of this class. void zhashx_test (bool verbose); // CLASS: ziflist // Get a list of network interfaces currently defined on the system ziflist_t * ziflist_new (void); // Destroy a ziflist instance void ziflist_destroy (ziflist_t **self_p); // Reload network interfaces from system void ziflist_reload (ziflist_t *self); // Return the number of network interfaces on system size_t ziflist_size (ziflist_t *self); // Get first network interface, return NULL if there are none const char * ziflist_first (ziflist_t *self); // Get next network interface, return NULL if we hit the last one const char * ziflist_next (ziflist_t *self); // Return the current interface IP address as a printable string const char * ziflist_address (ziflist_t *self); // Return the current interface broadcast address as a printable string const char * ziflist_broadcast (ziflist_t *self); // Return the current interface network mask as a printable string const char * ziflist_netmask (ziflist_t *self); // Return the list of interfaces. void ziflist_print (ziflist_t *self); // Get a list of network interfaces currently defined on the system // Includes IPv6 interfaces ziflist_t * ziflist_new_ipv6 (void); // Reload network interfaces from system, including IPv6 void ziflist_reload_ipv6 (ziflist_t *self); // Return true if the current interface uses IPv6 bool ziflist_is_ipv6 (ziflist_t *self); // Self test of this class. void ziflist_test (bool verbose); // CLASS: zlist // Create a new list container zlist_t * zlist_new (void); // Destroy a list container void zlist_destroy (zlist_t **self_p); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * zlist_first (zlist_t *self); // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. void * zlist_next (zlist_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * zlist_last (zlist_t *self); // Return first item in the list, or null, leaves the cursor void * zlist_head (zlist_t *self); // Return last item in the list, or null, leaves the cursor void * zlist_tail (zlist_t *self); // Return the current item of list. If the list is empty, returns NULL. // Leaves cursor pointing at the current item, or NULL if the list is empty. void * zlist_item (zlist_t *self); // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int zlist_append (zlist_t *self, void *item); // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int zlist_push (zlist_t *self, void *item); // Pop the item off the start of the list, if any void * zlist_pop (zlist_t *self); // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. bool zlist_exists (zlist_t *self, void *item); // Remove the specified item from the list if present void zlist_remove (zlist_t *self, void *item); // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. zlist_t * zlist_dup (zlist_t *self); // Purge all items from list void zlist_purge (zlist_t *self); // Return number of items in the list size_t zlist_size (zlist_t *self); // Sort the list. If the compare function is null, sorts the list by // ascending key value using a straight ASCII comparison. If you specify // a compare function, this decides how items are sorted. The sort is not // stable, so may reorder items with the same keys. The algorithm used is // combsort, a compromise between performance and simplicity. void zlist_sort (zlist_t *self, zlist_compare_fn compare); // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. void zlist_autofree (zlist_t *self); // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. void zlist_comparefn (zlist_t *self, zlist_compare_fn fn); // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zlist_freefn (zlist_t *self, void *item, zlist_free_fn fn, bool at_tail); // Self test of this class. void zlist_test (bool verbose); // CLASS: zlistx // Create a new, empty list. zlistx_t * zlistx_new (void); // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. void zlistx_destroy (zlistx_t **self_p); // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void * zlistx_add_start (zlistx_t *self, void *item); // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void * zlistx_add_end (zlistx_t *self, void *item); // Return the number of items in the list size_t zlistx_size (zlistx_t *self); // Return first item in the list, or null, leaves the cursor void * zlistx_head (zlistx_t *self); // Return last item in the list, or null, leaves the cursor void * zlistx_tail (zlistx_t *self); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * zlistx_first (zlistx_t *self); // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). void * zlistx_next (zlistx_t *self); // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). void * zlistx_prev (zlistx_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * zlistx_last (zlistx_t *self); // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * zlistx_item (zlistx_t *self); // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * zlistx_cursor (zlistx_t *self); // Returns the item associated with the given list handle, or NULL if passed // in handle is NULL. Asserts that the passed in handle points to a list element. void * zlistx_handle_item (void *handle); // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. void * zlistx_find (zlistx_t *self, void *item); // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. void * zlistx_detach (zlistx_t *self, void *handle); // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. void * zlistx_detach_cur (zlistx_t *self); // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. int zlistx_delete (zlistx_t *self, void *handle); // Move an item to the start of the list, via its handle. void zlistx_move_start (zlistx_t *self, void *handle); // Move an item to the end of the list, via its handle. void zlistx_move_end (zlistx_t *self, void *handle); // Remove all items from the list, and destroy them if the item destructor // is set. void zlistx_purge (zlistx_t *self); // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. void zlistx_sort (zlistx_t *self); // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. void * zlistx_insert (zlistx_t *self, void *item, bool low_value); // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. void zlistx_reorder (zlistx_t *self, void *handle, bool low_value); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. zlistx_t * zlistx_dup (zlistx_t *self); // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. void zlistx_set_destructor (zlistx_t *self, zlistx_destructor_fn destructor); // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. void zlistx_set_duplicator (zlistx_t *self, zlistx_duplicator_fn duplicator); // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. void zlistx_set_comparator (zlistx_t *self, zlistx_comparator_fn comparator); // Self test of this class. void zlistx_test (bool verbose); // CLASS: zloop // Create a new zloop reactor zloop_t * zloop_new (void); // Destroy a reactor void zloop_destroy (zloop_t **self_p); // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. int zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg); // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. void zloop_reader_end (zloop_t *self, zsock_t *sock); // Configure a registered reader to ignore errors. If you do not set this, // then readers that have errors are removed from the reactor silently. void zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock); // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. int zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg); // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. void zloop_poller_end (zloop_t *self, zmq_pollitem_t *item); // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. void zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item); // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. int zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg); // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer). int zloop_timer_end (zloop_t *self, int timer_id); // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. void * zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg); // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. void zloop_ticket_reset (zloop_t *self, void *handle); // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. void zloop_ticket_delete (zloop_t *self, void *handle); // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. void zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay); // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. void zloop_set_max_timers (zloop_t *self, size_t max_timers); // Set verbose tracing of reactor on/off. The default verbose setting is // off (false). void zloop_set_verbose (zloop_t *self, bool verbose); // By default the reactor stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void zloop_set_nonstop (zloop_t *self, bool nonstop); // Start the reactor. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. int zloop_start (zloop_t *self); // Self test of this class. void zloop_test (bool verbose); // CLASS: zmsg // Create a new empty message object zmsg_t * zmsg_new (void); // Destroy a message object and all frames it contains void zmsg_destroy (zmsg_t **self_p); // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted. Does a blocking recv. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving. zmsg_t * zmsg_recv (void *source); // Load/append an open file into new message, return the message. // Returns NULL if the message could not be loaded. zmsg_t * zmsg_load (FILE *file); // Decodes a serialized message frame created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the frame was badly formatted or // there was insufficient memory to work. zmsg_t * zmsg_decode (zframe_t *frame); // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. zmsg_t * zmsg_new_signal (byte status); // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int zmsg_send (zmsg_t **self_p, void *dest); // Send message to destination socket as part of a multipart sequence, and // destroy the message after sending it successfully. Note that after a // zmsg_sendm, you must call zmsg_send or another method that sends a final // message part. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int zmsg_sendm (zmsg_t **self_p, void *dest); // Return size of message, i.e. number of frames (0 or more). size_t zmsg_size (zmsg_t *self); // Return total size of all frames in message. size_t zmsg_content_size (zmsg_t *self); // Return message routing ID, if the message came from a ZMQ_SERVER socket. // Else returns zero. uint32_t zmsg_routing_id (zmsg_t *self); // Set routing ID on message. This is used if/when the message is sent to a // ZMQ_SERVER socket. void zmsg_set_routing_id (zmsg_t *self, uint32_t routing_id); // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. int zmsg_prepend (zmsg_t *self, zframe_t **frame_p); // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Deprecates zmsg_add, which did not nullify the // caller's frame reference. int zmsg_append (zmsg_t *self, zframe_t **frame_p); // Remove first frame from message, if any. Returns frame, or NULL. zframe_t * zmsg_pop (zmsg_t *self); // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. int zmsg_pushmem (zmsg_t *self, const void *data, size_t size); // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. int zmsg_addmem (zmsg_t *self, const void *data, size_t size); // Push string as new frame to front of message. // Returns 0 on success, -1 on error. int zmsg_pushstr (zmsg_t *self, const char *string); // Push string as new frame to end of message. // Returns 0 on success, -1 on error. int zmsg_addstr (zmsg_t *self, const char *string); // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. int zmsg_pushstrf (zmsg_t *self, const char *format, ...); // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. int zmsg_addstrf (zmsg_t *self, const char *format, ...); // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. char * zmsg_popstr (zmsg_t *self); // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. int zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p); // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not successful. zmsg_t * zmsg_popmsg (zmsg_t *self); // Remove specified frame from list, if present. Does not destroy frame. void zmsg_remove (zmsg_t *self, zframe_t *frame); // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. zframe_t * zmsg_first (zmsg_t *self); // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. zframe_t * zmsg_next (zmsg_t *self); // Return the last frame. If there are no frames, returns NULL. zframe_t * zmsg_last (zmsg_t *self); // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. int zmsg_save (zmsg_t *self, FILE *file); // Serialize multipart message to a single message frame. Use this method // to send structured messages across transports that do not support // multipart data. Allocates and returns a new frame containing the // serialized message. To decode a serialized message frame, use // zmsg_decode (). zframe_t * zmsg_encode (zmsg_t *self); // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. zmsg_t * zmsg_dup (zmsg_t *self); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). void zmsg_print (zmsg_t *self); // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. bool zmsg_eq (zmsg_t *self, zmsg_t *other); // Return signal value, 0 or greater, if message is a signal, -1 if not. int zmsg_signal (zmsg_t *self); // Probe the supplied object, and report if it looks like a zmsg_t. bool zmsg_is (void *self); // Self test of this class. void zmsg_test (bool verbose); // CLASS: zpoller // Create new poller, specifying zero or more readers. The list of // readers ends in a NULL. Each reader can be a zsock_t instance, a // zactor_t instance, a libzmq socket (void *), or a file handle. zpoller_t * zpoller_new (void *reader, ...); // Destroy a poller void zpoller_destroy (zpoller_t **self_p); // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. int zpoller_add (zpoller_t *self, void *reader); // Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader // must have been passed during construction, or in an zpoller_add () call. int zpoller_remove (zpoller_t *self, void *reader); // By default the poller stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void zpoller_set_nonstop (zpoller_t *self, bool nonstop); // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. void * zpoller_wait (zpoller_t *self, int timeout); // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. bool zpoller_expired (zpoller_t *self); // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. bool zpoller_terminated (zpoller_t *self); // Self test of this class. void zpoller_test (bool verbose); // CLASS: zproc // Create a new zproc. // NOTE: On Windows and with libzmq3 and libzmq2 this function // returns NULL. Code needs to be ported there. zproc_t * zproc_new (void); // Destroy zproc, wait until process ends. void zproc_destroy (zproc_t **self_p); // Setup the command line arguments, the first item must be an (absolute) filename // to run. void zproc_set_args (zproc_t *self, zlistx_t *args); // Setup the environment variables for the process. void zproc_set_env (zproc_t *self, zhashx_t *args); // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The writable one is then accessbile via zproc_stdin method. void zproc_set_stdin (zproc_t *self, void *socket); // Connects process stdout with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stdout method. void zproc_set_stdout (zproc_t *self, void *socket); // Connects process stderr with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stderr method. void zproc_set_stderr (zproc_t *self, void *socket); // Return subprocess stdin writable socket. NULL for // not initialized or external sockets. void * zproc_stdin (zproc_t *self); // Return subprocess stdout readable socket. NULL for // not initialized or external sockets. void * zproc_stdout (zproc_t *self); // Return subprocess stderr readable socket. NULL for // not initialized or external sockets. void * zproc_stderr (zproc_t *self); // Starts the process. int zproc_run (zproc_t *self); // process exit code int zproc_returncode (zproc_t *self); // PID of the process int zproc_pid (zproc_t *self); // return true if process is running, false if not yet started or finished bool zproc_running (zproc_t *self); // wait or poll process status, return return code int zproc_wait (zproc_t *self, bool hang); // return internal actor, usefull for the polling if process died void * zproc_actor (zproc_t *self); // send a signal to the subprocess void zproc_kill (zproc_t *self, int signal); // set verbose mode void zproc_set_verbose (zproc_t *self, bool verbose); // Returns CZMQ version as a single 6-digit integer encoding the major // version (x 10000), the minor version (x 100) and the patch. int zproc_czmq_version (void); // Returns true if the process received a SIGINT or SIGTERM signal. // It is good practice to use this method to exit any infinite loop // processing messages. bool zproc_interrupted (void); // Returns true if the underlying libzmq supports CURVE security. bool zproc_has_curve (void); // Return current host name, for use in public tcp:// endpoints. // If the host name is not resolvable, returns NULL. char * zproc_hostname (void); // Move the current process into the background. The precise effect // depends on the operating system. On POSIX boxes, moves to a specified // working directory (if specified), closes all file handles, reopens // stdin, stdout, and stderr to the null device, and sets the process to // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there // was an error. void zproc_daemonize (const char *workdir); // Drop the process ID into the lockfile, with exclusive lock, and // switch the process to the specified group and/or user. Any of the // arguments may be null, indicating a no-op. Returns 0 on success, // -1 on failure. Note if you combine this with zsys_daemonize, run // after, not before that method, or the lockfile will hold the wrong // process ID. void zproc_run_as (const char *lockfile, const char *group, const char *user); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void zproc_set_io_threads (size_t io_threads); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void zproc_set_max_sockets (size_t max_sockets); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void zproc_set_biface (const char *value); // Return network interface to use for broadcasts, or "" if none was set. const char * zproc_biface (void); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void zproc_set_log_ident (const char *value); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void zproc_set_log_sender (const char *endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void zproc_set_log_system (bool logsystem); // Log error condition - highest priority void zproc_log_error (const char *format, ...); // Log warning condition - high priority void zproc_log_warning (const char *format, ...); // Log normal, but significant, condition - normal priority void zproc_log_notice (const char *format, ...); // Log informational message - low priority void zproc_log_info (const char *format, ...); // Log debug-level message - lowest priority void zproc_log_debug (const char *format, ...); // Self test of this class. void zproc_test (bool verbose); // CLASS: zsock // Create a new socket. Returns the new socket, or NULL if the new socket // could not be created. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection. This can have // performance implications if you use a LOT of sockets. To turn off this // redirection behaviour, define ZSOCK_NOCHECK. zsock_t * zsock_new (int type); // Destroy the socket. You must use this for any socket created via the // zsock_new method. void zsock_destroy (zsock_t **self_p); // Create a PUB socket. Default action is bind. zsock_t * zsock_new_pub (const char *endpoint); // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. zsock_t * zsock_new_sub (const char *endpoint, const char *subscribe); // Create a REQ socket. Default action is connect. zsock_t * zsock_new_req (const char *endpoint); // Create a REP socket. Default action is bind. zsock_t * zsock_new_rep (const char *endpoint); // Create a DEALER socket. Default action is connect. zsock_t * zsock_new_dealer (const char *endpoint); // Create a ROUTER socket. Default action is bind. zsock_t * zsock_new_router (const char *endpoint); // Create a PUSH socket. Default action is connect. zsock_t * zsock_new_push (const char *endpoint); // Create a PULL socket. Default action is bind. zsock_t * zsock_new_pull (const char *endpoint); // Create an XPUB socket. Default action is bind. zsock_t * zsock_new_xpub (const char *endpoint); // Create an XSUB socket. Default action is connect. zsock_t * zsock_new_xsub (const char *endpoint); // Create a PAIR socket. Default action is connect. zsock_t * zsock_new_pair (const char *endpoint); // Create a STREAM socket. Default action is connect. zsock_t * zsock_new_stream (const char *endpoint); // Create a SERVER socket. Default action is bind. zsock_t * zsock_new_server (const char *endpoint); // Create a CLIENT socket. Default action is connect. zsock_t * zsock_new_client (const char *endpoint); // Create a RADIO socket. Default action is bind. zsock_t * zsock_new_radio (const char *endpoint); // Create a DISH socket. Default action is connect. zsock_t * zsock_new_dish (const char *endpoint); // Create a GATHER socket. Default action is bind. zsock_t * zsock_new_gather (const char *endpoint); // Create a SCATTER socket. Default action is connect. zsock_t * zsock_new_scatter (const char *endpoint); // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. int zsock_bind (zsock_t *self, const char *format, ...); // Returns last bound endpoint, if any. const char * zsock_endpoint (zsock_t *self); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int zsock_unbind (zsock_t *self, const char *format, ...); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. int zsock_connect (zsock_t *self, const char *format, ...); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int zsock_disconnect (zsock_t *self, const char *format, ...); // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). int zsock_attach (zsock_t *self, const char *endpoints, bool serverish); // Returns socket type as printable constant string. const char * zsock_type_str (zsock_t *self); // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. int zsock_send (void *self, const char *picture, ...); // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. int zsock_vsend (void *self, const char *picture, va_list argptr); // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // U = zuuid_t * (creates a zuuid with the data) // h = zhashx_t ** (creates zhashx) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. int zsock_recv (void *self, const char *picture, ...); // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. int zsock_vrecv (void *self, const char *picture, va_list argptr); // Send a binary encoded 'picture' message to the socket (or actor). This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations. The pattern argument is a string that defines the // type of each argument. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0-255 chars type = "string" // S char *, 0-2^32-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // u zuuid_t * type = "uuid" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments. Returns 0 if // successful, -1 if sending failed for any reason. int zsock_bsend (void *self, const char *picture, ...); // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. // For types 1, 2, 4 and 8 the caller must allocate the memory itself before // calling zsock_brecv. // For types S, the caller must free the value once finished with it, as // zsock_brecv will allocate the buffer. // For type s, the caller must not free the value as it is stored in a // local cache for performance purposes. // For types c, f, u and m the caller must call the appropriate destructor // depending on the object as zsock_brecv will create new objects. // For type p the caller must coordinate with the sender, as it is just a // pointer value being passed. int zsock_brecv (void *self, const char *picture, ...); // Return socket routing ID if any. This returns 0 if the socket is not // of type ZMQ_SERVER or if no request was already received on it. uint32_t zsock_routing_id (zsock_t *self); // Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. // This will be used when sending messages on the socket via the zsock API. void zsock_set_routing_id (zsock_t *self, uint32_t routing_id); // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. void zsock_set_unbounded (void *self); // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zsock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. int zsock_signal (void *self, byte status); // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. int zsock_wait (void *self); // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. void zsock_flush (void *self); // Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int zsock_join (void *self, const char *group); // Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int zsock_leave (void *self, const char *group); // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. bool zsock_is (void *self); // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. void * zsock_resolve (void *self); // Get socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. int zsock_heartbeat_ivl (void *self); // Set socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. void zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl); // Get socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. int zsock_heartbeat_ttl (void *self); // Set socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. void zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl); // Get socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. int zsock_heartbeat_timeout (void *self); // Set socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. void zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout); // Get socket option `use_fd`. // Available from libzmq 4.2.0. int zsock_use_fd (void *self); // Set socket option `use_fd`. // Available from libzmq 4.2.0. void zsock_set_use_fd (void *self, int use_fd); // Set socket option `xpub_manual`. // Available from libzmq 4.2.0. void zsock_set_xpub_manual (void *self, int xpub_manual); // Set socket option `xpub_welcome_msg`. // Available from libzmq 4.2.0. void zsock_set_xpub_welcome_msg (void *self, const char *xpub_welcome_msg); // Set socket option `stream_notify`. // Available from libzmq 4.2.0. void zsock_set_stream_notify (void *self, int stream_notify); // Get socket option `invert_matching`. // Available from libzmq 4.2.0. int zsock_invert_matching (void *self); // Set socket option `invert_matching`. // Available from libzmq 4.2.0. void zsock_set_invert_matching (void *self, int invert_matching); // Set socket option `xpub_verboser`. // Available from libzmq 4.2.0. void zsock_set_xpub_verboser (void *self, int xpub_verboser); // Get socket option `connect_timeout`. // Available from libzmq 4.2.0. int zsock_connect_timeout (void *self); // Set socket option `connect_timeout`. // Available from libzmq 4.2.0. void zsock_set_connect_timeout (void *self, int connect_timeout); // Get socket option `tcp_maxrt`. // Available from libzmq 4.2.0. int zsock_tcp_maxrt (void *self); // Set socket option `tcp_maxrt`. // Available from libzmq 4.2.0. void zsock_set_tcp_maxrt (void *self, int tcp_maxrt); // Get socket option `thread_safe`. // Available from libzmq 4.2.0. int zsock_thread_safe (void *self); // Get socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. int zsock_multicast_maxtpdu (void *self); // Set socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. void zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu); // Get socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. int zsock_vmci_buffer_size (void *self); // Set socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. void zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size); // Get socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. int zsock_vmci_buffer_min_size (void *self); // Set socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. void zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size); // Get socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. int zsock_vmci_buffer_max_size (void *self); // Set socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. void zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size); // Get socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. int zsock_vmci_connect_timeout (void *self); // Set socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. void zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout); // Get socket option `tos`. // Available from libzmq 4.1.0. int zsock_tos (void *self); // Set socket option `tos`. // Available from libzmq 4.1.0. void zsock_set_tos (void *self, int tos); // Set socket option `router_handover`. // Available from libzmq 4.1.0. void zsock_set_router_handover (void *self, int router_handover); // Set socket option `connect_rid`. // Available from libzmq 4.1.0. void zsock_set_connect_rid (void *self, const char *connect_rid); // Set socket option `connect_rid` from 32-octet binary // Available from libzmq 4.1.0. void zsock_set_connect_rid_bin (void *self, const byte *connect_rid); // Get socket option `handshake_ivl`. // Available from libzmq 4.1.0. int zsock_handshake_ivl (void *self); // Set socket option `handshake_ivl`. // Available from libzmq 4.1.0. void zsock_set_handshake_ivl (void *self, int handshake_ivl); // Get socket option `socks_proxy`. // Available from libzmq 4.1.0. char * zsock_socks_proxy (void *self); // Set socket option `socks_proxy`. // Available from libzmq 4.1.0. void zsock_set_socks_proxy (void *self, const char *socks_proxy); // Set socket option `xpub_nodrop`. // Available from libzmq 4.1.0. void zsock_set_xpub_nodrop (void *self, int xpub_nodrop); // Set socket option `router_mandatory`. // Available from libzmq 4.0.0. void zsock_set_router_mandatory (void *self, int router_mandatory); // Set socket option `probe_router`. // Available from libzmq 4.0.0. void zsock_set_probe_router (void *self, int probe_router); // Set socket option `req_relaxed`. // Available from libzmq 4.0.0. void zsock_set_req_relaxed (void *self, int req_relaxed); // Set socket option `req_correlate`. // Available from libzmq 4.0.0. void zsock_set_req_correlate (void *self, int req_correlate); // Set socket option `conflate`. // Available from libzmq 4.0.0. void zsock_set_conflate (void *self, int conflate); // Get socket option `zap_domain`. // Available from libzmq 4.0.0. char * zsock_zap_domain (void *self); // Set socket option `zap_domain`. // Available from libzmq 4.0.0. void zsock_set_zap_domain (void *self, const char *zap_domain); // Get socket option `mechanism`. // Available from libzmq 4.0.0. int zsock_mechanism (void *self); // Get socket option `plain_server`. // Available from libzmq 4.0.0. int zsock_plain_server (void *self); // Set socket option `plain_server`. // Available from libzmq 4.0.0. void zsock_set_plain_server (void *self, int plain_server); // Get socket option `plain_username`. // Available from libzmq 4.0.0. char * zsock_plain_username (void *self); // Set socket option `plain_username`. // Available from libzmq 4.0.0. void zsock_set_plain_username (void *self, const char *plain_username); // Get socket option `plain_password`. // Available from libzmq 4.0.0. char * zsock_plain_password (void *self); // Set socket option `plain_password`. // Available from libzmq 4.0.0. void zsock_set_plain_password (void *self, const char *plain_password); // Get socket option `curve_server`. // Available from libzmq 4.0.0. int zsock_curve_server (void *self); // Set socket option `curve_server`. // Available from libzmq 4.0.0. void zsock_set_curve_server (void *self, int curve_server); // Get socket option `curve_publickey`. // Available from libzmq 4.0.0. char * zsock_curve_publickey (void *self); // Set socket option `curve_publickey`. // Available from libzmq 4.0.0. void zsock_set_curve_publickey (void *self, const char *curve_publickey); // Set socket option `curve_publickey` from 32-octet binary // Available from libzmq 4.0.0. void zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey); // Get socket option `curve_secretkey`. // Available from libzmq 4.0.0. char * zsock_curve_secretkey (void *self); // Set socket option `curve_secretkey`. // Available from libzmq 4.0.0. void zsock_set_curve_secretkey (void *self, const char *curve_secretkey); // Set socket option `curve_secretkey` from 32-octet binary // Available from libzmq 4.0.0. void zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey); // Get socket option `curve_serverkey`. // Available from libzmq 4.0.0. char * zsock_curve_serverkey (void *self); // Set socket option `curve_serverkey`. // Available from libzmq 4.0.0. void zsock_set_curve_serverkey (void *self, const char *curve_serverkey); // Set socket option `curve_serverkey` from 32-octet binary // Available from libzmq 4.0.0. void zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey); // Get socket option `gssapi_server`. // Available from libzmq 4.0.0. int zsock_gssapi_server (void *self); // Set socket option `gssapi_server`. // Available from libzmq 4.0.0. void zsock_set_gssapi_server (void *self, int gssapi_server); // Get socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. int zsock_gssapi_plaintext (void *self); // Set socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. void zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext); // Get socket option `gssapi_principal`. // Available from libzmq 4.0.0. char * zsock_gssapi_principal (void *self); // Set socket option `gssapi_principal`. // Available from libzmq 4.0.0. void zsock_set_gssapi_principal (void *self, const char *gssapi_principal); // Get socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. char * zsock_gssapi_service_principal (void *self); // Set socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. void zsock_set_gssapi_service_principal (void *self, const char *gssapi_service_principal); // Get socket option `ipv6`. // Available from libzmq 4.0.0. int zsock_ipv6 (void *self); // Set socket option `ipv6`. // Available from libzmq 4.0.0. void zsock_set_ipv6 (void *self, int ipv6); // Get socket option `immediate`. // Available from libzmq 4.0.0. int zsock_immediate (void *self); // Set socket option `immediate`. // Available from libzmq 4.0.0. void zsock_set_immediate (void *self, int immediate); // Get socket option `sndhwm`. // Available from libzmq 3.0.0. int zsock_sndhwm (void *self); // Set socket option `sndhwm`. // Available from libzmq 3.0.0. void zsock_set_sndhwm (void *self, int sndhwm); // Get socket option `rcvhwm`. // Available from libzmq 3.0.0. int zsock_rcvhwm (void *self); // Set socket option `rcvhwm`. // Available from libzmq 3.0.0. void zsock_set_rcvhwm (void *self, int rcvhwm); // Get socket option `maxmsgsize`. // Available from libzmq 3.0.0. int zsock_maxmsgsize (void *self); // Set socket option `maxmsgsize`. // Available from libzmq 3.0.0. void zsock_set_maxmsgsize (void *self, int maxmsgsize); // Get socket option `multicast_hops`. // Available from libzmq 3.0.0. int zsock_multicast_hops (void *self); // Set socket option `multicast_hops`. // Available from libzmq 3.0.0. void zsock_set_multicast_hops (void *self, int multicast_hops); // Set socket option `xpub_verbose`. // Available from libzmq 3.0.0. void zsock_set_xpub_verbose (void *self, int xpub_verbose); // Get socket option `tcp_keepalive`. // Available from libzmq 3.0.0. int zsock_tcp_keepalive (void *self); // Set socket option `tcp_keepalive`. // Available from libzmq 3.0.0. void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); // Get socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. int zsock_tcp_keepalive_idle (void *self); // Set socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); // Get socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. int zsock_tcp_keepalive_cnt (void *self); // Set socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); // Get socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. int zsock_tcp_keepalive_intvl (void *self); // Set socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); // Get socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. char * zsock_tcp_accept_filter (void *self); // Set socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. void zsock_set_tcp_accept_filter (void *self, const char *tcp_accept_filter); // Get socket option `last_endpoint`. // Available from libzmq 3.0.0. char * zsock_last_endpoint (void *self); // Set socket option `router_raw`. // Available from libzmq 3.0.0. void zsock_set_router_raw (void *self, int router_raw); // Get socket option `ipv4only`. // Available from libzmq 3.0.0. int zsock_ipv4only (void *self); // Set socket option `ipv4only`. // Available from libzmq 3.0.0. void zsock_set_ipv4only (void *self, int ipv4only); // Set socket option `delay_attach_on_connect`. // Available from libzmq 3.0.0. void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); // Get socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. int zsock_hwm (void *self); // Set socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. void zsock_set_hwm (void *self, int hwm); // Get socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. int zsock_swap (void *self); // Set socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. void zsock_set_swap (void *self, int swap); // Get socket option `affinity`. // Available from libzmq 2.0.0. int zsock_affinity (void *self); // Set socket option `affinity`. // Available from libzmq 2.0.0. void zsock_set_affinity (void *self, int affinity); // Get socket option `identity`. // Available from libzmq 2.0.0. char * zsock_identity (void *self); // Set socket option `identity`. // Available from libzmq 2.0.0. void zsock_set_identity (void *self, const char *identity); // Get socket option `rate`. // Available from libzmq 2.0.0. int zsock_rate (void *self); // Set socket option `rate`. // Available from libzmq 2.0.0. void zsock_set_rate (void *self, int rate); // Get socket option `recovery_ivl`. // Available from libzmq 2.0.0. int zsock_recovery_ivl (void *self); // Set socket option `recovery_ivl`. // Available from libzmq 2.0.0. void zsock_set_recovery_ivl (void *self, int recovery_ivl); // Get socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. int zsock_recovery_ivl_msec (void *self); // Set socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. void zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec); // Get socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. int zsock_mcast_loop (void *self); // Set socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. void zsock_set_mcast_loop (void *self, int mcast_loop); // Get socket option `rcvtimeo`. // Available from libzmq 2.2.0. int zsock_rcvtimeo (void *self); // Set socket option `rcvtimeo`. // Available from libzmq 2.2.0. void zsock_set_rcvtimeo (void *self, int rcvtimeo); // Get socket option `sndtimeo`. // Available from libzmq 2.2.0. int zsock_sndtimeo (void *self); // Set socket option `sndtimeo`. // Available from libzmq 2.2.0. void zsock_set_sndtimeo (void *self, int sndtimeo); // Get socket option `sndbuf`. // Available from libzmq 2.0.0. int zsock_sndbuf (void *self); // Set socket option `sndbuf`. // Available from libzmq 2.0.0. void zsock_set_sndbuf (void *self, int sndbuf); // Get socket option `rcvbuf`. // Available from libzmq 2.0.0. int zsock_rcvbuf (void *self); // Set socket option `rcvbuf`. // Available from libzmq 2.0.0. void zsock_set_rcvbuf (void *self, int rcvbuf); // Get socket option `linger`. // Available from libzmq 2.0.0. int zsock_linger (void *self); // Set socket option `linger`. // Available from libzmq 2.0.0. void zsock_set_linger (void *self, int linger); // Get socket option `reconnect_ivl`. // Available from libzmq 2.0.0. int zsock_reconnect_ivl (void *self); // Set socket option `reconnect_ivl`. // Available from libzmq 2.0.0. void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); // Get socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. int zsock_reconnect_ivl_max (void *self); // Set socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); // Get socket option `backlog`. // Available from libzmq 2.0.0. int zsock_backlog (void *self); // Set socket option `backlog`. // Available from libzmq 2.0.0. void zsock_set_backlog (void *self, int backlog); // Set socket option `subscribe`. // Available from libzmq 2.0.0. void zsock_set_subscribe (void *self, const char *subscribe); // Set socket option `unsubscribe`. // Available from libzmq 2.0.0. void zsock_set_unsubscribe (void *self, const char *unsubscribe); // Get socket option `type`. // Available from libzmq 2.0.0. int zsock_type (void *self); // Get socket option `rcvmore`. // Available from libzmq 2.0.0. int zsock_rcvmore (void *self); // Get socket option `fd`. // Available from libzmq 2.0.0. SOCKET zsock_fd (void *self); // Get socket option `events`. // Available from libzmq 2.0.0. int zsock_events (void *self); // Self test of this class. void zsock_test (bool verbose); // CLASS: zstr // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. char * zstr_recv (void *source); // Receive a series of strings (until NULL) from multipart data. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL. // Returns -1 if the message could not be read, else returns the // number of strings filled, zero or more. Free each returned string // using zstr_free(). If not enough strings are provided, remaining // multipart frames in the message are dropped. int zstr_recvx (void *source, char **string_p, ...); // De-compress and receive C string from socket, received as a message // with two frames: size of the uncompressed string, and the string itself. // Caller must free returned string using zstr_free(). Returns NULL if the // context is being terminated or the process was interrupted. char * zstr_recv_compress (void *source); // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". int zstr_send (void *dest, const char *string); // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. int zstr_sendm (void *dest, const char *string); // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). int zstr_sendf (void *dest, const char *format, ...); // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. int zstr_sendfm (void *dest, const char *format, ...); // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or -1 on error. int zstr_sendx (void *dest, const char *string, ...); // Compress and send a C string to a socket, as a message with two frames: // size of the uncompressed string, and the string itself. The string is // sent without trailing null byte; to read this you can use // zstr_recv_compress, or a similar method that de-compresses and adds a // null terminator on the received string. int zstr_send_compress (void *dest, const char *string); // Compress and send a C string to a socket, as zstr_send_compress(), // with a MORE flag, so that you can send further strings in the same // multi-part message. int zstr_sendm_compress (void *dest, const char *string); // Accepts a void pointer and returns a fresh character string. If source // is null, returns an empty string. char * zstr_str (void *source); // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. void zstr_free (char **string_p); // Self test of this class. void zstr_test (bool verbose); // CLASS: zsys // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. void * zsys_init (void); // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls. void zsys_shutdown (void); // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. // *** This is for CZMQ internal use only and may change arbitrarily *** void * zsys_socket (int type, const char *filename, size_t line_nbr); // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). // *** This is for CZMQ internal use only and may change arbitrarily *** int zsys_close (void *handle, const char *filename, size_t line_nbr); // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** char * zsys_sockname (int socktype); // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. zsock_t * zsys_create_pipe (zsock_t **backend_p); // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. void zsys_handler_set (zsys_handler_fn *handler_fn); // Reset interrupt handler, call this at exit if needed void zsys_handler_reset (void); // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. // Can be supressed by ZSYS_SIGHANDLER=false // *** This is for CZMQ internal use only and may change arbitrarily *** void zsys_catch_interrupts (void); // Return 1 if file exists, else zero bool zsys_file_exists (const char *filename); // Return file modification time. Returns 0 if the file does not exist. time_t zsys_file_modified (const char *filename); // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. int zsys_file_mode (const char *filename); // Delete file. Does not complain if the file is absent int zsys_file_delete (const char *filename); // Check if file is 'stable' bool zsys_file_stable (const char *filename); // Create a file path if it doesn't exist. The file path is treated as // printf format. int zsys_dir_create (const char *pathname, ...); // Remove a file path if empty; the pathname is treated as printf format. int zsys_dir_delete (const char *pathname, ...); // Move to a specified working directory. Returns 0 if OK, -1 if this failed. int zsys_dir_change (const char *pathname); // Set private file creation mode; all files created from here will be // readable/writable by the owner only. void zsys_file_mode_private (void); // Reset default file creation mode; all files created from here will use // process file mode defaults. void zsys_file_mode_default (void); // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. 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(). char * zsys_sprintf (const char *format, ...); // Format a string with a va_list argument, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). char * zsys_vprintf (const char *format, va_list argptr); // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. // *** This is for CZMQ internal use only and may change arbitrarily *** SOCKET zsys_udp_new (bool routable); // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** int zsys_udp_close (SOCKET handle); // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address, int addrlen); // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or // NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. // *** This is for CZMQ internal use only and may change arbitrarily *** zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername, int peerlen); // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. // *** This is for CZMQ internal use only and may change arbitrarily *** void zsys_socket_error (const char *reason); // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. char * zsys_hostname (void); // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. int zsys_daemonize (const char *workdir); // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. int zsys_run_as (const char *lockfile, const char *group, const char *user); // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. bool zsys_has_curve (void); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_io_threads (size_t io_threads); // Configure the scheduling policy of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY // is defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_thread_sched_policy (int policy); // Configure the scheduling priority of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_PRIORITY is // defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_thread_priority (int priority); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void zsys_set_max_sockets (size_t max_sockets); // Return maximum number of ZeroMQ sockets that the system will support. size_t zsys_socket_limit (void); // Configure the maximum allowed size of a message sent. // The default is INT_MAX. void zsys_set_max_msgsz (int max_msgsz); // Return maximum message size. int zsys_max_msgsz (void); // Configure the threshold value of filesystem object age per st_mtime // that should elapse until we consider that object "stable" at the // current zclock_time() moment. // The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c // which generally depends on host OS, with fallback value of 5000. void zsys_set_file_stable_age_msec (int64_t file_stable_age_msec); // Return current threshold value of file stable age in msec. // This can be used in code that chooses to wait for this timeout // before testing if a filesystem object is "stable" or not. int64_t zsys_file_stable_age_msec (void); // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. void zsys_set_linger (size_t linger); // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void zsys_set_sndhwm (size_t sndhwm); // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void zsys_set_rcvhwm (size_t rcvhwm); // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. void zsys_set_pipehwm (size_t pipehwm); // Return the HWM for zactor internal pipes. size_t zsys_pipehwm (void); // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. void zsys_set_ipv6 (int ipv6); // Return use of IPv6 for zsock instances. int zsys_ipv6 (void); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void zsys_set_interface (const char *value); // Return network interface to use for broadcasts, or "" if none was set. const char * zsys_interface (void); // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses // on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, // use that as the default IPv6 address. void zsys_set_ipv6_address (const char *value); // Return IPv6 address to use for zbeacon reception, or "" if none was set. const char * zsys_ipv6_address (void); // Set IPv6 milticast address to use for sending zbeacon messages. This needs // to be set if IPv6 is enabled. If the environment variable // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast // address. void zsys_set_ipv6_mcast_address (const char *value); // Return IPv6 multicast address to use for sending zbeacon, or "" if none was // set. const char * zsys_ipv6_mcast_address (void); // Configure the automatic use of pre-allocated FDs when creating new sockets. // If 0 (default), nothing will happen. Else, when a new socket is bound, the // system API will be used to check if an existing pre-allocated FD with a // matching port (if TCP) or path (if IPC) exists, and if it does it will be // set via the ZMQ_USE_FD socket option so that the library will use it // instead of creating a new socket. void zsys_set_auto_use_fd (int auto_use_fd); // Return use of automatic pre-allocated FDs for zsock instances. int zsys_auto_use_fd (void); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void zsys_set_logident (const char *value); // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). void zsys_set_logstream (FILE *stream); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void zsys_set_logsender (const char *endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void zsys_set_logsystem (bool logsystem); // Log error condition - highest priority void zsys_error (const char *format, ...); // Log warning condition - high priority void zsys_warning (const char *format, ...); // Log normal, but significant, condition - normal priority void zsys_notice (const char *format, ...); // Log informational message - low priority void zsys_info (const char *format, ...); // Log debug-level message - lowest priority void zsys_debug (const char *format, ...); // Self test of this class. void zsys_test (bool verbose); // CLASS: ztimerset // Create new timer set. ztimerset_t * ztimerset_new (void); // Destroy a timer set void ztimerset_destroy (ztimerset_t **self_p); // Add a timer to the set. Returns timer id if OK, -1 on failure. int ztimerset_add (ztimerset_t *self, size_t interval, ztimerset_fn handler, void *arg); // Cancel a timer. Returns 0 if OK, -1 on failure. int ztimerset_cancel (ztimerset_t *self, int timer_id); // Set timer interval. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int ztimerset_set_interval (ztimerset_t *self, int timer_id, size_t interval); // Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int ztimerset_reset (ztimerset_t *self, int timer_id); // Return the time until the next interval. // Should be used as timeout parameter for the zpoller wait method. // The timeout is in msec. int ztimerset_timeout (ztimerset_t *self); // Invoke callback function of all timers which their interval has elapsed. // Should be call after zpoller wait method. // Returns 0 if OK, -1 on failure. int ztimerset_execute (ztimerset_t *self); // Self test of this class. void ztimerset_test (bool verbose); // CLASS: ztrie // Creates a new ztrie. ztrie_t * ztrie_new (char delimiter); // Destroy the ztrie. void ztrie_destroy (ztrie_t **self_p); // Inserts a new route into the tree and attaches the data. Returns -1 // if the route already exists, otherwise 0. This method takes ownership of // the provided data if a destroy_data_fn is provided. int ztrie_insert_route (ztrie_t *self, const char *path, void *data, ztrie_destroy_data_fn destroy_data_fn); // Removes a route from the trie and destroys its data. Returns -1 if the // route does not exists, otherwise 0. // the start of the list call zlist_first (). Advances the cursor. int ztrie_remove_route (ztrie_t *self, const char *path); // Returns true if the path matches a route in the tree, otherwise false. bool ztrie_matches (ztrie_t *self, const char *path); // Returns the data of a matched route from last ztrie_matches. If the path // did not match, returns NULL. Do not delete the data as it's owned by // ztrie. void * ztrie_hit_data (ztrie_t *self); // Returns the count of parameters that a matched route has. size_t ztrie_hit_parameter_count (ztrie_t *self); // Returns the parameters of a matched route with named regexes from last // ztrie_matches. If the path did not match or the route did not contain any // named regexes, returns NULL. zhashx_t * ztrie_hit_parameters (ztrie_t *self); // Returns the asterisk matched part of a route, if there has been no match // or no asterisk match, returns NULL. const char * ztrie_hit_asterisk_match (ztrie_t *self); // Print the trie void ztrie_print (ztrie_t *self); // Self test of this class. void ztrie_test (bool verbose); // CLASS: zuuid // Create a new UUID object. zuuid_t * zuuid_new (void); // Destroy a specified UUID object. void zuuid_destroy (zuuid_t **self_p); // Create UUID object from supplied ZUUID_LEN-octet value. zuuid_t * zuuid_new_from (const byte *source); // Set UUID to new supplied ZUUID_LEN-octet value. void zuuid_set (zuuid_t *self, const byte *source); // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. int zuuid_set_str (zuuid_t *self, const char *source); // Return UUID binary data. const byte * zuuid_data (zuuid_t *self); // Return UUID binary size size_t zuuid_size (zuuid_t *self); // Returns UUID as string const char * zuuid_str (zuuid_t *self); // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier const char * zuuid_str_canonical (zuuid_t *self); // Store UUID blob in target array void zuuid_export (zuuid_t *self, byte *target); // Check if UUID is same as supplied value bool zuuid_eq (zuuid_t *self, const byte *compare); // Check if UUID is different from supplied value bool zuuid_neq (zuuid_t *self, const byte *compare); // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. zuuid_t * zuuid_dup (zuuid_t *self); // Self test of this class. void zuuid_test (bool verbose); ''') for i, item in enumerate (czmq_cdefs): czmq_cdefs [i] = re.sub(r';[^;]*\bva_list\b[^;]*;', ';', item, flags=re.S) # we don't support anything with a va_list arg czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zhash.py0000664000372000037200000001715313222211156023067 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zhash(object): """ generic type-free hash container (simple) """ def __init__(self): """ Create a new, empty hash container """ p = utils.lib.zhash_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zhash_destroy_py) def insert(self, key, item): """ Insert item into hash table with specified key and item. If key is already present returns -1 and leaves existing item unchanged Returns 0 on success. """ return utils.lib.zhash_insert(self._p, utils.to_bytes(key), item._p) def update(self, key, item): """ Update item into hash table with specified key and item. If key is already present, destroys old item and inserts new one. Use free_fn method to ensure deallocator is properly called on item. """ utils.lib.zhash_update(self._p, utils.to_bytes(key), item._p) def delete(self, key): """ Remove an item specified by key from the hash table. If there was no such item, this function does nothing. """ utils.lib.zhash_delete(self._p, utils.to_bytes(key)) def lookup(self, key): """ Return the item at the specified key, or null """ return utils.lib.zhash_lookup(self._p, utils.to_bytes(key)) def rename(self, old_key, new_key): """ Reindexes an item from an old key to a new key. If there was no such item, does nothing. Returns 0 if successful, else -1. """ return utils.lib.zhash_rename(self._p, utils.to_bytes(old_key), utils.to_bytes(new_key)) def freefn(self, key, free_fn): """ Set a free function for the specified hash table item. When the item is destroyed, the free function, if any, is called on that item. Use this when hash items are dynamically allocated, to ensure that you don't have memory leaks. You can pass 'free' or NULL as a free_fn. Returns the item, or NULL if there is no such item. """ return utils.lib.zhash_freefn(self._p, utils.to_bytes(key), free_fn) def size(self): """ Return the number of keys/items in the hash table """ return utils.lib.zhash_size(self._p) def dup(self): """ Make copy of hash table; if supplied table is null, returns null. Does not copy items themselves. Rebuilds new table so may be slow on very large tables. NOTE: only works with item values that are strings since there's no other way to know how to duplicate the item value. """ return utils.lib.zhash_dup(self._p) def keys(self): """ Return keys for items in table """ return utils.lib.zhash_keys(self._p) def first(self): """ Simple iterator; returns first item in hash table, in no given order, or NULL if the table is empty. This method is simpler to use than the foreach() method, which is deprecated. To access the key for this item use zhash_cursor(). NOTE: do NOT modify the table while iterating. """ return utils.lib.zhash_first(self._p) def next(self): """ Simple iterator; returns next item in hash table, in no given order, or NULL if the last item was already returned. Use this together with zhash_first() to process all items in a hash table. If you need the items in sorted order, use zhash_keys() and then zlist_sort(). To access the key for this item use zhash_cursor(). NOTE: do NOT modify the table while iterating. """ return utils.lib.zhash_next(self._p) def cursor(self): """ After a successful first/next method, returns the key for the item that was returned. This is a constant string that you may not modify or deallocate, and which lasts as long as the item in the hash. After an unsuccessful first/next, returns NULL. """ return utils.lib.zhash_cursor(self._p) def comment(self, format, ): """ Add a comment to hash table before saving to disk. You can add as many comment lines as you like. These comment lines are discarded when loading the file. If you use a null format, all comments are deleted. """ utils.lib.zhash_comment(self._p, format, ) def pack(self): """ Serialize hash table to a binary frame that can be sent in a message. The packed format is compatible with the 'dictionary' type defined in http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: ; A list of name/value pairs dictionary = dict-count *( dict-name dict-value ) dict-count = number-4 dict-value = longstr dict-name = string ; Strings are always length + text contents longstr = number-4 *VCHAR string = number-1 *VCHAR ; Numbers are unsigned integers in network byte order number-1 = 1OCTET number-4 = 4OCTET Comments are not included in the packed data. Item values MUST be strings. """ return utils.lib.zhash_pack(self._p) def save(self, filename): """ Save hash table to a text file in name=value format. Hash values must be printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file error occurred. """ return utils.lib.zhash_save(self._p, utils.to_bytes(filename)) def load(self, filename): """ Load hash table from a text file in name=value format; hash table must already exist. Hash values must printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file was not readable. """ return utils.lib.zhash_load(self._p, utils.to_bytes(filename)) def refresh(self): """ When a hash table was loaded from a file by zhash_load, this method will reload the file if it has been modified since, and is "stable", i.e. not still changing. Returns 0 if OK, -1 if there was an error reloading the file. """ return utils.lib.zhash_refresh(self._p) def autofree(self): """ Set hash for automatic value destruction. Note that this assumes that values are NULL-terminated strings. Do not use with different types. """ utils.lib.zhash_autofree(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zhash_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zdigest.py0000664000372000037200000000445613222211156023425 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zdigest(object): """ provides hashing functions (SHA-1 at present) """ def __init__(self): """ Constructor - creates new digest object, which you use to build up a digest by repeatedly calling zdigest_update() on chunks of data. """ p = utils.lib.zdigest_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zdigest_destroy_py) def update(self, buffer, length): """ Add buffer into digest calculation """ utils.lib.zdigest_update(self._p, buffer, length) def data(self): """ Return final digest hash data. If built without crypto support, returns NULL. """ return utils.lib.zdigest_data(self._p) def size(self): """ Return final digest hash size """ return utils.lib.zdigest_size(self._p) def string(self): """ Return digest as printable hex string; caller should not modify nor free this string. After calling this, you may not use zdigest_update() on the same digest. If built without crypto support, returns NULL. """ return utils.lib.zdigest_string(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zdigest_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zframe.py0000664000372000037200000001237613222211156023240 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zframe(object): """ working with single message frames """ def __init__(self, data, size): """ Create a new frame. If size is not null, allocates the frame data to the specified size. If additionally, data is not null, copies size octets from the specified data into the frame body. """ p = utils.lib.zframe_new(data, size) if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zframe_destroy_py) def send(self_p, dest, flags): """ Send a frame to a socket, destroy frame after sending. Return -1 on error, 0 on success. """ return utils.lib.zframe_send(self_p._p, dest._p, flags) def size(self): """ Return number of bytes in frame data """ return utils.lib.zframe_size(self._p) def data(self): """ Return address of frame data """ return utils.lib.zframe_data(self._p) def meta(self, property): """ Return meta data property for frame The caller shall not modify or free the returned value, which shall be owned by the message. """ return utils.lib.zframe_meta(self._p, utils.to_bytes(property)) def dup(self): """ Create a new frame that duplicates an existing frame. If frame is null, or memory was exhausted, returns null. """ return utils.lib.zframe_dup(self._p) def strhex(self): """ Return frame data encoded as printable hex string, useful for 0MQ UUIDs. Caller must free string when finished with it. """ return utils.lib.zframe_strhex(self._p) def strdup(self): """ Return frame data copied into freshly allocated string Caller must free string when finished with it. """ return utils.lib.zframe_strdup(self._p) def streq(self, string): """ Return TRUE if frame body is equal to string, excluding terminator """ return utils.lib.zframe_streq(self._p, utils.to_bytes(string)) def more(self): """ Return frame MORE indicator (1 or 0), set when reading frame from socket or by the zframe_set_more() method """ return utils.lib.zframe_more(self._p) def set_more(self, more): """ Set frame MORE indicator (1 or 0). Note this is NOT used when sending frame to socket, you have to specify flag explicitly. """ utils.lib.zframe_set_more(self._p, more) def routing_id(self): """ Return frame routing ID, if the frame came from a ZMQ_SERVER socket. Else returns zero. """ return utils.lib.zframe_routing_id(self._p) def set_routing_id(self, routing_id): """ Set routing ID on frame. This is used if/when the frame is sent to a ZMQ_SERVER socket. """ utils.lib.zframe_set_routing_id(self._p, routing_id) def group(self): """ Return frame group of radio-dish pattern. """ return utils.lib.zframe_group(self._p) def set_group(self, group): """ Set group on frame. This is used if/when the frame is sent to a ZMQ_RADIO socket. Return -1 on error, 0 on success. """ return utils.lib.zframe_set_group(self._p, utils.to_bytes(group)) def eq(self, other): """ Return TRUE if two frames have identical size and data If either frame is NULL, equality is always false. """ return utils.lib.zframe_eq(self._p, other._p) def reset(self, data, size): """ Set new contents for frame """ utils.lib.zframe_reset(self._p, data, size) def print_py(self, prefix): """ Send message to zsys log sink (may be stdout, or system facility as configured by zsys_set_logstream). Prefix shows before frame, if not null. """ utils.lib.zframe_print(self._p, utils.to_bytes(prefix)) def is_py(self): """ Probe the supplied object, and report if it looks like a zframe_t. """ return utils.lib.zframe_is(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zframe_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/_cdefs.inc0000664000372000037200000041051613222211156023356 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ # This file is intended to be included while generating cffi binding for top level library czmq_cdefs = list () # Custom setup for czmq czmq_cdefs.append (''' typedef int time_t; typedef int off_t; typedef unsigned char byte; // Single unsigned byte = 8 bits typedef unsigned short dbyte; // Double byte = 16 bits typedef unsigned int qbyte; // Quad byte = 32 bits typedef int SOCKET; typedef struct sockaddr_in inaddr_t; // -- destroy an item typedef void (czmq_destructor) (void **item); // -- duplicate an item typedef void *(czmq_duplicator) (const void *item); // - compare two items, for sorting typedef int (czmq_comparator) (const void *item1, const void *item2); ''') czmq_cdefs.append (''' typedef struct _zsock_t zsock_t; typedef struct _zactor_t zactor_t; typedef struct _zmsg_t zmsg_t; typedef struct _zargs_t zargs_t; typedef struct _zarmour_t zarmour_t; typedef struct _zchunk_t zchunk_t; typedef struct _char_t char_t; typedef struct _zcert_t zcert_t; typedef struct _zlist_t zlist_t; typedef struct _zcertstore_t zcertstore_t; typedef struct _zlistx_t zlistx_t; typedef struct _zframe_t zframe_t; typedef struct _msecs_t msecs_t; typedef struct _zclock_t zclock_t; typedef struct _zconfig_t zconfig_t; typedef struct _zdigest_t zdigest_t; typedef struct _zdir_t zdir_t; typedef struct _zhash_t zhash_t; typedef struct _zfile_t zfile_t; typedef struct _zdir_patch_t zdir_patch_t; typedef struct _zhashx_t zhashx_t; typedef struct _ziflist_t ziflist_t; typedef struct _zloop_t zloop_t; typedef struct _zmq_pollitem_t zmq_pollitem_t; typedef struct _zpoller_t zpoller_t; typedef struct _zproc_t zproc_t; typedef struct _va_list_t va_list_t; typedef struct _socket_t socket_t; typedef struct _zstr_t zstr_t; typedef struct _zsys_t zsys_t; typedef struct _ztimerset_t ztimerset_t; typedef struct _ztrie_t ztrie_t; typedef struct _zuuid_t zuuid_t; // Actors get a pipe and arguments from caller typedef void (zactor_fn) ( zsock_t *pipe, void *args); // Function to be called on zactor_destroy. Default behavior is to send zmsg_t with string "$TERM" in a first frame. // // An example - to send $KTHXBAI string // // if (zstr_send (self->pipe, "$KTHXBAI") == 0) // zsock_wait (self->pipe); typedef void (zactor_destructor_fn) ( zactor_t *self); // Loaders retrieve certificates from an arbitrary source. typedef void (zcertstore_loader) ( zcertstore_t *self); // Destructor for loader state. typedef void (zcertstore_destructor) ( void **self_p); // typedef int (zconfig_fct) ( zconfig_t *self, void *arg, int level); // Callback function for zhash_freefn method typedef void (zhash_free_fn) ( void *data); // Destroy an item typedef void (zhashx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zhashx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zhashx_comparator_fn) ( const void *item1, const void *item2); // Destroy an item. typedef void (zhashx_free_fn) ( void *data); // Hash function for keys. typedef size_t (zhashx_hash_fn) ( const void *key); // Serializes an item to a longstr. // The caller takes ownership of the newly created object. typedef char * (zhashx_serializer_fn) ( const void *item); // Deserializes a longstr into an item. // The caller takes ownership of the newly created object. typedef void * (zhashx_deserializer_fn) ( const char *item_str); // Comparison function e.g. for sorting and removing. typedef int (zlist_compare_fn) ( void *item1, void *item2); // Callback function for zlist_freefn method typedef void (zlist_free_fn) ( void *data); // Destroy an item typedef void (zlistx_destructor_fn) ( void **item); // Duplicate an item typedef void * (zlistx_duplicator_fn) ( const void *item); // Compare two items, for sorting typedef int (zlistx_comparator_fn) ( const void *item1, const void *item2); // Callback function for reactor socket activity typedef int (zloop_reader_fn) ( zloop_t *loop, zsock_t *reader, void *arg); // Callback function for reactor events (low-level) typedef int (zloop_fn) ( zloop_t *loop, zmq_pollitem_t *item, void *arg); // Callback for reactor timer events typedef int (zloop_timer_fn) ( zloop_t *loop, int timer_id, void *arg); // Callback for interrupt signal handler typedef void (zsys_handler_fn) ( int signal_value); // Callback function for timer event. typedef void (ztimerset_fn) ( int timer_id, void *arg); // Callback function for ztrie_node to destroy node data. typedef void (ztrie_destroy_data_fn) ( void **data); // CLASS: zactor // Create a new actor passing arbitrary arguments reference. zactor_t * zactor_new (zactor_fn task, void *args); // Destroy an actor. void zactor_destroy (zactor_t **self_p); // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. int zactor_send (zactor_t *self, zmsg_t **msg_p); // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. zmsg_t * zactor_recv (zactor_t *self); // Probe the supplied object, and report if it looks like a zactor_t. bool zactor_is (void *self); // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. void * zactor_resolve (void *self); // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. zsock_t * zactor_sock (zactor_t *self); // Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. void zactor_set_destructor (zactor_t *self, zactor_destructor_fn destructor); // Self test of this class. void zactor_test (bool verbose); // CLASS: zargs // Create a new zargs from command line arguments. zargs_t * zargs_new (int argc, char **argv); // Destroy zargs instance. void zargs_destroy (zargs_t **self_p); // Return program name (argv[0]) const char * zargs_progname (zargs_t *self); // Return number of positional arguments size_t zargs_arguments (zargs_t *self); // Return first positional argument or NULL const char * zargs_first (zargs_t *self); // Return next positional argument or NULL const char * zargs_next (zargs_t *self); // Return first named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const char * zargs_param_first (zargs_t *self); // Return next named parameter value, or NULL if there are no named // parameters, or value for which zargs_param_empty (arg) returns true. const char * zargs_param_next (zargs_t *self); // Return current parameter name, or NULL if there are no named // parameters. const char * zargs_param_name (zargs_t *self); // Return value of named parameter, NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const char * zargs_param_lookup (zargs_t *self, const char *keys); // Return value of named parameter(s), NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const char * zargs_param_lookupx (zargs_t *self, const char *keys, ...); // Returns true if there are --help -h arguments bool zargs_has_help (zargs_t *self); // Returns true if parameter did not have a value bool zargs_param_empty (const char *arg); // Print an instance of zargs. void zargs_print (zargs_t *self); // Self test of this class. void zargs_test (bool verbose); // CLASS: zarmour // Create a new zarmour zarmour_t * zarmour_new (void); // Destroy the zarmour void zarmour_destroy (zarmour_t **self_p); // Encode a stream of bytes into an armoured string. Returns the armoured // string, or NULL if there was insufficient memory available to allocate // a new string. char * zarmour_encode (zarmour_t *self, const byte *data, size_t size); // Decode an armoured string into a chunk. The decoded output is // null-terminated, so it may be treated as a string, if that's what // it was prior to encoding. zchunk_t * zarmour_decode (zarmour_t *self, const char *data); // Get the mode property. int zarmour_mode (zarmour_t *self); // Get printable string for mode. const char * zarmour_mode_str (zarmour_t *self); // Set the mode property. void zarmour_set_mode (zarmour_t *self, int mode); // Return true if padding is turned on. bool zarmour_pad (zarmour_t *self); // Turn padding on or off. Default is on. void zarmour_set_pad (zarmour_t *self, bool pad); // Get the padding character. char zarmour_pad_char (zarmour_t *self); // Set the padding character. void zarmour_set_pad_char (zarmour_t *self, char pad_char); // Return if splitting output into lines is turned on. Default is off. bool zarmour_line_breaks (zarmour_t *self); // Turn splitting output into lines on or off. void zarmour_set_line_breaks (zarmour_t *self, bool line_breaks); // Get the line length used for splitting lines. size_t zarmour_line_length (zarmour_t *self); // Set the line length used for splitting lines. void zarmour_set_line_length (zarmour_t *self, size_t line_length); // Print properties of object void zarmour_print (zarmour_t *self); // Self test of this class. void zarmour_test (bool verbose); // CLASS: zcert // Create and initialize a new certificate in memory zcert_t * zcert_new (void); // Accepts public/secret key pair from caller zcert_t * zcert_new_from (const byte *public_key, const byte *secret_key); // Accepts public/secret key text pair from caller zcert_t * zcert_new_from_txt (const char *public_txt, const char *secret_txt); // Load certificate from file zcert_t * zcert_load (const char *filename); // Destroy a certificate in memory void zcert_destroy (zcert_t **self_p); // Return public part of key pair as 32-byte binary string const byte * zcert_public_key (zcert_t *self); // Return secret part of key pair as 32-byte binary string const byte * zcert_secret_key (zcert_t *self); // Return public part of key pair as Z85 armored string const char * zcert_public_txt (zcert_t *self); // Return secret part of key pair as Z85 armored string const char * zcert_secret_txt (zcert_t *self); // Set certificate metadata from formatted string. void zcert_set_meta (zcert_t *self, const char *name, const char *format, ...); // Unset certificate metadata. void zcert_unset_meta (zcert_t *self, const char *name); // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. const char * zcert_meta (zcert_t *self, const char *name); // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. zlist_t * zcert_meta_keys (zcert_t *self); // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). int zcert_save (zcert_t *self, const char *filename); // Save public certificate only to file for persistent storage int zcert_save_public (zcert_t *self, const char *filename); // Save secret certificate only to file for persistent storage int zcert_save_secret (zcert_t *self, const char *filename); // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. void zcert_apply (zcert_t *self, void *socket); // Return copy of certificate; if certificate is NULL or we exhausted // heap memory, returns NULL. zcert_t * zcert_dup (zcert_t *self); // Return true if two certificates have the same keys bool zcert_eq (zcert_t *self, zcert_t *compare); // Print certificate contents to stdout void zcert_print (zcert_t *self); // Self test of this class void zcert_test (bool verbose); // CLASS: zcertstore // Create a new certificate store from a disk directory, loading and // indexing all certificates in that location. The directory itself may be // absent, and created later, or modified at any time. The certificate store // is automatically refreshed on any zcertstore_lookup() call. If the // location is specified as NULL, creates a pure-memory store, which you // can work with by inserting certificates at runtime. zcertstore_t * zcertstore_new (const char *location); // Destroy a certificate store object in memory. Does not affect anything // stored on disk. void zcertstore_destroy (zcertstore_t **self_p); // Override the default disk loader with a custom loader fn. void zcertstore_set_loader (zcertstore_t *self, zcertstore_loader loader, zcertstore_destructor destructor, void *state); // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. zcert_t * zcertstore_lookup (zcertstore_t *self, const char *public_key); // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. void zcertstore_insert (zcertstore_t *self, zcert_t **cert_p); // Empty certificate hashtable. This wrapper exists to be friendly to bindings, // which don't usually have access to struct internals. void zcertstore_empty (zcertstore_t *self); // Print list of certificates in store to logging facility void zcertstore_print (zcertstore_t *self); // Return a list of all the certificates in the store. // The caller takes ownership of the zlistx_t object and is responsible // for destroying it. The caller does not take ownership of the zcert_t // objects. zlistx_t * zcertstore_certs (zcertstore_t *self); // Self test of this class void zcertstore_test (bool verbose); // CLASS: zchunk // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. zchunk_t * zchunk_new (const void *data, size_t size); // Destroy a chunk void zchunk_destroy (zchunk_t **self_p); // Resizes chunk max_size as requested; chunk_cur size is set to zero void zchunk_resize (zchunk_t *self, size_t size); // Return chunk cur size size_t zchunk_size (zchunk_t *self); // Return chunk max size size_t zchunk_max_size (zchunk_t *self); // Return chunk data byte * zchunk_data (zchunk_t *self); // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk size_t zchunk_set (zchunk_t *self, const void *data, size_t size); // Fill chunk data from user-supplied octet size_t zchunk_fill (zchunk_t *self, byte filler, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, it is truncated. If you want to // grow the chunk to accommodate new data, use the zchunk_extend method. size_t zchunk_append (zchunk_t *self, const void *data, size_t size); // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, the chunk grows in size. size_t zchunk_extend (zchunk_t *self, const void *data, size_t size); // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. size_t zchunk_consume (zchunk_t *self, zchunk_t *source); // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. bool zchunk_exhausted (zchunk_t *self); // Read chunk from an open file descriptor zchunk_t * zchunk_read (FILE *handle, size_t bytes); // Write chunk to an open file descriptor int zchunk_write (zchunk_t *self, FILE *handle); // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. zchunk_t * zchunk_slurp (const char *filename, size_t maxsize); // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // returns null. zchunk_t * zchunk_dup (zchunk_t *self); // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. char * zchunk_strhex (zchunk_t *self); // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. char * zchunk_strdup (zchunk_t *self); // Return TRUE if chunk body is equal to string, excluding terminator bool zchunk_streq (zchunk_t *self, const char *string); // Transform zchunk into a zframe that can be sent in a message. zframe_t * zchunk_pack (zchunk_t *self); // Transform a zframe into a zchunk. zchunk_t * zchunk_unpack (zframe_t *frame); // Calculate SHA1 digest for chunk, using zdigest class. const char * zchunk_digest (zchunk_t *self); // Dump chunk to FILE stream, for debugging and tracing. void zchunk_fprint (zchunk_t *self, FILE *file); // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details void zchunk_print (zchunk_t *self); // Probe the supplied object, and report if it looks like a zchunk_t. bool zchunk_is (void *self); // Self test of this class. void zchunk_test (bool verbose); // CLASS: zclock // Sleep for a number of milliseconds void zclock_sleep (int msecs); // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. int64_t zclock_time (void); // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t zclock_mono (void); // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t zclock_usecs (void); // Return formatted date/time as fresh string. Free using zstr_free(). char * zclock_timestr (void); // Self test of this class. void zclock_test (bool verbose); // CLASS: zconfig // Create new config item zconfig_t * zconfig_new (const char *name, zconfig_t *parent); // Destroy a config item and all its children void zconfig_destroy (zconfig_t **self_p); // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. zconfig_t * zconfig_load (const char *filename); // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. zconfig_t * zconfig_loadf (const char *format, ...); // Return name of config item char * zconfig_name (zconfig_t *self); // Return value of config item char * zconfig_value (zconfig_t *self); // Insert or update configuration key with value void zconfig_put (zconfig_t *self, const char *path, const char *value); // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. void zconfig_putf (zconfig_t *self, const char *path, const char *format, ...); // Get value for config item into a string value; leading slash is optional // and ignored. char * zconfig_get (zconfig_t *self, const char *path, const char *default_value); // Set config item name, name may be NULL void zconfig_set_name (zconfig_t *self, const char *name); // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. void zconfig_set_value (zconfig_t *self, const char *format, ...); // Find our first child, if any zconfig_t * zconfig_child (zconfig_t *self); // Find our first sibling, if any zconfig_t * zconfig_next (zconfig_t *self); // Find a config item along a path; leading slash is optional and ignored. zconfig_t * zconfig_locate (zconfig_t *self, const char *path); // Locate the last config item at a specified depth zconfig_t * zconfig_at_depth (zconfig_t *self, int level); // Execute a callback for each config item in the tree; returns zero if // successful, else -1. int zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg); // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. void zconfig_set_comment (zconfig_t *self, const char *format, ...); // Return comments of config item, as zlist. zlist_t * zconfig_comments (zconfig_t *self); // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. int zconfig_save (zconfig_t *self, const char *filename); // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. int zconfig_savef (zconfig_t *self, const char *format, ...); // Report filename used during zconfig_load, or NULL if none const char * zconfig_filename (zconfig_t *self); // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). int zconfig_reload (zconfig_t **self_p); // Load a config tree from a memory chunk zconfig_t * zconfig_chunk_load (zchunk_t *chunk); // Save a config tree to a new memory chunk zchunk_t * zconfig_chunk_save (zconfig_t *self); // Load a config tree from a null-terminated string zconfig_t * zconfig_str_load (const char *string); // Save a config tree to a new null terminated string char * zconfig_str_save (zconfig_t *self); // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. bool zconfig_has_changed (zconfig_t *self); // Destroy subtree (all children) void zconfig_remove_subtree (zconfig_t *self); // Destroy node and subtree (all children) void zconfig_remove (zconfig_t **self_p); // Print the config file to open stream void zconfig_fprint (zconfig_t *self, FILE *file); // Print properties of object void zconfig_print (zconfig_t *self); // Self test of this class void zconfig_test (bool verbose); // CLASS: zdigest // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. zdigest_t * zdigest_new (void); // Destroy a digest object void zdigest_destroy (zdigest_t **self_p); // Add buffer into digest calculation void zdigest_update (zdigest_t *self, const byte *buffer, size_t length); // Return final digest hash data. If built without crypto support, // returns NULL. const byte * zdigest_data (zdigest_t *self); // Return final digest hash size size_t zdigest_size (zdigest_t *self); // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. char * zdigest_string (zdigest_t *self); // Self test of this class. void zdigest_test (bool verbose); // CLASS: zdir // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. zdir_t * zdir_new (const char *path, const char *parent); // Destroy a directory tree and all children it contains. void zdir_destroy (zdir_t **self_p); // Return directory path const char * zdir_path (zdir_t *self); // Return last modification time for directory. time_t zdir_modified (zdir_t *self); // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. off_t zdir_cursize (zdir_t *self); // Return directory count size_t zdir_count (zdir_t *self); // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. zlist_t * zdir_list (zdir_t *self); // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. void zdir_remove (zdir_t *self, bool force); // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). zlist_t * zdir_diff (zdir_t *older, zdir_t *newer, const char *alias); // Return full contents of directory as a zdir_patch list. zlist_t * zdir_resync (zdir_t *self, const char *alias); // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. zhash_t * zdir_cache (zdir_t *self); // Print contents of directory to open stream void zdir_fprint (zdir_t *self, FILE *file, int indent); // Print contents of directory to stdout void zdir_print (zdir_t *self, int indent); // Create a new zdir_watch actor instance: // // zactor_t *watch = zactor_new (zdir_watch, NULL); // // Destroy zdir_watch instance: // // zactor_destroy (&watch); // // Enable verbose logging of commands and activity: // // zstr_send (watch, "VERBOSE"); // // Subscribe to changes to a directory path: // // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); // // Unsubscribe from changes to a directory path: // // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); // // Receive directory changes: // zsock_recv (watch, "sp", &path, &patches); // // // Delete the received data. // free (path); // zlist_destroy (&patches); void zdir_watch (zsock_t *pipe, void *unused); // Self test of this class. void zdir_test (bool verbose); // CLASS: zdir_patch // Create new patch zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, int op, const char *alias); // Destroy a patch void zdir_patch_destroy (zdir_patch_t **self_p); // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. zdir_patch_t * zdir_patch_dup (zdir_patch_t *self); // Return patch file directory path const char * zdir_patch_path (zdir_patch_t *self); // Return patch file item zfile_t * zdir_patch_file (zdir_patch_t *self); // Return operation int zdir_patch_op (zdir_patch_t *self); // Return patch virtual file path const char * zdir_patch_vpath (zdir_patch_t *self); // Calculate hash digest for file (create only) void zdir_patch_digest_set (zdir_patch_t *self); // Return hash digest for patch file const char * zdir_patch_digest (zdir_patch_t *self); // Self test of this class. void zdir_patch_test (bool verbose); // CLASS: zfile // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. zfile_t * zfile_new (const char *path, const char *name); // Create new temporary file for writing via tmpfile. File is automaticaly // deleted on destroy zfile_t * zfile_tmp (void); // Destroy a file item void zfile_destroy (zfile_t **self_p); // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. zfile_t * zfile_dup (zfile_t *self); // Return file name, remove path if provided const char * zfile_filename (zfile_t *self, const char *path); // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. void zfile_restat (zfile_t *self); // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. time_t zfile_modified (zfile_t *self); // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. off_t zfile_cursize (zfile_t *self); // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool zfile_is_directory (zfile_t *self); // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool zfile_is_regular (zfile_t *self); // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. bool zfile_is_readable (zfile_t *self); // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. bool zfile_is_writeable (zfile_t *self); // Check if file has stopped changing and can be safely processed. // Updates the file statistics from disk at every call. bool zfile_is_stable (zfile_t *self); // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. bool zfile_has_changed (zfile_t *self); // Remove the file from disk void zfile_remove (zfile_t *self); // Open file for reading // Returns 0 if OK, -1 if not found or not accessible int zfile_input (zfile_t *self); // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. int zfile_output (zfile_t *self); // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. zchunk_t * zfile_read (zfile_t *self, size_t bytes, off_t offset); // Returns true if zfile_read() just read the last chunk in the file. bool zfile_eof (zfile_t *self); // Write chunk to file at specified position // Return 0 if OK, else -1 int zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset); // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. const char * zfile_readln (zfile_t *self); // Close file, if open void zfile_close (zfile_t *self); // Return file handle, if opened FILE * zfile_handle (zfile_t *self); // Calculate SHA1 digest for file, using zdigest class. const char * zfile_digest (zfile_t *self); // Self test of this class. void zfile_test (bool verbose); // CLASS: zframe // Create a new frame. If size is not null, allocates the frame data // to the specified size. If additionally, data is not null, copies // size octets from the specified data into the frame body. zframe_t * zframe_new (const void *data, size_t size); // Destroy a frame void zframe_destroy (zframe_t **self_p); // Create an empty (zero-sized) frame zframe_t * zframe_new_empty (void); // Create a frame with a specified string content. zframe_t * zframe_from (const char *string); // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. zframe_t * zframe_recv (void *source); // Send a frame to a socket, destroy frame after sending. // Return -1 on error, 0 on success. int zframe_send (zframe_t **self_p, void *dest, int flags); // Return number of bytes in frame data size_t zframe_size (zframe_t *self); // Return address of frame data byte * zframe_data (zframe_t *self); // Return meta data property for frame // The caller shall not modify or free the returned value, which shall be // owned by the message. const char * zframe_meta (zframe_t *self, const char *property); // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. zframe_t * zframe_dup (zframe_t *self); // Return frame data encoded as printable hex string, useful for 0MQ UUIDs. // Caller must free string when finished with it. char * zframe_strhex (zframe_t *self); // Return frame data copied into freshly allocated string // Caller must free string when finished with it. char * zframe_strdup (zframe_t *self); // Return TRUE if frame body is equal to string, excluding terminator bool zframe_streq (zframe_t *self, const char *string); // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method int zframe_more (zframe_t *self); // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. void zframe_set_more (zframe_t *self, int more); // Return frame routing ID, if the frame came from a ZMQ_SERVER socket. // Else returns zero. uint32_t zframe_routing_id (zframe_t *self); // Set routing ID on frame. This is used if/when the frame is sent to a // ZMQ_SERVER socket. void zframe_set_routing_id (zframe_t *self, uint32_t routing_id); // Return frame group of radio-dish pattern. const char * zframe_group (zframe_t *self); // Set group on frame. This is used if/when the frame is sent to a // ZMQ_RADIO socket. // Return -1 on error, 0 on success. int zframe_set_group (zframe_t *self, const char *group); // Return TRUE if two frames have identical size and data // If either frame is NULL, equality is always false. bool zframe_eq (zframe_t *self, zframe_t *other); // Set new contents for frame void zframe_reset (zframe_t *self, const void *data, size_t size); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. void zframe_print (zframe_t *self, const char *prefix); // Probe the supplied object, and report if it looks like a zframe_t. bool zframe_is (void *self); // Self test of this class. void zframe_test (bool verbose); // CLASS: zhash // Create a new, empty hash container zhash_t * zhash_new (void); // Destroy a hash container and all items in it void zhash_destroy (zhash_t **self_p); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. zhash_t * zhash_unpack (zframe_t *frame); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int zhash_insert (zhash_t *self, const char *key, void *item); // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. void zhash_update (zhash_t *self, const char *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void zhash_delete (zhash_t *self, const char *key); // Return the item at the specified key, or null void * zhash_lookup (zhash_t *self, const char *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int zhash_rename (zhash_t *self, const char *old_key, const char *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn); // Return the number of keys/items in the hash table size_t zhash_size (zhash_t *self); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. zhash_t * zhash_dup (zhash_t *self); // Return keys for items in table zlist_t * zhash_keys (zhash_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhash_cursor(). NOTE: do NOT modify the table while iterating. void * zhash_first (zhash_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). To // access the key for this item use zhash_cursor(). NOTE: do NOT modify // the table while iterating. void * zhash_next (zhash_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const char * zhash_cursor (zhash_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void zhash_comment (zhash_t *self, const char *format, ...); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. zframe_t * zhash_pack (zhash_t *self); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int zhash_save (zhash_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int zhash_load (zhash_t *self, const char *filename); // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int zhash_refresh (zhash_t *self); // Set hash for automatic value destruction. Note that this assumes that // values are NULL-terminated strings. Do not use with different types. void zhash_autofree (zhash_t *self); // Self test of this class. void zhash_test (bool verbose); // CLASS: zhashx // Create a new, empty hash container zhashx_t * zhashx_new (void); // Destroy a hash container and all items in it void zhashx_destroy (zhashx_t **self_p); // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. zhashx_t * zhashx_unpack (zframe_t *frame); // Same as unpack but uses a user-defined deserializer function to convert // a longstr back into item format. zhashx_t * zhashx_unpack_own (zframe_t *frame, zhashx_deserializer_fn deserializer); // Insert item into hash table with specified key and item. // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int zhashx_insert (zhashx_t *self, const void *key, void *item); // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. void zhashx_update (zhashx_t *self, const void *key, void *item); // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void zhashx_delete (zhashx_t *self, const void *key); // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. void zhashx_purge (zhashx_t *self); // Return the item at the specified key, or null void * zhashx_lookup (zhashx_t *self, const void *key); // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. Returns 0 if successful, else -1. int zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key); // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn free_fn); // Return the number of keys/items in the hash table size_t zhashx_size (zhashx_t *self); // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. zlistx_t * zhashx_keys (zhashx_t *self); // Return a zlistx_t containing the values for the items in the // table. Uses the duplicator to duplicate all items and sets the // destructor as destructor for the list. zlistx_t * zhashx_values (zhashx_t *self); // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. To access the key for this item // use zhashx_cursor(). NOTE: do NOT modify the table while iterating. void * zhashx_first (zhashx_t *self); // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). To // access the key for this item use zhashx_cursor(). NOTE: do NOT modify // the table while iterating. void * zhashx_next (zhashx_t *self); // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const void * zhashx_cursor (zhashx_t *self); // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void zhashx_comment (zhashx_t *self, const char *format, ...); // Save hash table to a text file in name=value format. Hash values must be // printable strings; keys may not contain '=' character. Returns 0 if OK, // else -1 if a file error occurred. int zhashx_save (zhashx_t *self, const char *filename); // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings; keys may not contain // '=' character. Returns 0 if OK, else -1 if a file was not readable. int zhashx_load (zhashx_t *self, const char *filename); // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int zhashx_refresh (zhashx_t *self); // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. zframe_t * zhashx_pack (zhashx_t *self); // Same as pack but uses a user-defined serializer function to convert items // into longstr. zframe_t * zhashx_pack_own (zhashx_t *self, zhashx_serializer_fn serializer); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. zhashx_t * zhashx_dup (zhashx_t *self); // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. void zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. void zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined deallocator for keys; by default keys are freed // when the hash is destroyed using free(). void zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor); // Set a user-defined duplicator for keys; by default keys are duplicated // using strdup. void zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator); // Set a user-defined comparator for keys; by default keys are // compared using strcmp. // The callback function should return zero (0) on matching // items. void zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator); // Set a user-defined hash function for keys; by default keys are // hashed by a modified Bernstein hashing function. void zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher); // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. zhashx_t * zhashx_dup_v2 (zhashx_t *self); // Self test of this class. void zhashx_test (bool verbose); // CLASS: ziflist // Get a list of network interfaces currently defined on the system ziflist_t * ziflist_new (void); // Destroy a ziflist instance void ziflist_destroy (ziflist_t **self_p); // Reload network interfaces from system void ziflist_reload (ziflist_t *self); // Return the number of network interfaces on system size_t ziflist_size (ziflist_t *self); // Get first network interface, return NULL if there are none const char * ziflist_first (ziflist_t *self); // Get next network interface, return NULL if we hit the last one const char * ziflist_next (ziflist_t *self); // Return the current interface IP address as a printable string const char * ziflist_address (ziflist_t *self); // Return the current interface broadcast address as a printable string const char * ziflist_broadcast (ziflist_t *self); // Return the current interface network mask as a printable string const char * ziflist_netmask (ziflist_t *self); // Return the list of interfaces. void ziflist_print (ziflist_t *self); // Get a list of network interfaces currently defined on the system // Includes IPv6 interfaces ziflist_t * ziflist_new_ipv6 (void); // Reload network interfaces from system, including IPv6 void ziflist_reload_ipv6 (ziflist_t *self); // Return true if the current interface uses IPv6 bool ziflist_is_ipv6 (ziflist_t *self); // Self test of this class. void ziflist_test (bool verbose); // CLASS: zlist // Create a new list container zlist_t * zlist_new (void); // Destroy a list container void zlist_destroy (zlist_t **self_p); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * zlist_first (zlist_t *self); // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. void * zlist_next (zlist_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * zlist_last (zlist_t *self); // Return first item in the list, or null, leaves the cursor void * zlist_head (zlist_t *self); // Return last item in the list, or null, leaves the cursor void * zlist_tail (zlist_t *self); // Return the current item of list. If the list is empty, returns NULL. // Leaves cursor pointing at the current item, or NULL if the list is empty. void * zlist_item (zlist_t *self); // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int zlist_append (zlist_t *self, void *item); // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason (out of memory). Note that if a duplicator has // been set, this method will also duplicate the item. int zlist_push (zlist_t *self, void *item); // Pop the item off the start of the list, if any void * zlist_pop (zlist_t *self); // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. bool zlist_exists (zlist_t *self, void *item); // Remove the specified item from the list if present void zlist_remove (zlist_t *self, void *item); // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. zlist_t * zlist_dup (zlist_t *self); // Purge all items from list void zlist_purge (zlist_t *self); // Return number of items in the list size_t zlist_size (zlist_t *self); // Sort the list. If the compare function is null, sorts the list by // ascending key value using a straight ASCII comparison. If you specify // a compare function, this decides how items are sorted. The sort is not // stable, so may reorder items with the same keys. The algorithm used is // combsort, a compromise between performance and simplicity. void zlist_sort (zlist_t *self, zlist_compare_fn compare); // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. void zlist_autofree (zlist_t *self); // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. void zlist_comparefn (zlist_t *self, zlist_compare_fn fn); // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zlist_freefn (zlist_t *self, void *item, zlist_free_fn fn, bool at_tail); // Self test of this class. void zlist_test (bool verbose); // CLASS: zlistx // Create a new, empty list. zlistx_t * zlistx_new (void); // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. void zlistx_destroy (zlistx_t **self_p); // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void * zlistx_add_start (zlistx_t *self, void *item); // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success, NULL if memory was exhausted. void * zlistx_add_end (zlistx_t *self, void *item); // Return the number of items in the list size_t zlistx_size (zlistx_t *self); // Return first item in the list, or null, leaves the cursor void * zlistx_head (zlistx_t *self); // Return last item in the list, or null, leaves the cursor void * zlistx_tail (zlistx_t *self); // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * zlistx_first (zlistx_t *self); // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). void * zlistx_next (zlistx_t *self); // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). void * zlistx_prev (zlistx_t *self); // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * zlistx_last (zlistx_t *self); // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * zlistx_item (zlistx_t *self); // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * zlistx_cursor (zlistx_t *self); // Returns the item associated with the given list handle, or NULL if passed // in handle is NULL. Asserts that the passed in handle points to a list element. void * zlistx_handle_item (void *handle); // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. void * zlistx_find (zlistx_t *self, void *item); // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. void * zlistx_detach (zlistx_t *self, void *handle); // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. void * zlistx_detach_cur (zlistx_t *self); // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. int zlistx_delete (zlistx_t *self, void *handle); // Move an item to the start of the list, via its handle. void zlistx_move_start (zlistx_t *self, void *handle); // Move an item to the end of the list, via its handle. void zlistx_move_end (zlistx_t *self, void *handle); // Remove all items from the list, and destroy them if the item destructor // is set. void zlistx_purge (zlistx_t *self); // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. void zlistx_sort (zlistx_t *self); // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. void * zlistx_insert (zlistx_t *self, void *item, bool low_value); // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. void zlistx_reorder (zlistx_t *self, void *handle, bool low_value); // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. zlistx_t * zlistx_dup (zlistx_t *self); // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. void zlistx_set_destructor (zlistx_t *self, zlistx_destructor_fn destructor); // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. void zlistx_set_duplicator (zlistx_t *self, zlistx_duplicator_fn duplicator); // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. void zlistx_set_comparator (zlistx_t *self, zlistx_comparator_fn comparator); // Self test of this class. void zlistx_test (bool verbose); // CLASS: zloop // Create a new zloop reactor zloop_t * zloop_new (void); // Destroy a reactor void zloop_destroy (zloop_t **self_p); // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. int zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg); // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. void zloop_reader_end (zloop_t *self, zsock_t *sock); // Configure a registered reader to ignore errors. If you do not set this, // then readers that have errors are removed from the reactor silently. void zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock); // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. int zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg); // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. void zloop_poller_end (zloop_t *self, zmq_pollitem_t *item); // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. void zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item); // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. int zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg); // Cancel a specific timer identified by a specific timer_id (as returned by // zloop_timer). int zloop_timer_end (zloop_t *self, int timer_id); // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. void * zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg); // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. void zloop_ticket_reset (zloop_t *self, void *handle); // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. void zloop_ticket_delete (zloop_t *self, void *handle); // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. void zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay); // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. void zloop_set_max_timers (zloop_t *self, size_t max_timers); // Set verbose tracing of reactor on/off. The default verbose setting is // off (false). void zloop_set_verbose (zloop_t *self, bool verbose); // By default the reactor stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void zloop_set_nonstop (zloop_t *self, bool nonstop); // Start the reactor. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. int zloop_start (zloop_t *self); // Self test of this class. void zloop_test (bool verbose); // CLASS: zmsg // Create a new empty message object zmsg_t * zmsg_new (void); // Destroy a message object and all frames it contains void zmsg_destroy (zmsg_t **self_p); // Receive message from socket, returns zmsg_t object or NULL if the recv // was interrupted. Does a blocking recv. If you want to not block then use // the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input // before receiving. zmsg_t * zmsg_recv (void *source); // Load/append an open file into new message, return the message. // Returns NULL if the message could not be loaded. zmsg_t * zmsg_load (FILE *file); // Decodes a serialized message frame created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the frame was badly formatted or // there was insufficient memory to work. zmsg_t * zmsg_decode (zframe_t *frame); // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. zmsg_t * zmsg_new_signal (byte status); // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int zmsg_send (zmsg_t **self_p, void *dest); // Send message to destination socket as part of a multipart sequence, and // destroy the message after sending it successfully. Note that after a // zmsg_sendm, you must call zmsg_send or another method that sends a final // message part. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). int zmsg_sendm (zmsg_t **self_p, void *dest); // Return size of message, i.e. number of frames (0 or more). size_t zmsg_size (zmsg_t *self); // Return total size of all frames in message. size_t zmsg_content_size (zmsg_t *self); // Return message routing ID, if the message came from a ZMQ_SERVER socket. // Else returns zero. uint32_t zmsg_routing_id (zmsg_t *self); // Set routing ID on message. This is used if/when the message is sent to a // ZMQ_SERVER socket. void zmsg_set_routing_id (zmsg_t *self, uint32_t routing_id); // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. int zmsg_prepend (zmsg_t *self, zframe_t **frame_p); // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Deprecates zmsg_add, which did not nullify the // caller's frame reference. int zmsg_append (zmsg_t *self, zframe_t **frame_p); // Remove first frame from message, if any. Returns frame, or NULL. zframe_t * zmsg_pop (zmsg_t *self); // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. int zmsg_pushmem (zmsg_t *self, const void *data, size_t size); // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. int zmsg_addmem (zmsg_t *self, const void *data, size_t size); // Push string as new frame to front of message. // Returns 0 on success, -1 on error. int zmsg_pushstr (zmsg_t *self, const char *string); // Push string as new frame to end of message. // Returns 0 on success, -1 on error. int zmsg_addstr (zmsg_t *self, const char *string); // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. int zmsg_pushstrf (zmsg_t *self, const char *format, ...); // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. int zmsg_addstrf (zmsg_t *self, const char *format, ...); // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. char * zmsg_popstr (zmsg_t *self); // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. int zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p); // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not successful. zmsg_t * zmsg_popmsg (zmsg_t *self); // Remove specified frame from list, if present. Does not destroy frame. void zmsg_remove (zmsg_t *self, zframe_t *frame); // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. zframe_t * zmsg_first (zmsg_t *self); // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. zframe_t * zmsg_next (zmsg_t *self); // Return the last frame. If there are no frames, returns NULL. zframe_t * zmsg_last (zmsg_t *self); // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. int zmsg_save (zmsg_t *self, FILE *file); // Serialize multipart message to a single message frame. Use this method // to send structured messages across transports that do not support // multipart data. Allocates and returns a new frame containing the // serialized message. To decode a serialized message frame, use // zmsg_decode (). zframe_t * zmsg_encode (zmsg_t *self); // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. zmsg_t * zmsg_dup (zmsg_t *self); // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). void zmsg_print (zmsg_t *self); // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. bool zmsg_eq (zmsg_t *self, zmsg_t *other); // Return signal value, 0 or greater, if message is a signal, -1 if not. int zmsg_signal (zmsg_t *self); // Probe the supplied object, and report if it looks like a zmsg_t. bool zmsg_is (void *self); // Self test of this class. void zmsg_test (bool verbose); // CLASS: zpoller // Create new poller, specifying zero or more readers. The list of // readers ends in a NULL. Each reader can be a zsock_t instance, a // zactor_t instance, a libzmq socket (void *), or a file handle. zpoller_t * zpoller_new (void *reader, ...); // Destroy a poller void zpoller_destroy (zpoller_t **self_p); // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. int zpoller_add (zpoller_t *self, void *reader); // Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader // must have been passed during construction, or in an zpoller_add () call. int zpoller_remove (zpoller_t *self, void *reader); // By default the poller stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void zpoller_set_nonstop (zpoller_t *self, bool nonstop); // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. void * zpoller_wait (zpoller_t *self, int timeout); // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. bool zpoller_expired (zpoller_t *self); // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. bool zpoller_terminated (zpoller_t *self); // Self test of this class. void zpoller_test (bool verbose); // CLASS: zproc // Create a new zproc. // NOTE: On Windows and with libzmq3 and libzmq2 this function // returns NULL. Code needs to be ported there. zproc_t * zproc_new (void); // Destroy zproc, wait until process ends. void zproc_destroy (zproc_t **self_p); // Setup the command line arguments, the first item must be an (absolute) filename // to run. void zproc_set_args (zproc_t *self, zlistx_t *args); // Setup the environment variables for the process. void zproc_set_env (zproc_t *self, zhashx_t *args); // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The writable one is then accessbile via zproc_stdin method. void zproc_set_stdin (zproc_t *self, void *socket); // Connects process stdout with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stdout method. void zproc_set_stdout (zproc_t *self, void *socket); // Connects process stderr with a writable ('@', bind) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc // sockets. The readable one is then accessbile via zproc_stderr method. void zproc_set_stderr (zproc_t *self, void *socket); // Return subprocess stdin writable socket. NULL for // not initialized or external sockets. void * zproc_stdin (zproc_t *self); // Return subprocess stdout readable socket. NULL for // not initialized or external sockets. void * zproc_stdout (zproc_t *self); // Return subprocess stderr readable socket. NULL for // not initialized or external sockets. void * zproc_stderr (zproc_t *self); // Starts the process. int zproc_run (zproc_t *self); // process exit code int zproc_returncode (zproc_t *self); // PID of the process int zproc_pid (zproc_t *self); // return true if process is running, false if not yet started or finished bool zproc_running (zproc_t *self); // wait or poll process status, return return code int zproc_wait (zproc_t *self, bool hang); // return internal actor, usefull for the polling if process died void * zproc_actor (zproc_t *self); // send a signal to the subprocess void zproc_kill (zproc_t *self, int signal); // set verbose mode void zproc_set_verbose (zproc_t *self, bool verbose); // Returns CZMQ version as a single 6-digit integer encoding the major // version (x 10000), the minor version (x 100) and the patch. int zproc_czmq_version (void); // Returns true if the process received a SIGINT or SIGTERM signal. // It is good practice to use this method to exit any infinite loop // processing messages. bool zproc_interrupted (void); // Returns true if the underlying libzmq supports CURVE security. bool zproc_has_curve (void); // Return current host name, for use in public tcp:// endpoints. // If the host name is not resolvable, returns NULL. char * zproc_hostname (void); // Move the current process into the background. The precise effect // depends on the operating system. On POSIX boxes, moves to a specified // working directory (if specified), closes all file handles, reopens // stdin, stdout, and stderr to the null device, and sets the process to // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there // was an error. void zproc_daemonize (const char *workdir); // Drop the process ID into the lockfile, with exclusive lock, and // switch the process to the specified group and/or user. Any of the // arguments may be null, indicating a no-op. Returns 0 on success, // -1 on failure. Note if you combine this with zsys_daemonize, run // after, not before that method, or the lockfile will hold the wrong // process ID. void zproc_run_as (const char *lockfile, const char *group, const char *user); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void zproc_set_io_threads (size_t io_threads); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void zproc_set_max_sockets (size_t max_sockets); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void zproc_set_biface (const char *value); // Return network interface to use for broadcasts, or "" if none was set. const char * zproc_biface (void); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void zproc_set_log_ident (const char *value); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void zproc_set_log_sender (const char *endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void zproc_set_log_system (bool logsystem); // Log error condition - highest priority void zproc_log_error (const char *format, ...); // Log warning condition - high priority void zproc_log_warning (const char *format, ...); // Log normal, but significant, condition - normal priority void zproc_log_notice (const char *format, ...); // Log informational message - low priority void zproc_log_info (const char *format, ...); // Log debug-level message - lowest priority void zproc_log_debug (const char *format, ...); // Self test of this class. void zproc_test (bool verbose); // CLASS: zsock // Create a new socket. Returns the new socket, or NULL if the new socket // could not be created. Note that the symbol zsock_new (and other // constructors/destructors for zsock) are redirected to the *_checked // variant, enabling intelligent socket leak detection. This can have // performance implications if you use a LOT of sockets. To turn off this // redirection behaviour, define ZSOCK_NOCHECK. zsock_t * zsock_new (int type); // Destroy the socket. You must use this for any socket created via the // zsock_new method. void zsock_destroy (zsock_t **self_p); // Create a PUB socket. Default action is bind. zsock_t * zsock_new_pub (const char *endpoint); // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. zsock_t * zsock_new_sub (const char *endpoint, const char *subscribe); // Create a REQ socket. Default action is connect. zsock_t * zsock_new_req (const char *endpoint); // Create a REP socket. Default action is bind. zsock_t * zsock_new_rep (const char *endpoint); // Create a DEALER socket. Default action is connect. zsock_t * zsock_new_dealer (const char *endpoint); // Create a ROUTER socket. Default action is bind. zsock_t * zsock_new_router (const char *endpoint); // Create a PUSH socket. Default action is connect. zsock_t * zsock_new_push (const char *endpoint); // Create a PULL socket. Default action is bind. zsock_t * zsock_new_pull (const char *endpoint); // Create an XPUB socket. Default action is bind. zsock_t * zsock_new_xpub (const char *endpoint); // Create an XSUB socket. Default action is connect. zsock_t * zsock_new_xsub (const char *endpoint); // Create a PAIR socket. Default action is connect. zsock_t * zsock_new_pair (const char *endpoint); // Create a STREAM socket. Default action is connect. zsock_t * zsock_new_stream (const char *endpoint); // Create a SERVER socket. Default action is bind. zsock_t * zsock_new_server (const char *endpoint); // Create a CLIENT socket. Default action is connect. zsock_t * zsock_new_client (const char *endpoint); // Create a RADIO socket. Default action is bind. zsock_t * zsock_new_radio (const char *endpoint); // Create a DISH socket. Default action is connect. zsock_t * zsock_new_dish (const char *endpoint); // Create a GATHER socket. Default action is bind. zsock_t * zsock_new_gather (const char *endpoint); // Create a SCATTER socket. Default action is connect. zsock_t * zsock_new_scatter (const char *endpoint); // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] // bind to random port from 55000 to 55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. int zsock_bind (zsock_t *self, const char *format, ...); // Returns last bound endpoint, if any. const char * zsock_endpoint (zsock_t *self); // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int zsock_unbind (zsock_t *self, const char *format, ...); // Connect a socket to a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid. int zsock_connect (zsock_t *self, const char *format, ...); // Disconnect a socket from a formatted endpoint // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int zsock_disconnect (zsock_t *self, const char *format, ...); // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). int zsock_attach (zsock_t *self, const char *endpoints, bool serverish); // Returns socket type as printable constant string. const char * zsock_type_str (zsock_t *self); // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, size_t (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. int zsock_send (void *self, const char *picture, ...); // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. int zsock_vsend (void *self, const char *picture, va_list argptr); // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // U = zuuid_t * (creates a zuuid with the data) // h = zhashx_t ** (creates zhashx) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. int zsock_recv (void *self, const char *picture, ...); // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. int zsock_vrecv (void *self, const char *picture, va_list argptr); // Send a binary encoded 'picture' message to the socket (or actor). This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations. The pattern argument is a string that defines the // type of each argument. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0-255 chars type = "string" // S char *, 0-2^32-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // u zuuid_t * type = "uuid" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments. Returns 0 if // successful, -1 if sending failed for any reason. int zsock_bsend (void *self, const char *picture, ...); // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. // For types 1, 2, 4 and 8 the caller must allocate the memory itself before // calling zsock_brecv. // For types S, the caller must free the value once finished with it, as // zsock_brecv will allocate the buffer. // For type s, the caller must not free the value as it is stored in a // local cache for performance purposes. // For types c, f, u and m the caller must call the appropriate destructor // depending on the object as zsock_brecv will create new objects. // For type p the caller must coordinate with the sender, as it is just a // pointer value being passed. int zsock_brecv (void *self, const char *picture, ...); // Return socket routing ID if any. This returns 0 if the socket is not // of type ZMQ_SERVER or if no request was already received on it. uint32_t zsock_routing_id (zsock_t *self); // Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. // This will be used when sending messages on the socket via the zsock API. void zsock_set_routing_id (zsock_t *self, uint32_t routing_id); // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. void zsock_set_unbounded (void *self); // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zsock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. int zsock_signal (void *self, byte status); // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. int zsock_wait (void *self); // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. void zsock_flush (void *self); // Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int zsock_join (void *self, const char *group); // Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int zsock_leave (void *self, const char *group); // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. bool zsock_is (void *self); // Probe the supplied reference. If it looks like a zsock_t instance, return // the underlying libzmq socket handle; else if it looks like a file // descriptor, return NULL; else if it looks like a libzmq socket handle, // return the supplied value. Takes a polymorphic socket reference. void * zsock_resolve (void *self); // Get socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. int zsock_heartbeat_ivl (void *self); // Set socket option `heartbeat_ivl`. // Available from libzmq 4.2.0. void zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl); // Get socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. int zsock_heartbeat_ttl (void *self); // Set socket option `heartbeat_ttl`. // Available from libzmq 4.2.0. void zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl); // Get socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. int zsock_heartbeat_timeout (void *self); // Set socket option `heartbeat_timeout`. // Available from libzmq 4.2.0. void zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout); // Get socket option `use_fd`. // Available from libzmq 4.2.0. int zsock_use_fd (void *self); // Set socket option `use_fd`. // Available from libzmq 4.2.0. void zsock_set_use_fd (void *self, int use_fd); // Set socket option `xpub_manual`. // Available from libzmq 4.2.0. void zsock_set_xpub_manual (void *self, int xpub_manual); // Set socket option `xpub_welcome_msg`. // Available from libzmq 4.2.0. void zsock_set_xpub_welcome_msg (void *self, const char *xpub_welcome_msg); // Set socket option `stream_notify`. // Available from libzmq 4.2.0. void zsock_set_stream_notify (void *self, int stream_notify); // Get socket option `invert_matching`. // Available from libzmq 4.2.0. int zsock_invert_matching (void *self); // Set socket option `invert_matching`. // Available from libzmq 4.2.0. void zsock_set_invert_matching (void *self, int invert_matching); // Set socket option `xpub_verboser`. // Available from libzmq 4.2.0. void zsock_set_xpub_verboser (void *self, int xpub_verboser); // Get socket option `connect_timeout`. // Available from libzmq 4.2.0. int zsock_connect_timeout (void *self); // Set socket option `connect_timeout`. // Available from libzmq 4.2.0. void zsock_set_connect_timeout (void *self, int connect_timeout); // Get socket option `tcp_maxrt`. // Available from libzmq 4.2.0. int zsock_tcp_maxrt (void *self); // Set socket option `tcp_maxrt`. // Available from libzmq 4.2.0. void zsock_set_tcp_maxrt (void *self, int tcp_maxrt); // Get socket option `thread_safe`. // Available from libzmq 4.2.0. int zsock_thread_safe (void *self); // Get socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. int zsock_multicast_maxtpdu (void *self); // Set socket option `multicast_maxtpdu`. // Available from libzmq 4.2.0. void zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu); // Get socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. int zsock_vmci_buffer_size (void *self); // Set socket option `vmci_buffer_size`. // Available from libzmq 4.2.0. void zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size); // Get socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. int zsock_vmci_buffer_min_size (void *self); // Set socket option `vmci_buffer_min_size`. // Available from libzmq 4.2.0. void zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size); // Get socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. int zsock_vmci_buffer_max_size (void *self); // Set socket option `vmci_buffer_max_size`. // Available from libzmq 4.2.0. void zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size); // Get socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. int zsock_vmci_connect_timeout (void *self); // Set socket option `vmci_connect_timeout`. // Available from libzmq 4.2.0. void zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout); // Get socket option `tos`. // Available from libzmq 4.1.0. int zsock_tos (void *self); // Set socket option `tos`. // Available from libzmq 4.1.0. void zsock_set_tos (void *self, int tos); // Set socket option `router_handover`. // Available from libzmq 4.1.0. void zsock_set_router_handover (void *self, int router_handover); // Set socket option `connect_rid`. // Available from libzmq 4.1.0. void zsock_set_connect_rid (void *self, const char *connect_rid); // Set socket option `connect_rid` from 32-octet binary // Available from libzmq 4.1.0. void zsock_set_connect_rid_bin (void *self, const byte *connect_rid); // Get socket option `handshake_ivl`. // Available from libzmq 4.1.0. int zsock_handshake_ivl (void *self); // Set socket option `handshake_ivl`. // Available from libzmq 4.1.0. void zsock_set_handshake_ivl (void *self, int handshake_ivl); // Get socket option `socks_proxy`. // Available from libzmq 4.1.0. char * zsock_socks_proxy (void *self); // Set socket option `socks_proxy`. // Available from libzmq 4.1.0. void zsock_set_socks_proxy (void *self, const char *socks_proxy); // Set socket option `xpub_nodrop`. // Available from libzmq 4.1.0. void zsock_set_xpub_nodrop (void *self, int xpub_nodrop); // Set socket option `router_mandatory`. // Available from libzmq 4.0.0. void zsock_set_router_mandatory (void *self, int router_mandatory); // Set socket option `probe_router`. // Available from libzmq 4.0.0. void zsock_set_probe_router (void *self, int probe_router); // Set socket option `req_relaxed`. // Available from libzmq 4.0.0. void zsock_set_req_relaxed (void *self, int req_relaxed); // Set socket option `req_correlate`. // Available from libzmq 4.0.0. void zsock_set_req_correlate (void *self, int req_correlate); // Set socket option `conflate`. // Available from libzmq 4.0.0. void zsock_set_conflate (void *self, int conflate); // Get socket option `zap_domain`. // Available from libzmq 4.0.0. char * zsock_zap_domain (void *self); // Set socket option `zap_domain`. // Available from libzmq 4.0.0. void zsock_set_zap_domain (void *self, const char *zap_domain); // Get socket option `mechanism`. // Available from libzmq 4.0.0. int zsock_mechanism (void *self); // Get socket option `plain_server`. // Available from libzmq 4.0.0. int zsock_plain_server (void *self); // Set socket option `plain_server`. // Available from libzmq 4.0.0. void zsock_set_plain_server (void *self, int plain_server); // Get socket option `plain_username`. // Available from libzmq 4.0.0. char * zsock_plain_username (void *self); // Set socket option `plain_username`. // Available from libzmq 4.0.0. void zsock_set_plain_username (void *self, const char *plain_username); // Get socket option `plain_password`. // Available from libzmq 4.0.0. char * zsock_plain_password (void *self); // Set socket option `plain_password`. // Available from libzmq 4.0.0. void zsock_set_plain_password (void *self, const char *plain_password); // Get socket option `curve_server`. // Available from libzmq 4.0.0. int zsock_curve_server (void *self); // Set socket option `curve_server`. // Available from libzmq 4.0.0. void zsock_set_curve_server (void *self, int curve_server); // Get socket option `curve_publickey`. // Available from libzmq 4.0.0. char * zsock_curve_publickey (void *self); // Set socket option `curve_publickey`. // Available from libzmq 4.0.0. void zsock_set_curve_publickey (void *self, const char *curve_publickey); // Set socket option `curve_publickey` from 32-octet binary // Available from libzmq 4.0.0. void zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey); // Get socket option `curve_secretkey`. // Available from libzmq 4.0.0. char * zsock_curve_secretkey (void *self); // Set socket option `curve_secretkey`. // Available from libzmq 4.0.0. void zsock_set_curve_secretkey (void *self, const char *curve_secretkey); // Set socket option `curve_secretkey` from 32-octet binary // Available from libzmq 4.0.0. void zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey); // Get socket option `curve_serverkey`. // Available from libzmq 4.0.0. char * zsock_curve_serverkey (void *self); // Set socket option `curve_serverkey`. // Available from libzmq 4.0.0. void zsock_set_curve_serverkey (void *self, const char *curve_serverkey); // Set socket option `curve_serverkey` from 32-octet binary // Available from libzmq 4.0.0. void zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey); // Get socket option `gssapi_server`. // Available from libzmq 4.0.0. int zsock_gssapi_server (void *self); // Set socket option `gssapi_server`. // Available from libzmq 4.0.0. void zsock_set_gssapi_server (void *self, int gssapi_server); // Get socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. int zsock_gssapi_plaintext (void *self); // Set socket option `gssapi_plaintext`. // Available from libzmq 4.0.0. void zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext); // Get socket option `gssapi_principal`. // Available from libzmq 4.0.0. char * zsock_gssapi_principal (void *self); // Set socket option `gssapi_principal`. // Available from libzmq 4.0.0. void zsock_set_gssapi_principal (void *self, const char *gssapi_principal); // Get socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. char * zsock_gssapi_service_principal (void *self); // Set socket option `gssapi_service_principal`. // Available from libzmq 4.0.0. void zsock_set_gssapi_service_principal (void *self, const char *gssapi_service_principal); // Get socket option `ipv6`. // Available from libzmq 4.0.0. int zsock_ipv6 (void *self); // Set socket option `ipv6`. // Available from libzmq 4.0.0. void zsock_set_ipv6 (void *self, int ipv6); // Get socket option `immediate`. // Available from libzmq 4.0.0. int zsock_immediate (void *self); // Set socket option `immediate`. // Available from libzmq 4.0.0. void zsock_set_immediate (void *self, int immediate); // Get socket option `sndhwm`. // Available from libzmq 3.0.0. int zsock_sndhwm (void *self); // Set socket option `sndhwm`. // Available from libzmq 3.0.0. void zsock_set_sndhwm (void *self, int sndhwm); // Get socket option `rcvhwm`. // Available from libzmq 3.0.0. int zsock_rcvhwm (void *self); // Set socket option `rcvhwm`. // Available from libzmq 3.0.0. void zsock_set_rcvhwm (void *self, int rcvhwm); // Get socket option `maxmsgsize`. // Available from libzmq 3.0.0. int zsock_maxmsgsize (void *self); // Set socket option `maxmsgsize`. // Available from libzmq 3.0.0. void zsock_set_maxmsgsize (void *self, int maxmsgsize); // Get socket option `multicast_hops`. // Available from libzmq 3.0.0. int zsock_multicast_hops (void *self); // Set socket option `multicast_hops`. // Available from libzmq 3.0.0. void zsock_set_multicast_hops (void *self, int multicast_hops); // Set socket option `xpub_verbose`. // Available from libzmq 3.0.0. void zsock_set_xpub_verbose (void *self, int xpub_verbose); // Get socket option `tcp_keepalive`. // Available from libzmq 3.0.0. int zsock_tcp_keepalive (void *self); // Set socket option `tcp_keepalive`. // Available from libzmq 3.0.0. void zsock_set_tcp_keepalive (void *self, int tcp_keepalive); // Get socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. int zsock_tcp_keepalive_idle (void *self); // Set socket option `tcp_keepalive_idle`. // Available from libzmq 3.0.0. void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle); // Get socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. int zsock_tcp_keepalive_cnt (void *self); // Set socket option `tcp_keepalive_cnt`. // Available from libzmq 3.0.0. void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt); // Get socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. int zsock_tcp_keepalive_intvl (void *self); // Set socket option `tcp_keepalive_intvl`. // Available from libzmq 3.0.0. void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl); // Get socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. char * zsock_tcp_accept_filter (void *self); // Set socket option `tcp_accept_filter`. // Available from libzmq 3.0.0. void zsock_set_tcp_accept_filter (void *self, const char *tcp_accept_filter); // Get socket option `last_endpoint`. // Available from libzmq 3.0.0. char * zsock_last_endpoint (void *self); // Set socket option `router_raw`. // Available from libzmq 3.0.0. void zsock_set_router_raw (void *self, int router_raw); // Get socket option `ipv4only`. // Available from libzmq 3.0.0. int zsock_ipv4only (void *self); // Set socket option `ipv4only`. // Available from libzmq 3.0.0. void zsock_set_ipv4only (void *self, int ipv4only); // Set socket option `delay_attach_on_connect`. // Available from libzmq 3.0.0. void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect); // Get socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. int zsock_hwm (void *self); // Set socket option `hwm`. // Available from libzmq 2.0.0 to 3.0.0. void zsock_set_hwm (void *self, int hwm); // Get socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. int zsock_swap (void *self); // Set socket option `swap`. // Available from libzmq 2.0.0 to 3.0.0. void zsock_set_swap (void *self, int swap); // Get socket option `affinity`. // Available from libzmq 2.0.0. int zsock_affinity (void *self); // Set socket option `affinity`. // Available from libzmq 2.0.0. void zsock_set_affinity (void *self, int affinity); // Get socket option `identity`. // Available from libzmq 2.0.0. char * zsock_identity (void *self); // Set socket option `identity`. // Available from libzmq 2.0.0. void zsock_set_identity (void *self, const char *identity); // Get socket option `rate`. // Available from libzmq 2.0.0. int zsock_rate (void *self); // Set socket option `rate`. // Available from libzmq 2.0.0. void zsock_set_rate (void *self, int rate); // Get socket option `recovery_ivl`. // Available from libzmq 2.0.0. int zsock_recovery_ivl (void *self); // Set socket option `recovery_ivl`. // Available from libzmq 2.0.0. void zsock_set_recovery_ivl (void *self, int recovery_ivl); // Get socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. int zsock_recovery_ivl_msec (void *self); // Set socket option `recovery_ivl_msec`. // Available from libzmq 2.0.0 to 3.0.0. void zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec); // Get socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. int zsock_mcast_loop (void *self); // Set socket option `mcast_loop`. // Available from libzmq 2.0.0 to 3.0.0. void zsock_set_mcast_loop (void *self, int mcast_loop); // Get socket option `rcvtimeo`. // Available from libzmq 2.2.0. int zsock_rcvtimeo (void *self); // Set socket option `rcvtimeo`. // Available from libzmq 2.2.0. void zsock_set_rcvtimeo (void *self, int rcvtimeo); // Get socket option `sndtimeo`. // Available from libzmq 2.2.0. int zsock_sndtimeo (void *self); // Set socket option `sndtimeo`. // Available from libzmq 2.2.0. void zsock_set_sndtimeo (void *self, int sndtimeo); // Get socket option `sndbuf`. // Available from libzmq 2.0.0. int zsock_sndbuf (void *self); // Set socket option `sndbuf`. // Available from libzmq 2.0.0. void zsock_set_sndbuf (void *self, int sndbuf); // Get socket option `rcvbuf`. // Available from libzmq 2.0.0. int zsock_rcvbuf (void *self); // Set socket option `rcvbuf`. // Available from libzmq 2.0.0. void zsock_set_rcvbuf (void *self, int rcvbuf); // Get socket option `linger`. // Available from libzmq 2.0.0. int zsock_linger (void *self); // Set socket option `linger`. // Available from libzmq 2.0.0. void zsock_set_linger (void *self, int linger); // Get socket option `reconnect_ivl`. // Available from libzmq 2.0.0. int zsock_reconnect_ivl (void *self); // Set socket option `reconnect_ivl`. // Available from libzmq 2.0.0. void zsock_set_reconnect_ivl (void *self, int reconnect_ivl); // Get socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. int zsock_reconnect_ivl_max (void *self); // Set socket option `reconnect_ivl_max`. // Available from libzmq 2.0.0. void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max); // Get socket option `backlog`. // Available from libzmq 2.0.0. int zsock_backlog (void *self); // Set socket option `backlog`. // Available from libzmq 2.0.0. void zsock_set_backlog (void *self, int backlog); // Set socket option `subscribe`. // Available from libzmq 2.0.0. void zsock_set_subscribe (void *self, const char *subscribe); // Set socket option `unsubscribe`. // Available from libzmq 2.0.0. void zsock_set_unsubscribe (void *self, const char *unsubscribe); // Get socket option `type`. // Available from libzmq 2.0.0. int zsock_type (void *self); // Get socket option `rcvmore`. // Available from libzmq 2.0.0. int zsock_rcvmore (void *self); // Get socket option `fd`. // Available from libzmq 2.0.0. SOCKET zsock_fd (void *self); // Get socket option `events`. // Available from libzmq 2.0.0. int zsock_events (void *self); // Self test of this class. void zsock_test (bool verbose); // CLASS: zstr // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. char * zstr_recv (void *source); // Receive a series of strings (until NULL) from multipart data. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL. // Returns -1 if the message could not be read, else returns the // number of strings filled, zero or more. Free each returned string // using zstr_free(). If not enough strings are provided, remaining // multipart frames in the message are dropped. int zstr_recvx (void *source, char **string_p, ...); // De-compress and receive C string from socket, received as a message // with two frames: size of the uncompressed string, and the string itself. // Caller must free returned string using zstr_free(). Returns NULL if the // context is being terminated or the process was interrupted. char * zstr_recv_compress (void *source); // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". int zstr_send (void *dest, const char *string); // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. int zstr_sendm (void *dest, const char *string); // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). int zstr_sendf (void *dest, const char *format, ...); // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. int zstr_sendfm (void *dest, const char *format, ...); // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or -1 on error. int zstr_sendx (void *dest, const char *string, ...); // Compress and send a C string to a socket, as a message with two frames: // size of the uncompressed string, and the string itself. The string is // sent without trailing null byte; to read this you can use // zstr_recv_compress, or a similar method that de-compresses and adds a // null terminator on the received string. int zstr_send_compress (void *dest, const char *string); // Compress and send a C string to a socket, as zstr_send_compress(), // with a MORE flag, so that you can send further strings in the same // multi-part message. int zstr_sendm_compress (void *dest, const char *string); // Accepts a void pointer and returns a fresh character string. If source // is null, returns an empty string. char * zstr_str (void *source); // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. void zstr_free (char **string_p); // Self test of this class. void zstr_test (bool verbose); // CLASS: zsys // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. void * zsys_init (void); // Optionally shut down the CZMQ zsys layer; this normally happens automatically // when the process exits; however this call lets you force a shutdown // earlier, avoiding any potential problems with atexit() ordering, especially // with Windows dlls. void zsys_shutdown (void); // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. // *** This is for CZMQ internal use only and may change arbitrarily *** void * zsys_socket (int type, const char *filename, size_t line_nbr); // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). // *** This is for CZMQ internal use only and may change arbitrarily *** int zsys_close (void *handle, const char *filename, size_t line_nbr); // Return ZMQ socket name for socket type // *** This is for CZMQ internal use only and may change arbitrarily *** char * zsys_sockname (int socktype); // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. zsock_t * zsys_create_pipe (zsock_t **backend_p); // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. void zsys_handler_set (zsys_handler_fn *handler_fn); // Reset interrupt handler, call this at exit if needed void zsys_handler_reset (void); // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. // Can be supressed by ZSYS_SIGHANDLER=false // *** This is for CZMQ internal use only and may change arbitrarily *** void zsys_catch_interrupts (void); // Return 1 if file exists, else zero bool zsys_file_exists (const char *filename); // Return file modification time. Returns 0 if the file does not exist. time_t zsys_file_modified (const char *filename); // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. int zsys_file_mode (const char *filename); // Delete file. Does not complain if the file is absent int zsys_file_delete (const char *filename); // Check if file is 'stable' bool zsys_file_stable (const char *filename); // Create a file path if it doesn't exist. The file path is treated as // printf format. int zsys_dir_create (const char *pathname, ...); // Remove a file path if empty; the pathname is treated as printf format. int zsys_dir_delete (const char *pathname, ...); // Move to a specified working directory. Returns 0 if OK, -1 if this failed. int zsys_dir_change (const char *pathname); // Set private file creation mode; all files created from here will be // readable/writable by the owner only. void zsys_file_mode_private (void); // Reset default file creation mode; all files created from here will use // process file mode defaults. void zsys_file_mode_default (void); // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. 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(). char * zsys_sprintf (const char *format, ...); // Format a string with a va_list argument, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). char * zsys_vprintf (const char *format, va_list argptr); // Create UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. // *** This is for CZMQ internal use only and may change arbitrarily *** SOCKET zsys_udp_new (bool routable); // Close a UDP socket // *** This is for CZMQ internal use only and may change arbitrarily *** int zsys_udp_close (SOCKET handle); // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) // *** This is for CZMQ internal use only and may change arbitrarily *** int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address, int addrlen); // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or // NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. // *** This is for CZMQ internal use only and may change arbitrarily *** zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername, int peerlen); // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. // *** This is for CZMQ internal use only and may change arbitrarily *** void zsys_socket_error (const char *reason); // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. char * zsys_hostname (void); // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. int zsys_daemonize (const char *workdir); // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. int zsys_run_as (const char *lockfile, const char *group, const char *user); // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. bool zsys_has_curve (void); // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_io_threads (size_t io_threads); // Configure the scheduling policy of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY // is defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_thread_sched_policy (int policy); // Configure the scheduling priority of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_PRIORITY is // defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_thread_priority (int priority); // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void zsys_set_max_sockets (size_t max_sockets); // Return maximum number of ZeroMQ sockets that the system will support. size_t zsys_socket_limit (void); // Configure the maximum allowed size of a message sent. // The default is INT_MAX. void zsys_set_max_msgsz (int max_msgsz); // Return maximum message size. int zsys_max_msgsz (void); // Configure the threshold value of filesystem object age per st_mtime // that should elapse until we consider that object "stable" at the // current zclock_time() moment. // The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c // which generally depends on host OS, with fallback value of 5000. void zsys_set_file_stable_age_msec (int64_t file_stable_age_msec); // Return current threshold value of file stable age in msec. // This can be used in code that chooses to wait for this timeout // before testing if a filesystem object is "stable" or not. int64_t zsys_file_stable_age_msec (void); // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. void zsys_set_linger (size_t linger); // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void zsys_set_sndhwm (size_t sndhwm); // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void zsys_set_rcvhwm (size_t rcvhwm); // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. void zsys_set_pipehwm (size_t pipehwm); // Return the HWM for zactor internal pipes. size_t zsys_pipehwm (void); // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. void zsys_set_ipv6 (int ipv6); // Return use of IPv6 for zsock instances. int zsys_ipv6 (void); // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void zsys_set_interface (const char *value); // Return network interface to use for broadcasts, or "" if none was set. const char * zsys_interface (void); // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses // on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, // use that as the default IPv6 address. void zsys_set_ipv6_address (const char *value); // Return IPv6 address to use for zbeacon reception, or "" if none was set. const char * zsys_ipv6_address (void); // Set IPv6 milticast address to use for sending zbeacon messages. This needs // to be set if IPv6 is enabled. If the environment variable // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast // address. void zsys_set_ipv6_mcast_address (const char *value); // Return IPv6 multicast address to use for sending zbeacon, or "" if none was // set. const char * zsys_ipv6_mcast_address (void); // Configure the automatic use of pre-allocated FDs when creating new sockets. // If 0 (default), nothing will happen. Else, when a new socket is bound, the // system API will be used to check if an existing pre-allocated FD with a // matching port (if TCP) or path (if IPC) exists, and if it does it will be // set via the ZMQ_USE_FD socket option so that the library will use it // instead of creating a new socket. void zsys_set_auto_use_fd (int auto_use_fd); // Return use of automatic pre-allocated FDs for zsock instances. int zsys_auto_use_fd (void); // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void zsys_set_logident (const char *value); // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). void zsys_set_logstream (FILE *stream); // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void zsys_set_logsender (const char *endpoint); // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void zsys_set_logsystem (bool logsystem); // Log error condition - highest priority void zsys_error (const char *format, ...); // Log warning condition - high priority void zsys_warning (const char *format, ...); // Log normal, but significant, condition - normal priority void zsys_notice (const char *format, ...); // Log informational message - low priority void zsys_info (const char *format, ...); // Log debug-level message - lowest priority void zsys_debug (const char *format, ...); // Self test of this class. void zsys_test (bool verbose); // CLASS: ztimerset // Create new timer set. ztimerset_t * ztimerset_new (void); // Destroy a timer set void ztimerset_destroy (ztimerset_t **self_p); // Add a timer to the set. Returns timer id if OK, -1 on failure. int ztimerset_add (ztimerset_t *self, size_t interval, ztimerset_fn handler, void *arg); // Cancel a timer. Returns 0 if OK, -1 on failure. int ztimerset_cancel (ztimerset_t *self, int timer_id); // Set timer interval. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int ztimerset_set_interval (ztimerset_t *self, int timer_id, size_t interval); // Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int ztimerset_reset (ztimerset_t *self, int timer_id); // Return the time until the next interval. // Should be used as timeout parameter for the zpoller wait method. // The timeout is in msec. int ztimerset_timeout (ztimerset_t *self); // Invoke callback function of all timers which their interval has elapsed. // Should be call after zpoller wait method. // Returns 0 if OK, -1 on failure. int ztimerset_execute (ztimerset_t *self); // Self test of this class. void ztimerset_test (bool verbose); // CLASS: ztrie // Creates a new ztrie. ztrie_t * ztrie_new (char delimiter); // Destroy the ztrie. void ztrie_destroy (ztrie_t **self_p); // Inserts a new route into the tree and attaches the data. Returns -1 // if the route already exists, otherwise 0. This method takes ownership of // the provided data if a destroy_data_fn is provided. int ztrie_insert_route (ztrie_t *self, const char *path, void *data, ztrie_destroy_data_fn destroy_data_fn); // Removes a route from the trie and destroys its data. Returns -1 if the // route does not exists, otherwise 0. // the start of the list call zlist_first (). Advances the cursor. int ztrie_remove_route (ztrie_t *self, const char *path); // Returns true if the path matches a route in the tree, otherwise false. bool ztrie_matches (ztrie_t *self, const char *path); // Returns the data of a matched route from last ztrie_matches. If the path // did not match, returns NULL. Do not delete the data as it's owned by // ztrie. void * ztrie_hit_data (ztrie_t *self); // Returns the count of parameters that a matched route has. size_t ztrie_hit_parameter_count (ztrie_t *self); // Returns the parameters of a matched route with named regexes from last // ztrie_matches. If the path did not match or the route did not contain any // named regexes, returns NULL. zhashx_t * ztrie_hit_parameters (ztrie_t *self); // Returns the asterisk matched part of a route, if there has been no match // or no asterisk match, returns NULL. const char * ztrie_hit_asterisk_match (ztrie_t *self); // Print the trie void ztrie_print (ztrie_t *self); // Self test of this class. void ztrie_test (bool verbose); // CLASS: zuuid // Create a new UUID object. zuuid_t * zuuid_new (void); // Destroy a specified UUID object. void zuuid_destroy (zuuid_t **self_p); // Create UUID object from supplied ZUUID_LEN-octet value. zuuid_t * zuuid_new_from (const byte *source); // Set UUID to new supplied ZUUID_LEN-octet value. void zuuid_set (zuuid_t *self, const byte *source); // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. int zuuid_set_str (zuuid_t *self, const char *source); // Return UUID binary data. const byte * zuuid_data (zuuid_t *self); // Return UUID binary size size_t zuuid_size (zuuid_t *self); // Returns UUID as string const char * zuuid_str (zuuid_t *self); // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier const char * zuuid_str_canonical (zuuid_t *self); // Store UUID blob in target array void zuuid_export (zuuid_t *self, byte *target); // Check if UUID is same as supplied value bool zuuid_eq (zuuid_t *self, const byte *compare); // Check if UUID is different from supplied value bool zuuid_neq (zuuid_t *self, const byte *compare); // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. zuuid_t * zuuid_dup (zuuid_t *self); // Self test of this class. void zuuid_test (bool verbose); ''') czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zcertstore.py0000664000372000037200000000657413222211156024163 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zcertstore(object): """ work with CURVE security certificate stores """ def __init__(self, location): """ Create a new certificate store from a disk directory, loading and indexing all certificates in that location. The directory itself may be absent, and created later, or modified at any time. The certificate store is automatically refreshed on any zcertstore_lookup() call. If the location is specified as NULL, creates a pure-memory store, which you can work with by inserting certificates at runtime. """ p = utils.lib.zcertstore_new(utils.to_bytes(location)) if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zcertstore_destroy_py) def set_loader(self, loader, destructor, state): """ Override the default disk loader with a custom loader fn. """ utils.lib.zcertstore_set_loader(self._p, loader, destructor, state) def lookup(self, public_key): """ Look up certificate by public key, returns zcert_t object if found, else returns NULL. The public key is provided in Z85 text format. """ return utils.lib.zcertstore_lookup(self._p, utils.to_bytes(public_key)) def insert(self, cert_p): """ Insert certificate into certificate store in memory. Note that this does not save the certificate to disk. To do that, use zcert_save() directly on the certificate. Takes ownership of zcert_t object. """ utils.lib.zcertstore_insert(self._p, cert_p._p) def empty(self): """ Empty certificate hashtable. This wrapper exists to be friendly to bindings, which don't usually have access to struct internals. """ utils.lib.zcertstore_empty(self._p) def print_py(self): """ Print list of certificates in store to logging facility """ utils.lib.zcertstore_print(self._p) def certs(self): """ Return a list of all the certificates in the store. The caller takes ownership of the zlistx_t object and is responsible for destroying it. The caller does not take ownership of the zcert_t objects. """ return utils.lib.zcertstore_certs(self._p) def test(verbose): """ Self test of this class """ utils.lib.zcertstore_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zsys.py0000664000372000037200000005131713222211156022762 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zsys(object): """ """ def init(): """ Initialize CZMQ zsys layer; this happens automatically when you create a socket or an actor; however this call lets you force initialization earlier, so e.g. logging is properly set-up before you start working. Not threadsafe, so call only from main thread. Safe to call multiple times. Returns global CZMQ context. """ return utils.lib.zsys_init() def shutdown(): """ Optionally shut down the CZMQ zsys layer; this normally happens automatically when the process exits; however this call lets you force a shutdown earlier, avoiding any potential problems with atexit() ordering, especially with Windows dlls. """ utils.lib.zsys_shutdown() def socket(type, filename, line_nbr): """ Get a new ZMQ socket, automagically creating a ZMQ context if this is the first time. Caller is responsible for destroying the ZMQ socket before process exits, to avoid a ZMQ deadlock. Note: you should not use this method in CZMQ apps, use zsock_new() instead. *** This is for CZMQ internal use only and may change arbitrarily *** """ return utils.lib.zsys_socket(type, utils.to_bytes(filename), line_nbr) def close(handle, filename, line_nbr): """ Destroy/close a ZMQ socket. You should call this for every socket you create using zsys_socket(). *** This is for CZMQ internal use only and may change arbitrarily *** """ return utils.lib.zsys_close(handle._p, utils.to_bytes(filename), line_nbr) def sockname(socktype): """ Return ZMQ socket name for socket type *** This is for CZMQ internal use only and may change arbitrarily *** """ return utils.lib.zsys_sockname(socktype) def create_pipe(backend_p): """ Create a pipe, which consists of two PAIR sockets connected over inproc. The pipe is configured to use the zsys_pipehwm setting. Returns the frontend socket successful, NULL if failed. """ return utils.lib.zsys_create_pipe(backend_p._p) def handler_set(handler_fn): """ Set interrupt handler; this saves the default handlers so that a zsys_handler_reset () can restore them. If you call this multiple times then the last handler will take affect. If handler_fn is NULL, disables default SIGINT/SIGTERM handling in CZMQ. """ utils.lib.zsys_handler_set(handler_fn) def handler_reset(): """ Reset interrupt handler, call this at exit if needed """ utils.lib.zsys_handler_reset() def catch_interrupts(): """ Set default interrupt handler, so Ctrl-C or SIGTERM will set zsys_interrupted. Idempotent; safe to call multiple times. Can be supressed by ZSYS_SIGHANDLER=false *** This is for CZMQ internal use only and may change arbitrarily *** """ utils.lib.zsys_catch_interrupts() def file_exists(filename): """ Return 1 if file exists, else zero """ return utils.lib.zsys_file_exists(utils.to_bytes(filename)) def file_modified(filename): """ Return file modification time. Returns 0 if the file does not exist. """ return utils.lib.zsys_file_modified(utils.to_bytes(filename)) def file_mode(filename): """ Return file mode; provides at least support for the POSIX S_ISREG(m) and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. Returns a mode_t cast to int, or -1 in case of error. """ return utils.lib.zsys_file_mode(utils.to_bytes(filename)) def file_delete(filename): """ Delete file. Does not complain if the file is absent """ return utils.lib.zsys_file_delete(utils.to_bytes(filename)) def file_stable(filename): """ Check if file is 'stable' """ return utils.lib.zsys_file_stable(utils.to_bytes(filename)) def dir_create(pathname, ): """ Create a file path if it doesn't exist. The file path is treated as printf format. """ return utils.lib.zsys_dir_create(utils.to_bytes(pathname), ) def dir_delete(pathname, ): """ Remove a file path if empty; the pathname is treated as printf format. """ return utils.lib.zsys_dir_delete(utils.to_bytes(pathname), ) def dir_change(pathname): """ Move to a specified working directory. Returns 0 if OK, -1 if this failed. """ return utils.lib.zsys_dir_change(utils.to_bytes(pathname)) def file_mode_private(): """ Set private file creation mode; all files created from here will be readable/writable by the owner only. """ utils.lib.zsys_file_mode_private() def file_mode_default(): """ Reset default file creation mode; all files created from here will use process file mode defaults. """ utils.lib.zsys_file_mode_default() def version(major, minor, patch): """ Return the CZMQ version for run-time API detection; returns version number into provided fields, providing reference isn't null in each case. """ utils.lib.zsys_version(major, minor, patch) def sprintf(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(). """ return utils.lib.zsys_sprintf(utils.to_bytes(format), ) def vprintf(format, argptr): """ Format a string with a va_list argument, returning a freshly allocated buffer. If there was insufficient memory, returns NULL. Free the returned string using zstr_free(). """ return utils.lib.zsys_vprintf(utils.to_bytes(format), argptr._p) def udp_new(routable): """ Create UDP beacon socket; if the routable option is true, uses multicast (not yet implemented), else uses broadcast. This method and related ones might _eventually_ be moved to a zudp class. *** This is for CZMQ internal use only and may change arbitrarily *** """ return utils.lib.zsys_udp_new(routable) def udp_close(handle): """ Close a UDP socket *** This is for CZMQ internal use only and may change arbitrarily *** """ return utils.lib.zsys_udp_close(handle._p) def udp_send(udpsock, frame, address, addrlen): """ Send zframe to UDP socket, return -1 if sending failed due to interface having disappeared (happens easily with WiFi) *** This is for CZMQ internal use only and may change arbitrarily *** """ return utils.lib.zsys_udp_send(udpsock._p, frame._p, address._p, addrlen) def udp_recv(udpsock, peername, peerlen): """ Receive zframe from UDP socket, and set address of peer that sent it The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. *** This is for CZMQ internal use only and may change arbitrarily *** """ return utils.lib.zsys_udp_recv(udpsock._p, utils.to_bytes(peername), peerlen) def socket_error(reason): """ Handle an I/O error on some socket operation; will report and die on fatal errors, and continue silently on "try again" errors. *** This is for CZMQ internal use only and may change arbitrarily *** """ utils.lib.zsys_socket_error(utils.to_bytes(reason)) def hostname(): """ Return current host name, for use in public tcp:// endpoints. Caller gets a freshly allocated string, should free it using zstr_free(). If the host name is not resolvable, returns NULL. """ return utils.lib.zsys_hostname() def daemonize(workdir): """ Move the current process into the background. The precise effect depends on the operating system. On POSIX boxes, moves to a specified working directory (if specified), closes all file handles, reopens stdin, stdout, and stderr to the null device, and sets the process to ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there was an error. """ return utils.lib.zsys_daemonize(utils.to_bytes(workdir)) def run_as(lockfile, group, user): """ Drop the process ID into the lockfile, with exclusive lock, and switch the process to the specified group and/or user. Any of the arguments may be null, indicating a no-op. Returns 0 on success, -1 on failure. Note if you combine this with zsys_daemonize, run after, not before that method, or the lockfile will hold the wrong process ID. """ return utils.lib.zsys_run_as(utils.to_bytes(lockfile), utils.to_bytes(group), utils.to_bytes(user)) def has_curve(): """ Returns true if the underlying libzmq supports CURVE security. Uses a heuristic probe according to the version of libzmq being used. """ return utils.lib.zsys_has_curve() def set_io_threads(io_threads): """ Configure the number of I/O threads that ZeroMQ will use. A good rule of thumb is one thread per gigabit of traffic in or out. The default is 1, sufficient for most applications. If the environment variable ZSYS_IO_THREADS is defined, that provides the default. Note that this method is valid only before any socket is created. """ utils.lib.zsys_set_io_threads(io_threads) def set_thread_sched_policy(policy): """ Configure the scheduling policy of the ZMQ context thread pool. Not available on Windows. See the sched_setscheduler man page or sched.h for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY is defined, that provides the default. Note that this method is valid only before any socket is created. """ utils.lib.zsys_set_thread_sched_policy(policy) def set_thread_priority(priority): """ Configure the scheduling priority of the ZMQ context thread pool. Not available on Windows. See the sched_setscheduler man page or sched.h for more information. If the environment variable ZSYS_THREAD_PRIORITY is defined, that provides the default. Note that this method is valid only before any socket is created. """ utils.lib.zsys_set_thread_priority(priority) def set_max_sockets(max_sockets): """ Configure the number of sockets that ZeroMQ will allow. The default is 1024. The actual limit depends on the system, and you can query it by using zsys_socket_limit (). A value of zero means "maximum". Note that this method is valid only before any socket is created. """ utils.lib.zsys_set_max_sockets(max_sockets) def socket_limit(): """ Return maximum number of ZeroMQ sockets that the system will support. """ return utils.lib.zsys_socket_limit() def set_max_msgsz(max_msgsz): """ Configure the maximum allowed size of a message sent. The default is INT_MAX. """ utils.lib.zsys_set_max_msgsz(max_msgsz) def max_msgsz(): """ Return maximum message size. """ return utils.lib.zsys_max_msgsz() def set_file_stable_age_msec(file_stable_age_msec): """ Configure the threshold value of filesystem object age per st_mtime that should elapse until we consider that object "stable" at the current zclock_time() moment. The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c which generally depends on host OS, with fallback value of 5000. """ utils.lib.zsys_set_file_stable_age_msec(file_stable_age_msec._p) def file_stable_age_msec(): """ Return current threshold value of file stable age in msec. This can be used in code that chooses to wait for this timeout before testing if a filesystem object is "stable" or not. """ return utils.lib.zsys_file_stable_age_msec() def set_linger(linger): """ Configure the default linger timeout in msecs for new zsock instances. You can also set this separately on each zsock_t instance. The default linger time is zero, i.e. any pending messages will be dropped. If the environment variable ZSYS_LINGER is defined, that provides the default. Note that process exit will typically be delayed by the linger time. """ utils.lib.zsys_set_linger(linger) def set_sndhwm(sndhwm): """ Configure the default outgoing pipe limit (HWM) for new zsock instances. You can also set this separately on each zsock_t instance. The default HWM is 1,000, on all versions of ZeroMQ. If the environment variable ZSYS_SNDHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. """ utils.lib.zsys_set_sndhwm(sndhwm) def set_rcvhwm(rcvhwm): """ Configure the default incoming pipe limit (HWM) for new zsock instances. You can also set this separately on each zsock_t instance. The default HWM is 1,000, on all versions of ZeroMQ. If the environment variable ZSYS_RCVHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. """ utils.lib.zsys_set_rcvhwm(rcvhwm) def set_pipehwm(pipehwm): """ Configure the default HWM for zactor internal pipes; this is set on both ends of the pipe, for outgoing messages only (sndhwm). The default HWM is 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. """ utils.lib.zsys_set_pipehwm(pipehwm) def pipehwm(): """ Return the HWM for zactor internal pipes. """ return utils.lib.zsys_pipehwm() def set_ipv6(ipv6): """ Configure use of IPv6 for new zsock instances. By default sockets accept and make only IPv4 connections. When you enable IPv6, sockets will accept and connect to both IPv4 and IPv6 peers. You can override the setting on each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the default. Note: has no effect on ZMQ v2. """ utils.lib.zsys_set_ipv6(ipv6) def ipv6(): """ Return use of IPv6 for zsock instances. """ return utils.lib.zsys_ipv6() def set_interface(value): """ Set network interface name to use for broadcasts, particularly zbeacon. This lets the interface be configured for test environments where required. For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is the default when there is no specified interface. If the environment variable ZSYS_INTERFACE is set, use that as the default interface name. Setting the interface to "*" means "use all available interfaces". """ utils.lib.zsys_set_interface(utils.to_bytes(value)) def interface(): """ Return network interface to use for broadcasts, or "" if none was set. """ return utils.lib.zsys_interface() def set_ipv6_address(value): """ Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. This needs to be set IPv6 is enabled as IPv6 can have multiple addresses on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, use that as the default IPv6 address. """ utils.lib.zsys_set_ipv6_address(utils.to_bytes(value)) def ipv6_address(): """ Return IPv6 address to use for zbeacon reception, or "" if none was set. """ return utils.lib.zsys_ipv6_address() def set_ipv6_mcast_address(value): """ Set IPv6 milticast address to use for sending zbeacon messages. This needs to be set if IPv6 is enabled. If the environment variable ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast address. """ utils.lib.zsys_set_ipv6_mcast_address(utils.to_bytes(value)) def ipv6_mcast_address(): """ Return IPv6 multicast address to use for sending zbeacon, or "" if none was set. """ return utils.lib.zsys_ipv6_mcast_address() def set_auto_use_fd(auto_use_fd): """ Configure the automatic use of pre-allocated FDs when creating new sockets. If 0 (default), nothing will happen. Else, when a new socket is bound, the system API will be used to check if an existing pre-allocated FD with a matching port (if TCP) or path (if IPC) exists, and if it does it will be set via the ZMQ_USE_FD socket option so that the library will use it instead of creating a new socket. """ utils.lib.zsys_set_auto_use_fd(auto_use_fd) def auto_use_fd(): """ Return use of automatic pre-allocated FDs for zsock instances. """ return utils.lib.zsys_auto_use_fd() def set_logident(value): """ Set log identity, which is a string that prefixes all log messages sent by this process. The log identity defaults to the environment variable ZSYS_LOGIDENT, if that is set. """ utils.lib.zsys_set_logident(utils.to_bytes(value)) def set_logstream(stream): """ Set stream to receive log traffic. By default, log traffic is sent to stdout. If you set the stream to NULL, no stream will receive the log traffic (it may still be sent to the system facility). """ utils.lib.zsys_set_logstream(stream) def set_logsender(endpoint): """ Sends log output to a PUB socket bound to the specified endpoint. To collect such log output, create a SUB socket, subscribe to the traffic you care about, and connect to the endpoint. Log traffic is sent as a single string frame, in the same format as when sent to stdout. The log system supports a single sender; multiple calls to this method will bind the same sender to multiple endpoints. To disable the sender, call this method with a null argument. """ utils.lib.zsys_set_logsender(utils.to_bytes(endpoint)) def set_logsystem(logsystem): """ Enable or disable logging to the system facility (syslog on POSIX boxes, event log on Windows). By default this is disabled. """ utils.lib.zsys_set_logsystem(logsystem) def error(format, ): """ Log error condition - highest priority """ utils.lib.zsys_error(utils.to_bytes(format), ) def warning(format, ): """ Log warning condition - high priority """ utils.lib.zsys_warning(utils.to_bytes(format), ) def notice(format, ): """ Log normal, but significant, condition - normal priority """ utils.lib.zsys_notice(utils.to_bytes(format), ) def info(format, ): """ Log informational message - low priority """ utils.lib.zsys_info(utils.to_bytes(format), ) def debug(format, ): """ Log debug-level message - lowest priority """ utils.lib.zsys_debug(utils.to_bytes(format), ) def test(verbose): """ Self test of this class. """ utils.lib.zsys_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Ztrie.py0000664000372000037200000000662713222211156023113 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Ztrie(object): """ simple trie for tokenizable strings """ def __init__(self, delimiter): """ Creates a new ztrie. """ p = utils.lib.ztrie_new(delimiter._p) if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.ztrie_destroy_py) def insert_route(self, path, data, destroy_data_fn): """ Inserts a new route into the tree and attaches the data. Returns -1 if the route already exists, otherwise 0. This method takes ownership of the provided data if a destroy_data_fn is provided. """ return utils.lib.ztrie_insert_route(self._p, utils.to_bytes(path), data._p, destroy_data_fn) def remove_route(self, path): """ Removes a route from the trie and destroys its data. Returns -1 if the route does not exists, otherwise 0. the start of the list call zlist_first (). Advances the cursor. """ return utils.lib.ztrie_remove_route(self._p, utils.to_bytes(path)) def matches(self, path): """ Returns true if the path matches a route in the tree, otherwise false. """ return utils.lib.ztrie_matches(self._p, utils.to_bytes(path)) def hit_data(self): """ Returns the data of a matched route from last ztrie_matches. If the path did not match, returns NULL. Do not delete the data as it's owned by ztrie. """ return utils.lib.ztrie_hit_data(self._p) def hit_parameter_count(self): """ Returns the count of parameters that a matched route has. """ return utils.lib.ztrie_hit_parameter_count(self._p) def hit_parameters(self): """ Returns the parameters of a matched route with named regexes from last ztrie_matches. If the path did not match or the route did not contain any named regexes, returns NULL. """ return utils.lib.ztrie_hit_parameters(self._p) def hit_asterisk_match(self): """ Returns the asterisk matched part of a route, if there has been no match or no asterisk match, returns NULL. """ return utils.lib.ztrie_hit_asterisk_match(self._p) def print_py(self): """ Print the trie """ utils.lib.ztrie_print(self._p) def test(verbose): """ Self test of this class. """ utils.lib.ztrie_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zproc.py0000664000372000037200000002373213222211156023107 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zproc(object): """ process configuration and status """ def __init__(self): """ Create a new zproc. NOTE: On Windows and with libzmq3 and libzmq2 this function returns NULL. Code needs to be ported there. """ p = utils.lib.zproc_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zproc_destroy_py) def set_args(self, args): """ Setup the command line arguments, the first item must be an (absolute) filename to run. """ utils.lib.zproc_set_args(self._p, args._p) def set_env(self, args): """ Setup the environment variables for the process. """ utils.lib.zproc_set_env(self._p, args._p) def set_stdin(self, socket): """ Connects process stdin with a readable ('>', connect) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The writable one is then accessbile via zproc_stdin method. """ utils.lib.zproc_set_stdin(self._p, socket._p) def set_stdout(self, socket): """ Connects process stdout with a writable ('@', bind) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The readable one is then accessbile via zproc_stdout method. """ utils.lib.zproc_set_stdout(self._p, socket._p) def set_stderr(self, socket): """ Connects process stderr with a writable ('@', bind) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The readable one is then accessbile via zproc_stderr method. """ utils.lib.zproc_set_stderr(self._p, socket._p) def stdin(self): """ Return subprocess stdin writable socket. NULL for not initialized or external sockets. """ return utils.lib.zproc_stdin(self._p) def stdout(self): """ Return subprocess stdout readable socket. NULL for not initialized or external sockets. """ return utils.lib.zproc_stdout(self._p) def stderr(self): """ Return subprocess stderr readable socket. NULL for not initialized or external sockets. """ return utils.lib.zproc_stderr(self._p) def run(self): """ Starts the process. """ return utils.lib.zproc_run(self._p) def returncode(self): """ process exit code """ return utils.lib.zproc_returncode(self._p) def pid(self): """ PID of the process """ return utils.lib.zproc_pid(self._p) def running(self): """ return true if process is running, false if not yet started or finished """ return utils.lib.zproc_running(self._p) def wait(self, hang): """ wait or poll process status, return return code """ return utils.lib.zproc_wait(self._p, hang) def actor(self): """ return internal actor, usefull for the polling if process died """ return utils.lib.zproc_actor(self._p) def kill(self, signal): """ send a signal to the subprocess """ utils.lib.zproc_kill(self._p, signal) def set_verbose(self, verbose): """ set verbose mode """ utils.lib.zproc_set_verbose(self._p, verbose) def czmq_version(): """ Returns CZMQ version as a single 6-digit integer encoding the major version (x 10000), the minor version (x 100) and the patch. """ return utils.lib.zproc_czmq_version() def interrupted(): """ Returns true if the process received a SIGINT or SIGTERM signal. It is good practice to use this method to exit any infinite loop processing messages. """ return utils.lib.zproc_interrupted() def has_curve(): """ Returns true if the underlying libzmq supports CURVE security. """ return utils.lib.zproc_has_curve() def hostname(): """ Return current host name, for use in public tcp:// endpoints. If the host name is not resolvable, returns NULL. """ return utils.lib.zproc_hostname() def daemonize(workdir): """ Move the current process into the background. The precise effect depends on the operating system. On POSIX boxes, moves to a specified working directory (if specified), closes all file handles, reopens stdin, stdout, and stderr to the null device, and sets the process to ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there was an error. """ utils.lib.zproc_daemonize(utils.to_bytes(workdir)) def run_as(lockfile, group, user): """ Drop the process ID into the lockfile, with exclusive lock, and switch the process to the specified group and/or user. Any of the arguments may be null, indicating a no-op. Returns 0 on success, -1 on failure. Note if you combine this with zsys_daemonize, run after, not before that method, or the lockfile will hold the wrong process ID. """ utils.lib.zproc_run_as(utils.to_bytes(lockfile), utils.to_bytes(group), utils.to_bytes(user)) def set_io_threads(io_threads): """ Configure the number of I/O threads that ZeroMQ will use. A good rule of thumb is one thread per gigabit of traffic in or out. The default is 1, sufficient for most applications. If the environment variable ZSYS_IO_THREADS is defined, that provides the default. Note that this method is valid only before any socket is created. """ utils.lib.zproc_set_io_threads(io_threads) def set_max_sockets(max_sockets): """ Configure the number of sockets that ZeroMQ will allow. The default is 1024. The actual limit depends on the system, and you can query it by using zsys_socket_limit (). A value of zero means "maximum". Note that this method is valid only before any socket is created. """ utils.lib.zproc_set_max_sockets(max_sockets) def set_biface(value): """ Set network interface name to use for broadcasts, particularly zbeacon. This lets the interface be configured for test environments where required. For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is the default when there is no specified interface. If the environment variable ZSYS_INTERFACE is set, use that as the default interface name. Setting the interface to "*" means "use all available interfaces". """ utils.lib.zproc_set_biface(utils.to_bytes(value)) def biface(): """ Return network interface to use for broadcasts, or "" if none was set. """ return utils.lib.zproc_biface() def set_log_ident(value): """ Set log identity, which is a string that prefixes all log messages sent by this process. The log identity defaults to the environment variable ZSYS_LOGIDENT, if that is set. """ utils.lib.zproc_set_log_ident(utils.to_bytes(value)) def set_log_sender(endpoint): """ Sends log output to a PUB socket bound to the specified endpoint. To collect such log output, create a SUB socket, subscribe to the traffic you care about, and connect to the endpoint. Log traffic is sent as a single string frame, in the same format as when sent to stdout. The log system supports a single sender; multiple calls to this method will bind the same sender to multiple endpoints. To disable the sender, call this method with a null argument. """ utils.lib.zproc_set_log_sender(utils.to_bytes(endpoint)) def set_log_system(logsystem): """ Enable or disable logging to the system facility (syslog on POSIX boxes, event log on Windows). By default this is disabled. """ utils.lib.zproc_set_log_system(logsystem) def log_error(format, ): """ Log error condition - highest priority """ utils.lib.zproc_log_error(format, ) def log_warning(format, ): """ Log warning condition - high priority """ utils.lib.zproc_log_warning(format, ) def log_notice(format, ): """ Log normal, but significant, condition - normal priority """ utils.lib.zproc_log_notice(format, ) def log_info(format, ): """ Log informational message - low priority """ utils.lib.zproc_log_info(format, ) def log_debug(format, ): """ Log debug-level message - lowest priority """ utils.lib.zproc_log_debug(format, ) def test(verbose): """ Self test of this class. """ utils.lib.zproc_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zfile.py0000664000372000037200000001435113222211156023060 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zfile(object): """ helper functions for working with files. """ def __init__(self, path, name): """ If file exists, populates properties. CZMQ supports portable symbolic links, which are files with the extension ".ln". A symbolic link is a text file containing one line, the filename of a target file. Reading data from the symbolic link actually reads from the target file. Path may be NULL, in which case it is not used. """ p = utils.lib.zfile_new(utils.to_bytes(path), utils.to_bytes(name)) if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zfile_destroy_py) def dup(self): """ Duplicate a file item, returns a newly constructed item. If the file is null, or memory was exhausted, returns null. """ return utils.lib.zfile_dup(self._p) def filename(self, path): """ Return file name, remove path if provided """ return utils.lib.zfile_filename(self._p, utils.to_bytes(path)) def restat(self): """ Refresh file properties from disk; this is not done automatically on access methods, otherwise it is not possible to compare directory snapshots. """ utils.lib.zfile_restat(self._p) def modified(self): """ Return when the file was last modified. If you want this to reflect the current situation, call zfile_restat before checking this property. """ return utils.lib.zfile_modified(self._p) def cursize(self): """ Return the last-known size of the file. If you want this to reflect the current situation, call zfile_restat before checking this property. """ return utils.lib.zfile_cursize(self._p) def is_directory(self): """ Return true if the file is a directory. If you want this to reflect any external changes, call zfile_restat before checking this property. """ return utils.lib.zfile_is_directory(self._p) def is_regular(self): """ Return true if the file is a regular file. If you want this to reflect any external changes, call zfile_restat before checking this property. """ return utils.lib.zfile_is_regular(self._p) def is_readable(self): """ Return true if the file is readable by this process. If you want this to reflect any external changes, call zfile_restat before checking this property. """ return utils.lib.zfile_is_readable(self._p) def is_writeable(self): """ Return true if the file is writeable by this process. If you want this to reflect any external changes, call zfile_restat before checking this property. """ return utils.lib.zfile_is_writeable(self._p) def is_stable(self): """ Check if file has stopped changing and can be safely processed. Updates the file statistics from disk at every call. """ return utils.lib.zfile_is_stable(self._p) def has_changed(self): """ Return true if the file was changed on disk since the zfile_t object was created, or the last zfile_restat() call made on it. """ return utils.lib.zfile_has_changed(self._p) def remove(self): """ Remove the file from disk """ utils.lib.zfile_remove(self._p) def input(self): """ Open file for reading Returns 0 if OK, -1 if not found or not accessible """ return utils.lib.zfile_input(self._p) def output(self): """ Open file for writing, creating directory if needed File is created if necessary; chunks can be written to file at any location. Returns 0 if OK, -1 if error. """ return utils.lib.zfile_output(self._p) def read(self, bytes, offset): """ Read chunk from file at specified position. If this was the last chunk, sets the eof property. Returns a null chunk in case of error. """ return utils.lib.zfile_read(self._p, bytes, offset) def eof(self): """ Returns true if zfile_read() just read the last chunk in the file. """ return utils.lib.zfile_eof(self._p) def write(self, chunk, offset): """ Write chunk to file at specified position Return 0 if OK, else -1 """ return utils.lib.zfile_write(self._p, chunk._p, offset) def readln(self): """ Read next line of text from file. Returns a pointer to the text line, or NULL if there was nothing more to read from the file. """ return utils.lib.zfile_readln(self._p) def close(self): """ Close file, if open """ utils.lib.zfile_close(self._p) def handle(self): """ Return file handle, if opened """ return utils.lib.zfile_handle(self._p) def digest(self): """ Calculate SHA1 digest for file, using zdigest class. """ return utils.lib.zfile_digest(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zfile_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/ZdirPatch.py0000664000372000037200000000467513222211156023707 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class ZdirPatch(object): """ work with directory patches """ def __init__(self, path, file, op, alias): """ Create new patch """ p = utils.lib.zdir_patch_new(utils.to_bytes(path), file._p, op, utils.to_bytes(alias)) if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zdir_patch_destroy_py) def dup(self): """ Create copy of a patch. If the patch is null, or memory was exhausted, returns null. """ return utils.lib.zdir_patch_dup(self._p) def path(self): """ Return patch file directory path """ return utils.lib.zdir_patch_path(self._p) def file(self): """ Return patch file item """ return utils.lib.zdir_patch_file(self._p) def op(self): """ Return operation """ return utils.lib.zdir_patch_op(self._p) def vpath(self): """ Return patch virtual file path """ return utils.lib.zdir_patch_vpath(self._p) def digest_set(self): """ Calculate hash digest for file (create only) """ utils.lib.zdir_patch_digest_set(self._p) def digest(self): """ Return hash digest for patch file """ return utils.lib.zdir_patch_digest(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zdir_patch_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Ztimerset.py0000664000372000037200000000555513222211156024003 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Ztimerset(object): """ timer set """ def __init__(self): """ Create new timer set. """ p = utils.lib.ztimerset_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.ztimerset_destroy_py) def add(self, interval, handler, arg): """ Add a timer to the set. Returns timer id if OK, -1 on failure. """ return utils.lib.ztimerset_add(self._p, interval, handler, arg._p) def cancel(self, timer_id): """ Cancel a timer. Returns 0 if OK, -1 on failure. """ return utils.lib.ztimerset_cancel(self._p, timer_id) def set_interval(self, timer_id, interval): """ Set timer interval. Returns 0 if OK, -1 on failure. This method is slow, canceling the timer and adding a new one yield better performance. """ return utils.lib.ztimerset_set_interval(self._p, timer_id, interval) def reset(self, timer_id): """ Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. This method is slow, canceling the timer and adding a new one yield better performance. """ return utils.lib.ztimerset_reset(self._p, timer_id) def timeout(self): """ Return the time until the next interval. Should be used as timeout parameter for the zpoller wait method. The timeout is in msec. """ return utils.lib.ztimerset_timeout(self._p) def execute(self): """ Invoke callback function of all timers which their interval has elapsed. Should be call after zpoller wait method. Returns 0 if OK, -1 on failure. """ return utils.lib.ztimerset_execute(self._p) def test(verbose): """ Self test of this class. """ utils.lib.ztimerset_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/build.py0000664000372000037200000001520313222211156023103 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ from __future__ import print_function import os import re import sys import subprocess def pkgconfig_installed (): try: subprocess.check_output (["pkg-config", "--version"]) return True except subprocess.CalledProcessError: return False def pkgconfig_kwargs (libs): """If pkg-config is available, then return kwargs for set_source based on pkg-config output It setup include_dirs, library_dirs, libraries and define_macros """ # make API great again! if isinstance (libs, (str, bytes)): libs = (libs, ) # drop starting -I -L -l from cflags def dropILl (string): def _dropILl (string): if string.startswith (b"-I") or string.startswith (b"-L") or string.startswith (b"-l"): return string [2:] return [_dropILl (x) for x in string.split ()] # convert -Dfoo=bar to list of tuples [("foo", "bar")] expected by cffi def macros (string): def _macros (string): return tuple (string [2:].split (b'=', 2)) return [_macros (x) for x in string.split () if x.startswith (b"-D")] # pkg-config call def pc (libname, *args): a = ["pkg-config", "--print-errors"] a.extend (args) a.append (libname) return subprocess.check_output (a) # return kwargs for given libname def kwargs (libname): return { "include_dirs" : dropILl (pc (libname, "--cflags-only-I")), "library_dirs" : dropILl (pc (libname, "--libs-only-L")), "libraries" : dropILl (pc (libname, "--libs-only-l")), "define_macros" : macros (pc (libname, "--cflags")), } # merge all arguments together ret = {} for libname in libs: foo = kwargs (libname) for key, value in foo.items (): if not key in ret: ret [key] = value else: ret [key].extend (value) # Python3 and strict unicode for key, value in ret.items (): if isinstance (value, bytes): ret [key] = value.decode ("utf-8") elif isinstance (value, list): if len (value) == 0: continue if isinstance (value[0], tuple): ret [key] = [(v[0].decode ("utf-8"), v[1].decode ("utf-8")) for v in value] else: ret [key] = [v.decode ("utf-8") for v in value] return ret if not pkgconfig_installed (): print ("ERROR: build without pkg-config not supported", file=sys.stderr) sys.exit (1) kwargs = pkgconfig_kwargs ([ "libzmq", "uuid", "libsystemd", "liblz4", "libczmq" ]) import cffi # can't import does not work, read and exec manually with open (os.path.join ( os.path.dirname (__file__), "cdefs.py"), 'r') as fp: cdefs_py = fp.read() gl = {} exec (cdefs_py, gl) czmq_cdefs = gl ["czmq_cdefs"] ffibuilder = cffi.FFI () ffibuilder.set_source ("czmq_cffi.native", "#include ", **kwargs) # Custom setup for czmq for item in czmq_cdefs: ffibuilder.cdef(item) ffidestructorbuilder = cffi.FFI () ffidestructorbuilder.cdef(''' void zactor_destroy_py (void *self); void zargs_destroy_py (void *self); void zarmour_destroy_py (void *self); void zcert_destroy_py (void *self); void zcertstore_destroy_py (void *self); void zchunk_destroy_py (void *self); void zconfig_destroy_py (void *self); void zdigest_destroy_py (void *self); void zdir_destroy_py (void *self); void zdir_patch_destroy_py (void *self); void zfile_destroy_py (void *self); void zframe_destroy_py (void *self); void zhash_destroy_py (void *self); void zhashx_destroy_py (void *self); void ziflist_destroy_py (void *self); void zlist_destroy_py (void *self); void zlistx_destroy_py (void *self); void zloop_destroy_py (void *self); void zmsg_destroy_py (void *self); void zpoller_destroy_py (void *self); void zproc_destroy_py (void *self); void zsock_destroy_py (void *self); void ztimerset_destroy_py (void *self); void ztrie_destroy_py (void *self); void zuuid_destroy_py (void *self); ''') ffidestructorbuilder.set_source ("czmq_cffi.destructors", ''' #include void zactor_destroy_py (void *self) { zactor_destroy ((zactor_t **) &self); } void zargs_destroy_py (void *self) { zargs_destroy ((zargs_t **) &self); } void zarmour_destroy_py (void *self) { zarmour_destroy ((zarmour_t **) &self); } void zcert_destroy_py (void *self) { zcert_destroy ((zcert_t **) &self); } void zcertstore_destroy_py (void *self) { zcertstore_destroy ((zcertstore_t **) &self); } void zchunk_destroy_py (void *self) { zchunk_destroy ((zchunk_t **) &self); } void zconfig_destroy_py (void *self) { zconfig_destroy ((zconfig_t **) &self); } void zdigest_destroy_py (void *self) { zdigest_destroy ((zdigest_t **) &self); } void zdir_destroy_py (void *self) { zdir_destroy ((zdir_t **) &self); } void zdir_patch_destroy_py (void *self) { zdir_patch_destroy ((zdir_patch_t **) &self); } void zfile_destroy_py (void *self) { zfile_destroy ((zfile_t **) &self); } void zframe_destroy_py (void *self) { zframe_destroy ((zframe_t **) &self); } void zhash_destroy_py (void *self) { zhash_destroy ((zhash_t **) &self); } void zhashx_destroy_py (void *self) { zhashx_destroy ((zhashx_t **) &self); } void ziflist_destroy_py (void *self) { ziflist_destroy ((ziflist_t **) &self); } void zlist_destroy_py (void *self) { zlist_destroy ((zlist_t **) &self); } void zlistx_destroy_py (void *self) { zlistx_destroy ((zlistx_t **) &self); } void zloop_destroy_py (void *self) { zloop_destroy ((zloop_t **) &self); } void zmsg_destroy_py (void *self) { zmsg_destroy ((zmsg_t **) &self); } void zpoller_destroy_py (void *self) { zpoller_destroy ((zpoller_t **) &self); } void zproc_destroy_py (void *self) { zproc_destroy ((zproc_t **) &self); } void zsock_destroy_py (void *self) { zsock_destroy ((zsock_t **) &self); } void ztimerset_destroy_py (void *self) { ztimerset_destroy ((ztimerset_t **) &self); } void ztrie_destroy_py (void *self) { ztrie_destroy ((ztrie_t **) &self); } void zuuid_destroy_py (void *self) { zuuid_destroy ((zuuid_t **) &self); } ''', **kwargs) if __name__ == "__main__": ffibuilder.compile (verbose=True) ffidestructorbuilder.compile (verbose=True) czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zsock.py0000664000372000037200000012253113222211156023100 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zsock(object): """ high-level socket API that hides libzmq contexts and sockets """ def __init__(self, type): """ Create a new socket. Returns the new socket, or NULL if the new socket could not be created. Note that the symbol zsock_new (and other constructors/destructors for zsock) are redirected to the *_checked variant, enabling intelligent socket leak detection. This can have performance implications if you use a LOT of sockets. To turn off this redirection behaviour, define ZSOCK_NOCHECK. """ p = utils.lib.zsock_new(type) if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zsock_destroy_py) def bind(self, format, ): """ Bind a socket to a formatted endpoint. For tcp:// endpoints, supports ephemeral ports, if you specify the port number as "*". By default zsock uses the IANA designated range from C000 (49152) to FFFF (65535). To override this range, follow the "*" with "[first-last]". Either or both first and last may be empty. To bind to a random port within the range, use "!" in place of "*". Examples: tcp://127.0.0.1:* bind to first free port from C000 up tcp://127.0.0.1:! bind to random port from C000 to FFFF tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 tcp://127.0.0.1:![55000-55999] bind to random port from 55000 to 55999 On success, returns the actual port number used, for tcp:// endpoints, and 0 for other transports. On failure, returns -1. Note that when using ephemeral ports, a port may be reused by different services without clients being aware. Protocols that run on ephemeral ports should take this into account. """ return utils.lib.zsock_bind(self._p, format, ) def endpoint(self): """ Returns last bound endpoint, if any. """ return utils.lib.zsock_endpoint(self._p) def unbind(self, format, ): """ Unbind a socket from a formatted endpoint. Returns 0 if OK, -1 if the endpoint was invalid or the function isn't supported. """ return utils.lib.zsock_unbind(self._p, format, ) def connect(self, format, ): """ Connect a socket to a formatted endpoint Returns 0 if OK, -1 if the endpoint was invalid. """ return utils.lib.zsock_connect(self._p, format, ) def disconnect(self, format, ): """ Disconnect a socket from a formatted endpoint Returns 0 if OK, -1 if the endpoint was invalid or the function isn't supported. """ return utils.lib.zsock_disconnect(self._p, format, ) def attach(self, endpoints, serverish): """ Attach a socket to zero or more endpoints. If endpoints is not null, parses as list of ZeroMQ endpoints, separated by commas, and prefixed by '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all endpoints were valid, or -1 if there was a syntax error. If the endpoint does not start with '@' or '>', the serverish argument defines whether it is used to bind (serverish = true) or connect (serverish = false). """ return utils.lib.zsock_attach(self._p, utils.to_bytes(endpoints), serverish) def type_str(self): """ Returns socket type as printable constant string. """ return utils.lib.zsock_type_str(self._p) def send(self, picture, ): """ Send a 'picture' message to the socket (or actor). The picture is a string that defines the type of each frame. This makes it easy to send a complex multiframe message in one call. The picture can contain any of these characters, each corresponding to one or two arguments: i = int (signed) 1 = uint8_t 2 = uint16_t 4 = uint32_t 8 = uint64_t s = char * b = byte *, size_t (2 arguments) c = zchunk_t * f = zframe_t * h = zhashx_t * U = zuuid_t * p = void * (sends the pointer value, only meaningful over inproc) m = zmsg_t * (sends all frames in the zmsg) z = sends zero-sized frame (0 arguments) u = uint (deprecated) Note that s, b, c, and f are encoded the same way and the choice is offered as a convenience to the sender, which may or may not already have data in a zchunk or zframe. Does not change or take ownership of any arguments. Returns 0 if successful, -1 if sending failed for any reason. """ return utils.lib.zsock_send(self._p, utils.to_bytes(picture), ) def vsend(self, picture, argptr): """ Send a 'picture' message to the socket (or actor). This is a va_list version of zsock_send (), so please consult its documentation for the details. """ return utils.lib.zsock_vsend(self._p, utils.to_bytes(picture), argptr._p) def recv(self, picture, ): """ Receive a 'picture' message to the socket (or actor). See zsock_send for the format and meaning of the picture. Returns the picture elements into a series of pointers as provided by the caller: i = int * (stores signed integer) 4 = uint32_t * (stores 32-bit unsigned integer) 8 = uint64_t * (stores 64-bit unsigned integer) s = char ** (allocates new string) b = byte **, size_t * (2 arguments) (allocates memory) c = zchunk_t ** (creates zchunk) f = zframe_t ** (creates zframe) U = zuuid_t * (creates a zuuid with the data) h = zhashx_t ** (creates zhashx) p = void ** (stores pointer) m = zmsg_t ** (creates a zmsg with the remaing frames) z = null, asserts empty frame (0 arguments) u = uint * (stores unsigned integer, deprecated) Note that zsock_recv creates the returned objects, and the caller must destroy them when finished with them. The supplied pointers do not need to be initialized. Returns 0 if successful, or -1 if it failed to recv a message, in which case the pointers are not modified. When message frames are truncated (a short message), sets return values to zero/null. If an argument pointer is NULL, does not store any value (skips it). An 'n' picture matches an empty frame; if the message does not match, the method will return -1. """ return utils.lib.zsock_recv(self._p, utils.to_bytes(picture), ) def vrecv(self, picture, argptr): """ Receive a 'picture' message from the socket (or actor). This is a va_list version of zsock_recv (), so please consult its documentation for the details. """ return utils.lib.zsock_vrecv(self._p, utils.to_bytes(picture), argptr._p) def bsend(self, picture, ): """ Send a binary encoded 'picture' message to the socket (or actor). This method is similar to zsock_send, except the arguments are encoded in a binary format that is compatible with zproto, and is designed to reduce memory allocations. The pattern argument is a string that defines the type of each argument. Supports these argument types: pattern C type zproto type: 1 uint8_t type = "number" size = "1" 2 uint16_t type = "number" size = "2" 4 uint32_t type = "number" size = "3" 8 uint64_t type = "number" size = "4" s char *, 0-255 chars type = "string" S char *, 0-2^32-1 chars type = "longstr" c zchunk_t * type = "chunk" f zframe_t * type = "frame" u zuuid_t * type = "uuid" m zmsg_t * type = "msg" p void *, sends pointer value, only over inproc Does not change or take ownership of any arguments. Returns 0 if successful, -1 if sending failed for any reason. """ return utils.lib.zsock_bsend(self._p, utils.to_bytes(picture), ) def brecv(self, picture, ): """ Receive a binary encoded 'picture' message from the socket (or actor). This method is similar to zsock_recv, except the arguments are encoded in a binary format that is compatible with zproto, and is designed to reduce memory allocations. The pattern argument is a string that defines the type of each argument. See zsock_bsend for the supported argument types. All arguments must be pointers; this call sets them to point to values held on a per-socket basis. For types 1, 2, 4 and 8 the caller must allocate the memory itself before calling zsock_brecv. For types S, the caller must free the value once finished with it, as zsock_brecv will allocate the buffer. For type s, the caller must not free the value as it is stored in a local cache for performance purposes. For types c, f, u and m the caller must call the appropriate destructor depending on the object as zsock_brecv will create new objects. For type p the caller must coordinate with the sender, as it is just a pointer value being passed. """ return utils.lib.zsock_brecv(self._p, utils.to_bytes(picture), ) def routing_id(self): """ Return socket routing ID if any. This returns 0 if the socket is not of type ZMQ_SERVER or if no request was already received on it. """ return utils.lib.zsock_routing_id(self._p) def set_routing_id(self, routing_id): """ Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. This will be used when sending messages on the socket via the zsock API. """ utils.lib.zsock_set_routing_id(self._p, routing_id) def set_unbounded(self): """ Set socket to use unbounded pipes (HWM=0); use this in cases when you are totally certain the message volume can fit in memory. This method works across all versions of ZeroMQ. Takes a polymorphic socket reference. """ utils.lib.zsock_set_unbounded(self._p) def signal(self, status): """ Send a signal over a socket. A signal is a short message carrying a success/failure code (by convention, 0 means OK). Signals are encoded to be distinguishable from "normal" messages. Accepts a zsock_t or a zactor_t argument, and returns 0 if successful, -1 if the signal could not be sent. Takes a polymorphic socket reference. """ return utils.lib.zsock_signal(self._p, status) def wait(self): """ Wait on a signal. Use this to coordinate between threads, over pipe pairs. Blocks until the signal is received. Returns -1 on error, 0 or greater on success. Accepts a zsock_t or a zactor_t as argument. Takes a polymorphic socket reference. """ return utils.lib.zsock_wait(self._p) def flush(self): """ If there is a partial message still waiting on the socket, remove and discard it. This is useful when reading partial messages, to get specific message types. """ utils.lib.zsock_flush(self._p) def join(self, group): """ Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. Returns 0 if OK, -1 if failed. """ return utils.lib.zsock_join(self._p, utils.to_bytes(group)) def leave(self, group): """ Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. Returns 0 if OK, -1 if failed. """ return utils.lib.zsock_leave(self._p, utils.to_bytes(group)) def is_py(self): """ Probe the supplied object, and report if it looks like a zsock_t. Takes a polymorphic socket reference. """ return utils.lib.zsock_is(self._p) def resolve(self): """ Probe the supplied reference. If it looks like a zsock_t instance, return the underlying libzmq socket handle; else if it looks like a file descriptor, return NULL; else if it looks like a libzmq socket handle, return the supplied value. Takes a polymorphic socket reference. """ return utils.lib.zsock_resolve(self._p) def heartbeat_ivl(self): """ Get socket option `heartbeat_ivl`. Available from libzmq 4.2.0. """ return utils.lib.zsock_heartbeat_ivl(self._p) def set_heartbeat_ivl(self, heartbeat_ivl): """ Set socket option `heartbeat_ivl`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_heartbeat_ivl(self._p, heartbeat_ivl) def heartbeat_ttl(self): """ Get socket option `heartbeat_ttl`. Available from libzmq 4.2.0. """ return utils.lib.zsock_heartbeat_ttl(self._p) def set_heartbeat_ttl(self, heartbeat_ttl): """ Set socket option `heartbeat_ttl`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_heartbeat_ttl(self._p, heartbeat_ttl) def heartbeat_timeout(self): """ Get socket option `heartbeat_timeout`. Available from libzmq 4.2.0. """ return utils.lib.zsock_heartbeat_timeout(self._p) def set_heartbeat_timeout(self, heartbeat_timeout): """ Set socket option `heartbeat_timeout`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_heartbeat_timeout(self._p, heartbeat_timeout) def use_fd(self): """ Get socket option `use_fd`. Available from libzmq 4.2.0. """ return utils.lib.zsock_use_fd(self._p) def set_use_fd(self, use_fd): """ Set socket option `use_fd`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_use_fd(self._p, use_fd) def set_xpub_manual(self, xpub_manual): """ Set socket option `xpub_manual`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_xpub_manual(self._p, xpub_manual) def set_xpub_welcome_msg(self, xpub_welcome_msg): """ Set socket option `xpub_welcome_msg`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_xpub_welcome_msg(self._p, utils.to_bytes(xpub_welcome_msg)) def set_stream_notify(self, stream_notify): """ Set socket option `stream_notify`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_stream_notify(self._p, stream_notify) def invert_matching(self): """ Get socket option `invert_matching`. Available from libzmq 4.2.0. """ return utils.lib.zsock_invert_matching(self._p) def set_invert_matching(self, invert_matching): """ Set socket option `invert_matching`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_invert_matching(self._p, invert_matching) def set_xpub_verboser(self, xpub_verboser): """ Set socket option `xpub_verboser`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_xpub_verboser(self._p, xpub_verboser) def connect_timeout(self): """ Get socket option `connect_timeout`. Available from libzmq 4.2.0. """ return utils.lib.zsock_connect_timeout(self._p) def set_connect_timeout(self, connect_timeout): """ Set socket option `connect_timeout`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_connect_timeout(self._p, connect_timeout) def tcp_maxrt(self): """ Get socket option `tcp_maxrt`. Available from libzmq 4.2.0. """ return utils.lib.zsock_tcp_maxrt(self._p) def set_tcp_maxrt(self, tcp_maxrt): """ Set socket option `tcp_maxrt`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_tcp_maxrt(self._p, tcp_maxrt) def thread_safe(self): """ Get socket option `thread_safe`. Available from libzmq 4.2.0. """ return utils.lib.zsock_thread_safe(self._p) def multicast_maxtpdu(self): """ Get socket option `multicast_maxtpdu`. Available from libzmq 4.2.0. """ return utils.lib.zsock_multicast_maxtpdu(self._p) def set_multicast_maxtpdu(self, multicast_maxtpdu): """ Set socket option `multicast_maxtpdu`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_multicast_maxtpdu(self._p, multicast_maxtpdu) def vmci_buffer_size(self): """ Get socket option `vmci_buffer_size`. Available from libzmq 4.2.0. """ return utils.lib.zsock_vmci_buffer_size(self._p) def set_vmci_buffer_size(self, vmci_buffer_size): """ Set socket option `vmci_buffer_size`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_vmci_buffer_size(self._p, vmci_buffer_size) def vmci_buffer_min_size(self): """ Get socket option `vmci_buffer_min_size`. Available from libzmq 4.2.0. """ return utils.lib.zsock_vmci_buffer_min_size(self._p) def set_vmci_buffer_min_size(self, vmci_buffer_min_size): """ Set socket option `vmci_buffer_min_size`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_vmci_buffer_min_size(self._p, vmci_buffer_min_size) def vmci_buffer_max_size(self): """ Get socket option `vmci_buffer_max_size`. Available from libzmq 4.2.0. """ return utils.lib.zsock_vmci_buffer_max_size(self._p) def set_vmci_buffer_max_size(self, vmci_buffer_max_size): """ Set socket option `vmci_buffer_max_size`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_vmci_buffer_max_size(self._p, vmci_buffer_max_size) def vmci_connect_timeout(self): """ Get socket option `vmci_connect_timeout`. Available from libzmq 4.2.0. """ return utils.lib.zsock_vmci_connect_timeout(self._p) def set_vmci_connect_timeout(self, vmci_connect_timeout): """ Set socket option `vmci_connect_timeout`. Available from libzmq 4.2.0. """ utils.lib.zsock_set_vmci_connect_timeout(self._p, vmci_connect_timeout) def tos(self): """ Get socket option `tos`. Available from libzmq 4.1.0. """ return utils.lib.zsock_tos(self._p) def set_tos(self, tos): """ Set socket option `tos`. Available from libzmq 4.1.0. """ utils.lib.zsock_set_tos(self._p, tos) def set_router_handover(self, router_handover): """ Set socket option `router_handover`. Available from libzmq 4.1.0. """ utils.lib.zsock_set_router_handover(self._p, router_handover) def set_connect_rid(self, connect_rid): """ Set socket option `connect_rid`. Available from libzmq 4.1.0. """ utils.lib.zsock_set_connect_rid(self._p, utils.to_bytes(connect_rid)) def set_connect_rid_bin(self, connect_rid): """ Set socket option `connect_rid` from 32-octet binary Available from libzmq 4.1.0. """ utils.lib.zsock_set_connect_rid_bin(self._p, connect_rid) def handshake_ivl(self): """ Get socket option `handshake_ivl`. Available from libzmq 4.1.0. """ return utils.lib.zsock_handshake_ivl(self._p) def set_handshake_ivl(self, handshake_ivl): """ Set socket option `handshake_ivl`. Available from libzmq 4.1.0. """ utils.lib.zsock_set_handshake_ivl(self._p, handshake_ivl) def socks_proxy(self): """ Get socket option `socks_proxy`. Available from libzmq 4.1.0. """ return utils.lib.zsock_socks_proxy(self._p) def set_socks_proxy(self, socks_proxy): """ Set socket option `socks_proxy`. Available from libzmq 4.1.0. """ utils.lib.zsock_set_socks_proxy(self._p, utils.to_bytes(socks_proxy)) def set_xpub_nodrop(self, xpub_nodrop): """ Set socket option `xpub_nodrop`. Available from libzmq 4.1.0. """ utils.lib.zsock_set_xpub_nodrop(self._p, xpub_nodrop) def set_router_mandatory(self, router_mandatory): """ Set socket option `router_mandatory`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_router_mandatory(self._p, router_mandatory) def set_probe_router(self, probe_router): """ Set socket option `probe_router`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_probe_router(self._p, probe_router) def set_req_relaxed(self, req_relaxed): """ Set socket option `req_relaxed`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_req_relaxed(self._p, req_relaxed) def set_req_correlate(self, req_correlate): """ Set socket option `req_correlate`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_req_correlate(self._p, req_correlate) def set_conflate(self, conflate): """ Set socket option `conflate`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_conflate(self._p, conflate) def zap_domain(self): """ Get socket option `zap_domain`. Available from libzmq 4.0.0. """ return utils.lib.zsock_zap_domain(self._p) def set_zap_domain(self, zap_domain): """ Set socket option `zap_domain`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_zap_domain(self._p, utils.to_bytes(zap_domain)) def mechanism(self): """ Get socket option `mechanism`. Available from libzmq 4.0.0. """ return utils.lib.zsock_mechanism(self._p) def plain_server(self): """ Get socket option `plain_server`. Available from libzmq 4.0.0. """ return utils.lib.zsock_plain_server(self._p) def set_plain_server(self, plain_server): """ Set socket option `plain_server`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_plain_server(self._p, plain_server) def plain_username(self): """ Get socket option `plain_username`. Available from libzmq 4.0.0. """ return utils.lib.zsock_plain_username(self._p) def set_plain_username(self, plain_username): """ Set socket option `plain_username`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_plain_username(self._p, utils.to_bytes(plain_username)) def plain_password(self): """ Get socket option `plain_password`. Available from libzmq 4.0.0. """ return utils.lib.zsock_plain_password(self._p) def set_plain_password(self, plain_password): """ Set socket option `plain_password`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_plain_password(self._p, utils.to_bytes(plain_password)) def curve_server(self): """ Get socket option `curve_server`. Available from libzmq 4.0.0. """ return utils.lib.zsock_curve_server(self._p) def set_curve_server(self, curve_server): """ Set socket option `curve_server`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_curve_server(self._p, curve_server) def curve_publickey(self): """ Get socket option `curve_publickey`. Available from libzmq 4.0.0. """ return utils.lib.zsock_curve_publickey(self._p) def set_curve_publickey(self, curve_publickey): """ Set socket option `curve_publickey`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_curve_publickey(self._p, utils.to_bytes(curve_publickey)) def set_curve_publickey_bin(self, curve_publickey): """ Set socket option `curve_publickey` from 32-octet binary Available from libzmq 4.0.0. """ utils.lib.zsock_set_curve_publickey_bin(self._p, curve_publickey) def curve_secretkey(self): """ Get socket option `curve_secretkey`. Available from libzmq 4.0.0. """ return utils.lib.zsock_curve_secretkey(self._p) def set_curve_secretkey(self, curve_secretkey): """ Set socket option `curve_secretkey`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_curve_secretkey(self._p, utils.to_bytes(curve_secretkey)) def set_curve_secretkey_bin(self, curve_secretkey): """ Set socket option `curve_secretkey` from 32-octet binary Available from libzmq 4.0.0. """ utils.lib.zsock_set_curve_secretkey_bin(self._p, curve_secretkey) def curve_serverkey(self): """ Get socket option `curve_serverkey`. Available from libzmq 4.0.0. """ return utils.lib.zsock_curve_serverkey(self._p) def set_curve_serverkey(self, curve_serverkey): """ Set socket option `curve_serverkey`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_curve_serverkey(self._p, utils.to_bytes(curve_serverkey)) def set_curve_serverkey_bin(self, curve_serverkey): """ Set socket option `curve_serverkey` from 32-octet binary Available from libzmq 4.0.0. """ utils.lib.zsock_set_curve_serverkey_bin(self._p, curve_serverkey) def gssapi_server(self): """ Get socket option `gssapi_server`. Available from libzmq 4.0.0. """ return utils.lib.zsock_gssapi_server(self._p) def set_gssapi_server(self, gssapi_server): """ Set socket option `gssapi_server`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_gssapi_server(self._p, gssapi_server) def gssapi_plaintext(self): """ Get socket option `gssapi_plaintext`. Available from libzmq 4.0.0. """ return utils.lib.zsock_gssapi_plaintext(self._p) def set_gssapi_plaintext(self, gssapi_plaintext): """ Set socket option `gssapi_plaintext`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_gssapi_plaintext(self._p, gssapi_plaintext) def gssapi_principal(self): """ Get socket option `gssapi_principal`. Available from libzmq 4.0.0. """ return utils.lib.zsock_gssapi_principal(self._p) def set_gssapi_principal(self, gssapi_principal): """ Set socket option `gssapi_principal`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_gssapi_principal(self._p, utils.to_bytes(gssapi_principal)) def gssapi_service_principal(self): """ Get socket option `gssapi_service_principal`. Available from libzmq 4.0.0. """ return utils.lib.zsock_gssapi_service_principal(self._p) def set_gssapi_service_principal(self, gssapi_service_principal): """ Set socket option `gssapi_service_principal`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_gssapi_service_principal(self._p, utils.to_bytes(gssapi_service_principal)) def ipv6(self): """ Get socket option `ipv6`. Available from libzmq 4.0.0. """ return utils.lib.zsock_ipv6(self._p) def set_ipv6(self, ipv6): """ Set socket option `ipv6`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_ipv6(self._p, ipv6) def immediate(self): """ Get socket option `immediate`. Available from libzmq 4.0.0. """ return utils.lib.zsock_immediate(self._p) def set_immediate(self, immediate): """ Set socket option `immediate`. Available from libzmq 4.0.0. """ utils.lib.zsock_set_immediate(self._p, immediate) def sndhwm(self): """ Get socket option `sndhwm`. Available from libzmq 3.0.0. """ return utils.lib.zsock_sndhwm(self._p) def set_sndhwm(self, sndhwm): """ Set socket option `sndhwm`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_sndhwm(self._p, sndhwm) def rcvhwm(self): """ Get socket option `rcvhwm`. Available from libzmq 3.0.0. """ return utils.lib.zsock_rcvhwm(self._p) def set_rcvhwm(self, rcvhwm): """ Set socket option `rcvhwm`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_rcvhwm(self._p, rcvhwm) def maxmsgsize(self): """ Get socket option `maxmsgsize`. Available from libzmq 3.0.0. """ return utils.lib.zsock_maxmsgsize(self._p) def set_maxmsgsize(self, maxmsgsize): """ Set socket option `maxmsgsize`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_maxmsgsize(self._p, maxmsgsize) def multicast_hops(self): """ Get socket option `multicast_hops`. Available from libzmq 3.0.0. """ return utils.lib.zsock_multicast_hops(self._p) def set_multicast_hops(self, multicast_hops): """ Set socket option `multicast_hops`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_multicast_hops(self._p, multicast_hops) def set_xpub_verbose(self, xpub_verbose): """ Set socket option `xpub_verbose`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_xpub_verbose(self._p, xpub_verbose) def tcp_keepalive(self): """ Get socket option `tcp_keepalive`. Available from libzmq 3.0.0. """ return utils.lib.zsock_tcp_keepalive(self._p) def set_tcp_keepalive(self, tcp_keepalive): """ Set socket option `tcp_keepalive`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_tcp_keepalive(self._p, tcp_keepalive) def tcp_keepalive_idle(self): """ Get socket option `tcp_keepalive_idle`. Available from libzmq 3.0.0. """ return utils.lib.zsock_tcp_keepalive_idle(self._p) def set_tcp_keepalive_idle(self, tcp_keepalive_idle): """ Set socket option `tcp_keepalive_idle`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_tcp_keepalive_idle(self._p, tcp_keepalive_idle) def tcp_keepalive_cnt(self): """ Get socket option `tcp_keepalive_cnt`. Available from libzmq 3.0.0. """ return utils.lib.zsock_tcp_keepalive_cnt(self._p) def set_tcp_keepalive_cnt(self, tcp_keepalive_cnt): """ Set socket option `tcp_keepalive_cnt`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_tcp_keepalive_cnt(self._p, tcp_keepalive_cnt) def tcp_keepalive_intvl(self): """ Get socket option `tcp_keepalive_intvl`. Available from libzmq 3.0.0. """ return utils.lib.zsock_tcp_keepalive_intvl(self._p) def set_tcp_keepalive_intvl(self, tcp_keepalive_intvl): """ Set socket option `tcp_keepalive_intvl`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_tcp_keepalive_intvl(self._p, tcp_keepalive_intvl) def tcp_accept_filter(self): """ Get socket option `tcp_accept_filter`. Available from libzmq 3.0.0. """ return utils.lib.zsock_tcp_accept_filter(self._p) def set_tcp_accept_filter(self, tcp_accept_filter): """ Set socket option `tcp_accept_filter`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_tcp_accept_filter(self._p, utils.to_bytes(tcp_accept_filter)) def last_endpoint(self): """ Get socket option `last_endpoint`. Available from libzmq 3.0.0. """ return utils.lib.zsock_last_endpoint(self._p) def set_router_raw(self, router_raw): """ Set socket option `router_raw`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_router_raw(self._p, router_raw) def ipv4only(self): """ Get socket option `ipv4only`. Available from libzmq 3.0.0. """ return utils.lib.zsock_ipv4only(self._p) def set_ipv4only(self, ipv4only): """ Set socket option `ipv4only`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_ipv4only(self._p, ipv4only) def set_delay_attach_on_connect(self, delay_attach_on_connect): """ Set socket option `delay_attach_on_connect`. Available from libzmq 3.0.0. """ utils.lib.zsock_set_delay_attach_on_connect(self._p, delay_attach_on_connect) def hwm(self): """ Get socket option `hwm`. Available from libzmq 2.0.0 to 3.0.0. """ return utils.lib.zsock_hwm(self._p) def set_hwm(self, hwm): """ Set socket option `hwm`. Available from libzmq 2.0.0 to 3.0.0. """ utils.lib.zsock_set_hwm(self._p, hwm) def swap(self): """ Get socket option `swap`. Available from libzmq 2.0.0 to 3.0.0. """ return utils.lib.zsock_swap(self._p) def set_swap(self, swap): """ Set socket option `swap`. Available from libzmq 2.0.0 to 3.0.0. """ utils.lib.zsock_set_swap(self._p, swap) def affinity(self): """ Get socket option `affinity`. Available from libzmq 2.0.0. """ return utils.lib.zsock_affinity(self._p) def set_affinity(self, affinity): """ Set socket option `affinity`. Available from libzmq 2.0.0. """ utils.lib.zsock_set_affinity(self._p, affinity) def identity(self): """ Get socket option `identity`. Available from libzmq 2.0.0. """ return utils.lib.zsock_identity(self._p) def set_identity(self, identity): """ Set socket option `identity`. Available from libzmq 2.0.0. """ utils.lib.zsock_set_identity(self._p, utils.to_bytes(identity)) def rate(self): """ Get socket option `rate`. Available from libzmq 2.0.0. """ return utils.lib.zsock_rate(self._p) def set_rate(self, rate): """ Set socket option `rate`. Available from libzmq 2.0.0. """ utils.lib.zsock_set_rate(self._p, rate) def recovery_ivl(self): """ Get socket option `recovery_ivl`. Available from libzmq 2.0.0. """ return utils.lib.zsock_recovery_ivl(self._p) def set_recovery_ivl(self, recovery_ivl): """ Set socket option `recovery_ivl`. Available from libzmq 2.0.0. """ utils.lib.zsock_set_recovery_ivl(self._p, recovery_ivl) def recovery_ivl_msec(self): """ Get socket option `recovery_ivl_msec`. Available from libzmq 2.0.0 to 3.0.0. """ return utils.lib.zsock_recovery_ivl_msec(self._p) def set_recovery_ivl_msec(self, recovery_ivl_msec): """ Set socket option `recovery_ivl_msec`. Available from libzmq 2.0.0 to 3.0.0. """ utils.lib.zsock_set_recovery_ivl_msec(self._p, recovery_ivl_msec) def mcast_loop(self): """ Get socket option `mcast_loop`. Available from libzmq 2.0.0 to 3.0.0. """ return utils.lib.zsock_mcast_loop(self._p) def set_mcast_loop(self, mcast_loop): """ Set socket option `mcast_loop`. Available from libzmq 2.0.0 to 3.0.0. """ utils.lib.zsock_set_mcast_loop(self._p, mcast_loop) def rcvtimeo(self): """ Get socket option `rcvtimeo`. Available from libzmq 2.2.0. """ return utils.lib.zsock_rcvtimeo(self._p) def set_rcvtimeo(self, rcvtimeo): """ Set socket option `rcvtimeo`. Available from libzmq 2.2.0. """ utils.lib.zsock_set_rcvtimeo(self._p, rcvtimeo) def sndtimeo(self): """ Get socket option `sndtimeo`. Available from libzmq 2.2.0. """ return utils.lib.zsock_sndtimeo(self._p) def set_sndtimeo(self, sndtimeo): """ Set socket option `sndtimeo`. Available from libzmq 2.2.0. """ utils.lib.zsock_set_sndtimeo(self._p, sndtimeo) def sndbuf(self): """ Get socket option `sndbuf`. Available from libzmq 2.0.0. """ return utils.lib.zsock_sndbuf(self._p) def set_sndbuf(self, sndbuf): """ Set socket option `sndbuf`. Available from libzmq 2.0.0. """ utils.lib.zsock_set_sndbuf(self._p, sndbuf) def rcvbuf(self): """ Get socket option `rcvbuf`. Available from libzmq 2.0.0. """ return utils.lib.zsock_rcvbuf(self._p) def set_rcvbuf(self, rcvbuf): """ Set socket option `rcvbuf`. Available from libzmq 2.0.0. """ utils.lib.zsock_set_rcvbuf(self._p, rcvbuf) def linger(self): """ Get socket option `linger`. Available from libzmq 2.0.0. """ return utils.lib.zsock_linger(self._p) def set_linger(self, linger): """ Set socket option `linger`. Available from libzmq 2.0.0. """ utils.lib.zsock_set_linger(self._p, linger) def reconnect_ivl(self): """ Get socket option `reconnect_ivl`. Available from libzmq 2.0.0. """ return utils.lib.zsock_reconnect_ivl(self._p) def set_reconnect_ivl(self, reconnect_ivl): """ Set socket option `reconnect_ivl`. Available from libzmq 2.0.0. """ utils.lib.zsock_set_reconnect_ivl(self._p, reconnect_ivl) def reconnect_ivl_max(self): """ Get socket option `reconnect_ivl_max`. Available from libzmq 2.0.0. """ return utils.lib.zsock_reconnect_ivl_max(self._p) def set_reconnect_ivl_max(self, reconnect_ivl_max): """ Set socket option `reconnect_ivl_max`. Available from libzmq 2.0.0. """ utils.lib.zsock_set_reconnect_ivl_max(self._p, reconnect_ivl_max) def backlog(self): """ Get socket option `backlog`. Available from libzmq 2.0.0. """ return utils.lib.zsock_backlog(self._p) def set_backlog(self, backlog): """ Set socket option `backlog`. Available from libzmq 2.0.0. """ utils.lib.zsock_set_backlog(self._p, backlog) def set_subscribe(self, subscribe): """ Set socket option `subscribe`. Available from libzmq 2.0.0. """ utils.lib.zsock_set_subscribe(self._p, utils.to_bytes(subscribe)) def set_unsubscribe(self, unsubscribe): """ Set socket option `unsubscribe`. Available from libzmq 2.0.0. """ utils.lib.zsock_set_unsubscribe(self._p, utils.to_bytes(unsubscribe)) def type(self): """ Get socket option `type`. Available from libzmq 2.0.0. """ return utils.lib.zsock_type(self._p) def rcvmore(self): """ Get socket option `rcvmore`. Available from libzmq 2.0.0. """ return utils.lib.zsock_rcvmore(self._p) def fd(self): """ Get socket option `fd`. Available from libzmq 2.0.0. """ return utils.lib.zsock_fd(self._p) def events(self): """ Get socket option `events`. Available from libzmq 2.0.0. """ return utils.lib.zsock_events(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zsock_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zlistx.py0000664000372000037200000002126713222211156023310 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zlistx(object): """ extended generic list container """ def __init__(self): """ Create a new, empty list. """ p = utils.lib.zlistx_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zlistx_destroy_py) def add_start(self, item): """ Add an item to the head of the list. Calls the item duplicator, if any, on the item. Resets cursor to list head. Returns an item handle on success, NULL if memory was exhausted. """ return utils.lib.zlistx_add_start(self._p, item._p) def add_end(self, item): """ Add an item to the tail of the list. Calls the item duplicator, if any, on the item. Resets cursor to list head. Returns an item handle on success, NULL if memory was exhausted. """ return utils.lib.zlistx_add_end(self._p, item._p) def size(self): """ Return the number of items in the list """ return utils.lib.zlistx_size(self._p) def head(self): """ Return first item in the list, or null, leaves the cursor """ return utils.lib.zlistx_head(self._p) def tail(self): """ Return last item in the list, or null, leaves the cursor """ return utils.lib.zlistx_tail(self._p) def first(self): """ Return the item at the head of list. If the list is empty, returns NULL. Leaves cursor pointing at the head item, or NULL if the list is empty. """ return utils.lib.zlistx_first(self._p) def next(self): """ Return the next item. At the end of the list (or in an empty list), returns NULL. Use repeated zlistx_next () calls to work through the list from zlistx_first (). First time, acts as zlistx_first(). """ return utils.lib.zlistx_next(self._p) def prev(self): """ Return the previous item. At the start of the list (or in an empty list), returns NULL. Use repeated zlistx_prev () calls to work through the list backwards from zlistx_last (). First time, acts as zlistx_last(). """ return utils.lib.zlistx_prev(self._p) def last(self): """ Return the item at the tail of list. If the list is empty, returns NULL. Leaves cursor pointing at the tail item, or NULL if the list is empty. """ return utils.lib.zlistx_last(self._p) def item(self): """ Returns the value of the item at the cursor, or NULL if the cursor is not pointing to an item. """ return utils.lib.zlistx_item(self._p) def cursor(self): """ Returns the handle of the item at the cursor, or NULL if the cursor is not pointing to an item. """ return utils.lib.zlistx_cursor(self._p) def handle_item(handle): """ Returns the item associated with the given list handle, or NULL if passed in handle is NULL. Asserts that the passed in handle points to a list element. """ return utils.lib.zlistx_handle_item(handle._p) def find(self, item): """ Find an item in the list, searching from the start. Uses the item comparator, if any, else compares item values directly. Returns the item handle found, or NULL. Sets the cursor to the found item, if any. """ return utils.lib.zlistx_find(self._p, item._p) def detach(self, handle): """ Detach an item from the list, using its handle. The item is not modified, and the caller is responsible for destroying it if necessary. If handle is null, detaches the first item on the list. Returns item that was detached, or null if none was. If cursor was at item, moves cursor to previous item, so you can detach items while iterating forwards through a list. """ return utils.lib.zlistx_detach(self._p, handle._p) def detach_cur(self): """ Detach item at the cursor, if any, from the list. The item is not modified, and the caller is responsible for destroying it as necessary. Returns item that was detached, or null if none was. Moves cursor to previous item, so you can detach items while iterating forwards through a list. """ return utils.lib.zlistx_detach_cur(self._p) def delete(self, handle): """ Delete an item, using its handle. Calls the item destructor is any is set. If handle is null, deletes the first item on the list. Returns 0 if an item was deleted, -1 if not. If cursor was at item, moves cursor to previous item, so you can delete items while iterating forwards through a list. """ return utils.lib.zlistx_delete(self._p, handle._p) def move_start(self, handle): """ Move an item to the start of the list, via its handle. """ utils.lib.zlistx_move_start(self._p, handle._p) def move_end(self, handle): """ Move an item to the end of the list, via its handle. """ utils.lib.zlistx_move_end(self._p, handle._p) def purge(self): """ Remove all items from the list, and destroy them if the item destructor is set. """ utils.lib.zlistx_purge(self._p) def sort(self): """ Sort the list. If an item comparator was set, calls that to compare items, otherwise compares on item value. The sort is not stable, so may reorder equal items. """ utils.lib.zlistx_sort(self._p) def insert(self, item, low_value): """ Create a new node and insert it into a sorted list. Calls the item duplicator, if any, on the item. If low_value is true, starts searching from the start of the list, otherwise searches from the end. Use the item comparator, if any, to find where to place the new node. Returns a handle to the new node, or NULL if memory was exhausted. Resets the cursor to the list head. """ return utils.lib.zlistx_insert(self._p, item._p, low_value) def reorder(self, handle, low_value): """ Move an item, specified by handle, into position in a sorted list. Uses the item comparator, if any, to determine the new location. If low_value is true, starts searching from the start of the list, otherwise searches from the end. """ utils.lib.zlistx_reorder(self._p, handle._p, low_value) def dup(self): """ Make a copy of the list; items are duplicated if you set a duplicator for the list, otherwise not. Copying a null reference returns a null reference. """ return utils.lib.zlistx_dup(self._p) def set_destructor(self, destructor): """ Set a user-defined deallocator for list items; by default items are not freed when the list is destroyed. """ utils.lib.zlistx_set_destructor(self._p, destructor) def set_duplicator(self, duplicator): """ Set a user-defined duplicator for list items; by default items are not copied when the list is duplicated. """ utils.lib.zlistx_set_duplicator(self._p, duplicator) def set_comparator(self, comparator): """ Set a user-defined comparator for zlistx_find and zlistx_sort; the method must return -1, 0, or 1 depending on whether item1 is less than, equal to, or greater than, item2. """ utils.lib.zlistx_set_comparator(self._p, comparator) def test(verbose): """ Self test of this class. """ utils.lib.zlistx_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zactor.py0000664000372000037200000000554113222211156023252 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zactor(object): """ provides a simple actor framework """ def __init__(self, task, args): """ Create a new actor passing arbitrary arguments reference. """ p = utils.lib.zactor_new(task, args._p) if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zactor_destroy_py) def send(self, msg_p): """ Send a zmsg message to the actor, take ownership of the message and destroy when it has been sent. """ return utils.lib.zactor_send(self._p, msg_p._p) def recv(self): """ Receive a zmsg message from the actor. Returns NULL if the actor was interrupted before the message could be received, or if there was a timeout on the actor. """ return utils.lib.zactor_recv(self._p) def is_py(self): """ Probe the supplied object, and report if it looks like a zactor_t. """ return utils.lib.zactor_is(self._p) def resolve(self): """ Probe the supplied reference. If it looks like a zactor_t instance, return the underlying libzmq actor handle; else if it looks like a libzmq actor handle, return the supplied value. """ return utils.lib.zactor_resolve(self._p) def sock(self): """ Return the actor's zsock handle. Use this when you absolutely need to work with the zsock instance rather than the actor. """ return utils.lib.zactor_sock(self._p) def set_destructor(self, destructor): """ Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. """ utils.lib.zactor_set_destructor(self._p, destructor) def test(verbose): """ Self test of this class. """ utils.lib.zactor_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zargs.py0000664000372000037200000001056213222211156023075 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zargs(object): """ Platform independent command line argument parsing helpers There are two kind of elements provided by this class foo --named-parameter --parameter with_value positional arguments -a gain-parameter zargs keeps poision only for arguments, parameters are to be accessed like hash. It DOES: * provide easy to use CLASS compatible API for accessing argv * is platform independent * provide getopt_long style -- argument, which delimits parameters from arguments * makes parameters positon independent It does NOT * change argv * provide a "declarative" way to define command line interface In future it SHALL * hide several formats of command line to one (-Idir, --include=dir, --include dir are the same from API pov) """ def __init__(self, argc, argv): """ Create a new zargs from command line arguments. """ p = utils.lib.zargs_new(argc, utils.to_bytes(argv)) if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zargs_destroy_py) def progname(self): """ Return program name (argv[0]) """ return utils.lib.zargs_progname(self._p) def arguments(self): """ Return number of positional arguments """ return utils.lib.zargs_arguments(self._p) def first(self): """ Return first positional argument or NULL """ return utils.lib.zargs_first(self._p) def next(self): """ Return next positional argument or NULL """ return utils.lib.zargs_next(self._p) def param_first(self): """ Return first named parameter value, or NULL if there are no named parameters, or value for which zargs_param_empty (arg) returns true. """ return utils.lib.zargs_param_first(self._p) def param_next(self): """ Return next named parameter value, or NULL if there are no named parameters, or value for which zargs_param_empty (arg) returns true. """ return utils.lib.zargs_param_next(self._p) def param_name(self): """ Return current parameter name, or NULL if there are no named parameters. """ return utils.lib.zargs_param_name(self._p) def param_lookup(self, keys): """ Return value of named parameter, NULL if no given parameter has been specified, or special value for wich zargs_param_empty () returns true. """ return utils.lib.zargs_param_lookup(self._p, utils.to_bytes(keys)) def param_lookupx(self, keys, ): """ Return value of named parameter(s), NULL if no given parameter has been specified, or special value for wich zargs_param_empty () returns true. """ return utils.lib.zargs_param_lookupx(self._p, utils.to_bytes(keys), ) def has_help(self): """ Returns true if there are --help -h arguments """ return utils.lib.zargs_has_help(self._p) def param_empty(arg): """ Returns true if parameter did not have a value """ return utils.lib.zargs_param_empty(utils.to_bytes(arg)) def print_py(self): """ Print an instance of zargs. """ utils.lib.zargs_print(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zargs_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/__init__.py0000664000372000037200000000166613222211156023553 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from .Zactor import * from .Zargs import * from .Zarmour import * from .Zcert import * from .Zcertstore import * from .Zchunk import * from .Zclock import * from .Zconfig import * from .Zdigest import * from .Zdir import * from .ZdirPatch import * from .Zfile import * from .Zframe import * from .Zhash import * from .Zhashx import * from .Ziflist import * from .Zlist import * from .Zlistx import * from .Zloop import * from .Zmsg import * from .Zpoller import * from .Zproc import * from .Zsock import * from .Zstr import * from .Zsys import * from .Ztimerset import * from .Ztrie import * from .Zuuid import * czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zlist.py0000664000372000037200000001501213222211156023107 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zlist(object): """ simple generic list container """ def __init__(self): """ Create a new list container """ p = utils.lib.zlist_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zlist_destroy_py) def first(self): """ Return the item at the head of list. If the list is empty, returns NULL. Leaves cursor pointing at the head item, or NULL if the list is empty. """ return utils.lib.zlist_first(self._p) def next(self): """ Return the next item. If the list is empty, returns NULL. To move to the start of the list call zlist_first (). Advances the cursor. """ return utils.lib.zlist_next(self._p) def last(self): """ Return the item at the tail of list. If the list is empty, returns NULL. Leaves cursor pointing at the tail item, or NULL if the list is empty. """ return utils.lib.zlist_last(self._p) def head(self): """ Return first item in the list, or null, leaves the cursor """ return utils.lib.zlist_head(self._p) def tail(self): """ Return last item in the list, or null, leaves the cursor """ return utils.lib.zlist_tail(self._p) def item(self): """ Return the current item of list. If the list is empty, returns NULL. Leaves cursor pointing at the current item, or NULL if the list is empty. """ return utils.lib.zlist_item(self._p) def append(self, item): """ Append an item to the end of the list, return 0 if OK or -1 if this failed for some reason (out of memory). Note that if a duplicator has been set, this method will also duplicate the item. """ return utils.lib.zlist_append(self._p, item._p) def push(self, item): """ Push an item to the start of the list, return 0 if OK or -1 if this failed for some reason (out of memory). Note that if a duplicator has been set, this method will also duplicate the item. """ return utils.lib.zlist_push(self._p, item._p) def pop(self): """ Pop the item off the start of the list, if any """ return utils.lib.zlist_pop(self._p) def exists(self, item): """ Checks if an item already is present. Uses compare method to determine if items are equal. If the compare method is NULL the check will only compare pointers. Returns true if item is present else false. """ return utils.lib.zlist_exists(self._p, item._p) def remove(self, item): """ Remove the specified item from the list if present """ utils.lib.zlist_remove(self._p, item._p) def dup(self): """ Make a copy of list. If the list has autofree set, the copied list will duplicate all items, which must be strings. Otherwise, the list will hold pointers back to the items in the original list. If list is null, returns NULL. """ return utils.lib.zlist_dup(self._p) def purge(self): """ Purge all items from list """ utils.lib.zlist_purge(self._p) def size(self): """ Return number of items in the list """ return utils.lib.zlist_size(self._p) def sort(self, compare): """ Sort the list. If the compare function is null, sorts the list by ascending key value using a straight ASCII comparison. If you specify a compare function, this decides how items are sorted. The sort is not stable, so may reorder items with the same keys. The algorithm used is combsort, a compromise between performance and simplicity. """ utils.lib.zlist_sort(self._p, compare) def autofree(self): """ Set list for automatic item destruction; item values MUST be strings. By default a list item refers to a value held elsewhere. When you set this, each time you append or push a list item, zlist will take a copy of the string value. Then, when you destroy the list, it will free all item values automatically. If you use any other technique to allocate list values, you must free them explicitly before destroying the list. The usual technique is to pop list items and destroy them, until the list is empty. """ utils.lib.zlist_autofree(self._p) def comparefn(self, fn): """ Sets a compare function for this list. The function compares two items. It returns an integer less than, equal to, or greater than zero if the first item is found, respectively, to be less than, to match, or be greater than the second item. This function is used for sorting, removal and exists checking. """ utils.lib.zlist_comparefn(self._p, fn) def freefn(self, item, fn, at_tail): """ Set a free function for the specified list item. When the item is destroyed, the free function, if any, is called on that item. Use this when list items are dynamically allocated, to ensure that you don't have memory leaks. You can pass 'free' or NULL as a free_fn. Returns the item, or NULL if there is no such item. """ return utils.lib.zlist_freefn(self._p, item._p, fn, at_tail) def test(verbose): """ Self test of this class. """ utils.lib.zlist_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zmsg.py0000664000372000037200000002126513222211156022731 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zmsg(object): """ working with multipart messages """ def __init__(self): """ Create a new empty message object """ p = utils.lib.zmsg_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zmsg_destroy_py) def send(self_p, dest): """ Send message to destination socket, and destroy the message after sending it successfully. If the message has no frames, sends nothing but destroys the message anyhow. Nullifies the caller's reference to the message (as it is a destructor). """ return utils.lib.zmsg_send(self_p._p, dest._p) def sendm(self_p, dest): """ Send message to destination socket as part of a multipart sequence, and destroy the message after sending it successfully. Note that after a zmsg_sendm, you must call zmsg_send or another method that sends a final message part. If the message has no frames, sends nothing but destroys the message anyhow. Nullifies the caller's reference to the message (as it is a destructor). """ return utils.lib.zmsg_sendm(self_p._p, dest._p) def size(self): """ Return size of message, i.e. number of frames (0 or more). """ return utils.lib.zmsg_size(self._p) def content_size(self): """ Return total size of all frames in message. """ return utils.lib.zmsg_content_size(self._p) def routing_id(self): """ Return message routing ID, if the message came from a ZMQ_SERVER socket. Else returns zero. """ return utils.lib.zmsg_routing_id(self._p) def set_routing_id(self, routing_id): """ Set routing ID on message. This is used if/when the message is sent to a ZMQ_SERVER socket. """ utils.lib.zmsg_set_routing_id(self._p, routing_id) def prepend(self, frame_p): """ Push frame to the front of the message, i.e. before all other frames. Message takes ownership of frame, will destroy it when message is sent. Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not nullify the caller's frame reference. """ return utils.lib.zmsg_prepend(self._p, frame_p._p) def append(self, frame_p): """ Add frame to the end of the message, i.e. after all other frames. Message takes ownership of frame, will destroy it when message is sent. Returns 0 on success. Deprecates zmsg_add, which did not nullify the caller's frame reference. """ return utils.lib.zmsg_append(self._p, frame_p._p) def pop(self): """ Remove first frame from message, if any. Returns frame, or NULL. """ return utils.lib.zmsg_pop(self._p) def pushmem(self, data, size): """ Push block of memory to front of message, as a new frame. Returns 0 on success, -1 on error. """ return utils.lib.zmsg_pushmem(self._p, data, size) def addmem(self, data, size): """ Add block of memory to the end of the message, as a new frame. Returns 0 on success, -1 on error. """ return utils.lib.zmsg_addmem(self._p, data, size) def pushstr(self, string): """ Push string as new frame to front of message. Returns 0 on success, -1 on error. """ return utils.lib.zmsg_pushstr(self._p, utils.to_bytes(string)) def addstr(self, string): """ Push string as new frame to end of message. Returns 0 on success, -1 on error. """ return utils.lib.zmsg_addstr(self._p, utils.to_bytes(string)) def pushstrf(self, format, ): """ Push formatted string as new frame to front of message. Returns 0 on success, -1 on error. """ return utils.lib.zmsg_pushstrf(self._p, format, ) def addstrf(self, format, ): """ Push formatted string as new frame to end of message. Returns 0 on success, -1 on error. """ return utils.lib.zmsg_addstrf(self._p, format, ) def popstr(self): """ Pop frame off front of message, return as fresh string. If there were no more frames in the message, returns NULL. """ return utils.lib.zmsg_popstr(self._p) def addmsg(self, msg_p): """ Push encoded message as a new frame. Message takes ownership of submessage, so the original is destroyed in this call. Returns 0 on success, -1 on error. """ return utils.lib.zmsg_addmsg(self._p, msg_p._p) def popmsg(self): """ Remove first submessage from message, if any. Returns zmsg_t, or NULL if decoding was not successful. """ return utils.lib.zmsg_popmsg(self._p) def remove(self, frame): """ Remove specified frame from list, if present. Does not destroy frame. """ utils.lib.zmsg_remove(self._p, frame._p) def first(self): """ Set cursor to first frame in message. Returns frame, or NULL, if the message is empty. Use this to navigate the frames as a list. """ return utils.lib.zmsg_first(self._p) def next(self): """ Return the next frame. If there are no more frames, returns NULL. To move to the first frame call zmsg_first(). Advances the cursor. """ return utils.lib.zmsg_next(self._p) def last(self): """ Return the last frame. If there are no frames, returns NULL. """ return utils.lib.zmsg_last(self._p) def save(self, file): """ Save message to an open file, return 0 if OK, else -1. The message is saved as a series of frames, each with length and data. Note that the file is NOT guaranteed to be portable between operating systems, not versions of CZMQ. The file format is at present undocumented and liable to arbitrary change. """ return utils.lib.zmsg_save(self._p, file) def encode(self): """ Serialize multipart message to a single message frame. Use this method to send structured messages across transports that do not support multipart data. Allocates and returns a new frame containing the serialized message. To decode a serialized message frame, use zmsg_decode (). """ return utils.lib.zmsg_encode(self._p) def dup(self): """ Create copy of message, as new message object. Returns a fresh zmsg_t object. If message is null, or memory was exhausted, returns null. """ return utils.lib.zmsg_dup(self._p) def print_py(self): """ Send message to zsys log sink (may be stdout, or system facility as configured by zsys_set_logstream). """ utils.lib.zmsg_print(self._p) def eq(self, other): """ Return true if the two messages have the same number of frames and each frame in the first message is identical to the corresponding frame in the other message. As with zframe_eq, return false if either message is NULL. """ return utils.lib.zmsg_eq(self._p, other._p) def signal(self): """ Return signal value, 0 or greater, if message is a signal, -1 if not. """ return utils.lib.zmsg_signal(self._p) def is_py(self): """ Probe the supplied object, and report if it looks like a zmsg_t. """ return utils.lib.zmsg_is(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zmsg_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zdir.py0000664000372000037200000001146113222211156022716 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zdir(object): """ work with file-system directories """ def __init__(self, path, parent): """ Create a new directory item that loads in the full tree of the specified path, optionally located under some parent path. If parent is "-", then loads only the top-level directory, and does not use parent as a path. """ p = utils.lib.zdir_new(utils.to_bytes(path), utils.to_bytes(parent)) if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zdir_destroy_py) def path(self): """ Return directory path """ return utils.lib.zdir_path(self._p) def modified(self): """ Return last modification time for directory. """ return utils.lib.zdir_modified(self._p) def cursize(self): """ Return total hierarchy size, in bytes of data contained in all files in the directory tree. """ return utils.lib.zdir_cursize(self._p) def count(self): """ Return directory count """ return utils.lib.zdir_count(self._p) def list(self): """ Returns a sorted list of zfile objects; Each entry in the list is a pointer to a zfile_t item already allocated in the zdir tree. Do not destroy the original zdir tree until you are done with this list. """ return utils.lib.zdir_list(self._p) def remove(self, force): """ Remove directory, optionally including all files that it contains, at all levels. If force is false, will only remove the directory if empty. If force is true, will remove all files and all subdirectories. """ utils.lib.zdir_remove(self._p, force) def diff(older, newer, alias): """ Calculate differences between two versions of a directory tree. Returns a list of zdir_patch_t patches. Either older or newer may be null, indicating the directory is empty/absent. If alias is set, generates virtual filename (minus path, plus alias). """ return utils.lib.zdir_diff(older._p, newer._p, utils.to_bytes(alias)) def resync(self, alias): """ Return full contents of directory as a zdir_patch list. """ return utils.lib.zdir_resync(self._p, utils.to_bytes(alias)) def cache(self): """ Load directory cache; returns a hash table containing the SHA-1 digests of every file in the tree. The cache is saved between runs in .cache. """ return utils.lib.zdir_cache(self._p) def fprint(self, file, indent): """ Print contents of directory to open stream """ utils.lib.zdir_fprint(self._p, file, indent) def print_py(self, indent): """ Print contents of directory to stdout """ utils.lib.zdir_print(self._p, indent) def watch(pipe, unused): """ Create a new zdir_watch actor instance: zactor_t *watch = zactor_new (zdir_watch, NULL); Destroy zdir_watch instance: zactor_destroy (&watch); Enable verbose logging of commands and activity: zstr_send (watch, "VERBOSE"); Subscribe to changes to a directory path: zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); Unsubscribe from changes to a directory path: zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); Receive directory changes: zsock_recv (watch, "sp", &path, &patches); // Delete the received data. free (path); zlist_destroy (&patches); """ utils.lib.zdir_watch(pipe._p, unused._p) def test(verbose): """ Self test of this class. """ utils.lib.zdir_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Ziflist.py0000664000372000037200000000624013222211156023431 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Ziflist(object): """ List of network interfaces available on system """ def __init__(self): """ Get a list of network interfaces currently defined on the system """ p = utils.lib.ziflist_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.ziflist_destroy_py) def reload(self): """ Reload network interfaces from system """ utils.lib.ziflist_reload(self._p) def size(self): """ Return the number of network interfaces on system """ return utils.lib.ziflist_size(self._p) def first(self): """ Get first network interface, return NULL if there are none """ return utils.lib.ziflist_first(self._p) def next(self): """ Get next network interface, return NULL if we hit the last one """ return utils.lib.ziflist_next(self._p) def address(self): """ Return the current interface IP address as a printable string """ return utils.lib.ziflist_address(self._p) def broadcast(self): """ Return the current interface broadcast address as a printable string """ return utils.lib.ziflist_broadcast(self._p) def netmask(self): """ Return the current interface network mask as a printable string """ return utils.lib.ziflist_netmask(self._p) def print_py(self): """ Return the list of interfaces. """ utils.lib.ziflist_print(self._p) def new_ipv6(): """ Get a list of network interfaces currently defined on the system Includes IPv6 interfaces """ return utils.lib.ziflist_new_ipv6() def reload_ipv6(self): """ Reload network interfaces from system, including IPv6 """ utils.lib.ziflist_reload_ipv6(self._p) def is_ipv6(self): """ Return true if the current interface uses IPv6 """ return utils.lib.ziflist_is_ipv6(self._p) def test(verbose): """ Self test of this class. """ utils.lib.ziflist_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zstr.py0000664000372000037200000001152213222211156022746 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zstr(object): """ sending and receiving strings """ def recv(source): """ Receive C string from socket. Caller must free returned string using zstr_free(). Returns NULL if the context is being terminated or the process was interrupted. """ return utils.lib.zstr_recv(source._p) def recvx(source, string_p, ): """ Receive a series of strings (until NULL) from multipart data. Each string is allocated and filled with string data; if there are not enough frames, unallocated strings are set to NULL. Returns -1 if the message could not be read, else returns the number of strings filled, zero or more. Free each returned string using zstr_free(). If not enough strings are provided, remaining multipart frames in the message are dropped. """ return utils.lib.zstr_recvx(source._p, utils.to_bytes(string_p), ) def recv_compress(source): """ De-compress and receive C string from socket, received as a message with two frames: size of the uncompressed string, and the string itself. Caller must free returned string using zstr_free(). Returns NULL if the context is being terminated or the process was interrupted. """ return utils.lib.zstr_recv_compress(source._p) def send(dest, string): """ Send a C string to a socket, as a frame. The string is sent without trailing null byte; to read this you can use zstr_recv, or a similar method that adds a null terminator on the received string. String may be NULL, which is sent as "". """ return utils.lib.zstr_send(dest._p, utils.to_bytes(string)) def sendm(dest, string): """ Send a C string to a socket, as zstr_send(), with a MORE flag, so that you can send further strings in the same multi-part message. """ return utils.lib.zstr_sendm(dest._p, utils.to_bytes(string)) def sendf(dest, format, ): """ Send a formatted string to a socket. Note that you should NOT use user-supplied strings in the format (they may contain '%' which will create security holes). """ return utils.lib.zstr_sendf(dest._p, format, ) def sendfm(dest, format, ): """ Send a formatted string to a socket, as for zstr_sendf(), with a MORE flag, so that you can send further strings in the same multi-part message. """ return utils.lib.zstr_sendfm(dest._p, format, ) def sendx(dest, string, ): """ Send a series of strings (until NULL) as multipart data Returns 0 if the strings could be sent OK, or -1 on error. """ return utils.lib.zstr_sendx(dest._p, utils.to_bytes(string), ) def send_compress(dest, string): """ Compress and send a C string to a socket, as a message with two frames: size of the uncompressed string, and the string itself. The string is sent without trailing null byte; to read this you can use zstr_recv_compress, or a similar method that de-compresses and adds a null terminator on the received string. """ return utils.lib.zstr_send_compress(dest._p, utils.to_bytes(string)) def sendm_compress(dest, string): """ Compress and send a C string to a socket, as zstr_send_compress(), with a MORE flag, so that you can send further strings in the same multi-part message. """ return utils.lib.zstr_sendm_compress(dest._p, utils.to_bytes(string)) def str(source): """ Accepts a void pointer and returns a fresh character string. If source is null, returns an empty string. """ return utils.lib.zstr_str(source._p) def free(string_p): """ Free a provided string, and nullify the parent pointer. Safe to call on a null pointer. """ utils.lib.zstr_free(utils.to_bytes(string_p)) def test(verbose): """ Self test of this class. """ utils.lib.zstr_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zpoller.py0000664000372000037200000000735713222211156023446 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zpoller(object): """ event-driven reactor """ def __init__(self, reader, ): """ Create new poller, specifying zero or more readers. The list of readers ends in a NULL. Each reader can be a zsock_t instance, a zactor_t instance, a libzmq socket (void *), or a file handle. """ p = utils.lib.zpoller_new(reader._p, ) if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zpoller_destroy_py) def add(self, reader): """ Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. """ return utils.lib.zpoller_add(self._p, reader._p) def remove(self, reader): """ Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader must have been passed during construction, or in an zpoller_add () call. """ return utils.lib.zpoller_remove(self._p, reader._p) def set_nonstop(self, nonstop): """ By default the poller stops if the process receives a SIGINT or SIGTERM signal. This makes it impossible to shut-down message based architectures like zactors. This method lets you switch off break handling. The default nonstop setting is off (false). """ utils.lib.zpoller_set_nonstop(self._p, nonstop) def wait(self, timeout): """ Poll the registered readers for I/O, return first reader that has input. The reader will be a libzmq void * socket, or a zsock_t or zactor_t instance as specified in zpoller_new/zpoller_add. The timeout should be zero or greater, or -1 to wait indefinitely. Socket priority is defined by their order in the poll list. If you need a balanced poll, use the low level zmq_poll method directly. If the poll call was interrupted (SIGINT), or the ZMQ context was destroyed, or the timeout expired, returns NULL. You can test the actual exit condition by calling zpoller_expired () and zpoller_terminated (). The timeout is in msec. """ return utils.lib.zpoller_wait(self._p, timeout) def expired(self): """ Return true if the last zpoller_wait () call ended because the timeout expired, without any error. """ return utils.lib.zpoller_expired(self._p) def terminated(self): """ Return true if the last zpoller_wait () call ended because the process was interrupted, or the parent context was destroyed. """ return utils.lib.zpoller_terminated(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zpoller_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zhashx.py0000664000372000037200000002451213222211156023254 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zhashx(object): """ extended generic type-free hash container """ def __init__(self): """ Create a new, empty hash container """ p = utils.lib.zhashx_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zhashx_destroy_py) def insert(self, key, item): """ Insert item into hash table with specified key and item. If key is already present returns -1 and leaves existing item unchanged Returns 0 on success. """ return utils.lib.zhashx_insert(self._p, key._p, item._p) def update(self, key, item): """ Update or insert item into hash table with specified key and item. If the key is already present, destroys old item and inserts new one. If you set a container item destructor, this is called on the old value. If the key was not already present, inserts a new item. Sets the hash cursor to the new item. """ utils.lib.zhashx_update(self._p, key._p, item._p) def delete(self, key): """ Remove an item specified by key from the hash table. If there was no such item, this function does nothing. """ utils.lib.zhashx_delete(self._p, key._p) def purge(self): """ Delete all items from the hash table. If the key destructor is set, calls it on every key. If the item destructor is set, calls it on every item. """ utils.lib.zhashx_purge(self._p) def lookup(self, key): """ Return the item at the specified key, or null """ return utils.lib.zhashx_lookup(self._p, key._p) def rename(self, old_key, new_key): """ Reindexes an item from an old key to a new key. If there was no such item, does nothing. Returns 0 if successful, else -1. """ return utils.lib.zhashx_rename(self._p, old_key._p, new_key._p) def freefn(self, key, free_fn): """ Set a free function for the specified hash table item. When the item is destroyed, the free function, if any, is called on that item. Use this when hash items are dynamically allocated, to ensure that you don't have memory leaks. You can pass 'free' or NULL as a free_fn. Returns the item, or NULL if there is no such item. """ return utils.lib.zhashx_freefn(self._p, key._p, free_fn) def size(self): """ Return the number of keys/items in the hash table """ return utils.lib.zhashx_size(self._p) def keys(self): """ Return a zlistx_t containing the keys for the items in the table. Uses the key_duplicator to duplicate all keys and sets the key_destructor as destructor for the list. """ return utils.lib.zhashx_keys(self._p) def values(self): """ Return a zlistx_t containing the values for the items in the table. Uses the duplicator to duplicate all items and sets the destructor as destructor for the list. """ return utils.lib.zhashx_values(self._p) def first(self): """ Simple iterator; returns first item in hash table, in no given order, or NULL if the table is empty. This method is simpler to use than the foreach() method, which is deprecated. To access the key for this item use zhashx_cursor(). NOTE: do NOT modify the table while iterating. """ return utils.lib.zhashx_first(self._p) def next(self): """ Simple iterator; returns next item in hash table, in no given order, or NULL if the last item was already returned. Use this together with zhashx_first() to process all items in a hash table. If you need the items in sorted order, use zhashx_keys() and then zlistx_sort(). To access the key for this item use zhashx_cursor(). NOTE: do NOT modify the table while iterating. """ return utils.lib.zhashx_next(self._p) def cursor(self): """ After a successful first/next method, returns the key for the item that was returned. This is a constant string that you may not modify or deallocate, and which lasts as long as the item in the hash. After an unsuccessful first/next, returns NULL. """ return utils.lib.zhashx_cursor(self._p) def comment(self, format, ): """ Add a comment to hash table before saving to disk. You can add as many comment lines as you like. These comment lines are discarded when loading the file. If you use a null format, all comments are deleted. """ utils.lib.zhashx_comment(self._p, format, ) def save(self, filename): """ Save hash table to a text file in name=value format. Hash values must be printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file error occurred. """ return utils.lib.zhashx_save(self._p, utils.to_bytes(filename)) def load(self, filename): """ Load hash table from a text file in name=value format; hash table must already exist. Hash values must printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file was not readable. """ return utils.lib.zhashx_load(self._p, utils.to_bytes(filename)) def refresh(self): """ When a hash table was loaded from a file by zhashx_load, this method will reload the file if it has been modified since, and is "stable", i.e. not still changing. Returns 0 if OK, -1 if there was an error reloading the file. """ return utils.lib.zhashx_refresh(self._p) def pack(self): """ Serialize hash table to a binary frame that can be sent in a message. The packed format is compatible with the 'dictionary' type defined in http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: ; A list of name/value pairs dictionary = dict-count *( dict-name dict-value ) dict-count = number-4 dict-value = longstr dict-name = string ; Strings are always length + text contents longstr = number-4 *VCHAR string = number-1 *VCHAR ; Numbers are unsigned integers in network byte order number-1 = 1OCTET number-4 = 4OCTET Comments are not included in the packed data. Item values MUST be strings. """ return utils.lib.zhashx_pack(self._p) def pack_own(self, serializer): """ Same as pack but uses a user-defined serializer function to convert items into longstr. """ return utils.lib.zhashx_pack_own(self._p, serializer) def dup(self): """ Make a copy of the list; items are duplicated if you set a duplicator for the list, otherwise not. Copying a null reference returns a null reference. Note that this method's behavior changed slightly for CZMQ v3.x, as it does not set nor respect autofree. It does however let you duplicate any hash table safely. The old behavior is in zhashx_dup_v2. """ return utils.lib.zhashx_dup(self._p) def set_destructor(self, destructor): """ Set a user-defined deallocator for hash items; by default items are not freed when the hash is destroyed. """ utils.lib.zhashx_set_destructor(self._p, destructor) def set_duplicator(self, duplicator): """ Set a user-defined duplicator for hash items; by default items are not copied when the hash is duplicated. """ utils.lib.zhashx_set_duplicator(self._p, duplicator) def set_key_destructor(self, destructor): """ Set a user-defined deallocator for keys; by default keys are freed when the hash is destroyed using free(). """ utils.lib.zhashx_set_key_destructor(self._p, destructor) def set_key_duplicator(self, duplicator): """ Set a user-defined duplicator for keys; by default keys are duplicated using strdup. """ utils.lib.zhashx_set_key_duplicator(self._p, duplicator) def set_key_comparator(self, comparator): """ Set a user-defined comparator for keys; by default keys are compared using strcmp. The callback function should return zero (0) on matching items. """ utils.lib.zhashx_set_key_comparator(self._p, comparator) def set_key_hasher(self, hasher): """ Set a user-defined hash function for keys; by default keys are hashed by a modified Bernstein hashing function. """ utils.lib.zhashx_set_key_hasher(self._p, hasher) def dup_v2(self): """ Make copy of hash table; if supplied table is null, returns null. Does not copy items themselves. Rebuilds new table so may be slow on very large tables. NOTE: only works with item values that are strings since there's no other way to know how to duplicate the item value. """ return utils.lib.zhashx_dup_v2(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zhashx_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zclock.py0000664000372000037200000000412213222211156023227 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zclock(object): """ millisecond clocks and delays """ def sleep(msecs): """ Sleep for a number of milliseconds """ utils.lib.zclock_sleep(msecs) def time(): """ Return current system clock as milliseconds. Note that this clock can jump backwards (if the system clock is changed) so is unsafe to use for timers and time offsets. Use zclock_mono for that instead. """ return utils.lib.zclock_time() def mono(): """ Return current monotonic clock in milliseconds. Use this when you compute time offsets. The monotonic clock is not affected by system changes and so will never be reset backwards, unlike a system clock. """ return utils.lib.zclock_mono() def usecs(): """ Return current monotonic clock in microseconds. Use this when you compute time offsets. The monotonic clock is not affected by system changes and so will never be reset backwards, unlike a system clock. """ return utils.lib.zclock_usecs() def timestr(): """ Return formatted date/time as fresh string. Free using zstr_free(). """ return utils.lib.zclock_timestr() def test(verbose): """ Self test of this class. """ utils.lib.zclock_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/utils.py0000664000372000037200000000330313222211156023142 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ try: from . import native lib = native.lib ffi = native.ffi except ImportError: from . import dlopen lib = dlopen.lib ffi = dlopen.ffi def rebind (_lib, _ffi): """Rebind Lib and CompiledFFi objects for given package. Lib object MUST expose all functions required by the classes. This is default for zproject based projects""" global lib global ffi lib = _lib ffi = _ffi try: text_type = unicode # Python 2 binary_type = str except NameError: text_type = str # Python 3 binary_type = bytes def to_bytes(s): return s if isinstance(s, binary_type) else text_type(s).encode("utf-8") def to_unicode(s): return s if isinstance(s, text_type) else binary_type(s).decode("utf-8") def to_strings (s): """Convert Python native list types to zlist_t of strings""" if issubclass (s.__class__, (list, set, frozenset, tuple)): foo = lib.zlist_new () lib.zlist_autofree (foo) for item in s: lib.zlist_append (foo, to_bytes (item)) return foo return None ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zchunk.py0000664000372000037200000001450513222211156023252 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zchunk(object): """ work with memory chunks """ def __init__(self, data, size): """ Create a new chunk of the specified size. If you specify the data, it is copied into the chunk. If you do not specify the data, the chunk is allocated and left empty, and you can then add data using zchunk_append. """ p = utils.lib.zchunk_new(data, size) if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zchunk_destroy_py) def resize(self, size): """ Resizes chunk max_size as requested; chunk_cur size is set to zero """ utils.lib.zchunk_resize(self._p, size) def size(self): """ Return chunk cur size """ return utils.lib.zchunk_size(self._p) def max_size(self): """ Return chunk max size """ return utils.lib.zchunk_max_size(self._p) def data(self): """ Return chunk data """ return utils.lib.zchunk_data(self._p) def set(self, data, size): """ Set chunk data from user-supplied data; truncate if too large. Data may be null. Returns actual size of chunk """ return utils.lib.zchunk_set(self._p, data, size) def fill(self, filler, size): """ Fill chunk data from user-supplied octet """ return utils.lib.zchunk_fill(self._p, filler, size) def append(self, data, size): """ Append user-supplied data to chunk, return resulting chunk size. If the data would exceeded the available space, it is truncated. If you want to grow the chunk to accommodate new data, use the zchunk_extend method. """ return utils.lib.zchunk_append(self._p, data, size) def extend(self, data, size): """ Append user-supplied data to chunk, return resulting chunk size. If the data would exceeded the available space, the chunk grows in size. """ return utils.lib.zchunk_extend(self._p, data, size) def consume(self, source): """ Copy as much data from 'source' into the chunk as possible; returns the new size of chunk. If all data from 'source' is used, returns exhausted on the source chunk. Source can be consumed as many times as needed until it is exhausted. If source was already exhausted, does not change chunk. """ return utils.lib.zchunk_consume(self._p, source._p) def exhausted(self): """ Returns true if the chunk was exhausted by consume methods, or if the chunk has a size of zero. """ return utils.lib.zchunk_exhausted(self._p) def read(handle, bytes): """ Read chunk from an open file descriptor """ return utils.lib.zchunk_read(handle, bytes) def write(self, handle): """ Write chunk to an open file descriptor """ return utils.lib.zchunk_write(self._p, handle) def slurp(filename, maxsize): """ Try to slurp an entire file into a chunk. Will read up to maxsize of the file. If maxsize is 0, will attempt to read the entire file and fail with an assertion if that cannot fit into memory. Returns a new chunk containing the file data, or NULL if the file could not be read. """ return utils.lib.zchunk_slurp(utils.to_bytes(filename), maxsize) def dup(self): """ Create copy of chunk, as new chunk object. Returns a fresh zchunk_t object, or null if there was not enough heap memory. If chunk is null, returns null. """ return utils.lib.zchunk_dup(self._p) def strhex(self): """ Return chunk data encoded as printable hex string. Caller must free string when finished with it. """ return utils.lib.zchunk_strhex(self._p) def strdup(self): """ Return chunk data copied into freshly allocated string Caller must free string when finished with it. """ return utils.lib.zchunk_strdup(self._p) def streq(self, string): """ Return TRUE if chunk body is equal to string, excluding terminator """ return utils.lib.zchunk_streq(self._p, utils.to_bytes(string)) def pack(self): """ Transform zchunk into a zframe that can be sent in a message. """ return utils.lib.zchunk_pack(self._p) def unpack(frame): """ Transform a zframe into a zchunk. """ return utils.lib.zchunk_unpack(frame._p) def digest(self): """ Calculate SHA1 digest for chunk, using zdigest class. """ return utils.lib.zchunk_digest(self._p) def fprint(self, file): """ Dump chunk to FILE stream, for debugging and tracing. """ utils.lib.zchunk_fprint(self._p, file) def print_py(self): """ Dump message to stderr, for debugging and tracing. See zchunk_fprint for details """ utils.lib.zchunk_print(self._p) def is_py(self): """ Probe the supplied object, and report if it looks like a zchunk_t. """ return utils.lib.zchunk_is(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zchunk_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zcert.py0000664000372000037200000001053713222211156023100 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zcert(object): """ work with CURVE security certificates """ def __init__(self): """ Create and initialize a new certificate in memory """ p = utils.lib.zcert_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zcert_destroy_py) def public_key(self): """ Return public part of key pair as 32-byte binary string """ return utils.lib.zcert_public_key(self._p) def secret_key(self): """ Return secret part of key pair as 32-byte binary string """ return utils.lib.zcert_secret_key(self._p) def public_txt(self): """ Return public part of key pair as Z85 armored string """ return utils.lib.zcert_public_txt(self._p) def secret_txt(self): """ Return secret part of key pair as Z85 armored string """ return utils.lib.zcert_secret_txt(self._p) def set_meta(self, name, format, ): """ Set certificate metadata from formatted string. """ utils.lib.zcert_set_meta(self._p, utils.to_bytes(name), format, ) def unset_meta(self, name): """ Unset certificate metadata. """ utils.lib.zcert_unset_meta(self._p, utils.to_bytes(name)) def meta(self, name): """ Get metadata value from certificate; if the metadata value doesn't exist, returns NULL. """ return utils.lib.zcert_meta(self._p, utils.to_bytes(name)) def meta_keys(self): """ Get list of metadata fields from certificate. Caller is responsible for destroying list. Caller should not modify the values of list items. """ return utils.lib.zcert_meta_keys(self._p) def save(self, filename): """ Save full certificate (public + secret) to file for persistent storage This creates one public file and one secret file (filename + "_secret"). """ return utils.lib.zcert_save(self._p, utils.to_bytes(filename)) def save_public(self, filename): """ Save public certificate only to file for persistent storage """ return utils.lib.zcert_save_public(self._p, utils.to_bytes(filename)) def save_secret(self, filename): """ Save secret certificate only to file for persistent storage """ return utils.lib.zcert_save_secret(self._p, utils.to_bytes(filename)) def apply(self, socket): """ Apply certificate to socket, i.e. use for CURVE security on socket. If certificate was loaded from public file, the secret key will be undefined, and this certificate will not work successfully. """ utils.lib.zcert_apply(self._p, socket._p) def dup(self): """ Return copy of certificate; if certificate is NULL or we exhausted heap memory, returns NULL. """ return utils.lib.zcert_dup(self._p) def eq(self, compare): """ Return true if two certificates have the same keys """ return utils.lib.zcert_eq(self._p, compare._p) def print_py(self): """ Print certificate contents to stdout """ utils.lib.zcert_print(self._p) def test(verbose): """ Self test of this class """ utils.lib.zcert_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zarmour.py0000664000372000037200000000736513222211156023455 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zarmour(object): """ armoured text encoding and decoding """ def __init__(self): """ Create a new zarmour """ p = utils.lib.zarmour_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zarmour_destroy_py) def encode(self, data, size): """ Encode a stream of bytes into an armoured string. Returns the armoured string, or NULL if there was insufficient memory available to allocate a new string. """ return utils.lib.zarmour_encode(self._p, data, size) def decode(self, data): """ Decode an armoured string into a chunk. The decoded output is null-terminated, so it may be treated as a string, if that's what it was prior to encoding. """ return utils.lib.zarmour_decode(self._p, utils.to_bytes(data)) def mode(self): """ Get the mode property. """ return utils.lib.zarmour_mode(self._p) def mode_str(self): """ Get printable string for mode. """ return utils.lib.zarmour_mode_str(self._p) def set_mode(self, mode): """ Set the mode property. """ utils.lib.zarmour_set_mode(self._p, mode) def pad(self): """ Return true if padding is turned on. """ return utils.lib.zarmour_pad(self._p) def set_pad(self, pad): """ Turn padding on or off. Default is on. """ utils.lib.zarmour_set_pad(self._p, pad) def pad_char(self): """ Get the padding character. """ return utils.lib.zarmour_pad_char(self._p) def set_pad_char(self, pad_char): """ Set the padding character. """ utils.lib.zarmour_set_pad_char(self._p, pad_char._p) def line_breaks(self): """ Return if splitting output into lines is turned on. Default is off. """ return utils.lib.zarmour_line_breaks(self._p) def set_line_breaks(self, line_breaks): """ Turn splitting output into lines on or off. """ utils.lib.zarmour_set_line_breaks(self._p, line_breaks) def line_length(self): """ Get the line length used for splitting lines. """ return utils.lib.zarmour_line_length(self._p) def set_line_length(self, line_length): """ Set the line length used for splitting lines. """ utils.lib.zarmour_set_line_length(self._p, line_length) def print_py(self): """ Print properties of object """ utils.lib.zarmour_print(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zarmour_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zuuid.py0000664000372000037200000000606613222211156023113 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ import utils from . import destructors libczmq_destructors = destructors.lib class Zuuid(object): """ UUID support class """ def __init__(self): """ Create a new UUID object. """ p = utils.lib.zuuid_new() if p == utils.ffi.NULL: raise MemoryError("Could not allocate person") # ffi.gc returns a copy of the cdata object which will have the # destructor called when the Python object is GC'd: # https://cffi.readthedocs.org/en/latest/using.html#ffi-interface self._p = utils.ffi.gc(p, libczmq_destructors.zuuid_destroy_py) def set(self, source): """ Set UUID to new supplied ZUUID_LEN-octet value. """ utils.lib.zuuid_set(self._p, source) def set_str(self, source): """ Set UUID to new supplied string value skipping '-' and '{' '}' optional delimiters. Return 0 if OK, else returns -1. """ return utils.lib.zuuid_set_str(self._p, utils.to_bytes(source)) def data(self): """ Return UUID binary data. """ return utils.lib.zuuid_data(self._p) def size(self): """ Return UUID binary size """ return utils.lib.zuuid_size(self._p) def str(self): """ Returns UUID as string """ return utils.lib.zuuid_str(self._p) def str_canonical(self): """ Return UUID in the canonical string format: 8-4-4-4-12, in lower case. Caller does not modify or free returned value. See http://en.wikipedia.org/wiki/Universally_unique_identifier """ return utils.lib.zuuid_str_canonical(self._p) def export(self, target): """ Store UUID blob in target array """ utils.lib.zuuid_export(self._p, target) def eq(self, compare): """ Check if UUID is same as supplied value """ return utils.lib.zuuid_eq(self._p, compare) def neq(self, compare): """ Check if UUID is different from supplied value """ return utils.lib.zuuid_neq(self._p, compare) def dup(self): """ Make copy of UUID object; if uuid is null, or memory was exhausted, returns null. """ return utils.lib.zuuid_dup(self._p) def test(verbose): """ Self test of this class. """ utils.lib.zuuid_test(verbose) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/bindings/python_cffi/czmq_cffi/dlopen.py0000664000372000037200000000211013222211156023256 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ from __future__ import print_function import os import sys from ctypes.util import find_library import cffi ffi = cffi.FFI() try: # If LD_LIBRARY_PATH or your OSs equivalent is set, this is the only way to # load the library. If we use find_library below, we get the wrong result. if os.name == 'posix': if sys.platform == 'darwin': libpath = 'libczmq.4.dylib' else: libpath = 'libczmq.so.4' elif os.name == 'nt': libpath = 'libczmq.dll' lib = ffi.dlopen(libpath) except OSError: libpath = find_library("czmq") if not libpath: raise ImportError("Unable to find libczmq") lib = ffi.dlopen(libpath) from czmq_cffi.cdefs import czmq_cdefs for cdef in czmq_cdefs: ffi.cdef (cdef) czmq-4.1.0/api/0000775000372000037200000000000013222211351014131 5ustar00travistravis00000000000000czmq-4.1.0/api/zsock_option.api0000664000372000037200000006343113222211156017357 0ustar00travistravis00000000000000 Get socket option `heartbeat_ivl`. Available from libzmq 4.2.0. Set socket option `heartbeat_ivl`. Available from libzmq 4.2.0. Get socket option `heartbeat_ttl`. Available from libzmq 4.2.0. Set socket option `heartbeat_ttl`. Available from libzmq 4.2.0. Get socket option `heartbeat_timeout`. Available from libzmq 4.2.0. Set socket option `heartbeat_timeout`. Available from libzmq 4.2.0. Get socket option `use_fd`. Available from libzmq 4.2.0. Set socket option `use_fd`. Available from libzmq 4.2.0. Set socket option `xpub_manual`. Available from libzmq 4.2.0. Set socket option `xpub_welcome_msg`. Available from libzmq 4.2.0. Set socket option `stream_notify`. Available from libzmq 4.2.0. Get socket option `invert_matching`. Available from libzmq 4.2.0. Set socket option `invert_matching`. Available from libzmq 4.2.0. Set socket option `xpub_verboser`. Available from libzmq 4.2.0. Get socket option `connect_timeout`. Available from libzmq 4.2.0. Set socket option `connect_timeout`. Available from libzmq 4.2.0. Get socket option `tcp_maxrt`. Available from libzmq 4.2.0. Set socket option `tcp_maxrt`. Available from libzmq 4.2.0. Get socket option `thread_safe`. Available from libzmq 4.2.0. Get socket option `multicast_maxtpdu`. Available from libzmq 4.2.0. Set socket option `multicast_maxtpdu`. Available from libzmq 4.2.0. Get socket option `vmci_buffer_size`. Available from libzmq 4.2.0. Set socket option `vmci_buffer_size`. Available from libzmq 4.2.0. Get socket option `vmci_buffer_min_size`. Available from libzmq 4.2.0. Set socket option `vmci_buffer_min_size`. Available from libzmq 4.2.0. Get socket option `vmci_buffer_max_size`. Available from libzmq 4.2.0. Set socket option `vmci_buffer_max_size`. Available from libzmq 4.2.0. Get socket option `vmci_connect_timeout`. Available from libzmq 4.2.0. Set socket option `vmci_connect_timeout`. Available from libzmq 4.2.0. Get socket option `tos`. Available from libzmq 4.1.0. Set socket option `tos`. Available from libzmq 4.1.0. Set socket option `router_handover`. Available from libzmq 4.1.0. Set socket option `connect_rid`. Available from libzmq 4.1.0. Set socket option `connect_rid` from 32-octet binary Available from libzmq 4.1.0. Get socket option `handshake_ivl`. Available from libzmq 4.1.0. Set socket option `handshake_ivl`. Available from libzmq 4.1.0. Get socket option `socks_proxy`. Available from libzmq 4.1.0. Set socket option `socks_proxy`. Available from libzmq 4.1.0. Set socket option `xpub_nodrop`. Available from libzmq 4.1.0. Set socket option `router_mandatory`. Available from libzmq 4.0.0. Set socket option `probe_router`. Available from libzmq 4.0.0. Set socket option `req_relaxed`. Available from libzmq 4.0.0. Set socket option `req_correlate`. Available from libzmq 4.0.0. Set socket option `conflate`. Available from libzmq 4.0.0. Get socket option `zap_domain`. Available from libzmq 4.0.0. Set socket option `zap_domain`. Available from libzmq 4.0.0. Get socket option `mechanism`. Available from libzmq 4.0.0. Get socket option `plain_server`. Available from libzmq 4.0.0. Set socket option `plain_server`. Available from libzmq 4.0.0. Get socket option `plain_username`. Available from libzmq 4.0.0. Set socket option `plain_username`. Available from libzmq 4.0.0. Get socket option `plain_password`. Available from libzmq 4.0.0. Set socket option `plain_password`. Available from libzmq 4.0.0. Get socket option `curve_server`. Available from libzmq 4.0.0. Set socket option `curve_server`. Available from libzmq 4.0.0. Get socket option `curve_publickey`. Available from libzmq 4.0.0. Set socket option `curve_publickey`. Available from libzmq 4.0.0. Set socket option `curve_publickey` from 32-octet binary Available from libzmq 4.0.0. Get socket option `curve_secretkey`. Available from libzmq 4.0.0. Set socket option `curve_secretkey`. Available from libzmq 4.0.0. Set socket option `curve_secretkey` from 32-octet binary Available from libzmq 4.0.0. Get socket option `curve_serverkey`. Available from libzmq 4.0.0. Set socket option `curve_serverkey`. Available from libzmq 4.0.0. Set socket option `curve_serverkey` from 32-octet binary Available from libzmq 4.0.0. Get socket option `gssapi_server`. Available from libzmq 4.0.0. Set socket option `gssapi_server`. Available from libzmq 4.0.0. Get socket option `gssapi_plaintext`. Available from libzmq 4.0.0. Set socket option `gssapi_plaintext`. Available from libzmq 4.0.0. Get socket option `gssapi_principal`. Available from libzmq 4.0.0. Set socket option `gssapi_principal`. Available from libzmq 4.0.0. Get socket option `gssapi_service_principal`. Available from libzmq 4.0.0. Set socket option `gssapi_service_principal`. Available from libzmq 4.0.0. Get socket option `ipv6`. Available from libzmq 4.0.0. Set socket option `ipv6`. Available from libzmq 4.0.0. Get socket option `immediate`. Available from libzmq 4.0.0. Set socket option `immediate`. Available from libzmq 4.0.0. Get socket option `sndhwm`. Available from libzmq 3.0.0. Set socket option `sndhwm`. Available from libzmq 3.0.0. Get socket option `rcvhwm`. Available from libzmq 3.0.0. Set socket option `rcvhwm`. Available from libzmq 3.0.0. Get socket option `maxmsgsize`. Available from libzmq 3.0.0. Set socket option `maxmsgsize`. Available from libzmq 3.0.0. Get socket option `multicast_hops`. Available from libzmq 3.0.0. Set socket option `multicast_hops`. Available from libzmq 3.0.0. Set socket option `xpub_verbose`. Available from libzmq 3.0.0. Get socket option `tcp_keepalive`. Available from libzmq 3.0.0. Set socket option `tcp_keepalive`. Available from libzmq 3.0.0. Get socket option `tcp_keepalive_idle`. Available from libzmq 3.0.0. Set socket option `tcp_keepalive_idle`. Available from libzmq 3.0.0. Get socket option `tcp_keepalive_cnt`. Available from libzmq 3.0.0. Set socket option `tcp_keepalive_cnt`. Available from libzmq 3.0.0. Get socket option `tcp_keepalive_intvl`. Available from libzmq 3.0.0. Set socket option `tcp_keepalive_intvl`. Available from libzmq 3.0.0. Get socket option `tcp_accept_filter`. Available from libzmq 3.0.0. Set socket option `tcp_accept_filter`. Available from libzmq 3.0.0. Get socket option `last_endpoint`. Available from libzmq 3.0.0. Set socket option `router_raw`. Available from libzmq 3.0.0. Get socket option `ipv4only`. Available from libzmq 3.0.0. Set socket option `ipv4only`. Available from libzmq 3.0.0. Set socket option `delay_attach_on_connect`. Available from libzmq 3.0.0. Get socket option `hwm`. Available from libzmq 2.0.0 to 3.0.0. Set socket option `hwm`. Available from libzmq 2.0.0 to 3.0.0. Get socket option `swap`. Available from libzmq 2.0.0 to 3.0.0. Set socket option `swap`. Available from libzmq 2.0.0 to 3.0.0. Get socket option `affinity`. Available from libzmq 2.0.0. Set socket option `affinity`. Available from libzmq 2.0.0. Get socket option `identity`. Available from libzmq 2.0.0. Set socket option `identity`. Available from libzmq 2.0.0. Get socket option `rate`. Available from libzmq 2.0.0. Set socket option `rate`. Available from libzmq 2.0.0. Get socket option `recovery_ivl`. Available from libzmq 2.0.0. Set socket option `recovery_ivl`. Available from libzmq 2.0.0. Get socket option `recovery_ivl_msec`. Available from libzmq 2.0.0 to 3.0.0. Set socket option `recovery_ivl_msec`. Available from libzmq 2.0.0 to 3.0.0. Get socket option `mcast_loop`. Available from libzmq 2.0.0 to 3.0.0. Set socket option `mcast_loop`. Available from libzmq 2.0.0 to 3.0.0. Get socket option `rcvtimeo`. Available from libzmq 2.2.0. Set socket option `rcvtimeo`. Available from libzmq 2.2.0. Get socket option `sndtimeo`. Available from libzmq 2.2.0. Set socket option `sndtimeo`. Available from libzmq 2.2.0. Get socket option `sndbuf`. Available from libzmq 2.0.0. Set socket option `sndbuf`. Available from libzmq 2.0.0. Get socket option `rcvbuf`. Available from libzmq 2.0.0. Set socket option `rcvbuf`. Available from libzmq 2.0.0. Get socket option `linger`. Available from libzmq 2.0.0. Set socket option `linger`. Available from libzmq 2.0.0. Get socket option `reconnect_ivl`. Available from libzmq 2.0.0. Set socket option `reconnect_ivl`. Available from libzmq 2.0.0. Get socket option `reconnect_ivl_max`. Available from libzmq 2.0.0. Set socket option `reconnect_ivl_max`. Available from libzmq 2.0.0. Get socket option `backlog`. Available from libzmq 2.0.0. Set socket option `backlog`. Available from libzmq 2.0.0. Set socket option `subscribe`. Available from libzmq 2.0.0. Set socket option `unsubscribe`. Available from libzmq 2.0.0. Get socket option `type`. Available from libzmq 2.0.0. Get socket option `rcvmore`. Available from libzmq 2.0.0. Get socket option `fd`. Available from libzmq 2.0.0. Get socket option `events`. Available from libzmq 2.0.0. czmq-4.1.0/api/zlist.api0000664000372000037200000001431413222211156015777 0ustar00travistravis00000000000000 simple generic list container Comparison function e.g. for sorting and removing. Callback function for zlist_freefn method Create a new list container Destroy a list container Return the item at the head of list. If the list is empty, returns NULL. Leaves cursor pointing at the head item, or NULL if the list is empty. Return the next item. If the list is empty, returns NULL. To move to the start of the list call zlist_first (). Advances the cursor. Return the item at the tail of list. If the list is empty, returns NULL. Leaves cursor pointing at the tail item, or NULL if the list is empty. Return first item in the list, or null, leaves the cursor Return last item in the list, or null, leaves the cursor Return the current item of list. If the list is empty, returns NULL. Leaves cursor pointing at the current item, or NULL if the list is empty. Append an item to the end of the list, return 0 if OK or -1 if this failed for some reason (out of memory). Note that if a duplicator has been set, this method will also duplicate the item. Push an item to the start of the list, return 0 if OK or -1 if this failed for some reason (out of memory). Note that if a duplicator has been set, this method will also duplicate the item. Pop the item off the start of the list, if any Checks if an item already is present. Uses compare method to determine if items are equal. If the compare method is NULL the check will only compare pointers. Returns true if item is present else false. Remove the specified item from the list if present Make a copy of list. If the list has autofree set, the copied list will duplicate all items, which must be strings. Otherwise, the list will hold pointers back to the items in the original list. If list is null, returns NULL. Purge all items from list Return number of items in the list Sort the list. If the compare function is null, sorts the list by ascending key value using a straight ASCII comparison. If you specify a compare function, this decides how items are sorted. The sort is not stable, so may reorder items with the same keys. The algorithm used is combsort, a compromise between performance and simplicity. Set list for automatic item destruction; item values MUST be strings. By default a list item refers to a value held elsewhere. When you set this, each time you append or push a list item, zlist will take a copy of the string value. Then, when you destroy the list, it will free all item values automatically. If you use any other technique to allocate list values, you must free them explicitly before destroying the list. The usual technique is to pop list items and destroy them, until the list is empty. Sets a compare function for this list. The function compares two items. It returns an integer less than, equal to, or greater than zero if the first item is found, respectively, to be less than, to match, or be greater than the second item. This function is used for sorting, removal and exists checking. Set a free function for the specified list item. When the item is destroyed, the free function, if any, is called on that item. Use this when list items are dynamically allocated, to ensure that you don't have memory leaks. You can pass 'free' or NULL as a free_fn. Returns the item, or NULL if there is no such item. czmq-4.1.0/api/zactor.api0000664000372000037200000000562213222211156016136 0ustar00travistravis00000000000000 provides a simple actor framework Actors get a pipe and arguments from caller Function to be called on zactor_destroy. Default behavior is to send zmsg_t with string "$TERM" in a first frame. An example - to send $KTHXBAI string if (zstr_send (self->pipe, "$KTHXBAI") == 0) zsock_wait (self->pipe); Create a new actor passing arbitrary arguments reference. Destroy an actor. Send a zmsg message to the actor, take ownership of the message and destroy when it has been sent. Receive a zmsg message from the actor. Returns NULL if the actor was interrupted before the message could be received, or if there was a timeout on the actor. Probe the supplied object, and report if it looks like a zactor_t. Probe the supplied reference. If it looks like a zactor_t instance, return the underlying libzmq actor handle; else if it looks like a libzmq actor handle, return the supplied value. Return the actor's zsock handle. Use this when you absolutely need to work with the zsock instance rather than the actor. Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. czmq-4.1.0/api/zclock.api0000664000372000037200000000334013222211156016114 0ustar00travistravis00000000000000 millisecond clocks and delays Sleep for a number of milliseconds Return current system clock as milliseconds. Note that this clock can jump backwards (if the system clock is changed) so is unsafe to use for timers and time offsets. Use zclock_mono for that instead. Return current monotonic clock in milliseconds. Use this when you compute time offsets. The monotonic clock is not affected by system changes and so will never be reset backwards, unlike a system clock. Return current monotonic clock in microseconds. Use this when you compute time offsets. The monotonic clock is not affected by system changes and so will never be reset backwards, unlike a system clock. Return formatted date/time as fresh string. Free using zstr_free(). czmq-4.1.0/api/zarmour.api0000664000372000037200000000644213222211156016334 0ustar00travistravis00000000000000 armoured text encoding and decoding Standard base 64 URL and filename friendly base 64 Standard base 32 Extended hex base 32 Standard base 16 Z85 from ZeroMQ RFC 32 Create a new zarmour Destroy the zarmour Encode a stream of bytes into an armoured string. Returns the armoured string, or NULL if there was insufficient memory available to allocate a new string. Decode an armoured string into a chunk. The decoded output is null-terminated, so it may be treated as a string, if that's what it was prior to encoding. Get the mode property. Get printable string for mode. Set the mode property. Return true if padding is turned on. Turn padding on or off. Default is on. Get the padding character. Set the padding character. Return if splitting output into lines is turned on. Default is off. Turn splitting output into lines on or off. Get the line length used for splitting lines. Set the line length used for splitting lines. Print properties of object czmq-4.1.0/api/ziflist.api0000664000372000037200000000427313222211156016321 0ustar00travistravis00000000000000 List of network interfaces available on system Get a list of network interfaces currently defined on the system Destroy a ziflist instance Reload network interfaces from system Return the number of network interfaces on system Get first network interface, return NULL if there are none Get next network interface, return NULL if we hit the last one Return the current interface IP address as a printable string Return the current interface broadcast address as a printable string Return the current interface network mask as a printable string Return the list of interfaces. Get a list of network interfaces currently defined on the system Includes IPv6 interfaces Reload network interfaces from system, including IPv6 Return true if the current interface uses IPv6 czmq-4.1.0/api/zsock.api0000664000372000037200000004376013222211156015772 0ustar00travistravis00000000000000 high-level socket API that hides libzmq contexts and sockets Create a new socket. Returns the new socket, or NULL if the new socket could not be created. Note that the symbol zsock_new (and other constructors/destructors for zsock) are redirected to the *_checked variant, enabling intelligent socket leak detection. This can have performance implications if you use a LOT of sockets. To turn off this redirection behaviour, define ZSOCK_NOCHECK. Destroy the socket. You must use this for any socket created via the zsock_new method. Create a PUB socket. Default action is bind. Create a SUB socket, and optionally subscribe to some prefix string. Default action is connect. Create a REQ socket. Default action is connect. Create a REP socket. Default action is bind. Create a DEALER socket. Default action is connect. Create a ROUTER socket. Default action is bind. Create a PUSH socket. Default action is connect. Create a PULL socket. Default action is bind. Create an XPUB socket. Default action is bind. Create an XSUB socket. Default action is connect. Create a PAIR socket. Default action is connect. Create a STREAM socket. Default action is connect. Create a SERVER socket. Default action is bind. Create a CLIENT socket. Default action is connect. Create a RADIO socket. Default action is bind. Create a DISH socket. Default action is connect. Create a GATHER socket. Default action is bind. Create a SCATTER socket. Default action is connect. Bind a socket to a formatted endpoint. For tcp:// endpoints, supports ephemeral ports, if you specify the port number as "*". By default zsock uses the IANA designated range from C000 (49152) to FFFF (65535). To override this range, follow the "*" with "[first-last]". Either or both first and last may be empty. To bind to a random port within the range, use "!" in place of "*". Examples: tcp://127.0.0.1:* bind to first free port from C000 up tcp://127.0.0.1:! bind to random port from C000 to FFFF tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 tcp://127.0.0.1:![55000-55999] bind to random port from 55000 to 55999 On success, returns the actual port number used, for tcp:// endpoints, and 0 for other transports. On failure, returns -1. Note that when using ephemeral ports, a port may be reused by different services without clients being aware. Protocols that run on ephemeral ports should take this into account. Returns last bound endpoint, if any. Unbind a socket from a formatted endpoint. Returns 0 if OK, -1 if the endpoint was invalid or the function isn't supported. Connect a socket to a formatted endpoint Returns 0 if OK, -1 if the endpoint was invalid. Disconnect a socket from a formatted endpoint Returns 0 if OK, -1 if the endpoint was invalid or the function isn't supported. Attach a socket to zero or more endpoints. If endpoints is not null, parses as list of ZeroMQ endpoints, separated by commas, and prefixed by '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all endpoints were valid, or -1 if there was a syntax error. If the endpoint does not start with '@' or '>', the serverish argument defines whether it is used to bind (serverish = true) or connect (serverish = false). Returns socket type as printable constant string. Send a 'picture' message to the socket (or actor). The picture is a string that defines the type of each frame. This makes it easy to send a complex multiframe message in one call. The picture can contain any of these characters, each corresponding to one or two arguments: i = int (signed) 1 = uint8_t 2 = uint16_t 4 = uint32_t 8 = uint64_t s = char * b = byte *, size_t (2 arguments) c = zchunk_t * f = zframe_t * h = zhashx_t * U = zuuid_t * p = void * (sends the pointer value, only meaningful over inproc) m = zmsg_t * (sends all frames in the zmsg) z = sends zero-sized frame (0 arguments) u = uint (deprecated) Note that s, b, c, and f are encoded the same way and the choice is offered as a convenience to the sender, which may or may not already have data in a zchunk or zframe. Does not change or take ownership of any arguments. Returns 0 if successful, -1 if sending failed for any reason. Send a 'picture' message to the socket (or actor). This is a va_list version of zsock_send (), so please consult its documentation for the details. Receive a 'picture' message to the socket (or actor). See zsock_send for the format and meaning of the picture. Returns the picture elements into a series of pointers as provided by the caller: i = int * (stores signed integer) 4 = uint32_t * (stores 32-bit unsigned integer) 8 = uint64_t * (stores 64-bit unsigned integer) s = char ** (allocates new string) b = byte **, size_t * (2 arguments) (allocates memory) c = zchunk_t ** (creates zchunk) f = zframe_t ** (creates zframe) U = zuuid_t * (creates a zuuid with the data) h = zhashx_t ** (creates zhashx) p = void ** (stores pointer) m = zmsg_t ** (creates a zmsg with the remaing frames) z = null, asserts empty frame (0 arguments) u = uint * (stores unsigned integer, deprecated) Note that zsock_recv creates the returned objects, and the caller must destroy them when finished with them. The supplied pointers do not need to be initialized. Returns 0 if successful, or -1 if it failed to recv a message, in which case the pointers are not modified. When message frames are truncated (a short message), sets return values to zero/null. If an argument pointer is NULL, does not store any value (skips it). An 'n' picture matches an empty frame; if the message does not match, the method will return -1. Receive a 'picture' message from the socket (or actor). This is a va_list version of zsock_recv (), so please consult its documentation for the details. Send a binary encoded 'picture' message to the socket (or actor). This method is similar to zsock_send, except the arguments are encoded in a binary format that is compatible with zproto, and is designed to reduce memory allocations. The pattern argument is a string that defines the type of each argument. Supports these argument types: pattern C type zproto type: 1 uint8_t type = "number" size = "1" 2 uint16_t type = "number" size = "2" 4 uint32_t type = "number" size = "3" 8 uint64_t type = "number" size = "4" s char *, 0-255 chars type = "string" S char *, 0-2^32-1 chars type = "longstr" c zchunk_t * type = "chunk" f zframe_t * type = "frame" u zuuid_t * type = "uuid" m zmsg_t * type = "msg" p void *, sends pointer value, only over inproc Does not change or take ownership of any arguments. Returns 0 if successful, -1 if sending failed for any reason. Receive a binary encoded 'picture' message from the socket (or actor). This method is similar to zsock_recv, except the arguments are encoded in a binary format that is compatible with zproto, and is designed to reduce memory allocations. The pattern argument is a string that defines the type of each argument. See zsock_bsend for the supported argument types. All arguments must be pointers; this call sets them to point to values held on a per-socket basis. For types 1, 2, 4 and 8 the caller must allocate the memory itself before calling zsock_brecv. For types S, the caller must free the value once finished with it, as zsock_brecv will allocate the buffer. For type s, the caller must not free the value as it is stored in a local cache for performance purposes. For types c, f, u and m the caller must call the appropriate destructor depending on the object as zsock_brecv will create new objects. For type p the caller must coordinate with the sender, as it is just a pointer value being passed. Return socket routing ID if any. This returns 0 if the socket is not of type ZMQ_SERVER or if no request was already received on it. Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. This will be used when sending messages on the socket via the zsock API. Set socket to use unbounded pipes (HWM=0); use this in cases when you are totally certain the message volume can fit in memory. This method works across all versions of ZeroMQ. Takes a polymorphic socket reference. Send a signal over a socket. A signal is a short message carrying a success/failure code (by convention, 0 means OK). Signals are encoded to be distinguishable from "normal" messages. Accepts a zsock_t or a zactor_t argument, and returns 0 if successful, -1 if the signal could not be sent. Takes a polymorphic socket reference. Wait on a signal. Use this to coordinate between threads, over pipe pairs. Blocks until the signal is received. Returns -1 on error, 0 or greater on success. Accepts a zsock_t or a zactor_t as argument. Takes a polymorphic socket reference. If there is a partial message still waiting on the socket, remove and discard it. This is useful when reading partial messages, to get specific message types. Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. Returns 0 if OK, -1 if failed. Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. Returns 0 if OK, -1 if failed. Probe the supplied object, and report if it looks like a zsock_t. Takes a polymorphic socket reference. Probe the supplied reference. If it looks like a zsock_t instance, return the underlying libzmq socket handle; else if it looks like a file descriptor, return NULL; else if it looks like a libzmq socket handle, return the supplied value. Takes a polymorphic socket reference. czmq-4.1.0/api/zproc.api0000664000372000037200000002276513222211156016000 0ustar00travistravis00000000000000 process configuration and status Create a new zproc. NOTE: On Windows and with libzmq3 and libzmq2 this function returns NULL. Code needs to be ported there. Destroy zproc, wait until process ends. Setup the command line arguments, the first item must be an (absolute) filename to run. Setup the environment variables for the process. Connects process stdin with a readable ('>', connect) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The writable one is then accessbile via zproc_stdin method. Connects process stdout with a writable ('@', bind) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The readable one is then accessbile via zproc_stdout method. Connects process stderr with a writable ('@', bind) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The readable one is then accessbile via zproc_stderr method. Return subprocess stdin writable socket. NULL for not initialized or external sockets. Return subprocess stdout readable socket. NULL for not initialized or external sockets. Return subprocess stderr readable socket. NULL for not initialized or external sockets. Starts the process. process exit code PID of the process return true if process is running, false if not yet started or finished wait or poll process status, return return code return internal actor, usefull for the polling if process died send a signal to the subprocess set verbose mode Returns CZMQ version as a single 6-digit integer encoding the major version (x 10000), the minor version (x 100) and the patch. Returns true if the process received a SIGINT or SIGTERM signal. It is good practice to use this method to exit any infinite loop processing messages. Returns true if the underlying libzmq supports CURVE security. Return current host name, for use in public tcp:// endpoints. If the host name is not resolvable, returns NULL. Move the current process into the background. The precise effect depends on the operating system. On POSIX boxes, moves to a specified working directory (if specified), closes all file handles, reopens stdin, stdout, and stderr to the null device, and sets the process to ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there was an error. Drop the process ID into the lockfile, with exclusive lock, and switch the process to the specified group and/or user. Any of the arguments may be null, indicating a no-op. Returns 0 on success, -1 on failure. Note if you combine this with zsys_daemonize, run after, not before that method, or the lockfile will hold the wrong process ID. Configure the number of I/O threads that ZeroMQ will use. A good rule of thumb is one thread per gigabit of traffic in or out. The default is 1, sufficient for most applications. If the environment variable ZSYS_IO_THREADS is defined, that provides the default. Note that this method is valid only before any socket is created. Configure the number of sockets that ZeroMQ will allow. The default is 1024. The actual limit depends on the system, and you can query it by using zsys_socket_limit (). A value of zero means "maximum". Note that this method is valid only before any socket is created. Set network interface name to use for broadcasts, particularly zbeacon. This lets the interface be configured for test environments where required. For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is the default when there is no specified interface. If the environment variable ZSYS_INTERFACE is set, use that as the default interface name. Setting the interface to "*" means "use all available interfaces". Return network interface to use for broadcasts, or "" if none was set. Set log identity, which is a string that prefixes all log messages sent by this process. The log identity defaults to the environment variable ZSYS_LOGIDENT, if that is set. Sends log output to a PUB socket bound to the specified endpoint. To collect such log output, create a SUB socket, subscribe to the traffic you care about, and connect to the endpoint. Log traffic is sent as a single string frame, in the same format as when sent to stdout. The log system supports a single sender; multiple calls to this method will bind the same sender to multiple endpoints. To disable the sender, call this method with a null argument. Enable or disable logging to the system facility (syslog on POSIX boxes, event log on Windows). By default this is disabled. Log error condition - highest priority Log warning condition - high priority Log normal, but significant, condition - normal priority Log informational message - low priority Log debug-level message - lowest priority czmq-4.1.0/api/zloop.api0000664000372000037200000001705113222211156015776 0ustar00travistravis00000000000000 event-driven reactor Callback function for reactor socket activity Callback function for reactor events (low-level) Callback for reactor timer events Create a new zloop reactor Destroy a reactor Register socket reader with the reactor. When the reader has messages, the reactor will call the handler, passing the arg. Returns 0 if OK, -1 if there was an error. If you register the same socket more than once, each instance will invoke its corresponding handler. Cancel a socket reader from the reactor. If multiple readers exist for same socket, cancels ALL of them. Configure a registered reader to ignore errors. If you do not set this, then readers that have errors are removed from the reactor silently. Register low-level libzmq pollitem with the reactor. When the pollitem is ready, will call the handler, passing the arg. Returns 0 if OK, -1 if there was an error. If you register the pollitem more than once, each instance will invoke its corresponding handler. A pollitem with socket=NULL and fd=0 means 'poll on FD zero'. Cancel a pollitem from the reactor, specified by socket or FD. If both are specified, uses only socket. If multiple poll items exist for same socket/FD, cancels ALL of them. Configure a registered poller to ignore errors. If you do not set this, then poller that have errors are removed from the reactor silently. Register a timer that expires after some delay and repeats some number of times. At each expiry, will call the handler, passing the arg. To run a timer forever, use 0 times. Returns a timer_id that is used to cancel the timer in the future. Returns -1 if there was an error. Cancel a specific timer identified by a specific timer_id (as returned by zloop_timer). Register a ticket timer. Ticket timers are very fast in the case where you use a lot of timers (thousands), and frequently remove and add them. The main use case is expiry timers for servers that handle many clients, and which reset the expiry timer for each message received from a client. Whereas normal timers perform poorly as the number of clients grows, the cost of ticket timers is constant, no matter the number of clients. You must set the ticket delay using zloop_set_ticket_delay before creating a ticket. Returns a handle to the timer that you should use in zloop_ticket_reset and zloop_ticket_delete. Reset a ticket timer, which moves it to the end of the ticket list and resets its execution time. This is a very fast operation. Delete a ticket timer. We do not actually delete the ticket here, as other code may still refer to the ticket. We mark as deleted, and remove later and safely. Set the ticket delay, which applies to all tickets. If you lower the delay and there are already tickets created, the results are undefined. Set hard limit on number of timers allowed. Setting more than a small number of timers (10-100) can have a dramatic impact on the performance of the reactor. For high-volume cases, use ticket timers. If the hard limit is reached, the reactor stops creating new timers and logs an error. Set verbose tracing of reactor on/off. The default verbose setting is off (false). By default the reactor stops if the process receives a SIGINT or SIGTERM signal. This makes it impossible to shut-down message based architectures like zactors. This method lets you switch off break handling. The default nonstop setting is off (false). Start the reactor. Takes control of the thread and returns when the 0MQ context is terminated or the process is interrupted, or any event handler returns -1. Event handlers may register new sockets and timers, and cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. czmq-4.1.0/api/zcert.api0000664000372000037200000001035113222211156015756 0ustar00travistravis00000000000000 work with CURVE security certificates Create and initialize a new certificate in memory Accepts public/secret key pair from caller Accepts public/secret key text pair from caller Load certificate from file Destroy a certificate in memory Return public part of key pair as 32-byte binary string Return secret part of key pair as 32-byte binary string Return public part of key pair as Z85 armored string Return secret part of key pair as Z85 armored string Set certificate metadata from formatted string. Unset certificate metadata. Get metadata value from certificate; if the metadata value doesn't exist, returns NULL. Get list of metadata fields from certificate. Caller is responsible for destroying list. Caller should not modify the values of list items. Save full certificate (public + secret) to file for persistent storage This creates one public file and one secret file (filename + "_secret"). Save public certificate only to file for persistent storage Save secret certificate only to file for persistent storage Apply certificate to socket, i.e. use for CURVE security on socket. If certificate was loaded from public file, the secret key will be undefined, and this certificate will not work successfully. Return copy of certificate; if certificate is NULL or we exhausted heap memory, returns NULL. Return true if two certificates have the same keys Print certificate contents to stdout Self test of this class czmq-4.1.0/api/zsys.api0000664000372000037200000005463113222211156015650 0ustar00travistravis00000000000000 Callback for interrupt signal handler Initialize CZMQ zsys layer; this happens automatically when you create a socket or an actor; however this call lets you force initialization earlier, so e.g. logging is properly set-up before you start working. Not threadsafe, so call only from main thread. Safe to call multiple times. Returns global CZMQ context. Optionally shut down the CZMQ zsys layer; this normally happens automatically when the process exits; however this call lets you force a shutdown earlier, avoiding any potential problems with atexit() ordering, especially with Windows dlls. Get a new ZMQ socket, automagically creating a ZMQ context if this is the first time. Caller is responsible for destroying the ZMQ socket before process exits, to avoid a ZMQ deadlock. Note: you should not use this method in CZMQ apps, use zsock_new() instead. *** This is for CZMQ internal use only and may change arbitrarily *** Destroy/close a ZMQ socket. You should call this for every socket you create using zsys_socket(). *** This is for CZMQ internal use only and may change arbitrarily *** Return ZMQ socket name for socket type *** This is for CZMQ internal use only and may change arbitrarily *** Create a pipe, which consists of two PAIR sockets connected over inproc. The pipe is configured to use the zsys_pipehwm setting. Returns the frontend socket successful, NULL if failed. Set interrupt handler; this saves the default handlers so that a zsys_handler_reset () can restore them. If you call this multiple times then the last handler will take affect. If handler_fn is NULL, disables default SIGINT/SIGTERM handling in CZMQ. Reset interrupt handler, call this at exit if needed Set default interrupt handler, so Ctrl-C or SIGTERM will set zsys_interrupted. Idempotent; safe to call multiple times. Can be supressed by ZSYS_SIGHANDLER=false *** This is for CZMQ internal use only and may change arbitrarily *** Return 1 if file exists, else zero Return file modification time. Returns 0 if the file does not exist. Return file mode; provides at least support for the POSIX S_ISREG(m) and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. Returns a mode_t cast to int, or -1 in case of error. Delete file. Does not complain if the file is absent Check if file is 'stable' Create a file path if it doesn't exist. The file path is treated as printf format. Remove a file path if empty; the pathname is treated as printf format. Move to a specified working directory. Returns 0 if OK, -1 if this failed. Set private file creation mode; all files created from here will be readable/writable by the owner only. Reset default file creation mode; all files created from here will use process file mode defaults. Return the CZMQ version for run-time API detection; returns version number into provided fields, providing reference isn't null in each case. 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(). Format a string with a va_list argument, returning a freshly allocated buffer. If there was insufficient memory, returns NULL. Free the returned string using zstr_free(). Create UDP beacon socket; if the routable option is true, uses multicast (not yet implemented), else uses broadcast. This method and related ones might _eventually_ be moved to a zudp class. *** This is for CZMQ internal use only and may change arbitrarily *** Close a UDP socket *** This is for CZMQ internal use only and may change arbitrarily *** Send zframe to UDP socket, return -1 if sending failed due to interface having disappeared (happens easily with WiFi) *** This is for CZMQ internal use only and may change arbitrarily *** Receive zframe from UDP socket, and set address of peer that sent it The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. *** This is for CZMQ internal use only and may change arbitrarily *** Handle an I/O error on some socket operation; will report and die on fatal errors, and continue silently on "try again" errors. *** This is for CZMQ internal use only and may change arbitrarily *** Return current host name, for use in public tcp:// endpoints. Caller gets a freshly allocated string, should free it using zstr_free(). If the host name is not resolvable, returns NULL. Move the current process into the background. The precise effect depends on the operating system. On POSIX boxes, moves to a specified working directory (if specified), closes all file handles, reopens stdin, stdout, and stderr to the null device, and sets the process to ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there was an error. Drop the process ID into the lockfile, with exclusive lock, and switch the process to the specified group and/or user. Any of the arguments may be null, indicating a no-op. Returns 0 on success, -1 on failure. Note if you combine this with zsys_daemonize, run after, not before that method, or the lockfile will hold the wrong process ID. Returns true if the underlying libzmq supports CURVE security. Uses a heuristic probe according to the version of libzmq being used. Configure the number of I/O threads that ZeroMQ will use. A good rule of thumb is one thread per gigabit of traffic in or out. The default is 1, sufficient for most applications. If the environment variable ZSYS_IO_THREADS is defined, that provides the default. Note that this method is valid only before any socket is created. Configure the scheduling policy of the ZMQ context thread pool. Not available on Windows. See the sched_setscheduler man page or sched.h for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY is defined, that provides the default. Note that this method is valid only before any socket is created. Configure the scheduling priority of the ZMQ context thread pool. Not available on Windows. See the sched_setscheduler man page or sched.h for more information. If the environment variable ZSYS_THREAD_PRIORITY is defined, that provides the default. Note that this method is valid only before any socket is created. Configure the number of sockets that ZeroMQ will allow. The default is 1024. The actual limit depends on the system, and you can query it by using zsys_socket_limit (). A value of zero means "maximum". Note that this method is valid only before any socket is created. Return maximum number of ZeroMQ sockets that the system will support. Configure the maximum allowed size of a message sent. The default is INT_MAX. Return maximum message size. Configure the threshold value of filesystem object age per st_mtime that should elapse until we consider that object "stable" at the current zclock_time() moment. The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c which generally depends on host OS, with fallback value of 5000. Return current threshold value of file stable age in msec. This can be used in code that chooses to wait for this timeout before testing if a filesystem object is "stable" or not. Configure the default linger timeout in msecs for new zsock instances. You can also set this separately on each zsock_t instance. The default linger time is zero, i.e. any pending messages will be dropped. If the environment variable ZSYS_LINGER is defined, that provides the default. Note that process exit will typically be delayed by the linger time. Configure the default outgoing pipe limit (HWM) for new zsock instances. You can also set this separately on each zsock_t instance. The default HWM is 1,000, on all versions of ZeroMQ. If the environment variable ZSYS_SNDHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. Configure the default incoming pipe limit (HWM) for new zsock instances. You can also set this separately on each zsock_t instance. The default HWM is 1,000, on all versions of ZeroMQ. If the environment variable ZSYS_RCVHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. Configure the default HWM for zactor internal pipes; this is set on both ends of the pipe, for outgoing messages only (sndhwm). The default HWM is 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is defined, that provides the default. Note that a value of zero means no limit, i.e. infinite memory consumption. Return the HWM for zactor internal pipes. Configure use of IPv6 for new zsock instances. By default sockets accept and make only IPv4 connections. When you enable IPv6, sockets will accept and connect to both IPv4 and IPv6 peers. You can override the setting on each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the default. Note: has no effect on ZMQ v2. Return use of IPv6 for zsock instances. Set network interface name to use for broadcasts, particularly zbeacon. This lets the interface be configured for test environments where required. For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is the default when there is no specified interface. If the environment variable ZSYS_INTERFACE is set, use that as the default interface name. Setting the interface to "*" means "use all available interfaces". Return network interface to use for broadcasts, or "" if none was set. Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. This needs to be set IPv6 is enabled as IPv6 can have multiple addresses on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, use that as the default IPv6 address. Return IPv6 address to use for zbeacon reception, or "" if none was set. Set IPv6 milticast address to use for sending zbeacon messages. This needs to be set if IPv6 is enabled. If the environment variable ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast address. Return IPv6 multicast address to use for sending zbeacon, or "" if none was set. Configure the automatic use of pre-allocated FDs when creating new sockets. If 0 (default), nothing will happen. Else, when a new socket is bound, the system API will be used to check if an existing pre-allocated FD with a matching port (if TCP) or path (if IPC) exists, and if it does it will be set via the ZMQ_USE_FD socket option so that the library will use it instead of creating a new socket. Return use of automatic pre-allocated FDs for zsock instances. Set log identity, which is a string that prefixes all log messages sent by this process. The log identity defaults to the environment variable ZSYS_LOGIDENT, if that is set. Set stream to receive log traffic. By default, log traffic is sent to stdout. If you set the stream to NULL, no stream will receive the log traffic (it may still be sent to the system facility). Sends log output to a PUB socket bound to the specified endpoint. To collect such log output, create a SUB socket, subscribe to the traffic you care about, and connect to the endpoint. Log traffic is sent as a single string frame, in the same format as when sent to stdout. The log system supports a single sender; multiple calls to this method will bind the same sender to multiple endpoints. To disable the sender, call this method with a null argument. Enable or disable logging to the system facility (syslog on POSIX boxes, event log on Windows). By default this is disabled. Log error condition - highest priority Log warning condition - high priority Log normal, but significant, condition - normal priority Log informational message - low priority Log debug-level message - lowest priority czmq-4.1.0/api/zframe.api0000664000372000037200000001301613222211156016114 0ustar00travistravis00000000000000 working with single message frames Create a new frame. If size is not null, allocates the frame data to the specified size. If additionally, data is not null, copies size octets from the specified data into the frame body. Destroy a frame Create an empty (zero-sized) frame Create a frame with a specified string content. Receive frame from socket, returns zframe_t object or NULL if the recv was interrupted. Does a blocking recv, if you want to not block then use zpoller or zloop. Send a frame to a socket, destroy frame after sending. Return -1 on error, 0 on success. Return number of bytes in frame data Return address of frame data Return meta data property for frame The caller shall not modify or free the returned value, which shall be owned by the message. Create a new frame that duplicates an existing frame. If frame is null, or memory was exhausted, returns null. Return frame data encoded as printable hex string, useful for 0MQ UUIDs. Caller must free string when finished with it. Return frame data copied into freshly allocated string Caller must free string when finished with it. Return TRUE if frame body is equal to string, excluding terminator Return frame MORE indicator (1 or 0), set when reading frame from socket or by the zframe_set_more() method Set frame MORE indicator (1 or 0). Note this is NOT used when sending frame to socket, you have to specify flag explicitly. Return frame routing ID, if the frame came from a ZMQ_SERVER socket. Else returns zero. Set routing ID on frame. This is used if/when the frame is sent to a ZMQ_SERVER socket. Return frame group of radio-dish pattern. Set group on frame. This is used if/when the frame is sent to a ZMQ_RADIO socket. Return -1 on error, 0 on success. Return TRUE if two frames have identical size and data If either frame is NULL, equality is always false. Set new contents for frame Send message to zsys log sink (may be stdout, or system facility as configured by zsys_set_logstream). Prefix shows before frame, if not null. Probe the supplied object, and report if it looks like a zframe_t. czmq-4.1.0/api/zchunk.api0000664000372000037200000001434013222211156016133 0ustar00travistravis00000000000000 work with memory chunks Create a new chunk of the specified size. If you specify the data, it is copied into the chunk. If you do not specify the data, the chunk is allocated and left empty, and you can then add data using zchunk_append. Destroy a chunk Resizes chunk max_size as requested; chunk_cur size is set to zero Return chunk cur size Return chunk max size Return chunk data Set chunk data from user-supplied data; truncate if too large. Data may be null. Returns actual size of chunk Fill chunk data from user-supplied octet Append user-supplied data to chunk, return resulting chunk size. If the data would exceeded the available space, it is truncated. If you want to grow the chunk to accommodate new data, use the zchunk_extend method. Append user-supplied data to chunk, return resulting chunk size. If the data would exceeded the available space, the chunk grows in size. Copy as much data from 'source' into the chunk as possible; returns the new size of chunk. If all data from 'source' is used, returns exhausted on the source chunk. Source can be consumed as many times as needed until it is exhausted. If source was already exhausted, does not change chunk. Returns true if the chunk was exhausted by consume methods, or if the chunk has a size of zero. Read chunk from an open file descriptor Write chunk to an open file descriptor Try to slurp an entire file into a chunk. Will read up to maxsize of the file. If maxsize is 0, will attempt to read the entire file and fail with an assertion if that cannot fit into memory. Returns a new chunk containing the file data, or NULL if the file could not be read. Create copy of chunk, as new chunk object. Returns a fresh zchunk_t object, or null if there was not enough heap memory. If chunk is null, returns null. Return chunk data encoded as printable hex string. Caller must free string when finished with it. Return chunk data copied into freshly allocated string Caller must free string when finished with it. Return TRUE if chunk body is equal to string, excluding terminator Transform zchunk into a zframe that can be sent in a message. Transform a zframe into a zchunk. Calculate SHA1 digest for chunk, using zdigest class. Dump chunk to FILE stream, for debugging and tracing. Dump message to stderr, for debugging and tracing. See zchunk_fprint for details Probe the supplied object, and report if it looks like a zchunk_t. czmq-4.1.0/api/zdigest.api0000664000372000037200000000302313222211156016276 0ustar00travistravis00000000000000 provides hashing functions (SHA-1 at present) Constructor - creates new digest object, which you use to build up a digest by repeatedly calling zdigest_update() on chunks of data. Destroy a digest object Add buffer into digest calculation Return final digest hash data. If built without crypto support, returns NULL. Return final digest hash size Return digest as printable hex string; caller should not modify nor free this string. After calling this, you may not use zdigest_update() on the same digest. If built without crypto support, returns NULL. czmq-4.1.0/api/zconfig.api0000664000372000037200000001546513222211156016301 0ustar00travistravis00000000000000 work with config files written in rfc.zeromq.org/spec:4/ZPL. Create new config item Destroy a config item and all its children Return name of config item Return value of config item Insert or update configuration key with value Equivalent to zconfig_put, accepting a format specifier and variable argument list, instead of a single string value. Get value for config item into a string value; leading slash is optional and ignored. Set config item name, name may be NULL Set new value for config item. The new value may be a string, a printf format, or NULL. Note that if string may possibly contain '%', or if it comes from an insecure source, you must use '%s' as the format, followed by the string. Find our first child, if any Find our first sibling, if any Find a config item along a path; leading slash is optional and ignored. Locate the last config item at a specified depth Execute a callback for each config item in the tree; returns zero if successful, else -1. Add comment to config item before saving to disk. You can add as many comment lines as you like. If you use a null format, all comments are deleted. Return comments of config item, as zlist. Load a config tree from a specified ZPL text file; returns a zconfig_t reference for the root, if the file exists and is readable. Returns NULL if the file does not exist. Save a config tree to a specified ZPL text file, where a filename "-" means dump to standard output. Equivalent to zconfig_load, taking a format string instead of a fixed filename. Equivalent to zconfig_save, taking a format string instead of a fixed filename. Report filename used during zconfig_load, or NULL if none Reload config tree from same file that it was previously loaded from. Returns 0 if OK, -1 if there was an error (and then does not change existing data). Load a config tree from a memory chunk Save a config tree to a new memory chunk Load a config tree from a null-terminated string Save a config tree to a new null terminated string Return true if a configuration tree was loaded from a file and that file has changed in since the tree was loaded. Destroy subtree (all children) Destroy node and subtree (all children) Print the config file to open stream Print properties of object Self test of this class czmq-4.1.0/api/zuuid.api0000664000372000037200000000471613222211156015777 0ustar00travistravis00000000000000 UUID support class Create a new UUID object. Destroy a specified UUID object. Create UUID object from supplied ZUUID_LEN-octet value. Set UUID to new supplied ZUUID_LEN-octet value. Set UUID to new supplied string value skipping '-' and '{' '}' optional delimiters. Return 0 if OK, else returns -1. Return UUID binary data. Return UUID binary size Returns UUID as string Return UUID in the canonical string format: 8-4-4-4-12, in lower case. Caller does not modify or free returned value. See http://en.wikipedia.org/wiki/Universally_unique_identifier Store UUID blob in target array Check if UUID is same as supplied value Check if UUID is different from supplied value Make copy of UUID object; if uuid is null, or memory was exhausted, returns null. czmq-4.1.0/api/zpoller.api0000664000372000037200000000600213222211156016314 0ustar00travistravis00000000000000 event-driven reactor Create new poller, specifying zero or more readers. The list of readers ends in a NULL. Each reader can be a zsock_t instance, a zactor_t instance, a libzmq socket (void *), or a file handle. Destroy a poller Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader must have been passed during construction, or in an zpoller_add () call. By default the poller stops if the process receives a SIGINT or SIGTERM signal. This makes it impossible to shut-down message based architectures like zactors. This method lets you switch off break handling. The default nonstop setting is off (false). Poll the registered readers for I/O, return first reader that has input. The reader will be a libzmq void * socket, or a zsock_t or zactor_t instance as specified in zpoller_new/zpoller_add. The timeout should be zero or greater, or -1 to wait indefinitely. Socket priority is defined by their order in the poll list. If you need a balanced poll, use the low level zmq_poll method directly. If the poll call was interrupted (SIGINT), or the ZMQ context was destroyed, or the timeout expired, returns NULL. You can test the actual exit condition by calling zpoller_expired () and zpoller_terminated (). The timeout is in msec. Return true if the last zpoller_wait () call ended because the timeout expired, without any error. Return true if the last zpoller_wait () call ended because the process was interrupted, or the parent context was destroyed. czmq-4.1.0/api/zmsg.api0000664000372000037200000002327613222211156015621 0ustar00travistravis00000000000000 working with multipart messages Create a new empty message object Destroy a message object and all frames it contains Receive message from socket, returns zmsg_t object or NULL if the recv was interrupted. Does a blocking recv. If you want to not block then use the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input before receiving. Send message to destination socket, and destroy the message after sending it successfully. If the message has no frames, sends nothing but destroys the message anyhow. Nullifies the caller's reference to the message (as it is a destructor). Send message to destination socket as part of a multipart sequence, and destroy the message after sending it successfully. Note that after a zmsg_sendm, you must call zmsg_send or another method that sends a final message part. If the message has no frames, sends nothing but destroys the message anyhow. Nullifies the caller's reference to the message (as it is a destructor). Return size of message, i.e. number of frames (0 or more). Return total size of all frames in message. Return message routing ID, if the message came from a ZMQ_SERVER socket. Else returns zero. Set routing ID on message. This is used if/when the message is sent to a ZMQ_SERVER socket. Push frame to the front of the message, i.e. before all other frames. Message takes ownership of frame, will destroy it when message is sent. Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not nullify the caller's frame reference. Add frame to the end of the message, i.e. after all other frames. Message takes ownership of frame, will destroy it when message is sent. Returns 0 on success. Deprecates zmsg_add, which did not nullify the caller's frame reference. Remove first frame from message, if any. Returns frame, or NULL. Push block of memory to front of message, as a new frame. Returns 0 on success, -1 on error. Add block of memory to the end of the message, as a new frame. Returns 0 on success, -1 on error. Push string as new frame to front of message. Returns 0 on success, -1 on error. Push string as new frame to end of message. Returns 0 on success, -1 on error. Push formatted string as new frame to front of message. Returns 0 on success, -1 on error. Push formatted string as new frame to end of message. Returns 0 on success, -1 on error. Pop frame off front of message, return as fresh string. If there were no more frames in the message, returns NULL. Push encoded message as a new frame. Message takes ownership of submessage, so the original is destroyed in this call. Returns 0 on success, -1 on error. Remove first submessage from message, if any. Returns zmsg_t, or NULL if decoding was not successful. Remove specified frame from list, if present. Does not destroy frame. Set cursor to first frame in message. Returns frame, or NULL, if the message is empty. Use this to navigate the frames as a list. Return the next frame. If there are no more frames, returns NULL. To move to the first frame call zmsg_first(). Advances the cursor. Return the last frame. If there are no frames, returns NULL. Save message to an open file, return 0 if OK, else -1. The message is saved as a series of frames, each with length and data. Note that the file is NOT guaranteed to be portable between operating systems, not versions of CZMQ. The file format is at present undocumented and liable to arbitrary change. Load/append an open file into new message, return the message. Returns NULL if the message could not be loaded. Serialize multipart message to a single message frame. Use this method to send structured messages across transports that do not support multipart data. Allocates and returns a new frame containing the serialized message. To decode a serialized message frame, use zmsg_decode (). Decodes a serialized message frame created by zmsg_encode () and returns a new zmsg_t object. Returns NULL if the frame was badly formatted or there was insufficient memory to work. Create copy of message, as new message object. Returns a fresh zmsg_t object. If message is null, or memory was exhausted, returns null. Send message to zsys log sink (may be stdout, or system facility as configured by zsys_set_logstream). Return true if the two messages have the same number of frames and each frame in the first message is identical to the corresponding frame in the other message. As with zframe_eq, return false if either message is NULL. Generate a signal message encoding the given status. A signal is a short message carrying a 1-byte success/failure code (by convention, 0 means OK). Signals are encoded to be distinguishable from "normal" messages. Return signal value, 0 or greater, if message is a signal, -1 if not. Probe the supplied object, and report if it looks like a zmsg_t. czmq-4.1.0/api/zstr.api0000664000372000037200000001247713222211156015644 0ustar00travistravis00000000000000 sending and receiving strings Receive C string from socket. Caller must free returned string using zstr_free(). Returns NULL if the context is being terminated or the process was interrupted. Receive a series of strings (until NULL) from multipart data. Each string is allocated and filled with string data; if there are not enough frames, unallocated strings are set to NULL. Returns -1 if the message could not be read, else returns the number of strings filled, zero or more. Free each returned string using zstr_free(). If not enough strings are provided, remaining multipart frames in the message are dropped. De-compress and receive C string from socket, received as a message with two frames: size of the uncompressed string, and the string itself. Caller must free returned string using zstr_free(). Returns NULL if the context is being terminated or the process was interrupted. Send a C string to a socket, as a frame. The string is sent without trailing null byte; to read this you can use zstr_recv, or a similar method that adds a null terminator on the received string. String may be NULL, which is sent as "". Send a C string to a socket, as zstr_send(), with a MORE flag, so that you can send further strings in the same multi-part message. Send a formatted string to a socket. Note that you should NOT use user-supplied strings in the format (they may contain '%' which will create security holes). Send a formatted string to a socket, as for zstr_sendf(), with a MORE flag, so that you can send further strings in the same multi-part message. Send a series of strings (until NULL) as multipart data Returns 0 if the strings could be sent OK, or -1 on error. Compress and send a C string to a socket, as a message with two frames: size of the uncompressed string, and the string itself. The string is sent without trailing null byte; to read this you can use zstr_recv_compress, or a similar method that de-compresses and adds a null terminator on the received string. Compress and send a C string to a socket, as zstr_send_compress(), with a MORE flag, so that you can send further strings in the same multi-part message. Accepts a void pointer and returns a fresh character string. If source is null, returns an empty string. Free a provided string, and nullify the parent pointer. Safe to call on a null pointer. czmq-4.1.0/api/zfile.api0000664000372000037200000001270713222211156015747 0ustar00travistravis00000000000000 helper functions for working with files. If file exists, populates properties. CZMQ supports portable symbolic links, which are files with the extension ".ln". A symbolic link is a text file containing one line, the filename of a target file. Reading data from the symbolic link actually reads from the target file. Path may be NULL, in which case it is not used. Create new temporary file for writing via tmpfile. File is automaticaly deleted on destroy Destroy a file item Duplicate a file item, returns a newly constructed item. If the file is null, or memory was exhausted, returns null. Return file name, remove path if provided Refresh file properties from disk; this is not done automatically on access methods, otherwise it is not possible to compare directory snapshots. Return when the file was last modified. If you want this to reflect the current situation, call zfile_restat before checking this property. Return the last-known size of the file. If you want this to reflect the current situation, call zfile_restat before checking this property. Return true if the file is a directory. If you want this to reflect any external changes, call zfile_restat before checking this property. Return true if the file is a regular file. If you want this to reflect any external changes, call zfile_restat before checking this property. Return true if the file is readable by this process. If you want this to reflect any external changes, call zfile_restat before checking this property. Return true if the file is writeable by this process. If you want this to reflect any external changes, call zfile_restat before checking this property. Check if file has stopped changing and can be safely processed. Updates the file statistics from disk at every call. Return true if the file was changed on disk since the zfile_t object was created, or the last zfile_restat() call made on it. Remove the file from disk Open file for reading Returns 0 if OK, -1 if not found or not accessible Open file for writing, creating directory if needed File is created if necessary; chunks can be written to file at any location. Returns 0 if OK, -1 if error. Read chunk from file at specified position. If this was the last chunk, sets the eof property. Returns a null chunk in case of error. Returns true if zfile_read() just read the last chunk in the file. Write chunk to file at specified position Return 0 if OK, else -1 Read next line of text from file. Returns a pointer to the text line, or NULL if there was nothing more to read from the file. Close file, if open Return file handle, if opened Calculate SHA1 digest for file, using zdigest class. czmq-4.1.0/api/zhash.api0000664000372000037200000001653413222211156015755 0ustar00travistravis00000000000000 generic type-free hash container (simple) Callback function for zhash_freefn method Create a new, empty hash container Destroy a hash container and all items in it Insert item into hash table with specified key and item. If key is already present returns -1 and leaves existing item unchanged Returns 0 on success. Update item into hash table with specified key and item. If key is already present, destroys old item and inserts new one. Use free_fn method to ensure deallocator is properly called on item. Remove an item specified by key from the hash table. If there was no such item, this function does nothing. Return the item at the specified key, or null Reindexes an item from an old key to a new key. If there was no such item, does nothing. Returns 0 if successful, else -1. Set a free function for the specified hash table item. When the item is destroyed, the free function, if any, is called on that item. Use this when hash items are dynamically allocated, to ensure that you don't have memory leaks. You can pass 'free' or NULL as a free_fn. Returns the item, or NULL if there is no such item. Return the number of keys/items in the hash table Make copy of hash table; if supplied table is null, returns null. Does not copy items themselves. Rebuilds new table so may be slow on very large tables. NOTE: only works with item values that are strings since there's no other way to know how to duplicate the item value. Return keys for items in table Simple iterator; returns first item in hash table, in no given order, or NULL if the table is empty. This method is simpler to use than the foreach() method, which is deprecated. To access the key for this item use zhash_cursor(). NOTE: do NOT modify the table while iterating. Simple iterator; returns next item in hash table, in no given order, or NULL if the last item was already returned. Use this together with zhash_first() to process all items in a hash table. If you need the items in sorted order, use zhash_keys() and then zlist_sort(). To access the key for this item use zhash_cursor(). NOTE: do NOT modify the table while iterating. After a successful first/next method, returns the key for the item that was returned. This is a constant string that you may not modify or deallocate, and which lasts as long as the item in the hash. After an unsuccessful first/next, returns NULL. Add a comment to hash table before saving to disk. You can add as many comment lines as you like. These comment lines are discarded when loading the file. If you use a null format, all comments are deleted. Serialize hash table to a binary frame that can be sent in a message. The packed format is compatible with the 'dictionary' type defined in http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: ; A list of name/value pairs dictionary = dict-count *( dict-name dict-value ) dict-count = number-4 dict-value = longstr dict-name = string ; Strings are always length + text contents longstr = number-4 *VCHAR string = number-1 *VCHAR ; Numbers are unsigned integers in network byte order number-1 = 1OCTET number-4 = 4OCTET Comments are not included in the packed data. Item values MUST be strings. Unpack binary frame into a new hash table. Packed data must follow format defined by zhash_pack. Hash table is set to autofree. An empty frame unpacks to an empty hash table. Save hash table to a text file in name=value format. Hash values must be printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file error occurred. Load hash table from a text file in name=value format; hash table must already exist. Hash values must printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file was not readable. When a hash table was loaded from a file by zhash_load, this method will reload the file if it has been modified since, and is "stable", i.e. not still changing. Returns 0 if OK, -1 if there was an error reloading the file. Set hash for automatic value destruction. Note that this assumes that values are NULL-terminated strings. Do not use with different types. czmq-4.1.0/api/zgossip_msg.api0000664000372000037200000000622213222211156017175 0ustar00travistravis00000000000000 Create a new empty zgossip_msg Destroy a zgossip_msg instance Receive a zgossip_msg from the socket. Returns 0 if OK, -1 if there was an error. Blocks if there is no message waiting. Send the zgossip_msg to the output socket, does not destroy it Print contents of message to stdout Get the message routing id, as a frame Set the message routing id from a frame Get the zgossip_msg message id Set the zgossip_msg message id Get the zgossip_msg message id as printable text Get the key field Set the key field Get the value field Set the value field Get the ttl field Set the ttl field czmq-4.1.0/api/zcertstore.api0000664000372000037200000000640713222211156017042 0ustar00travistravis00000000000000 work with CURVE security certificate stores Create a new certificate store from a disk directory, loading and indexing all certificates in that location. The directory itself may be absent, and created later, or modified at any time. The certificate store is automatically refreshed on any zcertstore_lookup() call. If the location is specified as NULL, creates a pure-memory store, which you can work with by inserting certificates at runtime. Destroy a certificate store object in memory. Does not affect anything stored on disk. Loaders retrieve certificates from an arbitrary source. Destructor for loader state. Override the default disk loader with a custom loader fn. Look up certificate by public key, returns zcert_t object if found, else returns NULL. The public key is provided in Z85 text format. Insert certificate into certificate store in memory. Note that this does not save the certificate to disk. To do that, use zcert_save() directly on the certificate. Takes ownership of zcert_t object. Empty certificate hashtable. This wrapper exists to be friendly to bindings, which don't usually have access to struct internals. Print list of certificates in store to logging facility Return a list of all the certificates in the store. The caller takes ownership of the zlistx_t object and is responsible for destroying it. The caller does not take ownership of the zcert_t objects. Self test of this class czmq-4.1.0/api/ztimerset.api0000664000372000037200000000464313222211156016664 0ustar00travistravis00000000000000 timer set Create new timer set. Destroy a timer set Callback function for timer event. Add a timer to the set. Returns timer id if OK, -1 on failure. Cancel a timer. Returns 0 if OK, -1 on failure. Set timer interval. Returns 0 if OK, -1 on failure. This method is slow, canceling the timer and adding a new one yield better performance. Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. This method is slow, canceling the timer and adding a new one yield better performance. Return the time until the next interval. Should be used as timeout parameter for the zpoller wait method. The timeout is in msec. Invoke callback function of all timers which their interval has elapsed. Should be call after zpoller wait method. Returns 0 if OK, -1 on failure. czmq-4.1.0/api/zdir_patch.api0000664000372000037200000000337713222211156016770 0ustar00travistravis00000000000000 work with directory patches Creates a new file Delete a file Create new patch Destroy a patch Create copy of a patch. If the patch is null, or memory was exhausted, returns null. Return patch file directory path Return patch file item Return operation Return patch virtual file path Calculate hash digest for file (create only) Return hash digest for patch file czmq-4.1.0/api/zhashx.api0000664000372000037200000002775413222211156016153 0ustar00travistravis00000000000000 extended generic type-free hash container Destroy an item Duplicate an item Compare two items, for sorting Destroy an item. Hash function for keys. Serializes an item to a longstr. The caller takes ownership of the newly created object. Deserializes a longstr into an item. The caller takes ownership of the newly created object. Create a new, empty hash container Destroy a hash container and all items in it Insert item into hash table with specified key and item. If key is already present returns -1 and leaves existing item unchanged Returns 0 on success. Update or insert item into hash table with specified key and item. If the key is already present, destroys old item and inserts new one. If you set a container item destructor, this is called on the old value. If the key was not already present, inserts a new item. Sets the hash cursor to the new item. Remove an item specified by key from the hash table. If there was no such item, this function does nothing. Delete all items from the hash table. If the key destructor is set, calls it on every key. If the item destructor is set, calls it on every item. Return the item at the specified key, or null Reindexes an item from an old key to a new key. If there was no such item, does nothing. Returns 0 if successful, else -1. Set a free function for the specified hash table item. When the item is destroyed, the free function, if any, is called on that item. Use this when hash items are dynamically allocated, to ensure that you don't have memory leaks. You can pass 'free' or NULL as a free_fn. Returns the item, or NULL if there is no such item. Return the number of keys/items in the hash table Return a zlistx_t containing the keys for the items in the table. Uses the key_duplicator to duplicate all keys and sets the key_destructor as destructor for the list. Return a zlistx_t containing the values for the items in the table. Uses the duplicator to duplicate all items and sets the destructor as destructor for the list. Simple iterator; returns first item in hash table, in no given order, or NULL if the table is empty. This method is simpler to use than the foreach() method, which is deprecated. To access the key for this item use zhashx_cursor(). NOTE: do NOT modify the table while iterating. Simple iterator; returns next item in hash table, in no given order, or NULL if the last item was already returned. Use this together with zhashx_first() to process all items in a hash table. If you need the items in sorted order, use zhashx_keys() and then zlistx_sort(). To access the key for this item use zhashx_cursor(). NOTE: do NOT modify the table while iterating. After a successful first/next method, returns the key for the item that was returned. This is a constant string that you may not modify or deallocate, and which lasts as long as the item in the hash. After an unsuccessful first/next, returns NULL. Add a comment to hash table before saving to disk. You can add as many comment lines as you like. These comment lines are discarded when loading the file. If you use a null format, all comments are deleted. Save hash table to a text file in name=value format. Hash values must be printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file error occurred. Load hash table from a text file in name=value format; hash table must already exist. Hash values must printable strings; keys may not contain '=' character. Returns 0 if OK, else -1 if a file was not readable. When a hash table was loaded from a file by zhashx_load, this method will reload the file if it has been modified since, and is "stable", i.e. not still changing. Returns 0 if OK, -1 if there was an error reloading the file. Serialize hash table to a binary frame that can be sent in a message. The packed format is compatible with the 'dictionary' type defined in http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: ; A list of name/value pairs dictionary = dict-count *( dict-name dict-value ) dict-count = number-4 dict-value = longstr dict-name = string ; Strings are always length + text contents longstr = number-4 *VCHAR string = number-1 *VCHAR ; Numbers are unsigned integers in network byte order number-1 = 1OCTET number-4 = 4OCTET Comments are not included in the packed data. Item values MUST be strings. Same as pack but uses a user-defined serializer function to convert items into longstr. Unpack binary frame into a new hash table. Packed data must follow format defined by zhashx_pack. Hash table is set to autofree. An empty frame unpacks to an empty hash table. Same as unpack but uses a user-defined deserializer function to convert a longstr back into item format. Make a copy of the list; items are duplicated if you set a duplicator for the list, otherwise not. Copying a null reference returns a null reference. Note that this method's behavior changed slightly for CZMQ v3.x, as it does not set nor respect autofree. It does however let you duplicate any hash table safely. The old behavior is in zhashx_dup_v2. Set a user-defined deallocator for hash items; by default items are not freed when the hash is destroyed. Set a user-defined duplicator for hash items; by default items are not copied when the hash is duplicated. Set a user-defined deallocator for keys; by default keys are freed when the hash is destroyed using free(). Set a user-defined duplicator for keys; by default keys are duplicated using strdup. Set a user-defined comparator for keys; by default keys are compared using strcmp. The callback function should return zero (0) on matching items. Set a user-defined hash function for keys; by default keys are hashed by a modified Bernstein hashing function. Make copy of hash table; if supplied table is null, returns null. Does not copy items themselves. Rebuilds new table so may be slow on very large tables. NOTE: only works with item values that are strings since there's no other way to know how to duplicate the item value. czmq-4.1.0/api/zlistx.api0000664000372000037200000002175613222211156016177 0ustar00travistravis00000000000000 extended generic list container Destroy an item Duplicate an item Compare two items, for sorting Create a new, empty list. Destroy a list. If an item destructor was specified, all items in the list are automatically destroyed as well. Add an item to the head of the list. Calls the item duplicator, if any, on the item. Resets cursor to list head. Returns an item handle on success, NULL if memory was exhausted. Add an item to the tail of the list. Calls the item duplicator, if any, on the item. Resets cursor to list head. Returns an item handle on success, NULL if memory was exhausted. Return the number of items in the list Return first item in the list, or null, leaves the cursor Return last item in the list, or null, leaves the cursor Return the item at the head of list. If the list is empty, returns NULL. Leaves cursor pointing at the head item, or NULL if the list is empty. Return the next item. At the end of the list (or in an empty list), returns NULL. Use repeated zlistx_next () calls to work through the list from zlistx_first (). First time, acts as zlistx_first(). Return the previous item. At the start of the list (or in an empty list), returns NULL. Use repeated zlistx_prev () calls to work through the list backwards from zlistx_last (). First time, acts as zlistx_last(). Return the item at the tail of list. If the list is empty, returns NULL. Leaves cursor pointing at the tail item, or NULL if the list is empty. Returns the value of the item at the cursor, or NULL if the cursor is not pointing to an item. Returns the handle of the item at the cursor, or NULL if the cursor is not pointing to an item. Returns the item associated with the given list handle, or NULL if passed in handle is NULL. Asserts that the passed in handle points to a list element. Find an item in the list, searching from the start. Uses the item comparator, if any, else compares item values directly. Returns the item handle found, or NULL. Sets the cursor to the found item, if any. Detach an item from the list, using its handle. The item is not modified, and the caller is responsible for destroying it if necessary. If handle is null, detaches the first item on the list. Returns item that was detached, or null if none was. If cursor was at item, moves cursor to previous item, so you can detach items while iterating forwards through a list. Detach item at the cursor, if any, from the list. The item is not modified, and the caller is responsible for destroying it as necessary. Returns item that was detached, or null if none was. Moves cursor to previous item, so you can detach items while iterating forwards through a list. Delete an item, using its handle. Calls the item destructor is any is set. If handle is null, deletes the first item on the list. Returns 0 if an item was deleted, -1 if not. If cursor was at item, moves cursor to previous item, so you can delete items while iterating forwards through a list. Move an item to the start of the list, via its handle. Move an item to the end of the list, via its handle. Remove all items from the list, and destroy them if the item destructor is set. Sort the list. If an item comparator was set, calls that to compare items, otherwise compares on item value. The sort is not stable, so may reorder equal items. Create a new node and insert it into a sorted list. Calls the item duplicator, if any, on the item. If low_value is true, starts searching from the start of the list, otherwise searches from the end. Use the item comparator, if any, to find where to place the new node. Returns a handle to the new node, or NULL if memory was exhausted. Resets the cursor to the list head. Move an item, specified by handle, into position in a sorted list. Uses the item comparator, if any, to determine the new location. If low_value is true, starts searching from the start of the list, otherwise searches from the end. Make a copy of the list; items are duplicated if you set a duplicator for the list, otherwise not. Copying a null reference returns a null reference. Set a user-defined deallocator for list items; by default items are not freed when the list is destroyed. Set a user-defined duplicator for list items; by default items are not copied when the list is duplicated. Set a user-defined comparator for zlistx_find and zlistx_sort; the method must return -1, 0, or 1 depending on whether item1 is less than, equal to, or greater than, item2. czmq-4.1.0/api/zargs.api0000664000372000037200000000674313222211156015767 0ustar00travistravis00000000000000 Platform independent command line argument parsing helpers There are two kind of elements provided by this class foo --named-parameter --parameter with_value positional arguments -a gain-parameter zargs keeps poision only for arguments, parameters are to be accessed like hash. It DOES: * provide easy to use CLASS compatible API for accessing argv * is platform independent * provide getopt_long style -- argument, which delimits parameters from arguments * makes parameters positon independent It does NOT * change argv * provide a "declarative" way to define command line interface In future it SHALL * hide several formats of command line to one (-Idir, --include=dir, --include dir are the same from API pov) Create a new zargs from command line arguments. Destroy zargs instance. Return program name (argv[0]) Return number of positional arguments Return first positional argument or NULL Return next positional argument or NULL Return first named parameter value, or NULL if there are no named parameters, or value for which zargs_param_empty (arg) returns true. Return next named parameter value, or NULL if there are no named parameters, or value for which zargs_param_empty (arg) returns true. Return current parameter name, or NULL if there are no named parameters. Return value of named parameter, NULL if no given parameter has been specified, or special value for wich zargs_param_empty () returns true. Return value of named parameter(s), NULL if no given parameter has been specified, or special value for wich zargs_param_empty () returns true. Returns true if there are --help -h arguments Returns true if parameter did not have a value Print an instance of zargs. czmq-4.1.0/api/zdir.api0000664000372000037200000001042313222211156015577 0ustar00travistravis00000000000000 work with file-system directories Create a new directory item that loads in the full tree of the specified path, optionally located under some parent path. If parent is "-", then loads only the top-level directory, and does not use parent as a path. Destroy a directory tree and all children it contains. Return directory path Return last modification time for directory. Return total hierarchy size, in bytes of data contained in all files in the directory tree. Return directory count Returns a sorted list of zfile objects; Each entry in the list is a pointer to a zfile_t item already allocated in the zdir tree. Do not destroy the original zdir tree until you are done with this list. Remove directory, optionally including all files that it contains, at all levels. If force is false, will only remove the directory if empty. If force is true, will remove all files and all subdirectories. Calculate differences between two versions of a directory tree. Returns a list of zdir_patch_t patches. Either older or newer may be null, indicating the directory is empty/absent. If alias is set, generates virtual filename (minus path, plus alias). Return full contents of directory as a zdir_patch list. Load directory cache; returns a hash table containing the SHA-1 digests of every file in the tree. The cache is saved between runs in .cache. Print contents of directory to open stream Print contents of directory to stdout Create a new zdir_watch actor instance: zactor_t *watch = zactor_new (zdir_watch, NULL); Destroy zdir_watch instance: zactor_destroy (&watch); Enable verbose logging of commands and activity: zstr_send (watch, "VERBOSE"); Subscribe to changes to a directory path: zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); Unsubscribe from changes to a directory path: zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); Receive directory changes: zsock_recv (watch, "sp", &path, &patches); // Delete the received data. free (path); zlist_destroy (&patches); czmq-4.1.0/api/ztrie.api0000664000372000037200000000547513222211156015777 0ustar00travistravis00000000000000 simple trie for tokenizable strings Callback function for ztrie_node to destroy node data. Creates a new ztrie. Destroy the ztrie. Inserts a new route into the tree and attaches the data. Returns -1 if the route already exists, otherwise 0. This method takes ownership of the provided data if a destroy_data_fn is provided. Removes a route from the trie and destroys its data. Returns -1 if the route does not exists, otherwise 0. the start of the list call zlist_first (). Advances the cursor. Returns true if the path matches a route in the tree, otherwise false. Returns the data of a matched route from last ztrie_matches. If the path did not match, returns NULL. Do not delete the data as it's owned by ztrie. Returns the count of parameters that a matched route has. Returns the parameters of a matched route with named regexes from last ztrie_matches. If the path did not match or the route did not contain any named regexes, returns NULL. Returns the asterisk matched part of a route, if there has been no match or no asterisk match, returns NULL. Print the trie czmq-4.1.0/configure0000775000372000037200000202473113222211332015277 0ustar00travistravis00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for czmq 4.1.0. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: zeromq-dev@lists.zeromq.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='czmq' PACKAGE_TARNAME='czmq' PACKAGE_VERSION='4.1.0' PACKAGE_STRING='czmq 4.1.0' PACKAGE_BUGREPORT='zeromq-dev@lists.zeromq.org' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='BUILD_VERSION BUILD_DATE BUILD_HOST BUILD_ARCH BUILD_USER am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS pkg_config_defines ENABLE_DRAFTS_FALSE ENABLE_DRAFTS_TRUE ENABLE_CZMQ_SELFTEST_FALSE ENABLE_CZMQ_SELFTEST_TRUE ENABLE_TEST_RANDOF_FALSE ENABLE_TEST_RANDOF_TRUE ENABLE_ZSP_FALSE ENABLE_ZSP_TRUE ENABLE_ZMAKECERT_FALSE ENABLE_ZMAKECERT_TRUE ENABLE_DIST_CMAKEFILES_FALSE ENABLE_DIST_CMAKEFILES_TRUE BUILD_DOC_FALSE BUILD_DOC_TRUE INSTALL_MAN_FALSE INSTALL_MAN_TRUE ON_GNU_FALSE ON_GNU_TRUE ON_LINUX_FALSE ON_LINUX_TRUE ON_ANDROID_FALSE ON_ANDROID_TRUE ON_CYGWIN_FALSE ON_CYGWIN_TRUE ON_MINGW_FALSE ON_MINGW_TRUE ENABLE_SHARED_FALSE ENABLE_SHARED_TRUE czmq_have_xmlto czmq_have_asciidoc pkg_config_libs_private pkgconfig_name_liblz4 lz4_LIBS lz4_CFLAGS pkgconfig_name_libsystemd systemd_LIBS systemd_CFLAGS pkgconfig_name_uuid uuid_LIBS uuid_CFLAGS pkgconfig_name_libzmq libzmq_LIBS libzmq_CFLAGS pkgconfigdir ENABLE_ASAN_FALSE ENABLE_ASAN_TRUE WITH_GCOV_FALSE WITH_GCOV_TRUE PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG CPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED LIBTOOL OBJDUMP DLLTOOL AS host_os host_vendor host_cpu host build_os build_vendor build_cpu build am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC USING_VPATH_FALSE USING_VPATH_TRUE LTVER AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking enable_shared enable_static with_pic enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock with_gcov enable_address_sanitizer with_pkgconfigdir with_libzmq with_uuid with_libsystemd with_liblz4 with_docs enable_dist_cmakefiles enable_zmakecert enable_zsp enable_test_randof enable_czmq_selftest enable_drafts enable_Werror ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR libzmq_CFLAGS libzmq_LIBS uuid_CFLAGS uuid_LIBS systemd_CFLAGS systemd_LIBS lz4_CFLAGS lz4_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures czmq 4.1.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/czmq] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of czmq 4.1.0:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --enable-address-sanitizer=yes/no Build with GCC Address Sanitizer instrumentation --enable-dist_cmakefiles Distribute CMakeLists.txt and related files [default depends: on if present and not cross compiling] --enable-zmakecert Compile and install 'zmakecert' [default=yes] --enable-zsp Compile 'zsp' in src [default=yes] --enable-test_randof Compile 'test_randof' in src [default=yes] --enable-czmq_selftest Compile 'czmq_selftest' in src [default=yes] --enable-drafts Build and install draft classes and methods [default=yes] --enable-Werror Add -Wall -Werror to GCC/GXX arguments [default=no; default=auto if nothing specified] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-gcov=yes/no With GCC Code Coverage reporting --with-pkgconfigdir=PATH Path to the pkgconfig directory [[LIBDIR/pkgconfig]] --with-libzmq yes or no. Optionally specify libzmq prefix (directory where its include/ and lib/ are located), but that is only used if pkgconfig metadata is not found first --with-uuid yes or no. Optionally specify uuid prefix (directory where its include/ and lib/ are located), but that is only used if pkgconfig metadata is not found first --with-libsystemd yes or no. Optionally specify libsystemd prefix (directory where its include/ and lib/ are located), but that is only used if pkgconfig metadata is not found first --with-liblz4 yes or no. Optionally specify liblz4 prefix (directory where its include/ and lib/ are located), but that is only used if pkgconfig metadata is not found first --with-docs Build and install man pages [default=yes] Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path libzmq_CFLAGS C compiler flags for libzmq, overriding pkg-config libzmq_LIBS linker flags for libzmq, overriding pkg-config uuid_CFLAGS C compiler flags for uuid, overriding pkg-config uuid_LIBS linker flags for uuid, overriding pkg-config systemd_CFLAGS C compiler flags for systemd, overriding pkg-config systemd_LIBS linker flags for systemd, overriding pkg-config lz4_CFLAGS C compiler flags for lz4, overriding pkg-config lz4_LIBS linker flags for lz4, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF czmq configure 4.1.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------------ ## ## Report this to zeromq-dev@lists.zeromq.org ## ## ------------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_find_uintX_t LINENO BITS VAR # ------------------------------------ # Finds an unsigned integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_uintX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 $as_echo_n "checking for uint$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : case $ac_type in #( uint$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_uintX_t cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by czmq $as_me 4.1.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in config "$srcdir"/config; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in config \"$srcdir\"/config" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. ac_config_headers="$ac_config_headers src/platform.h" am__api_version='1.14' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='czmq' VERSION='4.1.0' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar plaintar pax cpio none' # The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether UID '$am_uid' is supported by ustar format" >&5 $as_echo_n "checking whether UID '$am_uid' is supported by ustar format... " >&6; } if test $am_uid -le $am_max_uid; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } _am_tools=none fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether GID '$am_gid' is supported by ustar format" >&5 $as_echo_n "checking whether GID '$am_gid' is supported by ustar format... " >&6; } if test $am_gid -le $am_max_gid; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } _am_tools=none fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to create a ustar tar archive" >&5 $as_echo_n "checking how to create a ustar tar archive... " >&6; } # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_ustar-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do { echo "$as_me:$LINENO: $_am_tar --version" >&5 ($_am_tar --version) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && break done am__tar="$_am_tar --format=ustar -chf - "'"$$tardir"' am__tar_="$_am_tar --format=ustar -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x ustar -w "$$tardir"' am__tar_='pax -L -x ustar -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H ustar -L' am__tar_='find "$tardir" -print | cpio -o -H ustar -L' am__untar='cpio -i -H ustar -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_ustar}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file { echo "$as_me:$LINENO: tardir=conftest.dir && eval $am__tar_ >conftest.tar" >&5 (tardir=conftest.dir && eval $am__tar_ >conftest.tar) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } rm -rf conftest.dir if test -s conftest.tar; then { echo "$as_me:$LINENO: $am__untar &5 ($am__untar &5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { echo "$as_me:$LINENO: cat conftest.dir/file" >&5 (cat conftest.dir/file) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } grep GrepMe conftest.dir/file >/dev/null 2>&1 && break fi done rm -rf conftest.dir if ${am_cv_prog_tar_ustar+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_prog_tar_ustar=$_am_tool fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_tar_ustar" >&5 $as_echo "$am_cv_prog_tar_ustar" >&6; } # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=0;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' # This defines PACKAGE_VERSION_... in src/platform.h PV_MAJOR=`echo $PACKAGE_VERSION | cut -d . -f 1` PV_MINOR=`echo $PACKAGE_VERSION | cut -d . -f 2` PV_PATCH=`echo $PACKAGE_VERSION | cut -d . -f 3` cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION_MAJOR $PV_MAJOR _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION_MINOR $PV_MINOR _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION_PATCH $PV_PATCH _ACEOF # This lets us use PACKAGE_VERSION in Makefiles # # Libtool -version-info (ABI version) # # Currently 5:0:1 ("stable"). Don't change this unless you # know exactly what you're doing and have read and understand # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html # # libczmq -version-info LTVER="5:0:1" # building in a subdirectory? if test "x${srcdir}" != "x."; then USING_VPATH_TRUE= USING_VPATH_FALSE='#' else USING_VPATH_TRUE='#' USING_VPATH_FALSE= fi # Capture c flags CZMQ_ORIG_CFLAGS="${CFLAGS:-none}" # Checks for programs ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5 $as_echo_n "checking for $CC option to accept ISO C99... " >&6; } if ${ac_cv_prog_cc_c99+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include // Check varargs macros. These examples are taken from C99 6.10.3.5. #define debug(...) fprintf (stderr, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK your preprocessor is broken; #endif #if BIG_OK #else your preprocessor is broken; #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\0'; ++i) continue; return 0; } // Check varargs and va_copy. static void test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str; int number; float fnumber; while (*format) { switch (*format++) { case 's': // string str = va_arg (args_copy, const char *); break; case 'd': // int number = va_arg (args_copy, int); break; case 'f': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); } int main () { // Check bool. _Bool success = false; // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. test_varargs ("s, d' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' || dynamic_array[ni.number - 1] != 543); ; return 0; } _ACEOF for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c99=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c99" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c99" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 $as_echo "$ac_cv_prog_cc_c99" >&6; } ;; esac if test "x$ac_cv_prog_cc_c99" != xno; then : fi # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AS"; then ac_cv_prog_AS="$AS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AS="${ac_tool_prefix}as" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AS=$ac_cv_prog_AS if test -n "$AS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 $as_echo "$AS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_AS"; then ac_ct_AS=$AS # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AS"; then ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AS="as" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AS=$ac_cv_prog_ac_ct_AS if test -n "$ac_ct_AS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 $as_echo "$ac_ct_AS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_AS" = x; then AS="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AS=$ac_ct_AS fi else AS="$ac_cv_prog_AS" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi ;; esac test -z "$AS" && AS=as test -z "$DLLTOOL" && DLLTOOL=dlltool test -z "$OBJDUMP" && OBJDUMP=objdump case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.2' macro_revision='1.3337' ltmain="$ac_aux_dir/ltmain.sh" # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_dlopen=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi link_all_deplibs=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi # Check endianess of the system { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac # Optional project-local hook (acinclude.m4, add AC_DEFUN([AX_PROJECT_LOCAL_HOOK], [whatever]) ) for ac_header in pthread.h do : ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTHREAD_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 $as_echo_n "checking for pthread_create in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_create=yes else ac_cv_lib_pthread_pthread_create=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 $as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : CFLAGS="${CFLAGS} -pthread" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot link with -pthread." >&5 $as_echo "$as_me: WARNING: cannot link with -pthread." >&2;} fi # Code coverage { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable GCov" >&5 $as_echo_n "checking whether to enable GCov... " >&6; } # Check whether --with-gcov was given. if test "${with_gcov+set}" = set; then : withval=$with_gcov; CZMQ_GCOV="$withval" fi if test "x${CZMQ_GCOV}" == "xyes"; then CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" if test "x${CZMQ_ORIG_CFLAGS}" != "xnone"; then CFLAGS="${CFLAGS} ${CZMQ_ORIG_CFLAGS}" fi if true; then WITH_GCOV_TRUE= WITH_GCOV_FALSE='#' else WITH_GCOV_TRUE='#' WITH_GCOV_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else if false; then WITH_GCOV_TRUE= WITH_GCOV_FALSE='#' else WITH_GCOV_TRUE='#' WITH_GCOV_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Memory mis-use detection { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable ASan" >&5 $as_echo_n "checking whether to enable ASan... " >&6; } # Check whether --enable-address-sanitizer was given. if test "${enable_address_sanitizer+set}" = set; then : enableval=$enable_address_sanitizer; CZMQ_ASAN="$enableval" fi if test "x${CZMQ_ASAN}" == "xyes"; then CFLAGS="${CFLAGS} -fsanitize=address" CXXFLAGS="${CXXFLAGS} -fsanitize=address" if true; then ENABLE_ASAN_TRUE= ENABLE_ASAN_FALSE='#' else ENABLE_ASAN_TRUE='#' ENABLE_ASAN_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else if false; then ENABLE_ASAN_TRUE= ENABLE_ASAN_FALSE='#' else ENABLE_ASAN_TRUE='#' ENABLE_ASAN_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Set pkgconfigdir # Check whether --with-pkgconfigdir was given. if test "${with_pkgconfigdir+set}" = set; then : withval=$with_pkgconfigdir; pkgconfigdir="$withval" else pkgconfigdir='${libdir}/pkgconfig' fi # Use the provided pkgconfigdir not only to write our pkg-config data, # but also as an additional location to look for other packages metadata. if test -n "${pkgconfigdir}" -a -d "${pkgconfigdir}"; then : if test -z "${PKG_CONFIG_PATH}"; then : PKG_CONFIG_PATH="${pkgconfigdir}" else PKG_CONFIG_PATH="${pkgconfigdir}:${PKG_CONFIG_PATH}" fi export PKG_CONFIG_PATH fi # Will be used to add flags to pkg-config useful when apps want to statically link PKGCFG_LIBS_PRIVATE="" # Archive user supplied flags PREVIOUS_CFLAGS="${CFLAGS}" PREVIOUS_LIBS="${LIBS}" was_libzmq_check_lib_detected=no search_libzmq="yes" # Check whether --with-libzmq was given. if test "${with_libzmq+set}" = set; then : withval=$with_libzmq; search_libzmq="yes" fi case x"${with_libzmq}" in #( xyes) : search_libzmq="yes" ;; #( xno) : search_libzmq="no" ;; #( *) : ;; esac if test x"${search_libzmq}" = xno; then : { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Required dependency on libzmq was explicitly disabled during configuration by '--with-libzmq=no'; subsequent full build of czmq may fail" >&5 $as_echo "$as_me: WARNING: Required dependency on libzmq was explicitly disabled during configuration by '--with-libzmq=no'; subsequent full build of czmq may fail" >&2;} fi if test x"${search_libzmq}" = xyes; then : # Archive previously detected and supplied flags PRE_SEARCH_CFLAGS="${CFLAGS}" PRE_SEARCH_LIBS="${LIBS}" found_pkgconfig="" found_linkname="" pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzmq" >&5 $as_echo_n "checking for libzmq... " >&6; } if test -n "$libzmq_CFLAGS"; then pkg_cv_libzmq_CFLAGS="$libzmq_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzmq >= 0.0.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "libzmq >= 0.0.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_libzmq_CFLAGS=`$PKG_CONFIG --cflags "libzmq >= 0.0.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$libzmq_LIBS"; then pkg_cv_libzmq_LIBS="$libzmq_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzmq >= 0.0.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "libzmq >= 0.0.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_libzmq_LIBS=`$PKG_CONFIG --libs "libzmq >= 0.0.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then libzmq_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libzmq >= 0.0.0" 2>&1` else libzmq_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libzmq >= 0.0.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$libzmq_PKG_ERRORS" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: Package libzmq not found; falling back to defined compilability tests" >&5 $as_echo "$as_me: Package libzmq not found; falling back to defined compilability tests" >&6;} libzmq_synthetic_cflags="" libzmq_synthetic_libs="-lzmq" if test -n "${with_libzmq}" && test x"${with_libzmq}" != xyes && test x"${with_libzmq}" != xno; then if test -r "${with_libzmq}/include/zmq.h"; then libzmq_synthetic_cflags="-I${with_libzmq}/include" libzmq_synthetic_libs="-L${with_libzmq}/lib -lzmq" else as_fn_error $? "Header file ${with_libzmq}/include/zmq.h was not found. Please check libzmq prefix" "$LINENO" 5 fi else ac_fn_c_check_header_mongrel "$LINENO" "zmq.h" "ac_cv_header_zmq_h" "$ac_includes_default" if test "x$ac_cv_header_zmq_h" = xyes; then : else as_fn_error $? "Header file zmq.h was not found in default search paths" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zmq_init in -lzmq" >&5 $as_echo_n "checking for zmq_init in -lzmq... " >&6; } if ${ac_cv_lib_zmq_zmq_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lzmq $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char zmq_init (); int main () { return zmq_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_zmq_zmq_init=yes else ac_cv_lib_zmq_zmq_init=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_zmq_zmq_init" >&5 $as_echo "$ac_cv_lib_zmq_zmq_init" >&6; } if test "x$ac_cv_lib_zmq_zmq_init" = xyes; then : was_libzmq_check_lib_detected=yes PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -lzmq" found_linkname="zmq" else as_fn_error $? "cannot link with -lzmq, install libzmq" "$LINENO" 5 fi elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: Package libzmq not found; falling back to defined compilability tests" >&5 $as_echo "$as_me: Package libzmq not found; falling back to defined compilability tests" >&6;} libzmq_synthetic_cflags="" libzmq_synthetic_libs="-lzmq" if test -n "${with_libzmq}" && test x"${with_libzmq}" != xyes && test x"${with_libzmq}" != xno; then if test -r "${with_libzmq}/include/zmq.h"; then libzmq_synthetic_cflags="-I${with_libzmq}/include" libzmq_synthetic_libs="-L${with_libzmq}/lib -lzmq" else as_fn_error $? "Header file ${with_libzmq}/include/zmq.h was not found. Please check libzmq prefix" "$LINENO" 5 fi else ac_fn_c_check_header_mongrel "$LINENO" "zmq.h" "ac_cv_header_zmq_h" "$ac_includes_default" if test "x$ac_cv_header_zmq_h" = xyes; then : else as_fn_error $? "Header file zmq.h was not found in default search paths" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zmq_init in -lzmq" >&5 $as_echo_n "checking for zmq_init in -lzmq... " >&6; } if ${ac_cv_lib_zmq_zmq_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lzmq $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char zmq_init (); int main () { return zmq_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_zmq_zmq_init=yes else ac_cv_lib_zmq_zmq_init=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_zmq_zmq_init" >&5 $as_echo "$ac_cv_lib_zmq_zmq_init" >&6; } if test "x$ac_cv_lib_zmq_zmq_init" = xyes; then : was_libzmq_check_lib_detected=yes PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -lzmq" found_linkname="zmq" else as_fn_error $? "cannot link with -lzmq, install libzmq" "$LINENO" 5 fi else libzmq_CFLAGS=$pkg_cv_libzmq_CFLAGS libzmq_LIBS=$pkg_cv_libzmq_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE $libzmq_LIBS" was_libzmq_check_lib_detected=pkgcfg found_pkgconfig="libzmq" fi case "x${was_libzmq_check_lib_detected}" in #( xpkgcfg) : pkgconfig_name_libzmq=${found_pkgconfig} CFLAGS="${libzmq_CFLAGS} ${CFLAGS}" LIBS="${libzmq_LIBS} ${LIBS}" ;; #( xyes) : pkgconfig_name_libzmq=${found_linkname} CFLAGS="${libzmq_synthetic_cflags} ${CFLAGS}" LDFLAGS="${libzmq_synthetic_libs} ${LDFLAGS}" LIBS="${libzmq_synthetic_libs} ${LIBS}" libzmq_CFLAGS=${libzmq_synthetic_cflags} libzmq_LIBS=${libzmq_synthetic_libs} ;; #( xno) : pkgconfig_name_libzmq=libzmq as_fn_error $? "Cannot find pkg-config metadata for libzmq 0.0.0 or higher" "$LINENO" 5 ;; #( *) : ;; esac fi was_uuid_check_lib_detected=no search_uuid="no" # Check whether --with-uuid was given. if test "${with_uuid+set}" = set; then : withval=$with_uuid; search_uuid="yes" fi case x"${with_uuid}" in #( xyes) : search_uuid="yes" ;; #( xno) : search_uuid="no" ;; #( *) : ;; esac if test x"${search_uuid}" = xyes; then : # Archive previously detected and supplied flags PRE_SEARCH_CFLAGS="${CFLAGS}" PRE_SEARCH_LIBS="${LIBS}" found_pkgconfig="" found_linkname="" pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid" >&5 $as_echo_n "checking for uuid... " >&6; } if test -n "$uuid_CFLAGS"; then pkg_cv_uuid_CFLAGS="$uuid_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"uuid >= 0.0.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "uuid >= 0.0.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_uuid_CFLAGS=`$PKG_CONFIG --cflags "uuid >= 0.0.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$uuid_LIBS"; then pkg_cv_uuid_LIBS="$uuid_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"uuid >= 0.0.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "uuid >= 0.0.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_uuid_LIBS=`$PKG_CONFIG --libs "uuid >= 0.0.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then uuid_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "uuid >= 0.0.0" 2>&1` else uuid_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "uuid >= 0.0.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$uuid_PKG_ERRORS" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: Package uuid not found; falling back to defined compilability tests" >&5 $as_echo "$as_me: Package uuid not found; falling back to defined compilability tests" >&6;} uuid_synthetic_cflags="" uuid_synthetic_libs="-luuid" if test -n "${with_uuid}" && test x"${with_uuid}" != xyes && test x"${with_uuid}" != xno; then if test -r "${with_uuid}/include/uuid/uuid.h"; then uuid_synthetic_cflags="-I${with_uuid}/include" uuid_synthetic_libs="-L${with_uuid}/lib -luuid" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Header file ${with_uuid}/include/uuid/uuid.h was not found. Please check uuid prefix" >&5 $as_echo "$as_me: WARNING: Header file ${with_uuid}/include/uuid/uuid.h was not found. Please check uuid prefix" >&2;} fi else ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default" if test "x$ac_cv_header_uuid_uuid_h" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Header file uuid/uuid.h was not found in default search paths" >&5 $as_echo "$as_me: WARNING: Header file uuid/uuid.h was not found in default search paths" >&2;} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate in -luuid" >&5 $as_echo_n "checking for uuid_generate in -luuid... " >&6; } if ${ac_cv_lib_uuid_uuid_generate+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-luuid $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char uuid_generate (); int main () { return uuid_generate (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_uuid_uuid_generate=yes else ac_cv_lib_uuid_uuid_generate=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate" >&5 $as_echo "$ac_cv_lib_uuid_uuid_generate" >&6; } if test "x$ac_cv_lib_uuid_uuid_generate" = xyes; then : was_uuid_check_lib_detected=yes PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -luuid" found_linkname="uuid" $as_echo "#define HAVE_UUID 1" >>confdefs.h fi elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: Package uuid not found; falling back to defined compilability tests" >&5 $as_echo "$as_me: Package uuid not found; falling back to defined compilability tests" >&6;} uuid_synthetic_cflags="" uuid_synthetic_libs="-luuid" if test -n "${with_uuid}" && test x"${with_uuid}" != xyes && test x"${with_uuid}" != xno; then if test -r "${with_uuid}/include/uuid/uuid.h"; then uuid_synthetic_cflags="-I${with_uuid}/include" uuid_synthetic_libs="-L${with_uuid}/lib -luuid" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Header file ${with_uuid}/include/uuid/uuid.h was not found. Please check uuid prefix" >&5 $as_echo "$as_me: WARNING: Header file ${with_uuid}/include/uuid/uuid.h was not found. Please check uuid prefix" >&2;} fi else ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default" if test "x$ac_cv_header_uuid_uuid_h" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Header file uuid/uuid.h was not found in default search paths" >&5 $as_echo "$as_me: WARNING: Header file uuid/uuid.h was not found in default search paths" >&2;} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate in -luuid" >&5 $as_echo_n "checking for uuid_generate in -luuid... " >&6; } if ${ac_cv_lib_uuid_uuid_generate+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-luuid $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char uuid_generate (); int main () { return uuid_generate (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_uuid_uuid_generate=yes else ac_cv_lib_uuid_uuid_generate=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate" >&5 $as_echo "$ac_cv_lib_uuid_uuid_generate" >&6; } if test "x$ac_cv_lib_uuid_uuid_generate" = xyes; then : was_uuid_check_lib_detected=yes PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -luuid" found_linkname="uuid" $as_echo "#define HAVE_UUID 1" >>confdefs.h fi else uuid_CFLAGS=$pkg_cv_uuid_CFLAGS uuid_LIBS=$pkg_cv_uuid_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_UUID 1" >>confdefs.h PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE $uuid_LIBS" was_uuid_check_lib_detected=pkgcfg found_pkgconfig="uuid" fi case "x${was_uuid_check_lib_detected}" in #( xpkgcfg) : pkgconfig_name_uuid=${found_pkgconfig} CFLAGS="${uuid_CFLAGS} ${CFLAGS}" LIBS="${uuid_LIBS} ${LIBS}" ;; #( xyes) : pkgconfig_name_uuid=${found_linkname} CFLAGS="${uuid_synthetic_cflags} ${CFLAGS}" LDFLAGS="${uuid_synthetic_libs} ${LDFLAGS}" LIBS="${uuid_synthetic_libs} ${LIBS}" uuid_CFLAGS=${uuid_synthetic_cflags} uuid_LIBS=${uuid_synthetic_libs} ;; #( xno) : pkgconfig_name_uuid=uuid { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find pkg-config metadata for uuid 0.0.0 or higher" >&5 $as_echo "$as_me: WARNING: Cannot find pkg-config metadata for uuid 0.0.0 or higher" >&2;} ;; #( *) : ;; esac fi was_systemd_check_lib_detected=no search_libsystemd="no" # Check whether --with-libsystemd was given. if test "${with_libsystemd+set}" = set; then : withval=$with_libsystemd; search_libsystemd="yes" fi case x"${with_libsystemd}" in #( xyes) : search_libsystemd="yes" ;; #( xno) : search_libsystemd="no" ;; #( *) : ;; esac if test x"${search_libsystemd}" = xyes; then : # Archive previously detected and supplied flags PRE_SEARCH_CFLAGS="${CFLAGS}" PRE_SEARCH_LIBS="${LIBS}" found_pkgconfig="" found_linkname="" pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for systemd" >&5 $as_echo_n "checking for systemd... " >&6; } if test -n "$systemd_CFLAGS"; then pkg_cv_systemd_CFLAGS="$systemd_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libsystemd >= 200.0.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "libsystemd >= 200.0.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_systemd_CFLAGS=`$PKG_CONFIG --cflags "libsystemd >= 200.0.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$systemd_LIBS"; then pkg_cv_systemd_LIBS="$systemd_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libsystemd >= 200.0.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "libsystemd >= 200.0.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_systemd_LIBS=`$PKG_CONFIG --libs "libsystemd >= 200.0.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then systemd_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libsystemd >= 200.0.0" 2>&1` else systemd_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libsystemd >= 200.0.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$systemd_PKG_ERRORS" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: Package libsystemd not found with needed constraints; falling back to defined compilability tests" >&5 $as_echo "$as_me: Package libsystemd not found with needed constraints; falling back to defined compilability tests" >&6;} systemd_synthetic_cflags="" systemd_synthetic_libs="-lsystemd" if test -n "${with_libsystemd}" && test x"${with_libsystemd}" != xyes && test x"${with_libsystemd}" != xno; then if test -r "${with_libsystemd}/include/systemd/sd-daemon.h"; then systemd_synthetic_cflags="-I${with_libsystemd}/include" systemd_synthetic_libs="-L${with_libsystemd}/lib -lsystemd" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Header file ${with_libsystemd}/include/systemd/sd-daemon.h was not found. Please check libsystemd prefix" >&5 $as_echo "$as_me: WARNING: Header file ${with_libsystemd}/include/systemd/sd-daemon.h was not found. Please check libsystemd prefix" >&2;} fi else ac_fn_c_check_header_mongrel "$LINENO" "systemd/sd-daemon.h" "ac_cv_header_systemd_sd_daemon_h" "$ac_includes_default" if test "x$ac_cv_header_systemd_sd_daemon_h" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Header file systemd/sd-daemon.h was not found in default search paths" >&5 $as_echo "$as_me: WARNING: Header file systemd/sd-daemon.h was not found in default search paths" >&2;} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sd_listen_fds in -llibsystemd" >&5 $as_echo_n "checking for sd_listen_fds in -llibsystemd... " >&6; } if ${ac_cv_lib_libsystemd_sd_listen_fds+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-llibsystemd $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char sd_listen_fds (); int main () { return sd_listen_fds (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_libsystemd_sd_listen_fds=yes else ac_cv_lib_libsystemd_sd_listen_fds=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_libsystemd_sd_listen_fds" >&5 $as_echo "$ac_cv_lib_libsystemd_sd_listen_fds" >&6; } if test "x$ac_cv_lib_libsystemd_sd_listen_fds" = xyes; then : was_systemd_check_lib_detected=yes PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -lsystemd" found_linkname="systemd" $as_echo "#define HAVE_LIBSYSTEMD 1" >>confdefs.h fi elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: Package libsystemd not found with needed constraints; falling back to defined compilability tests" >&5 $as_echo "$as_me: Package libsystemd not found with needed constraints; falling back to defined compilability tests" >&6;} systemd_synthetic_cflags="" systemd_synthetic_libs="-lsystemd" if test -n "${with_libsystemd}" && test x"${with_libsystemd}" != xyes && test x"${with_libsystemd}" != xno; then if test -r "${with_libsystemd}/include/systemd/sd-daemon.h"; then systemd_synthetic_cflags="-I${with_libsystemd}/include" systemd_synthetic_libs="-L${with_libsystemd}/lib -lsystemd" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Header file ${with_libsystemd}/include/systemd/sd-daemon.h was not found. Please check libsystemd prefix" >&5 $as_echo "$as_me: WARNING: Header file ${with_libsystemd}/include/systemd/sd-daemon.h was not found. Please check libsystemd prefix" >&2;} fi else ac_fn_c_check_header_mongrel "$LINENO" "systemd/sd-daemon.h" "ac_cv_header_systemd_sd_daemon_h" "$ac_includes_default" if test "x$ac_cv_header_systemd_sd_daemon_h" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Header file systemd/sd-daemon.h was not found in default search paths" >&5 $as_echo "$as_me: WARNING: Header file systemd/sd-daemon.h was not found in default search paths" >&2;} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sd_listen_fds in -llibsystemd" >&5 $as_echo_n "checking for sd_listen_fds in -llibsystemd... " >&6; } if ${ac_cv_lib_libsystemd_sd_listen_fds+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-llibsystemd $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char sd_listen_fds (); int main () { return sd_listen_fds (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_libsystemd_sd_listen_fds=yes else ac_cv_lib_libsystemd_sd_listen_fds=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_libsystemd_sd_listen_fds" >&5 $as_echo "$ac_cv_lib_libsystemd_sd_listen_fds" >&6; } if test "x$ac_cv_lib_libsystemd_sd_listen_fds" = xyes; then : was_systemd_check_lib_detected=yes PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -lsystemd" found_linkname="systemd" $as_echo "#define HAVE_LIBSYSTEMD 1" >>confdefs.h fi else systemd_CFLAGS=$pkg_cv_systemd_CFLAGS systemd_LIBS=$pkg_cv_systemd_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LIBSYSTEMD 1" >>confdefs.h PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE $systemd_LIBS" was_systemd_check_lib_detected=pkgcfg found_pkgconfig="libsystemd" fi case "x${was_systemd_check_lib_detected}" in #( xpkgcfg) : pkgconfig_name_libsystemd=${found_pkgconfig} CFLAGS="${systemd_CFLAGS} ${CFLAGS}" LIBS="${systemd_LIBS} ${LIBS}" ;; #( xyes) : pkgconfig_name_libsystemd=${found_linkname} CFLAGS="${systemd_synthetic_cflags} ${CFLAGS}" LDFLAGS="${systemd_synthetic_libs} ${LDFLAGS}" LIBS="${systemd_synthetic_libs} ${LIBS}" systemd_CFLAGS=${systemd_synthetic_cflags} systemd_LIBS=${systemd_synthetic_libs} ;; #( xno) : pkgconfig_name_libsystemd=libsystemd { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find pkg-config metadata for libsystemd 200.0.0 or higher" >&5 $as_echo "$as_me: WARNING: Cannot find pkg-config metadata for libsystemd 200.0.0 or higher" >&2;} ;; #( *) : ;; esac fi was_lz4_check_lib_detected=no search_liblz4="no" # Check whether --with-liblz4 was given. if test "${with_liblz4+set}" = set; then : withval=$with_liblz4; search_liblz4="yes" fi case x"${with_liblz4}" in #( xyes) : search_liblz4="yes" ;; #( xno) : search_liblz4="no" ;; #( *) : ;; esac if test x"${search_liblz4}" = xyes; then : # Archive previously detected and supplied flags PRE_SEARCH_CFLAGS="${CFLAGS}" PRE_SEARCH_LIBS="${LIBS}" found_pkgconfig="" found_linkname="" pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lz4" >&5 $as_echo_n "checking for lz4... " >&6; } if test -n "$lz4_CFLAGS"; then pkg_cv_lz4_CFLAGS="$lz4_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"liblz4 >= 0.0.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "liblz4 >= 0.0.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_lz4_CFLAGS=`$PKG_CONFIG --cflags "liblz4 >= 0.0.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$lz4_LIBS"; then pkg_cv_lz4_LIBS="$lz4_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"liblz4 >= 0.0.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "liblz4 >= 0.0.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_lz4_LIBS=`$PKG_CONFIG --libs "liblz4 >= 0.0.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then lz4_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "liblz4 >= 0.0.0" 2>&1` else lz4_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "liblz4 >= 0.0.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$lz4_PKG_ERRORS" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: Package liblz4 not found; falling back to defined compilability tests" >&5 $as_echo "$as_me: Package liblz4 not found; falling back to defined compilability tests" >&6;} lz4_synthetic_cflags="" lz4_synthetic_libs="-llz4" if test -n "${with_liblz4}" && test x"${with_liblz4}" != xyes && test x"${with_liblz4}" != xno; then if test -r "${with_liblz4}/include/lz4.h"; then lz4_synthetic_cflags="-I${with_liblz4}/include" lz4_synthetic_libs="-L${with_liblz4}/lib -llz4" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Header file ${with_liblz4}/include/lz4.h was not found. Please check liblz4 prefix" >&5 $as_echo "$as_me: WARNING: Header file ${with_liblz4}/include/lz4.h was not found. Please check liblz4 prefix" >&2;} fi else ac_fn_c_check_header_mongrel "$LINENO" "lz4.h" "ac_cv_header_lz4_h" "$ac_includes_default" if test "x$ac_cv_header_lz4_h" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Header file lz4.h was not found in default search paths" >&5 $as_echo "$as_me: WARNING: Header file lz4.h was not found in default search paths" >&2;} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LZ4_decompress_safe in -llz4" >&5 $as_echo_n "checking for LZ4_decompress_safe in -llz4... " >&6; } if ${ac_cv_lib_lz4_LZ4_decompress_safe+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-llz4 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char LZ4_decompress_safe (); int main () { return LZ4_decompress_safe (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_lz4_LZ4_decompress_safe=yes else ac_cv_lib_lz4_LZ4_decompress_safe=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lz4_LZ4_decompress_safe" >&5 $as_echo "$ac_cv_lib_lz4_LZ4_decompress_safe" >&6; } if test "x$ac_cv_lib_lz4_LZ4_decompress_safe" = xyes; then : was_lz4_check_lib_detected=yes PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -llz4" found_linkname="lz4" $as_echo "#define HAVE_LIBLZ4 1" >>confdefs.h fi elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: Package liblz4 not found; falling back to defined compilability tests" >&5 $as_echo "$as_me: Package liblz4 not found; falling back to defined compilability tests" >&6;} lz4_synthetic_cflags="" lz4_synthetic_libs="-llz4" if test -n "${with_liblz4}" && test x"${with_liblz4}" != xyes && test x"${with_liblz4}" != xno; then if test -r "${with_liblz4}/include/lz4.h"; then lz4_synthetic_cflags="-I${with_liblz4}/include" lz4_synthetic_libs="-L${with_liblz4}/lib -llz4" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Header file ${with_liblz4}/include/lz4.h was not found. Please check liblz4 prefix" >&5 $as_echo "$as_me: WARNING: Header file ${with_liblz4}/include/lz4.h was not found. Please check liblz4 prefix" >&2;} fi else ac_fn_c_check_header_mongrel "$LINENO" "lz4.h" "ac_cv_header_lz4_h" "$ac_includes_default" if test "x$ac_cv_header_lz4_h" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Header file lz4.h was not found in default search paths" >&5 $as_echo "$as_me: WARNING: Header file lz4.h was not found in default search paths" >&2;} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LZ4_decompress_safe in -llz4" >&5 $as_echo_n "checking for LZ4_decompress_safe in -llz4... " >&6; } if ${ac_cv_lib_lz4_LZ4_decompress_safe+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-llz4 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char LZ4_decompress_safe (); int main () { return LZ4_decompress_safe (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_lz4_LZ4_decompress_safe=yes else ac_cv_lib_lz4_LZ4_decompress_safe=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lz4_LZ4_decompress_safe" >&5 $as_echo "$ac_cv_lib_lz4_LZ4_decompress_safe" >&6; } if test "x$ac_cv_lib_lz4_LZ4_decompress_safe" = xyes; then : was_lz4_check_lib_detected=yes PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -llz4" found_linkname="lz4" $as_echo "#define HAVE_LIBLZ4 1" >>confdefs.h fi else lz4_CFLAGS=$pkg_cv_lz4_CFLAGS lz4_LIBS=$pkg_cv_lz4_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LIBLZ4 1" >>confdefs.h PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE $lz4_LIBS" was_lz4_check_lib_detected=pkgcfg found_pkgconfig="liblz4" fi case "x${was_lz4_check_lib_detected}" in #( xpkgcfg) : pkgconfig_name_liblz4=${found_pkgconfig} CFLAGS="${lz4_CFLAGS} ${CFLAGS}" LIBS="${lz4_LIBS} ${LIBS}" ;; #( xyes) : pkgconfig_name_liblz4=${found_linkname} CFLAGS="${lz4_synthetic_cflags} ${CFLAGS}" LDFLAGS="${lz4_synthetic_libs} ${LDFLAGS}" LIBS="${lz4_synthetic_libs} ${LIBS}" lz4_CFLAGS=${lz4_synthetic_cflags} lz4_LIBS=${lz4_synthetic_libs} ;; #( xno) : pkgconfig_name_liblz4=liblz4 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find pkg-config metadata for liblz4 0.0.0 or higher" >&5 $as_echo "$as_me: WARNING: Cannot find pkg-config metadata for liblz4 0.0.0 or higher" >&2;} ;; #( *) : ;; esac fi CFLAGS="${PREVIOUS_CFLAGS}" LIBS="${PREVIOUS_LIBS}" pkg_config_libs_private=$PKGCFG_LIBS_PRIVATE # Platform specific checks czmq_on_mingw32="no" czmq_on_cygwin="no" czmq_on_android="no" czmq_on_linux="no" czmq_on_gnu="no" # Host specific checks # Man pages are built/installed if asciidoc and xmlto are present # --with-docs=no overrides this # Check whether --with-docs was given. if test "${with_docs+set}" = set; then : withval=$with_docs; with_docs=$withval fi if test "x$with_docs" = "xno"; then czmq_build_doc="no" czmq_install_man="no" else # Determine whether or not documentation should be built and installed. czmq_build_doc="yes" czmq_install_man="yes" # Check for asciidoc and xmlto and don't build the docs if these are not installed. # Extract the first word of "asciidoc", so it can be a program name with args. set dummy asciidoc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_czmq_have_asciidoc+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$czmq_have_asciidoc"; then ac_cv_prog_czmq_have_asciidoc="$czmq_have_asciidoc" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_czmq_have_asciidoc="yes" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_czmq_have_asciidoc" && ac_cv_prog_czmq_have_asciidoc="no" fi fi czmq_have_asciidoc=$ac_cv_prog_czmq_have_asciidoc if test -n "$czmq_have_asciidoc"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $czmq_have_asciidoc" >&5 $as_echo "$czmq_have_asciidoc" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "xmlto", so it can be a program name with args. set dummy xmlto; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_czmq_have_xmlto+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$czmq_have_xmlto"; then ac_cv_prog_czmq_have_xmlto="$czmq_have_xmlto" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_czmq_have_xmlto="yes" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_czmq_have_xmlto" && ac_cv_prog_czmq_have_xmlto="no" fi fi czmq_have_xmlto=$ac_cv_prog_czmq_have_xmlto if test -n "$czmq_have_xmlto"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $czmq_have_xmlto" >&5 $as_echo "$czmq_have_xmlto" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$czmq_have_asciidoc" = "xno" -o "x$czmq_have_xmlto" = "xno"; then if test "x$with_docs" = "xyes" ; then as_fn_error $? "Build with docs was explicitly requested, but tools are not available" "$LINENO" 5 fi czmq_build_doc="no" # Tarballs built with 'make dist' ship with prebuilt documentation. if ! test -f doc/czmq.7; then czmq_install_man="no" { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You are building an unreleased version of CZMQ and asciidoc or xmlto are not installed." >&5 $as_echo "$as_me: WARNING: You are building an unreleased version of CZMQ and asciidoc or xmlto are not installed." >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Documentation will not be built and manual pages will not be installed." >&5 $as_echo "$as_me: WARNING: Documentation will not be built and manual pages will not be installed." >&2;} fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build documentation" >&5 $as_echo_n "checking whether to build documentation... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $czmq_build_doc" >&5 $as_echo "$czmq_build_doc" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install manpages" >&5 $as_echo_n "checking whether to install manpages... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $czmq_install_man" >&5 $as_echo "$czmq_install_man" >&6; } # Set some default features required by libczmq code. CPPFLAGS="-DCZMQ_INTERNAL_BUILD -D_REENTRANT -D_THREAD_SAFE $CPPFLAGS" # OS-specific tests case "${host_os}" in *linux*) # Define on Linux to enable all library features CPPFLAGS="-D_GNU_SOURCE -DLINUX $CPPFLAGS" $as_echo "#define CZMQ_HAVE_LINUX 1" >>confdefs.h czmq_on_linux="yes" case "${host_os}" in *android*) $as_echo "#define CZMQ_HAVE_ANDROID 1" >>confdefs.h czmq_on_android="yes" ;; esac ;; *solaris*) # Define on Solaris to enable all library features CPPFLAGS="-D_PTHREADS $CPPFLAGS" # Allow definitions of common OS-provided functions that are not in old standards CPPFLAGS="-D__EXTENSIONS__ $CPPFLAGS" $as_echo "#define CZMQ_HAVE_SOLARIS 1" >>confdefs.h CFLAGS="${CFLAGS} -lsocket -lssp" ;; *freebsd*) # Define on FreeBSD to enable all library features CPPFLAGS="-D__BSD_VISIBLE $CPPFLAGS" $as_echo "#define CZMQ_HAVE_FREEBSD 1" >>confdefs.h ;; *darwin*) # Define on Darwin to enable all library features CPPFLAGS="-D_DARWIN_C_SOURCE $CPPFLAGS" $as_echo "#define CZMQ_HAVE_OSX 1" >>confdefs.h ;; *netbsd*) # Define on NetBSD to enable all library features CPPFLAGS="-D_NETBSD_SOURCE $CPPFLAGS" $as_echo "#define CZMQ_HAVE_NETBSD 1" >>confdefs.h ;; *openbsd*) # Define on OpenBSD to enable all library features CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS" $as_echo "#define CZMQ_HAVE_OPENBSD 1" >>confdefs.h ;; *nto-qnx*) $as_echo "#define CZMQ_HAVE_QNXNTO 1" >>confdefs.h ;; *aix*) $as_echo "#define CZMQ_HAVE_AIX 1" >>confdefs.h ;; *hpux*) # Define on HP-UX to enable all library features CPPFLAGS="-D_POSIX_C_SOURCE=200112L" $as_echo "#define CZMQ_HAVE_HPUX 1" >>confdefs.h ;; *mingw32*) # Disable format error due to incomplete ANSI C CFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CFLAGS" CPPFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CPPFLAGS" $as_echo "#define CZMQ_HAVE_WINDOWS 1" >>confdefs.h $as_echo "#define CZMQ_HAVE_MINGW32 1" >>confdefs.h for ac_header in windows.h do : ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default" if test "x$ac_cv_header_windows_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINDOWS_H 1 _ACEOF fi done czmq_on_mingw32="yes" czmq_install_man="no" ;; *mingw64*) # Define on MINGW64 to enable all libeary features # Disable format error due to incomplete ANSI C CFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CFLAGS" CPPFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CPPFLAGS" $as_echo "#define CZMQ_HAVE_WINDOWS 1" >>confdefs.h $as_echo "#define CZMQ_HAVE_MINGW32 1" >>confdefs.h for ac_header in windows.h do : ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default" if test "x$ac_cv_header_windows_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINDOWS_H 1 _ACEOF fi done czmq_on_mingw32="yes" czmq_install_man="no" ;; *cygwin*) # Define on Cygwin to enable all library features CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS" $as_echo "#define CZMQ_HAVE_CYGWIN 1" >>confdefs.h czmq_on_cygwin="yes" ;; gnu*) # Define on GNU/Hurd to enable all library features if test "x$GXX" = "xyes"; then CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS" fi $as_echo "#define CZMQ_HAVE_GNU 1" >>confdefs.h czmq_on_gnu="yes" ;; *) as_fn_error $? "unsupported system: ${host_os}" "$LINENO" 5 ;; esac # Checks for header files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi for ac_header in errno.h arpa/inet.h netinet/tcp.h netinet/in.h stddef.h \ stdlib.h string.h sys/socket.h sys/time.h unistd.h \ limits.h ifaddrs.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in net/if.h net/if_media.h linux/wireless.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" " #ifdef HAVE_SYS_SOCKET_H # include #endif #include " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } if ${ac_cv_header_stdbool_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; /* See body of main program for 'e'. */ char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; /* The following fails for HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { bool e = &s; *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdbool_h=yes else ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi if test $ac_cv_header_stdbool_h = yes; then $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" if test "x$ac_cv_type_ssize_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define ssize_t int _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" case $ac_cv_c_uint32_t in #( no|yes) ;; #( *) $as_echo "#define _UINT32_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint32_t $ac_cv_c_uint32_t _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5 $as_echo_n "checking for working volatile... " >&6; } if ${ac_cv_c_volatile+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { volatile int x; int * volatile y = (int *) 0; return !x && !y; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_volatile=yes else ac_cv_c_volatile=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5 $as_echo "$ac_cv_c_volatile" >&6; } if test $ac_cv_c_volatile = no; then $as_echo "#define volatile /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac # These options are GNU compiler specific. if test "x$GCC" = "xyes"; then CPPFLAGS="-pedantic -Werror -Wall -Wc++-compat ${CPPFLAGS}" fi if test "x$enable_shared" = "xyes"; then ENABLE_SHARED_TRUE= ENABLE_SHARED_FALSE='#' else ENABLE_SHARED_TRUE='#' ENABLE_SHARED_FALSE= fi if test "x$czmq_on_mingw32" = "xyes"; then ON_MINGW_TRUE= ON_MINGW_FALSE='#' else ON_MINGW_TRUE='#' ON_MINGW_FALSE= fi if test "x$czmq_on_cygwin" = "xyes"; then ON_CYGWIN_TRUE= ON_CYGWIN_FALSE='#' else ON_CYGWIN_TRUE='#' ON_CYGWIN_FALSE= fi if test "x$czmq_on_android" = "xyes"; then ON_ANDROID_TRUE= ON_ANDROID_FALSE='#' else ON_ANDROID_TRUE='#' ON_ANDROID_FALSE= fi if test "x$czmq_on_linux" = "xyes"; then ON_LINUX_TRUE= ON_LINUX_FALSE='#' else ON_LINUX_TRUE='#' ON_LINUX_FALSE= fi if test "x$czmq_on_gnu" = "xyes"; then ON_GNU_TRUE= ON_GNU_FALSE='#' else ON_GNU_TRUE='#' ON_GNU_FALSE= fi if test "x$czmq_install_man" = "xyes"; then INSTALL_MAN_TRUE= INSTALL_MAN_FALSE='#' else INSTALL_MAN_TRUE='#' INSTALL_MAN_FALSE= fi if test "x$czmq_build_doc" = "xyes"; then BUILD_DOC_TRUE= BUILD_DOC_FALSE='#' else BUILD_DOC_TRUE='#' BUILD_DOC_FALSE= fi # Check whether --enable-dist_cmakefiles was given. if test "${enable_dist_cmakefiles+set}" = set; then : enableval=$enable_dist_cmakefiles; enable_dist_cmakefiles=$enableval else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for presence of CMake recipes" >&5 $as_echo_n "checking for presence of CMake recipes... " >&6; } if test "x$cross_compiling" = "xyes"; then enable_dist_cmakefiles=no else as_ac_File=`$as_echo "ac_cv_file_$srcdir/CMakeLists.txt" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $srcdir/CMakeLists.txt" >&5 $as_echo_n "checking for $srcdir/CMakeLists.txt... " >&6; } if eval \${$as_ac_File+:} false; then : $as_echo_n "(cached) " >&6 else test "$cross_compiling" = yes && as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 if test -r "$srcdir/CMakeLists.txt"; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi eval ac_res=\$$as_ac_File { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes"; then : enable_dist_cmakefiles=yes else enable_dist_cmakefiles=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_dist_cmakefiles" >&5 $as_echo "$enable_dist_cmakefiles" >&6; } fi if test "x$enable_dist_cmakefiles" = "xyes"; then ENABLE_DIST_CMAKEFILES_TRUE= ENABLE_DIST_CMAKEFILES_FALSE='#' else ENABLE_DIST_CMAKEFILES_TRUE='#' ENABLE_DIST_CMAKEFILES_FALSE= fi # Check for zmakecert intent # Check whether --enable-zmakecert was given. if test "${enable_zmakecert+set}" = set; then : enableval=$enable_zmakecert; enable_zmakecert=$enableval else enable_zmakecert=yes fi if test x$enable_zmakecert != xno; then ENABLE_ZMAKECERT_TRUE= ENABLE_ZMAKECERT_FALSE='#' else ENABLE_ZMAKECERT_TRUE='#' ENABLE_ZMAKECERT_FALSE= fi if test -z "$ENABLE_ZMAKECERT_TRUE"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: ENABLE_ZMAKECERT defined" >&5 $as_echo "$as_me: ENABLE_ZMAKECERT defined" >&6;} fi # Check for zsp intent # Check whether --enable-zsp was given. if test "${enable_zsp+set}" = set; then : enableval=$enable_zsp; enable_zsp=$enableval else enable_zsp=yes fi if test x$enable_zsp != xno; then ENABLE_ZSP_TRUE= ENABLE_ZSP_FALSE='#' else ENABLE_ZSP_TRUE='#' ENABLE_ZSP_FALSE= fi if test -z "$ENABLE_ZSP_TRUE"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: ENABLE_ZSP defined" >&5 $as_echo "$as_me: ENABLE_ZSP defined" >&6;} fi # Check for test_randof intent # Check whether --enable-test_randof was given. if test "${enable_test_randof+set}" = set; then : enableval=$enable_test_randof; enable_test_randof=$enableval else enable_test_randof=yes fi if test x$enable_test_randof != xno; then ENABLE_TEST_RANDOF_TRUE= ENABLE_TEST_RANDOF_FALSE='#' else ENABLE_TEST_RANDOF_TRUE='#' ENABLE_TEST_RANDOF_FALSE= fi if test -z "$ENABLE_TEST_RANDOF_TRUE"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: ENABLE_TEST_RANDOF defined" >&5 $as_echo "$as_me: ENABLE_TEST_RANDOF defined" >&6;} fi # Check for czmq_selftest intent # Check whether --enable-czmq_selftest was given. if test "${enable_czmq_selftest+set}" = set; then : enableval=$enable_czmq_selftest; enable_czmq_selftest=$enableval else enable_czmq_selftest=yes fi if test x$enable_czmq_selftest != xno; then ENABLE_CZMQ_SELFTEST_TRUE= ENABLE_CZMQ_SELFTEST_FALSE='#' else ENABLE_CZMQ_SELFTEST_TRUE='#' ENABLE_CZMQ_SELFTEST_FALSE= fi if test -z "$ENABLE_CZMQ_SELFTEST_TRUE"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: ENABLE_CZMQ_SELFTEST defined" >&5 $as_echo "$as_me: ENABLE_CZMQ_SELFTEST defined" >&6;} fi # Checks for library functions. { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } if ${ac_cv_type_signal+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_signal=int else ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF for ac_func in perror gettimeofday memset getifaddrs do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done # enable specific system integration features if test "x$cross_compiling" = "xyes"; then # Enable draft by default when cross-compiling defaultval=yes else # enable draft API by default if we're in a git repository # else disable it by default; then allow --enable-drafts=yes/no override as_ac_File=`$as_echo "ac_cv_file_$srcdir/.git" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $srcdir/.git" >&5 $as_echo_n "checking for $srcdir/.git... " >&6; } if eval \${$as_ac_File+:} false; then : $as_echo_n "(cached) " >&6 else test "$cross_compiling" = yes && as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 if test -r "$srcdir/.git"; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi eval ac_res=\$$as_ac_File { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes"; then : defaultval=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: checking running under a git repository workspace" >&5 $as_echo_n "checking running under a git repository workspace... " >&6; } if git rev-parse --show-toplevel 2>/dev/null; then : defaultval=yes else defaultval=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $defaultval" >&5 $as_echo "$defaultval" >&6; } fi fi # Check whether --enable-drafts was given. if test "${enable_drafts+set}" = set; then : enableval=$enable_drafts; enable_drafts=$enableval else enable_drafts=$defaultval fi if test x$enable_drafts != xno; then ENABLE_DRAFTS_TRUE= ENABLE_DRAFTS_FALSE='#' else ENABLE_DRAFTS_TRUE='#' ENABLE_DRAFTS_FALSE= fi if test "x$enable_drafts" = "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: Building stable and legacy API + draft API" >&5 $as_echo "$as_me: Building stable and legacy API + draft API" >&6;} $as_echo "#define CZMQ_BUILD_DRAFT_API 1" >>confdefs.h pkg_config_defines="-DCZMQ_BUILD_DRAFT_API=1" else { $as_echo "$as_me:${as_lineno-$LINENO}: Building stable and legacy API (no draft API)" >&5 $as_echo "$as_me: Building stable and legacy API (no draft API)" >&6;} pkg_config_defines="" fi # Check whether --enable-Werror was given. if test "${enable_Werror+set}" = set; then : enableval=$enable_Werror; if test -n "$enableval"; then : enable_Werror=$enableval else enable_Werror=auto fi else enable_Werror=no fi if test "x$enable_Werror" = "xyes" || test "x$enable_Werror" = "xauto"; then : if test -n "$CC"; then : if $CC --version 2>&1 | grep 'Free Software Foundation' > /dev/null; then : { $as_echo "$as_me:${as_lineno-$LINENO}: Enabling pedantic errors for GNU C" >&5 $as_echo "$as_me: Enabling pedantic errors for GNU C" >&6;} CFLAGS="$CFLAGS -Wall -Werror" else { $as_echo "$as_me:${as_lineno-$LINENO}: Not enabling pedantic errors: compiler not supported by this recipe (not GNU C)" >&5 $as_echo "$as_me: Not enabling pedantic errors: compiler not supported by this recipe (not GNU C)" >&6;} if test "x$enable_Werror" = "xyes"; then : as_fn_error $? "--enable-Werror=yes was requested and can not be satisfied for C: $CC" "$LINENO" 5 fi fi fi if test -n "$CXX"; then : if $CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null; then : { $as_echo "$as_me:${as_lineno-$LINENO}: Enabling pedantic errors for GNU C++" >&5 $as_echo "$as_me: Enabling pedantic errors for GNU C++" >&6;} CXXFLAGS="$CXXFLAGS -Wall -Werror" else { $as_echo "$as_me:${as_lineno-$LINENO}: Not enabling pedantic errors: compiler not supported by this recipe (not GNU C++)" >&5 $as_echo "$as_me: Not enabling pedantic errors: compiler not supported by this recipe (not GNU C++)" >&6;} if test "x$enable_Werror" = "xyes"; then : as_fn_error $? "--enable-Werror=yes was requested and can not be satisfied for C++: $CXX" "$LINENO" 5 fi fi fi if test -n "$CPP"; then : if $CPP --version 2>&1 | grep 'Free Software Foundation' > /dev/null; then : { $as_echo "$as_me:${as_lineno-$LINENO}: Enabling pedantic errors for GNU CPP preprocessor" >&5 $as_echo "$as_me: Enabling pedantic errors for GNU CPP preprocessor" >&6;} CPPFLAGS="$CPPFLAGS -Wall -Werror" else { $as_echo "$as_me:${as_lineno-$LINENO}: Not enabling pedantic errors: preprocessor not supported by this recipe (not GNU CPP)" >&5 $as_echo "$as_me: Not enabling pedantic errors: preprocessor not supported by this recipe (not GNU CPP)" >&6;} if test "x$enable_Werror" = "xyes"; then : as_fn_error $? "--enable-Werror=yes was requested and can not be satisfied for CPP: $CPP" "$LINENO" 5 fi fi fi fi # Specify output files ac_config_files="$ac_config_files Makefile doc/Makefile src/libczmq.pc" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${USING_VPATH_TRUE}" && test -z "${USING_VPATH_FALSE}"; then as_fn_error $? "conditional \"USING_VPATH\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WITH_GCOV_TRUE}" && test -z "${WITH_GCOV_FALSE}"; then as_fn_error $? "conditional \"WITH_GCOV\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WITH_GCOV_TRUE}" && test -z "${WITH_GCOV_FALSE}"; then as_fn_error $? "conditional \"WITH_GCOV\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_ASAN_TRUE}" && test -z "${ENABLE_ASAN_FALSE}"; then as_fn_error $? "conditional \"ENABLE_ASAN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_ASAN_TRUE}" && test -z "${ENABLE_ASAN_FALSE}"; then as_fn_error $? "conditional \"ENABLE_ASAN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_SHARED_TRUE}" && test -z "${ENABLE_SHARED_FALSE}"; then as_fn_error $? "conditional \"ENABLE_SHARED\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ON_MINGW_TRUE}" && test -z "${ON_MINGW_FALSE}"; then as_fn_error $? "conditional \"ON_MINGW\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ON_CYGWIN_TRUE}" && test -z "${ON_CYGWIN_FALSE}"; then as_fn_error $? "conditional \"ON_CYGWIN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ON_ANDROID_TRUE}" && test -z "${ON_ANDROID_FALSE}"; then as_fn_error $? "conditional \"ON_ANDROID\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ON_LINUX_TRUE}" && test -z "${ON_LINUX_FALSE}"; then as_fn_error $? "conditional \"ON_LINUX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ON_GNU_TRUE}" && test -z "${ON_GNU_FALSE}"; then as_fn_error $? "conditional \"ON_GNU\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${INSTALL_MAN_TRUE}" && test -z "${INSTALL_MAN_FALSE}"; then as_fn_error $? "conditional \"INSTALL_MAN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILD_DOC_TRUE}" && test -z "${BUILD_DOC_FALSE}"; then as_fn_error $? "conditional \"BUILD_DOC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_DIST_CMAKEFILES_TRUE}" && test -z "${ENABLE_DIST_CMAKEFILES_FALSE}"; then as_fn_error $? "conditional \"ENABLE_DIST_CMAKEFILES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_ZMAKECERT_TRUE}" && test -z "${ENABLE_ZMAKECERT_FALSE}"; then as_fn_error $? "conditional \"ENABLE_ZMAKECERT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_ZSP_TRUE}" && test -z "${ENABLE_ZSP_FALSE}"; then as_fn_error $? "conditional \"ENABLE_ZSP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_TEST_RANDOF_TRUE}" && test -z "${ENABLE_TEST_RANDOF_FALSE}"; then as_fn_error $? "conditional \"ENABLE_TEST_RANDOF\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_CZMQ_SELFTEST_TRUE}" && test -z "${ENABLE_CZMQ_SELFTEST_FALSE}"; then as_fn_error $? "conditional \"ENABLE_CZMQ_SELFTEST\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_DRAFTS_TRUE}" && test -z "${ENABLE_DRAFTS_FALSE}"; then as_fn_error $? "conditional \"ENABLE_DRAFTS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by czmq $as_me 4.1.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ czmq config.status 4.1.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in AS \ DLLTOOL \ OBJDUMP \ SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "src/platform.h") CONFIG_HEADERS="$CONFIG_HEADERS src/platform.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "src/libczmq.pc") CONFIG_FILES="$CONFIG_FILES src/libczmq.pc" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="" # ### BEGIN LIBTOOL CONFIG # Assembler program. AS=$lt_AS # DLL creation program. DLLTOOL=$lt_DLLTOOL # Object dumper program. OBJDUMP=$lt_OBJDUMP # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ func_stripname ()\ {\ \ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ \ # positional parameters, so assign one to ordinary parameter first.\ \ func_stripname_result=${3}\ \ func_stripname_result=${func_stripname_result#"${1}"}\ \ func_stripname_result=${func_stripname_result%"${2}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi # Print configure summary and list make options BUILD_USER=${USER} BUILD_ARCH=${host} BUILD_HOST=${ac_hostname} BUILD_DATE=$(date +'%F %H:%M') cat >>confdefs.h <<_ACEOF #define BUILD_USER "${BUILD_USER}" _ACEOF cat >>confdefs.h <<_ACEOF #define BUILD_ARCH "${BUILD_ARCH}" _ACEOF cat >>confdefs.h <<_ACEOF #define BUILD_HOST "${BUILD_HOST}" _ACEOF cat >>confdefs.h <<_ACEOF #define BUILD_DATE "${BUILD_DATE}" _ACEOF echo echo '##########################################################################' echo '# SUMMARY #' echo '##########################################################################' echo echo Package version............... : $PACKAGE-$VERSION echo echo C compiler.................... : $CC echo C compiler flags.............. : $CFLAGS echo C++ compiler.................. : $CXX echo C++ compiler flags............ : $CXXFLAGS echo Configure date................ : $BUILD_DATE echo Build architecture............ : $BUILD_ARCH echo Build docs.................... : $czmq_build_doc echo Build host.................... : $BUILD_HOST echo Build user.................... : $USER echo Draft API..................... : $enable_drafts echo Install dir................... : $prefix echo Install man pages............. : $czmq_install_man echo echo Help: echo Use the Draft API \(default = yes\): echo --enable-drafts=\(yes\|no\) echo echo Build the docs and install the man pages \(default = yes\): echo --with-docs=\(yes\|no\) *requires asciidoc and xmlto echo echo '##########################################################################' echo echo Configure complete! Now proceed with: echo " - 'make' compile the project" echo " - 'make check' run the project's selftest" echo " - 'make install' install the project to $prefix" echo echo Further options are: echo " - 'make callcheck' run the project's selftest with valgrind to" echo " check for performance leaks" echo " - 'make check-verbose' run the project's selftest in verbose mode" echo " - 'make code' generate code from models in src directory" echo " (requires zproject and zproto)" echo " - 'make debug' run the project's selftest under gdb" echo " - 'make memcheck' run the project's selftest with valgrind to" echo " check for memory leaks" echo " - 'make coverage' generate project's selftest coverage report" echo " expects --with-gcov option for configure" echo ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/configure.ac0000664000372000037200000007541413222211156015664 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) # AC_INIT([czmq],[4.1.0],[zeromq-dev@lists.zeromq.org]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_MACRO_DIR(config) AC_CONFIG_HEADERS([src/platform.h]) AM_INIT_AUTOMAKE([subdir-objects tar-ustar dist-zip foreign]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # This defines PACKAGE_VERSION_... in src/platform.h PV_MAJOR=`echo $PACKAGE_VERSION | cut -d . -f 1` PV_MINOR=`echo $PACKAGE_VERSION | cut -d . -f 2` PV_PATCH=`echo $PACKAGE_VERSION | cut -d . -f 3` AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR],[$PV_MAJOR], [CZMQ major version]) AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],[$PV_MINOR], [CZMQ minor version]) AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCH],[$PV_PATCH], [CZMQ patchlevel]) # This lets us use PACKAGE_VERSION in Makefiles AC_SUBST(PACKAGE_VERSION) # # Libtool -version-info (ABI version) # # Currently 5:0:1 ("stable"). Don't change this unless you # know exactly what you're doing and have read and understand # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html # # libczmq -version-info LTVER="5:0:1" AC_SUBST(LTVER) # building in a subdirectory? AM_CONDITIONAL([USING_VPATH], [test "x${srcdir}" != "x."]) # Capture c flags CZMQ_ORIG_CFLAGS="${CFLAGS:-none}" # Checks for programs AC_PROG_CC AC_PROG_CC_C99 AM_PROG_CC_C_O AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL AC_PROG_SED AC_PROG_AWK PKG_PROG_PKG_CONFIG # Check endianess of the system AC_C_BIGENDIAN # Optional project-local hook (acinclude.m4, add AC_DEFUN([AX_PROJECT_LOCAL_HOOK], [whatever]) ) AX_PROJECT_LOCAL_HOOK # Code coverage AC_MSG_CHECKING([whether to enable GCov]) AC_ARG_WITH(gcov, [AS_HELP_STRING([--with-gcov=yes/no], [With GCC Code Coverage reporting])], [CZMQ_GCOV="$withval"]) if test "x${CZMQ_GCOV}" == "xyes"; then CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" if test "x${CZMQ_ORIG_CFLAGS}" != "xnone"; then CFLAGS="${CFLAGS} ${CZMQ_ORIG_CFLAGS}" fi AM_CONDITIONAL(WITH_GCOV, true) AC_MSG_RESULT([yes]) else AM_CONDITIONAL(WITH_GCOV, false) AC_MSG_RESULT([no]) fi # Memory mis-use detection AC_MSG_CHECKING([whether to enable ASan]) AC_ARG_ENABLE(address-sanitizer, [AS_HELP_STRING([--enable-address-sanitizer=yes/no], [Build with GCC Address Sanitizer instrumentation])], [CZMQ_ASAN="$enableval"]) if test "x${CZMQ_ASAN}" == "xyes"; then CFLAGS="${CFLAGS} -fsanitize=address" CXXFLAGS="${CXXFLAGS} -fsanitize=address" AM_CONDITIONAL(ENABLE_ASAN, true) AC_MSG_RESULT([yes]) else AM_CONDITIONAL(ENABLE_ASAN, false) AC_MSG_RESULT([no]) fi # Set pkgconfigdir AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH], [Path to the pkgconfig directory [[LIBDIR/pkgconfig]]]), [pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig']) AC_SUBST([pkgconfigdir]) # Use the provided pkgconfigdir not only to write our pkg-config data, # but also as an additional location to look for other packages metadata. AS_IF([test -n "${pkgconfigdir}" -a -d "${pkgconfigdir}"], [AS_IF([test -z "${PKG_CONFIG_PATH}"], [PKG_CONFIG_PATH="${pkgconfigdir}"], [PKG_CONFIG_PATH="${pkgconfigdir}:${PKG_CONFIG_PATH}"]) export PKG_CONFIG_PATH ]) # Will be used to add flags to pkg-config useful when apps want to statically link PKGCFG_LIBS_PRIVATE="" # Archive user supplied flags PREVIOUS_CFLAGS="${CFLAGS}" PREVIOUS_LIBS="${LIBS}" was_libzmq_check_lib_detected=no search_libzmq="yes" AC_ARG_WITH([libzmq], [ AS_HELP_STRING([--with-libzmq], [yes or no. Optionally specify libzmq prefix (directory where its include/ and lib/ are located), but that is only used if pkgconfig metadata is not found first]) ], [ search_libzmq="yes" ], []) AS_CASE([x"${with_libzmq}"], [xyes], [search_libzmq="yes"], [xno], [search_libzmq="no"]) dnl We do not abort right now, because the maintainer/developer may have dnl something particular in mind, e.g. to build just parts of a project. AS_IF([test x"${search_libzmq}" = xno], [AC_MSG_WARN([Required dependency on libzmq was explicitly disabled during configuration by '--with-libzmq=no'; subsequent full build of czmq may fail])]) AS_IF([test x"${search_libzmq}" = xyes], [ # Archive previously detected and supplied flags PRE_SEARCH_CFLAGS="${CFLAGS}" PRE_SEARCH_LIBS="${LIBS}" found_pkgconfig="" found_linkname="" PKG_CHECK_MODULES([libzmq], [libzmq >= 0.0.0], [ PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE $libzmq_LIBS" was_libzmq_check_lib_detected=pkgcfg found_pkgconfig="libzmq" ], [ AC_MSG_NOTICE([Package libzmq not found; falling back to defined compilability tests]) libzmq_synthetic_cflags="" libzmq_synthetic_libs="-lzmq" if test -n "${with_libzmq}" && test x"${with_libzmq}" != xyes && test x"${with_libzmq}" != xno; then if test -r "${with_libzmq}/include/zmq.h"; then libzmq_synthetic_cflags="-I${with_libzmq}/include" libzmq_synthetic_libs="-L${with_libzmq}/lib -lzmq" else AC_MSG_ERROR([Header file ${with_libzmq}/include/zmq.h was not found. Please check libzmq prefix]) fi else AC_CHECK_HEADER([zmq.h], [], AC_MSG_ERROR([Header file zmq.h was not found in default search paths]) ) fi AC_CHECK_LIB([zmq], [zmq_init], [ was_libzmq_check_lib_detected=yes PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -lzmq" found_linkname="zmq" ], [AC_MSG_ERROR([cannot link with -lzmq, install libzmq])]) ]) dnl END of PKG_CHECK_MODULES and/or direct tests for libzmq AS_CASE(["x${was_libzmq_check_lib_detected}"], [xpkgcfg], [ AC_SUBST([pkgconfig_name_libzmq],[${found_pkgconfig}]) CFLAGS="${libzmq_CFLAGS} ${CFLAGS}" LIBS="${libzmq_LIBS} ${LIBS}" ], [xyes], [ AC_SUBST([pkgconfig_name_libzmq],[${found_linkname}]) CFLAGS="${libzmq_synthetic_cflags} ${CFLAGS}" LDFLAGS="${libzmq_synthetic_libs} ${LDFLAGS}" LIBS="${libzmq_synthetic_libs} ${LIBS}" AC_SUBST([libzmq_CFLAGS],[${libzmq_synthetic_cflags}]) AC_SUBST([libzmq_LIBS],[${libzmq_synthetic_libs}]) ], [xno], [ AC_SUBST([pkgconfig_name_libzmq],[libzmq]) AC_MSG_ERROR([Cannot find pkg-config metadata for libzmq 0.0.0 or higher]) ]) ]) dnl END of enabled attempts to search for libzmq was_uuid_check_lib_detected=no search_uuid="no" AC_ARG_WITH([uuid], [ AS_HELP_STRING([--with-uuid], [yes or no. Optionally specify uuid prefix (directory where its include/ and lib/ are located), but that is only used if pkgconfig metadata is not found first]) ], [ search_uuid="yes" ], []) AS_CASE([x"${with_uuid}"], [xyes], [search_uuid="yes"], [xno], [search_uuid="no"]) AS_IF([test x"${search_uuid}" = xyes], [ # Archive previously detected and supplied flags PRE_SEARCH_CFLAGS="${CFLAGS}" PRE_SEARCH_LIBS="${LIBS}" found_pkgconfig="" found_linkname="" PKG_CHECK_MODULES([uuid], [uuid >= 0.0.0], [ AC_DEFINE(HAVE_UUID, 1, [The optional uuid library is to be used]) PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE $uuid_LIBS" was_uuid_check_lib_detected=pkgcfg found_pkgconfig="uuid" ], [ AC_MSG_NOTICE([Package uuid not found; falling back to defined compilability tests]) uuid_synthetic_cflags="" uuid_synthetic_libs="-luuid" if test -n "${with_uuid}" && test x"${with_uuid}" != xyes && test x"${with_uuid}" != xno; then if test -r "${with_uuid}/include/uuid/uuid.h"; then uuid_synthetic_cflags="-I${with_uuid}/include" uuid_synthetic_libs="-L${with_uuid}/lib -luuid" else AC_MSG_WARN([Header file ${with_uuid}/include/uuid/uuid.h was not found. Please check uuid prefix]) fi else AC_CHECK_HEADER([uuid/uuid.h], [], AC_MSG_WARN([Header file uuid/uuid.h was not found in default search paths]) ) fi AC_CHECK_LIB([uuid], [uuid_generate], [ was_uuid_check_lib_detected=yes PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -luuid" found_linkname="uuid" AC_DEFINE(HAVE_UUID, 1, [The optional uuid library is to be used (as -luuid)]) ], []) ]) dnl END of PKG_CHECK_MODULES and/or direct tests for uuid AS_CASE(["x${was_uuid_check_lib_detected}"], [xpkgcfg], [ AC_SUBST([pkgconfig_name_uuid],[${found_pkgconfig}]) CFLAGS="${uuid_CFLAGS} ${CFLAGS}" LIBS="${uuid_LIBS} ${LIBS}" ], [xyes], [ AC_SUBST([pkgconfig_name_uuid],[${found_linkname}]) CFLAGS="${uuid_synthetic_cflags} ${CFLAGS}" LDFLAGS="${uuid_synthetic_libs} ${LDFLAGS}" LIBS="${uuid_synthetic_libs} ${LIBS}" AC_SUBST([uuid_CFLAGS],[${uuid_synthetic_cflags}]) AC_SUBST([uuid_LIBS],[${uuid_synthetic_libs}]) ], [xno], [ AC_SUBST([pkgconfig_name_uuid],[uuid]) AC_MSG_WARN([Cannot find pkg-config metadata for uuid 0.0.0 or higher]) ]) ]) dnl END of enabled attempts to search for uuid was_systemd_check_lib_detected=no search_libsystemd="no" AC_ARG_WITH([libsystemd], [ AS_HELP_STRING([--with-libsystemd], [yes or no. Optionally specify libsystemd prefix (directory where its include/ and lib/ are located), but that is only used if pkgconfig metadata is not found first]) ], [ search_libsystemd="yes" ], []) AS_CASE([x"${with_libsystemd}"], [xyes], [search_libsystemd="yes"], [xno], [search_libsystemd="no"]) AS_IF([test x"${search_libsystemd}" = xyes], [ # Archive previously detected and supplied flags PRE_SEARCH_CFLAGS="${CFLAGS}" PRE_SEARCH_LIBS="${LIBS}" found_pkgconfig="" found_linkname="" PKG_CHECK_MODULES([systemd], [libsystemd >= 200.0.0], [ AC_DEFINE(HAVE_LIBSYSTEMD, 1, [The optional libsystemd library is to be used]) PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE $systemd_LIBS" was_systemd_check_lib_detected=pkgcfg found_pkgconfig="libsystemd" ], [ AC_MSG_NOTICE([Package libsystemd not found with needed constraints; falling back to defined compilability tests]) systemd_synthetic_cflags="" systemd_synthetic_libs="-lsystemd" if test -n "${with_libsystemd}" && test x"${with_libsystemd}" != xyes && test x"${with_libsystemd}" != xno; then if test -r "${with_libsystemd}/include/systemd/sd-daemon.h"; then systemd_synthetic_cflags="-I${with_libsystemd}/include" systemd_synthetic_libs="-L${with_libsystemd}/lib -lsystemd" else AC_MSG_WARN([Header file ${with_libsystemd}/include/systemd/sd-daemon.h was not found. Please check libsystemd prefix]) fi else AC_CHECK_HEADER([systemd/sd-daemon.h], [], AC_MSG_WARN([Header file systemd/sd-daemon.h was not found in default search paths]) ) fi AC_CHECK_LIB([libsystemd], [sd_listen_fds], [ was_systemd_check_lib_detected=yes PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -lsystemd" found_linkname="systemd" AC_DEFINE(HAVE_LIBSYSTEMD, 1, [The optional libsystemd library is to be used (as -lsystemd)]) ], []) ]) dnl END of PKG_CHECK_MODULES and/or direct tests for libsystemd AS_CASE(["x${was_systemd_check_lib_detected}"], [xpkgcfg], [ AC_SUBST([pkgconfig_name_libsystemd],[${found_pkgconfig}]) CFLAGS="${systemd_CFLAGS} ${CFLAGS}" LIBS="${systemd_LIBS} ${LIBS}" ], [xyes], [ AC_SUBST([pkgconfig_name_libsystemd],[${found_linkname}]) CFLAGS="${systemd_synthetic_cflags} ${CFLAGS}" LDFLAGS="${systemd_synthetic_libs} ${LDFLAGS}" LIBS="${systemd_synthetic_libs} ${LIBS}" AC_SUBST([systemd_CFLAGS],[${systemd_synthetic_cflags}]) AC_SUBST([systemd_LIBS],[${systemd_synthetic_libs}]) ], [xno], [ AC_SUBST([pkgconfig_name_libsystemd],[libsystemd]) AC_MSG_WARN([Cannot find pkg-config metadata for libsystemd 200.0.0 or higher]) ]) ]) dnl END of enabled attempts to search for libsystemd was_lz4_check_lib_detected=no search_liblz4="no" AC_ARG_WITH([liblz4], [ AS_HELP_STRING([--with-liblz4], [yes or no. Optionally specify liblz4 prefix (directory where its include/ and lib/ are located), but that is only used if pkgconfig metadata is not found first]) ], [ search_liblz4="yes" ], []) AS_CASE([x"${with_liblz4}"], [xyes], [search_liblz4="yes"], [xno], [search_liblz4="no"]) AS_IF([test x"${search_liblz4}" = xyes], [ # Archive previously detected and supplied flags PRE_SEARCH_CFLAGS="${CFLAGS}" PRE_SEARCH_LIBS="${LIBS}" found_pkgconfig="" found_linkname="" PKG_CHECK_MODULES([lz4], [liblz4 >= 0.0.0], [ AC_DEFINE(HAVE_LIBLZ4, 1, [The optional liblz4 library is to be used]) PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE $lz4_LIBS" was_lz4_check_lib_detected=pkgcfg found_pkgconfig="liblz4" ], [ AC_MSG_NOTICE([Package liblz4 not found; falling back to defined compilability tests]) lz4_synthetic_cflags="" lz4_synthetic_libs="-llz4" if test -n "${with_liblz4}" && test x"${with_liblz4}" != xyes && test x"${with_liblz4}" != xno; then if test -r "${with_liblz4}/include/lz4.h"; then lz4_synthetic_cflags="-I${with_liblz4}/include" lz4_synthetic_libs="-L${with_liblz4}/lib -llz4" else AC_MSG_WARN([Header file ${with_liblz4}/include/lz4.h was not found. Please check liblz4 prefix]) fi else AC_CHECK_HEADER([lz4.h], [], AC_MSG_WARN([Header file lz4.h was not found in default search paths]) ) fi AC_CHECK_LIB([lz4], [LZ4_decompress_safe], [ was_lz4_check_lib_detected=yes PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -llz4" found_linkname="lz4" AC_DEFINE(HAVE_LIBLZ4, 1, [The optional liblz4 library is to be used (as -llz4)]) ], []) ]) dnl END of PKG_CHECK_MODULES and/or direct tests for liblz4 AS_CASE(["x${was_lz4_check_lib_detected}"], [xpkgcfg], [ AC_SUBST([pkgconfig_name_liblz4],[${found_pkgconfig}]) CFLAGS="${lz4_CFLAGS} ${CFLAGS}" LIBS="${lz4_LIBS} ${LIBS}" ], [xyes], [ AC_SUBST([pkgconfig_name_liblz4],[${found_linkname}]) CFLAGS="${lz4_synthetic_cflags} ${CFLAGS}" LDFLAGS="${lz4_synthetic_libs} ${LDFLAGS}" LIBS="${lz4_synthetic_libs} ${LIBS}" AC_SUBST([lz4_CFLAGS],[${lz4_synthetic_cflags}]) AC_SUBST([lz4_LIBS],[${lz4_synthetic_libs}]) ], [xno], [ AC_SUBST([pkgconfig_name_liblz4],[liblz4]) AC_MSG_WARN([Cannot find pkg-config metadata for liblz4 0.0.0 or higher]) ]) ]) dnl END of enabled attempts to search for liblz4 CFLAGS="${PREVIOUS_CFLAGS}" LIBS="${PREVIOUS_LIBS}" AC_SUBST(pkg_config_libs_private, $PKGCFG_LIBS_PRIVATE) # Platform specific checks czmq_on_mingw32="no" czmq_on_cygwin="no" czmq_on_android="no" czmq_on_linux="no" czmq_on_gnu="no" # Host specific checks AC_CANONICAL_HOST # Man pages are built/installed if asciidoc and xmlto are present # --with-docs=no overrides this AC_ARG_WITH([docs], AS_HELP_STRING([--with-docs], [Build and install man pages [default=yes]]), [with_docs=$withval]) if test "x$with_docs" = "xno"; then czmq_build_doc="no" czmq_install_man="no" else # Determine whether or not documentation should be built and installed. czmq_build_doc="yes" czmq_install_man="yes" # Check for asciidoc and xmlto and don't build the docs if these are not installed. AC_CHECK_PROG(czmq_have_asciidoc, asciidoc, yes, no) AC_CHECK_PROG(czmq_have_xmlto, xmlto, yes, no) if test "x$czmq_have_asciidoc" = "xno" -o "x$czmq_have_xmlto" = "xno"; then if test "x$with_docs" = "xyes" ; then AC_MSG_ERROR([Build with docs was explicitly requested, but tools are not available]) fi czmq_build_doc="no" # Tarballs built with 'make dist' ship with prebuilt documentation. if ! test -f doc/czmq.7; then czmq_install_man="no" AC_MSG_WARN([You are building an unreleased version of CZMQ and asciidoc or xmlto are not installed.]) AC_MSG_WARN([Documentation will not be built and manual pages will not be installed.]) fi fi fi AC_MSG_CHECKING([whether to build documentation]) AC_MSG_RESULT([$czmq_build_doc]) AC_MSG_CHECKING([whether to install manpages]) AC_MSG_RESULT([$czmq_install_man]) # Set some default features required by libczmq code. CPPFLAGS="-DCZMQ_INTERNAL_BUILD -D_REENTRANT -D_THREAD_SAFE $CPPFLAGS" # OS-specific tests case "${host_os}" in *linux*) # Define on Linux to enable all library features CPPFLAGS="-D_GNU_SOURCE -DLINUX $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_LINUX, 1, [Have Linux OS]) czmq_on_linux="yes" case "${host_os}" in *android*) AC_DEFINE(CZMQ_HAVE_ANDROID, 1, [Have Android OS]) czmq_on_android="yes" ;; esac ;; *solaris*) # Define on Solaris to enable all library features CPPFLAGS="-D_PTHREADS $CPPFLAGS" # Allow definitions of common OS-provided functions that are not in old standards CPPFLAGS="-D__EXTENSIONS__ $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_SOLARIS, 1, [Have Solaris OS]) CFLAGS="${CFLAGS} -lsocket -lssp" ;; *freebsd*) # Define on FreeBSD to enable all library features CPPFLAGS="-D__BSD_VISIBLE $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_FREEBSD, 1, [Have FreeBSD OS]) ;; *darwin*) # Define on Darwin to enable all library features CPPFLAGS="-D_DARWIN_C_SOURCE $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_OSX, 1, [Have DarwinOSX OS]) ;; *netbsd*) # Define on NetBSD to enable all library features CPPFLAGS="-D_NETBSD_SOURCE $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_NETBSD, 1, [Have NetBSD OS]) ;; *openbsd*) # Define on OpenBSD to enable all library features CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_OPENBSD, 1, [Have OpenBSD OS]) ;; *nto-qnx*) AC_DEFINE(CZMQ_HAVE_QNXNTO, 1, [Have QNX Neutrino OS]) ;; *aix*) AC_DEFINE(CZMQ_HAVE_AIX, 1, [Have AIX OS]) ;; *hpux*) # Define on HP-UX to enable all library features CPPFLAGS="-D_POSIX_C_SOURCE=200112L" AC_DEFINE(CZMQ_HAVE_HPUX, 1, [Have HPUX OS]) ;; *mingw32*) # Disable format error due to incomplete ANSI C CFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CFLAGS" CPPFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_WINDOWS, 1, [Have Windows OS]) AC_DEFINE(CZMQ_HAVE_MINGW32, 1, [Have MinGW32]) AC_CHECK_HEADERS(windows.h) czmq_on_mingw32="yes" czmq_install_man="no" ;; *mingw64*) # Define on MINGW64 to enable all libeary features # Disable format error due to incomplete ANSI C CFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CFLAGS" CPPFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_WINDOWS, 1, [Have Windows OS]) AC_DEFINE(CZMQ_HAVE_MINGW32, 1, [Have MinGW32]) AC_CHECK_HEADERS(windows.h) czmq_on_mingw32="yes" czmq_install_man="no" ;; *cygwin*) # Define on Cygwin to enable all library features CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS" AC_DEFINE(CZMQ_HAVE_CYGWIN, 1, [Have Cygwin]) czmq_on_cygwin="yes" ;; gnu*) # Define on GNU/Hurd to enable all library features if test "x$GXX" = "xyes"; then CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS" fi AC_DEFINE(CZMQ_HAVE_GNU, 1, [Have GNU/Hurd OS]) czmq_on_gnu="yes" ;; *) AC_MSG_ERROR([unsupported system: ${host_os}]) ;; esac # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(errno.h arpa/inet.h netinet/tcp.h netinet/in.h stddef.h \ stdlib.h string.h sys/socket.h sys/time.h unistd.h \ limits.h ifaddrs.h) AC_CHECK_HEADERS([net/if.h net/if_media.h linux/wireless.h], [], [], [ #ifdef HAVE_SYS_SOCKET_H # include #endif #include ]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST AC_C_INLINE AC_TYPE_SIZE_T AC_TYPE_SSIZE_T AC_HEADER_TIME AC_TYPE_UINT32_T AC_C_VOLATILE AC_C_BIGENDIAN # These options are GNU compiler specific. if test "x$GCC" = "xyes"; then CPPFLAGS="-pedantic -Werror -Wall -Wc++-compat ${CPPFLAGS}" fi AM_CONDITIONAL(ENABLE_SHARED, test "x$enable_shared" = "xyes") AM_CONDITIONAL(ON_MINGW, test "x$czmq_on_mingw32" = "xyes") AM_CONDITIONAL(ON_CYGWIN, test "x$czmq_on_cygwin" = "xyes") AM_CONDITIONAL(ON_ANDROID, test "x$czmq_on_android" = "xyes") AM_CONDITIONAL(ON_LINUX, test "x$czmq_on_linux" = "xyes") AM_CONDITIONAL(ON_GNU, test "x$czmq_on_gnu" = "xyes") AM_CONDITIONAL(INSTALL_MAN, test "x$czmq_install_man" = "xyes") AM_CONDITIONAL(BUILD_DOC, test "x$czmq_build_doc" = "xyes") AC_ARG_ENABLE([dist_cmakefiles], AS_HELP_STRING([--enable-dist_cmakefiles], [Distribute CMakeLists.txt and related files [default depends: on if present and not cross compiling]]), [enable_dist_cmakefiles=$enableval], [AC_MSG_CHECKING([for presence of CMake recipes]) if test "x$cross_compiling" = "xyes"; then enable_dist_cmakefiles=no else AC_CHECK_FILE($srcdir/CMakeLists.txt, [enable_dist_cmakefiles=yes], [enable_dist_cmakefiles=no]) fi AC_MSG_RESULT([$enable_dist_cmakefiles])]) AM_CONDITIONAL(ENABLE_DIST_CMAKEFILES, test "x$enable_dist_cmakefiles" = "xyes") # Check for zmakecert intent AC_ARG_ENABLE([zmakecert], AS_HELP_STRING([--enable-zmakecert], [Compile and install 'zmakecert' [default=yes]]), [enable_zmakecert=$enableval], [enable_zmakecert=yes]) AM_CONDITIONAL([ENABLE_ZMAKECERT], [test x$enable_zmakecert != xno]) AM_COND_IF([ENABLE_ZMAKECERT], [AC_MSG_NOTICE([ENABLE_ZMAKECERT defined])]) # Check for zsp intent AC_ARG_ENABLE([zsp], AS_HELP_STRING([--enable-zsp], [Compile 'zsp' in src [default=yes]]), [enable_zsp=$enableval], [enable_zsp=yes]) AM_CONDITIONAL([ENABLE_ZSP], [test x$enable_zsp != xno]) AM_COND_IF([ENABLE_ZSP], [AC_MSG_NOTICE([ENABLE_ZSP defined])]) # Check for test_randof intent AC_ARG_ENABLE([test_randof], AS_HELP_STRING([--enable-test_randof], [Compile 'test_randof' in src [default=yes]]), [enable_test_randof=$enableval], [enable_test_randof=yes]) AM_CONDITIONAL([ENABLE_TEST_RANDOF], [test x$enable_test_randof != xno]) AM_COND_IF([ENABLE_TEST_RANDOF], [AC_MSG_NOTICE([ENABLE_TEST_RANDOF defined])]) # Check for czmq_selftest intent AC_ARG_ENABLE([czmq_selftest], AS_HELP_STRING([--enable-czmq_selftest], [Compile 'czmq_selftest' in src [default=yes]]), [enable_czmq_selftest=$enableval], [enable_czmq_selftest=yes]) AM_CONDITIONAL([ENABLE_CZMQ_SELFTEST], [test x$enable_czmq_selftest != xno]) AM_COND_IF([ENABLE_CZMQ_SELFTEST], [AC_MSG_NOTICE([ENABLE_CZMQ_SELFTEST defined])]) # Checks for library functions. AC_TYPE_SIGNAL AC_CHECK_FUNCS(perror gettimeofday memset getifaddrs) # enable specific system integration features if test "x$cross_compiling" = "xyes"; then # Enable draft by default when cross-compiling defaultval=yes else # enable draft API by default if we're in a git repository # else disable it by default; then allow --enable-drafts=yes/no override AC_CHECK_FILE($srcdir/.git, [defaultval=yes], [AC_MSG_CHECKING([running under a git repository workspace]) AS_IF([git rev-parse --show-toplevel 2>/dev/null], [defaultval=yes], [defaultval=no]) AC_MSG_RESULT($defaultval) ]) fi AC_ARG_ENABLE([drafts], AS_HELP_STRING([--enable-drafts], [Build and install draft classes and methods [default=yes]]), [enable_drafts=$enableval], [enable_drafts=$defaultval]) AM_CONDITIONAL([ENABLE_DRAFTS], [test x$enable_drafts != xno]) if test "x$enable_drafts" = "xyes"; then AC_MSG_NOTICE([Building stable and legacy API + draft API]) AC_DEFINE(CZMQ_BUILD_DRAFT_API, 1, [Provide draft classes and methods]) AC_SUBST(pkg_config_defines, "-DCZMQ_BUILD_DRAFT_API=1") else AC_MSG_NOTICE([Building stable and legacy API (no draft API)]) AC_SUBST(pkg_config_defines, "") fi AC_ARG_ENABLE([Werror], AS_HELP_STRING([--enable-Werror], [Add -Wall -Werror to GCC/GXX arguments [default=no; default=auto if nothing specified]]), [AS_IF([test -n "$enableval"], [enable_Werror=$enableval], [enable_Werror=auto])], [enable_Werror=no]) 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], [AC_MSG_NOTICE([Enabling pedantic errors for GNU C]) CFLAGS="$CFLAGS -Wall -Werror"], [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([test -n "$CXX"],[AS_IF([$CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null], [AC_MSG_NOTICE([Enabling pedantic errors for GNU C++]) CXXFLAGS="$CXXFLAGS -Wall -Werror"], [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([test -n "$CPP"],[AS_IF([$CPP --version 2>&1 | grep 'Free Software Foundation' > /dev/null], [AC_MSG_NOTICE([Enabling pedantic errors for GNU CPP preprocessor]) CPPFLAGS="$CPPFLAGS -Wall -Werror"], [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])]) ])]) ]) # Specify output files AC_CONFIG_FILES([Makefile doc/Makefile src/libczmq.pc ]) AC_OUTPUT # Print configure summary and list make options AC_DEFUN([AX_SUMMARIZE_ENV], [ BUILD_USER=${USER} BUILD_ARCH=${host} BUILD_HOST=${ac_hostname} BUILD_DATE=$(date +'%F %H:%M') AC_DEFINE_UNQUOTED([BUILD_USER], "${BUILD_USER}", [The fine user who built the package]) AC_DEFINE_UNQUOTED([BUILD_ARCH], "${BUILD_ARCH}", [Architecture of the build host]) AC_DEFINE_UNQUOTED([BUILD_HOST], "${BUILD_HOST}", [Build host name]) AC_DEFINE_UNQUOTED([BUILD_DATE], "${BUILD_DATE}", [Build date]) AC_SUBST(BUILD_USER) AC_SUBST(BUILD_ARCH) AC_SUBST(BUILD_HOST) AC_SUBST(BUILD_DATE) AC_SUBST(BUILD_VERSION) ]) AC_DEFUN([AX_SUMMARIZE_CONFIG], [ echo echo '##########################################################################' echo '# SUMMARY #' echo '##########################################################################' echo echo Package version............... : $PACKAGE-$VERSION echo echo C compiler.................... : $CC echo C compiler flags.............. : $CFLAGS echo C++ compiler.................. : $CXX echo C++ compiler flags............ : $CXXFLAGS echo Configure date................ : $BUILD_DATE echo Build architecture............ : $BUILD_ARCH echo Build docs.................... : $czmq_build_doc echo Build host.................... : $BUILD_HOST echo Build user.................... : $USER echo Draft API..................... : $enable_drafts echo Install dir................... : $prefix echo Install man pages............. : $czmq_install_man echo echo Help: echo Use the Draft API \(default = yes\): echo --enable-drafts=\(yes\|no\) echo echo Build the docs and install the man pages \(default = yes\): echo --with-docs=\(yes\|no\) *requires asciidoc and xmlto echo echo '##########################################################################' echo echo Configure complete! Now proceed with: echo " - 'make' compile the project" echo " - 'make check' run the project's selftest" echo " - 'make install' install the project to $prefix" echo echo Further options are: echo " - 'make callcheck' run the project's selftest with valgrind to" echo " check for performance leaks" echo " - 'make check-verbose' run the project's selftest in verbose mode" echo " - 'make code' generate code from models in src directory" echo " (requires zproject and zproto)" echo " - 'make debug' run the project's selftest under gdb" echo " - 'make memcheck' run the project's selftest with valgrind to" echo " check for memory leaks" echo " - 'make coverage' generate project's selftest coverage report" echo " expects --with-gcov option for configure" echo ]) AX_SUMMARIZE_ENV AX_SUMMARIZE_CONFIG ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/Findlibzmq.cmake0000664000372000037200000000343613222211156016472 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ if (NOT MSVC) include(FindPkgConfig) pkg_check_modules(PC_LIBZMQ "libzmq") if (NOT PC_LIBZMQ_FOUND) pkg_check_modules(PC_LIBZMQ "libzmq") endif (NOT PC_LIBZMQ_FOUND) if (PC_LIBZMQ_FOUND) # add CFLAGS from pkg-config file, e.g. draft api. add_definitions(${PC_LIBZMQ_CFLAGS} ${PC_LIBZMQ_CFLAGS_OTHER}) # some libraries install the headers is a subdirectory of the include dir # returned by pkg-config, so use a wildcard match to improve chances of finding # headers and SOs. set(PC_LIBZMQ_INCLUDE_HINTS ${PC_LIBZMQ_INCLUDE_DIRS} ${PC_LIBZMQ_INCLUDE_DIRS}/*) set(PC_LIBZMQ_LIBRARY_HINTS ${PC_LIBZMQ_LIBRARY_DIRS} ${PC_LIBZMQ_LIBRARY_DIRS}/*) endif(PC_LIBZMQ_FOUND) endif (NOT MSVC) find_path ( LIBZMQ_INCLUDE_DIRS NAMES zmq.h HINTS ${PC_LIBZMQ_INCLUDE_HINTS} ) find_library ( LIBZMQ_LIBRARIES NAMES zmq HINTS ${PC_LIBZMQ_LIBRARY_HINTS} ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args( LIBZMQ REQUIRED_VARS LIBZMQ_LIBRARIES LIBZMQ_INCLUDE_DIRS ) mark_as_advanced( LIBZMQ_FOUND LIBZMQ_LIBRARIES LIBZMQ_INCLUDE_DIRS ) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/CMakeLists.txt0000664000372000037200000004456013222211156016134 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ ######################################################################## # Project setup ######################################################################## cmake_minimum_required(VERSION 2.8.8) project(czmq) enable_language(C) enable_testing() set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # Select flags SET(CMAKE_C_FLAGS_RELEASE "-O3") # Will be used to add flags to pkg-config useful when apps want to statically link set(pkg_config_libs_private "") ######################################################################## # options ######################################################################## if (NOT CMAKE_BUILD_TYPE) if (EXISTS "${SOURCE_DIR}/.git") set (CMAKE_BUILD_TYPE Debug) else () # http://xit0.org/2013/04/cmake-use-git-branch-and-commit-details-in-project/ # http://stackoverflow.com/questions/6797395/cmake-execute-process-always-fails-with-no-such-file-or-directory-when-i-cal execute_process( COMMAND git rev-parse --show-toplevel WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE git_result OUTPUT_VARIABLE git_root OUTPUT_STRIP_TRAILING_WHITESPACE ) message(STATUS "git workspace root [${git_result}]: ${git_root}") if ( "${git_result}" == "0" ) set (CMAKE_BUILD_TYPE Debug) else () set (CMAKE_BUILD_TYPE Release) endif () endif () endif () if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" ON) else () OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" OFF) endif () IF (ENABLE_DRAFTS) ADD_DEFINITIONS (-DCZMQ_BUILD_DRAFT_API) ENDIF (ENABLE_DRAFTS) ######################################################################## # platform.h ######################################################################## include(CheckIncludeFile) CHECK_INCLUDE_FILE("linux/wireless.h" HAVE_LINUX_WIRELESS_H) CHECK_INCLUDE_FILE("net/if_media.h" HAVE_NET_IF_MEDIA_H) include(CheckFunctionExists) CHECK_FUNCTION_EXISTS("getifaddrs" HAVE_GETIFADDRS) CHECK_FUNCTION_EXISTS("freeifaddrs" HAVE_FREEIFADDRS) include(CheckIncludeFiles) check_include_files("sys/socket.h;net/if.h" HAVE_NET_IF_H) 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" " #cmakedefine HAVE_LINUX_WIRELESS_H #cmakedefine HAVE_NET_IF_H #cmakedefine HAVE_NET_IF_MEDIA_H #cmakedefine HAVE_GETIFADDRS #cmakedefine HAVE_FREEIFADDRS ") configure_file("${SOURCE_DIR}/src/platform.h.in" "${SOURCE_DIR}/src/platform.h") #The MSVC C compiler is too out of date, #so the sources have to be compiled as c++ if (MSVC) enable_language(CXX) file(GLOB sources "${SOURCE_DIR}/src/*.c") set_source_files_properties( ${sources} PROPERTIES LANGUAGE CXX ) set(MORE_LIBRARIES ws2_32 Rpcrt4 Iphlpapi) endif() # specific case of windows UWP if( "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore" AND "${CMAKE_SYSTEM_VERSION}" STREQUAL "10.0") ADD_DEFINITIONS(-DZMQ_HAVE_WINDOWS_UWP) ADD_DEFINITIONS(-D_WIN32_WINNT=_WIN32_WINNT_WIN10) endif() # required libraries for mingw if (MINGW) set(MORE_LIBRARIES -lws2_32 -lrpcrt4 -liphlpapi) endif() # required libraries for cygwin if (CYGWIN) set(MORE_LIBRARIES) endif() list(APPEND CMAKE_MODULE_PATH "${SOURCE_DIR}") set(OPTIONAL_LIBRARIES) ######################################################################## # LIBZMQ dependency ######################################################################## find_package(libzmq REQUIRED) IF (LIBZMQ_FOUND) include_directories(${LIBZMQ_INCLUDE_DIRS}) list(APPEND MORE_LIBRARIES ${LIBZMQ_LIBRARIES}) set(pkg_config_libs_private "${pkg_config_libs_private} -lzmq") ELSE (LIBZMQ_FOUND) message( FATAL_ERROR "libzmq not found." ) ENDIF (LIBZMQ_FOUND) ######################################################################## # UUID dependency ######################################################################## find_package(uuid) IF (UUID_FOUND) include_directories(${UUID_INCLUDE_DIRS}) list(APPEND MORE_LIBRARIES ${UUID_LIBRARIES}) set(pkg_config_libs_private "${pkg_config_libs_private} -luuid") add_definitions(-DHAVE_UUID) list(APPEND OPTIONAL_LIBRARIES ${UUID_LIBRARIES}) ENDIF (UUID_FOUND) ######################################################################## # SYSTEMD dependency ######################################################################## find_package(systemd) IF (SYSTEMD_FOUND) include_directories(${SYSTEMD_INCLUDE_DIRS}) list(APPEND MORE_LIBRARIES ${SYSTEMD_LIBRARIES}) set(pkg_config_libs_private "${pkg_config_libs_private} -lsystemd") add_definitions(-DHAVE_LIBSYSTEMD) list(APPEND OPTIONAL_LIBRARIES ${SYSTEMD_LIBRARIES}) ENDIF (SYSTEMD_FOUND) ######################################################################## # LZ4 dependency ######################################################################## find_package(lz4) IF (LZ4_FOUND) include_directories(${LZ4_INCLUDE_DIRS}) list(APPEND MORE_LIBRARIES ${LZ4_LIBRARIES}) set(pkg_config_libs_private "${pkg_config_libs_private} -llz4") add_definitions(-DHAVE_LIBLZ4) list(APPEND OPTIONAL_LIBRARIES ${LZ4_LIBRARIES}) ENDIF (LZ4_FOUND) ######################################################################## # version ######################################################################## set(CZMQ_VERSION_MAJOR 4) set(CZMQ_VERSION_MINOR 1) set(CZMQ_VERSION_PATCH 0) set(CZMQ_VERSION "${CZMQ_VERSION_MAJOR}.${CZMQ_VERSION_MINOR}.${CZMQ_VERSION_PATCH}") message(STATUS "Detected CZMQ Version - ${CZMQ_VERSION}") ######################################################################## # includes ######################################################################## set (czmq_headers include/czmq_library.h include/czmq_prelude.h include/czmq.h include/zactor.h include/zarmour.h include/zcert.h include/zcertstore.h include/zchunk.h include/zclock.h include/zconfig.h include/zdigest.h include/zdir.h include/zdir_patch.h include/zfile.h include/zframe.h include/zhash.h include/zhashx.h include/ziflist.h include/zlist.h include/zlistx.h include/zloop.h include/zmsg.h include/zpoller.h include/zsock.h include/zstr.h include/zsys.h include/zuuid.h include/zauth.h include/zbeacon.h include/zgossip.h include/zmonitor.h include/zproxy.h include/zrex.h src/zgossip_msg.h src/zsock_option.inc src/zgossip_engine.inc src/zhash_primes.inc src/foreign/sha1/sha1.inc_c src/foreign/sha1/sha1.h src/foreign/slre/slre.inc_c src/foreign/slre/slre.h src/foreign/slre/readme.txt ) IF (ENABLE_DRAFTS) list(APPEND czmq_headers include/zargs.h include/zproc.h include/ztimerset.h include/ztrie.h ) ENDIF (ENABLE_DRAFTS) source_group ("Header Files" FILES ${czmq_headers}) install(FILES ${czmq_headers} DESTINATION include) ######################################################################## # library ######################################################################## include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include") set (czmq_sources src/zactor.c src/zarmour.c src/zcert.c src/zcertstore.c src/zchunk.c src/zclock.c src/zconfig.c src/zdigest.c src/zdir.c src/zdir_patch.c src/zfile.c src/zframe.c src/zhash.c src/zhashx.c src/ziflist.c src/zlist.c src/zlistx.c src/zloop.c src/zmsg.c src/zpoller.c src/zsock.c src/zstr.c src/zsys.c src/zuuid.c src/zauth.c src/zbeacon.c src/zgossip.c src/zmonitor.c src/zproxy.c src/zrex.c src/zgossip_msg.c ) IF (ENABLE_DRAFTS) list (APPEND czmq_sources src/zargs.c src/zproc.c src/ztimerset.c src/ztrie.c ) ENDIF (ENABLE_DRAFTS) IF (ENABLE_DRAFTS) list (APPEND czmq_sources src/czmq_private_selftest.c ) ENDIF (ENABLE_DRAFTS) source_group("Source Files" FILES ${czmq_sources}) option(CZMQ_BUILD_SHARED "Whether or not to build the shared object" ON) option(CZMQ_BUILD_STATIC "Whether or not to build the static archive" ON) if (NOT CZMQ_BUILD_SHARED AND NOT CZMQ_BUILD_STATIC) message(FATAL_ERROR "Neither static nor shared library build enabled") endif() IF (NOT MSVC) # avoid building everything twice for shared + static # only on *nix, as Windows needs different preprocessor defines in static builds add_library (objects OBJECT ${czmq_sources}) set_property(TARGET objects PROPERTY POSITION_INDEPENDENT_CODE ON) ENDIF (NOT MSVC) # shared if (CZMQ_BUILD_SHARED) IF (MSVC) add_library(czmq SHARED ${czmq_sources}) ELSE (MSVC) add_library(czmq SHARED $) ENDIF (MSVC) set_target_properties (czmq PROPERTIES PUBLIC_HEADER "${public_headers}" DEFINE_SYMBOL "CZMQ_EXPORTS" SOVERSION "4" VERSION "${CZMQ_VERSION}" COMPILE_DEFINITIONS "DLL_EXPORT" OUTPUT_NAME "czmq" PREFIX "lib" ) target_link_libraries(czmq ${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES} ) install(TARGETS czmq LIBRARY DESTINATION "lib${LIB_SUFFIX}" # .so file ARCHIVE DESTINATION "lib${LIB_SUFFIX}" # .lib file RUNTIME DESTINATION bin # .dll file ) target_include_directories(czmq PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ) endif() # static if (CZMQ_BUILD_STATIC) IF (MSVC) add_library(czmq-static STATIC ${czmq_sources}) ELSE (MSVC) add_library(czmq-static STATIC $) ENDIF (MSVC) set_target_properties(czmq-static PROPERTIES PUBLIC_HEADER "${public_headers}" COMPILE_DEFINITIONS "CZMQ_STATIC" OUTPUT_NAME "czmq" PREFIX "lib" ) target_link_libraries(czmq-static ${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES} ) install(TARGETS czmq-static LIBRARY DESTINATION "lib${LIB_SUFFIX}" # .so file ARCHIVE DESTINATION "lib${LIB_SUFFIX}" # .lib file RUNTIME DESTINATION bin # .dll file ) target_include_directories(czmq-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ) target_compile_definitions(czmq-static PUBLIC CZMQ_STATIC ) endif() include(${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists-local.txt) # Optional project-local hook ######################################################################## # pkgconfig ######################################################################## set (VERSION "4.1.0") set (prefix "${CMAKE_INSTALL_PREFIX}") set (exec_prefix "\${prefix}") set (libdir "\${prefix}/lib${LIB_SUFFIX}") set (includedir "\${prefix}/include") IF (ENABLE_DRAFTS) set (pkg_config_defines "-DCZMQ_BUILD_DRAFT_API=1") ELSE (ENABLE_DRAFTS) set (pkg_config_defines "") ENDIF (ENABLE_DRAFTS) configure_file( "${SOURCE_DIR}/src/libczmq.pc.in" "${SOURCE_DIR}/src/libczmq.pc" @ONLY) install( FILES "${SOURCE_DIR}/src/libczmq.pc" DESTINATION "lib${LIB_SUFFIX}/pkgconfig" ) ######################################################################## # executables ######################################################################## add_executable( zmakecert "${SOURCE_DIR}/src/zmakecert.c" ) if (TARGET czmq) target_link_libraries( zmakecert czmq ${LIBZMQ_LIBRARIES} ${OPTIONAL_LIBRARIES} ) endif() if (NOT TARGET czmq AND TARGET czmq-static) target_link_libraries( zmakecert czmq-static ${LIBZMQ_LIBRARIES} ${OPTIONAL_LIBRARIES} ) endif() install(TARGETS zmakecert RUNTIME DESTINATION bin ) add_executable( zsp "${SOURCE_DIR}/src/zsp.c" ) if (TARGET czmq) target_link_libraries( zsp czmq ${LIBZMQ_LIBRARIES} ${OPTIONAL_LIBRARIES} ) endif() if (NOT TARGET czmq AND TARGET czmq-static) target_link_libraries( zsp czmq-static ${LIBZMQ_LIBRARIES} ${OPTIONAL_LIBRARIES} ) endif() add_executable( test_randof "${SOURCE_DIR}/src/test_randof.c" ) if (TARGET czmq) target_link_libraries( test_randof czmq ${LIBZMQ_LIBRARIES} ${OPTIONAL_LIBRARIES} ) endif() if (NOT TARGET czmq AND TARGET czmq-static) target_link_libraries( test_randof czmq-static ${LIBZMQ_LIBRARIES} ${OPTIONAL_LIBRARIES} ) endif() add_executable( czmq_selftest "${SOURCE_DIR}/src/czmq_selftest.c" ) if (TARGET czmq) target_link_libraries( czmq_selftest czmq ${LIBZMQ_LIBRARIES} ${OPTIONAL_LIBRARIES} ) endif() if (NOT TARGET czmq AND TARGET czmq-static) target_link_libraries( czmq_selftest czmq-static ${LIBZMQ_LIBRARIES} ${OPTIONAL_LIBRARIES} ) endif() ######################################################################## # tests ######################################################################## set(CLASSTEST_TIMEOUT 60 CACHE STRING "Timeout of the selftest of a class") set(TOTAL_TIMEOUT 600 CACHE STRING "Timout of the total testsuite") if(UNIX) find_program(MEMORYCHECK_COMMAND valgrind) set(MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --show-reachable=yes --error-exitcode=1 --suppressions=src/.valgrind.supp") endif() set(TEST_CLASSES zactor zarmour zcert zcertstore zchunk zclock zconfig zdigest zdir zdir_patch zfile zframe zhash zhashx ziflist zlist zlistx zloop zmsg zpoller zsock zstr zsys zuuid zauth zbeacon zgossip zmonitor zproxy zrex ) IF (ENABLE_DRAFTS) list (APPEND TEST_CLASSES zargs zproc ztimerset ztrie ) ENDIF (ENABLE_DRAFTS) IF (ENABLE_DRAFTS) list (APPEND TEST_CLASSES private_classes ) ENDIF (ENABLE_DRAFTS) add_custom_target( copy-selftest-ro ALL COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/src/selftest-ro ${CMAKE_BINARY_DIR}/src/selftest-ro ) add_custom_target( make-selftest-rw ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/src/selftest-rw ) set_directory_properties( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/src/selftest-ro;${CMAKE_BINARY_DIR}/src/selftest-rw" ) foreach(TEST_CLASS ${TEST_CLASSES}) add_test( NAME ${TEST_CLASS} COMMAND czmq_selftest --continue --verbose --test ${TEST_CLASS} ) set_tests_properties( ${TEST_CLASS} PROPERTIES TIMEOUT ${CLASSTEST_TIMEOUT} ) set_tests_properties( ${TEST_CLASS} PROPERTIES DEPENDS "copy-selftest-ro;make-selftest-rw" ) endforeach(TEST_CLASS) include(CTest) ######################################################################## # cleanup ######################################################################## add_custom_target (distclean @echo Cleaning for source distribution) set(cmake_generated ${CMAKE_BINARY_DIR}/CMakeCache.txt ${CMAKE_BINARY_DIR}/cmake_install.cmake ${CMAKE_BINARY_DIR}/Makefile ${CMAKE_BINARY_DIR}/CMakeFiles ${CMAKE_BINARY_DIR}/CTestTestfile.cmake ${CMAKE_BINARY_DIR}/DartConfiguration.tcl ${CMAKE_BINARY_DIR}/Testing ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_BINARY_DIR}/src/platform.h ${CMAKE_BINARY_DIR}/src/libczmq.pc ${CMAKE_BINARY_DIR}/src/libczmq.so ${CMAKE_BINARY_DIR}/src/czmq_selftest ${CMAKE_BINARY_DIR}/src/zmakecert ${CMAKE_BINARY_DIR}/src/zsp ${CMAKE_BINARY_DIR}/src/test_randof ${CMAKE_BINARY_DIR}/src/czmq_selftest ) add_custom_command( DEPENDS clean COMMENT "distribution clean" COMMAND rm ARGS -rf CMakeTmp ${cmake_generated} TARGET distclean ) ######################################################################## # summary ######################################################################## message ("") message (STATUS "******************* Configuration Summary *******************") message (STATUS "General:") message (STATUS " Version : ${VERSION}") message (STATUS " System : ${CMAKE_SYSTEM_NAME}") message (STATUS " C compiler : ${CMAKE_C_COMPILER}") message (STATUS " Debug C flags : ${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS}") message (STATUS " Release C flags : ${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS}") message (STATUS " Build type : ${CMAKE_BUILD_TYPE}") message (STATUS " Static build : ${CZMQ_BUILD_STATIC}") message (STATUS " Shared build : ${CZMQ_BUILD_SHARED}") IF (ENABLE_DRAFTS) message (STATUS " Draft API : Yes") ELSE (ENABLE_DRAFTS) message (STATUS " Draft API : No") ENDIF (ENABLE_DRAFTS) message (STATUS "") message (STATUS "Dependencies:") include(FeatureSummary) feature_summary (WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) message (STATUS "") message (STATUS "Install:") message (STATUS " Install prefix :" "${CMAKE_INSTALL_PREFIX}") message (STATUS "") message (STATUS "************************* Options ***************************") message (STATUS "Options:") message (STATUS " Use the Draft API (default = yes):") message (STATUS " -DENABLE-DRAFTS=[yes|no]") message (STATUS "") message (STATUS "*************************************************************") message (STATUS "Configuration complete! Now procced with:") message (STATUS " 'make' compile the project") message (STATUS " 'make test' run the project's selftest") message (STATUS " 'make install' install the project to ${CMAKE_INSTALL_PREFIX}") message (STATUS "") message (STATUS "Further options are:") message (STATUS " 'ctest -T memcheck' run the project's selftest with") message (STATUS " valgrind to check for memory leaks") message (STATUS "") ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/AUTHORS0000664000372000037200000000210713222211156014433 0ustar00travistravis00000000000000Corporate Copyright Statements ============================== Copyright (c) 1991-2014 iMatix Corporation Copyright (c) 2014-2016 Brocade Communications Systems Inc. Contributors ============ Pieter Hintjens Uli Köhler KIU Shueng Chuan Brian Knox Felipe cruz Chris Laws AJ Lewis Shannen Saez Kevin Sapper Michael Haberler Momo the Monster Stephen Hemminger Felipe Cruz Matt Connolly Steven McCoy Timothee "TTimo" Besset evoskuil Javier Lopez Lourens Naude Shane Hubred TJ Holowaychuk William Roberts Mikko Koppanen HughPowell Akira Kitada Amir Taaki Apostolis Xekoukoulotakis James Tucker Juan López Rubio Martin Hurton Augusto Henrique Hentz Bruno D. Rodrigues Bulat Shakirzyanov Dan Colish Dongmin Yu Gavin Jason Ziglar Kaustubh Rawoorkar Luc Heinrich MilfordTea Timothee Besset jpulver woldan Patrick Noffke Brandon Ehle Mike Gatny Chris Busbey Goswin von Brederlow Svein L. Ellingsen oikosdev J. Ritchie Carroll Patrik Wenger Luca Boccassi Kouhei Sutou Michal Vyskocil Jim Klimov Michal Hrusecky Alena Chernikava Stephen Procter Wes Young czmq-4.1.0/Findlz4.cmake0000664000372000037200000000332613222211156015703 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ if (NOT MSVC) include(FindPkgConfig) pkg_check_modules(PC_LZ4 "liblz4") if (NOT PC_LZ4_FOUND) pkg_check_modules(PC_LZ4 "liblz4") endif (NOT PC_LZ4_FOUND) if (PC_LZ4_FOUND) # add CFLAGS from pkg-config file, e.g. draft api. add_definitions(${PC_LZ4_CFLAGS} ${PC_LZ4_CFLAGS_OTHER}) # some libraries install the headers is a subdirectory of the include dir # returned by pkg-config, so use a wildcard match to improve chances of finding # headers and SOs. set(PC_LZ4_INCLUDE_HINTS ${PC_LZ4_INCLUDE_DIRS} ${PC_LZ4_INCLUDE_DIRS}/*) set(PC_LZ4_LIBRARY_HINTS ${PC_LZ4_LIBRARY_DIRS} ${PC_LZ4_LIBRARY_DIRS}/*) endif(PC_LZ4_FOUND) endif (NOT MSVC) find_path ( LZ4_INCLUDE_DIRS NAMES lz4.h HINTS ${PC_LZ4_INCLUDE_HINTS} ) find_library ( LZ4_LIBRARIES NAMES lz4 HINTS ${PC_LZ4_LIBRARY_HINTS} ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args( LZ4 REQUIRED_VARS LZ4_LIBRARIES LZ4_INCLUDE_DIRS ) mark_as_advanced( LZ4_FOUND LZ4_LIBRARIES LZ4_INCLUDE_DIRS ) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/CONTRIBUTING.md0000664000372000037200000000277713222211156015631 0ustar00travistravis00000000000000# Contributing to CZMQ The contributors are listed in AUTHORS (add yourself). This project uses the MPL v2 license, see LICENSE. Please read these documents BEFORE you send a patch: * CZMQ uses the [C4.1 (Collective Code Construction Contract)](http://rfc.zeromq.org/spec:22) process for contributions. Please read this if you are unfamiliar with it. * CZMQ uses the [CLASS (C Language Style for Scalabilty)](http://rfc.zeromq.org/spec:21) guide for code style. Please read this, and also read the existing code base. CZMQ grows by the slow and careful accretion of simple, minimal solutions to real problems faced by many people. Some people seem to not understand this. So in case of doubt: * Each patch defines one clear and agreed problem, and one clear, minimal, plausible solution. If you come with a large, complex problem and a large, complex solution, you will provoke a negative reaction from CZMQ maintainers and users. * We will usually merge patches aggressively, without a blocking review. If you send us bad patches, without taking the care to read and understand our rules, that reflects on you. Do NOT expect us to do your homework for you. * As rapidly we will merge poor quality patches, we will remove them again. If you insist on arguing about this and trying to justify your changes, we will simply ignore you and your patches. If you still insist, we will ban you. * CZMQ is not a sandbox where "anything goes until the next stable release". If you want to experiment, please work in your own projects. czmq-4.1.0/Finduuid.cmake0000664000372000037200000000336113222211156016137 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ if (NOT MSVC) include(FindPkgConfig) pkg_check_modules(PC_UUID "uuid") if (NOT PC_UUID_FOUND) pkg_check_modules(PC_UUID "uuid") endif (NOT PC_UUID_FOUND) if (PC_UUID_FOUND) # add CFLAGS from pkg-config file, e.g. draft api. add_definitions(${PC_UUID_CFLAGS} ${PC_UUID_CFLAGS_OTHER}) # some libraries install the headers is a subdirectory of the include dir # returned by pkg-config, so use a wildcard match to improve chances of finding # headers and SOs. set(PC_UUID_INCLUDE_HINTS ${PC_UUID_INCLUDE_DIRS} ${PC_UUID_INCLUDE_DIRS}/*) set(PC_UUID_LIBRARY_HINTS ${PC_UUID_LIBRARY_DIRS} ${PC_UUID_LIBRARY_DIRS}/*) endif(PC_UUID_FOUND) endif (NOT MSVC) find_path ( UUID_INCLUDE_DIRS NAMES uuid/uuid.h HINTS ${PC_UUID_INCLUDE_HINTS} ) find_library ( UUID_LIBRARIES NAMES uuid HINTS ${PC_UUID_LIBRARY_HINTS} ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args( UUID REQUIRED_VARS UUID_LIBRARIES UUID_INCLUDE_DIRS ) mark_as_advanced( UUID_FOUND UUID_LIBRARIES UUID_INCLUDE_DIRS ) ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/src/0000775000372000037200000000000013222211351014147 5ustar00travistravis00000000000000czmq-4.1.0/src/zauth.c0000664000372000037200000006612113222211156015457 0ustar00travistravis00000000000000/* ========================================================================= zauth - authentication for ZeroMQ security mechanisms Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header A zauth actor takes over authentication for all incoming connections in its context. You can whitelist or blacklist peers based on IP address, and define policies for securing PLAIN, CURVE, and GSSAPI connections. @discuss This class replaces zauth_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). @end */ #include "czmq_classes.h" #define ZAP_ENDPOINT "inproc://zeromq.zap.01" // -------------------------------------------------------------------------- // The self_t structure holds the state for one actor instance typedef struct { zsock_t *pipe; // Actor command pipe zsock_t *handler; // ZAP handler socket zhashx_t *whitelist; // Whitelisted addresses zhashx_t *blacklist; // Blacklisted addresses zhashx_t *passwords; // PLAIN passwords, if loaded zpoller_t *poller; // Socket poller zcertstore_t *certstore; // CURVE certificate store, if loaded bool allow_any; // CURVE allows arbitrary clients bool terminated; // Did caller ask us to quit? bool verbose; // Verbose logging enabled? } self_t; static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; zhashx_destroy (&self->passwords); zhashx_destroy (&self->whitelist); zhashx_destroy (&self->blacklist); zcertstore_destroy (&self->certstore); zpoller_destroy (&self->poller); if (self->handler) { zsock_unbind (self->handler, ZAP_ENDPOINT); zsock_destroy (&self->handler); } freen (self); *self_p = NULL; } } static self_t * s_self_new (zsock_t *pipe, zcertstore_t *certstore) { self_t *self = (self_t *) zmalloc (sizeof (self_t)); assert (self); if (certstore) { self->certstore = certstore; self->allow_any = false; } self->pipe = pipe; self->whitelist = zhashx_new (); assert (self->whitelist); self->blacklist = zhashx_new (); // Create ZAP handler and get ready for requests assert (self->blacklist); self->handler = zsock_new (ZMQ_REP); assert (self->handler); int rc = zsock_bind (self->handler, ZAP_ENDPOINT); assert (rc == 0); self->poller = zpoller_new (self->pipe, self->handler, NULL); assert (self->poller); return self; } // -------------------------------------------------------------------------- // Handle a command from calling application static int s_self_handle_pipe (self_t *self) { // Get the whole message off the pipe in one go zmsg_t *request = zmsg_recv (self->pipe); if (!request) return -1; // Interrupted char *command = zmsg_popstr (request); if (self->verbose) zsys_info ("zauth: API command=%s", command); if (streq (command, "ALLOW")) { char *address = zmsg_popstr (request); while (address) { if (self->verbose) zsys_info ("zauth: - whitelisting ipaddress=%s", address); zhashx_insert (self->whitelist, address, "OK"); zstr_free (&address); address = zmsg_popstr (request); } zsock_signal (self->pipe, 0); } else if (streq (command, "DENY")) { char *address = zmsg_popstr (request); while (address) { if (self->verbose) zsys_info ("zauth: - blacklisting ipaddress=%s", address); zhashx_insert (self->blacklist, address, "OK"); zstr_free (&address); address = zmsg_popstr (request); } zsock_signal (self->pipe, 0); } else if (streq (command, "PLAIN")) { // Get password file and load into zhash table // If the file doesn't exist we'll get an empty table char *filename = zmsg_popstr (request); zhashx_destroy (&self->passwords); self->passwords = zhashx_new (); if (zhashx_load (self->passwords, filename) && self->verbose) zsys_info ("zauth: could not load file=%s", filename); zstr_free (&filename); zsock_signal (self->pipe, 0); } else if (streq (command, "CURVE")) { // If location is CURVE_ALLOW_ANY, allow all clients. Otherwise // treat location as a directory that holds the certificates. char *location = zmsg_popstr (request); if (streq (location, CURVE_ALLOW_ANY)) self->allow_any = true; else { zcertstore_destroy (&self->certstore); // FIXME: what if this fails? self->certstore = zcertstore_new (location); self->allow_any = false; } zstr_free (&location); zsock_signal (self->pipe, 0); } else if (streq (command, "GSSAPI")) // GSSAPI authentication is not yet implemented here zsock_signal (self->pipe, 0); else if (streq (command, "VERBOSE")) { self->verbose = true; zsock_signal (self->pipe, 0); } else if (streq (command, "$TERM")) self->terminated = true; else { zsys_error ("zauth: - invalid command: %s", command); assert (false); } zstr_free (&command); zmsg_destroy (&request); return 0; } // -------------------------------------------------------------------------- // A small class for working with ZAP requests and replies. // Used internally in zauth to simplify working with RFC 27 messages. // Structure of a ZAP request typedef struct { zsock_t *handler; // Socket we're talking to bool verbose; // Log ZAP requests and replies? char *version; // Version number, must be "1.0" char *sequence; // Sequence number of request char *domain; // Server socket domain char *address; // Client IP address char *identity; // Server socket idenntity char *mechanism; // Security mechansim char *username; // PLAIN user name char *password; // PLAIN password, in clear text char *client_key; // CURVE client public key in ASCII char *principal; // GSSAPI client principal char *user_id; // User-Id to return in the ZAP Response } zap_request_t; static void s_zap_request_destroy (zap_request_t **self_p) { assert (self_p); if (*self_p) { zap_request_t *self = *self_p; freen (self->version); freen (self->sequence); freen (self->domain); freen (self->address); freen (self->identity); freen (self->mechanism); freen (self->username); freen (self->password); freen (self->client_key); freen (self->principal); // self->user_id is a pointer to one of the above fields freen (self); *self_p = NULL; } } // Receive a valid ZAP request from the handler socket // If the request was not valid, returns NULL. static zap_request_t * s_zap_request_new (zsock_t *handler, bool verbose) { zap_request_t *self = (zap_request_t *) zmalloc (sizeof (zap_request_t)); if (!self) return NULL; // Store handler socket so we can send a reply easily self->handler = handler; self->verbose = verbose; zmsg_t *request = zmsg_recv (handler); if (!request) { // interrupted s_zap_request_destroy (&self); return NULL; } // Get all standard frames off the handler socket self->version = zmsg_popstr (request); self->sequence = zmsg_popstr (request); self->domain = zmsg_popstr (request); self->address = zmsg_popstr (request); self->identity = zmsg_popstr (request); self->mechanism = zmsg_popstr (request); // If the version is wrong, we're linked with a bogus libzmq, so die assert (streq (self->version, "1.0")); // Get mechanism-specific frames if (streq (self->mechanism, "PLAIN")) { self->username = zmsg_popstr (request); self->password = zmsg_popstr (request); } else if (streq (self->mechanism, "CURVE")) { zframe_t *frame = zmsg_pop (request); assert (zframe_size (frame) == 32); self->client_key = (char *) zmalloc (41); #if (ZMQ_VERSION_MAJOR == 4) zmq_z85_encode (self->client_key, zframe_data (frame), 32); #endif zframe_destroy (&frame); } else if (streq (self->mechanism, "GSSAPI")) self->principal = zmsg_popstr (request); if (self->verbose) zsys_info ("zauth: ZAP request mechanism=%s ipaddress=%s", self->mechanism, self->address); zmsg_destroy (&request); return self; } // Send a ZAP reply to the handler socket static int s_zap_request_reply (zap_request_t *self, char *status_code, char *status_text, unsigned char *metadata, size_t metasize) { if (self->verbose) zsys_info ("zauth: - ZAP reply status_code=%s status_text=%s", status_code, status_text); zmsg_t *msg = zmsg_new (); int rc = zmsg_addstr(msg, "1.0"); assert (rc == 0); rc = zmsg_addstr(msg, self->sequence); assert (rc == 0); rc = zmsg_addstr(msg, status_code); assert (rc == 0); rc = zmsg_addstr(msg, status_text); assert (rc == 0); rc = zmsg_addstr(msg, self->user_id ? self->user_id : ""); assert (rc == 0); rc = zmsg_addmem(msg, metadata, metasize); assert (rc == 0); rc = zmsg_send(&msg, self->handler); assert (rc == 0); return 0; } // -------------------------------------------------------------------------- // Handle an authentication request from libzmq core // Helper for s_add_property // THIS IS A COPY OF zmq::put_uint32 (/src/wire.hpp) static void s_put_uint32 (unsigned char *buffer_, uint32_t value) { buffer_ [0] = (unsigned char) (((value) >> 24) & 0xff); buffer_ [1] = (unsigned char) (((value) >> 16) & 0xff); buffer_ [2] = (unsigned char) (((value) >> 8) & 0xff); buffer_ [3] = (unsigned char) (value & 0xff); } // Add metadata property to ptr // THIS IS AN ADAPTATION OF zmq::mechanism_t::add_property (/src/mechanism.cpp) static size_t s_add_property (unsigned char *ptr, const char *name, const void *value, size_t value_len) { const size_t name_len = strlen (name); assert (name_len <= 255); *ptr++ = (unsigned char) name_len; memcpy (ptr, name, name_len); ptr += name_len; assert (value_len <= 0x7FFFFFFF); s_put_uint32 (ptr, (uint32_t) value_len); ptr += 4; memcpy (ptr, value, value_len); return 1 + name_len + 4 + value_len; } static bool s_authenticate_plain (self_t *self, zap_request_t *request) { if (self->passwords) { zhashx_refresh (self->passwords); char *password = (char *) zhashx_lookup (self->passwords, request->username); if (password && streq (password, request->password)) { if (self->verbose) zsys_info ("zauth: - allowed (PLAIN) username=%s password=%s", request->username, request->password); request->user_id = request->username; return true; } else { if (self->verbose) zsys_info ("zauth: - denied (PLAIN) username=%s password=%s", request->username, request->password); return false; } } else { if (self->verbose) zsys_info ("zauth: - denied (PLAIN) no password file defined"); return false; } } static bool s_authenticate_curve (self_t *self, zap_request_t *request, unsigned char **metadata) { if (self->allow_any) { if (self->verbose) zsys_info ("zauth: - allowed (CURVE allow any client)"); return true; } else if (self->certstore) { zcert_t *cert = zcertstore_lookup (self->certstore, request->client_key); if (cert != NULL) { zlist_t *meta_k = zcert_meta_keys (cert); while (true) { void *key = zlist_next (meta_k); if (key == NULL) { break; } const char *val = zcert_meta(cert, (const char *) key); if (val == NULL) { break; } *metadata += s_add_property(*metadata, (const char *) key, val, strlen (val)); } zlist_destroy (&meta_k); if (self->verbose) zsys_info ("zauth: - allowed (CURVE) client_key=%s", request->client_key); request->user_id = request->client_key; return true; } } if (self->verbose) zsys_info ("zauth: - denied (CURVE) client_key=%s", request->client_key); return false; } static bool s_authenticate_gssapi (self_t *self, zap_request_t *request) { if (self->verbose) zsys_info ("zauth: - allowed (GSSAPI) principal=%s identity=%s", request->principal, request->identity); request->user_id = request->principal; return true; } // TODO: allow regular expressions in addresses static int s_self_authenticate (self_t *self) { zap_request_t *request = s_zap_request_new (self->handler, self->verbose); if (!request) return 0; // Interrupted, no request to process // Is address explicitly whitelisted or blacklisted? bool allowed = false; bool denied = false; // Curve certificate metadata unsigned char * const metabuf = (unsigned char *) malloc (512); assert (metabuf != NULL); unsigned char *metadata = metabuf; if (zhashx_size (self->whitelist)) { if (zhashx_lookup (self->whitelist, request->address)) { allowed = true; if (self->verbose) zsys_info ("zauth: - passed (whitelist) address=%s", request->address); } else { denied = true; if (self->verbose) zsys_info ("zauth: - denied (not in whitelist) address=%s", request->address); } } else if (zhashx_size (self->blacklist)) { if (zhashx_lookup (self->blacklist, request->address)) { denied = true; if (self->verbose) zsys_info ("zauth: - denied (blacklist) address=%s", request->address); } else { allowed = true; if (self->verbose) zsys_info ("zauth: - passed (not in blacklist) address=%s", request->address); } } // Mechanism-specific checks if (!denied) { if (streq (request->mechanism, "NULL") && !allowed) { // For NULL, we allow if the address wasn't blacklisted if (self->verbose) zsys_info ("zauth: - allowed (NULL)"); allowed = true; } else if (streq (request->mechanism, "PLAIN")) // For PLAIN, even a whitelisted address must authenticate allowed = s_authenticate_plain (self, request); else if (streq (request->mechanism, "CURVE")) // For CURVE, even a whitelisted address must authenticate allowed = s_authenticate_curve (self, request, &metadata); else if (streq (request->mechanism, "GSSAPI")) // For GSSAPI, even a whitelisted address must authenticate allowed = s_authenticate_gssapi (self, request); } if (allowed) { size_t metasize = metadata - metabuf; s_zap_request_reply (request, "200", "OK", metabuf, metasize); } else s_zap_request_reply (request, "400", "No access", (unsigned char *) "", 0); s_zap_request_destroy (&request); free (metabuf); return 0; } // -------------------------------------------------------------------------- // zauth() implements the zauth actor interface void zauth (zsock_t *pipe, void *certstore) { self_t *self = s_self_new (pipe, (zcertstore_t *)certstore); assert (self); // Signal successful initialization zsock_signal (pipe, 0); while (!self->terminated) { zsock_t *which = (zsock_t *) zpoller_wait (self->poller, -1); if (which == self->pipe) s_self_handle_pipe (self); else if (which == self->handler) s_self_authenticate (self); else if (zpoller_terminated (self->poller)) break; // Interrupted } s_self_destroy (&self); } // -------------------------------------------------------------------------- // Selftest #if (ZMQ_VERSION_MAJOR == 4) // Destroys old sockets and returns new ones static void s_renew_sockets (zsock_t **server, zsock_t **client) { zsock_destroy (client); zsock_destroy (server); *server = zsock_new (ZMQ_PULL); assert (*server); *client = zsock_new (ZMQ_PUSH); assert (*client); } // Checks whether client can connect to server static bool s_can_connect (zsock_t **server, zsock_t **client, bool renew) { int port_nbr = zsock_bind (*server, "tcp://127.0.0.1:*"); assert (port_nbr > 0); int rc = zsock_connect (*client, "tcp://127.0.0.1:%d", port_nbr); assert (rc == 0); // Give the connection time to fail if that's the plan if (zsock_mechanism (*client) == ZMQ_CURVE) zclock_sleep (1500); else zclock_sleep (200); // By default PUSH sockets block if there's no peer zsock_set_sndtimeo (*client, 200); zstr_send (*client, "Hello, World"); zpoller_t *poller = zpoller_new (*server, NULL); assert (poller); bool success = (zpoller_wait (poller, 400) == *server); zpoller_destroy (&poller); if (renew == true) s_renew_sockets (server, client); return success; } static void s_test_loader (zcertstore_t *certstore) { zcertstore_empty (certstore); byte public_key [32] = { 105, 76, 150, 58, 214, 191, 218, 65, 50, 172, 131, 188, 247, 211, 136, 170, 227, 26, 57, 170, 185, 63, 246, 225, 177, 230, 12, 8, 134, 136, 105, 106 }; byte secret_key [32] = { 245, 217, 172, 73, 106, 28, 195, 17, 218, 132, 135, 209, 99, 240, 98, 232, 7, 137, 244, 100, 242, 23, 29, 114, 70, 223, 83, 1, 113, 207, 132, 149 }; zcert_t *cert = zcert_new_from (public_key, secret_key); assert (cert); zcertstore_insert (certstore, &cert); } #endif void zauth_test (bool verbose) { printf (" * zauth: "); #if (ZMQ_VERSION_MAJOR == 4) if (verbose) printf ("\n"); // @selftest const char *SELFTEST_DIR_RW = "src/selftest-rw"; const char *testbasedir = ".test_zauth"; const char *testpassfile = "password-file"; const char *testcertfile = "mycert.txt"; char *basedirpath = NULL; // subdir in a test, under SELFTEST_DIR_RW char *passfilepath = NULL; // pathname to testfile in a test, in dirpath char *certfilepath = NULL; // pathname to testfile in a test, in dirpath basedirpath = zsys_sprintf ("%s/%s", SELFTEST_DIR_RW, testbasedir); assert (basedirpath); passfilepath = zsys_sprintf ("%s/%s", basedirpath, testpassfile); assert (passfilepath); certfilepath = zsys_sprintf ("%s/%s", basedirpath, testcertfile); assert (certfilepath); // Make sure old aborted tests do not hinder us zdir_t *dir = zdir_new (basedirpath, NULL); if (dir) { zdir_remove (dir, true); zdir_destroy (&dir); } zsys_file_delete (passfilepath); zsys_file_delete (certfilepath); zsys_dir_delete (basedirpath); // Create temporary directory for test files zsys_dir_create (basedirpath); // Check there's no authentication zsock_t *server = zsock_new (ZMQ_PULL); assert (server); zsock_t *client = zsock_new (ZMQ_PUSH); assert (client); bool success = s_can_connect (&server, &client, true); assert (success); // Install the authenticator zactor_t *auth = zactor_new (zauth, NULL); assert (auth); if (verbose) { zstr_sendx (auth, "VERBOSE", NULL); zsock_wait (auth); } // Check there's no authentication on a default NULL server success = s_can_connect (&server, &client, true); assert (success); // When we set a domain on the server, we switch on authentication // for NULL sockets, but with no policies, the client connection // will be allowed. zsock_set_zap_domain (server, "global"); success = s_can_connect (&server, &client, true); assert (success); // Blacklist 127.0.0.1, connection should fail zsock_set_zap_domain (server, "global"); zstr_sendx (auth, "DENY", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&server, &client, true); assert (!success); // Whitelist our address, which overrides the blacklist zsock_set_zap_domain (server, "global"); zstr_sendx (auth, "ALLOW", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&server, &client, true); assert (success); // Try PLAIN authentication zsock_set_zap_domain (server, "global"); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Password"); success = s_can_connect (&server, &client, true); assert (!success); FILE *password = fopen (passfilepath, "w"); assert (password); fprintf (password, "admin=Password\n"); fclose (password); zsock_set_zap_domain (server, "global"); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Password"); zstr_sendx (auth, "PLAIN", passfilepath, NULL); zsock_wait (auth); success = s_can_connect (&server, &client, false); assert (success); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (4, 1, 0)) // Test that the User-Id metadata is present zframe_t *frame = zframe_recv (server); assert (frame != NULL); const char *user_id = zframe_meta (frame, "User-Id"); assert (user_id != NULL); assert (streq (user_id, "admin")); zframe_destroy (&frame); #endif s_renew_sockets(&server, &client); zsock_set_zap_domain (server, "global"); zsock_set_plain_server (server, 1); zsock_set_plain_username (client, "admin"); zsock_set_plain_password (client, "Bogus"); success = s_can_connect (&server, &client, true); assert (!success); if (zsys_has_curve ()) { // Try CURVE authentication // We'll create two new certificates and save the client public // certificate on disk; in a real case we'd transfer this securely // from the client machine to the server machine. zcert_t *server_cert = zcert_new (); assert (server_cert); zcert_t *client_cert = zcert_new (); assert (client_cert); const char *server_key = zcert_public_txt (server_cert); // Test without setting-up any authentication zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zsock_set_zap_domain (server, "global"); success = s_can_connect (&server, &client, true); assert (!success); // Test CURVE_ALLOW_ANY zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zstr_sendx (auth, "CURVE", CURVE_ALLOW_ANY, NULL); zsock_wait (auth); success = s_can_connect (&server, &client, true); assert (success); // Test full client authentication using certificates zcert_set_meta (client_cert, "Hello", "%s", "World!"); zcert_apply (server_cert, server); zcert_apply (client_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, server_key); zcert_save_public (client_cert, certfilepath); zstr_sendx (auth, "CURVE", basedirpath, NULL); zsock_wait (auth); zsock_set_zap_domain (server, "global"); success = s_can_connect (&server, &client, false); assert (success); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (4, 1, 0)) // Test send/recv certificate metadata zframe_t *frame = zframe_recv (server); assert (frame != NULL); const char *meta = zframe_meta (frame, "Hello"); assert (meta != NULL); assert (streq (meta, "World!")); const char *user_id = zframe_meta (frame, "User-Id"); assert (user_id != NULL); assert (streq (user_id, zcert_public_txt(client_cert))); zframe_destroy (&frame); s_renew_sockets(&server, &client); #endif zcert_destroy (&server_cert); zcert_destroy (&client_cert); // Test custom zcertstore zcertstore_t *certstore = zcertstore_new (NULL); zcertstore_set_loader (certstore, s_test_loader, NULL, NULL); zactor_destroy(&auth); auth = zactor_new (zauth, certstore); assert (auth); if (verbose) { zstr_sendx (auth, "VERBOSE", NULL); zsock_wait (auth); } byte public_key [32] = { 105, 76, 150, 58, 214, 191, 218, 65, 50, 172, 131, 188, 247, 211, 136, 170, 227, 26, 57, 170, 185, 63, 246, 225, 177, 230, 12, 8, 134, 136, 105, 106 }; byte secret_key [32] = { 245, 217, 172, 73, 106, 28, 195, 17, 218, 132, 135, 209, 99, 240, 98, 232, 7, 137, 244, 100, 242, 23, 29, 114, 70, 223, 83, 1, 113, 207, 132, 149 }; zcert_t *shared_cert = zcert_new_from (public_key, secret_key); assert (shared_cert); zcert_apply (shared_cert, server); zcert_apply (shared_cert, client); zsock_set_curve_server (server, 1); zsock_set_curve_serverkey (client, "x?T*N/1Y{8goubv{Ts}#&#f}TXJ//DVe#D2HkoLU"); success = s_can_connect (&server, &client, true); assert (success); zcert_destroy (&shared_cert); } // Remove the authenticator and check a normal connection works zactor_destroy (&auth); success = s_can_connect (&server, &client, true); assert (success); zsock_destroy (&client); zsock_destroy (&server); // Delete all test files dir = zdir_new (basedirpath, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); zstr_free (&passfilepath); zstr_free (&certfilepath); zstr_free (&basedirpath); #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zmsg.c0000664000372000037200000010651213222211156015303 0ustar00travistravis00000000000000/* ========================================================================= zmsg - working with multipart messages Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zmsg class provides methods to send and receive multipart messages across 0MQ sockets. This class provides a list-like container interface, with methods to work with the overall container. zmsg_t messages are composed of zero or more zframe_t frames. @discuss @end */ #include "czmq_classes.h" // zmsg_t instances always have this tag as the first 4 octets of // their data, which lets us do runtime object typing & validation. #define ZMSG_TAG 0x0003cafe // Structure of our class struct _zmsg_t { uint32_t tag; // Object tag for runtime detection zlist_t *frames; // List of frames size_t content_size; // Total content size uint32_t routing_id; // Routing ID back to sender, if any }; // -------------------------------------------------------------------------- // Constructor zmsg_t * zmsg_new (void) { zmsg_t *self = (zmsg_t *) zmalloc (sizeof (zmsg_t)); assert (self); self->tag = ZMSG_TAG; self->frames = zlist_new (); assert (self->frames); return self; } // -------------------------------------------------------------------------- // Destructor void zmsg_destroy (zmsg_t **self_p) { assert (self_p); if (*self_p) { zmsg_t *self = *self_p; assert (zmsg_is (self)); zframe_t *frame; while ((frame = (zframe_t *) zlist_pop (self->frames))) zframe_destroy (&frame); zlist_destroy (&self->frames); self->tag = 0xDeadBeef; freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Receive a message from a socket. The socket may be a libzmq socket, or a // zsock_t object. Returns a new zmsg_t object if successful, or NULL if the // receive was interrupted. The recv call blocks: if you want a non-blocking // call, use the zloop or zpoller class to receive only from ready sockets. // Keeps retrying if interrupted in a middle of a multipart sequence. zmsg_t * zmsg_recv (void *source) { assert (source); zmsg_t *self = zmsg_new (); if (!self) return NULL; while (true) { zframe_t *frame = zframe_recv (source); if (!frame) { if (errno == EINTR && zlist_head (self->frames)) continue; else { zmsg_destroy (&self); break; // Interrupted or terminated } } #if defined (ZMQ_SERVER) // Grab routing ID if we're reading from a SERVER socket (ZMQ 4.2 and later) if (zsock_type (source) == ZMQ_SERVER) self->routing_id = zframe_routing_id (frame); #endif if (zmsg_append (self, &frame)) { zmsg_destroy (&self); break; } if (!zsock_rcvmore (source)) break; // Last message frame } return self; } // -------------------------------------------------------------------------- // Send message to destination socket, and destroy the message after sending // it successfully. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). // Keeps retrying if interrupted in a middle of a multipart sequence. int zmsg_send (zmsg_t **self_p, void *dest) { assert (self_p); assert (dest); zmsg_t *self = *self_p; int rc = 0; if (self) { assert (zmsg_is (self)); bool sent_some = false; zframe_t *frame; while ((frame = (zframe_t *) zlist_head (self->frames))) { zframe_set_routing_id (frame, self->routing_id); rc = zframe_send (&frame, dest, zlist_size (self->frames) > 1? ZFRAME_MORE: 0); if (rc != 0) { if (errno == EINTR && sent_some) continue; else break; } sent_some = true; (void) zlist_pop (self->frames); } if (rc == 0) zmsg_destroy (self_p); } return rc; } // -------------------------------------------------------------------------- // Send message to destination socket as part of a multipart sequence, and // destroy the message after sending it successfully. Note that after a // zmsg_sendm, you must call zmsg_send or another method that sends a final // message part. If the message has no frames, sends nothing but destroys // the message anyhow. Nullifies the caller's reference to the message (as // it is a destructor). // Keeps retrying if interrupted in a middle of a multipart sequence. int zmsg_sendm (zmsg_t **self_p, void *dest) { assert (self_p); assert (dest); zmsg_t *self = *self_p; int rc = 0; if (self) { assert (zmsg_is (self)); bool sent_some = false; zframe_t *frame; while ((frame = (zframe_t *) zlist_head (self->frames))) { zframe_set_routing_id (frame, self->routing_id); rc = zframe_send (&frame, dest, ZFRAME_MORE); if (rc != 0) { if (errno == EINTR && sent_some) continue; else break; } sent_some = true; (void) zlist_pop (self->frames); } if (rc == 0) zmsg_destroy (self_p); } return rc; } // -------------------------------------------------------------------------- // Return size of message, i.e. number of frames (0 or more). size_t zmsg_size (zmsg_t *self) { assert (self); assert (zmsg_is (self)); return zlist_size (self->frames); } // -------------------------------------------------------------------------- // Return total size of all frames in message. size_t zmsg_content_size (zmsg_t *self) { assert (self); assert (zmsg_is (self)); return self->content_size; } // -------------------------------------------------------------------------- // Return message routing ID, if the message came from a ZMQ_SERVER socket. // Else returns zero. uint32_t zmsg_routing_id (zmsg_t *self) { assert (self); assert (zmsg_is (self)); return self->routing_id; } // -------------------------------------------------------------------------- // Set routing ID on message. This is used if/when the message is sent to a // ZMQ_SERVER socket. void zmsg_set_routing_id (zmsg_t *self, uint32_t routing_id) { assert (self); assert (zmsg_is (self)); self->routing_id = routing_id; } // -------------------------------------------------------------------------- // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not // nullify the caller's frame reference. int zmsg_prepend (zmsg_t *self, zframe_t **frame_p) { assert (self); assert (zmsg_is (self)); assert (frame_p); zframe_t *frame = *frame_p; *frame_p = NULL; // We now own frame self->content_size += zframe_size (frame); zlist_push (self->frames, frame); return 0; } // -------------------------------------------------------------------------- // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. Nullifies caller's reference to frame. int zmsg_append (zmsg_t *self, zframe_t **frame_p) { assert (self); assert (zmsg_is (self)); assert (frame_p); zframe_t *frame = *frame_p; *frame_p = NULL; // We now own frame self->content_size += zframe_size (frame); zlist_append (self->frames, frame); return 0; } // -------------------------------------------------------------------------- // Remove first frame from message, if any. Returns frame, or NULL. Caller // now owns frame and must destroy it when finished with it. zframe_t * zmsg_pop (zmsg_t *self) { assert (self); assert (zmsg_is (self)); zframe_t *frame = (zframe_t *) zlist_pop (self->frames); if (frame) self->content_size -= zframe_size (frame); return frame; } // -------------------------------------------------------------------------- // Push block of memory to front of message, as a new frame. // Returns 0 on success, -1 on error. int zmsg_pushmem (zmsg_t *self, const void *data, size_t size) { assert (self); assert (zmsg_is (self)); zframe_t *frame = zframe_new (data, size); assert (frame); self->content_size += size; zlist_push (self->frames, frame); return 0; } // -------------------------------------------------------------------------- // Add block of memory to the end of the message, as a new frame. // Returns 0 on success, -1 on error. int zmsg_addmem (zmsg_t *self, const void *data, size_t size) { assert (self); assert (zmsg_is (self)); zframe_t *frame = zframe_new (data, size); assert (frame); self->content_size += size; zlist_append (self->frames, frame); return 0; } // -------------------------------------------------------------------------- // Push string as new frame to front of message. // Returns 0 on success, -1 on error. int zmsg_pushstr (zmsg_t *self, const char *string) { assert (self); assert (zmsg_is (self)); assert (string); size_t len = strlen (string); zframe_t *frame = zframe_new (string, len); assert (frame); self->content_size += len; zlist_push (self->frames, frame); return 0; } // -------------------------------------------------------------------------- // Push string as new frame to end of message. // Returns 0 on success, -1 on error. int zmsg_addstr (zmsg_t *self, const char *string) { assert (self); assert (zmsg_is (self)); assert (string); size_t len = strlen (string); zframe_t *frame = zframe_new (string, len); assert (frame); self->content_size += len; zlist_append (self->frames, frame); return 0; } // -------------------------------------------------------------------------- // Push formatted string as new frame to front of message. // Returns 0 on success, -1 on error. int zmsg_pushstrf (zmsg_t *self, const char *format, ...) { assert (self); assert (zmsg_is (self)); assert (format); va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); if (!string) return -1; size_t len = strlen (string); zframe_t *frame = zframe_new (string, len); assert (frame); self->content_size += len; zlist_push (self->frames, frame); zstr_free (&string); return 0; } // -------------------------------------------------------------------------- // Push formatted string as new frame to end of message. // Returns 0 on success, -1 on error. int zmsg_addstrf (zmsg_t *self, const char *format, ...) { assert (self); assert (zmsg_is (self)); assert (format); va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); if (!string) return -1; size_t len = strlen (string); zframe_t *frame = zframe_new (string, len); assert (frame); self->content_size += len; zlist_append (self->frames, frame); zstr_free (&string); return 0; } // -------------------------------------------------------------------------- // Pop frame off front of message, return as fresh string. If there were // no more frames in the message, returns NULL. char * zmsg_popstr (zmsg_t *self) { assert (self); assert (zmsg_is (self)); zframe_t *frame = (zframe_t *) zlist_pop (self->frames); char *string = NULL; if (frame) { self->content_size -= zframe_size (frame); string = zframe_strdup (frame); zframe_destroy (&frame); } return string; } // -------------------------------------------------------------------------- // Push encoded message as a new frame. Message takes ownership of // submessage, so the original is destroyed in this call. Returns 0 on // success, -1 on error. int zmsg_addmsg (zmsg_t *self, zmsg_t **msg_p) { assert (self); assert (zmsg_is (self)); assert (msg_p); zframe_t *frame = zmsg_encode (*msg_p); zmsg_append (self, &frame); zmsg_destroy (msg_p); return 0; } // -------------------------------------------------------------------------- // Remove first submessage from message, if any. Returns zmsg_t, or NULL if // decoding was not successful. Caller now owns message and must destroy it // when finished with it. zmsg_t * zmsg_popmsg (zmsg_t *self) { assert (self); assert (zmsg_is (self)); zframe_t *frame = zmsg_pop (self); if (!frame) return NULL; zmsg_t *msg = zmsg_decode (frame); zframe_destroy (&frame); return msg; } // -------------------------------------------------------------------------- // Remove specified frame from list, if present. Does not destroy frame. void zmsg_remove (zmsg_t *self, zframe_t *frame) { assert (self); assert (zmsg_is (self)); // zlist_remove does not give feedback on whether an element was actually // removed or not. To avoid wrongly decreasing the size in case the frame // is not actually part of the zmsg, check the size before and after. // We could do a search but that's a full scan, while the size is saved // by zlist so checking it is much cheaper. size_t num_frames_before = zlist_size (self->frames); zlist_remove (self->frames, frame); size_t num_frames_after = zlist_size (self->frames); if (num_frames_before > num_frames_after) self->content_size -= zframe_size (frame); } // -------------------------------------------------------------------------- // Set cursor to first frame in message. Returns frame, or NULL, if the // message is empty. Use this to navigate the frames as a list. zframe_t * zmsg_first (zmsg_t *self) { assert (self); assert (zmsg_is (self)); return (zframe_t *) zlist_first (self->frames); } // -------------------------------------------------------------------------- // Return the next frame. If there are no more frames, returns NULL. To move // to the first frame call zmsg_first(). Advances the cursor. zframe_t * zmsg_next (zmsg_t *self) { assert (self); assert (zmsg_is (self)); return (zframe_t *) zlist_next (self->frames); } // -------------------------------------------------------------------------- // Return the last frame. If there are no frames, returns NULL. zframe_t * zmsg_last (zmsg_t *self) { assert (self); assert (zmsg_is (self)); return (zframe_t *) zlist_last (self->frames); } // -------------------------------------------------------------------------- // Save message to an open file, return 0 if OK, else -1. The message is // saved as a series of frames, each with length and data. Note that the // file is NOT guaranteed to be portable between operating systems, not // versions of CZMQ. The file format is at present undocumented and liable // to arbitrary change. int zmsg_save (zmsg_t *self, FILE *file) { assert (self); assert (zmsg_is (self)); assert (file); zframe_t *frame = zmsg_first (self); while (frame) { size_t frame_size = zframe_size (frame); if (fwrite (&frame_size, sizeof (frame_size), 1, file) != 1) return -1; if (fwrite (zframe_data (frame), frame_size, 1, file) != 1) return -1; frame = zmsg_next (self); } return 0; } // -------------------------------------------------------------------------- // Load/append an open file into new message, return the message. // Returns NULL if the message could not be loaded. zmsg_t * zmsg_load (FILE *file) { zmsg_t *self = zmsg_new (); assert (self); assert (file); while (true) { size_t frame_size; if (fread (&frame_size, sizeof (frame_size), 1, file) == 1) { zframe_t *frame = zframe_new (NULL, frame_size); if (fread (zframe_data (frame), frame_size, 1, file) == 1 && frame_size > 0) zmsg_append (self, &frame); else { zframe_destroy (&frame); zmsg_destroy (&self); break; } } else break; // Unable to read properly, quit } return self; } // -------------------------------------------------------------------------- // Serialize multipart message to a single message frame. Use this method // to send structured messages across transports that do not support // multipart data. Allocates and returns a new frame containing the // serialized message. To decode a serialized message frame, use // zmsg_decode (). // // Frame lengths are encoded as 1 or 1+4 bytes // 0..254 bytes octet + data // 255..4Gb-1 bytes 0xFF + 4octet + data zframe_t * zmsg_encode (zmsg_t *self) { assert (self); assert (zmsg_is (self)); // Calculate real size of frame size_t total_size = 0; zframe_t *frame = zmsg_first (self); while (frame) { size_t frame_size = zframe_size (frame); if (frame_size < 255) total_size += frame_size + 1; else total_size += frame_size + 1 + 4; frame = zmsg_next (self); } zframe_t *encoded = zframe_new (NULL, total_size); assert (encoded); // Encode message into frame byte *dest = zframe_data (encoded); frame = zmsg_first (self); while (frame) { size_t frame_size = zframe_size (frame); if (frame_size < 255) { *dest++ = (byte) frame_size; memcpy (dest, zframe_data (frame), frame_size); dest += frame_size; } else { *dest++ = 0xFF; *dest++ = (frame_size >> 24) & 255; *dest++ = (frame_size >> 16) & 255; *dest++ = (frame_size >> 8) & 255; *dest++ = frame_size & 255; memcpy (dest, zframe_data (frame), frame_size); dest += frame_size; } frame = zmsg_next (self); } assert ((size_t) (dest - zframe_data (encoded)) == total_size); return encoded; } // -------------------------------------------------------------------------- // Decodes a serialized message frame created by zmsg_encode () and returns // a new zmsg_t object. Returns NULL if the frame was badly formatted or // there was insufficient memory to work. zmsg_t * zmsg_decode (zframe_t *frame) { assert (frame); zmsg_t *self = zmsg_new (); assert (self); const byte *source = zframe_data (frame); const byte *limit = zframe_data (frame) + zframe_size (frame); while (source < limit) { size_t frame_size = *source++; if (frame_size == 255) { if (source > limit - 4) { zmsg_destroy (&self); break; } frame_size = (source [0] << 24) + (source [1] << 16) + (source [2] << 8) + source [3]; source += 4; } if (source > limit - frame_size) { zmsg_destroy (&self); break; } zframe_t *decoded = zframe_new (source, frame_size); assert (decoded); zmsg_append (self, &decoded); source += frame_size; } return self; } // -------------------------------------------------------------------------- // Create copy of message, as new message object. Returns a fresh zmsg_t // object. If message is null, or memory was exhausted, returns null. zmsg_t * zmsg_dup (zmsg_t *self) { if (self) { assert (zmsg_is (self)); zmsg_t *copy = zmsg_new (); assert (copy); zframe_t *frame = zmsg_first (self); while (frame) { zmsg_addmem (copy, zframe_data (frame), zframe_size (frame)); frame = zmsg_next (self); } return copy; } else return NULL; } // -------------------------------------------------------------------------- // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). void zmsg_print (zmsg_t *self) { assert (self); assert (zmsg_is (self)); if (!self) { zsys_debug ("(NULL)"); return; } zframe_t *frame = zmsg_first (self); while (frame) { zframe_print (frame, NULL); frame = zmsg_next (self); } } // -------------------------------------------------------------------------- // Return true if the two messages have the same number of frames and each // frame in the first message is identical to the corresponding frame in the // other message. As with zframe_eq, return false if either message is NULL. bool zmsg_eq (zmsg_t *self, zmsg_t *other) { if (!self || !other) return false; if (zlist_size (self->frames) != zlist_size (other->frames)) return false; zframe_t *self_frame = (zframe_t *) zlist_first (self->frames); zframe_t *other_frame = (zframe_t *) zlist_first (other->frames); while (self_frame && other_frame) { if (!zframe_eq (self_frame, other_frame)) return false; self_frame = (zframe_t *) zlist_next (self->frames); other_frame = (zframe_t *) zlist_next (other->frames); } return true; } // -------------------------------------------------------------------------- // Generate a signal message encoding the given status. A signal is a short // message carrying a 1-byte success/failure code (by convention, 0 means // OK). Signals are encoded to be distinguishable from "normal" messages. zmsg_t * zmsg_new_signal (byte status) { zmsg_t *self = zmsg_new (); int64_t signal_value = 0x7766554433221100L + status; zmsg_addmem (self, &signal_value, 8); return self; } // -------------------------------------------------------------------------- // Return signal value, 0 or greater, if message is a signal, -1 if not. int zmsg_signal (zmsg_t *self) { if (zmsg_size (self) == 1 && zmsg_content_size (self) == 8) { zframe_t *frame = zmsg_first (self); int64_t signal_value = *((int64_t *) zframe_data (frame)); if ((signal_value & 0xFFFFFFFFFFFFFF00L) == 0x7766554433221100L) return signal_value & 255; } return -1; } // -------------------------------------------------------------------------- // Probe the supplied object, and report if it looks like a zmsg_t. bool zmsg_is (void *self) { assert (self); return ((zmsg_t *) self)->tag == ZMSG_TAG; } // -------------------------------------------------------------------------- // DEPRECATED as over-engineered, poor style // Pop frame off front of message, caller now owns frame // If next frame is empty, pops and destroys that empty frame. zframe_t * zmsg_unwrap (zmsg_t *self) { assert (self); zframe_t *frame = zmsg_pop (self); zframe_t *empty = zmsg_first (self); if (empty && zframe_size (empty) == 0) { empty = zmsg_pop (self); zframe_destroy (&empty); } return frame; } // -------------------------------------------------------------------------- // DEPRECATED as poor style -- callers should use zloop or zpoller // Receive message from socket, returns zmsg_t object, or NULL either if // there was no input waiting, or the recv was interrupted. zmsg_t * zmsg_recv_nowait (void *source) { assert (source); zmsg_t *self = zmsg_new (); if (!self) return NULL; while (true) { zframe_t *frame = zframe_recv_nowait (source); if (!frame) { if (errno == EINTR && zlist_head (self->frames)) continue; else { zmsg_destroy (&self); break; // Interrupted or terminated } } #if defined (ZMQ_SERVER) // Grab routing ID if we're reading from a SERVER socket (ZMQ 4.2 and later) if (zsock_type (source) == ZMQ_SERVER) self->routing_id = zframe_routing_id (frame); #endif if (zmsg_append (self, &frame)) { zmsg_destroy (&self); break; } if (!zsock_rcvmore (source)) break; // Last message frame } return self; } // -------------------------------------------------------------------------- // DEPRECATED as unsafe -- does not nullify frame reference. // Push frame plus empty frame to front of message, before first frame. // Message takes ownership of frame, will destroy it when message is sent. void zmsg_wrap (zmsg_t *self, zframe_t *frame) { assert (self); assert (frame); if (zmsg_pushmem (self, "", 0) == 0) zmsg_push (self, frame); } // -------------------------------------------------------------------------- // DEPRECATED by zmsg_prepend (). // Push frame to the front of the message, i.e. before all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success, -1 on error. int zmsg_push (zmsg_t *self, zframe_t *frame) { assert (self); assert (frame); self->content_size += zframe_size (frame); zlist_push (self->frames, frame); return 0; } // -------------------------------------------------------------------------- // DEPRECATED by zmsg_append (). // Add frame to the end of the message, i.e. after all other frames. // Message takes ownership of frame, will destroy it when message is sent. // Returns 0 on success. int zmsg_add (zmsg_t *self, zframe_t *frame) { assert (self); assert (frame); self->content_size += zframe_size (frame); zlist_append (self->frames, frame); return 0; } // -------------------------------------------------------------------------- // DEPRECATED as inconsistent; breaks principle that logging should all go // to a single destination. // Dump message to FILE stream, for debugging and tracing. // Truncates to first 10 frames, for readability. void zmsg_fprint (zmsg_t *self, FILE *file) { assert (self); assert (zmsg_is (self)); fprintf (file, "--------------------------------------\n"); if (!self) { fprintf (file, "NULL"); return; } zframe_t *frame = zmsg_first (self); int frame_nbr = 0; while (frame && frame_nbr++ < 10) { zframe_fprint (frame, NULL, file); frame = zmsg_next (self); } } // -------------------------------------------------------------------------- // Selftest void zmsg_test (bool verbose) { printf (" * zmsg: "); int rc = 0; // @selftest // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zmsg.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zmsg.test"); assert (input); // Test send and receive of single-frame message zmsg_t *msg = zmsg_new (); assert (msg); zframe_t *frame = zframe_new ("Hello", 5); assert (frame); zmsg_prepend (msg, &frame); assert (zmsg_size (msg) == 1); assert (zmsg_content_size (msg) == 5); rc = zmsg_send (&msg, output); assert (msg == NULL); assert (rc == 0); msg = zmsg_recv (input); assert (msg); assert (zmsg_size (msg) == 1); assert (zmsg_content_size (msg) == 5); zmsg_destroy (&msg); // Test send and receive of multi-frame message msg = zmsg_new (); assert (msg); rc = zmsg_addmem (msg, "Frame0", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame1", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame2", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame3", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame4", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame5", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame6", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame7", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame8", 6); assert (rc == 0); rc = zmsg_addmem (msg, "Frame9", 6); assert (rc == 0); zmsg_t *copy = zmsg_dup (msg); assert (copy); rc = zmsg_send (©, output); assert (rc == 0); rc = zmsg_send (&msg, output); assert (rc == 0); copy = zmsg_recv (input); assert (copy); assert (zmsg_size (copy) == 10); assert (zmsg_content_size (copy) == 60); zmsg_destroy (©); msg = zmsg_recv (input); assert (msg); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); // Save to a file, read back FILE *file = fopen ("zmsg.test", "w"); assert (file); rc = zmsg_save (msg, file); assert (rc == 0); fclose (file); file = fopen ("zmsg.test", "r"); rc = zmsg_save (msg, file); assert (rc == -1); fclose (file); zmsg_destroy (&msg); file = fopen ("zmsg.test", "r"); msg = zmsg_load (file); assert (msg); fclose (file); remove ("zmsg.test"); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); // Remove all frames except first and last int frame_nbr; for (frame_nbr = 0; frame_nbr < 8; frame_nbr++) { zmsg_first (msg); frame = zmsg_next (msg); zmsg_remove (msg, frame); zframe_destroy (&frame); } // Test message frame manipulation assert (zmsg_size (msg) == 2); frame = zmsg_last (msg); assert (zframe_streq (frame, "Frame9")); assert (zmsg_content_size (msg) == 12); frame = zframe_new ("Address", 7); assert (frame); zmsg_prepend (msg, &frame); assert (zmsg_size (msg) == 3); rc = zmsg_addstr (msg, "Body"); assert (rc == 0); assert (zmsg_size (msg) == 4); frame = zmsg_pop (msg); zframe_destroy (&frame); assert (zmsg_size (msg) == 3); char *body = zmsg_popstr (msg); assert (streq (body, "Frame0")); freen (body); zmsg_destroy (&msg); // Test encoding/decoding msg = zmsg_new (); assert (msg); byte *blank = (byte *) zmalloc (100000); assert (blank); rc = zmsg_addmem (msg, blank, 0); assert (rc == 0); rc = zmsg_addmem (msg, blank, 1); assert (rc == 0); rc = zmsg_addmem (msg, blank, 253); assert (rc == 0); rc = zmsg_addmem (msg, blank, 254); assert (rc == 0); rc = zmsg_addmem (msg, blank, 255); assert (rc == 0); rc = zmsg_addmem (msg, blank, 256); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65535); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65536); assert (rc == 0); rc = zmsg_addmem (msg, blank, 65537); assert (rc == 0); freen (blank); assert (zmsg_size (msg) == 9); frame = zmsg_encode (msg); zmsg_destroy (&msg); msg = zmsg_decode (frame); assert (msg); zmsg_destroy (&msg); zframe_destroy (&frame); // Test submessages msg = zmsg_new (); assert (msg); zmsg_t *submsg = zmsg_new (); zmsg_pushstr (msg, "matr"); zmsg_pushstr (submsg, "joska"); rc = zmsg_addmsg (msg, &submsg); assert (rc == 0); assert (submsg == NULL); submsg = zmsg_popmsg (msg); assert (submsg == NULL); // string "matr" is not encoded zmsg_t, so was discarded submsg = zmsg_popmsg (msg); assert (submsg); body = zmsg_popstr (submsg); assert (streq (body, "joska")); freen (body); zmsg_destroy (&submsg); frame = zmsg_pop (msg); assert (frame == NULL); zmsg_destroy (&msg); // Test comparison of two messages msg = zmsg_new (); zmsg_addstr (msg, "One"); zmsg_addstr (msg, "Two"); zmsg_addstr (msg, "Three"); zmsg_t *msg_other = zmsg_new (); zmsg_addstr (msg_other, "One"); zmsg_addstr (msg_other, "Two"); zmsg_addstr (msg_other, "One-Hundred"); zmsg_t *msg_dup = zmsg_dup (msg); zmsg_t *empty_msg = zmsg_new (); zmsg_t *empty_msg_2 = zmsg_new (); assert (zmsg_eq (msg, msg_dup)); assert (!zmsg_eq (msg, msg_other)); assert (zmsg_eq (empty_msg, empty_msg_2)); assert (!zmsg_eq (msg, NULL)); assert (!zmsg_eq (NULL, empty_msg)); assert (!zmsg_eq (NULL, NULL)); zmsg_destroy (&msg); zmsg_destroy (&msg_other); zmsg_destroy (&msg_dup); zmsg_destroy (&empty_msg); zmsg_destroy (&empty_msg_2); // Test signal messages msg = zmsg_new_signal (0); assert (zmsg_signal (msg) == 0); zmsg_destroy (&msg); msg = zmsg_new_signal (-1); assert (zmsg_signal (msg) == 255); zmsg_destroy (&msg); // Now try methods on an empty message msg = zmsg_new (); assert (msg); assert (zmsg_size (msg) == 0); assert (zmsg_unwrap (msg) == NULL); assert (zmsg_first (msg) == NULL); assert (zmsg_last (msg) == NULL); assert (zmsg_next (msg) == NULL); assert (zmsg_pop (msg) == NULL); // Sending an empty message is valid and destroys the message assert (zmsg_send (&msg, output) == 0); assert (!msg); zsock_destroy (&input); zsock_destroy (&output); #if defined (ZMQ_SERVER) // Create server and client sockets and connect over inproc zsock_t *server = zsock_new_server ("inproc://zmsg-test-routing"); assert (server); zsock_t *client = zsock_new_client ("inproc://zmsg-test-routing"); assert (client); // Send request from client to server zmsg_t *request = zmsg_new (); assert (request); zmsg_addstr (request, "Hello"); rc = zmsg_send (&request, client); assert (rc == 0); assert (!request); // Read request and send reply request = zmsg_recv (server); assert (request); char *string = zmsg_popstr (request); assert (streq (string, "Hello")); assert (zmsg_routing_id (request)); zstr_free (&string); zmsg_t *reply = zmsg_new (); assert (reply); zmsg_addstr (reply, "World"); zmsg_set_routing_id (reply, zmsg_routing_id (request)); rc = zmsg_send (&reply, server); assert (rc == 0); zmsg_destroy (&request); // Read reply reply = zmsg_recv (client); string = zmsg_popstr (reply); assert (streq (string, "World")); assert (zmsg_routing_id (reply) == 0); zmsg_destroy (&reply); zstr_free (&string); // Client and server disallow multipart msg = zmsg_new (); zmsg_addstr (msg, "One"); zmsg_addstr (msg, "Two"); rc = zmsg_send (&msg, client); assert (rc == -1); assert (zmsg_size (msg) == 2); rc = zmsg_send (&msg, server); assert (rc == -1); assert (zmsg_size (msg) == 2); zmsg_destroy (&msg); zsock_destroy (&client); zsock_destroy (&server); #endif // Test message length calculation after removal msg = zmsg_new (); zmsg_addstr (msg, "One"); zmsg_addstr (msg, "Two"); size_t size_before = zmsg_content_size (msg); frame = zframe_new ("Three", strlen ("Three")); assert (frame); zmsg_remove (msg, frame); size_t size_after = zmsg_content_size (msg); assert (size_before == size_after); zframe_destroy (&frame); zmsg_destroy (&msg); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zdigest.c0000664000372000037200000001062613222211156015774 0ustar00travistravis00000000000000/* ========================================================================= zdigest - provides hashing functions (SHA-1 at present) Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zdigest class generates a hash from zchunks of data. The current algorithm is SHA-1, chosen for speed. We are aiming to generate a unique digest for a file, and there are no security issues in this use case. @discuss The current code depends on OpenSSL, which might be replaced by hard coded SHA-1 implementation to reduce build dependencies. @end */ #include "czmq_classes.h" #include "foreign/sha1/sha1.inc_c" // Structure of our class struct _zdigest_t { SHA_CTX context; // Digest context // Binary hash byte hash [SHA_DIGEST_LENGTH]; // ASCII representation (hex) char string [SHA_DIGEST_LENGTH * 2 + 1]; bool final; // Finished calculating }; // -------------------------------------------------------------------------- // Constructor - creates new digest object, which you use to build up a // digest by repeatedly calling zdigest_update() on chunks of data. zdigest_t * zdigest_new (void) { zdigest_t *self = (zdigest_t *) zmalloc (sizeof (zdigest_t)); assert (self); SHA1_Init (&self->context); return self; } // -------------------------------------------------------------------------- // Destroy a digest object void zdigest_destroy (zdigest_t **self_p) { assert (self_p); if (*self_p) { zdigest_t *self = *self_p; freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Add buffer into digest calculation void zdigest_update (zdigest_t *self, const byte *buffer, size_t length) { // Calling this after zdigest_data() is illegal use of the API assert (self); assert (!self->final); SHA1_Update (&self->context, buffer, length); } // -------------------------------------------------------------------------- // Return final digest hash data. If built without crypto support, returns // NULL. const byte * zdigest_data (zdigest_t *self) { assert (self); if (!self->final) { SHA1_Final (self->hash, &self->context); self->final = true; } return self->hash; } // -------------------------------------------------------------------------- // Return final digest hash size size_t zdigest_size (zdigest_t *self) { assert (self); return SHA_DIGEST_LENGTH; } // -------------------------------------------------------------------------- // Return digest as printable hex string; caller should not modify nor // free this string. After calling this, you may not use zdigest_update() // on the same digest. If built without crypto support, returns NULL. char * zdigest_string (zdigest_t *self) { assert (self); const byte *data = zdigest_data (self); char hex_char [] = "0123456789ABCDEF"; int byte_nbr; for (byte_nbr = 0; byte_nbr < SHA_DIGEST_LENGTH; byte_nbr++) { self->string [byte_nbr * 2 + 0] = hex_char [data [byte_nbr] >> 4]; self->string [byte_nbr * 2 + 1] = hex_char [data [byte_nbr] & 15]; } self->string [SHA_DIGEST_LENGTH * 2] = 0; return self->string; } // -------------------------------------------------------------------------- // Self test of this class void zdigest_test (bool verbose) { printf (" * zdigest: "); // @selftest byte *buffer = (byte *) zmalloc (1024); memset (buffer, 0xAA, 1024); zdigest_t *digest = zdigest_new (); assert (digest); zdigest_update (digest, buffer, 1024); const byte *data = zdigest_data (digest); assert (data [0] == 0xDE); assert (data [1] == 0xB2); assert (data [2] == 0x38); assert (data [3] == 0x07); assert (streq (zdigest_string (digest), "DEB23807D4FE025E900FE9A9C7D8410C3DDE9671")); zdigest_destroy (&digest); freen (buffer); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/czmq_private_selftest.c0000664000372000037200000000312313222211156020732 0ustar00travistravis00000000000000/* ========================================================================= czmq_private_selftest.c - run private classes selftests Runs all private classes selftests. ------------------------------------------------------------------------- Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ ========================================================================= */ #include "czmq_classes.h" // ------------------------------------------------------------------------- // Run all private classes tests. // void czmq_private_selftest (bool verbose) { // Tests for stable private classes: zgossip_msg_test (verbose); } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/src/zproc.c0000664000372000037200000010002213222211156015446 0ustar00travistravis00000000000000/* ========================================================================= zproc - process configuration and status Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header zproc - process configuration and status, plus unix pipes on steroids WARNING: zproc class have several limitations atm * is tested on zmq4 on Linux and OSX. * does not work on Windows, where you get empty stubs for most of the methods * does not work on libzmq3 and libzmq2. We have experienced stalls and timeouts when running tests against such old version Note: zproc is not yet stable, so there are no guarantees regarding API stability. Some methods can have weird semantics or strange API. Class zproc run an external process and to use ZeroMQ sockets to communicate with it. In other words standard input and outputs MAY be connected with appropriate zeromq socket and data flow is managed by zproc itself. This makes zproc the best in class way how to run and manage sub processes. Data are sent and received as zframes (zframe_t), so zproc does not try to interpret content of the messages in any way. See test example on how to use it. +----------------------------------------+ | /bin/cat cat /etc/passwd | | stdin | stdout | stderr | |------||--------||---------------||-----| | fd1 fd2 fd3 | | ^ v v | |zmq://stdin |zmq://stdout |zmq://stderr | | [zproc supervisor] | +----------------------------------------+ ----------> zeromq magic here <----------- +----------------------------------------+ |zmq://stdin |zmq://stdout |zmq://stderr | | | | consumer | | | | | +----------------------------------------+ @discuss @end */ #include "czmq_classes.h" // For getcwd() variants #if (defined (WIN32)) # include #else # include #endif #define ZPROC_RUNNING -42 // ####### internal helpers for zproc ####### // vvvvvvv vvvvvvv typedef struct _zpair_t zpair_t; struct _zpair_t { char *endpoint; bool write_owned; void *write; bool read_owned; void *read; }; static zpair_t* zpair_new (char* endpoint) { zpair_t *self = (zpair_t*) zmalloc (sizeof (zpair_t)); self->endpoint = endpoint; return self; } static void zpair_destroy (zpair_t **self_p) { assert (self_p); if (*self_p) { zpair_t *self = *self_p; if (self->write_owned) zsock_destroy ((zsock_t**)&self->write); if (self->read_owned) zsock_destroy ((zsock_t**)&self->read); zstr_free (&self->endpoint); freen (self); *self_p = NULL; } } static void zpair_set_read (zpair_t *self, void *sock, bool owned) { self->read = sock; self->read_owned = owned; } static void zpair_set_write (zpair_t *self, void *sock, bool owned) { self->write = sock; self->write_owned = owned; } static void * zpair_read (zpair_t *self) { return self->read; } static void * zpair_write (zpair_t *self) { return self->write; } static void zpair_mkpair (zpair_t *self) { self->endpoint[0] = '>'; self->read = zsock_new_pair (self->endpoint); self->read_owned = true; self->endpoint [0] = '@'; self->write = zsock_new_pair (self->endpoint); self->write_owned = true; self->endpoint [0] = '#'; } static void zpair_print (zpair_t *self) { assert (self); zsys_debug ("pair<%p> {.read = <%p>, .write = <%p>}", (void*) self, self->read, self->write); } static char ** arr_new (size_t len) { // we allocate one entry more, because there must be NULL at the end! char **ret = (char**) zmalloc (sizeof (char*) * (len + 1)); return ret; } static void arr_free (char **self) { assert (self); char **foo = self; while (*self) { freen (*(self++)); } freen (foo); } static void arr_add_ref (char **self, size_t i, char *s) { assert (self); self [i] = s; } static void arr_print (char**self) { assert (self); size_t i = 0; while (self [i]) { zsys_debug ("%zu:\t%s<%p>", i, self [i], (void*) *self); i += 1; } } // ^^^^^^^ ^^^^^^^ // ####### internal helpers for zproc ####### struct _zproc_t { #if ! defined (__WINDOWS__) //TODO: there is no windows port, so lets exclude pid from struct // zproc wasn't ported there, so no reason to do so pid_t pid; #endif int return_code; bool running; bool verbose; zactor_t *actor; zloop_t *loop_ref; zsock_t *pipe; // destroy actor pipe in a case of execve fail int stdinpipe [2]; // stdin pipe int stdoutpipe [2]; // stdout pipe int stderrpipe [2]; // stderr pipe zpair_t *stdinpair; // stdin socketpair zpair_t *stdoutpair; // stdout socketpair zpair_t *stderrpair; // stderr socketpair zlistx_t *args; // command line arguments zhashx_t *env; // environment }; zproc_t* zproc_new () { #if defined (__WINDOWS__) zsys_error ("zproc_set_stdin not implemented for Windows"); return NULL; #elif ZMQ_VERSION_MAJOR < 4 zsys_error ("Cannot use zproc with zmq older than 4"); return NULL; #endif int major, minor, patch; zsys_version (&major, &minor, &patch); if (major < 4) { zsys_error ("Cannot use zproc with zmq older than 4"); return NULL; } zproc_t *self = (zproc_t*) zmalloc (sizeof (zproc_t)); self->verbose = false; zuuid_t *uuid = zuuid_new (); self->stdinpair = zpair_new ( zsys_sprintf ("#inproc://zproc-%s-stdin", zuuid_str_canonical (uuid)) ); self->stdoutpair = zpair_new ( zsys_sprintf ("#inproc://zproc-%s-stdout", zuuid_str_canonical (uuid)) ); self->stderrpair = zpair_new ( zsys_sprintf ("#inproc://zproc-%s-stderr", zuuid_str_canonical (uuid)) ); zuuid_destroy (&uuid); return self; } void zproc_destroy (zproc_t **self_p) { assert (self_p); if (*self_p) { zproc_t *self = *self_p; zproc_wait (self, true); zactor_destroy (&self->actor); close (self->stdinpipe [0]); close (self->stdinpipe [1]); close (self->stdoutpipe [0]); close (self->stdoutpipe [1]); close (self->stderrpipe [0]); close (self->stderrpipe [1]); zpair_destroy (&self->stdinpair); zpair_destroy (&self->stdoutpair); zpair_destroy (&self->stderrpair); zlistx_destroy (&self->args); zhashx_destroy (&self->env); freen (self); *self_p = NULL; } } void zproc_set_args (zproc_t *self, zlistx_t *args) { assert (self); zlistx_destroy (&self->args); self->args = args; } void zproc_set_env (zproc_t *self, zhashx_t *env) { assert (self); zhashx_destroy (&self->env); self->env = env; } void zproc_set_stdin (zproc_t *self, void* socket) { assert (self); #if defined (__WINDOWS__) zsys_error ("zproc_set_stdin not implemented for Windows"); return; #else assert (self->stdinpipe [0] == 0); int r = pipe (self->stdinpipe); assert (r == 0); if (!socket) zpair_mkpair (self->stdinpair); else zpair_set_read (self->stdinpair, socket, false); #endif } void zproc_set_stdout (zproc_t *self, void* socket) { assert (self); #if defined (__WINDOWS__) zsys_error ("zproc_set_stdout not implemented for Windows"); return; #else assert (self->stdoutpipe [0] == 0); int r = pipe (self->stdoutpipe); assert (r == 0); if (!socket) zpair_mkpair (self->stdoutpair); else zpair_set_write (self->stdoutpair, socket, false); #endif } void zproc_set_stderr (zproc_t *self, void* socket) { assert (self); #if defined (__WINDOWS__) zsys_error ("zproc_set_stdout not implemented for Windows"); return; #else assert (self->stderrpipe [0] == 0); int r = pipe (self->stderrpipe); assert (r == 0); if (!socket) zpair_mkpair (self->stderrpair); else zpair_set_write (self->stderrpair, socket, false); #endif } void* zproc_stdin (zproc_t *self) { return zpair_write (self->stdinpair); } void* zproc_stdout (zproc_t *self) { return zpair_read (self->stdoutpair); } void* zproc_stderr (zproc_t *self) { return zpair_read (self->stderrpair); } int zproc_returncode (zproc_t *self) { assert (self); #if defined (__WINDOWS__) zsys_error ("zproc_returncode not implemented on Windows"); return -1; #else assert (self->pid); zproc_wait (self, false); return self->return_code; #endif } int zproc_pid (zproc_t *self) { assert (self); #if defined (__WINDOWS__) zsys_error ("zproc_pid not implemented on Windows"); return -1; #else return self->pid; #endif } static int s_fd_in_handler (zloop_t *self, zmq_pollitem_t *item, void *socket) { #define BUF_SIZE 1024 byte buf [BUF_SIZE]; ssize_t r = 1; while (r > 0) { r = read (item->fd, buf, BUF_SIZE); if (r == -1) { zsys_error ("read from fd %d: %s", item->fd, strerror (errno)); break; } else if (r == 0) break; zframe_t *frame = zframe_new (buf, r); zsock_bsend (socket, "f", frame, NULL); zframe_destroy (&frame); } return 0; #undef BUF_SIZE } static int s_fd_out_handler (zloop_t *self, zmq_pollitem_t *item, void *socket) { ssize_t r = 1; while (r > 0) { zframe_t *frame; r = zsock_brecv (socket, "f", &frame); if (r == -1) { zsys_error ("read from socket <%p>: %s", socket, strerror (errno)); break; } r = write (item->fd, zframe_data (frame), zframe_size (frame)); zframe_destroy (&frame); if (r == -1) { zsys_error ("write to fd %d: %s", item->fd, strerror (errno)); break; } } return 0; } static int s_zproc_addfd (zproc_t *self, int fd, void* socket, int flags) { assert (self); #if defined (__WINDOWS__) zsys_error ("s_zproc_addfd not implemented for Windows"); return -1; #else zmq_pollitem_t it = {NULL, fd, flags, 0}; return zloop_poller ( self->loop_ref, &it, flags == ZMQ_POLLIN ? s_fd_in_handler : s_fd_out_handler, socket); #endif } static int s_zproc_alive (zloop_t *loop, int timer_id, void *args) { zproc_t *self = (zproc_t*) args; if (zsys_interrupted) return -1; if (zproc_pid (self) && zproc_running (self)) return 0; return -1; } static int s_zproc_execve (zproc_t *self) { #if defined(__WINDOWS__) zsys_debug ("s_zproc_execve not implemented on Windows"); return -1; #else assert (self); int r; char *filename = (char*) zlistx_first (self->args); self->pid = fork (); if (self->pid == 0) { if (self->stdinpipe [0] != 0) { int o_flags = fcntl (self->stdinpipe [0], F_GETFL); int n_flags = o_flags & (~O_NONBLOCK); fcntl (self->stdinpipe [0], F_SETFL, n_flags); dup2 (self->stdinpipe [0], STDIN_FILENO); close (self->stdinpipe [1]); } // redirect stdout if set_stdout was called if (self->stdoutpipe [0] != 0) { close (self->stdoutpipe [0]); dup2 (self->stdoutpipe [1], STDOUT_FILENO); } // redirect stdout if set_stderr was called if (self->stderrpipe [0] != 0) { close (self->stderrpipe [0]); dup2 (self->stderrpipe [1], STDERR_FILENO); } // build argv for now and use self->args char **argv2 = arr_new (zlistx_size (self->args) + 1); size_t i = 0; for (char *arg = (char*) zlistx_first (self->args); arg != NULL; arg = (char*) zlistx_next (self->args)) { arr_add_ref (argv2, i, arg); i++; } arr_add_ref (argv2, i, NULL); // build environ for a new process char **env = arr_new (zhashx_size (self->env) + 1); i = 0; for (char *arg = (char*) zhashx_first (self->env); arg != NULL; arg = (char*) zhashx_next (self->env)) { char *name = (char*) zhashx_cursor (self->env); arr_add_ref (env, i, zsys_sprintf ("%s=%s", name, arg)); i++; } arr_add_ref (env, i, NULL); r = execve (filename, argv2, env); if (r == -1) { zsys_error ("fail to run %s: %s", filename, strerror (errno)); zproc_destroy (&self); zsock_destroy (&self->pipe); arr_free (argv2); exit (errno); } } else if (self->pid == -1) { zsys_error ("error fork: %s", strerror (errno)); exit (EXIT_FAILURE); } else { if (self->verbose) zsys_debug ("process %s with pid %d started", filename, self->pid); if (self->stdinpipe [0] != 0) { s_zproc_addfd (self, self->stdinpipe [1], zpair_read (self->stdinpair), ZMQ_POLLOUT); close (self->stdinpipe [0]); } // add a handler for read end of stdout if (self->stdoutpipe [1] != 0) { s_zproc_addfd (self, self->stdoutpipe [0], zpair_write (self->stdoutpair), ZMQ_POLLIN); close(self->stdoutpipe[1]); } // add a handler for read end of stderr if (self->stderrpipe [1] != 0) { s_zproc_addfd (self, self->stderrpipe [0], zpair_write (self->stderrpair), ZMQ_POLLIN); close(self->stderrpipe[1]); } } return 0; #endif } static int s_pipe_handler (zloop_t *loop, zsock_t *pipe, void *args) { zproc_t *self = (zproc_t*) args; int ret = 0; zmsg_t *msg = zmsg_recv (pipe); char *command = zmsg_popstr (msg); if (self->verbose) zsys_debug ("API command=%s", command); if (streq (command, "$TERM")) ret = -1; else if (streq (command, "RUN")) { if (zproc_pid (self) > 0) { zsys_error ("Can't run command twice!!"); goto end; } s_zproc_execve (self); } end: zstr_free(&command); zmsg_destroy (&msg); return ret; } static void s_zproc_actor (zsock_t *pipe, void *args) { zproc_t *self = (zproc_t*) args; zloop_t *loop = zloop_new (); assert (loop); self->loop_ref = loop; self->pipe = pipe; zloop_reader (loop, pipe, s_pipe_handler, (void*) self); zloop_timer (loop, 500, 0, s_zproc_alive, (void*) self); zsock_signal (pipe, 0); zloop_start (loop); zloop_destroy (&loop); zsock_signal (pipe, 0); } int zproc_run (zproc_t *self) { #if defined (__WINDOWS__) zsys_error ("zproc not yet implemented for Windows"); return -1; #endif assert (self); assert (!self->actor); if (!self->args || zlistx_size (self->args) == 0) { zsys_error ("No arguments, nothing to run. Call zproc_set_args before"); return -1; } self->actor = zactor_new (s_zproc_actor, (void*) self); self->running = true; self->return_code = ZPROC_RUNNING; zstr_send (self->actor, "RUN"); return 0; } int zproc_wait (zproc_t *self, bool wait) { #if defined (__WINDOWS__) zsys_error ("zproc not yet implemented for Windows"); return -1; #else assert (self); if (!self->pid) return 0; if (self->verbose) zsys_debug ("zproc_wait [%d]: wait=%s", self->pid, wait ? "true" : "false"); int status = -1; int options = !wait ? WNOHANG : 0; if (self->verbose) zsys_debug ("zproc_wait [%d]:\t!self->running=%s", self->pid, self->running ? "true" : "false"); if (!self->running) return self->return_code; if (self->verbose) zsys_debug ("zproc_wait [%d]:\twaitpid", self->pid); int r = waitpid (self->pid, &status, options); if (self->verbose) zsys_debug ("zproc_wait [%d]:\twaitpid, r=%d", self->pid, r); if (!wait && r == 0) return self->return_code; if (WIFEXITED(status)) { if (self->verbose) zsys_debug ("zproc_wait [%d]:\tWIFEXITED", self->pid); self->running = false; self->return_code = WEXITSTATUS(status); } else if (WIFSIGNALED(status)) { if (self->verbose) zsys_debug ("zproc_wait [%d]:\tWIFSIGNALED", self->pid); self->running = false; self->return_code = - WTERMSIG(status); /* if (WCOREDUMP(status)) { self->core_dumped = true; } */ } if (self->verbose) zsys_debug ("zproc_wait [%d]: self->return_code=%d", self->pid, self->return_code); return ZPROC_RUNNING; #endif } bool zproc_running (zproc_t *self) { assert (self); #if defined (__WINDOWS__) zsys_debug ("zproc_running not implemented on Windows"); return false; #else assert (self->pid); return zproc_wait (self, false) == ZPROC_RUNNING; #endif } void * zproc_actor (zproc_t *self) { assert (self); return self->actor; } // send a signal to the subprocess void zproc_kill (zproc_t *self, int signum) { assert (self); #if defined (__WINDOWS__) zsys_debug ("zproc_kill not implemented on Windows"); return; #else int r = kill (self->pid, signum); if (r != 0) zsys_error ("kill of pid=%d failed: %s", self->pid, strerror (errno)); zproc_wait (self, false); #endif } void zproc_set_verbose (zproc_t *self, bool verbose) { assert (self); self->verbose = verbose; } // -------------------------------------------------------------------------- // Returns CZMQ version as a single 6-digit integer encoding the major // version (x 10000), the minor version (x 100) and the patch. int zproc_czmq_version (void) { return CZMQ_VERSION; } // -------------------------------------------------------------------------- // Returns true if the process received a SIGINT or SIGTERM signal. // It is good practice to use this method to exit any infinite loop // processing messages. bool zproc_interrupted (void) { return zsys_interrupted == 1; } // -------------------------------------------------------------------------- // Returns true if the underlying libzmq supports CURVE security. bool zproc_has_curve (void) { return zsys_has_curve (); } // -------------------------------------------------------------------------- // Return current host name, for use in public tcp:// endpoints. // If the host name is not resolvable, returns NULL. The caller is // responsible for destroying the return value when finished with it. char * zproc_hostname (void) { return zsys_hostname (); } // -------------------------------------------------------------------------- // Move the current process into the background. The precise effect // depends on the operating system. On POSIX boxes, moves to a specified // working directory (if specified), closes all file handles, reopens // stdin, stdout, and stderr to the null device, and sets the process to // ignore SIGHUP. On Windows, does nothing. Returns 0 if OK, -1 if there // was an error. void zproc_daemonize (const char *workdir) { zsys_daemonize (workdir); } // -------------------------------------------------------------------------- // Drop the process ID into the lockfile, with exclusive lock, and // switch the process to the specified group and/or user. Any of the // arguments may be null, indicating a no-op. Returns 0 on success, // -1 on failure. Note if you combine this with zsys_daemonize, run // after, not before that method, or the lockfile will hold the wrong // process ID. void zproc_run_as (const char *lockfile, const char *group, const char *user) { zsys_run_as (lockfile, group, user); } // -------------------------------------------------------------------------- // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void zproc_set_io_threads (size_t io_threads) { zsys_set_io_threads (io_threads); } // -------------------------------------------------------------------------- // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void zproc_set_max_sockets (size_t max_sockets) { zsys_set_max_sockets (max_sockets); } // -------------------------------------------------------------------------- // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all available interfaces". void zproc_set_biface (const char *value) { zsys_set_interface (value); } // -------------------------------------------------------------------------- // Return network interface to use for broadcasts, or "" if none was set. const char * zproc_biface (void) { return zsys_interface (); } // -------------------------------------------------------------------------- // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void zproc_set_log_ident (const char *value) { zsys_set_logident (value); } // -------------------------------------------------------------------------- // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void zproc_set_log_sender (const char *endpoint) { zsys_set_logsender (endpoint); } // -------------------------------------------------------------------------- // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void zproc_set_log_system (bool logsystem) { zsys_set_logsystem (logsystem); } // -------------------------------------------------------------------------- // Log error condition - highest priority void zproc_log_error (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); zsys_error (string); zstr_free (&string); } // -------------------------------------------------------------------------- // Log warning condition - high priority void zproc_log_warning (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); zsys_warning (string); zstr_free (&string); } // -------------------------------------------------------------------------- // Log normal, but significant, condition - normal priority void zproc_log_notice (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); zsys_notice (string); zstr_free (&string); } // -------------------------------------------------------------------------- // Log informational message - low priority void zproc_log_info (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); zsys_info (string); zstr_free (&string); } // -------------------------------------------------------------------------- // Log debug-level message - lowest priority void zproc_log_debug (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); zsys_debug (string); zstr_free (&string); } // -------------------------------------------------------------------------- // Self test of this class. void zproc_test (bool verbose) { printf (" * zproc: "); // @selftest #if defined (__WINDOWS__) printf ("SKIPPED (on Windows)\n"); return; #endif #if ZMQ_VERSION_MAJOR < 4 printf ("SKIPPED (on zmq pre-4)\n"); return; #endif int major, minor, patch; zsys_version (&major, &minor, &patch); if (major < 4) { printf ("SKIPPED (on zmq pre-4)\n"); return; } // @selftest // 0. initialization if (verbose) { printf("\n"); } // find the right binary for current build (in-tree, distcheck, etc.) char *file = NULL; if (zsys_file_exists ("src/zsp") || zsys_file_exists ("./src/zsp")) file = "./src/zsp"; else if (zsys_file_exists ("../zsp")) // WHOA: zproc: zproc_test() : current working directory is // /home/travis/build/username/czmq/czmq-4.0.3/_build/src/selftest-rw file = "../zsp"; else if (zsys_file_exists ("_build/../src/zsp")) file = "_build/../src/zsp"; else if (zsys_file_exists ("_build/src/zsp")) file = "_build/src/zsp"; else if (zsys_file_exists ("../_build/src/zsp")) file = "../_build/src/zsp"; else if (zsys_file_exists ("../../_build/src/zsp")) file = "../../_build/src/zsp"; else if (zsys_file_exists ("_build/sub/src/zsp")) file = "_build/sub/src/zsp"; else if (zsys_file_exists ("../_build/sub/src/zsp")) file = "../_build/sub/src/zsp"; else if (zsys_file_exists ("../../_build/sub/src/zsp")) file = "../../_build/sub/src/zsp"; else if (zsys_file_exists ("zsp") || zsys_file_exists ("./zsp")) file = "./zsp"; else if (zsys_file_exists ("../src/zsp")) file = "../src/zsp"; if (file == NULL || !zsys_file_exists (file)) { zsys_warning ("cannot detect zsp binary, %s does not exist", file ? file : ""); printf ("SKIPPED (zsp helper not found)\n"); #if (defined (PATH_MAX)) char cwd[PATH_MAX]; #else # if (defined (_MAX_PATH)) char cwd[_MAX_PATH]; # else char cwd[1024]; # endif #endif memset (cwd, 0, sizeof (cwd)); #if (defined (WIN32)) if (_getcwd(cwd, sizeof(cwd)) != NULL) #else if (getcwd(cwd, sizeof(cwd)) != NULL) #endif printf ("zproc_test() : current working directory is %s\n", cwd); return; } if (verbose) { zsys_info ("zproc_test() : detected a zsp binary at %s\n", file); } // Create new subproc instance zproc_t *self = zproc_new (); zproc_set_verbose (self, verbose); assert (self); // join stdout of the process to zeromq socket // all data will be readable from zproc_stdout socket zproc_set_stdout (self, NULL); zlistx_t *args = zlistx_new (); zlistx_add_end (args, file); zlistx_add_end (args, "--stdout"); zproc_set_args (self, args); zhashx_t *env = zhashx_new (); zhashx_insert (env, "ZSP_MESSAGE", "czmq is great\n"); zproc_set_env (self, env); // execute the binary. It runs in own actor, which monitor the process and // pass data accross pipes and zeromq sockets if (verbose) zsys_debug("zproc_test() : launching helper '%s'", file ); zproc_run (self); zpoller_t *poller = zpoller_new (zproc_stdout (self), NULL); // kill the binary, it never ends, but the test must: // termination also flushes the output streams so we can // read them entirely; note that other process runs in // parallel to this thread if (verbose) zsys_debug("zproc_test() : sleeping 4000 msec to gather some output from helper"); zclock_sleep (4000); zproc_kill (self, SIGTERM); zproc_wait (self, true); // read the content from zproc_stdout - use zpoller and a loop bool stdout_read = false; int64_t zproc_timeout_msec = 10000; int64_t zproc_test_start_msec = zclock_mono(); int64_t zproc_test_elapsed_msec = 0; while (!zsys_interrupted) { void *which = zpoller_wait (poller, 800); zproc_test_elapsed_msec = zclock_mono() - zproc_test_start_msec; if (!which) { if (stdout_read) { if (verbose) zsys_debug("zproc_test() : did not get stdout from helper, but we already have some (%" PRIi64 " msec remaining to retry)", (zproc_timeout_msec - zproc_test_elapsed_msec) ); break; } if (zproc_timeout_msec > zproc_test_elapsed_msec) { if (verbose) zsys_debug("zproc_test() : did not get stdout from helper, %" PRIi64 " msec remaining to retry", (zproc_timeout_msec - zproc_test_elapsed_msec) ); continue; } // ...else : we've slept a lot and got no response; kill the helper if (verbose) zsys_debug("zproc_test() : did not get stdout from helper, patience expired (%" PRIi64 " msec remaining to retry)", (zproc_timeout_msec - zproc_test_elapsed_msec) ); break; } if (which == zproc_stdout (self)) { // it suffices for us to have read something // we only check the first frame, others may start with the // expected key string broken mid-way due to alignment etc., // but we drain the whole incoming queue of stdout frames. zframe_t *frame; zsock_brecv (zproc_stdout (self), "f", &frame); assert (frame); assert (zframe_data (frame)); if (!stdout_read) { if (verbose) zsys_debug("zproc_test() : got stdout from helper, %" PRIi64 " msec was remaining to retry", (zproc_timeout_msec - zproc_test_elapsed_msec)); assert (!strncmp( "czmq is great\n", (char*) zframe_data (frame), 14)); stdout_read = true; } if (verbose) zframe_print (frame, "zproc_test"); zframe_destroy (&frame); continue; } // should not get there if (verbose) zsys_debug("zproc_test() : reached the unreachable point (unexpected zpoller result), %" PRIi64 " msec was remaining to retry", (zproc_timeout_msec - zproc_test_elapsed_msec) ); assert (false); } assert (stdout_read); zpoller_destroy (&poller); zproc_destroy (&self); // @end // to have zpair print and arr print methods zpair_t *pair = zpair_new (strdup ("e")); assert (pair); if (verbose) zpair_print (pair); zpair_destroy (&pair); char ** a = arr_new (1); if (verbose) arr_print (a); arr_free (a); printf ("OK\n"); } czmq-4.1.0/src/zclock.c0000664000372000037200000001667413222211156015621 0ustar00travistravis00000000000000/* ========================================================================= zclock - millisecond clocks and delays Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zclock class provides essential sleep and system time functions, used to slow down threads for testing, and calculate timers for polling. Wraps the non-portable system calls in a simple portable API. @discuss The Win32 Sleep() call defaults to 16ms resolution unless the system timer resolution is increased with a call to timeBeginPeriod() permitting 1ms granularity. @end */ #include "czmq_classes.h" #if defined (__WINDOWS__) // -------------------------------------------------------------------------- // Convert FILETIME "Contains a 64-bit value representing the number of // 100-nanosecond intervals since January 1, 1601 (UTC)." static int64_t s_filetime_to_msec (const FILETIME *ft) { // As per Windows documentation for FILETIME, copy the resulting FILETIME // structure to a ULARGE_INTEGER structure using memcpy (using memcpy // instead of direct assignment can prevent alignment faults on 64-bit // Windows). ULARGE_INTEGER dateTime; memcpy (&dateTime, ft, sizeof (dateTime)); return (int64_t) (dateTime.QuadPart / 10000); } #endif // -------------------------------------------------------------------------- // Sleep for a number of milliseconds void zclock_sleep (int msecs) { #if defined (__UNIX__) struct timespec t; t.tv_sec = msecs / 1000; t.tv_nsec = (msecs % 1000) * 1000000; nanosleep (&t, NULL); #elif (defined (__WINDOWS__)) // Windows XP/2000: A value of zero causes the thread to relinquish the // remainder of its time slice to any other thread of equal priority that // is ready to run. If there are no other threads of equal priority ready // to run, the function returns immediately, and the thread continues // execution. This behavior changed starting with Windows Server 2003. # if defined (NTDDI_VERSION) && defined (NTDDI_WS03) && (NTDDI_VERSION >= NTDDI_WS03) Sleep (msecs); # else if (msecs > 0) Sleep (msecs); # endif #endif } // -------------------------------------------------------------------------- // Return current system clock as milliseconds. Note that this clock can // jump backwards (if the system clock is changed) so is unsafe to use for // timers and time offsets. Use zclock_mono for that instead. int64_t zclock_time (void) { #if defined (__UNIX__) struct timeval tv; gettimeofday (&tv, NULL); return (int64_t) ((int64_t) tv.tv_sec * 1000 + (int64_t) tv.tv_usec / 1000); #elif (defined (__WINDOWS__)) FILETIME ft; GetSystemTimeAsFileTime (&ft); return s_filetime_to_msec (&ft); #endif } // -------------------------------------------------------------------------- // Return current monotonic clock in milliseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t zclock_mono (void) { #if (defined (__UTYPE_OSX) || defined (__UTYPE_IOS)) clock_serv_t cclock; mach_timespec_t mts; host_get_clock_service (mach_host_self (), SYSTEM_CLOCK, &cclock); clock_get_time (cclock, &mts); mach_port_deallocate (mach_task_self (), cclock); return (int64_t) ((int64_t) mts.tv_sec * 1000 + (int64_t) mts.tv_nsec / 1000000); #elif defined (__UNIX__) struct timespec ts; clock_gettime (CLOCK_MONOTONIC, &ts); return (int64_t) ((int64_t) ts.tv_sec * 1000 + (int64_t) ts.tv_nsec / 1000000); #elif (defined (__WINDOWS__)) // System frequency does not change at run-time, cache it static int64_t frequency = 0; if (frequency == 0) { LARGE_INTEGER freq; QueryPerformanceFrequency (&freq); // Windows documentation says that XP and later will always return non-zero assert (freq.QuadPart != 0); frequency = freq.QuadPart; } LARGE_INTEGER count; QueryPerformanceCounter (&count); return (int64_t) (count.QuadPart * 1000) / frequency; #endif } // -------------------------------------------------------------------------- // Return current monotonic clock in microseconds. Use this when you compute // time offsets. The monotonic clock is not affected by system changes and // so will never be reset backwards, unlike a system clock. int64_t zclock_usecs (void) { #if (defined (__UTYPE_OSX) || defined (__UTYPE_IOS)) clock_serv_t cclock; mach_timespec_t mts; host_get_clock_service (mach_host_self (), SYSTEM_CLOCK, &cclock); clock_get_time (cclock, &mts); mach_port_deallocate (mach_task_self (), cclock); return (int64_t) ((int64_t) mts.tv_sec * 1000000 + (int64_t) mts.tv_nsec / 1000); #elif defined (__UNIX__) struct timespec ts; clock_gettime (CLOCK_MONOTONIC, &ts); return (int64_t) ((int64_t) ts.tv_sec * 1000000 + (int64_t) ts.tv_nsec / 1000); #elif (defined (__WINDOWS__)) // System frequency does not change at run-time, cache it static int64_t frequency = 0; if (frequency == 0) { LARGE_INTEGER freq; QueryPerformanceFrequency (&freq); // Windows documentation says that XP and later will always return non-zero assert (freq.QuadPart != 0); frequency = freq.QuadPart; } LARGE_INTEGER count; QueryPerformanceCounter (&count); return (int64_t) (count.QuadPart * 1000000) / frequency; #endif } // -------------------------------------------------------------------------- // Return formatted date/time as fresh string. Free using zstr_free(). char * zclock_timestr (void) { time_t curtime = time (NULL); struct tm *loctime = localtime (&curtime); char formatted [20]; strftime (formatted, 20, "%Y-%m-%d %H:%M:%S", loctime); return strdup (formatted); } // -------------------------------------------------------------------------- // DEPRECATED in favor of zsys logging, see issue #519 // Print formatted string to stdout, prefixed by date/time and // terminated with a newline. void zclock_log (const char *format, ...) { time_t curtime = time (NULL); struct tm *loctime = localtime (&curtime); char formatted [20]; strftime (formatted, 20, "%y-%m-%d %H:%M:%S ", loctime); printf ("%s", formatted); va_list argptr; va_start (argptr, format); vprintf (format, argptr); va_end (argptr); printf ("\n"); fflush (stdout); } // -------------------------------------------------------------------------- // Self test of this class void zclock_test (bool verbose) { printf (" * zclock: "); // @selftest int64_t start = zclock_time (); zclock_sleep (10); assert ((zclock_time () - start) >= 10); start = zclock_mono (); int64_t usecs = zclock_usecs (); zclock_sleep (10); assert ((zclock_mono () - start) >= 10); assert ((zclock_usecs () - usecs) >= 10000); char *timestr = zclock_timestr (); if (verbose) puts (timestr); freen (timestr); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zgossip_msg.c0000664000372000037200000004653413222211156016676 0ustar00travistravis00000000000000/* ========================================================================= zgossip_msg - ZeroMQ Gossip Protocol Codec class for zgossip_msg. ** WARNING ************************************************************* THIS SOURCE FILE IS 100% GENERATED. If you edit this file, you will lose your changes at the next build cycle. This is great for temporary printf statements. DO NOT MAKE ANY CHANGES YOU WISH TO KEEP. The correct places for commits are: * The XML model used for this code generation: zgossip_msg.xml, or * The code generation script that built this file: zproto_codec_c ************************************************************************ Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header zgossip_msg - ZeroMQ Gossip Protocol @discuss @end */ #include "czmq_classes.h" #include "./zgossip_msg.h" // Structure of our class struct _zgossip_msg_t { zframe_t *routing_id; // Routing_id from ROUTER, if any int id; // zgossip_msg message ID byte *needle; // Read/write pointer for serialization byte *ceiling; // Valid upper limit for read pointer char key [256]; // Tuple key, globally unique char *value; // Tuple value, as printable string uint32_t ttl; // Time to live, msecs }; // -------------------------------------------------------------------------- // Network data encoding macros // Put a block of octets to the frame #define PUT_OCTETS(host,size) { \ memcpy (self->needle, (host), size); \ self->needle += size; \ } // Get a block of octets from the frame #define GET_OCTETS(host,size) { \ if (self->needle + size > self->ceiling) { \ zsys_warning ("zgossip_msg: GET_OCTETS failed"); \ goto malformed; \ } \ memcpy ((host), self->needle, size); \ self->needle += size; \ } // Put a 1-byte number to the frame #define PUT_NUMBER1(host) { \ *(byte *) self->needle = (byte) (host); \ self->needle++; \ } // Put a 2-byte number to the frame #define PUT_NUMBER2(host) { \ self->needle [0] = (byte) (((host) >> 8) & 255); \ self->needle [1] = (byte) (((host)) & 255); \ self->needle += 2; \ } // Put a 4-byte number to the frame #define PUT_NUMBER4(host) { \ self->needle [0] = (byte) (((host) >> 24) & 255); \ self->needle [1] = (byte) (((host) >> 16) & 255); \ self->needle [2] = (byte) (((host) >> 8) & 255); \ self->needle [3] = (byte) (((host)) & 255); \ self->needle += 4; \ } // Put a 8-byte number to the frame #define PUT_NUMBER8(host) { \ self->needle [0] = (byte) (((host) >> 56) & 255); \ self->needle [1] = (byte) (((host) >> 48) & 255); \ self->needle [2] = (byte) (((host) >> 40) & 255); \ self->needle [3] = (byte) (((host) >> 32) & 255); \ self->needle [4] = (byte) (((host) >> 24) & 255); \ self->needle [5] = (byte) (((host) >> 16) & 255); \ self->needle [6] = (byte) (((host) >> 8) & 255); \ self->needle [7] = (byte) (((host)) & 255); \ self->needle += 8; \ } // Get a 1-byte number from the frame #define GET_NUMBER1(host) { \ if (self->needle + 1 > self->ceiling) { \ zsys_warning ("zgossip_msg: GET_NUMBER1 failed"); \ goto malformed; \ } \ (host) = *(byte *) self->needle; \ self->needle++; \ } // Get a 2-byte number from the frame #define GET_NUMBER2(host) { \ if (self->needle + 2 > self->ceiling) { \ zsys_warning ("zgossip_msg: GET_NUMBER2 failed"); \ goto malformed; \ } \ (host) = ((uint16_t) (self->needle [0]) << 8) \ + (uint16_t) (self->needle [1]); \ self->needle += 2; \ } // Get a 4-byte number from the frame #define GET_NUMBER4(host) { \ if (self->needle + 4 > self->ceiling) { \ zsys_warning ("zgossip_msg: GET_NUMBER4 failed"); \ goto malformed; \ } \ (host) = ((uint32_t) (self->needle [0]) << 24) \ + ((uint32_t) (self->needle [1]) << 16) \ + ((uint32_t) (self->needle [2]) << 8) \ + (uint32_t) (self->needle [3]); \ self->needle += 4; \ } // Get a 8-byte number from the frame #define GET_NUMBER8(host) { \ if (self->needle + 8 > self->ceiling) { \ zsys_warning ("zgossip_msg: GET_NUMBER8 failed"); \ goto malformed; \ } \ (host) = ((uint64_t) (self->needle [0]) << 56) \ + ((uint64_t) (self->needle [1]) << 48) \ + ((uint64_t) (self->needle [2]) << 40) \ + ((uint64_t) (self->needle [3]) << 32) \ + ((uint64_t) (self->needle [4]) << 24) \ + ((uint64_t) (self->needle [5]) << 16) \ + ((uint64_t) (self->needle [6]) << 8) \ + (uint64_t) (self->needle [7]); \ self->needle += 8; \ } // Put a string to the frame #define PUT_STRING(host) { \ size_t string_size = strlen (host); \ PUT_NUMBER1 (string_size); \ memcpy (self->needle, (host), string_size); \ self->needle += string_size; \ } // Get a string from the frame #define GET_STRING(host) { \ size_t string_size; \ GET_NUMBER1 (string_size); \ if (self->needle + string_size > (self->ceiling)) { \ zsys_warning ("zgossip_msg: GET_STRING failed"); \ goto malformed; \ } \ memcpy ((host), self->needle, string_size); \ (host) [string_size] = 0; \ self->needle += string_size; \ } // Put a long string to the frame #define PUT_LONGSTR(host) { \ size_t string_size = strlen (host); \ PUT_NUMBER4 (string_size); \ memcpy (self->needle, (host), string_size); \ self->needle += string_size; \ } // Get a long string from the frame #define GET_LONGSTR(host) { \ size_t string_size; \ GET_NUMBER4 (string_size); \ if (self->needle + string_size > (self->ceiling)) { \ zsys_warning ("zgossip_msg: GET_LONGSTR failed"); \ goto malformed; \ } \ free ((host)); \ (host) = (char *) malloc (string_size + 1); \ memcpy ((host), self->needle, string_size); \ (host) [string_size] = 0; \ self->needle += string_size; \ } // -------------------------------------------------------------------------- // Create a new zgossip_msg zgossip_msg_t * zgossip_msg_new (void) { zgossip_msg_t *self = (zgossip_msg_t *) zmalloc (sizeof (zgossip_msg_t)); return self; } // -------------------------------------------------------------------------- // Destroy the zgossip_msg void zgossip_msg_destroy (zgossip_msg_t **self_p) { assert (self_p); if (*self_p) { zgossip_msg_t *self = *self_p; // Free class properties zframe_destroy (&self->routing_id); free (self->value); // Free object itself free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Receive a zgossip_msg from the socket. Returns 0 if OK, -1 if // there was an error. Blocks if there is no message waiting. int zgossip_msg_recv (zgossip_msg_t *self, zsock_t *input) { assert (input); if (zsock_type (input) == ZMQ_ROUTER) { zframe_destroy (&self->routing_id); self->routing_id = zframe_recv (input); if (!self->routing_id || !zsock_rcvmore (input)) { zsys_warning ("zgossip_msg: no routing ID"); return -1; // Interrupted or malformed } } zmq_msg_t frame; zmq_msg_init (&frame); int size = zmq_msg_recv (&frame, zsock_resolve (input), 0); if (size == -1) { zsys_warning ("zgossip_msg: interrupted"); goto malformed; // Interrupted } // Get and check protocol signature self->needle = (byte *) zmq_msg_data (&frame); self->ceiling = self->needle + zmq_msg_size (&frame); uint16_t signature; GET_NUMBER2 (signature); if (signature != (0xAAA0 | 0)) { zsys_warning ("zgossip_msg: invalid signature"); // TODO: discard invalid messages and loop, and return // -1 only on interrupt goto malformed; // Interrupted } // Get message id and parse per message type GET_NUMBER1 (self->id); switch (self->id) { case ZGOSSIP_MSG_HELLO: { byte version; GET_NUMBER1 (version); if (version != 1) { zsys_warning ("zgossip_msg: version is invalid"); goto malformed; } } break; case ZGOSSIP_MSG_PUBLISH: { byte version; GET_NUMBER1 (version); if (version != 1) { zsys_warning ("zgossip_msg: version is invalid"); goto malformed; } } GET_STRING (self->key); GET_LONGSTR (self->value); GET_NUMBER4 (self->ttl); break; case ZGOSSIP_MSG_PING: { byte version; GET_NUMBER1 (version); if (version != 1) { zsys_warning ("zgossip_msg: version is invalid"); goto malformed; } } break; case ZGOSSIP_MSG_PONG: { byte version; GET_NUMBER1 (version); if (version != 1) { zsys_warning ("zgossip_msg: version is invalid"); goto malformed; } } break; case ZGOSSIP_MSG_INVALID: { byte version; GET_NUMBER1 (version); if (version != 1) { zsys_warning ("zgossip_msg: version is invalid"); goto malformed; } } break; default: zsys_warning ("zgossip_msg: bad message ID"); goto malformed; } // Successful return zmq_msg_close (&frame); return 0; // Error returns malformed: zsys_warning ("zgossip_msg: zgossip_msg malformed message, fail"); zmq_msg_close (&frame); return -1; // Invalid message } // -------------------------------------------------------------------------- // Send the zgossip_msg to the socket. Does not destroy it. Returns 0 if // OK, else -1. int zgossip_msg_send (zgossip_msg_t *self, zsock_t *output) { assert (self); assert (output); if (zsock_type (output) == ZMQ_ROUTER) zframe_send (&self->routing_id, output, ZFRAME_MORE + ZFRAME_REUSE); size_t frame_size = 2 + 1; // Signature and message ID switch (self->id) { case ZGOSSIP_MSG_HELLO: frame_size += 1; // version break; case ZGOSSIP_MSG_PUBLISH: frame_size += 1; // version frame_size += 1 + strlen (self->key); frame_size += 4; if (self->value) frame_size += strlen (self->value); frame_size += 4; // ttl break; case ZGOSSIP_MSG_PING: frame_size += 1; // version break; case ZGOSSIP_MSG_PONG: frame_size += 1; // version break; case ZGOSSIP_MSG_INVALID: frame_size += 1; // version break; } // Now serialize message into the frame zmq_msg_t frame; zmq_msg_init_size (&frame, frame_size); self->needle = (byte *) zmq_msg_data (&frame); PUT_NUMBER2 (0xAAA0 | 0); PUT_NUMBER1 (self->id); size_t nbr_frames = 1; // Total number of frames to send switch (self->id) { case ZGOSSIP_MSG_HELLO: PUT_NUMBER1 (1); break; case ZGOSSIP_MSG_PUBLISH: PUT_NUMBER1 (1); PUT_STRING (self->key); if (self->value) { PUT_LONGSTR (self->value); } else PUT_NUMBER4 (0); // Empty string PUT_NUMBER4 (self->ttl); break; case ZGOSSIP_MSG_PING: PUT_NUMBER1 (1); break; case ZGOSSIP_MSG_PONG: PUT_NUMBER1 (1); break; case ZGOSSIP_MSG_INVALID: PUT_NUMBER1 (1); break; } // Now send the data frame zmq_msg_send (&frame, zsock_resolve (output), --nbr_frames? ZMQ_SNDMORE: 0); return 0; } // -------------------------------------------------------------------------- // Print contents of message to stdout void zgossip_msg_print (zgossip_msg_t *self) { assert (self); switch (self->id) { case ZGOSSIP_MSG_HELLO: zsys_debug ("ZGOSSIP_MSG_HELLO:"); zsys_debug (" version=1"); break; case ZGOSSIP_MSG_PUBLISH: zsys_debug ("ZGOSSIP_MSG_PUBLISH:"); zsys_debug (" version=1"); zsys_debug (" key='%s'", self->key); if (self->value) zsys_debug (" value='%s'", self->value); else zsys_debug (" value="); zsys_debug (" ttl=%ld", (long) self->ttl); break; case ZGOSSIP_MSG_PING: zsys_debug ("ZGOSSIP_MSG_PING:"); zsys_debug (" version=1"); break; case ZGOSSIP_MSG_PONG: zsys_debug ("ZGOSSIP_MSG_PONG:"); zsys_debug (" version=1"); break; case ZGOSSIP_MSG_INVALID: zsys_debug ("ZGOSSIP_MSG_INVALID:"); zsys_debug (" version=1"); break; } } // -------------------------------------------------------------------------- // Get/set the message routing_id zframe_t * zgossip_msg_routing_id (zgossip_msg_t *self) { assert (self); return self->routing_id; } void zgossip_msg_set_routing_id (zgossip_msg_t *self, zframe_t *routing_id) { if (self->routing_id) zframe_destroy (&self->routing_id); self->routing_id = zframe_dup (routing_id); } // -------------------------------------------------------------------------- // Get/set the zgossip_msg id int zgossip_msg_id (zgossip_msg_t *self) { assert (self); return self->id; } void zgossip_msg_set_id (zgossip_msg_t *self, int id) { self->id = id; } // -------------------------------------------------------------------------- // Return a printable command string const char * zgossip_msg_command (zgossip_msg_t *self) { assert (self); switch (self->id) { case ZGOSSIP_MSG_HELLO: return ("HELLO"); break; case ZGOSSIP_MSG_PUBLISH: return ("PUBLISH"); break; case ZGOSSIP_MSG_PING: return ("PING"); break; case ZGOSSIP_MSG_PONG: return ("PONG"); break; case ZGOSSIP_MSG_INVALID: return ("INVALID"); break; } return "?"; } // -------------------------------------------------------------------------- // Get/set the key field const char * zgossip_msg_key (zgossip_msg_t *self) { assert (self); return self->key; } void zgossip_msg_set_key (zgossip_msg_t *self, const char *value) { assert (self); assert (value); if (value == self->key) return; strncpy (self->key, value, 255); self->key [255] = 0; } // -------------------------------------------------------------------------- // Get/set the value field const char * zgossip_msg_value (zgossip_msg_t *self) { assert (self); return self->value; } void zgossip_msg_set_value (zgossip_msg_t *self, const char *value) { assert (self); assert (value); free (self->value); self->value = strdup (value); } // -------------------------------------------------------------------------- // Get/set the ttl field uint32_t zgossip_msg_ttl (zgossip_msg_t *self) { assert (self); return self->ttl; } void zgossip_msg_set_ttl (zgossip_msg_t *self, uint32_t ttl) { assert (self); self->ttl = ttl; } // -------------------------------------------------------------------------- // Selftest void zgossip_msg_test (bool verbose) { printf (" * zgossip_msg: "); if (verbose) printf ("\n"); // @selftest // Simple create/destroy test zgossip_msg_t *self = zgossip_msg_new (); assert (self); zgossip_msg_destroy (&self); // Create pair of sockets we can send through // We must bind before connect if we wish to remain compatible with ZeroMQ < v4 zsock_t *output = zsock_new (ZMQ_DEALER); assert (output); int rc = zsock_bind (output, "inproc://selftest-zgossip_msg"); assert (rc == 0); zsock_t *input = zsock_new (ZMQ_ROUTER); assert (input); rc = zsock_connect (input, "inproc://selftest-zgossip_msg"); assert (rc == 0); // Encode/send/decode and verify each message type int instance; self = zgossip_msg_new (); zgossip_msg_set_id (self, ZGOSSIP_MSG_HELLO); // Send twice zgossip_msg_send (self, output); zgossip_msg_send (self, output); for (instance = 0; instance < 2; instance++) { zgossip_msg_recv (self, input); assert (zgossip_msg_routing_id (self)); } zgossip_msg_set_id (self, ZGOSSIP_MSG_PUBLISH); zgossip_msg_set_key (self, "Life is short but Now lasts for ever"); zgossip_msg_set_value (self, "Life is short but Now lasts for ever"); zgossip_msg_set_ttl (self, 123); // Send twice zgossip_msg_send (self, output); zgossip_msg_send (self, output); for (instance = 0; instance < 2; instance++) { zgossip_msg_recv (self, input); assert (zgossip_msg_routing_id (self)); assert (streq (zgossip_msg_key (self), "Life is short but Now lasts for ever")); assert (streq (zgossip_msg_value (self), "Life is short but Now lasts for ever")); assert (zgossip_msg_ttl (self) == 123); } zgossip_msg_set_id (self, ZGOSSIP_MSG_PING); // Send twice zgossip_msg_send (self, output); zgossip_msg_send (self, output); for (instance = 0; instance < 2; instance++) { zgossip_msg_recv (self, input); assert (zgossip_msg_routing_id (self)); } zgossip_msg_set_id (self, ZGOSSIP_MSG_PONG); // Send twice zgossip_msg_send (self, output); zgossip_msg_send (self, output); for (instance = 0; instance < 2; instance++) { zgossip_msg_recv (self, input); assert (zgossip_msg_routing_id (self)); } zgossip_msg_set_id (self, ZGOSSIP_MSG_INVALID); // Send twice zgossip_msg_send (self, output); zgossip_msg_send (self, output); for (instance = 0; instance < 2; instance++) { zgossip_msg_recv (self, input); assert (zgossip_msg_routing_id (self)); } zgossip_msg_destroy (&self); zsock_destroy (&input); zsock_destroy (&output); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zcert.c0000664000372000037200000004112413222211156015447 0ustar00travistravis00000000000000/* ========================================================================= zcert - work with CURVE security certificates Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zcert class provides a way to create and work with security certificates for the ZMQ CURVE mechanism. A certificate contains a public + secret key pair, plus metadata. It can be used as a temporary object in memory, or persisted to disk. On disk, a certificate is stored as two files. One is public and contains only the public key. The second is secret and contains both keys. The two have the same filename, with the secret file adding "_secret". To exchange certificates, send the public file via some secure route. Certificates are not signed but are text files that can be verified by eye. @discuss Certificates are stored in the ZPL (ZMQ RFC 4) format. They have two sections, "metadata" and "curve". The first contains a list of 'name = value' pairs, one per line. Values may be enclosed in quotes. The curve section has a 'public-key = keyvalue' and, for secret certificates, a 'secret-key = keyvalue' line. The keyvalue is a Z85-encoded CURVE key. @end */ #include "czmq_classes.h" // Structure of our class struct _zcert_t { byte public_key [32]; // Public key in binary byte secret_key [32]; // Secret key in binary char public_txt [41]; // Public key in Z85 text char secret_txt [41]; // Secret key in Z85 text zhash_t *metadata; // Certificate metadata zconfig_t *config; // Config tree to save }; // This is a null key, when curve is not available #define FORTY_ZEROES "0000000000000000000000000000000000000000" // -------------------------------------------------------------------------- // Constructor zcert_t * zcert_new (void) { byte public_key [32] = { 0 }; byte secret_key [32] = { 0 }; #if (ZMQ_VERSION_MAJOR == 4) if (zsys_has_curve ()) { char public_txt [41]; char secret_txt [41]; int rc = zmq_curve_keypair (public_txt, secret_txt); if (rc != 0) return NULL; zmq_z85_decode (public_key, public_txt); zmq_z85_decode (secret_key, secret_txt); } #endif return zcert_new_from (public_key, secret_key); } // -------------------------------------------------------------------------- // Constructor, accepts public/secret key pair from caller zcert_t * zcert_new_from (const byte *public_key, const byte *secret_key) { zcert_t *self = (zcert_t *) zmalloc (sizeof (zcert_t)); assert (self); assert (public_key); assert (secret_key); self->metadata = zhash_new (); assert (self->metadata); zhash_autofree (self->metadata); memcpy (self->public_key, public_key, 32); memcpy (self->secret_key, secret_key, 32); #if (ZMQ_VERSION_MAJOR == 4) zmq_z85_encode (self->public_txt, self->public_key, 32); zmq_z85_encode (self->secret_txt, self->secret_key, 32); #else strcpy (self->public_txt, FORTY_ZEROES); strcpy (self->secret_txt, FORTY_ZEROES); #endif return self; } // -------------------------------------------------------------------------- // Constructor, accepts public/secret text key pair from caller zcert_t * zcert_new_from_txt (const char *public_txt, const char *secret_txt) { zcert_t *self = (zcert_t *) zmalloc (sizeof (zcert_t)); assert (self); assert (public_txt); assert (secret_txt); self->metadata = zhash_new (); assert (self->metadata); zhash_autofree (self->metadata); memcpy (self->public_txt, public_txt, 41); memcpy (self->secret_txt, secret_txt, 41); #if (ZMQ_VERSION_MAJOR == 4) zmq_z85_decode (self->public_key, self->public_txt); zmq_z85_decode (self->secret_key, self->secret_txt); #else strcpy (self->public_txt, FORTY_ZEROES); strcpy (self->secret_txt, FORTY_ZEROES); #endif return self; } // -------------------------------------------------------------------------- // Destructor void zcert_destroy (zcert_t **self_p) { assert (self_p); if (*self_p) { zcert_t *self = *self_p; zhash_destroy (&self->metadata); zconfig_destroy (&self->config); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Return public part of key pair as 32-byte binary string const byte * zcert_public_key (zcert_t *self) { assert (self); return self->public_key; } // -------------------------------------------------------------------------- // Return secret part of key pair as 32-byte binary string const byte * zcert_secret_key (zcert_t *self) { assert (self); return self->secret_key; } // -------------------------------------------------------------------------- // Return public part of key pair as Z85 armored string const char * zcert_public_txt (zcert_t *self) { assert (self); return self->public_txt; } // -------------------------------------------------------------------------- // Return secret part of key pair as Z85 armored string const char * zcert_secret_txt (zcert_t *self) { assert (self); return self->secret_txt; } // -------------------------------------------------------------------------- // Set certificate metadata from formatted string. void zcert_set_meta (zcert_t *self, const char *name, const char *format, ...) { assert (self); assert (name); assert (format); va_list argptr; va_start (argptr, format); char *value = zsys_vprintf (format, argptr); va_end (argptr); assert (value); zhash_insert (self->metadata, name, value); zstr_free (&value); } // -------------------------------------------------------------------------- // Unset certificate metadata. void zcert_unset_meta (zcert_t *self, const char *name) { assert (self); assert (name); zhash_delete (self->metadata, name); } // -------------------------------------------------------------------------- // Get metadata value from certificate; if the metadata value doesn't // exist, returns NULL. const char * zcert_meta (zcert_t *self, const char *name) { assert (self); return (char *) zhash_lookup (self->metadata, name); } // -------------------------------------------------------------------------- // Get list of metadata fields from certificate. Caller is responsible for // destroying list. Caller should not modify the values of list items. zlist_t * zcert_meta_keys (zcert_t *self) { assert (self); return zhash_keys (self->metadata); } // -------------------------------------------------------------------------- // Load certificate from file (constructor) zcert_t * zcert_load (const char *filename) { assert (filename); // Try first to load secret certificate, which has both keys // Then fallback to loading public certificate char filename_secret [256]; snprintf (filename_secret, 256, "%s_secret", filename); zconfig_t *root = zconfig_load (filename_secret); if (!root) root = zconfig_load (filename); zcert_t *self = NULL; if (root) { char *public_text = zconfig_get (root, "/curve/public-key", NULL); if (public_text && strlen (public_text) == 40) { byte public_key [32] = { 0 }; byte secret_key [32] = { 0 }; #if (ZMQ_VERSION_MAJOR == 4) char *secret_text = zconfig_get (root, "/curve/secret-key", NULL); zmq_z85_decode (public_key, public_text); if (secret_text && strlen (secret_text) == 40) zmq_z85_decode (secret_key, secret_text); #endif // Load metadata into certificate self = zcert_new_from (public_key, secret_key); zconfig_t *metadata = zconfig_locate (root, "/metadata"); zconfig_t *item = metadata? zconfig_child (metadata): NULL; while (item) { zcert_set_meta (self, zconfig_name (item), "%s", zconfig_value (item)); item = zconfig_next (item); } } } zconfig_destroy (&root); return self; } // -------------------------------------------------------------------------- // Save full certificate (public + secret) to file for persistent storage // This creates one public file and one secret file (filename + "_secret"). static void s_save_metadata_all (zcert_t *self) { zconfig_destroy (&self->config); self->config = zconfig_new ("root", NULL); assert (self->config); zconfig_t *section = zconfig_new ("metadata", self->config); char *value = (char *) zhash_first (self->metadata); while (value) { zconfig_t *item = zconfig_new (zhash_cursor (self->metadata), section); assert (item); zconfig_set_value (item, "%s", value); value = (char *) zhash_next (self->metadata); } char *timestr = zclock_timestr (); zconfig_set_comment (self->config, " **** Generated on %s by CZMQ ****", timestr); zstr_free (×tr); } int zcert_save (zcert_t *self, const char *filename) { assert (self); assert (filename); // Save public certificate using specified filename int rc = zcert_save_public (self, filename); if (rc == -1) return rc; // Now save secret certificate using filename with "_secret" suffix char filename_secret [256]; snprintf (filename_secret, 256, "%s_secret", filename); rc = zcert_save_secret (self, filename_secret); return rc; } // -------------------------------------------------------------------------- // Save public certificate only to file for persistent storage. int zcert_save_public (zcert_t *self, const char *filename) { assert (self); assert (filename); s_save_metadata_all (self); zconfig_set_comment (self->config, " ZeroMQ CURVE Public Certificate"); zconfig_set_comment (self->config, " Exchange securely, or use a secure mechanism to verify the contents"); zconfig_set_comment (self->config, " of this file after exchange. Store public certificates in your home"); zconfig_set_comment (self->config, " directory, in the .curve subdirectory."); zconfig_put (self->config, "/curve/public-key", self->public_txt); return zconfig_save (self->config, filename);; } // -------------------------------------------------------------------------- // Save public certificate only to file for persistent storage. int zcert_save_secret (zcert_t *self, const char *filename) { assert (self); assert (filename); s_save_metadata_all (self); zconfig_set_comment (self->config, " ZeroMQ CURVE **Secret** Certificate"); zconfig_set_comment (self->config, " DO NOT PROVIDE THIS FILE TO OTHER USERS nor change its permissions."); zconfig_put (self->config, "/curve/public-key", self->public_txt); zconfig_put (self->config, "/curve/secret-key", self->secret_txt); zsys_file_mode_private (); int rc = zconfig_save (self->config, filename); zsys_file_mode_default (); return rc; } // -------------------------------------------------------------------------- // Apply certificate to socket, i.e. use for CURVE security on socket. // If certificate was loaded from public file, the secret key will be // undefined, and this certificate will not work successfully. void zcert_apply (zcert_t *self, void *socket) { assert (self); #if (ZMQ_VERSION_MAJOR == 4) void *handle = zsock_resolve (socket); if (zsys_has_curve ()) { zsock_set_curve_secretkey_bin (handle, self->secret_key); zsock_set_curve_publickey_bin (handle, self->public_key); } #endif } // -------------------------------------------------------------------------- // Return copy of certificate; if certificate is null or we exhausted // heap memory, returns null. zcert_t * zcert_dup (zcert_t *self) { if (self) { zcert_t *copy = zcert_new_from (self->public_key, self->secret_key); if (copy) { zhash_destroy (©->metadata); copy->metadata = zhash_dup (self->metadata); if (!copy->metadata) zcert_destroy (©); } return copy; } else return NULL; } // -------------------------------------------------------------------------- // Return true if two certificates have the same keys bool zcert_eq (zcert_t *self, zcert_t *compare) { assert (self); assert (compare); return (streq (self->public_txt, compare->public_txt) && streq (self->secret_txt, compare->secret_txt)); } // -------------------------------------------------------------------------- // Print certificate contents to stdout void zcert_print (zcert_t *self) { assert (self); zsys_info ("zcert: metadata"); char *value = (char *) zhash_first (self->metadata); while (value) { zsys_info ("zcert: %s = \"%s\"", zhash_cursor (self->metadata), value); value = (char *) zhash_next (self->metadata); } zsys_info ("zcert: curve"); zsys_info ("zcert: public-key = \"%s\"", self->public_txt); zsys_info ("zcert: secret-key = \"%s\"", self->secret_txt); } // -------------------------------------------------------------------------- // Selftest void zcert_test (bool verbose) { printf (" * zcert: "); // @selftest const char *SELFTEST_DIR_RW = "src/selftest-rw"; const char *testbasedir = ".test_zcert"; const char *testfile = "mycert.txt"; char *basedirpath = NULL; // subdir in a test, under SELFTEST_DIR_RW char *filepath = NULL; // pathname to testfile in a test, in dirpath char *filepath_s = NULL; // pathname to testfile+secret in a test, in dirpath basedirpath = zsys_sprintf ("%s/%s", SELFTEST_DIR_RW, testbasedir); assert (basedirpath); filepath = zsys_sprintf ("%s/%s", basedirpath, testfile); assert (filepath); filepath_s = zsys_sprintf ("%s_secret", filepath); assert (filepath_s); // Make sure old aborted tests do not hinder us zdir_t *dir = zdir_new (basedirpath, NULL); if (dir) { zdir_remove (dir, true); zdir_destroy (&dir); } zsys_file_delete (filepath); zsys_dir_delete (basedirpath); // Create temporary directory for test files zsys_dir_create (basedirpath); // Create a simple certificate with metadata zcert_t *cert = zcert_new (); assert (cert); zcert_set_meta (cert, "email", "ph@imatix.com"); zcert_set_meta (cert, "name", "Pieter Hintjens"); zcert_set_meta (cert, "organization", "iMatix Corporation"); zcert_set_meta (cert, "version", "%d", 1); zcert_set_meta (cert, "delete_me", "now"); zcert_unset_meta (cert, "delete_me"); assert (streq (zcert_meta (cert, "email"), "ph@imatix.com")); zlist_t *keys = zcert_meta_keys (cert); assert (zlist_size (keys) == 4); zlist_destroy (&keys); // Check the dup and eq methods zcert_t *shadow = zcert_dup (cert); assert (zcert_eq (cert, shadow)); zcert_destroy (&shadow); // Check we can save and load certificate zcert_save (cert, filepath); assert (zsys_file_exists (filepath)); assert (zsys_file_exists (filepath_s)); // Load certificate, will in fact load secret one shadow = zcert_load (filepath); assert (shadow); assert (zcert_eq (cert, shadow)); zcert_destroy (&shadow); // Delete secret certificate, load public one int rc = zsys_file_delete (filepath_s); assert (rc == 0); shadow = zcert_load (filepath); // 32-byte null key encodes as 40 '0' characters assert (streq (zcert_secret_txt (shadow), FORTY_ZEROES)); #ifdef CZMQ_BUILD_DRAFT_API // test zcert_from_txt zcert_t *cert2 = zcert_new_from_txt(cert->public_txt, cert->secret_txt); assert (cert2); assert (zcert_eq (cert, cert2)); zcert_destroy(&cert2); #endif zcert_destroy (&shadow); zcert_destroy (&cert); // Delete all test files dir = zdir_new (basedirpath, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); zstr_free (&basedirpath); zstr_free (&filepath); zstr_free (&filepath_s); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zsys.c0000664000372000037200000021354713222211156015342 0ustar00travistravis00000000000000/* ========================================================================= zsys - system-level methods Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zsys class provides a portable wrapper for system calls. We collect them here to reduce the number of weird #ifdefs in other classes. As far as possible, the bulk of CZMQ classes are fully portable. @discuss @end */ #include "czmq_classes.h" // For getcwd() variants #if (defined (WIN32)) # include #else # include #endif // -------------------------------------------------------------------------- // Signal handling // These are global variables accessible to CZMQ application code volatile int zsys_interrupted = 0; // Current name volatile int zctx_interrupted = 0; // Deprecated name static void s_signal_handler (int signal_value); // We use these variables for signal handling static bool s_first_time = true; static bool handle_signals = true; #if defined (__UNIX__) static struct sigaction sigint_default; static struct sigaction sigterm_default; #elif defined (__WINDOWS__) static zsys_handler_fn *installed_handler_fn; static BOOL WINAPI s_handler_fn_shim (DWORD ctrltype) { // Return TRUE for events that we handle if (ctrltype == CTRL_C_EVENT && installed_handler_fn != NULL) { installed_handler_fn (ctrltype); return TRUE; } if (ctrltype == CTRL_CLOSE_EVENT && installed_handler_fn != NULL) { installed_handler_fn (ctrltype); return TRUE; } return FALSE; } #endif // -------------------------------------------------------------------------- // Global context handling // ZeroMQ context for this process static void *s_process_ctx = NULL; static bool s_initialized = false; #ifndef S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC // This is a private tunable that is likely to be replaced or tweaked later // per comment block at s_zsys_file_stable() implementation, to reflect // the best stat data granularity available on host OS *and* used by czmq. #define S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC 5000 #endif // Default globals for new sockets and other joys; these can all be set // from the environment, or via the zsys_set_xxx API. static size_t s_io_threads = 1; // ZSYS_IO_THREADS=1 static int s_thread_sched_policy = -1; // ZSYS_THREAD_SCHED_POLICY=-1 static int s_thread_priority = -1; // ZSYS_THREAD_PRIORITY=-1 static size_t s_max_sockets = 1024; // ZSYS_MAX_SOCKETS=1024 static int s_max_msgsz = INT_MAX; // ZSYS_MAX_MSGSZ=INT_MAX static int64_t s_file_stable_age_msec = S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC; // ZSYS_FILE_STABLE_AGE_MSEC=5000 static size_t s_linger = 0; // ZSYS_LINGER=0 static size_t s_sndhwm = 1000; // ZSYS_SNDHWM=1000 static size_t s_rcvhwm = 1000; // ZSYS_RCVHWM=1000 static size_t s_pipehwm = 1000; // ZSYS_PIPEHWM=1000 static int s_ipv6 = 0; // ZSYS_IPV6=0 static char *s_interface = NULL; // ZSYS_INTERFACE= static char *s_ipv6_address = NULL; // ZSYS_IPV6_ADDRESS= static char *s_ipv6_mcast_address = NULL; // ZSYS_IPV6_MCAST_ADDRESS= static int s_auto_use_fd = 0; // ZSYS_AUTO_USE_FD=0 static char *s_logident = NULL; // ZSYS_LOGIDENT= static FILE *s_logstream = NULL; // ZSYS_LOGSTREAM=stdout/stderr static bool s_logsystem = false; // ZSYS_LOGSYSTEM=true/false static zsock_t *s_logsender = NULL; // ZSYS_LOGSENDER= // Track number of open sockets so we can zmq_term() safely static size_t s_open_sockets = 0; // We keep a list of open sockets to report leaks to developers static zlist_t *s_sockref_list = NULL; // This defines a single zsock_new() caller instance typedef struct { void *handle; int type; const char *filename; size_t line_nbr; } s_sockref_t; // Mutex macros #if defined (__UNIX__) typedef pthread_mutex_t zsys_mutex_t; # define ZMUTEX_INIT(m) pthread_mutex_init (&m, NULL); # define ZMUTEX_LOCK(m) pthread_mutex_lock (&m); # define ZMUTEX_UNLOCK(m) pthread_mutex_unlock (&m); # define ZMUTEX_DESTROY(m) pthread_mutex_destroy (&m); #elif defined (__WINDOWS__) typedef CRITICAL_SECTION zsys_mutex_t; # define ZMUTEX_INIT(m) InitializeCriticalSection (&m); # define ZMUTEX_LOCK(m) EnterCriticalSection (&m); # define ZMUTEX_UNLOCK(m) LeaveCriticalSection (&m); # define ZMUTEX_DESTROY(m) DeleteCriticalSection (&m); #endif // Mutex to guard socket counter static zsys_mutex_t s_mutex; // -------------------------------------------------------------------------- // Initialize CZMQ zsys layer; this happens automatically when you create // a socket or an actor; however this call lets you force initialization // earlier, so e.g. logging is properly set-up before you start working. // Not threadsafe, so call only from main thread. Safe to call multiple // times. Returns global CZMQ context. void * zsys_init (void) { if (s_initialized) { assert (s_process_ctx); return s_process_ctx; } // Pull process defaults from environment if (getenv ("ZSYS_IO_THREADS")) s_io_threads = atoi (getenv ("ZSYS_IO_THREADS")); if (getenv ("ZSYS_MAX_SOCKETS")) s_max_sockets = atoi (getenv ("ZSYS_MAX_SOCKETS")); if (getenv ("ZSYS_MAX_MSGSZ")) s_max_msgsz = atoi (getenv ("ZSYS_MAX_MSGSZ")); if (getenv ("ZSYS_FILE_STABLE_AGE_MSEC")) s_file_stable_age_msec = atoi (getenv ("ZSYS_FILE_STABLE_AGE_MSEC")); if (getenv ("ZSYS_LINGER")) s_linger = atoi (getenv ("ZSYS_LINGER")); if (getenv ("ZSYS_SNDHWM")) s_sndhwm = atoi (getenv ("ZSYS_SNDHWM")); if (getenv ("ZSYS_RCVHWM")) s_rcvhwm = atoi (getenv ("ZSYS_RCVHWM")); if (getenv ("ZSYS_PIPEHWM")) s_pipehwm = atoi (getenv ("ZSYS_PIPEHWM")); if (getenv ("ZSYS_IPV6")) s_ipv6 = atoi (getenv ("ZSYS_IPV6")); if (getenv ("ZSYS_LOGSTREAM")) { if (streq (getenv ("ZSYS_LOGSTREAM"), "stdout")) s_logstream = stdout; else if (streq (getenv ("ZSYS_LOGSTREAM"), "stderr")) s_logstream = stderr; } else s_logstream = stdout; if (getenv ("ZSYS_LOGSYSTEM")) { if (streq (getenv ("ZSYS_LOGSYSTEM"), "true")) s_logsystem = true; else if (streq (getenv ("ZSYS_LOGSYSTEM"), "false")) s_logsystem = false; } if (getenv ("ZSYS_AUTO_USE_FD")) s_auto_use_fd = atoi (getenv ("ZSYS_AUTO_USE_FD")); zsys_catch_interrupts (); ZMUTEX_INIT (s_mutex); s_sockref_list = zlist_new (); if (!s_sockref_list) { zsys_shutdown (); return NULL; } srandom ((unsigned) time (NULL)); atexit (zsys_shutdown); assert (!s_process_ctx); // We use zmq_init/zmq_term to keep compatibility back to ZMQ v2 s_process_ctx = zmq_init ((int) s_io_threads); #if defined (ZMQ_MAX_SOCKETS) zmq_ctx_set (s_process_ctx, ZMQ_MAX_SOCKETS, (int) s_max_sockets); #endif s_initialized = true; // The following functions call zsys_init(), so they MUST be called after // s_initialized is set in order to avoid an infinite recursion if (getenv ("ZSYS_INTERFACE")) zsys_set_interface (getenv ("ZSYS_INTERFACE")); if (getenv ("ZSYS_IPV6_ADDRESS")) zsys_set_ipv6_address (getenv ("ZSYS_IPV6_ADDRESS")); if (getenv ("ZSYS_IPV6_MCAST_ADDRESS")) zsys_set_ipv6_mcast_address (getenv ("ZSYS_IPV6_MCAST_ADDRESS")); else zsys_set_ipv6_mcast_address ("ff02:0:0:0:0:0:0:1"); if (getenv ("ZSYS_LOGIDENT")) zsys_set_logident (getenv ("ZSYS_LOGIDENT")); if (getenv ("ZSYS_LOGSENDER")) zsys_set_logsender (getenv ("ZSYS_LOGSENDER")); zsys_set_max_msgsz (s_max_msgsz); zsys_set_file_stable_age_msec (s_file_stable_age_msec); if (getenv ("ZSYS_THREAD_PRIORITY")) zsys_set_thread_priority (atoi (getenv ("ZSYS_THREAD_PRIORITY"))); else zsys_set_thread_priority (s_thread_priority); if (getenv ("ZSYS_THREAD_SCHED_POLICY")) zsys_set_thread_sched_policy (atoi (getenv ("ZSYS_THREAD_SCHED_POLICY"))); else zsys_set_thread_sched_policy (s_thread_sched_policy); return s_process_ctx; } // atexit or manual termination for the process void zsys_shutdown (void) { if (!s_initialized) return; s_initialized = false; // The atexit handler is called when the main function exits; // however we may have zactor threads shutting down and still // trying to close their sockets. So if we suspect there are // actors busy (s_open_sockets > 0), then we sleep for a few // hundred milliseconds to allow the actors, if any, to get in // and close their sockets. ZMUTEX_LOCK (s_mutex); size_t busy = s_open_sockets; ZMUTEX_UNLOCK (s_mutex); if (busy) zclock_sleep (200); // Close logsender socket if opened (don't do this in critical section) if (s_logsender) zsock_destroy (&s_logsender); // No matter, we are now going to shut down // Print the source reference for any sockets the app did not // destroy properly. ZMUTEX_LOCK (s_mutex); s_sockref_t *sockref = (s_sockref_t *) zlist_pop (s_sockref_list); while (sockref) { assert (sockref->filename); zsys_error ("[%d]dangling '%s' socket created at %s:%d", getpid (), zsys_sockname (sockref->type), sockref->filename, (int) sockref->line_nbr); zmq_close (sockref->handle); freen (sockref); sockref = (s_sockref_t *) zlist_pop (s_sockref_list); --s_open_sockets; } zlist_destroy (&s_sockref_list); ZMUTEX_UNLOCK (s_mutex); if (s_open_sockets == 0) { zmq_term(s_process_ctx); s_process_ctx = NULL; s_io_threads = 1; s_thread_sched_policy = -1; s_thread_priority = -1; s_max_sockets = 1024; s_max_msgsz = INT_MAX; s_file_stable_age_msec = S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC; s_linger = 0; s_sndhwm = 1000; s_rcvhwm = 1000; s_pipehwm = 1000; s_ipv6 = 0; s_auto_use_fd = 0; s_logstream = NULL; s_logsystem = false; } else zsys_error ("dangling sockets: cannot terminate ZMQ safely"); ZMUTEX_DESTROY (s_mutex); // Free dynamically allocated properties freen (s_interface); freen (s_ipv6_address); freen (s_ipv6_mcast_address); freen (s_logident); zsys_interrupted = 0; zctx_interrupted = 0; zsys_handler_reset (); #if defined (__UNIX__) closelog (); // Just to be pedantic #endif } // -------------------------------------------------------------------------- // Get a new ZMQ socket, automagically creating a ZMQ context if this is // the first time. Caller is responsible for destroying the ZMQ socket // before process exits, to avoid a ZMQ deadlock. Note: you should not use // this method in CZMQ apps, use zsock_new() instead. This is for system // use only, really. void * zsys_socket (int type, const char *filename, size_t line_nbr) { // First time initialization; if the application is mixing // its own threading calls with zsock, this may fail if two // threads try to create sockets at the same time. In such // apps, they MUST create a socket in the main program before // starting any threads. If the app uses zactor for its threads // then we can guarantee this to always be safe. zsys_init (); ZMUTEX_LOCK (s_mutex); void *handle = zmq_socket (s_process_ctx, type); if (handle) { // Configure socket with process defaults zsock_set_linger (handle, (int) s_linger); #if (ZMQ_VERSION_MAJOR == 2) // TODO: v2/v3 socket api in zsock_option.inc are not public (not // added to include/zsock.h) so we have to use zmq_setsockopt directly // This should be fixed and zsock_set_hwm should be used instead # if defined (ZMQ_HWM) uint64_t value = s_sndhwm; int rc = zmq_setsockopt (handle, ZMQ_HWM, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif #else // For later versions we use separate SNDHWM and RCVHWM zsock_set_sndhwm (handle, (int) s_sndhwm); zsock_set_rcvhwm (handle, (int) s_rcvhwm); # if defined (ZMQ_IPV6) zsock_set_ipv6 (handle, s_ipv6); # else zsock_set_ipv4only (handle, s_ipv6? 0: 1); # endif #endif // Add socket to reference tracker so we can report leaks; this is // done only when the caller passes a filename/line_nbr if (filename) { s_sockref_t *sockref = (s_sockref_t *) zmalloc (sizeof (s_sockref_t)); if (sockref) { sockref->handle = handle; sockref->type = type; sockref->filename = filename; sockref->line_nbr = line_nbr; zlist_append (s_sockref_list, sockref); } else { zmq_close (handle); ZMUTEX_UNLOCK (s_mutex); return NULL; } } s_open_sockets++; } ZMUTEX_UNLOCK (s_mutex); return handle; } // -------------------------------------------------------------------------- // Destroy/close a ZMQ socket. You should call this for every socket you // create using zsys_socket(). int zsys_close (void *handle, const char *filename, size_t line_nbr) { ZMUTEX_LOCK (s_mutex); // It's possible atexit() has already happened if we're running under // a debugger that redirects the main thread exit. if (s_sockref_list) { s_sockref_t *sockref = (s_sockref_t *) zlist_first (s_sockref_list); while (sockref) { if (sockref->handle == handle) { zlist_remove (s_sockref_list, sockref); freen (sockref); break; } sockref = (s_sockref_t *) zlist_next (s_sockref_list); } } s_open_sockets--; zmq_close (handle); ZMUTEX_UNLOCK (s_mutex); return 0; } // -------------------------------------------------------------------------- // Return ZMQ socket name for socket type char * zsys_sockname (int socktype) { char *type_names [] = { "PAIR", "PUB", "SUB", "REQ", "REP", "DEALER", "ROUTER", "PULL", "PUSH", "XPUB", "XSUB", "STREAM", "SERVER", "CLIENT", "RADIO", "DISH", "SCATTER", "GATHER" }; // This array matches ZMQ_XXX type definitions assert (ZMQ_PAIR == 0); #if defined (ZMQ_SCATTER) assert (socktype >= 0 && socktype <= ZMQ_SCATTER); #elif defined (ZMQ_DISH) assert (socktype >= 0 && socktype <= ZMQ_DISH); #elif defined (ZMQ_CLIENT) assert (socktype >= 0 && socktype <= ZMQ_CLIENT); #elif defined (ZMQ_STREAM) assert (socktype >= 0 && socktype <= ZMQ_STREAM); #else assert (socktype >= 0 && socktype <= ZMQ_XSUB); #endif return type_names [socktype]; } // -------------------------------------------------------------------------- // Create a pipe, which consists of two PAIR sockets connected over inproc. // The pipe is configured to use the zsys_pipehwm setting. Returns the // frontend socket successful, NULL if failed. zsock_t * zsys_create_pipe (zsock_t **backend_p) { zsock_t *frontend = zsock_new (ZMQ_PAIR); zsock_t *backend = zsock_new (ZMQ_PAIR); assert (frontend); assert (backend); #if (ZMQ_VERSION_MAJOR == 2) // TODO: v2/v3 socket api in zsock_option.inc are not public (not // added to include/zsock.h) so we have to use zmq_setsockopt directly // This should be fixed and zsock_set_hwm should be used instead # if defined (ZMQ_HWM) uint64_t value = zsys_pipehwm (); int ret = zmq_setsockopt (zsock_resolve (frontend), ZMQ_HWM, &value, sizeof (uint64_t)); assert (ret == 0 || zmq_errno () == ETERM); value = zsys_pipehwm (); ret = zmq_setsockopt (zsock_resolve (backend), ZMQ_HWM, &value, sizeof (uint64_t)); assert (ret == 0 || zmq_errno () == ETERM); # endif #else zsock_set_sndhwm (frontend, (int) zsys_pipehwm ()); zsock_set_sndhwm (backend, (int) zsys_pipehwm ()); #endif // Now bind and connect pipe ends char endpoint [32]; while (true) { sprintf (endpoint, "inproc://pipe-%04x-%04x", randof (0x10000), randof (0x10000)); if (zsock_bind (frontend, "%s", endpoint) == 0) break; } int rc = zsock_connect (backend, "%s", endpoint); assert (rc != -1); // Connect cannot fail // Return frontend and backend sockets *backend_p = backend; return frontend; } // -------------------------------------------------------------------------- // Set interrupt handler; this saves the default handlers so that a // zsys_handler_reset () can restore them. If you call this multiple times // then the last handler will take affect. If handler_fn is NULL, disables // default SIGINT/SIGTERM handling in CZMQ. void zsys_handler_set (zsys_handler_fn *handler_fn) { if (!handler_fn) { // Disable existing or future signal handling zsys_handler_reset (); handle_signals = false; } else { handle_signals = true; #if defined (__UNIX__) if (s_first_time) { // If first time, save default handlers sigaction (SIGINT, NULL, &sigint_default); sigaction (SIGTERM, NULL, &sigterm_default); s_first_time = false; } // Install signal handler for SIGINT and SIGTERM struct sigaction action; action.sa_handler = handler_fn; action.sa_flags = 0; sigemptyset (&action.sa_mask); sigaction (SIGINT, &action, NULL); sigaction (SIGTERM, &action, NULL); #elif defined (__WINDOWS__) installed_handler_fn = handler_fn; if (s_first_time) { SetConsoleCtrlHandler (s_handler_fn_shim, TRUE); s_first_time = false; } #else # error "No signal handling defined for this platform" #endif } } // -------------------------------------------------------------------------- // Reset interrupt handler, call this at exit if needed // Idempotent; safe to call multiple times void zsys_handler_reset (void) { #if defined (__UNIX__) // Restore default handlers if not already done if (handle_signals && !s_first_time) { sigaction (SIGINT, &sigint_default, NULL); sigaction (SIGTERM, &sigterm_default, NULL); sigint_default.sa_handler = NULL; sigterm_default.sa_handler = NULL; s_first_time = true; } #elif defined (__WINDOWS__) if (handle_signals && !s_first_time) { SetConsoleCtrlHandler (s_handler_fn_shim, FALSE); installed_handler_fn = NULL; s_first_time = true; } #endif } // -------------------------------------------------------------------------- // Set default interrupt handler, so Ctrl-C or SIGTERM will set // zsys_interrupted. Idempotent; safe to call multiple times. void zsys_catch_interrupts (void) { // Catch SIGINT and SIGTERM unless ZSYS_SIGHANDLER=false if ((getenv ("ZSYS_SIGHANDLER") == NULL || strneq (getenv ("ZSYS_SIGHANDLER"), "false")) && handle_signals) zsys_handler_set (s_signal_handler); } // Default internal signal handler static void s_signal_handler (int signal_value) { zctx_interrupted = 1; zsys_interrupted = 1; } // -------------------------------------------------------------------------- // Return true if file exists, else zero bool zsys_file_exists (const char *filename) { assert (filename); return zsys_file_mode (filename) != -1; } // -------------------------------------------------------------------------- // Return size of file, or -1 if not found ssize_t zsys_file_size (const char *filename) { struct stat stat_buf; assert (filename); if (stat ((char *) filename, &stat_buf) == 0) return stat_buf.st_size; else return -1; } // -------------------------------------------------------------------------- // Return file modification time (accounted in seconds usually since // UNIX Epoch, with granularity dependent on underlying filesystem, // and starting point dependent on host OS and maybe its bitness). // Per https://msdn.microsoft.com/en-us/library/w4ddyt9h(vs.71).aspx : // Note In all versions of Microsoft C/C++ except Microsoft C/C++ // version 7.0, and in all versions of Microsoft Visual C++, the time // function returns the current time as the number of seconds elapsed // since midnight on January 1, 1970. In Microsoft C/C++ version 7.0, // time() returned the current time as the number of seconds elapsed // since midnight on December 31, 1899. // This value is "arithmetic" with no big guarantees in the standards, and // normally it should be manipulated with host's datetime suite of routines, // including difftime(), or converted to "struct tm" for any predictable use. // Returns 0 if the file does not exist. time_t zsys_file_modified (const char *filename) { struct stat stat_buf; if (stat (filename, &stat_buf) == 0) return stat_buf.st_mtime; else return 0; } // -------------------------------------------------------------------------- // Return file mode; provides at least support for the POSIX S_ISREG(m) // and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. // Returns a mode_t cast to int, or -1 in case of error. int zsys_file_mode (const char *filename) { #if (defined (__WINDOWS__)) DWORD dwfa = GetFileAttributesA (filename); if (dwfa == 0xffffffff) return -1; dbyte mode = 0; if (dwfa & FILE_ATTRIBUTE_DIRECTORY) mode |= S_IFDIR; else mode |= S_IFREG; if (!(dwfa & FILE_ATTRIBUTE_HIDDEN)) mode |= S_IRUSR; if (!(dwfa & FILE_ATTRIBUTE_READONLY)) mode |= S_IWUSR; return mode; #else struct stat stat_buf; if (stat ((char *) filename, &stat_buf) == 0) return stat_buf.st_mode; else return -1; #endif } // -------------------------------------------------------------------------- // Delete file, return 0 if OK, -1 if not possible. int zsys_file_delete (const char *filename) { assert (filename); #if (defined (__WINDOWS__)) return DeleteFileA (filename)? 0: -1; #else return unlink (filename); #endif } // -------------------------------------------------------------------------- // Check if file is 'stable' // Internal implementation rigged with debugs and called from selftest static bool s_zsys_file_stable (const char *filename, bool verbose) { struct stat stat_buf; if (stat (filename, &stat_buf) == 0) { // File is 'stable' if older (per filesystem stats) than a threshold. // This used to mean more than 1 second old, counted in microseconds // after inflating the st_mtime data - but this way of calculation // has a caveat: if we created the file at Nsec.999msec, or rather // the FS metadata was updated at that point, the st_mtime will be // (after inflation) N.000. So a few milliseconds later, at (N+1)sec, // we find the age difference seems over 1000 so the file is 1 sec // old - even though it has barely been created. Compounding the // issue, some filesystems have worse timestamp precision - e.g. the // FAT filesystem variants are widespread (per SD standards) on // removable media, and only account even seconds in stat data. // Solutions are two-fold: when using stat fields that are precise // to a second (or inpredictably two), we should actually check for // (age > 3000+) in rounded-microsecond accounting. Also, for some // systems we can have `configure`-time checks on presence of more // precise (and less standardized) stat timestamp fields, where we // can presumably avoid rounding to thousands and use (age > 2000). // It might also help to define a zsys_file_modified_msec() whose // actual granularity will be OS-dependent (rounded to 1000 or not). // These are TODO ideas for subsequent work. #if (defined (WIN32)) # define EPOCH_DIFFERENCE 11644473600LL long age = (long) (zclock_time () - EPOCH_DIFFERENCE * 1000 - (stat_buf.st_mtime * 1000)); if (verbose) zsys_debug ("zsys_file_stable@WIN32: file '%s' age is %ld msec " "at timestamp %" PRIi64 " where st_mtime was %jd adjusted by %jd", filename, age, zclock_time (), (intmax_t)(stat_buf.st_mtime * 1000), (intmax_t)(EPOCH_DIFFERENCE * 1000) ); #else long age = (long) (zclock_time () - (stat_buf.st_mtime * 1000)); if (verbose) zsys_debug ("zsys_file_stable@non-WIN32: file '%s' age is %ld msec " "at timestamp %" PRIi64 " where st_mtime was %jd", filename, age, zclock_time (), (intmax_t)(stat_buf.st_mtime * 1000) ); #endif return (age > s_file_stable_age_msec); } else { if (verbose) zsys_debug ("zsys_file_stable: could not stat file '%s'", filename); return false; // File doesn't exist, so not stable } } // Public implementation does not do debugs bool zsys_file_stable (const char *filename) { return s_zsys_file_stable(filename, false); } // -------------------------------------------------------------------------- // Create a file path if it doesn't exist. The file path is treated as a // printf format. int zsys_dir_create (const char *pathname, ...) { va_list argptr; va_start (argptr, pathname); char *formatted = zsys_vprintf (pathname, argptr); va_end (argptr); if (!formatted) return -1; // Create parent directory levels if needed char *slash = strchr (formatted + 1, '/'); while (true) { if (slash) *slash = 0; // Cut at slash int mode = zsys_file_mode (formatted); if (mode == -1) { // Does not exist, try to create it #if (defined (__WINDOWS__)) if (!CreateDirectoryA (formatted, NULL)) { #else if (mkdir (formatted, 0775)) { #endif freen (formatted); return -1; // Failed } } else if ((mode & S_IFDIR) == 0) { // Not a directory, abort } if (!slash) // End if last segment break; *slash = '/'; slash = strchr (slash + 1, '/'); } zstr_free (&formatted); return 0; } // -------------------------------------------------------------------------- // Remove a file path if empty; the pathname is treated as printf format. int zsys_dir_delete (const char *pathname, ...) { va_list argptr; va_start (argptr, pathname); char *formatted = zsys_vprintf (pathname, argptr); va_end (argptr); if (!formatted) return -1; #if (defined (__WINDOWS__)) int rc = RemoveDirectoryA (formatted)? 0: -1; #else int rc = rmdir (formatted); #endif zstr_free (&formatted); return rc; } // -------------------------------------------------------------------------- // Move to a specified working directory. Returns 0 if OK, -1 if this failed. int zsys_dir_change (const char *pathname) { assert (pathname); #if (defined (__UNIX__)) return chdir (pathname); #elif (defined (__WINDOWS__)) return !SetCurrentDirectoryA (pathname); #endif return -1; // Not implemented } // -------------------------------------------------------------------------- // Set private file creation mode; all files created from here will be // readable/writable by the owner only. #if !defined (__WINDOWS__) static mode_t s_old_mask = 0; #endif void zsys_file_mode_private (void) { #if !defined (__WINDOWS__) s_old_mask = umask (S_IWGRP | S_IWOTH | S_IRGRP | S_IROTH); #endif } // -------------------------------------------------------------------------- // Reset default file creation mode; all files created from here will use // process file mode defaults. void zsys_file_mode_default (void) { // Reset process file create mask #if !defined (__WINDOWS__) if (s_old_mask) umask (s_old_mask); #endif } // -------------------------------------------------------------------------- // Return the CZMQ version for run-time API detection; returns version // number into provided fields, providing reference isn't null in each case. void zsys_version (int *major, int *minor, int *patch) { if (major) *major = CZMQ_VERSION_MAJOR; if (minor) *minor = CZMQ_VERSION_MINOR; if (patch) *patch = CZMQ_VERSION_PATCH; } // -------------------------------------------------------------------------- // Format a string using printf formatting, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). char * zsys_sprintf (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); return (string); } // -------------------------------------------------------------------------- // Format a string with variable arguments, returning a freshly allocated // buffer. If there was insufficient memory, returns NULL. Free the returned // string using zstr_free(). char * zsys_vprintf (const char *format, va_list argptr) { int size = 256; char *string = (char *) malloc (size); if (!string) return NULL; // Using argptr is destructive, so we take a copy each time we need it // We define va_copy for Windows in czmq_prelude.h va_list my_argptr; va_copy (my_argptr, argptr); int required = vsnprintf (string, size, format, my_argptr); va_end (my_argptr); #ifdef __WINDOWS__ if (required < 0 || required >= size) { va_copy (my_argptr, argptr); #ifdef _MSC_VER required = _vscprintf (format, argptr); #else required = vsnprintf (NULL, 0, format, argptr); #endif va_end (my_argptr); } #endif // If formatted string cannot fit into small string, reallocate a // larger buffer for it. if (required >= size) { size = required + 1; freen (string); string = (char *) malloc (size); if (string) { va_copy (my_argptr, argptr); vsnprintf (string, size, format, my_argptr); va_end (my_argptr); } } return string; } // -------------------------------------------------------------------------- // Create a UDP beacon socket; if the routable option is true, uses // multicast (not yet implemented), else uses broadcast. This method // and related ones might _eventually_ be moved to a zudp class. SOCKET zsys_udp_new (bool routable) { // We haven't implemented multicast yet assert (!routable); SOCKET udpsock; if (zsys_ipv6 ()) udpsock = socket (AF_INET6, SOCK_DGRAM, IPPROTO_UDP); else udpsock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (udpsock == INVALID_SOCKET) { zsys_socket_error ("socket"); return INVALID_SOCKET; } // Ask operating system for broadcast permissions on socket int on = 1; if (setsockopt (udpsock, SOL_SOCKET, SO_BROADCAST, (char *) &on, sizeof (on)) == SOCKET_ERROR) zsys_socket_error ("setsockopt (SO_BROADCAST)"); // Allow multiple owners to bind to socket; incoming // messages will replicate to each owner if (setsockopt (udpsock, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof (on)) == SOCKET_ERROR) zsys_socket_error ("setsockopt (SO_REUSEADDR)"); #if defined (SO_REUSEPORT) // On some platforms we have to ask to reuse the port if (setsockopt (udpsock, SOL_SOCKET, SO_REUSEPORT, (char *) &on, sizeof (on)) == SOCKET_ERROR) zsys_socket_error ("setsockopt (SO_REUSEPORT)"); #endif return udpsock; } // -------------------------------------------------------------------------- // Close a UDP socket int zsys_udp_close (SOCKET handle) { #if (defined (__WINDOWS__)) return closesocket (handle); #else return close (handle); #endif } // -------------------------------------------------------------------------- // Send zframe to UDP socket, return -1 if sending failed due to // interface having disappeared (happens easily with WiFi) int zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address, int addrlen) { assert (frame); assert (address); if (sendto (udpsock, (char *) zframe_data (frame), (int) zframe_size (frame), 0, // Flags (struct sockaddr *) address, addrlen) == -1) { zsys_debug ("zsys_udp_send: failed, reason=%s", strerror (errno)); return -1; // UDP broadcast not possible } else return 0; } // -------------------------------------------------------------------------- // Receive zframe from UDP socket, and set address of peer that sent it // The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or // NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address. zframe_t * zsys_udp_recv (SOCKET udpsock, char *peername, int peerlen) { char buffer [UDP_FRAME_MAX]; in6addr_t address6; socklen_t address_len = sizeof (in6addr_t); ssize_t size = recvfrom ( udpsock, buffer, UDP_FRAME_MAX, 0, // Flags (struct sockaddr *) &address6, &address_len); if (size == SOCKET_ERROR) zsys_socket_error ("recvfrom"); // Get sender address as printable string int rc = getnameinfo ((struct sockaddr *) &address6, address_len, peername, peerlen, NULL, 0, NI_NUMERICHOST); if (rc) { zsys_warning ("zsys_udp_recv: getnameinfo failed, reason=%s", gai_strerror (rc)); return NULL; } // Some platform's getnameinfo, like Solaris, appear not to append the // interface name when parsing a link-local IPv6 address. These addresses // cannot be used without the interface, so we must append it manually. // On Windows, if_indextoname is only available from Vista. #if !defined (__WINDOWS__) || (_WIN32_WINNT >= 0x0600) if (address6.sin6_family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL (&address6.sin6_addr) && !strchr (peername, '%')) { char ifname [IF_NAMESIZE] = {0}; if_indextoname (address6.sin6_scope_id, ifname); strcat (peername, "%"); strcat (peername, ifname); } #endif return zframe_new (buffer, size); } // -------------------------------------------------------------------------- // Handle an I/O error on some socket operation; will report and die on // fatal errors, and continue silently on "try again" errors. void zsys_socket_error (const char *reason) { bool check_errno; #if defined (__WINDOWS__) switch (WSAGetLastError ()) { case WSAEINTR: errno = EINTR; break; case WSAEBADF: errno = EBADF; break; case WSAEWOULDBLOCK: errno = EAGAIN; break; case WSAEINPROGRESS: errno = EAGAIN; break; case WSAENETDOWN: errno = ENETDOWN; break; case WSAECONNRESET: errno = ECONNRESET; break; case WSAECONNABORTED: errno = EPIPE; break; case WSAESHUTDOWN: errno = ECONNRESET; break; case WSAEINVAL: errno = EPIPE; break; case WSAEADDRNOTAVAIL: errno = EADDRNOTAVAIL; break; case WSAEADDRINUSE: errno = EADDRINUSE; break; default: errno = GetLastError (); } #endif check_errno = (errno == EAGAIN || errno == ENETDOWN || errno == EHOSTUNREACH || errno == ENETUNREACH || errno == EINTR || errno == EPIPE || errno == ECONNRESET); #if defined (ENOPROTOOPT) check_errno = (check_errno || errno == ENOPROTOOPT); #endif #if defined (EHOSTDOWN) check_errno = (check_errno || errno == EHOSTDOWN); #endif #if defined (EOPNOTSUPP) check_errno = (check_errno || errno == EOPNOTSUPP); #endif #if defined (EWOULDBLOCK) check_errno = (check_errno || errno == EWOULDBLOCK); #endif #if defined (EPROTO) check_errno = (check_errno || errno == EPROTO); #endif #if defined (ENONET) check_errno = (check_errno || errno == ENONET); #endif if (check_errno) return; // Ignore error and try again else { zsys_error ("(UDP) error '%s' on %s", strerror (errno), reason); assert (false); } } // -------------------------------------------------------------------------- // Return current host name, for use in public tcp:// endpoints. Caller gets // a freshly allocated string, should free it using zstr_free(). If the host // name is not resolvable, returns NULL. char * zsys_hostname (void) { char hostname [NI_MAXHOST]; gethostname (hostname, NI_MAXHOST); hostname [NI_MAXHOST - 1] = 0; struct hostent *host = gethostbyname (hostname); if (host && host->h_name) return strdup (host->h_name); else return NULL; } // -------------------------------------------------------------------------- // Move the current process into the background. The precise effect depends // on the operating system. On POSIX boxes, moves to a specified working // directory (if specified), closes all file handles, reopens stdin, stdout, // and stderr to the null device, and sets the process to ignore SIGHUP. On // Windows, does nothing. Returns 0 if OK, -1 if there was an error. int zsys_daemonize (const char *workdir) { #if (defined (__UNIX__)) // Defines umask for new files this process will create mode_t file_mask = 027; // Complement of 0750 // Recreate our process as a child of init int fork_result = fork (); if (fork_result < 0) // < 0 is an error return -1; // Could not fork else if (fork_result > 0) // > 0 is the parent process exit (0); // End parent process // Move to a safe and known directory, which is supplied as an // argument to this function (or not, if workdir is NULL or empty). if (workdir && zsys_dir_change (workdir)) { zsys_error ("cannot chdir to '%s'", workdir); return -1; } // Close all open file descriptors inherited from the parent // process, to reduce the resources we use int file_handle = sysconf (_SC_OPEN_MAX); while (file_handle) close (file_handle--); // Ignore any errors // Set the umask for new files we might create umask (file_mask); // Set standard input and output to the null device so that any // code that assumes that these files are open will work file_handle = open ("/dev/null", O_RDWR); int fh_stdout = dup (file_handle); int fh_stderr = dup (file_handle); assert (fh_stdout); assert (fh_stderr); // Ignore any hangup signal from the controlling console signal (SIGHUP, SIG_IGN); #endif return 0; } // -------------------------------------------------------------------------- // Drop the process ID into the lockfile, with exclusive lock, and switch // the process to the specified group and/or user. Any of the arguments // may be null, indicating a no-op. Returns 0 on success, -1 on failure. // Note if you combine this with zsys_daemonize, run after, not before // that method, or the lockfile will hold the wrong process ID. int zsys_run_as (const char *lockfile, const char *group, const char *user) { #if (defined (__UNIX__)) // Switch to effective user ID (who owns executable); for // system services this should be root, so that we can write // the PID file into e.g. /var/run/ if (seteuid (geteuid ())) { zsys_error ("cannot set effective user id: %s", strerror (errno)); return -1; } if (lockfile) { // We enforce a lock on the lockfile, if specified, so that // only one copy of the process can run at once. int handle = open (lockfile, O_RDWR | O_CREAT, 0640); if (handle < 0) { zsys_error ("cannot open lockfile '%s': %s", lockfile, strerror (errno)); return -1; } else { struct flock filelock; filelock.l_type = F_WRLCK; // F_RDLCK, F_WRLCK, F_UNLCK filelock.l_whence = SEEK_SET; // SEEK_SET, SEEK_CUR, SEEK_END filelock.l_start = 0; // Offset from l_whence filelock.l_len = 0; // length, 0 = to EOF filelock.l_pid = getpid (); if (fcntl (handle, F_SETLK, &filelock)) { zsys_error ("cannot get lock: %s", strerror (errno)); return -1; } } // We record the current process id in the lock file char pid_buffer [32]; snprintf (pid_buffer, sizeof (pid_buffer), "%6" PRIi64 "\n", (int64_t)getpid ()); if ((size_t) write (handle, pid_buffer, strlen (pid_buffer)) != strlen (pid_buffer)) { zsys_error ("cannot write to lockfile: %s", strerror (errno)); close (handle); return -1; } } if (group) { zsys_info ("running under group '%s'", group); struct group *grpbuf = NULL; grpbuf = getgrnam (group); if (grpbuf == NULL || setgid (grpbuf->gr_gid)) { zsys_error ("could not switch group: %s", strerror (errno)); return -1; } } if (user) { zsys_info ("running under user '%s'", user); struct passwd *pwdbuf = NULL; pwdbuf = getpwnam (user); if (pwdbuf == NULL || setuid (pwdbuf->pw_uid)) { zsys_error ("could not switch user: %s", strerror (errno)); return -1; } } else { // Switch back to real user ID (who started process) if (setuid (getuid ())) { zsys_error ("cannot set real user id: %s", strerror (errno)); return -1; } } return 0; #else // This is not yet ported to Windows and should not succeed there. return -1; #endif } // -------------------------------------------------------------------------- // Returns true if the underlying libzmq supports CURVE security. // Uses a heuristic probe according to the version of libzmq being used. bool zsys_has_curve (void) { #if defined (ZMQ_CURVE_SERVER) # if defined (ZMQ_HAS_CAPABILITIES) // This is the most modern way of probing libzmq capabilities return zmq_has ("curve") != 0; # else // However trying the zmq_setsockopt will also work int rc = -1; // assume we fail void *ctx = zmq_ctx_new (); if (ctx) { void *pub = zmq_socket (ctx, ZMQ_PUB); if (pub) { int as_server = 1; rc = zmq_setsockopt (pub, ZMQ_CURVE_SERVER, &as_server, sizeof (int)); zmq_close (pub); } zmq_term (ctx); } return rc != -1; # endif #else return false; #endif } // -------------------------------------------------------------------------- // Configure the number of I/O threads that ZeroMQ will use. A good // rule of thumb is one thread per gigabit of traffic in or out. The // default is 1, sufficient for most applications. If the environment // variable ZSYS_IO_THREADS is defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_io_threads (size_t io_threads) { zsys_init (); ZMUTEX_LOCK (s_mutex); if (s_open_sockets) zsys_error ("zsys_io_threads() is not valid after creating sockets"); assert (s_open_sockets == 0); s_io_threads = io_threads; #if ZMQ_VERSION < ZMQ_MAKE_VERSION(3, 2, 0) zmq_term (s_process_ctx); s_process_ctx = zmq_init ((int) s_io_threads); #else # if defined (ZMQ_IO_THREADS) zmq_ctx_set (s_process_ctx, ZMQ_IO_THREADS, s_io_threads); # endif #endif ZMUTEX_UNLOCK (s_mutex); #if ZMQ_VERSION < ZMQ_MAKE_VERSION(3, 2, 0) // Reinitialised outside of the lock to avoid recursive lock zsys_set_max_msgsz (s_max_msgsz); zsys_set_max_sockets (s_max_sockets); #endif } // -------------------------------------------------------------------------- // Configure the scheduling policy of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY // is defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_thread_sched_policy (int policy) { if (policy < 0) return; zsys_init (); ZMUTEX_LOCK (s_mutex); // If the app is misusing this method, burn it with fire if (s_open_sockets) zsys_error ("zsys_set_thread_sched_policy() is not valid after" " creating sockets"); assert (s_open_sockets == 0); s_thread_sched_policy = policy; #if defined (ZMQ_THREAD_SCHED_POLICY) zmq_ctx_set (s_process_ctx, ZMQ_THREAD_SCHED_POLICY, s_thread_sched_policy); #endif ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Configure the scheduling priority of the ZMQ context thread pool. // Not available on Windows. See the sched_setscheduler man page or sched.h // for more information. If the environment variable ZSYS_THREAD_PRIORITY is // defined, that provides the default. // Note that this method is valid only before any socket is created. void zsys_set_thread_priority (int priority) { if (priority < 0) return; zsys_init (); ZMUTEX_LOCK (s_mutex); // If the app is misusing this method, burn it with fire if (s_open_sockets) zsys_error ("zsys_set_thread_priority() is not valid after" " creating sockets"); assert (s_open_sockets == 0); s_thread_priority = priority; #if defined (ZMQ_THREAD_PRIORITY) zmq_ctx_set (s_process_ctx, ZMQ_THREAD_PRIORITY, s_thread_priority); #endif ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Configure the number of sockets that ZeroMQ will allow. The default // is 1024. The actual limit depends on the system, and you can query it // by using zsys_socket_limit (). A value of zero means "maximum". // Note that this method is valid only before any socket is created. void zsys_set_max_sockets (size_t max_sockets) { zsys_init (); ZMUTEX_LOCK (s_mutex); // If the app is misusing this method, burn it with fire if (s_open_sockets) zsys_error ("zsys_max_sockets() is not valid after creating sockets"); assert (s_open_sockets == 0); s_max_sockets = max_sockets? max_sockets: zsys_socket_limit (); #if defined (ZMQ_MAX_SOCKETS) zmq_ctx_set (s_process_ctx, ZMQ_MAX_SOCKETS, (int) s_max_sockets); #endif ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Return maximum number of ZeroMQ sockets that the system will support. size_t zsys_socket_limit (void) { size_t socket_limit; #if defined (ZMQ_SOCKET_LIMIT) if (s_process_ctx) socket_limit = (size_t) zmq_ctx_get (s_process_ctx, ZMQ_SOCKET_LIMIT); else { void *ctx = zmq_init (1); socket_limit = (size_t) zmq_ctx_get (ctx, ZMQ_SOCKET_LIMIT); zmq_term (ctx); } // ZeroMQ used to report a nonsense value (2^31) which if used would // on zmq_ctx_set (ZMQ_MAX_SOCKETS) cause an out-of-memory error. So // if we're running on an older library, enforce a sane limit. if (socket_limit > 65535) socket_limit = 65535; #else socket_limit = 1024; #endif return socket_limit; } // -------------------------------------------------------------------------- // Configure the maximum allowed size of a message sent. // The default is INT_MAX. void zsys_set_max_msgsz (int max_msgsz) { if (max_msgsz < 0) return; zsys_init (); ZMUTEX_LOCK (s_mutex); s_max_msgsz = max_msgsz; #if defined (ZMQ_MAX_MSGSZ) zmq_ctx_set (s_process_ctx, ZMQ_MAX_MSGSZ, (int) s_max_msgsz); #endif ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Return maximum message size. int zsys_max_msgsz (void) { zsys_init (); ZMUTEX_LOCK (s_mutex); #if defined (ZMQ_MAX_MSGSZ) s_max_msgsz = zmq_ctx_get (s_process_ctx, ZMQ_MAX_MSGSZ); #endif ZMUTEX_UNLOCK (s_mutex); return s_max_msgsz; } // -------------------------------------------------------------------------- // Configure the threshold value of filesystem object age per st_mtime // that should elapse until we consider that object "stable" at the // current zclock_time() moment. // The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c // which generally depends on host OS, with fallback value of 5000. void zsys_set_file_stable_age_msec (int64_t file_stable_age_msec) { if (file_stable_age_msec < 1) return; zsys_init (); ZMUTEX_LOCK (s_mutex); s_file_stable_age_msec = file_stable_age_msec; ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Return current threshold value of file stable age in msec. // This can be used in code that chooses to wait for this timeout // before testing if a filesystem object is "stable" or not. // Note that the OS timer quantization can bite you, so it may be // reasonably safe to sleep/wait/poll for a larger timeout before // assuming a fault, e.g. the default timer resolution on Windows // is 15.6 ms (per timer interrupt 64 times a second), graphed here: // https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx // and Unix/Linux OSes also have different-resolution timers. int64_t zsys_file_stable_age_msec (void) { zsys_init (); return s_file_stable_age_msec; } // -------------------------------------------------------------------------- // Configure the default linger timeout in msecs for new zsock instances. // You can also set this separately on each zsock_t instance. The default // linger time is zero, i.e. any pending messages will be dropped. If the // environment variable ZSYS_LINGER is defined, that provides the default. // Note that process exit will typically be delayed by the linger time. void zsys_set_linger (size_t linger) { zsys_init (); ZMUTEX_LOCK (s_mutex); s_linger = linger; ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Configure the default outgoing pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_SNDHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void zsys_set_sndhwm (size_t sndhwm) { zsys_init (); ZMUTEX_LOCK (s_mutex); s_sndhwm = sndhwm; ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Configure the default incoming pipe limit (HWM) for new zsock instances. // You can also set this separately on each zsock_t instance. The default // HWM is 1,000, on all versions of ZeroMQ. If the environment variable // ZSYS_RCVHWM is defined, that provides the default. Note that a value of // zero means no limit, i.e. infinite memory consumption. void zsys_set_rcvhwm (size_t rcvhwm) { zsys_init (); ZMUTEX_LOCK (s_mutex); s_rcvhwm = rcvhwm; ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Configure the default HWM for zactor internal pipes; this is set on both // ends of the pipe, for outgoing messages only (sndhwm). The default HWM is // 1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is // defined, that provides the default. Note that a value of zero means no // limit, i.e. infinite memory consumption. void zsys_set_pipehwm (size_t pipehwm) { zsys_init (); ZMUTEX_LOCK (s_mutex); s_pipehwm = pipehwm; ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Return the HWM for zactor internal pipes. size_t zsys_pipehwm (void) { return s_pipehwm; } // -------------------------------------------------------------------------- // Configure use of IPv6 for new zsock instances. By default sockets accept // and make only IPv4 connections. When you enable IPv6, sockets will accept // and connect to both IPv4 and IPv6 peers. You can override the setting on // each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the // environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the // default. Note: has no effect on ZMQ v2. void zsys_set_ipv6 (int ipv6) { zsys_init (); ZMUTEX_LOCK (s_mutex); s_ipv6 = ipv6; ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Return use of IPv6 for zsock instances. int zsys_ipv6 (void) { return s_ipv6; } // -------------------------------------------------------------------------- // Set network interface name to use for broadcasts, particularly zbeacon. // This lets the interface be configured for test environments where required. // For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is // the default when there is no specified interface. If the environment // variable ZSYS_INTERFACE is set, use that as the default interface name. // Setting the interface to "*" means "use all interfaces". void zsys_set_interface (const char *value) { zsys_init (); freen (s_interface); s_interface = strdup (value); assert (s_interface); } // -------------------------------------------------------------------------- // Return network interface to use for broadcasts, or "" if none was set. const char * zsys_interface (void) { return s_interface? s_interface: ""; } // -------------------------------------------------------------------------- // Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. // This needs to be set IPv6 is enabled as IPv6 can have multiple addresses // on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, // use that as the default IPv6 address. void zsys_set_ipv6_address (const char *value) { zsys_init (); freen (s_ipv6_address); s_ipv6_address = strdup (value); assert (s_ipv6_address); } // -------------------------------------------------------------------------- // Return IPv6 address to use for zbeacon reception, or "" if none was set. const char * zsys_ipv6_address (void) { return s_ipv6_address? s_ipv6_address: ""; } // -------------------------------------------------------------------------- // Set IPv6 multicast address to use for sending zbeacon messages. The default // is fe02::1 (link-local all-node). If the environment variable // ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast // address. void zsys_set_ipv6_mcast_address (const char *value) { zsys_init (); freen (s_ipv6_mcast_address); s_ipv6_mcast_address = strdup (value); assert (s_ipv6_mcast_address); } // -------------------------------------------------------------------------- // Return IPv6 multicast address to use for sending zbeacon, or // "ff02:0:0:0:0:0:0:1" if none was set. const char * zsys_ipv6_mcast_address (void) { return s_ipv6_mcast_address ? s_ipv6_mcast_address : "ff02:0:0:0:0:0:0:1"; } // -------------------------------------------------------------------------- // Configure the automatic use of pre-allocated FDs when creating new sockets. // If 0 (default), nothing will happen. Else, when a new socket is bound, the // system API will be used to check if an existing pre-allocated FD with a // matching port (if TCP) or path (if IPC) exists, and if it does it will be // set via the ZMQ_USE_FD socket option so that the library will use it // instead of creating a new socket. void zsys_set_auto_use_fd (int auto_use_fd) { zsys_init (); ZMUTEX_LOCK (s_mutex); s_auto_use_fd = auto_use_fd; ZMUTEX_UNLOCK (s_mutex); } // -------------------------------------------------------------------------- // Return use of automatic pre-allocated FDs for zsock instances. int zsys_auto_use_fd (void) { return s_auto_use_fd; } // -------------------------------------------------------------------------- // Set log identity, which is a string that prefixes all log messages sent // by this process. The log identity defaults to the environment variable // ZSYS_LOGIDENT, if that is set. void zsys_set_logident (const char *value) { zsys_init (); freen (s_logident); s_logident = strdup (value); #if defined (__UNIX__) if (s_logsystem) openlog (s_logident, LOG_PID, LOG_USER); #elif defined (__WINDOWS__) // TODO: hook in Windows event log for Windows #endif assert (s_logident); } // -------------------------------------------------------------------------- // Set stream to receive log traffic. By default, log traffic is sent to // stdout. If you set the stream to NULL, no stream will receive the log // traffic (it may still be sent to the system facility). void zsys_set_logstream (FILE *stream) { zsys_init (); s_logstream = stream; } // -------------------------------------------------------------------------- // Sends log output to a PUB socket bound to the specified endpoint. To // collect such log output, create a SUB socket, subscribe to the traffic // you care about, and connect to the endpoint. Log traffic is sent as a // single string frame, in the same format as when sent to stdout. The // log system supports a single sender; multiple calls to this method will // bind the same sender to multiple endpoints. To disable the sender, call // this method with a null argument. void zsys_set_logsender (const char *endpoint) { zsys_init (); if (endpoint) { // Create log sender if needed if (!s_logsender) { s_logsender = zsock_new_pub(NULL); assert (s_logsender); } // Bind/connect to specified endpoint(s) using zsock_attach() syntax int rc = zsock_attach (s_logsender, endpoint, true); assert (rc == 0); } else if (s_logsender) { zsock_destroy (&s_logsender); } } // -------------------------------------------------------------------------- // Enable or disable logging to the system facility (syslog on POSIX boxes, // event log on Windows). By default this is disabled. void zsys_set_logsystem (bool logsystem) { zsys_init (); s_logsystem = logsystem; #if defined (__UNIX__) if (s_logsystem) openlog (s_logident, LOG_PID, LOG_USER); #elif defined (__WINDOWS__) // TODO: hook into Windows event log #endif } static void s_log (char loglevel, char *string) { #if defined (__UNIX__) # if defined (__UTYPE_ANDROID) int priority = ANDROID_LOG_INFO; if (loglevel == 'E') priority = ANDROID_LOG_ERROR; else if (loglevel == 'W') priority = ANDROID_LOG_WARN; else if (loglevel == 'N') priority = ANDROID_LOG_INFO; else if (loglevel == 'I') priority = ANDROID_LOG_INFO; else if (loglevel == 'D') priority = ANDROID_LOG_DEBUG; __android_log_print(priority, "zsys", "%s", string); # else if (s_logsystem) { int priority = LOG_INFO; if (loglevel == 'E') priority = LOG_ERR; else if (loglevel == 'W') priority = LOG_WARNING; else if (loglevel == 'N') priority = LOG_NOTICE; else if (loglevel == 'I') priority = LOG_INFO; else if (loglevel == 'D') priority = LOG_DEBUG; syslog (priority, "%s", string); } else # endif #endif if (s_logstream || s_logsender) { time_t curtime = time (NULL); struct tm *loctime = localtime (&curtime); char date [20]; strftime (date, 20, "%y-%m-%d %H:%M:%S", loctime); char log_text [1024]; if (s_logident) snprintf (log_text, 1024, "%c: (%s) %s %s", loglevel, s_logident, date, string); else snprintf (log_text, 1024, "%c: %s %s", loglevel, date, string); if (s_logstream) { fprintf (s_logstream, "%s\n", log_text); fflush (s_logstream); } if (s_logsender) zstr_send (s_logsender, log_text); } } // -------------------------------------------------------------------------- // Log error condition - highest priority void zsys_error (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); s_log ('E', string); zstr_free (&string); } // -------------------------------------------------------------------------- // Log warning condition - high priority void zsys_warning (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); s_log ('W', string); zstr_free (&string); } // -------------------------------------------------------------------------- // Log normal, but significant, condition - normal priority void zsys_notice (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); s_log ('N', string); zstr_free (&string); } // -------------------------------------------------------------------------- // Log informational message - low priority void zsys_info (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); s_log ('I', string); zstr_free (&string); } // -------------------------------------------------------------------------- // Log debug-level message - lowest priority void zsys_debug (const char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); s_log ('D', string); zstr_free (&string); } // -------------------------------------------------------------------------- // Selftest void zsys_test (bool verbose) { printf (" * zsys: "); if (verbose) printf ("\n"); // check that we can stop/restart the environnemnt zsys_shutdown(); zsys_init(); zsys_shutdown(); zsys_init(); // @selftest zsys_catch_interrupts (); // Check capabilities without using the return value int rc = zsys_has_curve (); const char *SELFTEST_DIR_RW = "src/selftest-rw"; if (verbose) { char *hostname = zsys_hostname (); zsys_info ("host name is %s", hostname); freen (hostname); zsys_info ("system limit is %zu ZeroMQ sockets", zsys_socket_limit ()); } zsys_set_file_stable_age_msec (5123); assert (zsys_file_stable_age_msec() == 5123); zsys_set_file_stable_age_msec (-1); assert (zsys_file_stable_age_msec() == 5123); zsys_set_linger (0); zsys_set_sndhwm (1000); zsys_set_rcvhwm (1000); zsys_set_pipehwm (2500); assert (zsys_pipehwm () == 2500); zsys_set_ipv6 (0); zsys_set_thread_priority (-1); zsys_set_thread_sched_policy (-1); // Test pipe creation zsock_t *pipe_back; zsock_t *pipe_front = zsys_create_pipe (&pipe_back); zstr_send (pipe_front, "Hello"); char *string = zstr_recv (pipe_back); assert (streq (string, "Hello")); freen (string); zsock_destroy (&pipe_back); zsock_destroy (&pipe_front); // Test file manipulation // Don't let anyone fool our workspace if (zsys_file_exists ("nosuchfile")) { zsys_warning ("zsys_test() had to remove 'nosuchfile' which was not expected here at all"); zsys_file_delete ("nosuchfile"); } rc = zsys_file_delete ("nosuchfile"); assert (rc == -1); bool rc_bool = zsys_file_exists ("nosuchfile"); assert (rc_bool != true); rc = (int) zsys_file_size ("nosuchfile"); assert (rc == -1); time_t when = zsys_file_modified ("."); assert (when > 0); int mode = zsys_file_mode ("."); assert (S_ISDIR (mode)); assert (mode & S_IRUSR); assert (mode & S_IWUSR); const char *testbasedir = ".testsys"; const char *testsubdir = "subdir"; char *basedirpath = NULL; // subdir in a test, under SELFTEST_DIR_RW char *dirpath = NULL; // subdir in a test, under basedirpath char *relsubdir = NULL; // relative short "path" of subdir under testbasedir basedirpath = zsys_sprintf ("%s/%s", SELFTEST_DIR_RW, testbasedir); assert (basedirpath); dirpath = zsys_sprintf ("%s/%s", basedirpath, testsubdir); assert (dirpath); relsubdir = zsys_sprintf ("%s/%s", testbasedir, testsubdir); assert (relsubdir); // Normally tests clean up in the end, but if a selftest run dies // e.g. on assert(), workspace remains dirty. Better clean it up. // We do not really care about results here - we clean up a possible // dirty exit of an older build. If there are permission errors etc. // the actual tests below would explode. if (zsys_file_exists(dirpath)) { if (verbose) zsys_debug ("zsys_test() has to remove ./%s that should not have been here", dirpath); zsys_dir_delete (dirpath); } if (zsys_file_exists (basedirpath)) { if (verbose) zsys_debug ("zsys_test() has to remove ./%s that should not have been here", basedirpath); zsys_dir_delete (basedirpath); } // Added tracing because this file-age check fails on some systems // presumably due to congestion in a mass-build and valgrind on top zsys_file_mode_private (); if (verbose) printf ("zsys_test() at timestamp %" PRIi64 ": " "Creating %s\n", zclock_time(), relsubdir ); rc = zsys_dir_create ("%s/%s", SELFTEST_DIR_RW, relsubdir); if (verbose) printf ("zsys_test() at timestamp %" PRIi64 ": " "Finished creating %s with return-code %d\n", zclock_time(), relsubdir, rc ); assert (rc == 0); when = zsys_file_modified (dirpath); if (verbose) printf ("zsys_test() at timestamp %" PRIi64 ": " "Finished calling zsys_file_modified(), got age %jd\n", zclock_time(), (intmax_t)when ); assert (when > 0); if (verbose) printf ("zsys_test() at timestamp %" PRIi64 ": " "Checking if file is NOT stable (is younger than 1 sec)\n", zclock_time() ); assert (!s_zsys_file_stable (dirpath, verbose)); if (verbose) printf ("zsys_test() at timestamp %" PRIi64 ": " "Passed the test, file is not stable - as expected\n", zclock_time() ); rc = zsys_dir_delete ("%s/%s", SELFTEST_DIR_RW, relsubdir); assert (rc == 0); rc = zsys_dir_delete ("%s/%s", SELFTEST_DIR_RW, testbasedir); assert (rc == 0); zsys_file_mode_default (); #if (defined (PATH_MAX)) char cwd[PATH_MAX]; #else # if (defined (_MAX_PATH)) char cwd[_MAX_PATH]; # else char cwd[1024]; # endif #endif memset (cwd, 0, sizeof(cwd)); #if (defined (WIN32)) if (_getcwd(cwd, sizeof(cwd)) != NULL) { #else if (getcwd(cwd, sizeof(cwd)) != NULL) { #endif if (verbose) printf ("zsys_test() at timestamp %" PRIi64 ": " "current working directory is %s\n", zclock_time(), cwd); assert (zsys_dir_change (SELFTEST_DIR_RW) == 0); assert (zsys_dir_change (cwd) == 0); } else { zsys_warning ("zsys_test() : got getcwd() error... " "testing zsys_dir_change() anyway, but it can confuse " "subsequent tests in this process"); assert (zsys_dir_change (SELFTEST_DIR_RW) == 0); } zstr_free (&basedirpath); zstr_free (&dirpath); zstr_free (&relsubdir); // Other subtests int major, minor, patch; zsys_version (&major, &minor, &patch); assert (major == CZMQ_VERSION_MAJOR); assert (minor == CZMQ_VERSION_MINOR); assert (patch == CZMQ_VERSION_PATCH); string = zsys_sprintf ("%s %02x", "Hello", 16); assert (streq (string, "Hello 10")); freen (string); char *str64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,."; int num10 = 1234567890; string = zsys_sprintf ("%s%s%s%s%d", str64, str64, str64, str64, num10); assert (strlen (string) == (4 * 64 + 10)); freen (string); // Test logging system zsys_set_logident ("czmq_selftest"); zsys_set_logsender ("inproc://logging"); void *logger = zsys_socket (ZMQ_SUB, NULL, 0); assert (logger); rc = zmq_connect (logger, "inproc://logging"); assert (rc == 0); rc = zmq_setsockopt (logger, ZMQ_SUBSCRIBE, "", 0); assert (rc == 0); if (verbose) { zsys_error ("This is an %s message", "error"); zsys_warning ("This is a %s message", "warning"); zsys_notice ("This is a %s message", "notice"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); zsys_set_logident ("hello, world"); zsys_info ("This is a %s message", "info"); zsys_debug ("This is a %s message", "debug"); // Check that logsender functionality is working char *received = zstr_recv (logger); assert (received); zstr_free (&received); } zsys_close (logger, NULL, 0); // @end zsys_set_auto_use_fd (1); assert (zsys_auto_use_fd () == 1); assert (zsys_max_msgsz () == INT_MAX); zsys_set_max_msgsz (2000); assert (zsys_max_msgsz () == 2000); zsys_set_max_msgsz (-1); assert (zsys_max_msgsz () == 2000); #if defined (__WINDOWS__) zsys_shutdown(); #endif printf ("OK\n"); } czmq-4.1.0/src/zdir_patch.c0000664000372000037200000001353013222211156016447 0ustar00travistravis00000000000000/* ========================================================================= zdir_patch - work with directory patches A patch is a change to the directory (create/delete). Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zdir_patch class works with one patch, which says "create this file" or "delete this file" (referring to a zfile item each time). @discuss @end */ #include "czmq_classes.h" // Structure of our class // If you modify this beware to also change _dup struct _zdir_patch_t { char *path; // Directory path char *vpath; // Virtual file path zfile_t *file; // File we refer to int op; // Operation char *digest; // File SHA-1 digest }; // -------------------------------------------------------------------------- // Constructor // Create new patch, create virtual path from alias zdir_patch_t * zdir_patch_new (const char *path, zfile_t *file, int op, const char *alias) { zdir_patch_t *self = (zdir_patch_t *) zmalloc (sizeof (zdir_patch_t)); assert (self); self->path = strdup (path); assert (self->path); self->file = zfile_dup (file); assert (self->file); self->op = op; // Calculate virtual path for patch (remove path, prefix alias) const char *filename = zfile_filename (file, path); assert (filename); assert (*filename != '/'); self->vpath = (char *) zmalloc (strlen (alias) + strlen (filename) + 2); assert (self->vpath); if (strlen (alias) && alias [strlen (alias) - 1] == '/') sprintf (self->vpath, "%s%s", alias, filename); else sprintf (self->vpath, "%s/%s", alias, filename); return self; } // -------------------------------------------------------------------------- // Destroy a patch void zdir_patch_destroy (zdir_patch_t **self_p) { assert (self_p); if (*self_p) { zdir_patch_t *self = *self_p; freen (self->path); freen (self->vpath); freen (self->digest); zfile_destroy (&self->file); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Create copy of a patch. If the patch is null, or memory was exhausted, // returns null. zdir_patch_t * zdir_patch_dup (zdir_patch_t *self) { if (self) { zdir_patch_t *copy = (zdir_patch_t *) zmalloc (sizeof (zdir_patch_t)); if (copy) { copy->op = self->op; copy->path = strdup (self->path); if (copy->path) copy->file = zfile_dup (self->file); if (copy->file) copy->vpath = strdup (self->vpath); if (copy->vpath) // Don't recalculate hash when we duplicate patch copy->digest = self->digest? strdup (self->digest): NULL; if (copy->digest == NULL && copy->op != patch_delete) zdir_patch_destroy (©); } return copy; } else return NULL; } // -------------------------------------------------------------------------- // Return patch file directory path const char * zdir_patch_path (zdir_patch_t *self) { assert (self); return self->path; } // -------------------------------------------------------------------------- // Return patch file item zfile_t * zdir_patch_file (zdir_patch_t *self) { assert (self); return self->file; } // -------------------------------------------------------------------------- // Return operation int zdir_patch_op (zdir_patch_t *self) { assert (self); return self->op; } // -------------------------------------------------------------------------- // Return patch virtual file path const char * zdir_patch_vpath (zdir_patch_t *self) { assert (self); return self->vpath; } // -------------------------------------------------------------------------- // Calculate hash digest for file (create only) void zdir_patch_digest_set (zdir_patch_t *self) { if (self->op == patch_create && self->digest == NULL) { self->digest = strdup (zfile_digest (self->file)); assert (self->digest); } } // -------------------------------------------------------------------------- // Return hash digest for patch file (create only) const char * zdir_patch_digest (zdir_patch_t *self) { assert (self); return self->digest; } // -------------------------------------------------------------------------- // Self test of this class void zdir_patch_test (bool verbose) { printf (" * zdir_patch: "); // @selftest const char *SELFTEST_DIR_RW = "src/selftest-rw"; const char *testfile = "bilbo"; const char *prefix = "/"; char *prefixed_testfile = zsys_sprintf ("%s%s", prefix, testfile); assert (prefixed_testfile); // Make sure old aborted tests do not hinder us zsys_file_delete (prefixed_testfile); zfile_t *file = zfile_new (SELFTEST_DIR_RW, testfile); assert (file); zdir_patch_t *patch = zdir_patch_new (SELFTEST_DIR_RW, file, patch_create, prefix); assert (patch); zfile_destroy (&file); file = zdir_patch_file (patch); assert (file); assert (streq (zfile_filename (file, SELFTEST_DIR_RW), testfile)); assert (streq (zdir_patch_vpath (patch), prefixed_testfile)); zdir_patch_destroy (&patch); zstr_free (&prefixed_testfile); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/czmq_selftest.c0000664000372000037200000001635513222211156017213 0ustar00travistravis00000000000000/* ========================================================================= czmq_selftest.c - run selftests Runs all selftests. ------------------------------------------------------------------------- Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ ========================================================================= */ #include "czmq_classes.h" typedef struct { const char *testname; void (*test) (bool); } test_item_t; static test_item_t all_tests [] = { // Tests for stable public classes: { "zactor", zactor_test }, { "zarmour", zarmour_test }, { "zcert", zcert_test }, { "zcertstore", zcertstore_test }, { "zchunk", zchunk_test }, { "zclock", zclock_test }, { "zconfig", zconfig_test }, { "zdigest", zdigest_test }, { "zdir", zdir_test }, { "zdir_patch", zdir_patch_test }, { "zfile", zfile_test }, { "zframe", zframe_test }, { "zhash", zhash_test }, { "zhashx", zhashx_test }, { "ziflist", ziflist_test }, { "zlist", zlist_test }, { "zlistx", zlistx_test }, { "zloop", zloop_test }, { "zmsg", zmsg_test }, { "zpoller", zpoller_test }, { "zsock", zsock_test }, { "zstr", zstr_test }, { "zsys", zsys_test }, { "zuuid", zuuid_test }, { "zauth", zauth_test }, { "zbeacon", zbeacon_test }, { "zgossip", zgossip_test }, { "zmonitor", zmonitor_test }, { "zproxy", zproxy_test }, { "zrex", zrex_test }, #ifdef CZMQ_BUILD_DRAFT_API // Tests for draft public classes: { "zargs", zargs_test }, { "zproc", zproc_test }, { "ztimerset", ztimerset_test }, { "ztrie", ztrie_test }, #endif // CZMQ_BUILD_DRAFT_API #ifdef CZMQ_BUILD_DRAFT_API { "private_classes", czmq_private_selftest }, #endif // CZMQ_BUILD_DRAFT_API {0, 0} // Sentinel }; // ------------------------------------------------------------------------- // Test whether a test is available. // Return a pointer to a test_item_t if available, NULL otherwise. // test_item_t * test_available (const char *testname) { test_item_t *item; for (item = all_tests; item->test; item++) { if (streq (testname, item->testname)) return item; } return NULL; } // ------------------------------------------------------------------------- // Run all tests. // static void test_runall (bool verbose) { test_item_t *item; printf ("Running czmq selftests...\n"); for (item = all_tests; item->test; item++) item->test (verbose); printf ("Tests passed OK\n"); } int main (int argc, char **argv) { bool verbose = false; test_item_t *test = 0; int argn; for (argn = 1; argn < argc; argn++) { if (streq (argv [argn], "--help") || streq (argv [argn], "-h")) { puts ("czmq_selftest.c [options] ..."); puts (" --verbose / -v verbose test output"); puts (" --number / -n report number of tests"); puts (" --list / -l list all tests"); puts (" --test / -t [name] run only test 'name'"); puts (" --continue / -c continue on exception (on Windows)"); return 0; } if (streq (argv [argn], "--verbose") || streq (argv [argn], "-v")) verbose = true; else if (streq (argv [argn], "--number") || streq (argv [argn], "-n")) { puts ("35"); return 0; } else if (streq (argv [argn], "--list") || streq (argv [argn], "-l")) { puts ("Available tests:"); puts (" zactor\t\t- stable"); puts (" zargs\t\t- draft"); puts (" zarmour\t\t- stable"); puts (" zcert\t\t- stable"); puts (" zcertstore\t\t- stable"); puts (" zchunk\t\t- stable"); puts (" zclock\t\t- stable"); puts (" zconfig\t\t- stable"); puts (" zdigest\t\t- stable"); puts (" zdir\t\t- stable"); puts (" zdir_patch\t\t- stable"); puts (" zfile\t\t- stable"); puts (" zframe\t\t- stable"); puts (" zhash\t\t- stable"); puts (" zhashx\t\t- stable"); puts (" ziflist\t\t- stable"); puts (" zlist\t\t- stable"); puts (" zlistx\t\t- stable"); puts (" zloop\t\t- stable"); puts (" zmsg\t\t- stable"); puts (" zpoller\t\t- stable"); puts (" zproc\t\t- draft"); puts (" zsock\t\t- stable"); puts (" zstr\t\t- stable"); puts (" zsys\t\t- stable"); puts (" ztimerset\t\t- draft"); puts (" ztrie\t\t- draft"); puts (" zuuid\t\t- stable"); puts (" zauth\t\t- stable"); puts (" zbeacon\t\t- stable"); puts (" zgossip\t\t- stable"); puts (" zmonitor\t\t- stable"); puts (" zproxy\t\t- stable"); puts (" zrex\t\t- stable"); puts (" private_classes\t- draft"); return 0; } else if (streq (argv [argn], "--test") || streq (argv [argn], "-t")) { argn++; if (argn >= argc) { fprintf (stderr, "--test needs an argument\n"); return 1; } test = test_available (argv [argn]); if (!test) { fprintf (stderr, "%s not valid, use --list to show tests\n", argv [argn]); return 1; } } else if (streq (argv [argn], "--continue") || streq (argv [argn], "-c")) { #ifdef _MSC_VER // When receiving an abort signal, only print to stderr (no dialog) _set_abort_behavior (0, _WRITE_ABORT_MSG); #endif } else { printf ("Unknown option: %s\n", argv [argn]); return 1; } } #ifdef NDEBUG printf(" !!! 'assert' macro is disabled, remove NDEBUG from your compilation definitions.\n"); printf(" tests will be meaningless.\n"); #endif // if (test) { printf ("Running czmq test '%s'...\n", test->testname); test->test (verbose); } else test_runall (verbose); return 0; } /* ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ */ czmq-4.1.0/src/libczmq.pc.in0000664000372000037200000000167513222211156016555 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: libczmq Description: The high-level C binding for 0MQ Version: @VERSION@ Requires:@pkgconfig_name_libzmq@ Libs: -L${libdir} -lczmq Cflags: -I${includedir} @pkg_config_defines@ Libs.private: @pkg_config_libs_private@ ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/src/zrex.c0000664000372000037200000002336613222211156015320 0ustar00travistravis00000000000000/* ========================================================================= zrex - work with regular expressions Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Wraps a very simple regular expression library (SLRE) as a CZMQ class. Supports this syntax: ^ Match beginning of a buffer $ Match end of a buffer () Grouping and substring capturing [...] Match any character from set [^...] Match any character but ones from set . Match any character \s Match whitespace \S Match non-whitespace \d Match decimal digit \D Match non decimal digit \a Match alphabetic character \A Match non-alphabetic character \w Match alphanumeric character \W Match non-alphanumeric character \r Match carriage return \n Match newline + Match one or more times (greedy) +? Match one or more times (non-greedy) * Match zero or more times (greedy) *? Match zero or more times (non-greedy) ? Match zero or once \xDD Match byte with hex value 0xDD \meta Match one of the meta character: ^$().[*+?\ @discuss @end */ #include "czmq_classes.h" #include "foreign/slre/slre.inc_c" #define MAX_HITS 100 // Should be enough for anyone :) // Structure of our class struct _zrex_t { struct slre slre; // Compiled regular expression bool valid; // Is expression valid or not? const char *strerror; // Error message if any uint hits; // Number of hits matched size_t hit_set_len; // Length of hit set char *hit_set; // Captured hits as single string char *hit [MAX_HITS]; // Pointers into hit_set struct cap caps [MAX_HITS]; // Position/length for each hit }; // -------------------------------------------------------------------------- // Constructor. Optionally, sets an expression against which we can match // text and capture hits. If there is an error in the expression, reports // zrex_valid() as false and provides the error in zrex_strerror(). If you // set a pattern, you can call zrex_matches() to test it against text. zrex_t * zrex_new (const char *expression) { zrex_t *self = (zrex_t *) zmalloc (sizeof (zrex_t)); assert (self); self->strerror = "No error"; if (expression) { // Returns 1 on success, 0 on failure self->valid = (slre_compile (&self->slre, expression) == 1); if (!self->valid) self->strerror = self->slre.err_str; assert (self->slre.num_caps < MAX_HITS); } return self; } // -------------------------------------------------------------------------- // Destructor void zrex_destroy (zrex_t **self_p) { assert (self_p); if (*self_p) { zrex_t *self = *self_p; zstr_free (&self->hit_set); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Return true if the expression was valid and compiled without errors. bool zrex_valid (zrex_t *self) { assert (self); return self->valid; } // -------------------------------------------------------------------------- // Return the error message generated during compilation of the expression. const char * zrex_strerror (zrex_t *self) { assert (self); return self->strerror; } // -------------------------------------------------------------------------- // Returns true if the text matches the previously compiled expression. // Use this method to compare one expression against many strings. bool zrex_matches (zrex_t *self, const char *text) { assert (self); assert (text); // Free any previously-allocated hits self->hits = 0; bool matches = slre_match (&self->slre, text, strlen (text), self->caps) != 0; if (matches) { // Count number of captures plus whole string self->hits = self->slre.num_caps + 1; if (self->hits > MAX_HITS) self->hits = MAX_HITS; // Collect hits and prepare hit array, which is a single block of // memory holding all hits as null-terminated strings uint index; // First count total length of hit strings size_t hit_set_len = 0; for (index = 0; index < self->hits; index++) hit_set_len += self->caps [index].len + 1; if (hit_set_len > self->hit_set_len) { zstr_free (&self->hit_set); self->hit_set = (char *) zmalloc (hit_set_len); self->hit_set_len = hit_set_len; } // FIXME: no way to return an error assert (self->hit_set); // Now prepare hit strings for access by caller char *hit_set_ptr = self->hit_set; for (index = 0; index < self->hits; index++) { memcpy (hit_set_ptr, self->caps [index].ptr, self->caps [index].len); self->hit [index] = hit_set_ptr; hit_set_ptr += self->caps [index].len + 1; } } return matches; } // -------------------------------------------------------------------------- // Returns true if the text matches the supplied expression. Use this // method to compare one string against several expressions. bool zrex_eq (zrex_t *self, const char *text, const char *expression) { assert (self); assert (text); assert (expression); // Compile the new expression self->valid = (slre_compile (&self->slre, expression) == 1); if (!self->valid) self->strerror = self->slre.err_str; assert (self->slre.num_caps < MAX_HITS); // zrex_matches takes care of the rest for us if (self->valid) return zrex_matches (self, text); else return false; } // -------------------------------------------------------------------------- // Returns number of hits from last zrex_matches or zrex_eq. If the text // matched, returns 1 plus the number of capture groups. If the text did // not match, returns zero. To retrieve individual capture groups, call // zrex_hit (). int zrex_hits (zrex_t *self) { assert (self); return self->hits; } // -------------------------------------------------------------------------- // Returns the Nth capture group from the last expression match, where // N is 0 to the value returned by zrex_hits(). Capture group 0 is the // whole matching string. Sequence 1 is the first capture group, if any, // and so on. const char * zrex_hit (zrex_t *self, uint index) { assert (self); if (index < self->hits) return self->hit [index]; else return NULL; } // -------------------------------------------------------------------------- // Fetches hits into string variables provided by caller; this makes for // nicer code than accessing hits by index. Caller should not modify nor // free the returned values. Returns number of strings returned. This // method starts at hit 1, i.e. first capture group, as hit 0 is always // the original matched string. int zrex_fetch (zrex_t *self, const char **string_p, ...) { assert (self); va_list args; va_start (args, string_p); uint index = 0; while (string_p) { *string_p = zrex_hit (self, ++index); string_p = va_arg (args, const char **); } va_end (args); return index; } // -------------------------------------------------------------------------- // Selftest void zrex_test (bool verbose) { printf (" * zrex: "); // @selftest // This shows the pattern of matching many lines to a single pattern zrex_t *rex = zrex_new ("\\d+-\\d+-\\d+"); assert (rex); assert (zrex_valid (rex)); bool matches = zrex_matches (rex, "123-456-789"); assert (matches); assert (zrex_hits (rex) == 1); assert (streq (zrex_hit (rex, 0), "123-456-789")); assert (zrex_hit (rex, 1) == NULL); zrex_destroy (&rex); // Here we pick out hits using capture groups rex = zrex_new ("(\\d+)-(\\d+)-(\\d+)"); assert (rex); assert (zrex_valid (rex)); matches = zrex_matches (rex, "123-456-ABC"); assert (!matches); matches = zrex_matches (rex, "123-456-789"); assert (matches); assert (zrex_hits (rex) == 4); assert (streq (zrex_hit (rex, 0), "123-456-789")); assert (streq (zrex_hit (rex, 1), "123")); assert (streq (zrex_hit (rex, 2), "456")); assert (streq (zrex_hit (rex, 3), "789")); zrex_destroy (&rex); // This shows the pattern of matching one line against many // patterns and then handling the case when it hits rex = zrex_new (NULL); // No initial pattern assert (rex); char *input = "Mechanism: CURVE"; matches = zrex_eq (rex, input, "Version: (.+)"); assert (!matches); assert (zrex_hits (rex) == 0); matches = zrex_eq (rex, input, "Mechanism: (.+)"); assert (matches); assert (zrex_hits (rex) == 2); const char *mechanism; zrex_fetch (rex, &mechanism, NULL); assert (streq (zrex_hit (rex, 1), "CURVE")); assert (streq (mechanism, "CURVE")); zrex_destroy (&rex); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/foreign/0000775000372000037200000000000013222211351015600 5ustar00travistravis00000000000000czmq-4.1.0/src/foreign/sha1/0000775000372000037200000000000013222211351016434 5ustar00travistravis00000000000000czmq-4.1.0/src/foreign/sha1/sha1.h0000664000372000037200000000511713222211156017450 0ustar00travistravis00000000000000/* contrib/pgcrypto/sha1.h */ /* $KAME: sha1.h,v 1.4 2000/02/22 14:01:18 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) * based on: http://www.itl.nist.gov/fipspubs/fip180-1.htm * implemented by Jun-ichiro itojun Itoh */ #ifndef _NETINET6_SHA1_H_ #define _NETINET6_SHA1_H_ struct sha1_ctxt { union { uint8_t b8[20]; uint32_t b32[5]; } h; union { uint8_t b8[8]; uint64_t b64[1]; } c; union { uint8_t b8[64]; uint32_t b32[16]; } m; uint8_t count; }; extern void sha1_init(struct sha1_ctxt *); extern void sha1_pad(struct sha1_ctxt *); extern void sha1_loop(struct sha1_ctxt *, const uint8_t *, size_t); extern void sha1_result(struct sha1_ctxt *, uint8_t *); // Compatibility with OpenSSL API #define SHA_DIGEST_LENGTH 20 typedef struct sha1_ctxt SHA_CTX; #define SHA1_Init(x) sha1_init((x)) #define SHA1_Update(x, y, z) sha1_loop((x), (y), (z)) #define SHA1_Final(x, y) sha1_result((y), (x)) #define SHA1_RESULTLEN (160/8) #endif /* _NETINET6_SHA1_H_ */ czmq-4.1.0/src/foreign/sha1/sha1.inc_c0000664000372000037200000002100313222211156020264 0ustar00travistravis00000000000000/* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) * based on: http://www.itl.nist.gov/fipspubs/fip180-1.htm * implemented by Jun-ichiro itojun Itoh */ #include "../../../include/czmq.h" #include "sha1.h" /* constant table */ static uint32_t _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6}; #define K(t) _K[(t) / 20] #define F0(b, c, d) (((b) & (c)) | ((~(b)) & (d))) #define F1(b, c, d) (((b) ^ (c)) ^ (d)) #define F2(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) #define F3(b, c, d) (((b) ^ (c)) ^ (d)) #define S(n, x) (((x) << (n)) | ((x) >> (32 - (n)))) #define H(n) (ctxt->h.b32[(n)]) #define COUNT (ctxt->count) #define BCOUNT (ctxt->c.b64[0] / 8) #define W(n) (ctxt->m.b32[(n)]) #define PUTBYTE(x) \ do { \ ctxt->m.b8[(COUNT % 64)] = (x); \ COUNT++; \ COUNT %= 64; \ ctxt->c.b64[0] += 8; \ if (COUNT % 64 == 0) \ sha1_step(ctxt); \ } while (0) #define PUTPAD(x) \ do { \ ctxt->m.b8[(COUNT % 64)] = (x); \ COUNT++; \ COUNT %= 64; \ if (COUNT % 64 == 0) \ sha1_step(ctxt); \ } while (0) static void sha1_step(struct sha1_ctxt *); static void sha1_step(struct sha1_ctxt * ctxt) { uint32_t a, b, c, d, e; size_t t, s; uint32_t tmp; #ifndef WORDS_BIGENDIAN struct sha1_ctxt tctxt; memmove(&tctxt.m.b8[0], &ctxt->m.b8[0], 64); ctxt->m.b8[0] = tctxt.m.b8[3]; ctxt->m.b8[1] = tctxt.m.b8[2]; ctxt->m.b8[2] = tctxt.m.b8[1]; ctxt->m.b8[3] = tctxt.m.b8[0]; ctxt->m.b8[4] = tctxt.m.b8[7]; ctxt->m.b8[5] = tctxt.m.b8[6]; ctxt->m.b8[6] = tctxt.m.b8[5]; ctxt->m.b8[7] = tctxt.m.b8[4]; ctxt->m.b8[8] = tctxt.m.b8[11]; ctxt->m.b8[9] = tctxt.m.b8[10]; ctxt->m.b8[10] = tctxt.m.b8[9]; ctxt->m.b8[11] = tctxt.m.b8[8]; ctxt->m.b8[12] = tctxt.m.b8[15]; ctxt->m.b8[13] = tctxt.m.b8[14]; ctxt->m.b8[14] = tctxt.m.b8[13]; ctxt->m.b8[15] = tctxt.m.b8[12]; ctxt->m.b8[16] = tctxt.m.b8[19]; ctxt->m.b8[17] = tctxt.m.b8[18]; ctxt->m.b8[18] = tctxt.m.b8[17]; ctxt->m.b8[19] = tctxt.m.b8[16]; ctxt->m.b8[20] = tctxt.m.b8[23]; ctxt->m.b8[21] = tctxt.m.b8[22]; ctxt->m.b8[22] = tctxt.m.b8[21]; ctxt->m.b8[23] = tctxt.m.b8[20]; ctxt->m.b8[24] = tctxt.m.b8[27]; ctxt->m.b8[25] = tctxt.m.b8[26]; ctxt->m.b8[26] = tctxt.m.b8[25]; ctxt->m.b8[27] = tctxt.m.b8[24]; ctxt->m.b8[28] = tctxt.m.b8[31]; ctxt->m.b8[29] = tctxt.m.b8[30]; ctxt->m.b8[30] = tctxt.m.b8[29]; ctxt->m.b8[31] = tctxt.m.b8[28]; ctxt->m.b8[32] = tctxt.m.b8[35]; ctxt->m.b8[33] = tctxt.m.b8[34]; ctxt->m.b8[34] = tctxt.m.b8[33]; ctxt->m.b8[35] = tctxt.m.b8[32]; ctxt->m.b8[36] = tctxt.m.b8[39]; ctxt->m.b8[37] = tctxt.m.b8[38]; ctxt->m.b8[38] = tctxt.m.b8[37]; ctxt->m.b8[39] = tctxt.m.b8[36]; ctxt->m.b8[40] = tctxt.m.b8[43]; ctxt->m.b8[41] = tctxt.m.b8[42]; ctxt->m.b8[42] = tctxt.m.b8[41]; ctxt->m.b8[43] = tctxt.m.b8[40]; ctxt->m.b8[44] = tctxt.m.b8[47]; ctxt->m.b8[45] = tctxt.m.b8[46]; ctxt->m.b8[46] = tctxt.m.b8[45]; ctxt->m.b8[47] = tctxt.m.b8[44]; ctxt->m.b8[48] = tctxt.m.b8[51]; ctxt->m.b8[49] = tctxt.m.b8[50]; ctxt->m.b8[50] = tctxt.m.b8[49]; ctxt->m.b8[51] = tctxt.m.b8[48]; ctxt->m.b8[52] = tctxt.m.b8[55]; ctxt->m.b8[53] = tctxt.m.b8[54]; ctxt->m.b8[54] = tctxt.m.b8[53]; ctxt->m.b8[55] = tctxt.m.b8[52]; ctxt->m.b8[56] = tctxt.m.b8[59]; ctxt->m.b8[57] = tctxt.m.b8[58]; ctxt->m.b8[58] = tctxt.m.b8[57]; ctxt->m.b8[59] = tctxt.m.b8[56]; ctxt->m.b8[60] = tctxt.m.b8[63]; ctxt->m.b8[61] = tctxt.m.b8[62]; ctxt->m.b8[62] = tctxt.m.b8[61]; ctxt->m.b8[63] = tctxt.m.b8[60]; #endif a = H(0); b = H(1); c = H(2); d = H(3); e = H(4); for (t = 0; t < 20; t++) { s = t & 0x0f; if (t >= 16) W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F0(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } for (t = 20; t < 40; t++) { s = t & 0x0f; W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F1(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } for (t = 40; t < 60; t++) { s = t & 0x0f; W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F2(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } for (t = 60; t < 80; t++) { s = t & 0x0f; W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F3(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } H(0) = H(0) + a; H(1) = H(1) + b; H(2) = H(2) + c; H(3) = H(3) + d; H(4) = H(4) + e; memset(&ctxt->m.b8[0], 0, 64); } /*------------------------------------------------------------*/ void sha1_init(struct sha1_ctxt * ctxt) { memset(ctxt, 0, sizeof(struct sha1_ctxt)); H(0) = 0x67452301; H(1) = 0xefcdab89; H(2) = 0x98badcfe; H(3) = 0x10325476; H(4) = 0xc3d2e1f0; } void sha1_pad(struct sha1_ctxt * ctxt) { size_t padlen; /* pad length in bytes */ size_t padstart; PUTPAD(0x80); padstart = COUNT % 64; padlen = 64 - padstart; if (padlen < 8) { memset(&ctxt->m.b8[padstart], 0, padlen); COUNT += (uint8_t) padlen; COUNT %= 64; sha1_step(ctxt); padstart = COUNT % 64; /* should be 0 */ padlen = 64 - padstart; /* should be 64 */ } memset(&ctxt->m.b8[padstart], 0, padlen - 8); COUNT += ((uint8_t) padlen - 8); COUNT %= 64; #ifdef WORDS_BIGENDIAN PUTPAD(ctxt->c.b8[0]); PUTPAD(ctxt->c.b8[1]); PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[3]); PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[5]); PUTPAD(ctxt->c.b8[6]); PUTPAD(ctxt->c.b8[7]); #else PUTPAD(ctxt->c.b8[7]); PUTPAD(ctxt->c.b8[6]); PUTPAD(ctxt->c.b8[5]); PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[3]); PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[1]); PUTPAD(ctxt->c.b8[0]); #endif } void sha1_loop(struct sha1_ctxt * ctxt, const uint8_t *input0, size_t len) { const uint8_t *input; size_t gaplen; size_t gapstart; size_t off; size_t copysiz; input = (const uint8_t *) input0; off = 0; while (off < len) { gapstart = COUNT % 64; gaplen = 64 - gapstart; copysiz = (gaplen < len - off) ? gaplen : len - off; memmove(&ctxt->m.b8[gapstart], &input[off], copysiz); COUNT += (uint8_t) copysiz; COUNT %= 64; ctxt->c.b64[0] += copysiz * 8; if (COUNT % 64 == 0) sha1_step(ctxt); off += copysiz; } } void sha1_result(struct sha1_ctxt * ctxt, uint8_t *digest0) { uint8_t *digest; digest = (uint8_t *) digest0; sha1_pad(ctxt); #ifdef WORDS_BIGENDIAN memmove(digest, &ctxt->h.b8[0], 20); #else digest[0] = ctxt->h.b8[3]; digest[1] = ctxt->h.b8[2]; digest[2] = ctxt->h.b8[1]; digest[3] = ctxt->h.b8[0]; digest[4] = ctxt->h.b8[7]; digest[5] = ctxt->h.b8[6]; digest[6] = ctxt->h.b8[5]; digest[7] = ctxt->h.b8[4]; digest[8] = ctxt->h.b8[11]; digest[9] = ctxt->h.b8[10]; digest[10] = ctxt->h.b8[9]; digest[11] = ctxt->h.b8[8]; digest[12] = ctxt->h.b8[15]; digest[13] = ctxt->h.b8[14]; digest[14] = ctxt->h.b8[13]; digest[15] = ctxt->h.b8[12]; digest[16] = ctxt->h.b8[19]; digest[17] = ctxt->h.b8[18]; digest[18] = ctxt->h.b8[17]; digest[19] = ctxt->h.b8[16]; #endif } czmq-4.1.0/src/foreign/slre/0000775000372000037200000000000013222211351016545 5ustar00travistravis00000000000000czmq-4.1.0/src/foreign/slre/readme.txt0000664000372000037200000000726413222211156020557 0ustar00travistravis00000000000000SLRE - Super Light Regular Expression library Modified 2014-08-26 Pieter Hintjens SLRE is an ANSI C library that implements a tiny subset of Perl regular expressions. It is primarily targeted for developers who want to parse configuation files, where speed is unimportant. It is in single .c file, easily modifiable for custom needs. For example, if one wants to introduce a new metacharacter, '\i', that means 'IP address', it is easy to do so. Features Crossplatform - pure ANSI C Very simple API Light: about 5kB of code when compiled Uses no dynamic memory allocation Thread safe Supported RE Syntax ^ Match beginning of a buffer $ Match end of a buffer () Grouping and substring capturing [...] Match any character from set [^...] Match any character but ones from set . Match any character \s Match whitespace \S Match non-whitespace \d Match decimal digit \D Match non decimal digit \a Match alphabetic character \A Match non-alphabetic character \w Match alphanumeric character \W Match non-alphanumeric character \r Match carriage return \n Match newline + Match one or more times (greedy) +? Match one or more times (non-greedy) * Match zero or more times (greedy) *? Match zero or more times (non-greedy) ? Match zero or once \xDD Match byte with hex value 0xDD \meta Match one of the meta character: ^$().[*+?\ API Two functions represent the API: one is used for compilations of the RE, the other for performing a match. Both functions return 0 on error, and 1 on success. If the round brackets are used in the RE, then matched substrings can be returned back to the caller in the 'struct cap *' array. Array size must be enough to hold all matches: array_size = number_of_round_bracket_pairs + 1. The first element of the array will always hold the substring matched by the whole RE. /* Captured substring */ struct cap { const char *ptr; /* Pointer to the substring */ int len; /* Substring length */ }; int slre_compile(struct slre *, const char *re); int slre_match(const struct slre *, const char *buf, int buf_len, struct cap *captured_substrings); Usage example This example shows how to parse HTTP request line: struct slre slre; struct cap captures[4 + 1]; if (!slre_compile(&slre, "^(GET|POST) (\S+) HTTP/(\S+?)\r\n") { printf("Error compiling RE: %s\n", slre.err_str); } else if (!slre_match(&slre, buf, len, captures)) { printf("Not a valid HTTP request\n" ); } else { printf("Request line length: %d\n", captures[0].len); printf("Method: %.*s\n", captures[1].len, captures[1].ptr); printf("URI: %.*s\n", captures[2].len, captures[2].ptr); } Download Version 1.0: slre.h, slre.c License /* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * Sergey Lyubka wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. * ---------------------------------------------------------------------------- */ Author Copyright © by Sergey Lyubka (valenok at gmail dot com). Feel free to contact me if you want to comply with the license. czmq-4.1.0/src/foreign/slre/slre.h0000664000372000037200000000603113222211156017666 0ustar00travistravis00000000000000/* * Copyright (c) 2004-2005 Sergey Lyubka * All rights reserved * * "THE BEER-WARE LICENSE" (Revision 42): * Sergey Lyubka wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. */ /* * This is a regular expression library that implements a subset of Perl RE. * Please refer to http://slre.sourceforge.net for detailed description. * * Usage example (parsing HTTP request): * * struct slre slre; * struct cap captures[4 + 1]; // Number of braket pairs + 1 * ... * * slre_compile(&slre,"^(GET|POST) (\S+) HTTP/(\S+?)\r\n"); * * if (slre_match(&slre, buf, len, captures)) { * printf("Request line length: %d\n", captures[0].len); * printf("Method: %.*s\n", captures[1].len, captures[1].ptr); * printf("URI: %.*s\n", captures[2].len, captures[2].ptr); * } * * Supported syntax: * ^ Match beginning of a buffer * $ Match end of a buffer * () Grouping and substring capturing * [...] Match any character from set * [^...] Match any character but ones from set * \s Match whitespace * \S Match non-whitespace * \d Match decimal digit * \r Match carriage return * \n Match newline * + Match one or more times (greedy) * +? Match one or more times (non-greedy) * * Match zero or more times (greedy) * *? Match zero or more times (non-greedy) * ? Match zero or once * \xDD Match byte with hex value 0xDD * \meta Match one of the meta character: ^$().[*+?\ */ #ifndef SLRE_HEADER_DEFINED #define SLRE_HEADER_DEFINED /* * Compiled regular expression */ struct slre { unsigned char code[256]; unsigned char data[256]; int code_size; int data_size; int num_caps; /* Number of bracket pairs */ int anchored; /* Must match from string start */ const char *err_str; /* Error string */ }; /* * Captured substring */ struct cap { const char *ptr; /* Pointer to the substring */ size_t len; /* Substring length */ }; /* * Compile regular expression. If success, 1 is returned. * If error, 0 is returned and slre.err_str points to the error message. */ int slre_compile(struct slre *, const char *re); /* * Return 1 if match, 0 if no match. * If `captured_substrings' array is not NULL, then it is filled with the * values of captured substrings. captured_substrings[0] element is always * a full matched substring. The round bracket captures start from * captured_substrings[1]. * It is assumed that the size of captured_substrings array is enough to * hold all captures. The caller function must make sure it is! So, the * array_size = number_of_round_bracket_pairs + 1 */ int slre_match(const struct slre *, const char *buf, size_t buf_len, struct cap *captured_substrings); #endif /* SLRE_HEADER_DEFINED */ czmq-4.1.0/src/foreign/slre/slre.inc_c0000664000372000037200000004541213222211156020520 0ustar00travistravis00000000000000/* * Copyright (c) 2004-2005 Sergey Lyubka * All rights reserved * * "THE BEER-WARE LICENSE" (Revision 42): * Sergey Lyubka wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. */ #include #include #include #include #include #include #include "slre.h" enum { END, BRANCH, ANY, EXACT, ANYOF, ANYBUT, OPEN, CLOSE, BOL, EOL, STAR, PLUS, STARQ, PLUSQ, QUEST, SPACE, NONSPACE, DIGIT, NONDIGIT, ALPHA, NONALPHA, ALNUM, NONALNUM }; static struct { const char *name; int narg; const char *flags; } opcodes [] = { {"END", 0, ""}, /* End of code block or program */ {"BRANCH", 2, "oo"}, /* Alternative operator, "|" */ {"ANY", 0, ""}, /* Match any character, "." */ {"EXACT", 2, "d"}, /* Match exact string */ {"ANYOF", 2, "D"}, /* Match any from set, " []" */ {"ANYBUT", 2, "D"}, /* Match any but from set, " [^]"*/ {"OPEN ", 1, "i"}, /* Capture start, " (" */ {"CLOSE", 1, "i"}, /* Capture end, ")" */ {"BOL", 0, ""}, /* Beginning of string, "^" */ {"EOL", 0, ""}, /* End of string, "$" */ {"STAR", 1, "o"}, /* Match zero or more times "*" */ {"PLUS", 1, "o"}, /* Match one or more times, "+" */ {"STARQ", 1, "o"}, /* Non-greedy STAR, "*?" */ {"PLUSQ", 1, "o"}, /* Non-greedy PLUS, "+?" */ {"QUEST", 1, "o"}, /* Match zero or one time, "?" */ {"SPACE", 0, ""}, /* Match whitespace, "\s" */ {"NONSPACE",0, ""}, /* Match non-space, "\S" */ {"DIGIT", 0, ""}, /* Match digit, "\d" */ {"NONDIGIT",0, ""}, /* Match non-digit, "\D" */ {"ALPHA", 0, ""}, /* Match alpha, "\a" */ {"NONALPHA",0, ""}, /* Match non-alpha, "\A" */ {"ALNUM", 0, ""}, /* Match letter, "\w" */ {"NONALNUM", 0, ""} /* Match non-letter, "\W" */ }; /* * Commands and operands are all unsigned char (1 byte long). All code offsets * are relative to current address, and positive (always point forward). Data * offsets are absolute. Commands with operands: * * BRANCH offset1 offset2 * Try to match the code block that follows the BRANCH instruction * (code block ends with END). If no match, try to match code block that * starts at offset1. If either of these match, jump to offset2. * * EXACT data_offset data_length * Try to match exact string. String is recorded in data section from * data_offset, and has length data_length. * * OPEN capture_number * CLOSE capture_number * If the user have passed 'struct cap' array for captures, OPEN * records the beginning of the matched substring (cap->ptr), CLOSE * sets the length (cap->len) for respective capture_number. * * STAR code_offset * PLUS code_offset * QUEST code_offset * *, +, ?, respectively. Try to gobble as much as possible from the * matched buffer, until code block that follows these instructions * matches. When the longest possible string is matched, * jump to code_offset * * STARQ, PLUSQ are non-greedy versions of STAR and PLUS. */ static const char *meta_chars = "|.^$*+?()[\\"; static void print_character_set (FILE *fp, const unsigned char *p, int len) { int i; for (i = 0; i < len; i++) { if (i > 0) (void) fputc (',', fp); if (p [i] == 0) { i++; if (p [i] == 0) (void) fprintf (fp, "\\x%02x", p [i]); else (void) fprintf (fp, "%s", opcodes [p [i]].name); } else if (isprint (p [i])) (void) fputc (p [i], fp); else (void) fprintf (fp,"\\x%02x", p [i]); } } void slre_dump (const struct slre *r, FILE *fp) { int i, j, ch, op, pc; for (pc = 0; pc < r->code_size; pc++) { op = r->code [pc]; (void) fprintf (fp, "%3d %s ", pc, opcodes [op].name); for (i = 0; opcodes [op].flags [i] != '\0'; i++) switch (opcodes [op].flags [i]) { case 'i': (void) fprintf (fp, "%d ", r->code [pc + 1]); pc++; break; case 'o': (void) fprintf (fp, "%d ", pc + r->code [pc + 1] - i); pc++; break; case 'D': print_character_set (fp, r->data + r->code [pc + 1], r->code [pc + 2]); pc += 2; break; case 'd': (void) fputc ('"', fp); for (j = 0; j < r->code [pc + 2]; j++) { ch = r->data [r->code [pc + 1] + j]; if (isprint (ch)) (void) fputc (ch, fp); else (void) fprintf (fp,"\\x%02x",ch); } (void) fputc ('"', fp); pc += 2; break; } (void) fputc ('\n', fp); } } static void set_jump_offset (struct slre *r, int pc, int offset) { assert (offset < r->code_size); if (r->code_size - offset > 0xff) r->err_str = "Jump offset is too big"; else r->code [pc] = (unsigned char) (r->code_size - offset); } static void emit (struct slre *r, int code) { if (r->code_size >= (int) (sizeof (r->code) / sizeof (r->code [0]))) r->err_str = "RE is too long (code overflow)"; else r->code [r->code_size++] = (unsigned char) code; } static void store_char_in_data (struct slre *r, int ch) { if (r->data_size >= (int) sizeof (r->data)) r->err_str = "RE is too long (data overflow)"; else r->data [r->data_size++] = ch; } static void exact (struct slre *r, const char **re) { int old_data_size = r->data_size; while (**re != '\0' && (strchr (meta_chars, **re)) == NULL) store_char_in_data (r, *(*re)++); emit (r, EXACT); emit (r, old_data_size); emit (r, r->data_size - old_data_size); } static int get_escape_char (const char **re) { int res; switch (*(*re)++) { case 'n': res = '\n'; break; case 'r': res = '\r'; break; case 't': res = '\t'; break; case '0': res = 0; break; case 's': res = SPACE << 8; break; case 'S': res = NONSPACE << 8; break; case 'd': res = DIGIT << 8; break; case 'D': res = NONDIGIT << 8; break; case 'a': res = ALPHA << 8; break; case 'A': res = NONALPHA << 8; break; case 'w': res = ALNUM << 8; break; case 'W': res = NONALNUM << 8; break; default: res = (*re) [-1]; break; } return (res); } static void anyof (struct slre *r, const char **re) { int esc, old_data_size = r->data_size, op = ANYOF; if (**re == '^') { op = ANYBUT; (*re)++; } while (**re != '\0') { switch (*(*re)++) { case ']': emit (r, op); emit (r, old_data_size); emit (r, r->data_size - old_data_size); return; /* NOTREACHED */ break; case '\\': esc = get_escape_char (re); if ((esc & 0xff) == 0) { store_char_in_data (r, 0); store_char_in_data (r, esc >> 8); } else store_char_in_data (r, esc); break; default: store_char_in_data (r, (*re) [-1]); break; } } r->err_str = "No closing ']' bracket"; } static void relocate (struct slre *r, int begin, int shift) { emit (r, END); memmove (r->code + begin + shift, r->code + begin, r->code_size - begin); r->code_size += shift; } static void quantifier (struct slre *r, int prev, int op) { if (r->code [prev] == EXACT && r->code [prev + 2] > 1) { r->code [prev + 2]--; emit (r, EXACT); emit (r, r->code [prev + 1] + r->code [prev + 2]); emit (r, 1); prev = r->code_size - 3; } relocate (r, prev, 2); r->code [prev] = op; set_jump_offset (r, prev + 1, prev); } static void exact_one_char (struct slre *r, int ch) { emit (r, EXACT); emit (r, r->data_size); emit (r, 1); store_char_in_data (r, ch); } static void fixup_branch (struct slre *r, int fixup) { if (fixup > 0) { emit (r, END); set_jump_offset (r, fixup, fixup - 2); } } static void compile (struct slre *r, const char **re) { int op, esc, branch_start, last_op, fixup, cap_no, level; fixup = 0; level = r->num_caps; branch_start = last_op = r->code_size; for (;;) { switch (*(*re)++) { case '\0': (*re)--; return; case '^': emit (r, BOL); break; case '$': emit (r, EOL); break; case '.': last_op = r->code_size; emit (r, ANY); break; case '[': last_op = r->code_size; anyof (r, re); break; case '\\': last_op = r->code_size; esc = get_escape_char (re); if (esc & 0xff00) emit (r, esc >> 8); else exact_one_char (r, esc); break; case '(': last_op = r->code_size; cap_no = ++r->num_caps; emit (r, OPEN); emit (r, cap_no); compile (r, re); if (*(*re)++ != ')') { r->err_str = "No closing bracket"; return; } emit (r, CLOSE); emit (r, cap_no); break; case ')': (*re)--; fixup_branch (r, fixup); if (level == 0) { r->err_str = "Unbalanced brackets"; return; } return; case '+': case '*': op = (*re) [-1] == '*' ? STAR: PLUS; if (**re == '?') { (*re)++; op = op == STAR ? STARQ : PLUSQ; } quantifier (r, last_op, op); break; case '?': quantifier (r, last_op, QUEST); break; case '|': fixup_branch (r, fixup); relocate (r, branch_start, 3); r->code [branch_start] = BRANCH; set_jump_offset (r, branch_start + 1, branch_start); fixup = branch_start + 2; r->code [fixup] = 0xff; break; default: (*re)--; last_op = r->code_size; exact (r, re); break; } } } int slre_compile (struct slre *r, const char *re) { r->err_str = NULL; r->code_size = r->data_size = r->num_caps = r->anchored = 0; if (*re == '^') r->anchored++; emit (r, OPEN); /* This will capture what matches full RE */ emit (r, 0); while (*re != '\0') compile (r, &re); if (r->code [2] == BRANCH) fixup_branch (r, 4); emit (r, CLOSE); emit (r, 0); emit (r, END); return (r->err_str == NULL? 1: 0); } static int match (const struct slre *, int, const char *, size_t, size_t *, struct cap *); static void loop_greedy (const struct slre *r, int pc, const char *s, size_t len, size_t *ofs) { size_t saved_offset, matched_offset; saved_offset = matched_offset = *ofs; while (match (r, pc + 2, s, len, ofs, NULL)) { saved_offset = *ofs; if (match (r, pc + r->code [pc + 1], s, len, ofs, NULL)) matched_offset = saved_offset; *ofs = saved_offset; } *ofs = matched_offset; } static void loop_non_greedy (const struct slre *r, int pc, const char *s, size_t len, size_t *ofs) { size_t saved_offset = *ofs; while (match (r, pc + 2, s, len, ofs, NULL)) { saved_offset = *ofs; if (match (r, pc + r->code [pc + 1], s, len, ofs, NULL)) break; } *ofs = saved_offset; } static int is_any_of (const unsigned char *p, int len, const char *s, size_t *ofs) { int i, ch; ch = s [*ofs]; for (i = 0; i < len; i++) if (p [i] == ch) { (*ofs)++; return (1); } return (0); } static int is_any_but (const unsigned char *p, int len, const char *s, size_t *ofs) { int i, ch; ch = s [*ofs]; for (i = 0; i < len; i++) if (p [i] == ch) return (0); (*ofs)++; return (1); } static int match (const struct slre *r, int pc, const char *s, size_t len, size_t *ofs, struct cap *caps) { int res = 1; size_t n, saved_offset; while (res && r->code [pc] != END) { assert (pc < r->code_size); assert (pc < (int) (sizeof (r->code) / sizeof (r->code [0]))); switch (r->code [pc]) { case BRANCH: saved_offset = *ofs; res = match (r, pc + 3, s, len, ofs, caps); if (res == 0) { *ofs = saved_offset; res = match (r, pc + r->code [pc + 1], s, len, ofs, caps); } pc += r->code [pc + 2]; break; case EXACT: res = 0; n = r->code [pc + 2]; /* String length */ if (n <= len - *ofs && !memcmp (s + *ofs, r->data + r->code [pc + 1], n)) { (*ofs) += n; res = 1; } pc += 3; break; case QUEST: res = 1; saved_offset = *ofs; if (!match (r, pc + 2, s, len, ofs, caps)) *ofs = saved_offset; pc += r->code [pc + 1]; break; case STAR: res = 1; loop_greedy (r, pc, s, len, ofs); pc += r->code [pc + 1]; break; case STARQ: res = 1; loop_non_greedy (r, pc, s, len, ofs); pc += r->code [pc + 1]; break; case PLUS: if ((res = match (r, pc + 2, s, len, ofs, caps)) == 0) break; loop_greedy (r, pc, s, len, ofs); pc += r->code [pc + 1]; break; case PLUSQ: if ((res = match (r, pc + 2, s, len, ofs, caps)) == 0) break; loop_non_greedy (r, pc, s, len, ofs); pc += r->code [pc + 1]; break; case SPACE: res = 0; if (*ofs < len && isspace (((unsigned char *)s) [*ofs])) { (*ofs)++; res = 1; } pc++; break; case NONSPACE: res = 0; if (*ofs data + r->code [pc + 1], r->code [pc + 2], s, ofs); pc += 3; break; case ANYBUT: res = 0; if (*ofs < len) res = is_any_but (r->data + r->code [pc + 1], r->code [pc + 2], s, ofs); pc += 3; break; case BOL: res = *ofs == 0 ? 1 : 0; pc++; break; case EOL: res = *ofs == len ? 1 : 0; pc++; break; case OPEN: if (caps != NULL) caps [r->code [pc + 1]].ptr = s + *ofs; pc += 2; break; case CLOSE: if (caps != NULL) caps [r->code [pc + 1]].len = (s + *ofs) - caps [r->code [pc + 1]].ptr; pc += 2; break; case END: pc++; break; default: printf ("unknown cmd (%d) at %d\n", r->code [pc], pc); assert (0); break; } } return (res); } int slre_match(const struct slre *r, const char *buf, size_t len, struct cap *caps) { int res = 0; size_t ofs = 0; if (r->anchored) res = match (r, 0, buf, len, &ofs, caps); else { size_t i; for (i = 0; i < len && res == 0; i++) { ofs = i; res = match (r, 0, buf, len, &ofs, caps); } } return (res); } czmq-4.1.0/src/zsock_option.inc0000664000372000037200000041167013222211156017377 0ustar00travistravis00000000000000/* ========================================================================= zsock_option - get/set ZeroMQ socket options ****************************************************************** * GENERATED SOURCE CODE, DO NOT EDIT!! * * TO CHANGE THIS FILE: * * - EDIT src/zsock_option.gsl and/or * * - EDIT src/zsock_option.xml and then * * - RUN 'make code' * ****************************************************************** Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for ZeroMQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ // -------------------------------------------------------------------------- // Set socket ZMQ_HEARTBEAT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl) { assert (self); # if defined (ZMQ_HEARTBEAT_IVL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock heartbeat_ivl option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_HEARTBEAT_IVL, &heartbeat_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_HEARTBEAT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_heartbeat_ivl (void *self) { assert (self); # if defined (ZMQ_HEARTBEAT_IVL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock heartbeat_ivl option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } int heartbeat_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_HEARTBEAT_IVL, &heartbeat_ivl, &option_len); return heartbeat_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_HEARTBEAT_TTL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl) { assert (self); # if defined (ZMQ_HEARTBEAT_TTL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock heartbeat_ttl option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_HEARTBEAT_TTL, &heartbeat_ttl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_HEARTBEAT_TTL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_heartbeat_ttl (void *self) { assert (self); # if defined (ZMQ_HEARTBEAT_TTL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock heartbeat_ttl option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } int heartbeat_ttl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_HEARTBEAT_TTL, &heartbeat_ttl, &option_len); return heartbeat_ttl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_HEARTBEAT_TIMEOUT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout) { assert (self); # if defined (ZMQ_HEARTBEAT_TIMEOUT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock heartbeat_timeout option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_HEARTBEAT_TIMEOUT, &heartbeat_timeout, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_HEARTBEAT_TIMEOUT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_heartbeat_timeout (void *self) { assert (self); # if defined (ZMQ_HEARTBEAT_TIMEOUT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock heartbeat_timeout option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } int heartbeat_timeout; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_HEARTBEAT_TIMEOUT, &heartbeat_timeout, &option_len); return heartbeat_timeout; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_USE_FD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_use_fd (void *self, int use_fd) { assert (self); # if defined (ZMQ_USE_FD) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock use_fd option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_USE_FD, &use_fd, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_USE_FD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_use_fd (void *self) { assert (self); # if defined (ZMQ_USE_FD) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock use_fd option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } int use_fd; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_USE_FD, &use_fd, &option_len); return use_fd; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_XPUB_MANUAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_xpub_manual (void *self, int xpub_manual) { assert (self); # if defined (ZMQ_XPUB_MANUAL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock xpub_manual option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_XPUB) { printf ("ZMQ_XPUB_MANUAL is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_XPUB_MANUAL, &xpub_manual, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_XPUB_WELCOME_MSG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_xpub_welcome_msg (void *self, const char * xpub_welcome_msg) { assert (self); # if defined (ZMQ_XPUB_WELCOME_MSG) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock xpub_welcome_msg option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_XPUB) { printf ("ZMQ_XPUB_WELCOME_MSG is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_XPUB_WELCOME_MSG, xpub_welcome_msg, strlen (xpub_welcome_msg)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_STREAM_NOTIFY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_stream_notify (void *self, int stream_notify) { assert (self); # if defined (ZMQ_STREAM_NOTIFY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock stream_notify option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_STREAM) { printf ("ZMQ_STREAM_NOTIFY is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_STREAM_NOTIFY, &stream_notify, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_INVERT_MATCHING value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_invert_matching (void *self, int invert_matching) { assert (self); # if defined (ZMQ_INVERT_MATCHING) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock invert_matching option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_XPUB && zsock_type (self) != ZMQ_PUB && zsock_type (self) != ZMQ_SUB) { printf ("ZMQ_INVERT_MATCHING is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_INVERT_MATCHING, &invert_matching, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_INVERT_MATCHING value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_invert_matching (void *self) { assert (self); # if defined (ZMQ_INVERT_MATCHING) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock invert_matching option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } int invert_matching; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_INVERT_MATCHING, &invert_matching, &option_len); return invert_matching; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_XPUB_VERBOSER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_xpub_verboser (void *self, int xpub_verboser) { assert (self); # if defined (ZMQ_XPUB_VERBOSER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock xpub_verboser option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_XPUB) { printf ("ZMQ_XPUB_VERBOSER is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_XPUB_VERBOSER, &xpub_verboser, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CONNECT_TIMEOUT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_connect_timeout (void *self, int connect_timeout) { assert (self); # if defined (ZMQ_CONNECT_TIMEOUT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock connect_timeout option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CONNECT_TIMEOUT, &connect_timeout, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CONNECT_TIMEOUT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_connect_timeout (void *self) { assert (self); # if defined (ZMQ_CONNECT_TIMEOUT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock connect_timeout option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } int connect_timeout; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_CONNECT_TIMEOUT, &connect_timeout, &option_len); return connect_timeout; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_MAXRT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_maxrt (void *self, int tcp_maxrt) { assert (self); # if defined (ZMQ_TCP_MAXRT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock tcp_maxrt option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_MAXRT, &tcp_maxrt, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_MAXRT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_maxrt (void *self) { assert (self); # if defined (ZMQ_TCP_MAXRT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock tcp_maxrt option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } int tcp_maxrt; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_MAXRT, &tcp_maxrt, &option_len); return tcp_maxrt; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_THREAD_SAFE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_thread_safe (void *self) { assert (self); # if defined (ZMQ_THREAD_SAFE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock thread_safe option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } int thread_safe; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_THREAD_SAFE, &thread_safe, &option_len); return thread_safe; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MULTICAST_MAXTPDU value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu) { assert (self); # if defined (ZMQ_MULTICAST_MAXTPDU) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock multicast_maxtpdu option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MULTICAST_MAXTPDU, &multicast_maxtpdu, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MULTICAST_MAXTPDU value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_multicast_maxtpdu (void *self) { assert (self); # if defined (ZMQ_MULTICAST_MAXTPDU) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock multicast_maxtpdu option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } int multicast_maxtpdu; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_MULTICAST_MAXTPDU, &multicast_maxtpdu, &option_len); return multicast_maxtpdu; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_VMCI_BUFFER_SIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size) { assert (self); # if defined (ZMQ_VMCI_BUFFER_SIZE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock vmci_buffer_size option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } uint64_t value = vmci_buffer_size; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_VMCI_BUFFER_SIZE, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_VMCI_BUFFER_SIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_vmci_buffer_size (void *self) { assert (self); # if defined (ZMQ_VMCI_BUFFER_SIZE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock vmci_buffer_size option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } uint64_t vmci_buffer_size; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_VMCI_BUFFER_SIZE, &vmci_buffer_size, &option_len); return (int) vmci_buffer_size; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_VMCI_BUFFER_MIN_SIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size) { assert (self); # if defined (ZMQ_VMCI_BUFFER_MIN_SIZE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock vmci_buffer_min_size option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } uint64_t value = vmci_buffer_min_size; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_VMCI_BUFFER_MIN_SIZE, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_VMCI_BUFFER_MIN_SIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_vmci_buffer_min_size (void *self) { assert (self); # if defined (ZMQ_VMCI_BUFFER_MIN_SIZE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock vmci_buffer_min_size option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } uint64_t vmci_buffer_min_size; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_VMCI_BUFFER_MIN_SIZE, &vmci_buffer_min_size, &option_len); return (int) vmci_buffer_min_size; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_VMCI_BUFFER_MAX_SIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size) { assert (self); # if defined (ZMQ_VMCI_BUFFER_MAX_SIZE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock vmci_buffer_max_size option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } uint64_t value = vmci_buffer_max_size; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_VMCI_BUFFER_MAX_SIZE, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_VMCI_BUFFER_MAX_SIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_vmci_buffer_max_size (void *self) { assert (self); # if defined (ZMQ_VMCI_BUFFER_MAX_SIZE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock vmci_buffer_max_size option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } uint64_t vmci_buffer_max_size; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_VMCI_BUFFER_MAX_SIZE, &vmci_buffer_max_size, &option_len); return (int) vmci_buffer_max_size; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_VMCI_CONNECT_TIMEOUT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout) { assert (self); # if defined (ZMQ_VMCI_CONNECT_TIMEOUT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock vmci_connect_timeout option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_VMCI_CONNECT_TIMEOUT, &vmci_connect_timeout, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_VMCI_CONNECT_TIMEOUT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_vmci_connect_timeout (void *self) { assert (self); # if defined (ZMQ_VMCI_CONNECT_TIMEOUT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 2, 0)) { zsys_error ("zsock vmci_connect_timeout option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.2.0\n", major, minor, patch, NULL); return 0; } int vmci_connect_timeout; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_VMCI_CONNECT_TIMEOUT, &vmci_connect_timeout, &option_len); return vmci_connect_timeout; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TOS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tos (void *self, int tos) { assert (self); # if defined (ZMQ_TOS) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) { zsys_error ("zsock tos option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.1.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TOS, &tos, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TOS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tos (void *self) { assert (self); # if defined (ZMQ_TOS) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) { zsys_error ("zsock tos option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.1.0\n", major, minor, patch, NULL); return 0; } int tos; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TOS, &tos, &option_len); return tos; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_ROUTER_HANDOVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_router_handover (void *self, int router_handover) { assert (self); # if defined (ZMQ_ROUTER_HANDOVER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) { zsys_error ("zsock router_handover option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.1.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_ROUTER) { printf ("ZMQ_ROUTER_HANDOVER is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_ROUTER_HANDOVER, &router_handover, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CONNECT_RID value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_connect_rid (void *self, const char * connect_rid) { assert (self); # if defined (ZMQ_CONNECT_RID) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) { zsys_error ("zsock connect_rid option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.1.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_ROUTER && zsock_type (self) != ZMQ_STREAM) { printf ("ZMQ_CONNECT_RID is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CONNECT_RID, connect_rid, strlen (connect_rid)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CONNECT_RID value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_connect_rid_bin (void *self, const byte *connect_rid) { # if defined (ZMQ_CONNECT_RID) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) { zsys_error ("zsock connect_rid option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.1.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CONNECT_RID, connect_rid, 32); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_HANDSHAKE_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_handshake_ivl (void *self, int handshake_ivl) { assert (self); # if defined (ZMQ_HANDSHAKE_IVL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) { zsys_error ("zsock handshake_ivl option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.1.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_HANDSHAKE_IVL, &handshake_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_HANDSHAKE_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_handshake_ivl (void *self) { assert (self); # if defined (ZMQ_HANDSHAKE_IVL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) { zsys_error ("zsock handshake_ivl option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.1.0\n", major, minor, patch, NULL); return 0; } int handshake_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_HANDSHAKE_IVL, &handshake_ivl, &option_len); return handshake_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SOCKS_PROXY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_socks_proxy (void *self, const char * socks_proxy) { assert (self); # if defined (ZMQ_SOCKS_PROXY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) { zsys_error ("zsock socks_proxy option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.1.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SOCKS_PROXY, socks_proxy, strlen (socks_proxy)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SOCKS_PROXY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_socks_proxy (void *self) { assert (self); # if defined (ZMQ_SOCKS_PROXY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) { zsys_error ("zsock socks_proxy option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.1.0\n", major, minor, patch, NULL); return 0; } size_t option_len = 255; char *socks_proxy = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_SOCKS_PROXY, socks_proxy, &option_len); return (char *) socks_proxy; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_XPUB_NODROP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_xpub_nodrop (void *self, int xpub_nodrop) { assert (self); # if defined (ZMQ_XPUB_NODROP) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 1, 0)) { zsys_error ("zsock xpub_nodrop option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.1.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_XPUB && zsock_type (self) != ZMQ_PUB) { printf ("ZMQ_XPUB_NODROP is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_XPUB_NODROP, &xpub_nodrop, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_ROUTER_MANDATORY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_router_mandatory (void *self, int router_mandatory) { assert (self); # if defined (ZMQ_ROUTER_MANDATORY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock router_mandatory option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_ROUTER) { printf ("ZMQ_ROUTER_MANDATORY is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_ROUTER_MANDATORY, &router_mandatory, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_PROBE_ROUTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_probe_router (void *self, int probe_router) { assert (self); # if defined (ZMQ_PROBE_ROUTER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock probe_router option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_ROUTER && zsock_type (self) != ZMQ_DEALER && zsock_type (self) != ZMQ_REQ) { printf ("ZMQ_PROBE_ROUTER is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_PROBE_ROUTER, &probe_router, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_REQ_RELAXED value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_req_relaxed (void *self, int req_relaxed) { assert (self); # if defined (ZMQ_REQ_RELAXED) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock req_relaxed option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_REQ) { printf ("ZMQ_REQ_RELAXED is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_REQ_RELAXED, &req_relaxed, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_REQ_CORRELATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_req_correlate (void *self, int req_correlate) { assert (self); # if defined (ZMQ_REQ_CORRELATE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock req_correlate option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_REQ) { printf ("ZMQ_REQ_CORRELATE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_REQ_CORRELATE, &req_correlate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CONFLATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_conflate (void *self, int conflate) { assert (self); # if defined (ZMQ_CONFLATE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock conflate option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_PUSH && zsock_type (self) != ZMQ_PULL && zsock_type (self) != ZMQ_PUB && zsock_type (self) != ZMQ_SUB && zsock_type (self) != ZMQ_DEALER) { printf ("ZMQ_CONFLATE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CONFLATE, &conflate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_ZAP_DOMAIN value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_zap_domain (void *self, const char * zap_domain) { assert (self); # if defined (ZMQ_ZAP_DOMAIN) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock zap_domain option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_ZAP_DOMAIN, zap_domain, strlen (zap_domain)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_ZAP_DOMAIN value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_zap_domain (void *self) { assert (self); # if defined (ZMQ_ZAP_DOMAIN) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock zap_domain option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } size_t option_len = 255; char *zap_domain = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_ZAP_DOMAIN, zap_domain, &option_len); return (char *) zap_domain; # else return NULL; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MECHANISM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_mechanism (void *self) { assert (self); # if defined (ZMQ_MECHANISM) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock mechanism option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } int mechanism; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_MECHANISM, &mechanism, &option_len); return mechanism; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_PLAIN_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_plain_server (void *self, int plain_server) { assert (self); # if defined (ZMQ_PLAIN_SERVER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock plain_server option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_PLAIN_SERVER, &plain_server, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_PLAIN_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_plain_server (void *self) { assert (self); # if defined (ZMQ_PLAIN_SERVER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock plain_server option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } int plain_server; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_PLAIN_SERVER, &plain_server, &option_len); return plain_server; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_PLAIN_USERNAME value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_plain_username (void *self, const char * plain_username) { assert (self); # if defined (ZMQ_PLAIN_USERNAME) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock plain_username option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_PLAIN_USERNAME, plain_username, strlen (plain_username)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_PLAIN_USERNAME value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_plain_username (void *self) { assert (self); # if defined (ZMQ_PLAIN_USERNAME) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock plain_username option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } size_t option_len = 255; char *plain_username = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_PLAIN_USERNAME, plain_username, &option_len); return (char *) plain_username; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_PLAIN_PASSWORD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_plain_password (void *self, const char * plain_password) { assert (self); # if defined (ZMQ_PLAIN_PASSWORD) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock plain_password option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_PLAIN_PASSWORD, plain_password, strlen (plain_password)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_PLAIN_PASSWORD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_plain_password (void *self) { assert (self); # if defined (ZMQ_PLAIN_PASSWORD) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock plain_password option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } size_t option_len = 255; char *plain_password = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_PLAIN_PASSWORD, plain_password, &option_len); return (char *) plain_password; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_server (void *self, int curve_server) { assert (self); # if defined (ZMQ_CURVE_SERVER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock curve_server option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SERVER, &curve_server, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CURVE_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_curve_server (void *self) { assert (self); # if defined (ZMQ_CURVE_SERVER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock curve_server option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } int curve_server; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_CURVE_SERVER, &curve_server, &option_len); return curve_server; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_PUBLICKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_publickey (void *self, const char * curve_publickey) { assert (self); # if defined (ZMQ_CURVE_PUBLICKEY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock curve_publickey option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_PUBLICKEY, curve_publickey, strlen (curve_publickey)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_PUBLICKEY value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey) { # if defined (ZMQ_CURVE_PUBLICKEY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock curve_publickey option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_PUBLICKEY, curve_publickey, 32); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CURVE_PUBLICKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_curve_publickey (void *self) { assert (self); # if defined (ZMQ_CURVE_PUBLICKEY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock curve_publickey option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } size_t option_len = 40 + 1; // Z85 key + terminator char *curve_publickey = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_CURVE_PUBLICKEY, curve_publickey, &option_len); return (char *) curve_publickey; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SECRETKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_secretkey (void *self, const char * curve_secretkey) { assert (self); # if defined (ZMQ_CURVE_SECRETKEY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock curve_secretkey option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SECRETKEY, curve_secretkey, strlen (curve_secretkey)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SECRETKEY value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey) { # if defined (ZMQ_CURVE_SECRETKEY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock curve_secretkey option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SECRETKEY, curve_secretkey, 32); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CURVE_SECRETKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_curve_secretkey (void *self) { assert (self); # if defined (ZMQ_CURVE_SECRETKEY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock curve_secretkey option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } size_t option_len = 40 + 1; // Z85 key + terminator char *curve_secretkey = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_CURVE_SECRETKEY, curve_secretkey, &option_len); return (char *) curve_secretkey; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SERVERKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_serverkey (void *self, const char * curve_serverkey) { assert (self); # if defined (ZMQ_CURVE_SERVERKEY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock curve_serverkey option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SERVERKEY, curve_serverkey, strlen (curve_serverkey)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_CURVE_SERVERKEY value from 32-octet binary // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey) { # if defined (ZMQ_CURVE_SERVERKEY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock curve_serverkey option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_CURVE_SERVERKEY, curve_serverkey, 32); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_CURVE_SERVERKEY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_curve_serverkey (void *self) { assert (self); # if defined (ZMQ_CURVE_SERVERKEY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock curve_serverkey option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } size_t option_len = 40 + 1; // Z85 key + terminator char *curve_serverkey = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_CURVE_SERVERKEY, curve_serverkey, &option_len); return (char *) curve_serverkey; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_GSSAPI_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_gssapi_server (void *self, int gssapi_server) { assert (self); # if defined (ZMQ_GSSAPI_SERVER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock gssapi_server option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_GSSAPI_SERVER, &gssapi_server, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_GSSAPI_SERVER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_gssapi_server (void *self) { assert (self); # if defined (ZMQ_GSSAPI_SERVER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock gssapi_server option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } int gssapi_server; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_GSSAPI_SERVER, &gssapi_server, &option_len); return gssapi_server; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_GSSAPI_PLAINTEXT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext) { assert (self); # if defined (ZMQ_GSSAPI_PLAINTEXT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock gssapi_plaintext option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_GSSAPI_PLAINTEXT, &gssapi_plaintext, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_GSSAPI_PLAINTEXT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_gssapi_plaintext (void *self) { assert (self); # if defined (ZMQ_GSSAPI_PLAINTEXT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock gssapi_plaintext option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } int gssapi_plaintext; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_GSSAPI_PLAINTEXT, &gssapi_plaintext, &option_len); return gssapi_plaintext; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_GSSAPI_PRINCIPAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_gssapi_principal (void *self, const char * gssapi_principal) { assert (self); # if defined (ZMQ_GSSAPI_PRINCIPAL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock gssapi_principal option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_GSSAPI_PRINCIPAL, gssapi_principal, strlen (gssapi_principal)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_GSSAPI_PRINCIPAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_gssapi_principal (void *self) { assert (self); # if defined (ZMQ_GSSAPI_PRINCIPAL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock gssapi_principal option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } size_t option_len = 255; char *gssapi_principal = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_GSSAPI_PRINCIPAL, gssapi_principal, &option_len); return (char *) gssapi_principal; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_GSSAPI_SERVICE_PRINCIPAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_gssapi_service_principal (void *self, const char * gssapi_service_principal) { assert (self); # if defined (ZMQ_GSSAPI_SERVICE_PRINCIPAL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock gssapi_service_principal option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_GSSAPI_SERVICE_PRINCIPAL, gssapi_service_principal, strlen (gssapi_service_principal)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_GSSAPI_SERVICE_PRINCIPAL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_gssapi_service_principal (void *self) { assert (self); # if defined (ZMQ_GSSAPI_SERVICE_PRINCIPAL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock gssapi_service_principal option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } size_t option_len = 255; char *gssapi_service_principal = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_GSSAPI_SERVICE_PRINCIPAL, gssapi_service_principal, &option_len); return (char *) gssapi_service_principal; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IPV6 value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_ipv6 (void *self, int ipv6) { assert (self); # if defined (ZMQ_IPV6) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock ipv6 option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IPV6, &ipv6, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IPV6 value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_ipv6 (void *self) { assert (self); # if defined (ZMQ_IPV6) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock ipv6 option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } int ipv6; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_IPV6, &ipv6, &option_len); return ipv6; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IMMEDIATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_immediate (void *self, int immediate) { assert (self); # if defined (ZMQ_IMMEDIATE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock immediate option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IMMEDIATE, &immediate, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IMMEDIATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_immediate (void *self) { assert (self); # if defined (ZMQ_IMMEDIATE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (4, 0, 0)) { zsys_error ("zsock immediate option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 4.0.0\n", major, minor, patch, NULL); return 0; } int immediate; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_IMMEDIATE, &immediate, &option_len); return immediate; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_sndhwm (void *self, int sndhwm) { assert (self); # if defined (ZMQ_SNDHWM) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock sndhwm option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDHWM, &sndhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_sndhwm (void *self) { assert (self); # if defined (ZMQ_SNDHWM) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock sndhwm option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return 0; } int sndhwm; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_SNDHWM, &sndhwm, &option_len); return sndhwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rcvhwm (void *self, int rcvhwm) { assert (self); # if defined (ZMQ_RCVHWM) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock rcvhwm option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVHWM, &rcvhwm, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVHWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvhwm (void *self) { assert (self); # if defined (ZMQ_RCVHWM) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock rcvhwm option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return 0; } int rcvhwm; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVHWM, &rcvhwm, &option_len); return rcvhwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_maxmsgsize (void *self, int maxmsgsize) { assert (self); # if defined (ZMQ_MAXMSGSIZE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock maxmsgsize option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } int64_t value = maxmsgsize; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MAXMSGSIZE, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MAXMSGSIZE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_maxmsgsize (void *self) { assert (self); # if defined (ZMQ_MAXMSGSIZE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock maxmsgsize option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return 0; } int64_t maxmsgsize; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_MAXMSGSIZE, &maxmsgsize, &option_len); return (int) maxmsgsize; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_multicast_hops (void *self, int multicast_hops) { assert (self); # if defined (ZMQ_MULTICAST_HOPS) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock multicast_hops option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MULTICAST_HOPS, &multicast_hops, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MULTICAST_HOPS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_multicast_hops (void *self) { assert (self); # if defined (ZMQ_MULTICAST_HOPS) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock multicast_hops option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return 0; } int multicast_hops; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_MULTICAST_HOPS, &multicast_hops, &option_len); return multicast_hops; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_XPUB_VERBOSE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_xpub_verbose (void *self, int xpub_verbose) { assert (self); # if defined (ZMQ_XPUB_VERBOSE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock xpub_verbose option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_XPUB) { printf ("ZMQ_XPUB_VERBOSE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_XPUB_VERBOSE, &xpub_verbose, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_keepalive (void *self, int tcp_keepalive) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock tcp_keepalive option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE, &tcp_keepalive, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_keepalive (void *self) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock tcp_keepalive option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return 0; } int tcp_keepalive; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE, &tcp_keepalive, &option_len); return tcp_keepalive; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_IDLE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_IDLE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock tcp_keepalive_idle option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_IDLE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_keepalive_idle (void *self) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_IDLE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock tcp_keepalive_idle option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return 0; } int tcp_keepalive_idle; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_IDLE, &tcp_keepalive_idle, &option_len); return tcp_keepalive_idle; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_CNT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_CNT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock tcp_keepalive_cnt option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_CNT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_keepalive_cnt (void *self) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_CNT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock tcp_keepalive_cnt option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return 0; } int tcp_keepalive_cnt; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_CNT, &tcp_keepalive_cnt, &option_len); return tcp_keepalive_cnt; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_KEEPALIVE_INTVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_INTVL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock tcp_keepalive_intvl option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_KEEPALIVE_INTVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_tcp_keepalive_intvl (void *self) { assert (self); # if defined (ZMQ_TCP_KEEPALIVE_INTVL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock tcp_keepalive_intvl option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return 0; } int tcp_keepalive_intvl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_KEEPALIVE_INTVL, &tcp_keepalive_intvl, &option_len); return tcp_keepalive_intvl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_TCP_ACCEPT_FILTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_tcp_accept_filter (void *self, const char * tcp_accept_filter) { assert (self); # if defined (ZMQ_TCP_ACCEPT_FILTER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock tcp_accept_filter option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, strlen (tcp_accept_filter)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TCP_ACCEPT_FILTER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_tcp_accept_filter (void *self) { assert (self); # if defined (ZMQ_TCP_ACCEPT_FILTER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock tcp_accept_filter option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return 0; } size_t option_len = 255; char *tcp_accept_filter = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_TCP_ACCEPT_FILTER, tcp_accept_filter, &option_len); return (char *) tcp_accept_filter; # else return NULL; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_LAST_ENDPOINT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_last_endpoint (void *self) { assert (self); # if defined (ZMQ_LAST_ENDPOINT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock last_endpoint option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return 0; } size_t option_len = 255; char *last_endpoint = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_LAST_ENDPOINT, last_endpoint, &option_len); return (char *) last_endpoint; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_ROUTER_RAW value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_router_raw (void *self, int router_raw) { assert (self); # if defined (ZMQ_ROUTER_RAW) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock router_raw option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_ROUTER) { printf ("ZMQ_ROUTER_RAW is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_ROUTER_RAW, &router_raw, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IPV4ONLY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_ipv4only (void *self, int ipv4only) { assert (self); # if defined (ZMQ_IPV4ONLY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock ipv4only option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IPV4ONLY, &ipv4only, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IPV4ONLY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_ipv4only (void *self) { assert (self); # if defined (ZMQ_IPV4ONLY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock ipv4only option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return 0; } int ipv4only; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_IPV4ONLY, &ipv4only, &option_len); return ipv4only; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_DELAY_ATTACH_ON_CONNECT value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect) { assert (self); # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock delay_attach_on_connect option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 3.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_DELAY_ATTACH_ON_CONNECT, &delay_attach_on_connect, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_HWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_hwm (void *self, int hwm) { assert (self); # if defined (ZMQ_HWM) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0) || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock hwm option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL); return; } uint64_t value = hwm; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_HWM, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_HWM value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_hwm (void *self) { assert (self); # if defined (ZMQ_HWM) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0) || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock hwm option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL); return 0; } uint64_t hwm; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_HWM, &hwm, &option_len); return (int) hwm; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SWAP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_swap (void *self, int swap) { assert (self); # if defined (ZMQ_SWAP) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0) || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock swap option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL); return; } int64_t value = swap; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SWAP, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SWAP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_swap (void *self) { assert (self); # if defined (ZMQ_SWAP) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0) || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock swap option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL); return 0; } int64_t swap; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_SWAP, &swap, &option_len); return (int) swap; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_affinity (void *self, int affinity) { assert (self); # if defined (ZMQ_AFFINITY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock affinity option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return; } uint64_t value = affinity; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_AFFINITY, &value, sizeof (uint64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_AFFINITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_affinity (void *self) { assert (self); # if defined (ZMQ_AFFINITY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock affinity option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } uint64_t affinity; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_AFFINITY, &affinity, &option_len); return (int) affinity; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_identity (void *self, const char * identity) { assert (self); # if defined (ZMQ_IDENTITY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock identity option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_REQ && zsock_type (self) != ZMQ_REP && zsock_type (self) != ZMQ_DEALER && zsock_type (self) != ZMQ_ROUTER) { printf ("ZMQ_IDENTITY is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, strlen (identity)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_IDENTITY value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** char * zsock_identity (void *self) { assert (self); # if defined (ZMQ_IDENTITY) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock identity option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } size_t option_len = 255; char *identity = (char *) zmalloc (option_len); zmq_getsockopt (zsock_resolve (self), ZMQ_IDENTITY, identity, &option_len); return (char *) identity; # else return NULL; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rate (void *self, int rate) { assert (self); # if defined (ZMQ_RATE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock rate option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return; } # if ZMQ_VERSION_MAJOR < 3 int64_t value = rate; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RATE, &value, sizeof (int64_t)); # else int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RATE, &rate, sizeof (int)); # endif assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RATE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rate (void *self) { assert (self); # if defined (ZMQ_RATE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock rate option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } # if ZMQ_VERSION_MAJOR < 3 int64_t rate; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_RATE, &rate, &option_len); return (int) rate; # else int rate; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RATE, &rate, &option_len); return rate; # endif # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_recovery_ivl (void *self, int recovery_ivl) { assert (self); # if defined (ZMQ_RECOVERY_IVL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock recovery_ivl option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return; } # if ZMQ_VERSION_MAJOR < 3 int64_t value = recovery_ivl; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &value, sizeof (int64_t)); # else int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, sizeof (int)); # endif assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECOVERY_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_recovery_ivl (void *self) { assert (self); # if defined (ZMQ_RECOVERY_IVL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock recovery_ivl option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } # if ZMQ_VERSION_MAJOR < 3 int64_t recovery_ivl; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); return (int) recovery_ivl; # else int recovery_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL, &recovery_ivl, &option_len); return recovery_ivl; # endif # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECOVERY_IVL_MSEC value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec) { assert (self); # if defined (ZMQ_RECOVERY_IVL_MSEC) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0) || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock recovery_ivl_msec option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL); return; } int64_t value = recovery_ivl_msec; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL_MSEC, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECOVERY_IVL_MSEC value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_recovery_ivl_msec (void *self) { assert (self); # if defined (ZMQ_RECOVERY_IVL_MSEC) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0) || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock recovery_ivl_msec option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL); return 0; } int64_t recovery_ivl_msec; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_RECOVERY_IVL_MSEC, &recovery_ivl_msec, &option_len); return (int) recovery_ivl_msec; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_MCAST_LOOP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_mcast_loop (void *self, int mcast_loop) { assert (self); # if defined (ZMQ_MCAST_LOOP) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0) || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock mcast_loop option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL); return; } int64_t value = mcast_loop; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_MCAST_LOOP, &value, sizeof (int64_t)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_MCAST_LOOP value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_mcast_loop (void *self) { assert (self); # if defined (ZMQ_MCAST_LOOP) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0) || ZMQ_MAKE_VERSION (major, minor, patch) >= ZMQ_MAKE_VERSION (3, 0, 0)) { zsys_error ("zsock mcast_loop option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0 and < 3.0.0\n", major, minor, patch, NULL); return 0; } int64_t mcast_loop; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_MCAST_LOOP, &mcast_loop, &option_len); return (int) mcast_loop; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rcvtimeo (void *self, int rcvtimeo) { assert (self); # if defined (ZMQ_RCVTIMEO) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 2, 0)) { zsys_error ("zsock rcvtimeo option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.2.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvtimeo (void *self) { assert (self); # if defined (ZMQ_RCVTIMEO) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 2, 0)) { zsys_error ("zsock rcvtimeo option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.2.0\n", major, minor, patch, NULL); return 0; } int rcvtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVTIMEO, &rcvtimeo, &option_len); return rcvtimeo; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_sndtimeo (void *self, int sndtimeo) { assert (self); # if defined (ZMQ_SNDTIMEO) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 2, 0)) { zsys_error ("zsock sndtimeo option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.2.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDTIMEO value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_sndtimeo (void *self) { assert (self); # if defined (ZMQ_SNDTIMEO) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 2, 0)) { zsys_error ("zsock sndtimeo option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.2.0\n", major, minor, patch, NULL); return 0; } int sndtimeo; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_SNDTIMEO, &sndtimeo, &option_len); return sndtimeo; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_sndbuf (void *self, int sndbuf) { assert (self); # if defined (ZMQ_SNDBUF) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock sndbuf option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return; } # if ZMQ_VERSION_MAJOR < 3 uint64_t value = sndbuf; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDBUF, &value, sizeof (uint64_t)); # else int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, sizeof (int)); # endif assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_SNDBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_sndbuf (void *self) { assert (self); # if defined (ZMQ_SNDBUF) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock sndbuf option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } # if ZMQ_VERSION_MAJOR < 3 uint64_t sndbuf; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, &option_len); return (int) sndbuf; # else int sndbuf; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_SNDBUF, &sndbuf, &option_len); return sndbuf; # endif # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_rcvbuf (void *self, int rcvbuf) { assert (self); # if defined (ZMQ_RCVBUF) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock rcvbuf option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return; } # if ZMQ_VERSION_MAJOR < 3 uint64_t value = rcvbuf; int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVBUF, &value, sizeof (uint64_t)); # else int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, sizeof (int)); # endif assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVBUF value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvbuf (void *self) { assert (self); # if defined (ZMQ_RCVBUF) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock rcvbuf option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } # if ZMQ_VERSION_MAJOR < 3 uint64_t rcvbuf; size_t option_len = sizeof (uint64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, &option_len); return (int) rcvbuf; # else int rcvbuf; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVBUF, &rcvbuf, &option_len); return rcvbuf; # endif # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_linger (void *self, int linger) { assert (self); # if defined (ZMQ_LINGER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock linger option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_LINGER value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_linger (void *self) { assert (self); # if defined (ZMQ_LINGER) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock linger option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } int linger; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_LINGER, &linger, &option_len); return linger; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_reconnect_ivl (void *self, int reconnect_ivl) { assert (self); # if defined (ZMQ_RECONNECT_IVL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock reconnect_ivl option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_reconnect_ivl (void *self) { assert (self); # if defined (ZMQ_RECONNECT_IVL) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock reconnect_ivl option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } int reconnect_ivl; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL, &reconnect_ivl, &option_len); return reconnect_ivl; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max) { assert (self); # if defined (ZMQ_RECONNECT_IVL_MAX) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock reconnect_ivl_max option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RECONNECT_IVL_MAX value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_reconnect_ivl_max (void *self) { assert (self); # if defined (ZMQ_RECONNECT_IVL_MAX) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock reconnect_ivl_max option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } int reconnect_ivl_max; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl_max, &option_len); return reconnect_ivl_max; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_backlog (void *self, int backlog) { assert (self); # if defined (ZMQ_BACKLOG) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock backlog option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return; } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, sizeof (int)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_BACKLOG value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_backlog (void *self) { assert (self); # if defined (ZMQ_BACKLOG) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock backlog option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } int backlog; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_BACKLOG, &backlog, &option_len); return backlog; # else return 0; # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_SUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_subscribe (void *self, const char * subscribe) { assert (self); # if defined (ZMQ_SUBSCRIBE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock subscribe option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_SUB) { printf ("ZMQ_SUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_SUBSCRIBE, subscribe, strlen (subscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Set socket ZMQ_UNSUBSCRIBE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_set_unsubscribe (void *self, const char * unsubscribe) { assert (self); # if defined (ZMQ_UNSUBSCRIBE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock unsubscribe option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return; } if (zsock_type (self) != ZMQ_SUB) { printf ("ZMQ_UNSUBSCRIBE is not valid on %s sockets\n", zsys_sockname (zsock_type (self))); assert (false); } int rc = zmq_setsockopt (zsock_resolve (self), ZMQ_UNSUBSCRIBE, unsubscribe, strlen (unsubscribe)); assert (rc == 0 || zmq_errno () == ETERM); # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_TYPE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_type (void *self) { assert (self); # if defined (ZMQ_TYPE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock type option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } int type; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_TYPE, &type, &option_len); return type; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_RCVMORE value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_rcvmore (void *self) { assert (self); # if defined (ZMQ_RCVMORE) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock rcvmore option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } # if ZMQ_VERSION_MAJOR < 3 int64_t rcvmore; size_t option_len = sizeof (int64_t); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVMORE, &rcvmore, &option_len); return (int) rcvmore; # else int rcvmore; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_RCVMORE, &rcvmore, &option_len); return rcvmore; # endif # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_FD value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** SOCKET zsock_fd (void *self) { assert (self); # if defined (ZMQ_FD) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock fd option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } SOCKET fd; size_t option_len = sizeof (SOCKET); zmq_getsockopt (zsock_resolve (self), ZMQ_FD, &fd, &option_len); return fd; # else return 0; # endif } // -------------------------------------------------------------------------- // Return socket ZMQ_EVENTS value // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** int zsock_events (void *self) { assert (self); # if defined (ZMQ_EVENTS) int major, minor, patch; zmq_version (&major, &minor, &patch); if (ZMQ_MAKE_VERSION (major, minor, patch) < ZMQ_MAKE_VERSION (2, 0, 0)) { zsys_error ("zsock events option not supported by libzmq version %d.%d.%d, " "run with libzmq >= 2.0.0\n", major, minor, patch, NULL); return 0; } # if ZMQ_VERSION_MAJOR < 3 uint32_t events; size_t option_len = sizeof (uint32_t); zmq_getsockopt (zsock_resolve (self), ZMQ_EVENTS, &events, &option_len); return (int) events; # else int events; size_t option_len = sizeof (int); zmq_getsockopt (zsock_resolve (self), ZMQ_EVENTS, &events, &option_len); return events; # endif # else return 0; # endif } // -------------------------------------------------------------------------- // Selftest // *** GENERATED SOURCE CODE, DO NOT EDIT, SEE INSTRUCTIONS AT START *** void zsock_option_test (bool verbose) { printf (" * zsock_option: "); // @selftest zsock_t *self; #if (ZMQ_VERSION_MAJOR >= 4) # if (ZMQ_VERSION_MINOR >= 2) # if defined (ZMQ_HEARTBEAT_IVL) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_heartbeat_ivl (self, 2000); assert (zsock_heartbeat_ivl (self) == 2000); zsock_heartbeat_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_HEARTBEAT_TTL) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_heartbeat_ttl (self, 4000); assert (zsock_heartbeat_ttl (self) == 4000); zsock_heartbeat_ttl (self); zsock_destroy (&self); # endif # if defined (ZMQ_HEARTBEAT_TIMEOUT) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_heartbeat_timeout (self, 6000); assert (zsock_heartbeat_timeout (self) == 6000); zsock_heartbeat_timeout (self); zsock_destroy (&self); # endif # if defined (ZMQ_USE_FD) self = zsock_new (ZMQ_REQ); assert (self); zsock_set_use_fd (self, 3); assert (zsock_use_fd (self) == 3); zsock_use_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_MANUAL) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_manual (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_WELCOME_MSG) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_welcome_msg (self, "welcome"); zsock_destroy (&self); # endif # if defined (ZMQ_STREAM_NOTIFY) self = zsock_new (ZMQ_STREAM); assert (self); zsock_set_stream_notify (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_INVERT_MATCHING) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_invert_matching (self, 1); assert (zsock_invert_matching (self) == 1); zsock_invert_matching (self); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_VERBOSER) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_verboser (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_CONNECT_TIMEOUT) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_connect_timeout (self, 200); assert (zsock_connect_timeout (self) == 200); zsock_connect_timeout (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_MAXRT) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_tcp_maxrt (self, 200); assert (zsock_tcp_maxrt (self) == 200); zsock_tcp_maxrt (self); zsock_destroy (&self); # endif # if defined (ZMQ_THREAD_SAFE) self = zsock_new (ZMQ_DEALER); assert (self); zsock_thread_safe (self); zsock_destroy (&self); # endif # if defined (ZMQ_MULTICAST_MAXTPDU) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_multicast_maxtpdu (self, 1400); assert (zsock_multicast_maxtpdu (self) == 1400); zsock_multicast_maxtpdu (self); zsock_destroy (&self); # endif # endif #endif #if (ZMQ_VERSION_MAJOR >= 4) # if (ZMQ_VERSION_MINOR >= 1) # if defined (ZMQ_TOS) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_tos (self, 1); assert (zsock_tos (self) == 1); zsock_tos (self); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_HANDOVER) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_handover (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_CONNECT_RID) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_connect_rid (self, "ABCD"); zsock_destroy (&self); # endif # if defined (ZMQ_HANDSHAKE_IVL) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_handshake_ivl (self, 200); assert (zsock_handshake_ivl (self) == 200); zsock_handshake_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_SOCKS_PROXY) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_socks_proxy (self, "127.0.0.1"); char *socks_proxy = zsock_socks_proxy (self); assert (socks_proxy); freen (socks_proxy); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_NODROP) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_nodrop (self, 1); zsock_destroy (&self); # endif # endif #endif #if (ZMQ_VERSION_MAJOR >= 4) # if defined (ZMQ_ROUTER_MANDATORY) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_mandatory (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_PROBE_ROUTER) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_probe_router (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_REQ_RELAXED) self = zsock_new (ZMQ_REQ); assert (self); zsock_set_req_relaxed (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_REQ_CORRELATE) self = zsock_new (ZMQ_REQ); assert (self); zsock_set_req_correlate (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_CONFLATE) self = zsock_new (ZMQ_PUSH); assert (self); zsock_set_conflate (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_ZAP_DOMAIN) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_zap_domain (self, "test"); char *zap_domain = zsock_zap_domain (self); assert (zap_domain); freen (zap_domain); zsock_destroy (&self); # endif # if defined (ZMQ_MECHANISM) self = zsock_new (ZMQ_SUB); assert (self); zsock_mechanism (self); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_SERVER) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_plain_server (self, 1); assert (zsock_plain_server (self) == 1); zsock_plain_server (self); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_USERNAME) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_plain_username (self, "test"); char *plain_username = zsock_plain_username (self); assert (plain_username); freen (plain_username); zsock_destroy (&self); # endif # if defined (ZMQ_PLAIN_PASSWORD) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_plain_password (self, "test"); char *plain_password = zsock_plain_password (self); assert (plain_password); freen (plain_password); zsock_destroy (&self); # endif # if defined (ZMQ_IPV6) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv6 (self, 1); assert (zsock_ipv6 (self) == 1); zsock_ipv6 (self); zsock_destroy (&self); # endif # if defined (ZMQ_IMMEDIATE) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_immediate (self, 1); assert (zsock_immediate (self) == 1); zsock_immediate (self); zsock_destroy (&self); # endif #endif #if (ZMQ_VERSION_MAJOR >= 3) # if defined (ZMQ_SNDHWM) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_sndhwm (self, 1); assert (zsock_sndhwm (self) == 1); zsock_sndhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVHWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvhwm (self, 1); assert (zsock_rcvhwm (self) == 1); zsock_rcvhwm (self); zsock_destroy (&self); # endif # if defined (ZMQ_MAXMSGSIZE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_maxmsgsize (self, 1); assert (zsock_maxmsgsize (self) == 1); zsock_maxmsgsize (self); zsock_destroy (&self); # endif # if defined (ZMQ_MULTICAST_HOPS) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_multicast_hops (self, 1); assert (zsock_multicast_hops (self) == 1); zsock_multicast_hops (self); zsock_destroy (&self); # endif # if defined (ZMQ_XPUB_VERBOSE) self = zsock_new (ZMQ_XPUB); assert (self); zsock_set_xpub_verbose (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive (self, 1); assert (zsock_tcp_keepalive (self) == 1); zsock_tcp_keepalive (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_IDLE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_idle (self, 1); assert (zsock_tcp_keepalive_idle (self) == 1); zsock_tcp_keepalive_idle (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_CNT) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_cnt (self, 1); assert (zsock_tcp_keepalive_cnt (self) == 1); zsock_tcp_keepalive_cnt (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_KEEPALIVE_INTVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_keepalive_intvl (self, 1); assert (zsock_tcp_keepalive_intvl (self) == 1); zsock_tcp_keepalive_intvl (self); zsock_destroy (&self); # endif # if defined (ZMQ_TCP_ACCEPT_FILTER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_tcp_accept_filter (self, "127.0.0.1"); char *tcp_accept_filter = zsock_tcp_accept_filter (self); assert (tcp_accept_filter); freen (tcp_accept_filter); zsock_destroy (&self); # endif # if defined (ZMQ_LAST_ENDPOINT) self = zsock_new (ZMQ_SUB); assert (self); char *last_endpoint = zsock_last_endpoint (self); assert (last_endpoint); freen (last_endpoint); zsock_destroy (&self); # endif # if defined (ZMQ_ROUTER_RAW) self = zsock_new (ZMQ_ROUTER); assert (self); zsock_set_router_raw (self, 1); zsock_destroy (&self); # endif # if defined (ZMQ_IPV4ONLY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_ipv4only (self, 1); assert (zsock_ipv4only (self) == 1); zsock_ipv4only (self); zsock_destroy (&self); # endif # if defined (ZMQ_DELAY_ATTACH_ON_CONNECT) self = zsock_new (ZMQ_PUB); assert (self); zsock_set_delay_attach_on_connect (self, 1); zsock_destroy (&self); # endif #endif #if (ZMQ_VERSION_MAJOR >= 2) # if (ZMQ_VERSION_MAJOR < 3) # if defined (ZMQ_HWM) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_hwm (self, 1); assert (zsock_hwm (self) == 1); zsock_hwm (self); zsock_destroy (&self); # endif # endif # if (ZMQ_VERSION_MAJOR < 3) # if defined (ZMQ_SWAP) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_swap (self, 1); assert (zsock_swap (self) == 1); zsock_swap (self); zsock_destroy (&self); # endif # endif # if defined (ZMQ_AFFINITY) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_affinity (self, 1); assert (zsock_affinity (self) == 1); zsock_affinity (self); zsock_destroy (&self); # endif # if defined (ZMQ_IDENTITY) self = zsock_new (ZMQ_DEALER); assert (self); zsock_set_identity (self, "test"); char *identity = zsock_identity (self); assert (identity); freen (identity); zsock_destroy (&self); # endif # if defined (ZMQ_RATE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rate (self, 1); assert (zsock_rate (self) == 1); zsock_rate (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECOVERY_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl (self, 1); assert (zsock_recovery_ivl (self) == 1); zsock_recovery_ivl (self); zsock_destroy (&self); # endif # if (ZMQ_VERSION_MAJOR < 3) # if defined (ZMQ_RECOVERY_IVL_MSEC) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_recovery_ivl_msec (self, 1); assert (zsock_recovery_ivl_msec (self) == 1); zsock_recovery_ivl_msec (self); zsock_destroy (&self); # endif # endif # if (ZMQ_VERSION_MAJOR < 3) # if defined (ZMQ_MCAST_LOOP) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_mcast_loop (self, 1); assert (zsock_mcast_loop (self) == 1); zsock_mcast_loop (self); zsock_destroy (&self); # endif # endif # if defined (ZMQ_RCVTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvtimeo (self, 1); assert (zsock_rcvtimeo (self) == 1); zsock_rcvtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDTIMEO) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndtimeo (self, 1); assert (zsock_sndtimeo (self) == 1); zsock_sndtimeo (self); zsock_destroy (&self); # endif # if defined (ZMQ_SNDBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_sndbuf (self, 1); assert (zsock_sndbuf (self) == 1); zsock_sndbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVBUF) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_rcvbuf (self, 1); assert (zsock_rcvbuf (self) == 1); zsock_rcvbuf (self); zsock_destroy (&self); # endif # if defined (ZMQ_LINGER) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_linger (self, 1); assert (zsock_linger (self) == 1); zsock_linger (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl (self, 1); assert (zsock_reconnect_ivl (self) == 1); zsock_reconnect_ivl (self); zsock_destroy (&self); # endif # if defined (ZMQ_RECONNECT_IVL_MAX) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_reconnect_ivl_max (self, 1); assert (zsock_reconnect_ivl_max (self) == 1); zsock_reconnect_ivl_max (self); zsock_destroy (&self); # endif # if defined (ZMQ_BACKLOG) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_backlog (self, 1); assert (zsock_backlog (self) == 1); zsock_backlog (self); zsock_destroy (&self); # endif # if defined (ZMQ_SUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_subscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_UNSUBSCRIBE) self = zsock_new (ZMQ_SUB); assert (self); zsock_set_unsubscribe (self, "test"); zsock_destroy (&self); # endif # if defined (ZMQ_TYPE) self = zsock_new (ZMQ_SUB); assert (self); zsock_type (self); zsock_destroy (&self); # endif # if defined (ZMQ_RCVMORE) self = zsock_new (ZMQ_SUB); assert (self); zsock_rcvmore (self); zsock_destroy (&self); # endif # if defined (ZMQ_FD) self = zsock_new (ZMQ_SUB); assert (self); zsock_fd (self); zsock_destroy (&self); # endif # if defined (ZMQ_EVENTS) self = zsock_new (ZMQ_SUB); assert (self); zsock_events (self); zsock_destroy (&self); # endif #endif // @end printf ("OK\n"); } czmq-4.1.0/src/ztrie.c0000664000372000037200000007344413222211156015467 0ustar00travistravis00000000000000/* ========================================================================= ztrie - simple trie for tokenizable strings Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header This is a variant of a trie or prefix tree where all the descendants of a node have a common prefix of the string associated with that node. This implementation is specialized for strings that can be tokenized by a delimiter like a URL, URI or URN. Routes in the tree can be matched by regular expressions and by using capturing groups parts of a matched route can be easily obtained. @discuss Note that the performance for pure string based matching is okay but on short strings zhash and zhashx are 3-4 times faster. @end */ #include "czmq_classes.h" #define MODE_INSERT 0 #define MODE_LOOKUP 1 #define MODE_MATCH 2 #define NODE_TYPE_STRING 0 // Node with string token #define NODE_TYPE_REGEX 1 // Node with regex token #define NODE_TYPE_PARAM 2 // Node with named regex token and capturing group(s) #define NODE_TYPE_ASTERISK 3 // Node with an asterisk, to match routes of variable length #define MIN_LEN(x,y) \ y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))) // TODO: Move to a more appropriate location: static char * s_strndup (const char *s, size_t size) { char *dup; char *end = (char *) memchr (s, '\0', size); if (end) size = end - 1 - s; // -1 to get the last char before '\0' dup = (char *) zmalloc (sizeof (char) * size + 1); // +1 for trailing '\0' if (size) { memcpy (dup, s, size); dup [size] = '\0'; } return dup; } // Trie node, used internally only typedef struct _ztrie_node_t { char *token; // Part of a path between to delemiters e.g. '/{token}/' int token_type; // Type of the token, string, regex, asterisk int token_len; // Number of characters of the token size_t path_len; // Length of the path/route including this token bool endpoint; // Has a path been added that routes to this node? size_t parameter_count; // How many regex parameters does this token contain? char **parameter_names; // Names of the regex parameters for easy access at matching time char **parameter_values; // Values of the parameters char *asterisk_match; // Matched asterisk route zrex_t *regex; // Compiled regex void *data; // Custom arbitrary data assoziated with a route ztrie_destroy_data_fn *destroy_data_fn; // Callback to destroy custom data zlistx_t *children; // List of all children to this route struct _ztrie_node_t *parent; // Parent of this node } ztrie_node_t; // -------------------------------------------------------------------------- // Structure of our class struct _ztrie_t { char delimiter; // Character that seperates the tokens of a route ztrie_node_t *root; // Root node of this tree ztrie_node_t *match; // Last match made by ztrie_matches zlistx_t *params; // List of regex parameters found during parsing // The list is kept globally to optimize performance. }; // Internal helper functions static int s_ztrie_node_compare (const void *item1, const void *item2) { assert (item1); assert (item2); ztrie_node_t *node1 = (ztrie_node_t *) item1; ztrie_node_t *node2 = (ztrie_node_t *) item2; int same = node1->token_type - node2->token_type; if (same == 0) { if (*node1->token == *node2->token // This achieves a small performance boost && node1->token_len == node2->token_len && strncmp (node1->token, node2->token, MIN_LEN (node1->token_len, node2->token_len)) == 0) return 0; else return -1; } else return same; } // Create a new ztrie_node. If parent is not NULL the child will add itself // to the parents children. static ztrie_node_t * s_ztrie_node_new (ztrie_node_t *parent, char *token, int token_len, zlistx_t *param_keys, int token_type) { ztrie_node_t *self = (ztrie_node_t *) zmalloc (sizeof (ztrie_node_t)); assert (self); // Initialize properties self->token = s_strndup (token, token_len); self->token_type = token_type; self->token_len = token_len; self->endpoint = false; self->parameter_count = 0; self->parameter_names = NULL; self->parameter_values = NULL; if (param_keys && zlistx_size (param_keys) > 0) { self->parameter_count = zlistx_size (param_keys); self->parameter_names = (char **) malloc (sizeof (char *) * self->parameter_count); self->parameter_values = (char **) malloc (sizeof (char *) * self->parameter_count); char *key = (char *) zlistx_first (param_keys); size_t index; for (index = 0; index < zlistx_size (param_keys); index++) { self->parameter_names [index] = key; self->parameter_values [index] = NULL; key = (char *) zlistx_next (param_keys); } } if (self->token_type == NODE_TYPE_REGEX || self->token_type == NODE_TYPE_PARAM) self->regex = zrex_new (self->token); self->data = NULL; // Initialize relationships self->parent = parent; if (self->parent) { zlistx_add_end (self->parent->children, self); // Sort regexes to the end to avoid conlficts zlistx_sort (self->parent->children); } size_t parent_path_len = self->parent? self->parent->path_len: 0; self->path_len = parent_path_len + strlen (self->token) + 1; // +1 path delimiter self->children = zlistx_new (); zlistx_set_comparator (self->children, s_ztrie_node_compare); return self; } // Destroy the ztrie_node. static void s_ztrie_node_destroy (ztrie_node_t **self_p) { assert (self_p); if (*self_p) { ztrie_node_t *self = *self_p; // Free class properties zstr_free (&self->token); zstr_free (&self->asterisk_match); if (self->parameter_count > 0) { size_t index; for (index = 0; index < self->parameter_count; index++) { freen (self->parameter_names [index]); if (self->parameter_values [index]) freen (self->parameter_values [index]); } freen (self->parameter_names); freen (self->parameter_values); } if (self->token_type == NODE_TYPE_REGEX || self->token_type == NODE_TYPE_PARAM) zrex_destroy (&self->regex); zlistx_destroy (&self->children); if (self->data && self->destroy_data_fn) (self->destroy_data_fn) (&self->data); // Free object itself freen (self); *self_p = NULL; } } // Update the value of a regex parameter at position. static void s_ztrie_node_update_param (ztrie_node_t *self, int pos, const char *value) { assert (self); zstr_free (&self->parameter_values [pos - 1]); self->parameter_values [pos - 1] = strdup (value); } // -------------------------------------------------------------------------- // Creates a new ztrie. ztrie_t * ztrie_new (char delimiter) { ztrie_t *self = (ztrie_t *) zmalloc (sizeof (ztrie_t)); assert (self); // Initialize properties if (delimiter) self->delimiter = delimiter; else self->delimiter = '/'; self->root = s_ztrie_node_new (NULL, "", 0, NULL, NODE_TYPE_STRING); self->match = NULL; self->params = zlistx_new (); return self; } // Destroy all children of a node static void s_ztrie_destroy_children (ztrie_node_t *node) { ztrie_node_t *child = (ztrie_node_t *) zlistx_first (node->children); while (child) { s_ztrie_destroy_children (child); s_ztrie_node_destroy (&child); child = (ztrie_node_t *) zlistx_next (node->children); } } // -------------------------------------------------------------------------- // Destroy the ztrie. void ztrie_destroy (ztrie_t **self_p) { assert (self_p); if (*self_p) { ztrie_t *self = *self_p; // Free class properties s_ztrie_destroy_children (self->root); s_ztrie_node_destroy (&self->root); zlistx_destroy (&self->params); // Free object itself freen (self); *self_p = NULL; } } // String compare token static ztrie_node_t * s_ztrie_compare_token (ztrie_node_t *parent, char *token, int len) { ztrie_node_t *child = (ztrie_node_t *) zlistx_first (parent->children); while (child) { if (child->token_len == len && strncmp (child->token, token, MIN_LEN (child->token_len, len)) == 0) return child; child = (ztrie_node_t *) zlistx_next (parent->children); } return NULL; } // String compare token or evaluate regexes static ztrie_node_t * s_ztrie_matches_token (ztrie_node_t *parent, char *token, int len) { char firstbyte = *token; ztrie_node_t *child = (ztrie_node_t *) zlistx_first (parent->children); while (child) { if (child->token_type == NODE_TYPE_STRING) { if (firstbyte == *child->token // This achieves a small performance boost && child->token_len == len && strncmp (child->token, token, MIN_LEN (child->token_len, len)) == 0) return child; } else if (child->token_type == NODE_TYPE_ASTERISK) { child->asterisk_match = strdup (token); return child; } else { // Need to copy token as zrex_matches expects '\0' terminated string char *token_term = s_strndup (token, len); if (zrex_matches (child->regex, token_term)) { if (child->token_type == NODE_TYPE_PARAM) { // One hit means no capturing group was defined // More than one hit indicates that at least on capturing group. // In this case only the values of the capturing groups are considered. if (zrex_hits (child->regex) == 1) s_ztrie_node_update_param (child, 1, zrex_hit (child->regex, 0)); else if (zrex_hits (child->regex) > 1) { int index; for (index = 1; index < zrex_hits (child->regex); index++) s_ztrie_node_update_param (child, index, zrex_hit (child->regex, index)); } } freen (token_term); return child; } freen (token_term); } child = (ztrie_node_t *) zlistx_next (parent->children); } return NULL; } // -------------------------------------------------------------------------- // Parses a path bytewise trying to find matches for path tokens. Depending // on the mode there are different behaviors on, // how the tokens are compared: // MODE_INSERT: All tokens are compared as strings. // MODE_LOOKUP: All tokens are compared as strings. // MODE_MATCH: Node tokens of NODE_TYPE_STRING tokens are compared as strings, // otherwise the tokens are matched against the nodes regex. // how a mismatch is handled: // MODE_INSERT: creates a new node and attaches it to the common prefix for // the given path, repeat for the remaining path tokens. // returns the node that has been attached last. // MODE_LOOKUP: returns NULL if the comparison failed. // MODE_MATCH: returns NULL if the comparison failed. static ztrie_node_t * s_ztrie_parse_path (ztrie_t *self, const char *path, int mode) { int state = 0; char *needle, *beginToken = NULL, *beginRegex = NULL; ztrie_node_t *parent = self->root; if (zlistx_size (self->params) > 0) zlistx_purge (self->params); size_t len = strlen (path); needle = (char *) path; char *needle_stop = needle + len; // Ignore trailing delimiter if (needle [len-1] == self->delimiter) needle_stop -= 1; while (needle < needle_stop + 1) { // It is valid not to have an delimiter at the end of the path if (*needle == self->delimiter || needle == needle_stop) { // Token starts with delimiter ignore everything that comes before if (state == 0) { beginToken = needle + 1; state++; if (mode == MODE_INSERT || mode == MODE_LOOKUP) // Increment so regexes are parsed which is only relevant // during INSERT or LOOKUP. Using different states gives a small // performance boost for matching. state++; } // Token ends with delimiter. else if (state < 3) { int matchType = zlistx_size (self->params) > 0? NODE_TYPE_PARAM: beginRegex? NODE_TYPE_REGEX: NODE_TYPE_STRING; char *matchToken = beginRegex? beginRegex: beginToken; int matchTokenLen = (int) (needle - matchToken) - (beginRegex? 1: 0); // Illegal token if (matchTokenLen == 0) return NULL; ztrie_node_t *match = NULL; // Asterisk nodes are only allowed at the end of a route if (needle == needle_stop && *matchToken == '*') { if (zlistx_size (parent->children) == 0) { matchType = NODE_TYPE_ASTERISK; matchToken = needle - 1; matchTokenLen = 1; } // Asterisk must be a leaf in the tree else return NULL; } else { matchType = zlistx_size (self->params) > 0? NODE_TYPE_PARAM: beginRegex? NODE_TYPE_REGEX: NODE_TYPE_STRING; matchToken = beginRegex? beginRegex: beginToken; matchTokenLen = (int) (needle - matchToken) - (beginRegex? 1: 0); } // In insert and lookup mode only do a string comparison if (mode == MODE_INSERT || mode == MODE_LOOKUP) match = s_ztrie_compare_token (parent, matchToken, matchTokenLen); else // Otherwise evaluate regexes if (mode == MODE_MATCH) match = s_ztrie_matches_token (parent, matchToken, matchTokenLen); // Mismatch behavior depends on mode if (!match) { // Append to common prefix if (mode == MODE_INSERT) { // It's not allowed to append on asterisk if (parent->token_type == NODE_TYPE_ASTERISK || (zlistx_size (parent->children) == 1 && ((ztrie_node_t *) (zlistx_first (parent->children)))->token_type == NODE_TYPE_ASTERISK)) return NULL; parent = s_ztrie_node_new (parent, matchToken, matchTokenLen, self->params, matchType); } else // No match for path found if (mode == MODE_MATCH || mode == MODE_LOOKUP) return NULL; } // If a match has been found it becomes the parent for next path token else { parent = match; // In case a asterisk match has been made skip the rest of the route if (parent->token_type == NODE_TYPE_ASTERISK) break; } // Cleanup for next token beginRegex = NULL; if (zlistx_size (self->params) > 0) zlistx_purge (self->params); // Token end equals token begin beginToken = needle + 1; } } else // regex starts with '{' if (state == 2 && *needle == '{') { beginRegex = needle + 1; state++; } else // in the middle of the regex. Found a named regex. if (state == 3 && (*needle == ':')) { zlistx_add_end (self->params, s_strndup (beginRegex, needle - beginRegex)); beginRegex = needle + 1; } else // regex ends with { if (state == 3 && *needle == '}') { state--; } needle++; } // In matching mode the discovered node must be an endpoint if (parent && mode == MODE_MATCH && !parent->endpoint) return NULL; return parent; } // -------------------------------------------------------------------------- // Inserts a new route into the trie and attaches the data. Returns -1 // if the route already exists, otherwise 0. This method takes ownership of // the provided data. int ztrie_insert_route (ztrie_t *self, const char *path, void *data, ztrie_destroy_data_fn destroy_data_fn) { assert (self); ztrie_node_t *node = s_ztrie_parse_path (self, path, MODE_INSERT); // If the returned node has no endpoint, a new route can be assigned to it. if (node && !node->endpoint) { node->endpoint = true; node->data = data; node->destroy_data_fn = destroy_data_fn; return 0; } // If the returned node has an endpoint, a route has already assigned to it. else return -1; } // -------------------------------------------------------------------------- // Removes a route from the trie and destroys its data. Returns -1 if the // route does not exists, otherwise 0. int ztrie_remove_route (ztrie_t *self, const char *path) { assert (self); ztrie_node_t *match = s_ztrie_parse_path (self, path, MODE_LOOKUP); // The path did match a node which is endpoint to a route if (match && match->endpoint) { // This node is part of other routes, thus it cannot destroy it if (zlistx_size (match->children) > 0) { match->endpoint = false; if (match->data && match->destroy_data_fn) (match->destroy_data_fn) (&match->data); } // If this node is not part of other routes, destroy it else { // Delete match from parent's children before destroying void *handle = zlistx_find (match->parent->children, match); assert (handle); zlistx_delete (match->parent->children, handle); s_ztrie_node_destroy (&match); } return 0; } // If there is no match or the match is not endpoint to a route, fail else return -1; } // -------------------------------------------------------------------------- // Returns true if the path matches a route in the tree, otherwise false. bool ztrie_matches (ztrie_t *self, const char *path) { assert (self); self->match = s_ztrie_parse_path (self, path, MODE_MATCH); return self->match? true: false; } // -------------------------------------------------------------------------- // Returns the data of a matched route from last ztrie_matches. If the path // did not match, returns NULL. Do not delete the data as it's owned by // ztrie. void * ztrie_hit_data (ztrie_t *self) { assert (self); if (self->match) return self->match->data; return NULL; } // -------------------------------------------------------------------------- // Returns the count of parameters that a matched route has. size_t ztrie_hit_parameter_count (ztrie_t *self) { size_t count = 0; ztrie_node_t *node = self->match; while (node) { count += node->parameter_count; node = node->parent; } return count; } // -------------------------------------------------------------------------- // Returns the parameters of a matched route with named regexes from last // ztrie_matches. If the path did not match or the route did not contain any // named regexes, returns NULL. The caller is responseable for destroy the map. zhashx_t * ztrie_hit_parameters (ztrie_t *self) { assert (self); if (self->match) { zhashx_t *route_parameters = zhashx_new (); ztrie_node_t *node = self->match; while (node) { size_t index; for (index = 0; index < node->parameter_count; index++) zhashx_insert (route_parameters, node->parameter_names [index], (void *) node->parameter_values [index]); node = node->parent; } return route_parameters; } return NULL; } // -------------------------------------------------------------------------- // Returns the asterisk matched part of a route, if there has been no match // or no asterisk match, returns NULL. const char * ztrie_hit_asterisk_match (ztrie_t *self) { assert (self); if (self->match) return self->match->asterisk_match; return NULL; } // -------------------------------------------------------------------------- // Print properties of the ztrie object. // static void s_ztrie_print_tree_line (ztrie_node_t *self, bool end_line) { if (self->parent) { s_ztrie_print_tree_line (self->parent, false); if (zlistx_tail (self->parent->children) == self) { if (end_line) printf ("`-- "); else printf (" "); } else { if (end_line) printf ("+-- "); else printf ("| "); } if (end_line) { char *is_endpoint = self->endpoint? "true": "false"; printf ("%s (params: %zu, endpoint: %s, type: %d)\n", self->token, self->parameter_count, is_endpoint, self->token_type); } } } static void s_ztrie_print_tree (ztrie_node_t *self) { // Print tree like structure s_ztrie_print_tree_line (self, true); ztrie_node_t *child = (ztrie_node_t *) zlistx_first (self->children); while (child) { s_ztrie_print_tree (child); child = (ztrie_node_t *) zlistx_next (self->children); } } void ztrie_print (ztrie_t *self) { assert (self); s_ztrie_print_tree (self->root); } // -------------------------------------------------------------------------- // Self test of this class. void ztrie_test (bool verbose) { printf (" * ztrie: "); // @selftest // Create a new trie for matching strings that can be tokenized by a slash // (e.g. URLs minus the protocol, address and port). ztrie_t *self = ztrie_new ('/'); assert (self); int ret = 0; // Let's start by inserting a couple of routes into the trie. // This one is for the route '/foo/bar' the slash at the beginning of the // route is important because everything before the first delimiter will be // discarded. A slash at the end of a route is optional though. The data // associated with this node is passed without destroy function which means // it must be destroyed by the caller. int foo_bar_data = 10; ret = ztrie_insert_route (self, "/foo/bar", &foo_bar_data, NULL); assert (ret == 0); // Now suppose we like to match all routes with two tokens that start with // '/foo/' but aren't '/foo/bar'. This is possible by using regular // expressions which are enclosed in an opening and closing curly bracket. // Tokens that contain regular expressions are always match after string // based tokens. // Note: There is no order in which regular expressions are sorted thus // if you enter multiple expressions for a route you will have to make // sure they don't have overlapping results. For example '/foo/{[^/]+}' // and '/foo/{\d+} having could turn out badly. int foo_other_data = 100; ret = ztrie_insert_route (self, "/foo/{[^/]+}", &foo_other_data, NULL); assert (ret == 0); // Regular expression are only matched against tokens of the same level. // This allows us to append to are route with a regular expression as if // it were a string. ret = ztrie_insert_route (self, "/foo/{[^/]+}/gulp", NULL, NULL); assert (ret == 0); // Routes are identified by their endpoint, which is the last token of the route. // It is possible to insert routes for a node that already exists but isn't an // endpoint yet. The delimiter at the end of a route is optional and has no effect. ret = ztrie_insert_route (self, "/foo/", NULL, NULL); assert (ret == 0); // If you try to insert a route which already exists the method will return -1. ret = ztrie_insert_route (self, "/foo", NULL, NULL); assert (ret == -1); // It is not allowed to insert routes with empty tokens. ret = ztrie_insert_route (self, "//foo", NULL, NULL); assert (ret == -1); // Everything before the first delimiter is ignored so 'foo/bar/baz' is equivalent // to '/bar/baz'. ret = ztrie_insert_route (self, "foo/bar/baz", NULL, NULL); assert (ret == 0); ret = ztrie_insert_route (self, "/bar/baz", NULL, NULL); assert (ret == -1); // Of course you are allowed to remove routes, in case there is data associated with a // route and a destroy data function has been supplied that data will be destroyed. ret = ztrie_remove_route (self, "/foo"); assert (ret == 0); // Removing a non existent route will as well return -1. ret = ztrie_remove_route (self, "/foo"); assert (ret == -1); // Removing a route with a regular expression must exactly match the entered one. ret = ztrie_remove_route (self, "/foo/{[^/]+}"); assert (ret == 0); // Next we like to match a path by regular expressions and also extract matched // parts of a route. This can be done by naming the regular expression. The name of a // regular expression is entered at the beginning of the curly brackets and separated // by a colon from the regular expression. The first one in this examples is named // 'name' and names the expression '[^/]'. If there is no capturing group defined in // the expression the whole matched string will be associated with this parameter. In // case you don't like the get the whole matched string use a capturing group, like // it has been done for the 'id' parameter. This is nice but you can even match as // many parameter for a token as you like. Therefore simply put the parameter names // separated by colons in front of the regular expression and make sure to add a // capturing group for each parameter. The first parameter will be associated with // the first capturing and so on. char *data = (char *) malloc (80); sprintf (data, "%s", "Hello World!"); ret = ztrie_insert_route (self, "/baz/{name:[^/]+}/{id:--(\\d+)}/{street:nr:(\\a+)(\\d+)}", data, NULL); assert (ret == 0); // There is a lot you can do with regular expression but matching routes // of arbitrary length wont work. Therefore we make use of the asterisk // operator. Just place it at the end of your route, e.g. '/config/bar/*'. ret = ztrie_insert_route (self, "/config/bar/*", NULL, NULL); assert (ret == 0); // Appending to an asterisk as you would to with a regular expression // isn't valid. ret = ztrie_insert_route (self, "/config/bar/*/bar", NULL, NULL); assert (ret == -1); // The asterisk operator will only work as a leaf in the tree. If you // enter an asterisk in the middle of your route it will simply be // interpreted as a string. ret = ztrie_insert_route (self, "/test/*/bar", NULL, NULL); assert (ret == 0); // If a parent has an asterisk as child it is not allowed to have // other siblings. ret = ztrie_insert_route (self, "/config/bar/foo/glup", NULL, NULL); assert (ret != 0); // Test matches bool hasMatch = false; // The route '/bar/foo' will fail to match as this route has never been inserted. hasMatch = ztrie_matches (self, "/bar/foo"); assert (!hasMatch); // The route '/foo/bar' will match and we can obtain the data associated with it. hasMatch = ztrie_matches (self, "/foo/bar"); assert (hasMatch); int foo_bar_hit_data = *((int *) ztrie_hit_data (self)); assert (foo_bar_data == foo_bar_hit_data); // This route is part of another but is no endpoint itself thus the matches will fail. hasMatch = ztrie_matches (self, "/baz/blub"); assert (!hasMatch); // This route will match our named regular expressions route. Thus we can extract data // from the route by their names. hasMatch = ztrie_matches (self, "/baz/blub/--11/abc23"); assert (hasMatch); char *match_data = (char *) ztrie_hit_data (self); assert (streq ("Hello World!", match_data)); zhashx_t *parameters = ztrie_hit_parameters (self); assert (zhashx_size (parameters) == 4); assert (streq ("blub", (char *) zhashx_lookup (parameters, "name"))); assert (streq ("11", (char *) zhashx_lookup (parameters, "id"))); assert (streq ("abc", (char *) zhashx_lookup (parameters, "street"))); assert (streq ("23", (char *) zhashx_lookup (parameters, "nr"))); zhashx_destroy (¶meters); // This will match our asterisk route '/config/bar/*'. As the result we // can obtain the asterisk matched part of the route. hasMatch = ztrie_matches (self, "/config/bar/foo/bar"); assert (hasMatch); assert (streq (ztrie_hit_asterisk_match (self), "foo/bar")); zstr_free (&data); ztrie_destroy (&self); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zhash.c0000664000372000037200000007223013222211156015437 0ustar00travistravis00000000000000/* ========================================================================= zhash - simple generic hash container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header zhash is an expandable hash table container. This is a simple container. For heavy-duty applications we recommend using zhashx. @discuss Note that it's relatively slow (~50K insertions/deletes per second), so don't do inserts/updates on the critical path for message I/O. It can do ~2.5M lookups per second for 16-char keys. Timed on a 1.6GHz CPU. @end */ #include "czmq_classes.h" // Hash table performance parameters #define INITIAL_SIZE 255 // Initial size in items #define LOAD_FACTOR 75 // Percent loading before splitting #define GROWTH_FACTOR 200 // Increase in % after splitting // Hash item, used internally only typedef struct _item_t { void *value; // Opaque item value struct _item_t *next; // Next item in the hash slot size_t index; // Index of item in table char *key; // Item's original key zhash_free_fn *free_fn; // Value free function if any } item_t; // --------------------------------------------------------------------- // Structure of our class struct _zhash_t { size_t size; // Current size of hash table size_t limit; // Current hash table limit item_t **items; // Array of items size_t cached_index; // Avoids duplicate hash calculations bool autofree; // If true, free values in destructor size_t cursor_index; // For first/next iteration item_t *cursor_item; // For first/next iteration const char *cursor_key; // After first/next call, points to key zlist_t *comments; // File comments, if any time_t modified; // Set during zhash_load char *filename; // Set during zhash_load }; // Local helper functions static uint s_item_hash (const char *key, size_t limit); static item_t *s_item_lookup (zhash_t *self, const char *key); static item_t *s_item_insert (zhash_t *self, const char *key, void *value); static void s_item_destroy (zhash_t *self, item_t *item, bool hard); // -------------------------------------------------------------------------- // Hash table constructor zhash_t * zhash_new (void) { zhash_t *self = (zhash_t *) zmalloc (sizeof (zhash_t)); assert (self); self->limit = INITIAL_SIZE; self->items = (item_t **) zmalloc (sizeof (item_t *) * self->limit); assert (self->items); return self; } // -------------------------------------------------------------------------- // Hash table destructor void zhash_destroy (zhash_t **self_p) { assert (self_p); if (*self_p) { zhash_t *self = *self_p; uint index; for (index = 0; index < self->limit; index++) { // Destroy all items in this hash bucket item_t *cur_item = self->items [index]; while (cur_item) { item_t *next_item = cur_item->next; s_item_destroy (self, cur_item, true); cur_item = next_item; } } if (self->items) freen (self->items); zlist_destroy (&self->comments); freen (self->filename); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Local helper function // Destroy item in hash table, item must exist in table static void s_item_destroy (zhash_t *self, item_t *item, bool hard) { // Find previous item since it's a singly-linked list item_t *cur_item = self->items [item->index]; item_t **prev_item = &(self->items [item->index]); while (cur_item) { if (cur_item == item) break; prev_item = &(cur_item->next); cur_item = cur_item->next; } assert (cur_item); *prev_item = item->next; self->size--; if (hard) { if (item->free_fn) (item->free_fn) (item->value); else if (self->autofree) freen (item->value); freen (item->key); self->cursor_item = NULL; self->cursor_key = NULL; freen (item); } } // -------------------------------------------------------------------------- // Insert item into hash table with specified key and item // If key is already present returns -1 and leaves existing item unchanged // Returns 0 on success. int zhash_insert (zhash_t *self, const char *key, void *value) { assert (self); assert (key); // If we're exceeding the load factor of the hash table, // resize it according to the growth factor if (self->size >= self->limit * LOAD_FACTOR / 100) { // Create new hash table size_t new_limit = self->limit * GROWTH_FACTOR / 100; item_t **new_items = (item_t **) zmalloc (sizeof (item_t *) * new_limit); if (!new_items) return -1; // Move all items to the new hash table, rehashing to // take into account new hash table limit uint index; for (index = 0; index != self->limit; index++) { item_t *cur_item = self->items [index]; while (cur_item) { item_t *next_item = cur_item->next; uint new_index = s_item_hash (cur_item->key, new_limit); cur_item->index = new_index; cur_item->next = new_items [new_index]; new_items [new_index] = cur_item; cur_item = next_item; } } // Destroy old hash table freen (self->items); self->items = new_items; self->limit = new_limit; } return s_item_insert (self, key, value)? 0: -1; } // -------------------------------------------------------------------------- // Local helper function // Compute hash for key string static uint s_item_hash (const char *key, size_t limit) { // Modified Bernstein hashing function uint key_hash = 0; while (*key) key_hash = 33 * key_hash ^ *key++; key_hash %= limit; return key_hash; } // -------------------------------------------------------------------------- // Local helper function // Insert new item into hash table, returns item // If item already existed, returns NULL static item_t * s_item_insert (zhash_t *self, const char *key, void *value) { // Check that item does not already exist in hash table // Leaves self->cached_index with calculated hash item item_t *item = s_item_lookup (self, key); if (item == NULL) { item = (item_t *) zmalloc (sizeof (item_t)); assert (item); // If necessary, take duplicate of item (string) value if (self->autofree) { value = strdup ((char *) value); assert (value); } item->value = value; item->key = strdup (key); item->index = self->cached_index; // Insert into start of bucket list item->next = self->items [self->cached_index]; self->items [self->cached_index] = item; self->size++; } else item = NULL; // Signal duplicate insertion return item; } // -------------------------------------------------------------------------- // Local helper function // Lookup item in hash table, returns item or NULL static item_t * s_item_lookup (zhash_t *self, const char *key) { // Look in bucket list for item by key self->cached_index = s_item_hash (key, self->limit); item_t *item = self->items [self->cached_index]; while (item) { if (streq (item->key, key)) break; item = item->next; } return item; } // -------------------------------------------------------------------------- // Update item into hash table with specified key and item. // If key is already present, destroys old item and inserts new one. // Use free_fn method to ensure deallocator is properly called on item. void zhash_update (zhash_t *self, const char *key, void *value) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) { if (item->free_fn) (item->free_fn) (item->value); else if (self->autofree) freen (item->value); // If necessary, take duplicate of item (string) value if (self->autofree) { value = strdup ((char *) value); assert (value); } item->value = value; } else zhash_insert (self, key, value); } // -------------------------------------------------------------------------- // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void zhash_delete (zhash_t *self, const char *key) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) s_item_destroy (self, item, true); } // -------------------------------------------------------------------------- // Look for item in hash table and return its item, or NULL void * zhash_lookup (zhash_t *self, const char *key) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) return item->value; else return NULL; } // -------------------------------------------------------------------------- // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. If the new key already exists, deletes old item. int zhash_rename (zhash_t *self, const char *old_key, const char *new_key) { item_t *old_item = s_item_lookup (self, old_key); item_t *new_item = s_item_lookup (self, new_key); if (old_item && !new_item) { s_item_destroy (self, old_item, false); freen (old_item->key); old_item->key = strdup (new_key); assert (old_item->key); old_item->index = self->cached_index; old_item->next = self->items [self->cached_index]; self->items [self->cached_index] = old_item; self->size++; return 0; } else return -1; } // -------------------------------------------------------------------------- // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zhash_freefn (zhash_t *self, const char *key, zhash_free_fn free_fn) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) { item->free_fn = free_fn; return item->value; } else return NULL; } // -------------------------------------------------------------------------- // Return size of hash table size_t zhash_size (zhash_t *self) { assert (self); return self->size; } // -------------------------------------------------------------------------- // Make copy of hash table // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. zhash_t * zhash_dup (zhash_t *self) { if (!self) return NULL; zhash_t *copy = zhash_new (); zhash_autofree (copy); if (copy) { uint index; for (index = 0; index != self->limit; index++) { item_t *item = self->items [index]; while (item) { zhash_insert (copy, item->key, item->value); item = item->next; } } } return copy; } // -------------------------------------------------------------------------- // Return keys for items in table zlist_t * zhash_keys (zhash_t *self) { assert (self); zlist_t *keys = zlist_new (); if (!keys) return NULL; zlist_autofree (keys); uint index; for (index = 0; index != self->limit; index++) { item_t *item = self->items [index]; while (item) { zlist_append (keys, item->key); item = item->next; } } return keys; } // -------------------------------------------------------------------------- // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. NOTE: do NOT modify the table // while iterating. void * zhash_first (zhash_t *self) { assert (self); // Point to before or at first item self->cursor_index = 0; self->cursor_item = self->items [self->cursor_index]; // Now scan forwards to find it, leave cursor after item return zhash_next (self); } // -------------------------------------------------------------------------- // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhash_first() to process all items in a hash table. If you need the // items in sorted order, use zhash_keys() and then zlist_sort(). NOTE: // do NOT modify the table while iterating. void * zhash_next (zhash_t *self) { assert (self); // Scan forward from cursor until we find an item while (self->cursor_item == NULL) { if (self->cursor_index < self->limit - 1) self->cursor_index++; else return NULL; // At end of table // Get first item in next bucket self->cursor_item = self->items [self->cursor_index]; } // We have an item, so return it, and bump past it assert (self->cursor_item); item_t *item = self->cursor_item; self->cursor_key = item->key; self->cursor_item = self->cursor_item->next; return item->value; } // -------------------------------------------------------------------------- // After a successful first/next method, returns the key for the item that // was returned. This is a constant string that you may not modify or // deallocate, and which lasts as long as the item in the hash. After an // unsuccessful first/next, returns NULL. const char * zhash_cursor (zhash_t *self) { assert (self); return self->cursor_key; } // -------------------------------------------------------------------------- // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. void zhash_comment (zhash_t *self, const char *format, ...) { if (format) { if (!self->comments) { self->comments = zlist_new (); if (!self->comments) return; zlist_autofree (self->comments); } va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); if (string) zlist_append (self->comments, string); zstr_free (&string); } else zlist_destroy (&self->comments); } // -------------------------------------------------------------------------- // Save hash table to a text file in name=value format // Hash values must be printable strings. // Returns 0 if OK, else -1 if a file error occurred int zhash_save (zhash_t *self, const char *filename) { assert (self); FILE *handle = fopen (filename, "w"); if (!handle) return -1; // Failed to create file if (self->comments) { char *comment = (char *) zlist_first (self->comments); while (comment) { fprintf (handle, "# %s\n", comment); comment = (char *) zlist_next (self->comments); } fprintf (handle, "\n"); } uint index; for (index = 0; index != self->limit; index++) { item_t *item = self->items [index]; while (item) { fprintf (handle, "%s=%s\n", item->key, (char *) item->value); item = item->next; } } fclose (handle); return 0; } // -------------------------------------------------------------------------- // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings. // Returns 0 if OK, else -1 if a file was not readable. int zhash_load (zhash_t *self, const char *filename) { assert (self); zhash_autofree (self); // Whether or not file exists, we'll track the filename and last // modification date (0 for unknown files), so that zhash_refresh () // will always work after zhash_load (), to load a newly-created // file. // Take copy of filename in case self->filename is same string. char *filename_copy = strdup (filename); assert (filename_copy); freen (self->filename); self->filename = filename_copy; self->modified = zsys_file_modified (self->filename); FILE *handle = fopen (self->filename, "r"); if (handle) { char *buffer = (char *) zmalloc (1024); assert (buffer); while (fgets (buffer, 1024, handle)) { // Skip lines starting with "#" or that do not look like // name=value data. char *equals = strchr (buffer, '='); if (buffer [0] == '#' || equals == buffer || !equals) continue; // Buffer may end in newline, which we don't want if (buffer [strlen (buffer) - 1] == '\n') buffer [strlen (buffer) - 1] = 0; *equals++ = 0; zhash_update (self, buffer, equals); } freen (buffer); fclose (handle); } else return -1; // Failed to open file for reading return 0; } // -------------------------------------------------------------------------- // When a hash table was loaded from a file by zhash_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int zhash_refresh (zhash_t *self) { assert (self); if (self->filename) { if (zsys_file_modified (self->filename) > self->modified && zsys_file_stable (self->filename)) { // Empty the hash table; code is copied from zhash_destroy uint index; for (index = 0; index < self->limit; index++) { // Destroy all items in this hash bucket item_t *cur_item = self->items [index]; while (cur_item) { item_t *next_item = cur_item->next; s_item_destroy (self, cur_item, true); cur_item = next_item; } } zhash_load (self, self->filename); } } return 0; } // -------------------------------------------------------------------------- // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. zframe_t * zhash_pack (zhash_t *self) { assert (self); // First, calculate packed data size size_t frame_size = 4; // Dictionary size, number-4 uint index; for (index = 0; index < self->limit; index++) { item_t *item = self->items [index]; while (item) { // We store key as short string frame_size += 1 + strlen ((char *) item->key); // We store value as long string frame_size += 4 + strlen ((char *) item->value); item = item->next; } } // Now serialize items into the frame zframe_t *frame = zframe_new (NULL, frame_size); if (!frame) return NULL; byte *needle = zframe_data (frame); // Store size as number-4 *(uint32_t *) needle = htonl ((uint32_t) self->size); needle += 4; for (index = 0; index < self->limit; index++) { item_t *item = self->items [index]; while (item) { // Store key as string *needle++ = (byte) strlen ((char *) item->key); memcpy (needle, item->key, strlen ((char *) item->key)); needle += strlen ((char *) item->key); // Store value as longstr size_t length = strlen ((char *) item->value); *(uint32_t *) needle = htonl ((u_long) length); needle += 4; memcpy (needle, (char *) item->value, strlen ((char *) item->value)); needle += strlen ((char *) item->value); item = item->next; } } return frame; } // -------------------------------------------------------------------------- // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhash_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. zhash_t * zhash_unpack (zframe_t *frame) { zhash_t *self = zhash_new (); if (!self) return NULL; assert (frame); if (zframe_size (frame) < 4) return self; // Arguable... byte *needle = zframe_data (frame); byte *ceiling = needle + zframe_size (frame); size_t nbr_items = ntohl (*(uint32_t *) needle); needle += 4; while (nbr_items && needle < ceiling) { // Get key as string size_t key_size = *needle++; if (needle + key_size <= ceiling) { char key [256]; memcpy (key, needle, key_size); key [key_size] = 0; needle += key_size; // Get value as longstr if (needle + 4 <= ceiling) { size_t value_size = ntohl (*(uint32_t *) needle); needle += 4; // Be wary of malformed frames if (needle + value_size <= ceiling) { char *value = (char *) malloc (value_size + 1); memcpy (value, needle, value_size); value [value_size] = 0; needle += value_size; // Hash takes ownership of value if (zhash_insert (self, key, value)) { zhash_destroy (&self); break; } } } } } // Hash will free values in destructor if (self) zhash_autofree (self); return self; } // -------------------------------------------------------------------------- // Set hash for automatic value destruction void zhash_autofree (zhash_t *self) { assert (self); self->autofree = true; } // -------------------------------------------------------------------------- // Runs selftest of class // void zhash_test (bool verbose) { printf (" * zhash: "); // @selftest zhash_t *hash = zhash_new (); assert (hash); assert (zhash_size (hash) == 0); assert (zhash_first (hash) == NULL); assert (zhash_cursor (hash) == NULL); // Insert some items int rc; rc = zhash_insert (hash, "DEADBEEF", "dead beef"); char *item = (char *) zhash_first (hash); assert (streq (zhash_cursor (hash), "DEADBEEF")); assert (streq (item, "dead beef")); assert (rc == 0); rc = zhash_insert (hash, "ABADCAFE", "a bad cafe"); assert (rc == 0); rc = zhash_insert (hash, "C0DEDBAD", "coded bad"); assert (rc == 0); rc = zhash_insert (hash, "DEADF00D", "dead food"); assert (rc == 0); assert (zhash_size (hash) == 4); // Look for existing items item = (char *) zhash_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); item = (char *) zhash_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); item = (char *) zhash_lookup (hash, "C0DEDBAD"); assert (streq (item, "coded bad")); item = (char *) zhash_lookup (hash, "DEADF00D"); assert (streq (item, "dead food")); // Look for non-existent items item = (char *) zhash_lookup (hash, "foo"); assert (item == NULL); // Try to insert duplicate items rc = zhash_insert (hash, "DEADBEEF", "foo"); assert (rc == -1); item = (char *) zhash_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); // Some rename tests // Valid rename, key is now LIVEBEEF rc = zhash_rename (hash, "DEADBEEF", "LIVEBEEF"); assert (rc == 0); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an unknown item to a non-existent key rc = zhash_rename (hash, "WHATBEEF", "NONESUCH"); assert (rc == -1); // Trying to rename an unknown item to an existing key rc = zhash_rename (hash, "WHATBEEF", "LIVEBEEF"); assert (rc == -1); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an existing item to another existing item rc = zhash_rename (hash, "LIVEBEEF", "ABADCAFE"); assert (rc == -1); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); item = (char *) zhash_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); // Test keys method zlist_t *keys = zhash_keys (hash); assert (zlist_size (keys) == 4); zlist_destroy (&keys); // Test dup method zhash_t *copy = zhash_dup (hash); assert (zhash_size (copy) == 4); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); // Test pack/unpack methods zframe_t *frame = zhash_pack (hash); copy = zhash_unpack (frame); zframe_destroy (&frame); assert (zhash_size (copy) == 4); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); // Test save and load zhash_comment (hash, "This is a test file"); zhash_comment (hash, "Created by %s", "czmq_selftest"); zhash_save (hash, ".cache"); copy = zhash_new (); assert (copy); zhash_load (copy, ".cache"); item = (char *) zhash_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhash_destroy (©); zsys_file_delete (".cache"); // Delete a item zhash_delete (hash, "LIVEBEEF"); item = (char *) zhash_lookup (hash, "LIVEBEEF"); assert (item == NULL); assert (zhash_size (hash) == 3); // Check that the queue is robust against random usage struct { char name [100]; bool exists; } testset [200]; memset (testset, 0, sizeof (testset)); int testmax = 200, testnbr, iteration; srandom ((unsigned) time (NULL)); for (iteration = 0; iteration < 25000; iteration++) { testnbr = randof (testmax); assert (testnbr != testmax); assert (testnbr < testmax); if (testset [testnbr].exists) { item = (char *) zhash_lookup (hash, testset [testnbr].name); assert (item); zhash_delete (hash, testset [testnbr].name); testset [testnbr].exists = false; } else { sprintf (testset [testnbr].name, "%x-%x", rand (), rand ()); if (zhash_insert (hash, testset [testnbr].name, "") == 0) testset [testnbr].exists = true; } } // Test 10K lookups for (iteration = 0; iteration < 10000; iteration++) item = (char *) zhash_lookup (hash, "DEADBEEFABADCAFE"); // Destructor should be safe to call twice zhash_destroy (&hash); zhash_destroy (&hash); assert (hash == NULL); // Test autofree; automatically copies and frees string values hash = zhash_new (); assert (hash); zhash_autofree (hash); char value [255]; strcpy (value, "This is a string"); rc = zhash_insert (hash, "key1", value); assert (rc == 0); strcpy (value, "Inserting with the same key will fail"); rc = zhash_insert (hash, "key1", value); assert (rc == -1); strcpy (value, "Ring a ding ding"); rc = zhash_insert (hash, "key2", value); assert (rc == 0); assert (streq ((char *) zhash_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhash_lookup (hash, "key2"), "Ring a ding ding")); zhash_destroy (&hash); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zsp.c0000664000372000037200000000617413222211156015142 0ustar00travistravis00000000000000/* ========================================================================= zsp - description Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header zsp - ZSubProc testing tool @discuss Command line tool to support tests for zsubproc class @end */ #include "czmq_classes.h" int main (int argc, char *argv []) { int argn; bool verbose = false; bool use_stdin = false; bool use_stderr = false; bool use_stdout = false; char *message = NULL; for (argn = 1; argn < argc; argn++) { if (streq (argv [argn], "--help") || streq (argv [argn], "-h")) { puts ("zsp [options] ..."); #if ! defined (__WINDOWS__) puts (" --stdin / -i read input from stdin"); #endif puts (" --stderr / -e output on stderr"); puts (" --stdout / -o output on stdout"); puts (" --verbose / -v verbose mode"); puts (" --help / -h this information"); return 0; } else if (streq (argv [argn], "--stderr") || streq (argv [argn], "-e")) use_stderr = true; else if (streq (argv [argn], "--stdout") || streq (argv [argn], "-o")) use_stdout = true; else if (streq (argv [argn], "--stdin") || streq (argv [argn], "-i")) use_stdin = true; else if (streq (argv [argn], "--verbose") || streq (argv [argn], "-v")) verbose = true; else if (argv [argn][0] == '-') { printf ("Unknown option: %s\n", argv [argn]); return 1; } else { message = argv[argn]; } } zsys_init (); if (verbose) zsys_debug ("argn=%d, argc=%d", argn, argc); message = "Lorem ipsum"; if (getenv ("ZSP_MESSAGE")) message = getenv ("ZSP_MESSAGE"); zfile_t *stdinf = NULL; if (use_stdin) { stdinf = zfile_new ("/dev", "stdin"); int r = zfile_input (stdinf); assert (r == 0); } // Insert main code here while (!zsys_interrupted) { #if ! defined (__WINDOWS__) if (use_stdin) { const char *line = zfile_readln (stdinf); if (!line && errno != 0) { zsys_error ("Error reading stdin: %s", strerror (errno)); exit (EXIT_FAILURE); } if (zfile_eof (stdinf) || !line) break; message = (char*) line; } #endif if (use_stderr) fprintf (stderr, "%s\n", message); if (use_stdout) fprintf (stdout, "%s\n", message); zclock_sleep (50); } zfile_destroy (&stdinf); return 0; } czmq-4.1.0/src/zargs.c0000664000372000037200000002073013222211156015446 0ustar00travistravis00000000000000/* ========================================================================= zargs - Platform independent command line argument parsing helpers Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header zargs - Platform independent command line argument parsing helpers Platform independent command line argument parsing helpers There are two kind of elements provided by this class foo --named-parameter --parameter with_value positional arguments -a gain-parameter zargs keeps poision only for arguments, parameters are to be accessed like hash. It DOES: * provide easy to use CLASS compatible API for accessing argv * is platform independent * provide getopt_long style -- argument, which delimits parameters from arguments * makes parameters positon independent It does NOT * change argv * provide a "declarative" way to define command line interface In future it SHALL * hide several formats of command line to one (-Idir, --include=dir, --include dir are the same from API pov) @discuss @end */ #include "czmq_classes.h" // Structure of our class static char *ZARG_PARAM_EMPTY = ""; struct _zargs_t { char *progname; // program name aka argv [0] zlist_t *arguments; // positional arguments zhash_t *parameters; // --named parameters }; // -------------------------------------------------------------------------- // Create a new zargs zargs_t * zargs_new (int argc, char **argv) { assert (argc > 0); assert (argv); zargs_t *self = (zargs_t *) zmalloc (sizeof (zargs_t)); assert (self); // Initialize class properties here self->progname = argv [0]; assert (self->progname); self->arguments = zlist_new (); assert (self->arguments); self->parameters = zhash_new (); assert (self->parameters); if (argc == 1) return self; int idx = 1; bool params_only = false; while (argv [idx]) { if (params_only || argv [idx][0] != '-') zlist_append (self->arguments, argv [idx]); else { if (streq (argv [idx], "--")) { params_only = true; idx ++; continue; } else if (argv [idx+1] && argv [idx+1][0] != '-') { zhash_insert (self->parameters, argv [idx], argv [idx+1]); idx ++; } else { zhash_insert (self->parameters, argv [idx], ZARG_PARAM_EMPTY); } } idx ++; } return self; } // -------------------------------------------------------------------------- // Destroy the zargs void zargs_destroy (zargs_t **self_p) { assert (self_p); if (*self_p) { zargs_t *self = *self_p; // Free class properties here // Free object itself zlist_destroy (&self->arguments); zhash_destroy (&self->parameters); free (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Return the program name (argv[0]) const char * zargs_progname (zargs_t *self) { assert (self); return self->progname; } // -------------------------------------------------------------------------- // Return the number of command line arguments size_t zargs_arguments (zargs_t *self) { assert (self); return zlist_size (self->arguments); } // -------------------------------------------------------------------------- // Return first command line argument const char * zargs_first (zargs_t *self) { assert (self); return (const char*) zlist_first (self->arguments); } // -------------------------------------------------------------------------- // Return next command line argument const char * zargs_next (zargs_t *self) { assert (self); return (const char*) zlist_next (self->arguments); } // -------------------------------------------------------------------------- // Return first command line parameter value const char * zargs_param_first (zargs_t *self) { assert (self); return (const char*) zhash_first (self->parameters); } // -------------------------------------------------------------------------- // Return next command line parameter value const char * zargs_param_next (zargs_t *self) { assert (self); return (const char*) zhash_next (self->parameters); } // -------------------------------------------------------------------------- // Return current command line parameter name const char * zargs_param_name (zargs_t *self) { assert (self); return (const char*) zhash_cursor (self->parameters); } // -------------------------------------------------------------------------- // Return value of named parameter, NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const char * zargs_param_lookup (zargs_t *self, const char *name) { assert (self); assert (name); const char *ret = NULL; ret = (const char*) zhash_lookup (self->parameters, name); return ret; } // -------------------------------------------------------------------------- // Return value of named parameter(s), NULL if no given parameter has // been specified, or special value for wich zargs_param_empty () // returns true. const char * zargs_param_lookupx (zargs_t *self, const char *name, ...) { assert (self); const char *ret = NULL; va_list args; va_start (args, name); while (name) { ret = zargs_param_lookup (self, name); if (ret) break; name = va_arg (args, const char *); } va_end (args); return ret; } // -------------------------------------------------------------------------- bool zargs_has_help (zargs_t *self) { return zargs_param_lookupx (self, "--help", "-h", NULL) != NULL; } // -------------------------------------------------------------------------- // check if argument had a value or not bool zargs_param_empty (const char* arg) { return arg && arg == ZARG_PARAM_EMPTY; } // -------------------------------------------------------------------------- // Print the zargs instance void zargs_print (zargs_t *self) { assert (self); fprintf (stderr, "%s ", self->progname); for (const char *pvalue = zargs_param_first (self); pvalue != NULL; pvalue = zargs_param_next (self)) { const char *pname = zargs_param_name (self); if (pvalue == ZARG_PARAM_EMPTY) fprintf (stderr, "%s : None ", pname); else fprintf (stderr, "%s : %s ", pname, pvalue); fprintf (stderr, ", "); } for (const char *arg = zargs_first (self); arg != NULL; arg = zargs_next (self)) { fprintf (stderr, "%s ", arg); } fputs ("", stderr); } // -------------------------------------------------------------------------- // Self test of this class void zargs_test (bool verbose) { zsys_init (); printf (" * zargs: "); // @selftest // Simple create/destroy test char *argv1[] = {"progname", "--named1", "-n1", "val1", "positional1", "--with", "value", "--with2=value2", "-W3value3", "--", "--thisis", "considered", "positional", NULL}; zargs_t *self = zargs_new (13, argv1); assert (self); assert (streq (zargs_progname (self), "progname")); assert (streq (zargs_first (self), "positional1")); assert (streq (zargs_next (self), "--thisis")); assert (streq (zargs_next (self), "considered")); assert (streq (zargs_next (self), "positional")); assert (!zargs_next (self)); assert (zargs_param_empty (zargs_param_lookup (self, "--named1"))); assert (!zargs_param_empty (zargs_param_lookup (self, "-n1"))); assert (streq (zargs_param_lookupx (self, "--not at all", "-n1", NULL), "val1")); // TODO: this does not look like an easy hack w/o allocating extra memory // ??? //assert (streq (zargs_param_lookup (self, "--with", NULL), "value2")); zargs_destroy (&self); // @end printf ("OK\n"); } czmq-4.1.0/src/zlistx.c0000664000372000037200000005375113222211156015666 0ustar00travistravis00000000000000/* ========================================================================= zlistx - extended generic list container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Provides a generic doubly-linked list container. This container provides hooks for duplicator, comparator, and destructor functions. These tie into CZMQ and standard C semantics, so e.g. for string items you can use strdup, strcmp, and zstr_free. To store custom objects, define your own duplicator and comparator, and use the standard object destructor. @discuss This is a reworking of the simpler zlist container. It is faster to insert and delete items anywhere in the list, and to keep ordered lists. @end */ #include "czmq_classes.h" #define NODE_TAG 0x0006cafe // List node, used internally only typedef struct _node_t { uint32_t tag; // Object tag for validity checking struct _node_t *next; struct _node_t *prev; void *item; } node_t; // --------------------------------------------------------------------- // Structure of our class struct _zlistx_t { node_t *head; // First item in list, if any node_t *cursor; // Current cursors for iteration size_t size; // Number of items in list // Function callbacks for duplicating and destroying items, if any zlistx_duplicator_fn *duplicator; zlistx_destructor_fn *destructor; zlistx_comparator_fn *comparator; }; // Initialize a list node and attach to the prev and next nodes, or itself // if these are specified as null. Returns new node. static node_t * s_node_new (void *item) { node_t *self = (node_t *) zmalloc (sizeof (node_t)); assert (self); self->tag = NODE_TAG; self->prev = self; self->next = self; self->item = item; return self; } // Removing and inserting a node are actually the same operation: // swap (node->next, prev->next) // swap (node->prev, next->prev) // Which require only that the node be initialized to point to itself. // When inserting, node goes in between prev and next. static void s_node_relink (node_t *node, node_t *prev, node_t *next) { node_t *temp = node->next; node->next = prev->next; prev->next = temp; temp = node->prev; node->prev = next->prev; next->prev = temp; } // Default comparator static int s_comparator (const void *item1, const void *item2) { if (item1 == item2) return 0; else if (item1 < item2) return -1; else return 1; } // -------------------------------------------------------------------------- // Create a new, empty list. zlistx_t * zlistx_new (void) { zlistx_t *self = (zlistx_t *) zmalloc (sizeof (zlistx_t)); assert (self); self->head = s_node_new (NULL); assert (self->head); self->cursor = self->head; self->comparator = s_comparator; return self; } // -------------------------------------------------------------------------- // Destroy a list. If an item destructor was specified, all items in the // list are automatically destroyed as well. void zlistx_destroy (zlistx_t **self_p) { assert (self_p); if (*self_p) { zlistx_t *self = *self_p; zlistx_purge (self); freen (self->head); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Add an item to the head of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success. void * zlistx_add_start (zlistx_t *self, void *item) { assert (self); assert (item); if (self->duplicator) { item = (self->duplicator) (item); assert (item); } node_t *node = s_node_new (item); assert (node); // Insert after head s_node_relink (node, self->head, self->head->next); self->cursor = self->head; self->size++; return node; } // -------------------------------------------------------------------------- // Add an item to the tail of the list. Calls the item duplicator, if any, // on the item. Resets cursor to list head. Returns an item handle on // success. void * zlistx_add_end (zlistx_t *self, void *item) { assert (self); assert (item); if (self->duplicator) { item = (self->duplicator) (item); assert (item); } node_t *node = s_node_new (item); assert (node); // Insert before head s_node_relink (node, self->head->prev, self->head); self->cursor = self->head; self->size++; return node; } // -------------------------------------------------------------------------- // Return the number of items in the list size_t zlistx_size (zlistx_t *self) { assert (self); return self->size; } // -------------------------------------------------------------------------- // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor as-is. void * zlistx_head (zlistx_t *self) { assert (self); return self->head? self->head->item: NULL; } // -------------------------------------------------------------------------- // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor as-is. void * zlistx_tail (zlistx_t *self) { assert (self); return self->head? self->head->prev->item: NULL; } // -------------------------------------------------------------------------- // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * zlistx_first (zlistx_t *self) { assert (self); self->cursor = self->head->next; return self->cursor == self->head? NULL: self->cursor->item; } // -------------------------------------------------------------------------- // Return the next item. At the end of the list (or in an empty list), // returns NULL. Use repeated zlistx_next () calls to work through the list // from zlistx_first (). First time, acts as zlistx_first(). void * zlistx_next (zlistx_t *self) { assert (self); self->cursor = self->cursor->next; return self->cursor == self->head? NULL: self->cursor->item; } // -------------------------------------------------------------------------- // Return the previous item. At the start of the list (or in an empty list), // returns NULL. Use repeated zlistx_prev () calls to work through the list // backwards from zlistx_last (). First time, acts as zlistx_last(). void * zlistx_prev (zlistx_t *self) { assert (self); self->cursor = self->cursor->prev; return self->cursor == self->head? NULL: self->cursor->item; } // -------------------------------------------------------------------------- // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * zlistx_last (zlistx_t *self) { assert (self); self->cursor = self->head->prev; return self->cursor == self->head? NULL: self->cursor->item; } // -------------------------------------------------------------------------- // Returns the value of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * zlistx_item (zlistx_t *self) { assert (self); return self->cursor == self->head? NULL: self->cursor->item; } // -------------------------------------------------------------------------- // Returns the handle of the item at the cursor, or NULL if the cursor is // not pointing to an item. void * zlistx_cursor (zlistx_t *self) { assert (self); return self->cursor == self->head? NULL: self->cursor; } // -------------------------------------------------------------------------- // Returns the item associated with the given list handle, or NULL if passed // handle is NULL. asserts that the passed in ptr points to a list node. void * zlistx_handle_item (void *handle) { if (!handle) return NULL; node_t *node = (node_t *) handle; assert (node->tag == NODE_TAG); return node->item; } // -------------------------------------------------------------------------- // Find an item in the list, searching from the start. Uses the item // comparator, if any, else compares item values directly. Returns the // item handle found, or NULL. Sets the cursor to the found item, if any. void * zlistx_find (zlistx_t *self, void *item) { assert (self); assert (item); // Scan list for item, this is a O(N) operation node_t *node = self->head->next; while (node != self->head) { if (self->comparator (node->item, item) == 0) { self->cursor = node; return node; } node = node->next; } return NULL; } // -------------------------------------------------------------------------- // Detach an item from the list, using its handle. The item is not modified, // and the caller is responsible for destroying it if necessary. If handle is // null, detaches the first item on the list. Returns item that was detached, // or null if none was. If cursor was at item, moves cursor to previous item, // so you can detach items while iterating forwards through a list. void * zlistx_detach (zlistx_t *self, void *handle) { assert (self); node_t *node = (node_t *) handle; if (!node) node = self->head->next == self->head? NULL: self->head->next; // Now detach node from list, without destroying item if (node) { // Reposition cursor so that delete/detach works during iteration if (self->cursor == node) self->cursor = self->cursor->prev; // Remove node from list assert (node->tag == NODE_TAG); s_node_relink (node, node->prev, node->next); node->tag = 0xDeadBeef; void *item = node->item; freen (node); self->size--; return item; } else { assert (self->size == 0); return NULL; } } // -------------------------------------------------------------------------- // Detach item at the cursor, if any, from the list. The item is not modified, // and the caller is responsible for destroying it as necessary. Returns item // that was detached, or null if none was. Moves cursor to previous item, so // you can detach items while iterating forwards through a list. void * zlistx_detach_cur (zlistx_t *self) { return zlistx_detach (self, zlistx_cursor (self)); } // -------------------------------------------------------------------------- // Delete an item, using its handle. Calls the item destructor is any is // set. If handle is null, deletes the first item on the list. Returns 0 // if an item was deleted, -1 if not. If cursor was at item, moves cursor // to previous item, so you can delete items while iterating forwards // through a list. int zlistx_delete (zlistx_t *self, void *handle) { assert (self); void *item = zlistx_detach (self, handle); if (item) { if (self->destructor) self->destructor (&item); return 0; } else return -1; } // -------------------------------------------------------------------------- // Move an item to the start of the list, via its handle. void zlistx_move_start (zlistx_t *self, void *handle) { assert (self); assert (handle); node_t *node = (node_t *) handle; assert (node->tag == NODE_TAG); node_t *next = self->head->next; if (node != next) { // Remove node from list, insert before next node s_node_relink (node, node->prev, node->next); s_node_relink (node, next->prev, next); } } // -------------------------------------------------------------------------- // Move an item to the end of the list, via its handle. void zlistx_move_end (zlistx_t *self, void *handle) { assert (self); assert (handle); node_t *node = (node_t *) handle; assert (node->tag == NODE_TAG); node_t *prev = self->head->prev; if (node != prev) { // Remove node from list, insert after prev node s_node_relink (node, node->prev, node->next); s_node_relink (node, prev, prev->next); } } // -------------------------------------------------------------------------- // Remove all items from the list, and destroy them if the item destructor // is set. void zlistx_purge (zlistx_t *self) { assert (self); while (zlistx_size (self) > 0) zlistx_delete (self, NULL); } // -------------------------------------------------------------------------- // Sort the list. If an item comparator was set, calls that to compare // items, otherwise compares on item value. The sort is not stable, so may // reorder equal items. void zlistx_sort (zlistx_t *self) { // Uses a comb sort, which is simple and reasonably fast // See http://en.wikipedia.org/wiki/Comb_sort assert (self); size_t gap = self->size; bool swapped = false; while (gap > 1 || swapped) { gap = (size_t) ((double) gap / 1.3); node_t *base = self->head->next; node_t *test = self->head->next; size_t jump = gap; while (jump--) test = test->next; swapped = false; while (base != self->head && test != self->head) { if (self->comparator (base->item, test->item) > 0) { // We don't actually swap nodes, just the items in the nodes. // This is ridiculously simple and confuses the heck out of // me every time I re-read the code, as I expect to see the // nodes being swapped. Hence this comment. -- PH 2014/09/06 void *item = base->item; base->item = test->item; test->item = item; swapped = true; } base = base->next; test = test->next; } } } // -------------------------------------------------------------------------- // Create a new node and insert it into a sorted list. Calls the item // duplicator, if any, on the item. If low_value is true, starts searching // from the start of the list, otherwise searches from the end. Use the item // comparator, if any, to find where to place the new node. Returns a handle // to the new node, or NULL if memory was exhausted. Resets the cursor to the // list head. void * zlistx_insert (zlistx_t *self, void *item, bool low_value) { assert (self); if (self->duplicator) { item = (self->duplicator) (item); assert (item); } node_t *node = s_node_new (item); assert (node); zlistx_reorder (self, node, low_value); self->cursor = self->head; self->size++; return node; } // -------------------------------------------------------------------------- // Move an item, specified by handle, into position in a sorted list. Uses // the item comparator, if any, to determine the new location. If low_value // is true, starts searching from the start of the list, otherwise searches // from the end. void zlistx_reorder (zlistx_t *self, void *handle, bool low_value) { assert (self); assert (handle); node_t *node = (node_t *) handle; assert (node->tag == NODE_TAG); // Remove node from list, if it's attached s_node_relink (node, node->prev, node->next); if (low_value) { node_t *next = self->head->next; while (next != self->head) { if (self->comparator (node->item, next->item) <= 0) break; next = next->next; } // Relink node before next node s_node_relink (node, next->prev, next); } else { node_t *prev = self->head->prev; while (prev != self->head) { if (self->comparator (prev->item, node->item) <= 0) break; prev = prev->prev; } // Relink node after prev node s_node_relink (node, prev, prev->next); } } // -------------------------------------------------------------------------- // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. zlistx_t * zlistx_dup (zlistx_t *self) { if (!self) return NULL; zlistx_t *copy = zlistx_new (); if (copy) { // Copy item handlers copy->destructor = self->destructor; copy->duplicator = self->duplicator; copy->comparator = self->comparator; // Copy nodes node_t *node; for (node = self->head->next; node != self->head; node = node->next) zlistx_add_end (copy, node->item); } return copy; } // -------------------------------------------------------------------------- // Set a user-defined deallocator for list items; by default items are not // freed when the list is destroyed. void zlistx_set_destructor (zlistx_t *self, zlistx_destructor_fn destructor) { assert (self); self->destructor = destructor; } // -------------------------------------------------------------------------- // Set a user-defined duplicator for list items; by default items are not // copied when the list is duplicated. void zlistx_set_duplicator (zlistx_t *self, zlistx_duplicator_fn duplicator) { assert (self); self->duplicator = duplicator; } // -------------------------------------------------------------------------- // Set a user-defined comparator for zlistx_find and zlistx_sort; the method // must return -1, 0, or 1 depending on whether item1 is less than, equal to, // or greater than, item2. void zlistx_set_comparator (zlistx_t *self, zlistx_comparator_fn comparator) { assert (self); self->comparator = comparator; } // -------------------------------------------------------------------------- // Runs selftest of class void zlistx_test (bool verbose) { printf (" * zlistx: "); // @selftest zlistx_t *list = zlistx_new (); assert (list); assert (zlistx_size (list) == 0); // Test operations on an empty list assert (zlistx_first (list) == NULL); assert (zlistx_last (list) == NULL); assert (zlistx_next (list) == NULL); assert (zlistx_prev (list) == NULL); assert (zlistx_find (list, "hello") == NULL); assert (zlistx_delete (list, NULL) == -1); assert (zlistx_detach (list, NULL) == NULL); assert (zlistx_delete (list, NULL) == -1); assert (zlistx_detach (list, NULL) == NULL); zlistx_purge (list); zlistx_sort (list); // Use item handlers zlistx_set_destructor (list, (zlistx_destructor_fn *) zstr_free); zlistx_set_duplicator (list, (zlistx_duplicator_fn *) strdup); zlistx_set_comparator (list, (zlistx_comparator_fn *) strcmp); // Try simple insert/sort/delete/next assert (zlistx_next (list) == NULL); zlistx_add_end (list, "world"); assert (streq ((char *) zlistx_next (list), "world")); zlistx_add_end (list, "hello"); assert (streq ((char *) zlistx_prev (list), "hello")); zlistx_sort (list); assert (zlistx_size (list) == 2); void *handle = zlistx_find (list, "hello"); char *item1 = (char *) zlistx_item (list); char *item2 = (char *) zlistx_handle_item (handle); assert (item1 == item2); assert (streq (item1, "hello")); zlistx_delete (list, handle); assert (zlistx_size (list) == 1); char *string = (char *) zlistx_detach (list, NULL); assert (streq (string, "world")); freen (string); assert (zlistx_size (list) == 0); // Check next/back work // Now populate the list with items zlistx_add_start (list, "five"); zlistx_add_end (list, "six"); zlistx_add_start (list, "four"); zlistx_add_end (list, "seven"); zlistx_add_start (list, "three"); zlistx_add_end (list, "eight"); zlistx_add_start (list, "two"); zlistx_add_end (list, "nine"); zlistx_add_start (list, "one"); zlistx_add_end (list, "ten"); // Test our navigation skills assert (zlistx_size (list) == 10); assert (streq ((char *) zlistx_last (list), "ten")); assert (streq ((char *) zlistx_prev (list), "nine")); assert (streq ((char *) zlistx_prev (list), "eight")); assert (streq ((char *) zlistx_prev (list), "seven")); assert (streq ((char *) zlistx_prev (list), "six")); assert (streq ((char *) zlistx_prev (list), "five")); assert (streq ((char *) zlistx_first (list), "one")); assert (streq ((char *) zlistx_next (list), "two")); assert (streq ((char *) zlistx_next (list), "three")); assert (streq ((char *) zlistx_next (list), "four")); // Sort by alphabetical order zlistx_sort (list); assert (streq ((char *) zlistx_first (list), "eight")); assert (streq ((char *) zlistx_last (list), "two")); // Moving items around handle = zlistx_find (list, "six"); zlistx_move_start (list, handle); assert (streq ((char *) zlistx_first (list), "six")); zlistx_move_end (list, handle); assert (streq ((char *) zlistx_last (list), "six")); zlistx_sort (list); assert (streq ((char *) zlistx_last (list), "two")); // Copying a list zlistx_t *copy = zlistx_dup (list); assert (copy); assert (zlistx_size (copy) == 10); assert (streq ((char *) zlistx_first (copy), "eight")); assert (streq ((char *) zlistx_last (copy), "two")); zlistx_destroy (©); // Delete items while iterating string = (char *) zlistx_first (list); assert (streq (string, "eight")); string = (char *) zlistx_next (list); assert (streq (string, "five")); zlistx_delete (list, zlistx_cursor (list)); string = (char *) zlistx_next (list); assert (streq (string, "four")); zlistx_purge (list); zlistx_destroy (&list); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zsock.c0000664000372000037200000021173613222211156015461 0ustar00travistravis00000000000000/* ========================================================================= zsock - high-level socket API that hides libzmq contexts and sockets Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zsock class wraps the libzmq socket handle (a void *) with a proper structure that follows the CLASS rules for construction and destruction. Some zsock methods take a void * "polymorphic" reference, which can be either a zsock_t or a zactor_t reference, or a libzmq void *. @discuss @end */ #define ZSOCK_NOCHECK // we are defining the methods here, so don't redirect symbols. #include "czmq_classes.h" #include "zsock_option.inc" // zsock_t instances always have this tag as the first 4 octets of // their data, which lets us do runtime object typing & validation. #define ZSOCK_TAG 0x0004cafe // This port range is defined by IANA for dynamic or private ports // We use this when choosing a port for dynamic binding. #define DYNAMIC_FIRST 0xc000 // 49152 #define DYNAMIC_LAST 0xffff // 65535 #define ZSOCK_BSEND_MAX_FRAMES 32 // Arbitrary limit, for now // Structure of our class struct _zsock_t { uint32_t tag; // Object tag for runtime detection void *handle; // The libzmq socket handle char *endpoint; // Last bound endpoint, if any char *cache; // Holds last zsock_brecv strings int type; // Socket type size_t cache_size; // Current size of cache uint32_t routing_id; // Routing ID for server sockets }; #ifndef CZMQ_BUILD_DRAFT_API CZMQ_PRIVATE zsock_t * zsock_new_server_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_PRIVATE zsock_t * zsock_new_client_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_PRIVATE zsock_t * zsock_new_radio_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_PRIVATE zsock_t * zsock_new_dish_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_PRIVATE zsock_t * zsock_new_gather_checked (const char *endpoint, const char *filename, size_t line_nbr); CZMQ_PRIVATE zsock_t * zsock_new_scatter_checked (const char *endpoint, const char *filename, size_t line_nbr); #endif // CZMQ_BUILD_DRAFT_API // -------------------------------------------------------------------------- // Create a new socket. This macro passes the caller source and line // number so that CZMQ can report socket leaks intelligently. To switch // off this checking, which may be costly if you use a LOT of sockets, // define ZSOCK_NOCHECK before compiling your code. Returns the new // socket, or NULL if the new socket could not be created. zsock_t * zsock_new_checked (int type, const char *filename, size_t line_nbr) { zsock_t *self = (zsock_t *) zmalloc (sizeof (zsock_t)); assert (self); self->tag = ZSOCK_TAG; self->type = type; self->handle = zsys_socket (type, filename, line_nbr); assert (self->handle); return self; } zsock_t * zsock_new (int type) { return zsock_new_checked (type, NULL, 0); } // -------------------------------------------------------------------------- // Destroy the socket. You must use this for any socket created via the // zsock_new method. void zsock_destroy_checked (zsock_t **self_p, const char *filename, size_t line_nbr) { assert (self_p); if (*self_p) { zsock_t *self = *self_p; assert (zsock_is (self)); self->tag = 0xDeadBeef; int rc = zsys_close (self->handle, filename, line_nbr); assert (rc == 0); freen (self->endpoint); freen (self->cache); freen (self); *self_p = NULL; } } void zsock_destroy (zsock_t **self_p) { zsock_destroy_checked (self_p, NULL, 0); } // -------------------------------------------------------------------------- // This interface includes some smart constructors, which create sockets with // additional set-up. In all of these, the endpoint is NULL, or starts with // '@' (bind) or '>' (connect). Multiple endpoints are allowed, separated by // commas. If endpoint does not start with '@' or '>', default action depends // on socket type. // Create a PUB socket. Default action is bind. zsock_t * zsock_new_pub_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_PUB, filename, line_nbr); if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_pub (const char *endpoints) { return zsock_new_pub_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a SUB socket, and optionally subscribe to some prefix string. Default // action is connect. zsock_t * zsock_new_sub_checked (const char *endpoints, const char *subscribe, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_SUB, filename, line_nbr); if (zsock_attach (sock, endpoints, false) == 0) { if (subscribe) zsock_set_subscribe (sock, subscribe); } else zsock_destroy (&sock); return sock; } zsock_t * zsock_new_sub (const char *endpoints, const char *subscribe) { return zsock_new_sub_checked (endpoints, subscribe, NULL, 0); } // -------------------------------------------------------------------------- // Create a REQ socket. Default action is connect. zsock_t * zsock_new_req_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_REQ, filename, line_nbr); if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_req (const char *endpoints) { return zsock_new_req_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a REP socket. Default action is bind. zsock_t * zsock_new_rep_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_REP, filename, line_nbr); if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_rep (const char *endpoints) { return zsock_new_rep_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a DEALER socket. Default action is connect. zsock_t * zsock_new_dealer_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_DEALER, filename, line_nbr); if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_dealer (const char *endpoints) { return zsock_new_dealer_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a ROUTER socket. Default action is bind. zsock_t * zsock_new_router_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_ROUTER, filename, line_nbr); if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_router (const char *endpoints) { return zsock_new_router_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a PUSH socket. Default action is connect. zsock_t * zsock_new_push_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_PUSH, filename, line_nbr); if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_push (const char *endpoints) { return zsock_new_push_checked(endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a PULL socket. Default action is bind. zsock_t * zsock_new_pull_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_PULL, filename, line_nbr); if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_pull (const char *endpoints) { return zsock_new_pull_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create an XPUB socket. Default action is bind. zsock_t * zsock_new_xpub_checked (const char *endpoints, const char *filename, size_t line_nbr) { #if defined ZMQ_XPUB zsock_t *sock = zsock_new_checked (ZMQ_XPUB, filename, line_nbr); if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; #else return NULL; // Not implemented #endif } zsock_t * zsock_new_xpub (const char *endpoints) { return zsock_new_xpub_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create an XSUB socket. Default action is connect. zsock_t * zsock_new_xsub_checked (const char *endpoints, const char *filename, size_t line_nbr) { #if defined ZMQ_XSUB zsock_t *sock = zsock_new_checked (ZMQ_XSUB, filename, line_nbr); if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; #else return NULL; // Not implemented #endif } zsock_t * zsock_new_xsub (const char *endpoints) { return zsock_new_xsub_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a PAIR socket. Default action is connect. zsock_t * zsock_new_pair_checked (const char *endpoints, const char *filename, size_t line_nbr) { zsock_t *sock = zsock_new_checked (ZMQ_PAIR, filename, line_nbr); if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; } zsock_t * zsock_new_pair (const char *endpoints) { return zsock_new_pair_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a STREAM socket. Default action is connect. zsock_t * zsock_new_stream_checked (const char *endpoints, const char *filename, size_t line_nbr) { #if defined ZMQ_STREAM zsock_t *sock = zsock_new_checked (ZMQ_STREAM, filename, line_nbr); if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; #else return NULL; // Not implemented #endif } zsock_t * zsock_new_stream (const char *endpoints) { return zsock_new_stream_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a SERVER socket. Default action is bind. zsock_t * zsock_new_server_checked (const char *endpoints, const char *filename, size_t line_nbr) { #if defined ZMQ_SERVER zsock_t *sock = zsock_new_checked (ZMQ_SERVER, filename, line_nbr); if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; #else return NULL; #endif } zsock_t * zsock_new_server (const char *endpoints) { return zsock_new_server_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a CLIENT socket. Default action is connect. zsock_t * zsock_new_client_checked (const char *endpoints, const char *filename, size_t line_nbr) { #if defined ZMQ_CLIENT zsock_t *sock = zsock_new_checked (ZMQ_CLIENT, filename, line_nbr); if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; #else return NULL; #endif } zsock_t * zsock_new_client (const char *endpoints) { return zsock_new_client_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a RADIO socket. Default action is bind. zsock_t * zsock_new_radio_checked (const char *endpoints, const char *filename, size_t line_nbr) { #if defined ZMQ_RADIO zsock_t *sock = zsock_new_checked (ZMQ_RADIO, filename, line_nbr); if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; #else return NULL; #endif } zsock_t * zsock_new_radio (const char *endpoints) { return zsock_new_radio_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a DISH socket. Default action is connect. zsock_t * zsock_new_dish_checked (const char *endpoints, const char *filename, size_t line_nbr) { #if defined ZMQ_DISH zsock_t *sock = zsock_new_checked (ZMQ_DISH, filename, line_nbr); if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; #else return NULL; #endif } zsock_t * zsock_new_dish (const char *endpoints) { return zsock_new_dish_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a GATHER socket. Default action is bind. zsock_t * zsock_new_gather_checked (const char *endpoints, const char *filename, size_t line_nbr) { #if defined ZMQ_GATHER zsock_t *sock = zsock_new_checked (ZMQ_GATHER, filename, line_nbr); if (zsock_attach (sock, endpoints, true)) zsock_destroy (&sock); return sock; #else return NULL; #endif } zsock_t * zsock_new_gather (const char *endpoints) { return zsock_new_gather_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Create a scatter socket. Default action is connect. zsock_t * zsock_new_scatter_checked (const char *endpoints, const char *filename, size_t line_nbr) { #if defined ZMQ_SCATTER zsock_t *sock = zsock_new_checked (ZMQ_SCATTER, filename, line_nbr); if (zsock_attach (sock, endpoints, false)) zsock_destroy (&sock); return sock; #else return NULL; #endif } zsock_t * zsock_new_scatter (const char *endpoints) { return zsock_new_scatter_checked (endpoints, NULL, 0); } // -------------------------------------------------------------------------- // Bind a socket to a formatted endpoint. For tcp:// endpoints, supports // ephemeral ports, if you specify the port number as "*". By default // zsock uses the IANA designated range from C000 (49152) to FFFF (65535). // To override this range, follow the "*" with "[first-last]". Either or // both first and last may be empty. To bind to a random port within the // range, use "!" in place of "*". // // Examples: // tcp://127.0.0.1:* bind to first free port from C000 up // tcp://127.0.0.1:! bind to random port from C000 to FFFF // tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up // tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 // tcp://127.0.0.1:![55000-55999] bind to random port from 55000-55999 // // On success, returns the actual port number used, for tcp:// endpoints, // and 0 for other transports. On failure, returns -1. Note that when using // ephemeral ports, a port may be reused by different services without // clients being aware. Protocols that run on ephemeral ports should take // this into account. int zsock_bind (zsock_t *self, const char *format, ...) { assert (self); assert (zsock_is (self)); // Expand format to get full endpoint va_list argptr; va_start (argptr, format); char *endpoint = zsys_vprintf (format, argptr); va_end (argptr); if (!endpoint) return -1; int rc; // If tcp:// endpoint, parse to get or make port number zrex_t *rex = zrex_new (NULL); if (zrex_eq (rex, endpoint, "^tcp://.*:(\\d+)$")) { assert (zrex_hits (rex) == 2); int port = atoi (zrex_hit (rex, 1)); #if defined (HAVE_LIBSYSTEMD) && (ZMQ_VERSION >= ZMQ_MAKE_VERSION (4, 2, 0)) if (zsys_auto_use_fd ()) { int last_handle = SD_LISTEN_FDS_START + sd_listen_fds (0); int handle; for (handle = SD_LISTEN_FDS_START; handle < last_handle; ++handle) if (sd_is_socket_inet (handle, AF_UNSPEC, SOCK_STREAM, 1, (uint16_t) port) > 0) { zsock_set_use_fd (self, handle); break; } } #endif if (zmq_bind (self->handle, endpoint) == 0) rc = port; else rc = -1; } else if (zrex_eq (rex, endpoint, "^(tcp://.*):([*!])(\\[(\\d+)?-(\\d+)?\\])?$")) { assert (zrex_hits (rex) == 6); const char *hostname, *opcode, *group, *first_str, *last_str; zrex_fetch (rex, &hostname, &opcode, &group, &first_str, &last_str, NULL); int first = *first_str? atoi (first_str): DYNAMIC_FIRST; int last = *last_str? atoi (last_str): DYNAMIC_LAST; // This is how many times we'll try before giving up int attempts = last - first + 1; // If operator is '*', take first available port. // If operator is '!', take a random leap into our port space; we'll // still scan sequentially to make sure we find a free slot rapidly. int port = first; if (streq (opcode, "!")) port += randof (attempts); rc = -1; // Assume we don't succeed while (rc == -1 && attempts--) { zstr_free (&endpoint); endpoint = zsys_sprintf ("%s:%d", hostname, port); if (!endpoint) break; if (zmq_bind (self->handle, endpoint) == 0) rc = port; if (++port > last) port = first; } } else { #if defined (HAVE_LIBSYSTEMD) && (ZMQ_VERSION >= ZMQ_MAKE_VERSION (4, 2, 0)) if (zsys_auto_use_fd () && zrex_eq (rex, endpoint, "^ipc://(.*)$")) { assert (zrex_hits (rex) == 2); const char *sock_path; zrex_fetch (rex, &sock_path, NULL); int last_handle = SD_LISTEN_FDS_START + sd_listen_fds (0); int handle; for (handle = SD_LISTEN_FDS_START; handle < last_handle; ++handle) if (sd_is_socket_unix (handle, SOCK_STREAM, 1, sock_path, 0) > 0) { zsock_set_use_fd (self, handle); break; } } #endif rc = zmq_bind (self->handle, endpoint); } // Store successful endpoint for later reference if (rc >= 0) { zstr_free (&self->endpoint); self->endpoint = endpoint; } else zstr_free (&endpoint); zrex_destroy (&rex); return rc; } // -------------------------------------------------------------------------- // Returns last bound endpoint, if any. const char * zsock_endpoint (zsock_t *self) { assert (self); return self->endpoint; } // -------------------------------------------------------------------------- // Unbind a socket from a formatted endpoint. // Returns 0 if OK, -1 if the endpoint was invalid or the function // isn't supported. int zsock_unbind (zsock_t *self, const char *format, ...) { assert (self); assert (zsock_is (self)); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Expand format to get full endpoint va_list argptr; va_start (argptr, format); char *endpoint = zsys_vprintf (format, argptr); va_end (argptr); if (!endpoint) return -1; int rc = zmq_unbind (self->handle, endpoint); zstr_free (&endpoint); return rc; #else return -1; #endif } // -------------------------------------------------------------------------- // Connect a socket to a formatted endpoint // Returns 0 if the endpoint is valid, -1 if the connect failed. int zsock_connect (zsock_t *self, const char *format, ...) { assert (self); assert (zsock_is (self)); // Expand format to get full endpoint va_list argptr; va_start (argptr, format); char *endpoint = zsys_vprintf (format, argptr); va_end (argptr); if (!endpoint) return -1; int rc = zmq_connect (self->handle, endpoint); #if (ZMQ_VERSION < ZMQ_MAKE_VERSION (4, 0, 0)) int retries = 4; while (rc == -1 && zmq_errno () == ECONNREFUSED && retries) { // This bruteforces a synchronization between connecting and // binding threads on ZeroMQ v3.2 and earlier, where the bind // MUST happen before the connect on inproc transports. zclock_sleep (250); rc = zmq_connect (self->handle, endpoint); retries--; } #endif zstr_free (&endpoint); return rc; } // -------------------------------------------------------------------------- // Disconnect a socket from a formatted endpoint // Returns 0 if disconnection is complete -1 if the disconnection failed. int zsock_disconnect (zsock_t *self, const char *format, ...) { assert (self); assert (zsock_is (self)); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Expand format to get full endpoint va_list argptr; va_start (argptr, format); char *endpoint = zsys_vprintf (format, argptr); va_end (argptr); if (!endpoint) return -1; int rc = zmq_disconnect (self->handle, endpoint); zstr_free (&endpoint); return rc; #else return -1; #endif } // -------------------------------------------------------------------------- // Attach a socket to zero or more endpoints. If endpoints is not null, // parses as list of ZeroMQ endpoints, separated by commas, and prefixed by // '@' (to bind the socket) or '>' (to attach the socket). Returns 0 if all // endpoints were valid, or -1 if there was a syntax error. If the endpoint // does not start with '@' or '>', the serverish argument defines whether // it is used to bind (serverish = true) or connect (serverish = false). int zsock_attach (zsock_t *self, const char *endpoints, bool serverish) { assert (self); if (!endpoints) return 0; // We hold each individual endpoint here char endpoint [256]; while (*endpoints) { const char *delimiter = strchr (endpoints, ','); if (!delimiter) delimiter = endpoints + strlen (endpoints); if (delimiter - endpoints > 255) return -1; memcpy (endpoint, endpoints, delimiter - endpoints); endpoint [delimiter - endpoints] = 0; int rc; if (endpoint [0] == '@') rc = zsock_bind (self, "%s", endpoint + 1); else if (endpoint [0] == '>') rc = zsock_connect (self, "%s", endpoint + 1); else if (serverish) rc = zsock_bind (self, "%s", endpoint); else rc = zsock_connect (self, "%s", endpoint); if (rc == -1) return -1; // Bad endpoint syntax if (*delimiter == 0) break; endpoints = delimiter + 1; } return 0; } // -------------------------------------------------------------------------- // Returns socket type as printable constant string. const char * zsock_type_str (zsock_t *self) { assert (self); return zsys_sockname (self->type); } // -------------------------------------------------------------------------- // Send a 'picture' message to the socket (or actor). The picture is a // string that defines the type of each frame. This makes it easy to send // a complex multiframe message in one call. The picture can contain any // of these characters, each corresponding to one or two arguments: // // i = int (signed) // 1 = uint8_t // 2 = uint16_t // 4 = uint32_t // 8 = uint64_t // s = char * // b = byte *, int (2 arguments) // c = zchunk_t * // f = zframe_t * // h = zhashx_t * // U = zuuid_t * // p = void * (sends the pointer value, only meaningful over inproc) // m = zmsg_t * (sends all frames in the zmsg) // z = sends zero-sized frame (0 arguments) // u = uint (deprecated) // // Note that s, b, c, and f are encoded the same way and the choice is // offered as a convenience to the sender, which may or may not already // have data in a zchunk or zframe. Does not change or take ownership of // any arguments. Returns 0 if successful, -1 if sending failed for any // reason. int zsock_send (void *self, const char *picture, ...) { va_list argptr; va_start (argptr, picture); int rc = zsock_vsend (self, picture, argptr); va_end (argptr); return rc; } // -------------------------------------------------------------------------- // Send a 'picture' message to the socket (or actor). This is a va_list // version of zsock_send (), so please consult its documentation for the // details. int zsock_vsend (void *self, const char *picture, va_list argptr) { assert (self); assert (picture); zmsg_t *msg = zmsg_new (); while (*picture) { if (*picture == 'i') zmsg_addstrf (msg, "%d", va_arg (argptr, int)); else if (*picture == '1') zmsg_addstrf (msg, "%" PRIu8, (uint8_t) va_arg (argptr, int)); else if (*picture == '2') zmsg_addstrf (msg, "%" PRIu16, (uint16_t) va_arg (argptr, int)); else if (*picture == '4') zmsg_addstrf (msg, "%" PRIu32, va_arg (argptr, uint32_t)); else if (*picture == '8') zmsg_addstrf (msg, "%" PRIu64, va_arg (argptr, uint64_t)); else if (*picture == 'u') // Deprecated, use 4 or 8 instead zmsg_addstrf (msg, "%ud", va_arg (argptr, uint)); else if (*picture == 's') zmsg_addstr (msg, va_arg (argptr, char *)); else if (*picture == 'b') { // Note function arguments may be expanded in reverse order, // so we cannot use va_arg macro twice in a single call byte *data = va_arg (argptr, byte *); zmsg_addmem (msg, data, va_arg (argptr, int)); } else if (*picture == 'c') { zchunk_t *chunk = va_arg (argptr, zchunk_t *); assert (zchunk_is (chunk)); zmsg_addmem (msg, zchunk_data (chunk), zchunk_size (chunk)); } else if (*picture == 'f') { zframe_t *frame = va_arg (argptr, zframe_t *); assert (zframe_is (frame)); zmsg_addmem (msg, zframe_data (frame), zframe_size (frame)); } else if (*picture == 'U') { zuuid_t *uuid = va_arg (argptr, zuuid_t *); zmsg_addmem (msg, zuuid_data (uuid), zuuid_size (uuid)); } else if (*picture == 'p') { void *pointer = va_arg (argptr, void *); zmsg_addmem (msg, &pointer, sizeof (void *)); } else if (*picture == 'h') { zhashx_t *hash = va_arg (argptr, zhashx_t *); zframe_t *frame = zhashx_pack (hash); zmsg_append (msg, &frame); } else if (*picture == 'm') { zframe_t *frame; zmsg_t *zmsg = va_arg (argptr, zmsg_t *); for (frame = zmsg_first (zmsg); frame; frame = zmsg_next (zmsg) ) { zframe_t *frame_dup = zframe_dup (frame); zmsg_append (msg, &frame_dup); } } else if (*picture == 'z') zmsg_addmem (msg, NULL, 0); else { zsys_error ("zsock: invalid picture element '%c'", *picture); assert (false); } picture++; } int rc = zmsg_send (&msg, self); if (rc != 0) zmsg_destroy (&msg); return rc; } // -------------------------------------------------------------------------- // Receive a 'picture' message to the socket (or actor). See zsock_send for // the format and meaning of the picture. Returns the picture elements into // a series of pointers as provided by the caller: // // i = int * (stores signed integer) // 1 = uint8_t * (stores 8-bit unsigned integer) // 2 = uint16_t * (stores 16-bit unsigned integer) // 4 = uint32_t * (stores 32-bit unsigned integer) // 8 = uint64_t * (stores 64-bit unsigned integer) // s = char ** (allocates new string) // b = byte **, size_t * (2 arguments) (allocates memory) // c = zchunk_t ** (creates zchunk) // f = zframe_t ** (creates zframe) // h = zhashx_t ** (creates zhashx) // U = zuuid_t * (creates a zuuid with the data) // p = void ** (stores pointer) // m = zmsg_t ** (creates a zmsg with the remaing frames) // z = null, asserts empty frame (0 arguments) // u = uint * (stores unsigned integer, deprecated) // // Note that zsock_recv creates the returned objects, and the caller must // destroy them when finished with them. The supplied pointers do not need // to be initialized. Returns 0 if successful, or -1 if it failed to recv // a message, in which case the pointers are not modified. When message // frames are truncated (a short message), sets return values to zero/null. // If an argument pointer is NULL, does not store any value (skips it). // An 'n' picture matches an empty frame; if the message does not match, // the method will return -1. int zsock_recv (void *self, const char *picture, ...) { va_list argptr; va_start (argptr, picture); int rc = zsock_vrecv (self, picture, argptr); va_end (argptr); return rc; } // Receive a 'picture' message from the socket (or actor). This is a // va_list version of zsock_recv (), so please consult its documentation // for the details. int zsock_vrecv (void *self, const char *picture, va_list argptr) { assert (self); assert (picture); zmsg_t *msg = zmsg_recv (self); if (!msg) return -1; // Interrupted // Filter a signal that may come from a dying actor if (zmsg_signal (msg) >= 0) { zmsg_destroy (&msg); return -1; } // Now parse message according to picture argument int rc = 0; while (*picture) { if (*picture == 'i') { char *string = zmsg_popstr (msg); int *int_p = va_arg (argptr, int *); if (int_p) *int_p = string? atoi (string): 0; freen (string); } else if (*picture == '1') { char *string = zmsg_popstr (msg); uint8_t *uint8_p = va_arg (argptr, uint8_t *); if (uint8_p) *uint8_p = string? (uint8_t) atoi (string): 0; freen (string); } else if (*picture == '2') { char *string = zmsg_popstr (msg); uint16_t *uint16_p = va_arg (argptr, uint16_t *); if (uint16_p) *uint16_p = string? (uint16_t) atol (string): 0; freen (string); } else if (*picture == '4') { char *string = zmsg_popstr (msg); uint32_t *uint32_p = va_arg (argptr, uint32_t *); if (uint32_p) *uint32_p = string? (uint32_t) strtoul (string, NULL, 10): 0; freen (string); } else if (*picture == '8') { char *string = zmsg_popstr (msg); uint64_t *uint64_p = va_arg (argptr, uint64_t *); if (uint64_p) *uint64_p = string? (uint64_t) strtoull (string, NULL, 10): 0; freen (string); } else if (*picture == 'u') { // Deprecated, use 4 or 8 instead char *string = zmsg_popstr (msg); uint *uint_p = va_arg (argptr, uint *); if (uint_p) *uint_p = string? (uint) strtoul (string, NULL, 10): 0; freen (string); } else if (*picture == 's') { char *string = zmsg_popstr (msg); char **string_p = va_arg (argptr, char **); if (string_p) *string_p = string; else freen (string); } else if (*picture == 'b') { zframe_t *frame = zmsg_pop (msg); byte **data_p = va_arg (argptr, byte **); size_t *size = va_arg (argptr, size_t *); if (data_p) { if (frame) { *size = zframe_size (frame); *data_p = (byte *) malloc (*size); memcpy (*data_p, zframe_data (frame), *size); } else { *data_p = NULL; *size = 0; } } zframe_destroy (&frame); } else if (*picture == 'c') { zframe_t *frame = zmsg_pop (msg); zchunk_t **chunk_p = va_arg (argptr, zchunk_t **); if (chunk_p) { if (frame) *chunk_p = zchunk_new (zframe_data (frame), zframe_size (frame)); else *chunk_p = NULL; } zframe_destroy (&frame); } else if (*picture == 'f') { zframe_t *frame = zmsg_pop (msg); zframe_t **frame_p = va_arg (argptr, zframe_t **); if (frame_p) *frame_p = frame; else zframe_destroy (&frame); } else if (*picture == 'U') { zframe_t *frame = zmsg_pop (msg); zuuid_t **uuid_p = va_arg (argptr, zuuid_t **); if (uuid_p) { if (frame) { *uuid_p = zuuid_new (); zuuid_set (*uuid_p, zframe_data (frame)); } else *uuid_p = NULL; } zframe_destroy (&frame); } else if (*picture == 'p') { zframe_t *frame = zmsg_pop (msg); void **pointer_p = va_arg (argptr, void **); if (pointer_p) { if (frame) { if (zframe_size (frame) == sizeof (void *)) *pointer_p = *((void **) zframe_data (frame)); else rc = -1; } else *pointer_p = NULL; } zframe_destroy (&frame); } else if (*picture == 'h') { zframe_t *frame = zmsg_pop (msg); zhashx_t **hash_p = va_arg (argptr, zhashx_t **); if (hash_p) { if (frame) *hash_p = zhashx_unpack (frame); else *hash_p = NULL; } zframe_destroy (&frame); } else if (*picture == 'm') { zmsg_t **zmsg_p = va_arg (argptr, zmsg_t **); if (zmsg_p) { *zmsg_p = zmsg_new (); zframe_t *frame; while ((frame = zmsg_pop (msg))) zmsg_append (*zmsg_p, &frame); } } else if (*picture == 'z') { zframe_t *frame = zmsg_pop (msg); if (frame && zframe_size (frame) != 0) rc = -1; zframe_destroy (&frame); } else { zsys_error ("zsock: invalid picture element '%c'", *picture); assert (false); } picture++; } zmsg_destroy (&msg); return rc; } // -------------------------------------------------------------------------- // Network data encoding macros that we use in bsend/brecv // Put a 1-byte number to the frame #define PUT_NUMBER1(host) { \ *(byte *) needle = (host); \ needle++; \ } // Put a 2-byte number to the frame #define PUT_NUMBER2(host) { \ needle [0] = (byte) (((host) >> 8) & 255); \ needle [1] = (byte) (((host)) & 255); \ needle += 2; \ } // Put a 4-byte number to the frame #define PUT_NUMBER4(host) { \ needle [0] = (byte) (((host) >> 24) & 255); \ needle [1] = (byte) (((host) >> 16) & 255); \ needle [2] = (byte) (((host) >> 8) & 255); \ needle [3] = (byte) (((host)) & 255); \ needle += 4; \ } // Put a 8-byte number to the frame #define PUT_NUMBER8(host) { \ needle [0] = (byte) (((host) >> 56) & 255); \ needle [1] = (byte) (((host) >> 48) & 255); \ needle [2] = (byte) (((host) >> 40) & 255); \ needle [3] = (byte) (((host) >> 32) & 255); \ needle [4] = (byte) (((host) >> 24) & 255); \ needle [5] = (byte) (((host) >> 16) & 255); \ needle [6] = (byte) (((host) >> 8) & 255); \ needle [7] = (byte) (((host)) & 255); \ needle += 8; \ } // Get a 1-byte number from the frame #define GET_NUMBER1(host) { \ if (needle + 1 > ceiling) \ goto malformed; \ (host) = *(byte *) needle; \ needle++; \ } // Get a 2-byte number from the frame #define GET_NUMBER2(host) { \ if (needle + 2 > ceiling) \ goto malformed; \ (host) = ((uint16_t) (needle [0]) << 8) \ + (uint16_t) (needle [1]); \ needle += 2; \ } // Get a 4-byte number from the frame #define GET_NUMBER4(host) { \ if (needle + 4 > ceiling) \ goto malformed; \ (host) = ((uint32_t) (needle [0]) << 24) \ + ((uint32_t) (needle [1]) << 16) \ + ((uint32_t) (needle [2]) << 8) \ + (uint32_t) (needle [3]); \ needle += 4; \ } // Get a 8-byte number from the frame #define GET_NUMBER8(host) { \ if (needle + 8 > ceiling) \ goto malformed; \ (host) = ((uint64_t) (needle [0]) << 56) \ + ((uint64_t) (needle [1]) << 48) \ + ((uint64_t) (needle [2]) << 40) \ + ((uint64_t) (needle [3]) << 32) \ + ((uint64_t) (needle [4]) << 24) \ + ((uint64_t) (needle [5]) << 16) \ + ((uint64_t) (needle [6]) << 8) \ + (uint64_t) (needle [7]); \ needle += 8; \ } // -------------------------------------------------------------------------- // Send a binary encoded 'picture' message to the socket (or actor). This // method is similar to zsock_send, except the arguments are encoded in a // binary format that is compatible with zproto, and is designed to reduce // memory allocations. The pattern argument is a string that defines the // type of each argument. Supports these argument types: // // pattern C type zproto type: // 1 uint8_t type = "number" size = "1" // 2 uint16_t type = "number" size = "2" // 4 uint32_t type = "number" size = "3" // 8 uint64_t type = "number" size = "4" // s char *, 0-255 chars type = "string" // S char *, 0-2^32-1 chars type = "longstr" // c zchunk_t * type = "chunk" // f zframe_t * type = "frame" // u zuuid_t * type = "uuid" // m zmsg_t * type = "msg" // p void *, sends pointer value, only over inproc // // Does not change or take ownership of any arguments. Returns 0 if // successful, -1 if sending failed for any reason. int zsock_bsend (void *self, const char *picture, ...) { assert (self); assert (picture); // Pass 1: calculate total size of data frame size_t frame_size = 0; zframe_t *frames [ZSOCK_BSEND_MAX_FRAMES]; // Non-data frames to send size_t nbr_frames = 0; // Size of this table va_list argptr; va_start (argptr, picture); const char *picptr = picture; while (*picptr) { if (*picptr == '1') { va_arg (argptr, int); frame_size += 1; } else if (*picptr == '2') { va_arg (argptr, int); frame_size += 2; } else if (*picptr == '4') { va_arg (argptr, uint32_t); frame_size += 4; } else if (*picptr == '8') { va_arg (argptr, uint64_t); frame_size += 8; } else if (*picptr == 's') { char *string = va_arg (argptr, char *); frame_size += 1 + (string? strlen (string): 0); } else if (*picptr == 'S') { char *string = va_arg (argptr, char *); frame_size += 4 + (string? strlen (string): 0); } else if (*picptr == 'c') { zchunk_t *chunk = va_arg (argptr, zchunk_t *); frame_size += 4 + (chunk? zchunk_size (chunk): 0); } else if (*picptr == 'p') { va_arg (argptr, void *); frame_size += sizeof (void *); } else if (*picptr == 'f') { zframe_t *frame = va_arg (argptr, zframe_t *); assert (nbr_frames < ZSOCK_BSEND_MAX_FRAMES - 1); frames [nbr_frames++] = frame; } else if (*picptr == 'u') { zuuid_t *uuid = va_arg (argptr, zuuid_t *); frame_size += zuuid_size (uuid); } else if (*picptr == 'm') { if (picptr [1]) { zsys_error ("zsock_bsend: 'm' (zmsg) only valid at end of picptr"); assert (false); } zmsg_t *msg = va_arg (argptr, zmsg_t *); if (msg) { zframe_t *frame = zmsg_first (msg); while (frame) { assert (nbr_frames < ZSOCK_BSEND_MAX_FRAMES - 1); frames [nbr_frames++] = frame; frame = zmsg_next (msg); } } else frames [nbr_frames++] = zframe_new_empty (); } else { zsys_error ("zsock_bsend: invalid picptr element '%c'", *picptr); assert (false); } picptr++; } va_end (argptr); // Pass 2: encode data into data frame zmq_msg_t msg; zmq_msg_init_size (&msg, frame_size); byte *needle = (byte *) zmq_msg_data (&msg); // Set routing id if self is zsock #if defined ZMQ_SERVER if (zsock_is (self) && zsock_routing_id ((zsock_t *)self) != 0) zmq_msg_set_routing_id (&msg, zsock_routing_id ((zsock_t *)self)); #endif va_start (argptr, picture); picptr = picture; while (*picptr) { if (*picptr == '1') { int number1 = va_arg (argptr, int); PUT_NUMBER1 (number1); } else if (*picptr == '2') { int number2 = va_arg (argptr, int); PUT_NUMBER2 (number2); } else if (*picptr == '4') { uint32_t number4 = va_arg (argptr, uint32_t); PUT_NUMBER4 (number4); } else if (*picptr == '8') { uint64_t number8 = va_arg (argptr, uint64_t); PUT_NUMBER8 (number8); } else if (*picptr == 'p') { void *pointer = va_arg (argptr, void *); memcpy (needle, &pointer, sizeof (void *)); needle += sizeof (void *); } else if (*picptr == 's') { char *string = va_arg (argptr, char *); if (!string) string = ""; size_t string_size = strlen (string); PUT_NUMBER1 ((byte) string_size); memcpy (needle, string, string_size); needle += string_size; } else if (*picptr == 'S') { char *string = va_arg (argptr, char *); if (!string) string = ""; size_t string_size = strlen (string); PUT_NUMBER4 (string_size); memcpy (needle, string, string_size); needle += string_size; } else if (*picptr == 'c') { zchunk_t *chunk = va_arg (argptr, zchunk_t *); if (chunk) { PUT_NUMBER4 (zchunk_size (chunk)); memcpy (needle, zchunk_data (chunk), zchunk_size (chunk)); needle += zchunk_size (chunk); } } else if (*picptr == 'u') { zuuid_t *uuid = va_arg (argptr, zuuid_t *); if (uuid) { memcpy (needle, zuuid_data (uuid), zuuid_size (uuid)); needle += zuuid_size (uuid); } } picptr++; } va_end (argptr); // Now send the data frame void *handle = zsock_resolve (self); int rc = zmq_msg_send (&msg, handle, nbr_frames? ZMQ_SNDMORE: 0); if (rc >= 0) { // Now send any additional frames unsigned int frame_nbr; for (frame_nbr = 0; frame_nbr < nbr_frames; frame_nbr++) { bool more = frame_nbr < nbr_frames - 1; rc = zframe_send (&frames [frame_nbr], self, ZFRAME_REUSE + (more? ZFRAME_MORE: 0)); if (rc == -1) break; } } return rc >= 0? 0: -1; } // -------------------------------------------------------------------------- // Receive a binary encoded 'picture' message from the socket (or actor). // This method is similar to zsock_recv, except the arguments are encoded // in a binary format that is compatible with zproto, and is designed to // reduce memory allocations. The pattern argument is a string that defines // the type of each argument. See zsock_bsend for the supported argument // types. All arguments must be pointers; this call sets them to point to // values held on a per-socket basis. // For types 1, 2, 4 and 8 the caller must allocate the memory itself before // calling zsock_brecv. // For types S, the caller must free the value once finished with it, as // zsock_brecv will allocate the buffer. // For type s, the caller must not free the value as it is stored in a // local cache for performance purposes. // For types c, f, u and m the caller must call the appropriate destructor // depending on the object as zsock_brecv will create new objects. // For type p the caller must coordinate with the sender, as it is just a // pointer value being passed. // This is the largest size we allow for an incoming longstr or chunk (1M) #define MAX_ALLOC_SIZE 1024 * 1024 int zsock_brecv (void *selfish, const char *picture, ...) { assert (selfish); // Kind of self assert (picture); zmq_msg_t msg; zmq_msg_init (&msg); if (zmq_msg_recv (&msg, zsock_resolve (selfish), 0) == -1) return -1; // Interrupted // If we don't have a string cache, create one now with arbitrary // value; this will grow if needed. Do not use an initial size less // than 256, or cache expansion will not work properly. zsock_t *self = (zsock_t *) selfish; if (zactor_is (selfish)) self = zactor_sock ((zactor_t *) selfish); if (!self->cache) { self->cache = (char *) malloc (512); self->cache_size = 512; } // Last received strings are cached per socket uint cache_used = 0; byte *needle = (byte *) zmq_msg_data (&msg); byte *ceiling = needle + zmq_msg_size (&msg); // If selfish is zsock get routing id from msg #if defined ZMQ_SERVER if (zsock_is (selfish) && zsock_type (self) == ZMQ_SERVER) zsock_set_routing_id (self, zmq_msg_routing_id (&msg)); #endif va_list argptr; va_start (argptr, picture); const char *picptr = picture; while (*picptr) { if (*picptr == '1') { uint8_t *number1_p = va_arg (argptr, uint8_t *); GET_NUMBER1 (*number1_p); } else if (*picptr == '2') { uint16_t *number2_p = va_arg (argptr, uint16_t *); GET_NUMBER2 (*number2_p); } else if (*picptr == '4') { uint32_t *number4_p = va_arg (argptr, uint32_t *); GET_NUMBER4 (*number4_p); } else if (*picptr == '8') { uint64_t *number8_p = va_arg (argptr, uint64_t *); GET_NUMBER8 (*number8_p); } else if (*picptr == 'p') { void **pointer_p = va_arg (argptr, void **); memcpy (pointer_p, needle, sizeof (void *)); needle += sizeof (void *); } else if (*picptr == 's') { char **string_p = va_arg (argptr, char **); uint string_size; GET_NUMBER1 (string_size); if (needle + string_size > ceiling) goto malformed; // Expand cache if we need to; string is guaranteed to fit into // expansion space if (cache_used + string_size > self->cache_size) { puts ("REALLOC"); self->cache_size *= 2; self->cache = (char *) realloc (self->cache, self->cache_size); assert (self->cache); } *string_p = self->cache + cache_used; memcpy (*string_p, needle, string_size); cache_used += string_size; self->cache [cache_used++] = 0; needle += string_size; } else if (*picptr == 'S') { char **string_p = va_arg (argptr, char **); size_t string_size; GET_NUMBER4 (string_size); if (string_size > MAX_ALLOC_SIZE || needle + string_size > (ceiling)) goto malformed; *string_p = (char *) malloc (string_size + 1); assert (string_p); memcpy (*string_p, needle, string_size); (*string_p) [string_size] = 0; needle += string_size; } else if (*picptr == 'c') { zchunk_t **chunk_p = va_arg (argptr, zchunk_t **); size_t chunk_size; GET_NUMBER4 (chunk_size); if (chunk_size > MAX_ALLOC_SIZE || needle + chunk_size > (ceiling)) goto malformed; *chunk_p = zchunk_new (needle, chunk_size); needle += chunk_size; } else if (*picptr == 'u') { zuuid_t **uuid_p = va_arg (argptr, zuuid_t **); *uuid_p = zuuid_new (); if (zuuid_size (*uuid_p) > MAX_ALLOC_SIZE || needle + zuuid_size (*uuid_p) > (ceiling)) goto malformed; zuuid_set (*uuid_p, needle); needle += zuuid_size (*uuid_p); } else if (*picptr == 'f') { zframe_t **frame_p = va_arg (argptr, zframe_t **); // Get next frame off socket if (!zsock_rcvmore (self)) goto malformed; *frame_p = zframe_recv (self); } else if (*picptr == 'm') { if (picptr [1]) { zsys_error ("zsock_brecv: 'm' (zmsg) only valid at end of picptr"); assert (false); } zmsg_t **msg_p = va_arg (argptr, zmsg_t **); // Get zero or more remaining frames if (!zsock_rcvmore (self)) goto malformed; *msg_p = zmsg_recv (self); } else { zsys_error ("zsock_brecv: invalid picptr element '%c'", *picptr); assert (false); } picptr++; } va_end (argptr); zmq_msg_close (&msg); return 0; // Error return malformed: zmq_msg_close (&msg); return -1; // Invalid message } // -------------------------------------------------------------------------- // Return socket routing ID if any. This returns 0 if the socket is not // of type ZMQ_SERVER or if no request was already received on it. uint32_t zsock_routing_id (zsock_t *self) { return self->routing_id; } // -------------------------------------------------------------------------- // Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. // This will be used when sending messages on the socket via the zsock API. void zsock_set_routing_id (zsock_t *self, uint32_t routing_id) { assert (self); self->routing_id = routing_id; } // -------------------------------------------------------------------------- // Set socket to use unbounded pipes (HWM=0); use this in cases when you are // totally certain the message volume can fit in memory. This method works // across all versions of ZeroMQ. Takes a polymorphic socket reference. void zsock_set_unbounded (void *self) { #if (ZMQ_VERSION_MAJOR == 2) zsock_set_hwm (self, 0); #else zsock_set_sndhwm (self, 0); zsock_set_rcvhwm (self, 0); #endif } // -------------------------------------------------------------------------- // Send a signal over a socket. A signal is a short message carrying a // success/failure code (by convention, 0 means OK). Signals are encoded // to be distinguishable from "normal" messages. Accepts a zsock_t or a // zactor_t argument, and returns 0 if successful, -1 if the signal could // not be sent. Takes a polymorphic socket reference. int zsock_signal (void *self, byte status) { assert (self); zmsg_t *msg = zmsg_new_signal (status); if (zmsg_send (&msg, self) < 0) { zmsg_destroy (&msg); return -1; } else return 0; } // -------------------------------------------------------------------------- // Wait on a signal. Use this to coordinate between threads, over pipe // pairs. Blocks until the signal is received. Returns -1 on error, 0 or // greater on success. Accepts a zsock_t or a zactor_t as argument. // Takes a polymorphic socket reference. int zsock_wait (void *self) { assert (self); // Loop and discard messages until we get a signal value or interrupt. while (true) { zmsg_t *msg = zmsg_recv (self); if (!msg) return -1; int rc = zmsg_signal (msg); zmsg_destroy (&msg); if (rc >= 0) return rc; } return -1; } // -------------------------------------------------------------------------- // If there is a partial message still waiting on the socket, remove and // discard it. This is useful when reading partial messages, to get specific // message types. void zsock_flush (void *self) { if (zsock_rcvmore (self)) { zmsg_t *msg = zmsg_recv (self); zmsg_destroy (&msg); } } // -------------------------------------------------------------------------- // Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int zsock_join (void *self, const char *group) { assert (self); #ifdef ZMQ_DISH return zmq_join (zsock_resolve (self), group); #else errno = EINVAL; return -1; #endif } // -------------------------------------------------------------------------- // Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. int zsock_leave (void *self, const char *group) { assert (self); #ifdef ZMQ_DISH return zmq_leave (zsock_resolve (self), group); #else errno = EINVAL; return -1; #endif } // -------------------------------------------------------------------------- // Probe the supplied object, and report if it looks like a zsock_t. // Takes a polymorphic socket reference. bool zsock_is (void *self) { assert (self); return ((zsock_t *) self)->tag == ZSOCK_TAG; } // -------------------------------------------------------------------------- // Probe the supplied 'self' pointer. Takes a polymorphic socket reference. // If self is a zactor_t, zsock_t, or libzmq socket handle, returns the // libzmq socket handle. If self is a valid file descriptor, returns NULL. // Else returns self as-is. void * zsock_resolve (void *self) { assert (self); if (zactor_is (self)) return zactor_resolve (self); if (zsock_is (self)) return ((zsock_t *) self)->handle; // Check if we have a valid ZMQ socket by probing the socket type int type; size_t option_len = sizeof (int); if (zmq_getsockopt (self, ZMQ_TYPE, &type, &option_len) == 0) return self; // Check if self is a valid FD or socket FD // TODO: this code should move to zsys_isfd () as we don't like // non-portable code outside of that class. int sock_type = -1; #if defined (__WINDOWS__) int sock_type_size = sizeof (int); int rc = getsockopt (*(SOCKET *) self, SOL_SOCKET, SO_TYPE, (char *) &sock_type, &sock_type_size); if (rc == 0) return NULL; // It's a socket descriptor #else socklen_t sock_type_size = sizeof (socklen_t); int rc = getsockopt (*(SOCKET *) self, SOL_SOCKET, SO_TYPE, (char *) &sock_type, &sock_type_size); if (rc == 0 || (rc == -1 && errno == ENOTSOCK)) return NULL; // It's a socket FD or FD #endif // Socket appears to be something else, return it as-is return self; } // We use the gossip messages for some test cases #include "zgossip_msg.h" // -------------------------------------------------------------------------- // Selftest void zsock_test (bool verbose) { printf (" * zsock: "); if (verbose) printf ("\n"); // @selftest zsock_t *writer = zsock_new (ZMQ_PUSH); assert (writer); int port = zsock_bind (writer, "tcp://127.0.0.1:*"); assert (port != -1); assert (zsock_resolve (writer) != writer); assert (streq (zsock_type_str (writer), "PUSH")); int rc; #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) // Check unbind rc = zsock_unbind (writer, "tcp://127.0.0.1:%d", port); assert (rc == 0); // In some cases and especially when running under Valgrind, doing // a bind immediately after an unbind causes an EADDRINUSE error. // Even a short sleep allows the OS to release the port for reuse. zclock_sleep (100); // Bind again rc = zsock_bind (writer, "tcp://127.0.0.1:%d", port); assert (rc == port); char endpoint [40]; sprintf (endpoint, "tcp://127.0.0.1:%d", port); assert (streq (zsock_endpoint (writer), endpoint)); #endif zsock_t *reader = zsock_new (ZMQ_PULL); assert (reader); rc = zsock_connect (reader, "tcp://127.0.0.1:%d", port); assert (rc != -1); assert (zsock_resolve (reader) != reader); assert (streq (zsock_type_str (reader), "PULL")); // Basic Hello, World zstr_send (writer, "Hello, World"); zmsg_t *msg = zmsg_recv (reader); assert (msg); char *string = zmsg_popstr (msg); assert (streq (string, "Hello, World")); freen (string); zmsg_destroy (&msg); // Test resolve libzmq socket #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0)) void *zmq_ctx = zmq_ctx_new (); #else void *zmq_ctx = zmq_ctx_new (1); #endif assert (zmq_ctx); void *zmq_sock = zmq_socket (zmq_ctx, ZMQ_PUB); assert (zmq_sock); assert (zsock_resolve (zmq_sock) == zmq_sock); zmq_close (zmq_sock); zmq_ctx_term (zmq_ctx); // Test resolve zsock zsock_t *resolve = zsock_new_pub("@tcp://127.0.0.1:*"); assert (resolve); assert (zsock_resolve (resolve) == resolve->handle); zsock_destroy (&resolve); // Test resolve FD SOCKET fd = zsock_fd (reader); assert (zsock_resolve ((void *) &fd) == NULL); // Test binding to ephemeral ports, sequential and random port = zsock_bind (writer, "tcp://127.0.0.1:*"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:*[50000-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:*[-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127.0.0.1:*[60000-60500]"); assert (port >= 60000 && port <= 60500); port = zsock_bind (writer, "tcp://127.0.0.1:!"); assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:![50000-]"); assert (port >= 50000 && port <= DYNAMIC_LAST); port = zsock_bind (writer, "tcp://127.0.0.1:![-50001]"); assert (port >= DYNAMIC_FIRST && port <= 50001); port = zsock_bind (writer, "tcp://127.0.0.1:![60000-60500]"); assert (port >= 60000 && port <= 60500); // Test zsock_attach method zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); rc = zsock_attach (server, "@inproc://myendpoint,tcp://127.0.0.1:*,inproc://others", true); assert (rc == 0); rc = zsock_attach (server, "", false); assert (rc == 0); rc = zsock_attach (server, NULL, true); assert (rc == 0); rc = zsock_attach (server, ">a,@b, c,, ", false); assert (rc == -1); zsock_destroy (&server); // Test zsock_endpoint method rc = zsock_bind (writer, "inproc://test.%s", "writer"); assert (rc == 0); assert (streq (zsock_endpoint (writer), "inproc://test.writer")); // Test error state when connecting to an invalid socket type // ('txp://' instead of 'tcp://', typo intentional) rc = zsock_connect (reader, "txp://127.0.0.1:5560"); assert (rc == -1); // Test signal/wait methods rc = zsock_signal (writer, 123); assert (rc == 0); rc = zsock_wait (reader); assert (rc == 123); // Test zsock_send/recv pictures uint8_t number1 = 123; uint16_t number2 = 123 * 123; uint32_t number4 = 123 * 123; number4 *= 123; uint32_t number4_MAX = UINT32_MAX; uint64_t number8 = 123 * 123; number8 *= 123; number8 *= 123; uint64_t number8_MAX = UINT64_MAX; zchunk_t *chunk = zchunk_new ("HELLO", 5); assert (chunk); zframe_t *frame = zframe_new ("WORLD", 5); assert (frame); zhashx_t *hash = zhashx_new (); assert (hash); zuuid_t *uuid = zuuid_new (); assert (uuid); zhashx_set_destructor (hash, (zhashx_destructor_fn *) zstr_free); zhashx_set_duplicator (hash, (zhashx_duplicator_fn *) strdup); zhashx_insert (hash, "1", "value A"); zhashx_insert (hash, "2", "value B"); char *original = "pointer"; // Test zsock_recv into each supported type zsock_send (writer, "i124488zsbcfUhp", -12345, number1, number2, number4, number4_MAX, number8, number8_MAX, "This is a string", "ABCDE", 5, chunk, frame, uuid, hash, original); char *uuid_str = strdup (zuuid_str (uuid)); zchunk_destroy (&chunk); zframe_destroy (&frame); zuuid_destroy (&uuid); zhashx_destroy (&hash); int integer; byte *data; size_t size; char *pointer; number8_MAX = number8 = number4_MAX = number4 = number2 = number1 = 0ULL; rc = zsock_recv (reader, "i124488zsbcfUhp", &integer, &number1, &number2, &number4, &number4_MAX, &number8, &number8_MAX, &string, &data, &size, &chunk, &frame, &uuid, &hash, &pointer); assert (rc == 0); assert (integer == -12345); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number4_MAX == UINT32_MAX); assert (number8 == 123 * 123 * 123 * 123); assert (number8_MAX == UINT64_MAX); assert (streq (string, "This is a string")); assert (memcmp (data, "ABCDE", 5) == 0); assert (size == 5); assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0); assert (zchunk_size (chunk) == 5); assert (streq (uuid_str, zuuid_str (uuid))); assert (memcmp (zframe_data (frame), "WORLD", 5) == 0); assert (zframe_size (frame) == 5); char *value = (char *) zhashx_lookup (hash, "1"); assert (streq (value, "value A")); value = (char *) zhashx_lookup (hash, "2"); assert (streq (value, "value B")); assert (original == pointer); freen (string); freen (data); freen (uuid_str); zframe_destroy (&frame); zchunk_destroy (&chunk); zhashx_destroy (&hash); zuuid_destroy (&uuid); // Test zsock_recv of short message; this lets us return a failure // with a status code and then nothing else; the receiver will get // the status code and NULL/zero for all other values zsock_send (writer, "i", -1); zsock_recv (reader, "izsbcfp", &integer, &string, &data, &size, &chunk, &frame, &pointer); assert (integer == -1); assert (string == NULL); assert (data == NULL); assert (size == 0); assert (chunk == NULL); assert (frame == NULL); assert (pointer == NULL); msg = zmsg_new (); zmsg_addstr (msg, "frame 1"); zmsg_addstr (msg, "frame 2"); zsock_send (writer, "szm", "header", msg); zmsg_destroy (&msg); zsock_recv (reader, "szm", &string, &msg); assert (streq ("header", string)); assert (zmsg_size (msg) == 2); assert (zframe_streq (zmsg_first (msg), "frame 1")); assert (zframe_streq (zmsg_next (msg), "frame 2")); zstr_free (&string); zmsg_destroy (&msg); // Test zsock_recv with null arguments chunk = zchunk_new ("HELLO", 5); assert (chunk); frame = zframe_new ("WORLD", 5); assert (frame); zsock_send (writer, "izsbcfp", -12345, "This is a string", "ABCDE", 5, chunk, frame, original); zframe_destroy (&frame); zchunk_destroy (&chunk); zsock_recv (reader, "izsbcfp", &integer, NULL, NULL, NULL, &chunk, NULL, NULL); assert (integer == -12345); assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0); assert (zchunk_size (chunk) == 5); zchunk_destroy (&chunk); // Test zsock_bsend/brecv pictures with binary encoding frame = zframe_new ("Hello", 5); chunk = zchunk_new ("World", 5); msg = zmsg_new (); zmsg_addstr (msg, "Hello"); zmsg_addstr (msg, "World"); zsock_bsend (writer, "1248sSpcfm", number1, number2, number4, number8, "Hello, World", "Goodbye cruel World!", original, chunk, frame, msg); zchunk_destroy (&chunk); zframe_destroy (&frame); zmsg_destroy (&msg); number8 = number4 = number2 = number1 = 0; char *longstr; zsock_brecv (reader, "1248sSpcfm", &number1, &number2, &number4, &number8, &string, &longstr, &pointer, &chunk, &frame, &msg); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "Hello, World")); assert (streq (longstr, "Goodbye cruel World!")); assert (pointer == original); zstr_free (&longstr); zchunk_destroy (&chunk); zframe_destroy (&frame); zmsg_destroy (&msg); #ifdef ZMQ_SERVER // Test zsock_bsend/brecv pictures with binary encoding on SERVER and CLIENT sockets server = zsock_new (ZMQ_SERVER); assert (server); port = zsock_bind (server, "tcp://127.0.0.1:*"); assert (port != -1); zsock_t* client = zsock_new (ZMQ_CLIENT); assert (client); rc = zsock_connect (client, "tcp://127.0.0.1:%d", port); assert (rc != -1); // From client to server chunk = zchunk_new ("World", 5); zsock_bsend (client, "1248sSpc", number1, number2, number4, number8, "Hello, World", "Goodbye cruel World!", original, chunk); zchunk_destroy (&chunk); number8 = number4 = number2 = number1 = 0; zsock_brecv (server, "1248sSpc", &number1, &number2, &number4, &number8, &string, &longstr, &pointer, &chunk); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "Hello, World")); assert (streq (longstr, "Goodbye cruel World!")); assert (pointer == original); assert (zsock_routing_id (server)); zstr_free (&longstr); zchunk_destroy (&chunk); // From server to client chunk = zchunk_new ("World", 5); zsock_bsend (server, "1248sSpc", number1, number2, number4, number8, "Hello, World", "Goodbye cruel World!", original, chunk); zchunk_destroy (&chunk); number8 = number4 = number2 = number1 = 0; zsock_brecv (client, "1248sSpc", &number1, &number2, &number4, &number8, &string, &longstr, &pointer, &chunk); assert (number1 == 123); assert (number2 == 123 * 123); assert (number4 == 123 * 123 * 123); assert (number8 == 123 * 123 * 123 * 123); assert (streq (string, "Hello, World")); assert (streq (longstr, "Goodbye cruel World!")); assert (pointer == original); assert (zsock_routing_id (client) == 0); zstr_free (&longstr); zchunk_destroy (&chunk); zsock_destroy (&client); zsock_destroy (&server); #endif #ifdef ZMQ_SCATTER zsock_t* gather = zsock_new_gather ("inproc://test-gather-scatter"); assert (gather); zsock_t* scatter = zsock_new_scatter ("inproc://test-gather-scatter"); assert (scatter); rc = zstr_send (scatter, "HELLO"); assert (rc == 0); char* message; message = zstr_recv (gather); assert (streq(message, "HELLO")); zstr_free (&message); zsock_destroy (&gather); zsock_destroy (&scatter); #endif // Check that we can send a zproto format message zsock_bsend (writer, "1111sS4", 0xAA, 0xA0, 0x02, 0x01, "key", "value", 1234); zgossip_msg_t *gossip = zgossip_msg_new (); zgossip_msg_recv (gossip, reader); assert (zgossip_msg_id (gossip) == ZGOSSIP_MSG_PUBLISH); zgossip_msg_destroy (&gossip); zsock_destroy (&reader); zsock_destroy (&writer); // @end printf ("OK\n"); zsock_option_test (verbose); #if defined (__WINDOWS__) zsys_shutdown(); #endif } czmq-4.1.0/src/zconfig.c0000664000372000037200000011404313222211156015760 0ustar00travistravis00000000000000/* ========================================================================= zconfig - work with config files written in rfc.zeromq.org/spec:4/ZPL. Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Lets applications load, work with, and save configuration files. This implements rfc.zeromq.org/spec:4/ZPL, which is a simple structured text format for configuration files. @discuss Here is an example ZPL stream and corresponding config structure: context iothreads = 1 verbose = 1 # Ask for a trace main type = zqueue # ZMQ_DEVICE type frontend option hwm = 1000 swap = 25000000 # 25MB bind = 'inproc://addr1' bind = 'ipc://addr2' backend bind = inproc://addr3 root Down = child | Across = next v context-->main | | | v | type=queue-->frontend-->backend | | | | | v | | bind=inproc://addr3 | v | option-->bind=inproc://addr1-->bind=ipc://addr2 | | | v | hwm=1000-->swap=25000000 v iothreads=1-->verbose=false @end */ #include "czmq_classes.h" // Structure of our class struct _zconfig_t { char *name; // Property name if any char *value; // Property value, if any struct _zconfig_t *child, // First child if any *next, // Next sibling if any *parent; // Parent if any zlist_t *comments; // Comments if any zfile_t *file; // Config file handle }; // Local functions for parsing and saving ZPL tokens static int s_collect_level (char **start, int lineno); static char * s_collect_name (char **start, int lineno); static int s_verify_eoln (char *readptr, int lineno); static char * s_collect_value (char **start, int lineno); static int s_config_save (zconfig_t *self, void *arg, int level); static int s_config_execute (zconfig_t *self, zconfig_fct handler, void *arg, int level); // -------------------------------------------------------------------------- // Constructor // // Optionally attach new config to parent config, as first or next child. zconfig_t * zconfig_new (const char *name, zconfig_t *parent) { zconfig_t *self = (zconfig_t *) zmalloc (sizeof (zconfig_t)); assert (self); zconfig_set_name (self, name); if (parent) { if (parent->child) { // Attach as last child of parent zconfig_t *last = parent->child; while (last->next) last = last->next; last->next = self; } else // Attach as first child of parent parent->child = self; } self->parent = parent; return self; } // -------------------------------------------------------------------------- // Destructor void zconfig_destroy (zconfig_t **self_p) { assert (self_p); if (*self_p) { zconfig_t *self = *self_p; // Destroy all children and siblings recursively zconfig_destroy (&self->child); zconfig_destroy (&self->next); // Destroy other properties and then self zlist_destroy (&self->comments); zfile_destroy (&self->file); freen (self->name); freen (self->value); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Destroy node and subtree (all children) void zconfig_remove (zconfig_t **self_p) { assert (self_p); if (*self_p == NULL) return; zconfig_t *self = *self_p; // Destroy all children zconfig_remove_subtree (self); if (self->parent) { if (self->parent->child == self) { self->parent->child = self->next; } else { zconfig_t *prev = self->parent->child; while (prev->next != self) { prev = prev->next; } prev->next = self->next; } } // Destroy other properties and then self zlist_destroy (&self->comments); zfile_destroy (&self->file); freen (self->name); freen (self->value); freen (self); *self_p = NULL; } // -------------------------------------------------------------------------- // Destroy subtree (all children) void zconfig_remove_subtree (zconfig_t *self) { assert (self); // Destroy all children zconfig_destroy (&self->child); self->child = NULL; } // -------------------------------------------------------------------------- // Return name of config item char * zconfig_name (zconfig_t *self) { assert (self); return self->name; } // -------------------------------------------------------------------------- // Return value of config item char * zconfig_value (zconfig_t *self) { assert (self); return self->value; } // -------------------------------------------------------------------------- // Insert or update configuration key with value; leading slash is optional // and ignored. void zconfig_put (zconfig_t *self, const char *path, const char *value) { if (*path == '/') path++; // Check length of next path segment const char *slash = strchr (path, '/'); size_t length = strlen (path); if (slash) length = slash - path; // Find or create items starting at first child of root zconfig_t *child = self->child; while (child) { if (strlen (child->name) == length && memcmp (child->name, path, length) == 0) { // This segment exists if (slash) // Recurse to next level zconfig_put (child, slash + 1, value); else zconfig_set_value (child, "%s", value); return; } child = child->next; } // This segment doesn't exist, create it child = zconfig_new (path, self); assert (child); child->name [length] = 0; if (slash) // Recurse down further zconfig_put (child, slash, value); else zconfig_set_value (child, "%s", value); } // -------------------------------------------------------------------------- // Equivalent to zconfig_put, accepting a format specifier and variable // argument list, instead of a single string value. void zconfig_putf (zconfig_t *self, const char *path, const char *format, ...) { assert (self); va_list argptr; va_start (argptr, format); char *value = zsys_vprintf (format, argptr); va_end (argptr); zconfig_put (self, path, value); zstr_free (&value); } // -------------------------------------------------------------------------- // Set new name for config item; this may be null. void zconfig_set_name (zconfig_t *self, const char *name) { assert (self); freen (self->name); self->name = name? strdup (name): NULL; } // -------------------------------------------------------------------------- // Set new value for config item. The new value may be a string, a printf // format, or NULL. Note that if string may possibly contain '%', or if it // comes from an insecure source, you must use '%s' as the format, followed // by the string. void zconfig_set_value (zconfig_t *self, const char *format, ...) { assert (self); zstr_free (&self->value); if (format) { va_list argptr; va_start (argptr, format); self->value = zsys_vprintf (format, argptr); va_end (argptr); } else self->value = NULL; } // -------------------------------------------------------------------------- // Find our first child, if any zconfig_t * zconfig_child (zconfig_t *self) { assert (self); return self->child; } // -------------------------------------------------------------------------- // Find our first sibling, if any zconfig_t * zconfig_next (zconfig_t *self) { assert (self); return self->next; } // -------------------------------------------------------------------------- // Find a config item along a path; leading slash is optional and ignored. zconfig_t * zconfig_locate (zconfig_t *self, const char *path) { assert (self); // Check length of next path segment if (*path == '/') path++; const char *slash = strchr (path, '/'); size_t length = strlen (path); if (slash) length = slash - path; // Find matching name starting at first child of root zconfig_t *child = self->child; while (child) { if (strlen (child->name) == length && memcmp (child->name, path, length) == 0) { if (slash) // Look deeper return zconfig_locate (child, slash); else return child; } child = child->next; } return NULL; } // -------------------------------------------------------------------------- // Get value for config item into a string value; leading slash is optional // and ignored. char * zconfig_get (zconfig_t *self, const char *path, const char *default_value) { assert (self); zconfig_t *item = zconfig_locate (self, path); if (item) return zconfig_value (item); else return (char *) default_value; } // -------------------------------------------------------------------------- // Finds the latest node at the specified depth, where 0 is the root. If no // such node exists, returns NULL. zconfig_t * zconfig_at_depth (zconfig_t *self, int level) { assert (self); while (level > 0) { if (self->child) { self = self->child; while (self->next) self = self->next; level--; } else return NULL; } return self; } // -------------------------------------------------------------------------- // Execute a callback for each config item in the tree; returns zero if // successful, else -1. int zconfig_execute (zconfig_t *self, zconfig_fct handler, void *arg) { // Execute top level config at level zero assert (self); return s_config_execute (self, handler, arg, 0) >= 0? 0: -1; } // Return number of bytes processed if successful, otherwise -1. static int s_config_execute (zconfig_t *self, zconfig_fct handler, void *arg, int level) { assert (self); int size = handler (self, arg, level); if (size == -1) return -1; // fail early // Process all children in one go, as a list zconfig_t *child = self->child; while (child) { int rc = s_config_execute (child, handler, arg, level + 1); if (rc == -1) return -1; size += rc; child = child->next; } return size; } // -------------------------------------------------------------------------- // Load a config tree from a specified ZPL text file; returns a zconfig_t // reference for the root, if the file exists and is readable. Returns NULL // if the file does not exist. zconfig_t * zconfig_load (const char *filename) { // Load entire file into memory as a chunk, then process it zconfig_t *self = NULL; zfile_t *file = zfile_new (NULL, filename); if (!file) return NULL; if (zfile_input (file) == 0) { zchunk_t *chunk = zfile_read (file, zfile_cursize (file), 0); if (chunk) { self = zconfig_chunk_load (chunk); zchunk_destroy (&chunk); if (self) self->file = file; zfile_close (file); file = NULL; // Config tree now owns file handle } } zfile_destroy (&file); return self; } // -------------------------------------------------------------------------- // Save a config tree to a specified ZPL text file, where a filename // "-" means dump to standard output. int zconfig_save (zconfig_t *self, const char *filename) { assert (self); int rc = 0; if (streq (filename, "-")) // "-" means write to stdout rc = zconfig_execute (self, s_config_save, stdout); else { FILE *file; file = fopen (filename, "w"); if (file) { rc = zconfig_execute (self, s_config_save, file); fflush (file); fclose (file); // If we saved back to original file, restat it so that // the file does not appear as "changed" if (self->file && streq (filename, zconfig_filename (self))) zfile_restat (self->file); } else rc = -1; // File not writeable } return rc; } // Save an item, polymorphic: if arg is a zchunk_t *, appends the // data to the chunk; else if arg is not null, writes data to the // arg as FILE *, or appends to the chunk data. If arg is null, // stores nothing. Returns data size, or -1 if memory is exhausted. static int s_config_printf (zconfig_t *self, void *arg, char *format, ...) { va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); if (!string) return -1; if (arg) { if (zchunk_is (arg)) zchunk_append ((zchunk_t *) arg, string, strlen (string)); else fprintf ((FILE *) arg, "%s", string); } size_t size = strlen (string); zstr_free (&string); if (size > INT_MAX) return -1; return (int) size; } static int s_config_save (zconfig_t *self, void *arg, int level) { assert (self); // Store any comments on the item int size = 0; if (self->comments) { char *comment = (char *) zlist_first (self->comments); while (comment) { size += s_config_printf (self, arg, "#%s\n", comment); comment = (char *) zlist_next (self->comments); } size += s_config_printf (self, arg, "\n"); } if (level > 0) { if (self->value) size += s_config_printf (self, arg, "%*s%s = \"%s\"\n", (level - 1) * 4, "", self->name? self->name: "(Unnamed)", self->value); else size += s_config_printf (self, arg, "%*s%s\n", (level - 1) * 4, "", self->name? self->name: "(Unnamed)"); } return size; } // -------------------------------------------------------------------------- // Equivalent to zconfig_load, taking a format string instead of a fixed // filename. zconfig_t * zconfig_loadf (const char *format, ...) { va_list argptr; va_start (argptr, format); char *filename = zsys_vprintf (format, argptr); va_end (argptr); if (filename) { zconfig_t *config = zconfig_load (filename); freen (filename); return config; } else return NULL; } // -------------------------------------------------------------------------- // Equivalent to zconfig_save, taking a format string instead of a fixed // filename. int zconfig_savef (zconfig_t *self, const char *format, ...) { assert (self); va_list argptr; va_start (argptr, format); char *filename = zsys_vprintf (format, argptr); va_end (argptr); if (filename) { int rc = zconfig_save (self, filename); zstr_free (&filename); return rc; } else return -1; } // -------------------------------------------------------------------------- // Report filename used during zconfig_load, or NULL if none const char * zconfig_filename (zconfig_t *self) { assert (self); if (self->file) return (zfile_filename (self->file, NULL)); else return NULL; } // -------------------------------------------------------------------------- // Reload config tree from same file that it was previously loaded from. // Returns 0 if OK, -1 if there was an error (and then does not change // existing data). int zconfig_reload (zconfig_t **self_p) { assert (self_p); zconfig_t *self = *self_p; if (self->file) { zconfig_t *copy = zconfig_load (zfile_filename (self->file, NULL)); if (copy) { // Destroy old tree and install new one zconfig_destroy (self_p); *self_p = copy; return 0; } } return -1; // Not successful } // -------------------------------------------------------------------------- // Load a config tree from a memory chunk zconfig_t * zconfig_chunk_load (zchunk_t *chunk) { // Parse the chunk line by line zconfig_t *self = zconfig_new ("root", NULL); if (!self) return NULL; bool valid = true; int lineno = 0; char *data_ptr = (char *) zchunk_data (chunk); size_t remaining = zchunk_size (chunk); while (remaining) { // Copy stuff into cur_line; not fastest but safest option // since chunk may not be null terminated, etc. char *eoln = (char *) memchr (data_ptr, '\n', remaining); size_t cur_size; if (eoln) cur_size = eoln - data_ptr; else cur_size = remaining; if (cur_size > 1024) cur_size = 1024; char cur_line [1024 + 1]; memcpy (cur_line, data_ptr, cur_size); cur_line [cur_size] = '\0'; data_ptr = eoln? eoln + 1: NULL; remaining -= cur_size + (eoln? 1: 0); // Trim line size_t length = strlen (cur_line); while (length && isspace ((byte) cur_line [length - 1])) cur_line [--length] = 0; // Collect indentation level and name, if any lineno++; // Handle whole-line comment if present if (cur_line [0] == '#') { if (!self->comments) { self->comments = zlist_new (); assert (self->comments); zlist_autofree (self->comments); } zlist_append (self->comments, cur_line + 1); } char *scanner = cur_line; int level = s_collect_level (&scanner, lineno); if (level == -1) { valid = false; break; } char *name = s_collect_name (&scanner, lineno); if (name == NULL) { valid = false; break; } // If name is not empty, collect property value if (*name) { char *value = s_collect_value (&scanner, lineno); if (value == NULL) valid = false; else { // Navigate to parent for this element zconfig_t *parent = zconfig_at_depth (self, level); if (parent) { zconfig_t *item = zconfig_new (name, parent); assert (item); item->value = value; } else { zclock_log ("E (zconfig): (%d) indentation error", lineno); freen (value); valid = false; } } } else if (s_verify_eoln (scanner, lineno)) valid = false; freen (name); if (!valid) break; } // Either the whole ZPL stream is valid or none of it is if (!valid) zconfig_destroy (&self); return self; } // Count and verify indentation level, -1 means a syntax error or overflow static int s_collect_level (char **start, int lineno) { char *readptr = *start; while (*readptr == ' ') readptr++; ptrdiff_t level = (readptr - *start) / 4; if (level * 4 != readptr - *start) { zclock_log ("E (zconfig): (%d) indent 4 spaces at once", lineno); level = -1; } *start = readptr; if (level > INT_MAX) return -1; return (int) level; } // Collect property name static bool s_is_namechar (char thischar) { return ( isalnum (thischar) || thischar == '$' || thischar == '-' || thischar == '_' || thischar == '@' || thischar == '.' || thischar == '&' || thischar == '+' || thischar == '/'); } static char * s_collect_name (char **start, int lineno) { char *readptr = *start; while (s_is_namechar ((char) **start)) (*start)++; size_t length = *start - readptr; char *name = (char *) zmalloc (length + 1); if (!name) return NULL; memcpy (name, readptr, length); name [length] = 0; if (length > 0 && (name [0] == '/' || name [length - 1] == '/')) { zclock_log ("E (zconfig): (%d) '/' not valid at name start or end", lineno); freen (name); name = NULL; } return name; } // Check there's no junk after value on line, returns 0 if OK else -1. static int s_verify_eoln (char *readptr, int lineno) { while (*readptr) { if (isspace ((byte) *readptr)) readptr++; else if (*readptr == '#') break; else { zclock_log ("E (zconfig): (%d) invalid syntax '%s'", lineno, readptr); return -1; break; } } return 0; } // Return value for name, or "" - if syntax error, returns NULL. static char * s_collect_value (char **start, int lineno) { char *value = NULL; char *readptr = *start; int rc = 0; while (isspace ((byte) *readptr)) readptr++; if (*readptr == '=') { readptr++; while (isspace ((byte) *readptr)) readptr++; // If value starts with quote or apost, collect it if (*readptr == '"' || *readptr == '\'') { char *endquote = strchr (readptr + 1, *readptr); if (endquote) { size_t value_length = endquote - readptr - 1; value = (char *) zmalloc (value_length + 1); if (!value) return NULL; memcpy (value, readptr + 1, value_length); value [value_length] = 0; rc = s_verify_eoln (endquote + 1, lineno); } else { zclock_log ("E (zconfig): (%d) missing %c", lineno, *readptr); rc = -1; } } else { // Collect unquoted value up to comment char *comment = strchr (readptr, '#'); if (comment) { while (isspace ((byte) comment [-1])) comment--; *comment = 0; } value = strdup (readptr); } } else { value = strdup (""); rc = s_verify_eoln (readptr, lineno); } // If we had an error, drop value and return NULL if (rc) { freen (value); value = NULL; } return value; } // -------------------------------------------------------------------------- // Save a config tree to a new memory chunk; the chunk zchunk_t * zconfig_chunk_save (zconfig_t *self) { assert (self); int size = s_config_execute (self, s_config_save, NULL, 0); // Allow an extra byte so we can null-terminate the data zchunk_t *chunk = zchunk_new (NULL, size + 1); if (chunk) { s_config_execute (self, s_config_save, chunk, 0); // This lets us treat the chunk data as a string zchunk_data (chunk) [zchunk_size (chunk)] = 0; } return chunk; } // -------------------------------------------------------------------------- // Create a new config tree from a null-terminated string zconfig_t * zconfig_str_load (const char *string) { zchunk_t *chunk = zchunk_new (string, strlen (string)); zconfig_t *config = zconfig_chunk_load (chunk); zchunk_destroy (&chunk); return config; } // -------------------------------------------------------------------------- // Save a config tree to a new null terminated string char * zconfig_str_save (zconfig_t *self) { zchunk_t *chunk = zconfig_chunk_save (self); char *string = strdup ((char *) zchunk_data (chunk)); zchunk_destroy (&chunk); return string; } // -------------------------------------------------------------------------- // Return true if a configuration tree was loaded from a file and that // file has changed in since the tree was loaded. bool zconfig_has_changed (zconfig_t *self) { assert (self); if (self->file && zfile_has_changed (self->file)) return true; else return false; } // -------------------------------------------------------------------------- // Add comment to config item before saving to disk. You can add as many // comment lines as you like. If you use a null format, all comments are // deleted. void zconfig_set_comment (zconfig_t *self, const char *format, ...) { if (format) { if (!self->comments) { self->comments = zlist_new (); assert (self->comments); zlist_autofree (self->comments); } va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); zlist_append (self->comments, string); zstr_free (&string); } else zlist_destroy (&self->comments); } // -------------------------------------------------------------------------- // Return comments of config item, as zlist. zlist_t * zconfig_comments (zconfig_t *self) { assert (self); return self->comments; } // -------------------------------------------------------------------------- // Print the config file to open stream void zconfig_fprint (zconfig_t *self, FILE *file) { zconfig_execute (self, s_config_save, file); } // -------------------------------------------------------------------------- // Print the config file to stdout void zconfig_print (zconfig_t *self) { zconfig_fprint (self, stdout); } // -------------------------------------------------------------------------- // Self test of this class void zconfig_test (bool verbose) { printf (" * zconfig: "); // @selftest const char *SELFTEST_DIR_RW = "src/selftest-rw"; const char *testbasedir = ".test_zconfig"; const char *testfile = "test.cfg"; char *basedirpath = NULL; // subdir in a test, under SELFTEST_DIR_RW char *filepath = NULL; // pathname to testfile in a test, in dirpath basedirpath = zsys_sprintf ("%s/%s", SELFTEST_DIR_RW, testbasedir); assert (basedirpath); filepath = zsys_sprintf ("%s/%s", basedirpath, testfile); assert (filepath); // Make sure old aborted tests do not hinder us zdir_t *dir = zdir_new (basedirpath, NULL); if (dir) { zdir_remove (dir, true); zdir_destroy (&dir); } zsys_file_delete (filepath); zsys_dir_delete (basedirpath); // Create temporary directory for test files zsys_dir_create (basedirpath); zconfig_t *root = zconfig_new ("root", NULL); assert (root); zconfig_t *section, *item; section = zconfig_new ("headers", root); assert (section); item = zconfig_new ("email", section); assert (item); zconfig_set_value (item, "some@random.com"); item = zconfig_new ("name", section); assert (item); zconfig_set_value (item, "Justin Kayce"); zconfig_putf (root, "/curve/secret-key", "%s", "Top Secret"); zconfig_set_comment (root, " CURVE certificate"); zconfig_set_comment (root, " -----------------"); assert (zconfig_comments (root)); zconfig_save (root, filepath); zconfig_destroy (&root); root = zconfig_load (filepath); if (verbose) zconfig_save (root, "-"); assert (streq (zconfig_filename (root), filepath)); char *email = zconfig_get (root, "/headers/email", NULL); assert (email); assert (streq (email, "some@random.com")); char *passwd = zconfig_get (root, "/curve/secret-key", NULL); assert (passwd); assert (streq (passwd, "Top Secret")); zconfig_savef (root, "%s/%s", basedirpath, testfile); assert (!zconfig_has_changed (root)); int rc = zconfig_reload (&root); assert (rc == 0); assert (!zconfig_has_changed (root)); zconfig_destroy (&root); // Test chunk load/save root = zconfig_new ("root", NULL); assert (root); section = zconfig_new ("section", root); assert (section); item = zconfig_new ("value", section); assert (item); zconfig_set_value (item, "somevalue"); zconfig_t *search = zconfig_locate (root, "section/value"); assert (search == item); zchunk_t *chunk = zconfig_chunk_save (root); assert (strlen ((char *) zchunk_data (chunk)) == 32); char *string = zconfig_str_save (root); assert (string); assert (streq (string, (char *) zchunk_data (chunk))); freen (string); assert (chunk); zconfig_destroy (&root); root = zconfig_chunk_load (chunk); assert (root); char *value = zconfig_get (root, "/section/value", NULL); assert (value); assert (streq (value, "somevalue")); // Test config can't be saved to a file in a path that doesn't // exist or isn't writable rc = zconfig_savef (root, "%s/path/that/doesnt/exist/%s", basedirpath, testfile); assert (rc == -1); zconfig_destroy (&root); zchunk_destroy (&chunk); // Test str_load zconfig_t *config = zconfig_str_load ( "malamute\n" " endpoint = ipc://@/malamute\n" " producer = STREAM\n" " consumer\n" " STREAM2 = .*\n" " STREAM3 = HAM\n" "server\n" " verbose = true\n" ); assert (config); assert (streq (zconfig_get (config, "malamute/endpoint", NULL), "ipc://@/malamute")); assert (streq (zconfig_get (config, "malamute/producer", NULL), "STREAM")); assert (zconfig_locate (config, "malamute/consumer")); zconfig_t *c = zconfig_child (zconfig_locate (config, "malamute/consumer")); assert (c); assert (streq (zconfig_name (c), "STREAM2")); assert (streq (zconfig_value (c), ".*")); c = zconfig_next (c); assert (c); assert (streq (zconfig_name (c), "STREAM3")); assert (streq (zconfig_value (c), "HAM")); c = zconfig_next (c); assert (!c); assert (streq (zconfig_get (config, "server/verbose", NULL), "true")); zconfig_destroy (&config); // Test subtree removal { zconfig_t *root = zconfig_str_load ( "context\n" " iothreads = 1\n" " verbose = 1 # Ask for a trace\n" "main\n" " type = zqueue # ZMQ_DEVICE type\n" " frontend\n" " option\n" " hwm = 1000\n" " swap = 25000000 # 25MB\n" " bind = 'inproc://addr1'\n" " bind = 'ipc://addr2'\n" " backend\n" " bind = inproc://addr3\n" ); // no subtree zconfig_t *to_delete = zconfig_locate (root, "context/iothreads"); assert (to_delete); zconfig_remove_subtree (to_delete); zconfig_t *check = zconfig_locate (root, "context/iothreads"); assert (check); assert (streq (zconfig_value (check), "1")); check = zconfig_locate (root, "context/verbose"); assert (check); assert (streq (zconfig_value (check), "1")); // existing subtree to_delete = zconfig_locate (root, "main/frontend/option"); assert (to_delete); zconfig_remove_subtree (to_delete); check = zconfig_locate (root, "main/frontend/option/hwm"); assert (check == NULL); check = zconfig_locate (root, "main/frontend/option/swap"); assert (check == NULL); check = zconfig_locate (root, "main/frontend/option"); assert (check); assert (streq (zconfig_value (check), "")); check = zconfig_next (check); assert (check); assert (streq (zconfig_name (check), "bind")); assert (streq (zconfig_value (check), "inproc://addr1")); check = zconfig_next (check); assert (check); assert (streq (zconfig_name (check), "bind")); assert (streq (zconfig_value (check), "ipc://addr2")); assert (zconfig_next (check) == NULL); to_delete = zconfig_locate (root, "main/frontend"); assert (to_delete); zconfig_remove_subtree (to_delete); check = zconfig_locate (root, "main/frontend/option/hwm"); assert (check == NULL); check = zconfig_locate (root, "main/frontend/option/swap"); assert (check == NULL); check = zconfig_locate (root, "main/frontend/option"); assert (check == NULL); check = zconfig_locate (root, "main/frontend/bind"); assert (check == NULL); check = zconfig_locate (root, "main/frontend"); assert (check); assert (streq (zconfig_value (check), "")); assert (zconfig_child (check) == NULL); check = zconfig_next (check); assert (check); assert (streq (zconfig_name (check), "backend")); assert (streq (zconfig_value (check), "")); to_delete = zconfig_locate (root, "main"); assert (to_delete); zconfig_remove_subtree (to_delete); check = zconfig_locate (root, "main/type"); assert (check == NULL); check = zconfig_locate (root, "main/frontend"); assert (check == NULL); check = zconfig_locate (root, "main/backend"); assert (check == NULL); check = zconfig_locate (root, "main"); assert (check); // root zconfig_remove_subtree (root); assert (root); assert (zconfig_child (root) == NULL); check = zconfig_locate (root, "main"); assert (check == NULL); check = zconfig_locate (root, "context"); assert (check == NULL); zconfig_destroy (&root); } // Test node and subtree removal { zconfig_t *root = zconfig_str_load ( "A1 = abc\n" " x\n" " 1\n" " 2\n" " y = 1 # Ask for a trace\n" "A2\n" " B1 = zqueue # ZMQ_DEVICE type\n" " B2\n" " C1\n" " hwm = 1000\n" " swap = 25000000 # 25MB\n" " C2 = 50\n" " C3\n" " bind = addr3\n" " B3\n" " bind = inproc://addr4\n" " B4 = Ignac\n" " z = 5\n" "A3\n" "A4\n" ); zconfig_t *to_delete = zconfig_locate (root, "A2/B2/C3"); assert (to_delete); zconfig_remove (&to_delete); zconfig_t *check = zconfig_locate (root, "A2/B2/C2"); assert (check); assert (streq (zconfig_value (check), "50")); assert (zconfig_next (check) == NULL); assert (zconfig_locate (root, "A2/B2/C3/bind") == NULL); assert (zconfig_locate (root, "A2/B2/C3") == NULL); to_delete = zconfig_locate (root, "A2/B2"); assert (to_delete); zconfig_remove (&to_delete); check = zconfig_locate (root, "A2"); assert (check); check = zconfig_child (check); assert (check); assert (streq (zconfig_name (check), "B1")); assert (streq (zconfig_value (check), "zqueue")); check = zconfig_next (check); assert (check); assert (streq (zconfig_name (check), "B3")); assert (streq (zconfig_value (check), "")); assert (zconfig_locate (root, "A2/B2/C1") == NULL); assert (zconfig_locate (root, "A2/B2/C2") == NULL); assert (zconfig_locate (root, "A2/B2") == NULL); assert (zconfig_locate (root, "A2/B4")); to_delete = zconfig_locate (root, "A2/B1"); assert (to_delete); zconfig_remove (&to_delete); check = zconfig_locate (root, "A2"); assert (check); check = zconfig_child (check); assert (check); assert (streq (zconfig_name (check), "B3")); assert (streq (zconfig_value (check), "")); check = zconfig_next (check); assert (check); assert (streq (zconfig_name (check), "B4")); assert (streq (zconfig_value (check), "Ignac")); assert (zconfig_next (check) == NULL); assert (zconfig_locate (root, "A2/B1") == NULL); assert (zconfig_locate (root, "A2/B2") == NULL); to_delete = zconfig_locate (root, "A2/B3"); assert (to_delete); zconfig_remove (&to_delete); check = zconfig_locate (root, "A2"); assert (check); check = zconfig_child (check); assert (check); assert (streq (zconfig_name (check), "B4")); assert (streq (zconfig_value (check), "Ignac")); assert (zconfig_next (check) == NULL); to_delete = zconfig_locate (root, "A2"); assert (to_delete); zconfig_remove (&to_delete); check = zconfig_locate (root, "A1"); assert (check); check = zconfig_next (check); assert (check); assert (streq (zconfig_name (check), "A3")); assert (zconfig_locate (root, "A2/B4") == NULL); assert (zconfig_locate (root, "A2") == NULL); to_delete = zconfig_locate (root, "A1"); assert (to_delete); zconfig_remove (&to_delete); check = zconfig_child (root); assert (check); assert (streq (zconfig_name (check), "A3")); assert (zconfig_locate (root, "A1/x/1") == NULL); assert (zconfig_locate (root, "A1/x") == NULL); assert (zconfig_locate (root, "A1/y") == NULL); assert (zconfig_locate (root, "A3")); assert (zconfig_locate (root, "A4")); // called on root should be equivalent to zconfig_destroy (&root) zconfig_remove (&root); } // Delete all test files dir = zdir_new (basedirpath, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); zstr_free (&basedirpath); zstr_free (&filepath); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zhashx.c0000664000372000037200000012642513222211156015635 0ustar00travistravis00000000000000/* ========================================================================= zhashx - extended generic hash container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header zhashx is an extended hash table container with more functionality than zhash, its simpler cousin. @discuss The hash table always has a size that is prime and roughly doubles its size when 75% full. In case of hash collisions items are chained in a linked list. The hash table size is increased slightly (up to 5 times before roughly doubling the size) when an overly long chain (between 1 and 63 items depending on table size) is detected. @end */ #include "czmq_classes.h" // Hash table performance parameters #define INITIAL_PRIME 0 // Initial size in items (index into primes) #define GROWTH_FACTOR 5 // Increase after splitting (index into primes) #define LOAD_FACTOR 75 // Percent loading before splitting #define INITIAL_CHAIN 1 // Initial chaining limit #define CHAIN_GROWS 1 // Increase after splitting (chaining limit) #include "zhash_primes.inc" // Hash item, used internally only typedef struct _item_t { void *value; // Opaque item value struct _item_t *next; // Next item in the hash slot size_t index; // Index of item in table const void *key; // Item's original key zhashx_free_fn *free_fn; // Value free function if any } item_t; // --------------------------------------------------------------------- // Structure of our class struct _zhashx_t { size_t size; // Current size of hash table uint prime_index; // Current prime number used as limit uint chain_limit; // Current limit on chain length item_t **items; // Array of items size_t cached_index; // Avoids duplicate hash calculations size_t cursor_index; // For first/next iteration item_t *cursor_item; // For first/next iteration const void *cursor_key; // After first/next call, points to key zlistx_t *comments; // File comments, if any time_t modified; // Set during zhashx_load char *filename; // Set during zhashx_load // Function callbacks for duplicating and destroying items, if any zhashx_duplicator_fn *duplicator; zhashx_destructor_fn *destructor; // Function callbacks for duplicating and destroying keys, if any zhashx_duplicator_fn *key_duplicator; zhashx_destructor_fn *key_destructor; zhashx_comparator_fn *key_comparator; // Custom hash function zhashx_hash_fn *hasher; }; // Local helper functions static item_t *s_item_lookup (zhashx_t *self, const void *key); static item_t *s_item_insert (zhashx_t *self, const void *key, void *value); static void s_item_destroy (zhashx_t *self, item_t *item, bool hard); // -------------------------------------------------------------------------- // Modified Bernstein hashing function static size_t s_bernstein_hash (const void *key) { const char *pointer = (const char *) key; size_t key_hash = 0; while (*pointer) key_hash = 33 * key_hash ^ *pointer++; return key_hash; } // -------------------------------------------------------------------------- // Hash table constructor zhashx_t * zhashx_new (void) { zhashx_t *self = (zhashx_t *) zmalloc (sizeof (zhashx_t)); assert (self); self->prime_index = INITIAL_PRIME; self->chain_limit = INITIAL_CHAIN; size_t limit = primes [self->prime_index]; self->items = (item_t **) zmalloc (sizeof (item_t *) * limit); assert (self->items); self->hasher = s_bernstein_hash; self->key_destructor = (zhashx_destructor_fn *) zstr_free; self->key_duplicator = (zhashx_duplicator_fn *) strdup; self->key_comparator = (zhashx_comparator_fn *) strcmp; return self; } // -------------------------------------------------------------------------- // Purge all items from a hash table static void s_purge (zhashx_t *self) { uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { // Destroy all items in this hash bucket item_t *cur_item = self->items [index]; while (cur_item) { item_t *next_item = cur_item->next; s_item_destroy (self, cur_item, true); cur_item = next_item; } self->items [index] = NULL; } } // -------------------------------------------------------------------------- // Hash table destructor void zhashx_destroy (zhashx_t **self_p) { assert (self_p); if (*self_p) { zhashx_t *self = *self_p; if (self->items) { s_purge (self); freen (self->items); } zlistx_destroy (&self->comments); freen (self->filename); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Local helper function // Destroy item in hash table, item must exist in table static void s_item_destroy (zhashx_t *self, item_t *item, bool hard) { // Find previous item since it's a singly-linked list item_t *cur_item = self->items [item->index]; item_t **prev_item = &(self->items [item->index]); while (cur_item) { if (cur_item == item) break; prev_item = &(cur_item->next); cur_item = cur_item->next; } assert (cur_item); *prev_item = item->next; self->size--; if (hard) { if (self->destructor) (self->destructor)(&item->value); else if (item->free_fn) (item->free_fn)(item->value); self->cursor_item = NULL; self->cursor_key = NULL; if (self->key_destructor) (self->key_destructor)((void **) &item->key); freen (item); } } // -------------------------------------------------------------------------- // Rehash hash table with specified new prime index // Returns 0 on success, or fails the assertions (e.g. insufficient memory) // Note: Older code used to return -1 in case of errors - this is no longer so static int s_zhashx_rehash (zhashx_t *self, uint new_prime_index) { assert (self); assert (new_prime_index < sizeof (primes)); size_t limit = primes [self->prime_index]; size_t new_limit = primes [new_prime_index]; item_t **new_items = (item_t **) zmalloc (sizeof (item_t *) * new_limit); assert (new_items); // Move all items to the new hash table, rehashing to // take into account new hash table limit size_t index; for (index = 0; index < limit; index++) { item_t *cur_item = self->items [index]; while (cur_item) { item_t *next_item = cur_item->next; size_t new_index = self->hasher (cur_item->key); new_index %= new_limit; cur_item->index = new_index; cur_item->next = new_items [new_index]; new_items [new_index] = cur_item; cur_item = next_item; } } // Destroy old hash table freen (self->items); self->items = new_items; self->prime_index = new_prime_index; return 0; } // -------------------------------------------------------------------------- // Insert item into hash table with specified key and item. Returns 0 on // success. If the key is already present, returns -1 and leaves existing // item unchanged. Sets the hash cursor to the item, if found. Dies with // assertion if the process heap memory ran out. (Note: older code returned // -1 in such cases; this is no longer so). int zhashx_insert (zhashx_t *self, const void *key, void *value) { assert (self); assert (key); // If we're exceeding the load factor of the hash table, // resize it according to the growth factor size_t limit = primes [self->prime_index]; if (self->size >= limit * LOAD_FACTOR / 100) { // Create new hash table uint new_prime_index = self->prime_index + GROWTH_FACTOR; assert (s_zhashx_rehash (self, new_prime_index) == 0); self->chain_limit += CHAIN_GROWS; } return s_item_insert (self, key, value)? 0: -1; } // -------------------------------------------------------------------------- // Local helper function // Insert new item into hash table, returns item // If item already existed, returns NULL // Sets the hash cursor to the item, if found. static item_t * s_item_insert (zhashx_t *self, const void *key, void *value) { // Check that item does not already exist in hash table // Leaves self->cached_index with calculated hash item item_t *item = s_item_lookup (self, key); if (item == NULL) { item = (item_t *) zmalloc (sizeof (item_t)); assert (item); // If necessary, take duplicate of item key if (self->key_duplicator) item->key = (self->key_duplicator)((void *) key); else item->key = key; // If necessary, take duplicate of item value if (self->duplicator) item->value = (self->duplicator)(value); else item->value = value; item->index = self->cached_index; // Insert into start of bucket list item->next = self->items [self->cached_index]; self->items [self->cached_index] = item; self->size++; self->cursor_item = item; self->cursor_key = item->key; } else item = NULL; // Signal duplicate insertion return item; } // -------------------------------------------------------------------------- // Local helper function // Lookup item in hash table, returns item or NULL // Dies with assertion if the process heap memory ran out (Note: older code // returned NULL in such cases; this is no longer so). static item_t * s_item_lookup (zhashx_t *self, const void *key) { // Look in bucket list for item by key size_t limit = primes [self->prime_index]; self->cached_index = self->hasher (key) % limit; item_t *item = self->items [self->cached_index]; uint len = 0; while (item) { if ((self->key_comparator)(item->key, key) == 0) break; item = item->next; ++len; } if (len > self->chain_limit) { // Create new hash table uint new_prime_index = self->prime_index + GROWTH_FACTOR; assert (s_zhashx_rehash (self, new_prime_index) == 0); limit = primes [self->prime_index]; self->cached_index = self->hasher (key) % limit; } return item; } // -------------------------------------------------------------------------- // Update or insert item into hash table with specified key and item. If the // key is already present, destroys old item and inserts new one. If you set // a container item destructor, this is called on the old value. If the key // was not already present, inserts a new item. Sets the hash cursor to the // new item. void zhashx_update (zhashx_t *self, const void *key, void *value) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) { if (self->destructor) (self->destructor)(&item->value); else if (item->free_fn) (item->free_fn)(item->value); // If necessary, take duplicate of item value if (self->duplicator) item->value = (self->duplicator)(value); else item->value = value; } else zhashx_insert (self, key, value); } // -------------------------------------------------------------------------- // Remove an item specified by key from the hash table. If there was no such // item, this function does nothing. void zhashx_delete (zhashx_t *self, const void *key) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) s_item_destroy (self, item, true); } // -------------------------------------------------------------------------- // Delete all items from the hash table. If the key destructor is // set, calls it on every key. If the item destructor is set, calls // it on every item. void zhashx_purge (zhashx_t *self) { assert (self); s_purge (self); if (self->prime_index > INITIAL_PRIME) { // Try to shrink hash table size_t limit = primes [INITIAL_PRIME]; item_t **items = (item_t **) zmalloc (sizeof (item_t *) * limit); assert (items); freen (self->items); self->prime_index = INITIAL_PRIME; self->chain_limit = INITIAL_CHAIN; self->items = items; } } // -------------------------------------------------------------------------- // Look for item in hash table and return its item, or NULL. Sets the hash // cursor to the item, if found. void * zhashx_lookup (zhashx_t *self, const void *key) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) { self->cursor_item = item; self->cursor_key = item->key; return item->value; } else return NULL; } // -------------------------------------------------------------------------- // Reindexes an item from an old key to a new key. If there was no such // item, does nothing. If the new key already exists, deletes old item. // Sets the item cursor to the renamed item. int zhashx_rename (zhashx_t *self, const void *old_key, const void *new_key) { item_t *old_item = s_item_lookup (self, old_key); item_t *new_item = s_item_lookup (self, new_key); if (old_item && !new_item) { s_item_destroy (self, old_item, false); if (self->key_destructor) (self->key_destructor)((void **) &old_item->key); if (self->key_duplicator) old_item->key = (self->key_duplicator)(new_key); else old_item->key = new_key; old_item->index = self->cached_index; old_item->next = self->items [self->cached_index]; self->items [self->cached_index] = old_item; self->size++; self->cursor_item = old_item; self->cursor_key = old_item->key; return 0; } else return -1; } // -------------------------------------------------------------------------- // Set a free function for the specified hash table item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when hash items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zhashx_freefn (zhashx_t *self, const void *key, zhashx_free_fn free_fn) { assert (self); assert (key); item_t *item = s_item_lookup (self, key); if (item) { item->free_fn = free_fn; return item->value; } else return NULL; } // -------------------------------------------------------------------------- // Return size of hash table size_t zhashx_size (zhashx_t *self) { assert (self); return self->size; } // -------------------------------------------------------------------------- // Return a zlistx_t containing the keys for the items in the // table. Uses the key_duplicator to duplicate all keys and sets the // key_destructor as destructor for the list. zlistx_t * zhashx_keys (zhashx_t *self) { assert (self); zlistx_t *keys = zlistx_new (); if (!keys) return NULL; zlistx_set_destructor (keys, self->key_destructor); zlistx_set_duplicator (keys, self->key_duplicator); uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { if (zlistx_add_end (keys, (void *) item->key) == NULL) { zlistx_destroy (&keys); return NULL; } item = item->next; } } return keys; } // Return a zlistx_t containing the items in the table. If there exists // a duplicator, then it is used to duplicate all items, and if there // is a destructor then it set as the destructor for the list. zlistx_t * zhashx_values (zhashx_t *self) { assert (self); zlistx_t *values = zlistx_new (); if (!values) return NULL; zlistx_set_destructor (values, self->destructor); zlistx_set_duplicator (values, self->duplicator); uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { if (zlistx_add_end (values, (void *) item->value) == NULL) { zlistx_destroy (&values); return NULL; } item = item->next; } } return values; } // -------------------------------------------------------------------------- // Simple iterator; returns first item in hash table, in no given order, // or NULL if the table is empty. This method is simpler to use than the // foreach() method, which is deprecated. NOTE: do NOT modify the table // while iterating. void * zhashx_first (zhashx_t *self) { assert (self); // Point to before or at first item self->cursor_index = 0; self->cursor_item = self->items [self->cursor_index]; // Now scan forwards to find it, leave cursor after item return zhashx_next (self); } // -------------------------------------------------------------------------- // Simple iterator; returns next item in hash table, in no given order, // or NULL if the last item was already returned. Use this together with // zhashx_first() to process all items in a hash table. If you need the // items in sorted order, use zhashx_keys() and then zlistx_sort(). NOTE: // do NOT modify the table while iterating. void * zhashx_next (zhashx_t *self) { assert (self); // Scan forward from cursor until we find an item size_t limit = primes [self->prime_index]; while (self->cursor_item == NULL) { if (self->cursor_index < limit - 1) self->cursor_index++; else return NULL; // At end of table // Get first item in next bucket self->cursor_item = self->items [self->cursor_index]; } // We have an item, so return it, and bump past it assert (self->cursor_item); item_t *item = self->cursor_item; self->cursor_key = item->key; self->cursor_item = self->cursor_item->next; return item->value; } // -------------------------------------------------------------------------- // After a successful insert, update, or first/next method, returns the key // for the item that was returned. You may not modify or deallocate // the key, and it lasts as long as the item in the hash. // After an unsuccessful first/next, returns NULL. const void * zhashx_cursor (zhashx_t *self) { assert (self); return self->cursor_key; } // -------------------------------------------------------------------------- // Add a comment to hash table before saving to disk. You can add as many // comment lines as you like. These comment lines are discarded when loading // the file. If you use a null format, all comments are deleted. // FIXME: return 0 on success, -1 on error void zhashx_comment (zhashx_t *self, const char *format, ...) { if (format) { if (!self->comments) { self->comments = zlistx_new (); if (!self->comments) return; zlistx_set_destructor (self->comments, (zhashx_destructor_fn *) zstr_free); } va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); va_end (argptr); if (string) zlistx_add_end (self->comments, string); } else zlistx_destroy (&self->comments); } // -------------------------------------------------------------------------- // Save hash table to a text file in name=value format // Hash values must be printable strings. // Returns 0 if OK, else -1 if a file error occurred int zhashx_save (zhashx_t *self, const char *filename) { assert (self); FILE *handle = fopen (filename, "w"); if (!handle) return -1; // Failed to create file if (self->comments) { char *comment = (char *) zlistx_first (self->comments); while (comment) { fprintf (handle, "# %s\n", comment); comment = (char *) zlistx_next (self->comments); } fprintf (handle, "\n"); } uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { fprintf (handle, "%s=%s\n", (char *) item->key, (char *) item->value); item = item->next; } } fclose (handle); return 0; } // -------------------------------------------------------------------------- // Load hash table from a text file in name=value format; hash table must // already exist. Hash values must printable strings. // Returns 0 if OK, else -1 if a file was not readable. int zhashx_load (zhashx_t *self, const char *filename) { assert (self); zhashx_set_destructor (self, (zhashx_destructor_fn *) zstr_free); zhashx_set_duplicator (self, (zhashx_duplicator_fn *) strdup); // Whether or not file exists, we'll track the filename and last // modification date (0 for unknown files), so that zhashx_refresh () // will always work after zhashx_load (), to load a newly-created // file. // Take copy of filename in case self->filename is same string. char *filename_copy = strdup (filename); assert (filename_copy); freen (self->filename); self->filename = filename_copy; self->modified = zsys_file_modified (self->filename); FILE *handle = fopen (self->filename, "r"); if (handle) { char *buffer = (char *) zmalloc (1024); assert (buffer); while (fgets (buffer, 1024, handle)) { // Skip lines starting with "#" or that do not look like // name=value data. char *equals = strchr (buffer, '='); if (buffer [0] == '#' || equals == buffer || !equals) continue; // Buffer may end in newline, which we don't want if (buffer [strlen (buffer) - 1] == '\n') buffer [strlen (buffer) - 1] = 0; *equals++ = 0; zhashx_update (self, buffer, equals); } freen (buffer); fclose (handle); } else return -1; // Failed to open file for reading return 0; } // -------------------------------------------------------------------------- // When a hash table was loaded from a file by zhashx_load, this method will // reload the file if it has been modified since, and is "stable", i.e. not // still changing. Returns 0 if OK, -1 if there was an error reloading the // file. int zhashx_refresh (zhashx_t *self) { assert (self); if (self->filename) { if (zsys_file_modified (self->filename) > self->modified && zsys_file_stable (self->filename)) { // Empty the hash table; code is copied from zhashx_destroy uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { // Destroy all items in this hash bucket item_t *cur_item = self->items [index]; while (cur_item) { item_t *next_item = cur_item->next; s_item_destroy (self, cur_item, true); cur_item = next_item; } } zhashx_load (self, self->filename); } } return 0; } // -------------------------------------------------------------------------- // Same as pack but uses a user-defined serializer function to convert items // into longstr. // Caller owns return value and must destroy it when done. zframe_t * zhashx_pack_own (zhashx_t *self, zhashx_serializer_fn serializer) { assert (self); // First, calculate packed data size size_t frame_size = 4; // Dictionary size, number-4 uint index; uint vindex = 0; size_t limit = primes [self->prime_index]; char **values = (char **) zmalloc (self->size * sizeof (char*)); for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { // We store key as short string frame_size += 1 + strlen ((char *) item->key); // We store value as long string if (serializer != NULL) values [vindex] = serializer (item->value); else values [vindex] = (char *) item->value; frame_size += 4 + strlen ((char *) values [vindex]); item = item->next; vindex++; } } // Now serialize items into the frame zframe_t *frame = zframe_new (NULL, frame_size); if (!frame) { freen (values); return NULL; } byte *needle = zframe_data (frame); // Store size as number-4 *(uint32_t *) needle = htonl ((u_long) self->size); needle += 4; vindex = 0; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { // Store key as string *needle++ = (byte) strlen ((char *) item->key); memcpy (needle, item->key, strlen ((char *) item->key)); needle += strlen ((char *) item->key); // Store value as longstr size_t lenth = strlen (values [vindex]); *(uint32_t *) needle = htonl ((u_long) lenth); needle += 4; memcpy (needle, (char *) values [vindex], strlen ((char *) values [vindex])); needle += strlen ((char *) values [vindex]); item = item->next; // Destroy serialized value if (serializer != NULL) zstr_free (&values [vindex]); vindex++; } } freen (values); return frame; } // -------------------------------------------------------------------------- // Serialize hash table to a binary frame that can be sent in a message. // The packed format is compatible with the 'dictionary' type defined in // http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: // // ; A list of name/value pairs // dictionary = dict-count *( dict-name dict-value ) // dict-count = number-4 // dict-value = longstr // dict-name = string // // ; Strings are always length + text contents // longstr = number-4 *VCHAR // string = number-1 *VCHAR // // ; Numbers are unsigned integers in network byte order // number-1 = 1OCTET // number-4 = 4OCTET // // Comments are not included in the packed data. Item values MUST be // strings. zframe_t * zhashx_pack (zhashx_t *self) { return zhashx_pack_own (self, NULL); } // -------------------------------------------------------------------------- // Same as unpack but uses a user-defined deserializer function to convert // a longstr back into item format. zhashx_t * zhashx_unpack_own (zframe_t *frame, zhashx_deserializer_fn deserializer) { zhashx_t *self = zhashx_new (); if (!self) return NULL; assert (frame); if (zframe_size (frame) < 4) return self; // Arguable... byte *needle = zframe_data (frame); byte *ceiling = needle + zframe_size (frame); size_t nbr_items = ntohl (*(uint32_t *) needle); needle += 4; while (nbr_items && needle < ceiling) { // Get key as string size_t key_size = *needle++; if (needle + key_size <= ceiling) { char key [256]; memcpy (key, needle, key_size); key [key_size] = 0; needle += key_size; // Get value as longstr if (needle + 4 <= ceiling) { size_t value_size = ntohl (*(uint32_t *) needle); needle += 4; // Be wary of malformed frames if (needle + value_size <= ceiling) { char *value = (char *) zmalloc (value_size + 1); assert (value); memcpy (value, needle, value_size); value [value_size] = 0; needle += value_size; // Convert string to real value void *real_value; if (deserializer != NULL) { real_value = deserializer (value); zstr_free (&value); } else real_value = value; // Hash takes ownership of real_value if (zhashx_insert (self, key, real_value)) { zhashx_destroy (&self); break; } } } } } // Hash will free values in destructor if (self) { zhashx_set_destructor (self, (zhashx_destructor_fn *) zstr_free); zhashx_set_duplicator (self, (zhashx_duplicator_fn *) strdup); } return self; } // -------------------------------------------------------------------------- // Unpack binary frame into a new hash table. Packed data must follow format // defined by zhashx_pack. Hash table is set to autofree. An empty frame // unpacks to an empty hash table. zhashx_t * zhashx_unpack (zframe_t *frame) { return zhashx_unpack_own (frame, NULL); } // -------------------------------------------------------------------------- // Make a copy of the list; items are duplicated if you set a duplicator // for the list, otherwise not. Copying a null reference returns a null // reference. Note that this method's behavior changed slightly for CZMQ // v3.x, as it does not set nor respect autofree. It does however let you // duplicate any hash table safely. The old behavior is in zhashx_dup_v2. zhashx_t * zhashx_dup (zhashx_t *self) { if (!self) return NULL; zhashx_t *copy = zhashx_new (); if (copy) { copy->destructor = self->destructor; copy->duplicator = self->duplicator; uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { if (zhashx_insert (copy, item->key, item->value)) { zhashx_destroy (©); break; } item = item->next; } } } return copy; } // -------------------------------------------------------------------------- // Set a user-defined deallocator for hash items; by default items are not // freed when the hash is destroyed. void zhashx_set_destructor (zhashx_t *self, zhashx_destructor_fn destructor) { assert (self); self->destructor = destructor; } // -------------------------------------------------------------------------- // Set a user-defined duplicator for hash items; by default items are not // copied when the hash is duplicated. void zhashx_set_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator) { assert (self); self->duplicator = duplicator; } // -------------------------------------------------------------------------- // Set a user-defined deallocator for keys; by default keys are // freed when the hash is destroyed by calling free(). void zhashx_set_key_destructor (zhashx_t *self, zhashx_destructor_fn destructor) { assert (self); self->key_destructor = destructor; } // -------------------------------------------------------------------------- // Set a user-defined duplicator for keys; by default keys are // duplicated by calling strdup(). void zhashx_set_key_duplicator (zhashx_t *self, zhashx_duplicator_fn duplicator) { assert (self); self->key_duplicator = duplicator; } // -------------------------------------------------------------------------- // Set a user-defined comparator for keys; by default keys are // compared using streq. void zhashx_set_key_comparator (zhashx_t *self, zhashx_comparator_fn comparator) { assert (self); assert (comparator != NULL); self->key_comparator = comparator; } // -------------------------------------------------------------------------- // Set a user-defined hash function for keys; by default keys are // hashed by a modified Bernstein hashing function. void zhashx_set_key_hasher (zhashx_t *self, zhashx_hash_fn hasher) { assert (self); self->hasher = hasher; } // -------------------------------------------------------------------------- // DEPRECATED by zhashx_dup // Make copy of hash table; if supplied table is null, returns null. // Does not copy items themselves. Rebuilds new table so may be slow on // very large tables. NOTE: only works with item values that are strings // since there's no other way to know how to duplicate the item value. zhashx_t * zhashx_dup_v2 (zhashx_t *self) { if (!self) return NULL; zhashx_t *copy = zhashx_new (); if (copy) { zhashx_set_destructor (copy, (zhashx_destructor_fn *) zstr_free); zhashx_set_duplicator (copy, (zhashx_duplicator_fn *) strdup); uint index; size_t limit = primes [self->prime_index]; for (index = 0; index < limit; index++) { item_t *item = self->items [index]; while (item) { if (zhashx_insert (copy, item->key, item->value)) { zhashx_destroy (©); break; } item = item->next; } } } return copy; } // -------------------------------------------------------------------------- // Runs selftest of class // #ifdef CZMQ_BUILD_DRAFT_API static char * s_test_serialize_int (const void *item) { int *int_item = (int *) item; char *str_item = (char *) zmalloc (sizeof (char) * 10); sprintf (str_item, "%d", *int_item); return str_item; } static void * s_test_deserialze_int (const char *str_item) { int *int_item = (int *) zmalloc (sizeof (int)); sscanf (str_item, "%d", int_item); return int_item; } static void s_test_destroy_int (void **item) { int *int_item = (int *) *item; freen (int_item); } #endif // CZMQ_BUILD_DRAFT_API void zhashx_test (bool verbose) { printf (" * zhashx: "); // @selftest zhashx_t *hash = zhashx_new (); assert (hash); assert (zhashx_size (hash) == 0); assert (zhashx_first (hash) == NULL); assert (zhashx_cursor (hash) == NULL); // Insert some items int rc; rc = zhashx_insert (hash, "DEADBEEF", "dead beef"); char *item = (char *) zhashx_first (hash); assert (streq ((char *) zhashx_cursor (hash), "DEADBEEF")); assert (streq (item, "dead beef")); assert (rc == 0); rc = zhashx_insert (hash, "ABADCAFE", "a bad cafe"); assert (rc == 0); rc = zhashx_insert (hash, "C0DEDBAD", "coded bad"); assert (rc == 0); rc = zhashx_insert (hash, "DEADF00D", "dead food"); assert (rc == 0); assert (zhashx_size (hash) == 4); // Look for existing items item = (char *) zhashx_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); item = (char *) zhashx_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); item = (char *) zhashx_lookup (hash, "C0DEDBAD"); assert (streq (item, "coded bad")); item = (char *) zhashx_lookup (hash, "DEADF00D"); assert (streq (item, "dead food")); // Look for non-existent items item = (char *) zhashx_lookup (hash, "foo"); assert (item == NULL); // Try to insert duplicate items rc = zhashx_insert (hash, "DEADBEEF", "foo"); assert (rc == -1); item = (char *) zhashx_lookup (hash, "DEADBEEF"); assert (streq (item, "dead beef")); // Some rename tests // Valid rename, key is now LIVEBEEF rc = zhashx_rename (hash, "DEADBEEF", "LIVEBEEF"); assert (rc == 0); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an unknown item to a non-existent key rc = zhashx_rename (hash, "WHATBEEF", "NONESUCH"); assert (rc == -1); // Trying to rename an unknown item to an existing key rc = zhashx_rename (hash, "WHATBEEF", "LIVEBEEF"); assert (rc == -1); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); // Trying to rename an existing item to another existing item rc = zhashx_rename (hash, "LIVEBEEF", "ABADCAFE"); assert (rc == -1); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (streq (item, "dead beef")); item = (char *) zhashx_lookup (hash, "ABADCAFE"); assert (streq (item, "a bad cafe")); // Test keys method zlistx_t *keys = zhashx_keys (hash); assert (zlistx_size (keys) == 4); zlistx_destroy (&keys); zlistx_t *values = zhashx_values(hash); assert (zlistx_size (values) == 4); zlistx_destroy (&values); // Test dup method zhashx_t *copy = zhashx_dup (hash); assert (zhashx_size (copy) == 4); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); // Test pack/unpack methods zframe_t *frame = zhashx_pack (hash); copy = zhashx_unpack (frame); zframe_destroy (&frame); assert (zhashx_size (copy) == 4); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); #ifdef CZMQ_BUILD_DRAFT_API // Test own pack/unpack methods zhashx_t *own_hash = zhashx_new (); zhashx_set_destructor (own_hash, s_test_destroy_int); assert (own_hash); int *val1 = (int *) zmalloc (sizeof (int)); int *val2 = (int *) zmalloc (sizeof (int)); *val1 = 25; *val2 = 100; zhashx_insert (own_hash, "val1", val1); zhashx_insert (own_hash, "val2", val2); frame = zhashx_pack_own (own_hash, s_test_serialize_int); copy = zhashx_unpack_own (frame, s_test_deserialze_int); zhashx_set_destructor (copy, s_test_destroy_int); zframe_destroy (&frame); assert (zhashx_size (copy) == 2); assert (*((int *) zhashx_lookup (copy, "val1")) == 25); assert (*((int *) zhashx_lookup (copy, "val2")) == 100); zhashx_destroy (©); zhashx_destroy (&own_hash); #endif // CZMQ_BUILD_DRAFT_API // Test save and load zhashx_comment (hash, "This is a test file"); zhashx_comment (hash, "Created by %s", "czmq_selftest"); zhashx_save (hash, ".cache"); copy = zhashx_new (); assert (copy); zhashx_load (copy, ".cache"); item = (char *) zhashx_lookup (copy, "LIVEBEEF"); assert (item); assert (streq (item, "dead beef")); zhashx_destroy (©); zsys_file_delete (".cache"); // Delete a item zhashx_delete (hash, "LIVEBEEF"); item = (char *) zhashx_lookup (hash, "LIVEBEEF"); assert (item == NULL); assert (zhashx_size (hash) == 3); // Check that the queue is robust against random usage struct { char name [100]; bool exists; } testset [200]; memset (testset, 0, sizeof (testset)); int testmax = 200, testnbr, iteration; srandom ((unsigned) time (NULL)); for (iteration = 0; iteration < 25000; iteration++) { testnbr = randof (testmax); assert (testnbr != testmax); assert (testnbr < testmax); if (testset [testnbr].exists) { item = (char *) zhashx_lookup (hash, testset [testnbr].name); assert (item); zhashx_delete (hash, testset [testnbr].name); testset [testnbr].exists = false; } else { sprintf (testset [testnbr].name, "%x-%x", rand (), rand ()); if (zhashx_insert (hash, testset [testnbr].name, "") == 0) testset [testnbr].exists = true; } } // Test 10K lookups for (iteration = 0; iteration < 10000; iteration++) item = (char *) zhashx_lookup (hash, "DEADBEEFABADCAFE"); // Destructor should be safe to call twice zhashx_destroy (&hash); zhashx_destroy (&hash); assert (hash == NULL); // Test randof() limits - should be within (0..testmax) // and randomness distribution - should not have (many) zero-counts // If there are - maybe the ZSYS_RANDOF_MAX is too big for this platform // Note: This test can take a while on systems with weak floating point HW testmax = 999; size_t rndcnt[999]; assert ((sizeof (rndcnt)/sizeof(rndcnt[0])) == testmax); memset (rndcnt, 0, sizeof (rndcnt)); for (iteration = 0; iteration < 10000000; iteration++) { testnbr = randof (testmax); assert (testnbr != testmax); assert (testnbr < testmax); assert (testnbr >= 0); rndcnt[testnbr]++; } int rndmisses = 0; for (iteration = 0; iteration < testmax; iteration++) { if (rndcnt[iteration] == 0) { zsys_warning("zhashx_test() : random distribution fault : got 0 hits for %d/%d", iteration, testmax); rndmisses++; } } // Too many misses are suspicious... we can lose half the entries // for each bit not used in the assumed ZSYS_RANDOF_MAX... assert ( (rndmisses < (testmax / 3 )) ); // Test destructor; automatically copies and frees string values hash = zhashx_new (); assert (hash); zhashx_set_destructor (hash, (zhashx_destructor_fn *) zstr_free); zhashx_set_duplicator (hash, (zhashx_duplicator_fn *) strdup); char value [255]; strcpy (value, "This is a string"); rc = zhashx_insert (hash, "key1", value); assert (rc == 0); strcpy (value, "Ring a ding ding"); rc = zhashx_insert (hash, "key2", value); assert (rc == 0); assert (streq ((char *) zhashx_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhashx_lookup (hash, "key2"), "Ring a ding ding")); zhashx_destroy (&hash); // Test purger and shrinker: no data should end up unreferenced in valgrind hash = zhashx_new (); assert (hash); zhashx_set_destructor (hash, (zhashx_destructor_fn *) zstr_free); zhashx_set_duplicator (hash, (zhashx_duplicator_fn *) strdup); char valuep [255]; strcpy (valuep, "This is a string"); rc = zhashx_insert (hash, "key1", valuep); assert (rc == 0); strcpy (valuep, "Ring a ding ding"); rc = zhashx_insert (hash, "key2", valuep); assert (rc == 0); strcpy (valuep, "Cartahena delenda est"); rc = zhashx_insert (hash, "key3", valuep); assert (rc == 0); strcpy (valuep, "So say we all!"); rc = zhashx_insert (hash, "key4", valuep); assert (rc == 0); assert (streq ((char *) zhashx_lookup (hash, "key1"), "This is a string")); assert (streq ((char *) zhashx_lookup (hash, "key2"), "Ring a ding ding")); assert (streq ((char *) zhashx_lookup (hash, "key3"), "Cartahena delenda est")); assert (streq ((char *) zhashx_lookup (hash, "key4"), "So say we all!")); zhashx_purge (hash); zhashx_destroy (&hash); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zhash_primes.inc0000664000372000037200000002440013222211156017341 0ustar00travistravis00000000000000/* ========================================================================= zhash_primes.h - 5 largest primes less than 2^n for n = 4...63 Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef __ZHASH_PRIMES_H_INCLUDED__ #define __ZHASH_PRIMES_H_INCLUDED__ #ifdef _MSC_VER # define PORTABLE_LLU(number) number##ULL #else # define PORTABLE_LLU(number) number##LLU #endif static size_t primes [] = { PORTABLE_LLU(3), PORTABLE_LLU(5), PORTABLE_LLU(7), PORTABLE_LLU(11), PORTABLE_LLU(13), // 2^4 PORTABLE_LLU(17), PORTABLE_LLU(19), PORTABLE_LLU(23), PORTABLE_LLU(29), PORTABLE_LLU(31), // 2^5 PORTABLE_LLU(43), PORTABLE_LLU(47), PORTABLE_LLU(53), PORTABLE_LLU(59), PORTABLE_LLU(61), // 2^6 PORTABLE_LLU(103), PORTABLE_LLU(107), PORTABLE_LLU(109), PORTABLE_LLU(113), PORTABLE_LLU(127), // 2^7 PORTABLE_LLU(229), PORTABLE_LLU(233), PORTABLE_LLU(239), PORTABLE_LLU(241), PORTABLE_LLU(251), // 2^8 PORTABLE_LLU(487), PORTABLE_LLU(491), PORTABLE_LLU(499), PORTABLE_LLU(503), PORTABLE_LLU(509), // 2^9 PORTABLE_LLU(997), PORTABLE_LLU(1009), PORTABLE_LLU(1013), PORTABLE_LLU(1019), PORTABLE_LLU(1021), // 2^10 PORTABLE_LLU(2011), PORTABLE_LLU(2017), PORTABLE_LLU(2027), PORTABLE_LLU(2029), PORTABLE_LLU(2039), // 2^11 PORTABLE_LLU(4057), PORTABLE_LLU(4073), PORTABLE_LLU(4079), PORTABLE_LLU(4091), PORTABLE_LLU(4093), // 2^12 PORTABLE_LLU(8161), PORTABLE_LLU(8167), PORTABLE_LLU(8171), PORTABLE_LLU(8179), PORTABLE_LLU(8191), // 2^13 PORTABLE_LLU(16349), PORTABLE_LLU(16361), PORTABLE_LLU(16363), PORTABLE_LLU(16369), PORTABLE_LLU(16381), // 2^14 PORTABLE_LLU(32707), PORTABLE_LLU(32713), PORTABLE_LLU(32717), PORTABLE_LLU(32719), PORTABLE_LLU(32749), // 2^15 PORTABLE_LLU(65449), PORTABLE_LLU(65479), PORTABLE_LLU(65497), PORTABLE_LLU(65519), PORTABLE_LLU(65521), // 2^16 PORTABLE_LLU(131023), PORTABLE_LLU(131041), PORTABLE_LLU(131059), PORTABLE_LLU(131063), PORTABLE_LLU(131071), // 2^17 PORTABLE_LLU(262111), PORTABLE_LLU(262121), PORTABLE_LLU(262127), PORTABLE_LLU(262133), PORTABLE_LLU(262139), // 2^18 PORTABLE_LLU(524243), PORTABLE_LLU(524257), PORTABLE_LLU(524261), PORTABLE_LLU(524269), PORTABLE_LLU(524287), // 2^19 PORTABLE_LLU(1048517), PORTABLE_LLU(1048549), PORTABLE_LLU(1048559), PORTABLE_LLU(1048571), PORTABLE_LLU(1048573), // 2^20 PORTABLE_LLU(2097091), PORTABLE_LLU(2097097), PORTABLE_LLU(2097131), PORTABLE_LLU(2097133), PORTABLE_LLU(2097143), // 2^21 PORTABLE_LLU(4194247), PORTABLE_LLU(4194271), PORTABLE_LLU(4194277), PORTABLE_LLU(4194287), PORTABLE_LLU(4194301), // 2^22 PORTABLE_LLU(8388547), PORTABLE_LLU(8388571), PORTABLE_LLU(8388581), PORTABLE_LLU(8388587), PORTABLE_LLU(8388593), // 2^23 PORTABLE_LLU(16777141), PORTABLE_LLU(16777153), PORTABLE_LLU(16777183), PORTABLE_LLU(16777199), PORTABLE_LLU(16777213), // 2^24 PORTABLE_LLU(33554341), PORTABLE_LLU(33554347), PORTABLE_LLU(33554371), PORTABLE_LLU(33554383), PORTABLE_LLU(33554393), // 2^25 PORTABLE_LLU(67108763), PORTABLE_LLU(67108777), PORTABLE_LLU(67108819), PORTABLE_LLU(67108837), PORTABLE_LLU(67108859), // 2^26 PORTABLE_LLU(134217593), PORTABLE_LLU(134217613), PORTABLE_LLU(134217617), PORTABLE_LLU(134217649), PORTABLE_LLU(134217689), // 2^27 PORTABLE_LLU(268435331), PORTABLE_LLU(268435337), PORTABLE_LLU(268435361), PORTABLE_LLU(268435367), PORTABLE_LLU(268435399), // 2^28 PORTABLE_LLU(536870839), PORTABLE_LLU(536870849), PORTABLE_LLU(536870869), PORTABLE_LLU(536870879), PORTABLE_LLU(536870909), // 2^29 PORTABLE_LLU(1073741719), PORTABLE_LLU(1073741723), PORTABLE_LLU(1073741741), PORTABLE_LLU(1073741783), PORTABLE_LLU(1073741789), // 2^30 PORTABLE_LLU(2147483563), PORTABLE_LLU(2147483579), PORTABLE_LLU(2147483587), PORTABLE_LLU(2147483629), PORTABLE_LLU(2147483647), // 2^31 PORTABLE_LLU(4294967197), PORTABLE_LLU(4294967231), PORTABLE_LLU(4294967279), PORTABLE_LLU(4294967291), PORTABLE_LLU(4294967295), // 2^32 #if __WORDSIZE == 64 PORTABLE_LLU(8589934581), PORTABLE_LLU(8589934585), PORTABLE_LLU(8589934587), PORTABLE_LLU(8589934589), PORTABLE_LLU(8589934591), // 2^33 PORTABLE_LLU(17179869175), PORTABLE_LLU(17179869177), PORTABLE_LLU(17179869179), PORTABLE_LLU(17179869181), PORTABLE_LLU(17179869183), // 2^34 PORTABLE_LLU(34359738359), PORTABLE_LLU(34359738361), PORTABLE_LLU(34359738363), PORTABLE_LLU(34359738365), PORTABLE_LLU(34359738367), // 2^35 PORTABLE_LLU(68719476725), PORTABLE_LLU(68719476727), PORTABLE_LLU(68719476729), PORTABLE_LLU(68719476733), PORTABLE_LLU(68719476735), // 2^36 PORTABLE_LLU(137438953463), PORTABLE_LLU(137438953465), PORTABLE_LLU(137438953467), PORTABLE_LLU(137438953469), PORTABLE_LLU(137438953471), // 2^37 PORTABLE_LLU(274877906935), PORTABLE_LLU(274877906937), PORTABLE_LLU(274877906939), PORTABLE_LLU(274877906941), PORTABLE_LLU(274877906943), // 2^38 PORTABLE_LLU(549755813877), PORTABLE_LLU(549755813879), PORTABLE_LLU(549755813883), PORTABLE_LLU(549755813885), PORTABLE_LLU(549755813887), // 2^39 PORTABLE_LLU(1099511627767), PORTABLE_LLU(1099511627769), PORTABLE_LLU(1099511627771), PORTABLE_LLU(1099511627773), PORTABLE_LLU(1099511627775), // 2^40 PORTABLE_LLU(2199023255543), PORTABLE_LLU(2199023255545), PORTABLE_LLU(2199023255547), PORTABLE_LLU(2199023255549), PORTABLE_LLU(2199023255551), // 2^41 PORTABLE_LLU(4398046511095), PORTABLE_LLU(4398046511097), PORTABLE_LLU(4398046511099), PORTABLE_LLU(4398046511101), PORTABLE_LLU(4398046511103), // 2^42 PORTABLE_LLU(8796093022199), PORTABLE_LLU(8796093022201), PORTABLE_LLU(8796093022203), PORTABLE_LLU(8796093022205), PORTABLE_LLU(8796093022207), // 2^43 PORTABLE_LLU(17592186044407), PORTABLE_LLU(17592186044409), PORTABLE_LLU(17592186044411), PORTABLE_LLU(17592186044413), PORTABLE_LLU(17592186044415), // 2^44 PORTABLE_LLU(35184372088823), PORTABLE_LLU(35184372088825), PORTABLE_LLU(35184372088827), PORTABLE_LLU(35184372088829), PORTABLE_LLU(35184372088831), // 2^45 PORTABLE_LLU(70368744177655), PORTABLE_LLU(70368744177657), PORTABLE_LLU(70368744177659), PORTABLE_LLU(70368744177661), PORTABLE_LLU(70368744177663), // 2^46 PORTABLE_LLU(140737488355319), PORTABLE_LLU(140737488355321), PORTABLE_LLU(140737488355323), PORTABLE_LLU(140737488355325), PORTABLE_LLU(140737488355327), // 2^47 PORTABLE_LLU(281474976710647), PORTABLE_LLU(281474976710649), PORTABLE_LLU(281474976710651), PORTABLE_LLU(281474976710653), PORTABLE_LLU(281474976710655), // 2^48 PORTABLE_LLU(562949953421303), PORTABLE_LLU(562949953421305), PORTABLE_LLU(562949953421307), PORTABLE_LLU(562949953421309), PORTABLE_LLU(562949953421311), // 2^49 PORTABLE_LLU(1125899906842615), PORTABLE_LLU(1125899906842617), PORTABLE_LLU(1125899906842619), PORTABLE_LLU(1125899906842621), PORTABLE_LLU(1125899906842623), // 2^50 PORTABLE_LLU(2251799813685239), PORTABLE_LLU(2251799813685241), PORTABLE_LLU(2251799813685243), PORTABLE_LLU(2251799813685245), PORTABLE_LLU(2251799813685247), // 2^51 PORTABLE_LLU(4503599627370487), PORTABLE_LLU(4503599627370489), PORTABLE_LLU(4503599627370491), PORTABLE_LLU(4503599627370493), PORTABLE_LLU(4503599627370495), // 2^52 PORTABLE_LLU(9007199254740983), PORTABLE_LLU(9007199254740985), PORTABLE_LLU(9007199254740987), PORTABLE_LLU(9007199254740989), PORTABLE_LLU(9007199254740991), // 2^53 PORTABLE_LLU(18014398509481975), PORTABLE_LLU(18014398509481977), PORTABLE_LLU(18014398509481979), PORTABLE_LLU(18014398509481981), PORTABLE_LLU(18014398509481983), // 2^54 PORTABLE_LLU(36028797018963959), PORTABLE_LLU(36028797018963961), PORTABLE_LLU(36028797018963963), PORTABLE_LLU(36028797018963965), PORTABLE_LLU(36028797018963967), // 2^55 PORTABLE_LLU(72057594037927925), PORTABLE_LLU(72057594037927927), PORTABLE_LLU(72057594037927929), PORTABLE_LLU(72057594037927933), PORTABLE_LLU(72057594037927935), // 2^56 PORTABLE_LLU(144115188075855863), PORTABLE_LLU(144115188075855865), PORTABLE_LLU(144115188075855867), PORTABLE_LLU(144115188075855869), PORTABLE_LLU(144115188075855871), // 2^57 PORTABLE_LLU(288230376151711735), PORTABLE_LLU(288230376151711737), PORTABLE_LLU(288230376151711739), PORTABLE_LLU(288230376151711741), PORTABLE_LLU(288230376151711743), // 2^58 PORTABLE_LLU(576460752303423479), PORTABLE_LLU(576460752303423481), PORTABLE_LLU(576460752303423483), PORTABLE_LLU(576460752303423485), PORTABLE_LLU(576460752303423487), // 2^59 PORTABLE_LLU(1152921504606846967), PORTABLE_LLU(1152921504606846969), PORTABLE_LLU(1152921504606846971), PORTABLE_LLU(1152921504606846973), PORTABLE_LLU(1152921504606846975), // 2^60 PORTABLE_LLU(2305843009213693941), PORTABLE_LLU(2305843009213693943), PORTABLE_LLU(2305843009213693945), PORTABLE_LLU(2305843009213693947), PORTABLE_LLU(2305843009213693949), // 2^61 PORTABLE_LLU(4611686018427387895), PORTABLE_LLU(4611686018427387897), PORTABLE_LLU(4611686018427387899), PORTABLE_LLU(4611686018427387901), PORTABLE_LLU(4611686018427387903), // 2^62 PORTABLE_LLU(9223372036854775799), PORTABLE_LLU(9223372036854775801), PORTABLE_LLU(9223372036854775803), PORTABLE_LLU(9223372036854775805), PORTABLE_LLU(9223372036854775807) // 2^63 #endif }; #endif czmq-4.1.0/src/zcertstore.c0000664000372000037200000003143513222211156016530 0ustar00travistravis00000000000000/* ========================================================================= zcertstore - work with CURVE security certificate stores Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header To authenticate new clients using the ZeroMQ CURVE security mechanism, we have to check that the client's public key matches a key we know and accept. There are numerous ways to store accepted client public keys. The mechanism CZMQ implements is "certificates" (plain text files) held in a "certificate store" (a disk directory). This class works with such certificate stores, and lets you easily load them from disk, and check if a given client public key is known or not. The zcert class does the work of managing a single certificate. @discuss The certificate store can be memory-only, in which case you can load it yourself by inserting certificate objects one by one, or it can be loaded from disk, in which case you can add, modify, or remove certificates on disk at any time, and the store will detect such changes and refresh itself automatically. In most applications you won't use this class directly but through the zauth class, which provides a high-level API for authentication (and manages certificate stores for you). To actually create certificates on disk, use the zcert class in code, or the tools/zmakecert.c command line tool, or any text editor. The format of a certificate file is defined in the zcert man page. @end */ #include "czmq_classes.h" // -------------------------------------------------------------------------- // Disk loader typedef struct _disk_loader_state { char *location; // Directory location // This isn't sufficient; we should check the hash of all files // or else use a trigger like inotify on Linux. time_t modified; // Modified time of directory size_t count; // Number of certificates size_t cursize; // Total size of certificates } disk_loader_state; // -------------------------------------------------------------------------- // Zcertstore struct _zcertstore_t { zcertstore_loader *loader; // Certificate loader fn zcertstore_destructor *destructor; // Certificate loader state destructor void *state; // Certificate loader state data zhashx_t *certs; // Loaded certificates }; // -------------------------------------------------------------------------- // Disk loader static void s_disk_loader (zcertstore_t *self); static void s_disk_loader (zcertstore_t *certstore) { disk_loader_state *state = (disk_loader_state *)certstore->state; zdir_t *dir = zdir_new (state->location, NULL); if (dir && (state->modified != zdir_modified (dir) || state->count != zdir_count (dir) || state->cursize != (size_t) zdir_cursize (dir))) { zhashx_purge (certstore->certs); // Load all certificates including those in subdirectories zfile_t **filelist = zdir_flatten (dir); assert (filelist); zrex_t *rex = zrex_new ("_secret$"); assert (rex); uint index; for (index = 0;; index++) { zfile_t *file = filelist [index]; if (!file) break; // End of list if (zfile_is_regular (file) && !zrex_matches (rex, zfile_filename (file, NULL))) { zcert_t *cert = zcert_load (zfile_filename (file, NULL)); if (cert) zcertstore_insert (certstore, &cert); } } zdir_flatten_free (&filelist); state->modified = zdir_modified (dir); state->count = zdir_count (dir); state->cursize = zdir_cursize (dir); zrex_destroy (&rex); } zdir_destroy (&dir); } // -------------------------------------------------------------------------- // Disk loader destructor static void s_disk_loader_state_destroy (void **self_p) { assert (self_p); if (*self_p) { disk_loader_state *self = (disk_loader_state *)*self_p; freen (self->location); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Constructor // // Create a new certificate store, loading and indexing all certificates from // the loader callback. The default loader is the directory loader, which // gathers certificates from a local system folder. Specifying the location // argument will setup the directory loader for this zcertstore instance. The // directory itself may be absent, and created later, or modified at any time. // The certificate store is automatically refreshed on any zcertstore_lookup() // call. If the location is specified as NULL, creates a pure-memory store, // which you can work with by inserting certificates at runtime. zcertstore_t * zcertstore_new (const char *location) { zcertstore_t *self = (zcertstore_t *) zmalloc (sizeof (zcertstore_t)); assert (self); self->certs = zhashx_new (); assert (self->certs); zhashx_set_destructor (self->certs, (czmq_destructor *) zcert_destroy); if (location) { disk_loader_state *state = (disk_loader_state *) zmalloc (sizeof (disk_loader_state)); state->location = strdup (location); assert (state->location); state->modified = 0; state->count = 0; state->cursize = 0; zcertstore_set_loader (self, s_disk_loader, s_disk_loader_state_destroy, (void *)state); } return self; } // -------------------------------------------------------------------------- // Destructor // // Destroy a certificate store object in memory. Does not affect anything // stored on disk. void zcertstore_destroy (zcertstore_t **self_p) { assert (self_p); if (*self_p) { zcertstore_t *self = *self_p; zhashx_destroy (&self->certs); if (self->destructor) self->destructor (&self->state); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Override the default disk loader with a custom loader fn. void zcertstore_set_loader (zcertstore_t *self, zcertstore_loader loader, zcertstore_destructor destructor, void *state) { if (self->destructor && self->state) self->destructor (&self->state); self->loader = loader; self->destructor = destructor; self->state = state; self->loader (self); } // -------------------------------------------------------------------------- // Look up certificate by public key, returns zcert_t object if found, // else returns NULL. The public key is provided in Z85 text format. zcert_t * zcertstore_lookup (zcertstore_t *self, const char *public_key) { if (self->loader) self->loader (self); return (zcert_t *) zhashx_lookup (self->certs, public_key); } // -------------------------------------------------------------------------- // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. void zcertstore_insert (zcertstore_t *self, zcert_t **cert_p) { int rc = zhashx_insert (self->certs, zcert_public_txt (*cert_p), *cert_p); assert (rc == 0); *cert_p = NULL; // We own this now } // -------------------------------------------------------------------------- // Empty certificate hashtable // This wrapper exists to be friendly to bindings, which don't usually have // access to struct internals (e.g. self->certs). void zcertstore_empty (zcertstore_t *self) { zhashx_purge (self->certs); } // -------------------------------------------------------------------------- // Return a list of all the certificates in the store zlistx_t * zcertstore_certs (zcertstore_t *self) { if (self->loader) self->loader (self); zlistx_t *certs = zhashx_values(self->certs); zlistx_set_destructor (certs, NULL); return certs; } // -------------------------------------------------------------------------- // Print list of certificates in store to stdout void zcertstore_print (zcertstore_t *self) { if (self->loader) zsys_info ("zcertstore: certificates in store"); else zsys_info ("zcertstore: certificates in memory"); zcert_t *cert = (zcert_t *) zhashx_first (self->certs); while (cert) { zcert_print (cert); cert = (zcert_t *) zhashx_next (self->certs); } } // -------------------------------------------------------------------------- // Selftest // Trivial example state for testing typedef struct _test_loader_state { int index; } test_loader_state; static void s_test_loader (zcertstore_t *certstore) { zcertstore_empty (certstore); byte public_key [32] = { 31, 133, 154, 36, 47, 67, 155, 5, 63, 1, 155, 230, 78, 191, 156, 199, 94, 125, 157, 168, 109, 69, 19, 241, 44, 29, 154, 216, 59, 219, 155, 185 }; byte secret_key [32] = { 31, 133, 154, 36, 47, 67, 155, 5, 63, 1, 155, 230, 78, 191, 156, 199, 94, 125, 157, 168, 109, 69, 19, 241, 44, 29, 154, 216, 59, 219, 155, 185 }; zcert_t *cert = zcert_new_from (public_key, secret_key); zcertstore_insert (certstore, &cert); test_loader_state *state = (test_loader_state *)certstore->state; state->index++; } static void s_test_destructor (void **self_p) { assert (self_p); if (*self_p) { test_loader_state *self = (test_loader_state *)*self_p; freen (self); *self_p = NULL; } } void zcertstore_test (bool verbose) { printf (" * zcertstore: "); if (verbose) printf ("\n"); // @selftest const char *SELFTEST_DIR_RW = "src/selftest-rw"; const char *testbasedir = ".test_zcertstore"; const char *testfile = "mycert.txt"; char *basedirpath = NULL; // subdir in a test, under SELFTEST_DIR_RW char *filepath = NULL; // pathname to testfile in a test, in dirpath basedirpath = zsys_sprintf ("%s/%s", SELFTEST_DIR_RW, testbasedir); assert (basedirpath); filepath = zsys_sprintf ("%s/%s", basedirpath, testfile); assert (filepath); // Make sure old aborted tests do not hinder us zdir_t *dir = zdir_new (basedirpath, NULL); if (dir) { zdir_remove (dir, true); zdir_destroy (&dir); } zsys_file_delete (filepath); zsys_dir_delete (basedirpath); // Create temporary directory for test files zsys_dir_create (basedirpath); // Load certificate store from disk; it will be empty zcertstore_t *certstore = zcertstore_new (basedirpath); assert (certstore); // Create a single new certificate and save to disk zcert_t *cert = zcert_new (); assert (cert); char *client_key = strdup (zcert_public_txt (cert)); assert (client_key); zcert_set_meta (cert, "name", "John Doe"); zcert_save (cert, filepath); zcert_destroy (&cert); // Check that certificate store refreshes as expected cert = zcertstore_lookup (certstore, client_key); assert (cert); assert (streq (zcert_meta (cert, "name"), "John Doe")); #ifdef CZMQ_BUILD_DRAFT_API // Iterate through certs zlistx_t *certs = zcertstore_certs(certstore); cert = (zcert_t *) zlistx_first(certs); int cert_count = 0; while (cert) { assert (streq (zcert_meta (cert, "name"), "John Doe")); cert = (zcert_t *) zlistx_next(certs); cert_count++; } assert(cert_count==1); zlistx_destroy(&certs); #endif // Test custom loader test_loader_state *state = (test_loader_state *) zmalloc (sizeof (test_loader_state)); state->index = 0; zcertstore_set_loader (certstore, s_test_loader, s_test_destructor, (void *)state); #if (ZMQ_VERSION_MAJOR >= 4) cert = zcertstore_lookup (certstore, client_key); assert (cert == NULL); cert = zcertstore_lookup (certstore, "abcdefghijklmnopqrstuvwxyzabcdefghijklmn"); assert (cert); #endif freen (client_key); if (verbose) zcertstore_print (certstore); zcertstore_destroy (&certstore); // Delete all test files dir = zdir_new (basedirpath, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); zstr_free (&basedirpath); zstr_free (&filepath); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zproxy.c0000664000372000037200000006232413222211156015700 0ustar00travistravis00000000000000/* ========================================================================= zproxy - run a steerable proxy in the background Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header A zproxy actor switches messages between a frontend and a backend socket. It acts much like the zmq_proxy_steerable method, though it makes benefit of CZMQ's facilities, to be somewhat simpler to set-up. @discuss This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). @end */ #include "czmq_classes.h" typedef enum proxy_socket { NONE = -1, FRONTEND, BACKEND, SOCKETS } proxy_socket; #define AUTH_NONE 0 #define AUTH_PLAIN 1 #define AUTH_CURVE 2 // -------------------------------------------------------------------------- // The self_t structure holds the state for one actor instance typedef struct { zsock_t *pipe; // Actor command pipe zpoller_t *poller; // Socket poller zsock_t *frontend; // Frontend socket zsock_t *backend; // Backend socket zsock_t *capture; // Capture socket int auth_type [SOCKETS]; // Auth type for sockets char *domain [SOCKETS]; // Auth domains for sockets char *public_key [SOCKETS]; // Public keys for sockets char *secret_key [SOCKETS]; // Secret keys for sockets bool terminated; // Did caller ask us to quit? bool verbose; // Verbose logging enabled? } self_t; static self_t * s_self_new (zsock_t *pipe) { self_t *self = (self_t *) zmalloc (sizeof (self_t)); assert (self); self->pipe = pipe; self->poller = zpoller_new (self->pipe, NULL); assert (self->poller); return self; } static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; zpoller_destroy (&self->poller); zsock_destroy (&self->frontend); zsock_destroy (&self->backend); zsock_destroy (&self->capture); int index; for (index = 0; index < SOCKETS; index++) { zstr_free (&self->domain [index]); zstr_free (&self->public_key [index]); zstr_free (&self->secret_key [index]); } freen (self); *self_p = NULL; } } static zsock_t * s_self_create_socket (self_t *self, char *type_name, char *endpoints, proxy_socket selected_socket) { // This array matches ZMQ_XXX type definitions assert (ZMQ_PAIR == 0); char *type_names [] = { "PAIR", "PUB", "SUB", "REQ", "REP", "DEALER", "ROUTER", "PULL", "PUSH", "XPUB", "XSUB", type_name }; // We always match type at least at end of table int index; for (index = 0; strneq (type_name, type_names [index]); index++) ; if (index > ZMQ_XSUB) { zsys_error ("zproxy: invalid socket type '%s'", type_name); return NULL; } zsock_t *sock = zsock_new (index); if (sock) { #if (ZMQ_VERSION_MAJOR == 4) if (self->domain [selected_socket]) { // Apply authentication domain zsock_set_zap_domain (sock, self->domain [selected_socket]); } if (self->auth_type [selected_socket] == AUTH_PLAIN) { // Enable plain authentication zsock_set_plain_server (sock, 1); } else if (self->auth_type [selected_socket] == AUTH_CURVE) { // Apply certificate keys char *public_key = self->public_key [selected_socket]; assert (public_key); char *secret_key = self->secret_key [selected_socket]; assert (secret_key); zsock_set_curve_publickey (sock, public_key); zsock_set_curve_secretkey (sock, secret_key); // Enable curve authentication zsock_set_curve_server (sock, 1); } #endif if (zsock_attach (sock, endpoints, true)) { zsys_error ("zproxy: invalid endpoints '%s'", endpoints); zsock_destroy (&sock); } } return sock; } static const char * s_self_selected_socket_name (proxy_socket selected_socket) { switch (selected_socket) { case FRONTEND: return "FRONTEND"; case BACKEND: return "BACKEND"; default: return "UNDEFINED"; } } static const char * s_self_selected_socket_auth (int auth_type) { switch (auth_type) { case AUTH_PLAIN: return "PLAIN"; case AUTH_CURVE: return "CURVE"; default: return "NONE"; } } static proxy_socket s_self_selected_socket (zmsg_t *request) { char *socket_name = zmsg_popstr (request); assert (socket_name); proxy_socket socket = NONE; if (streq (socket_name, "FRONTEND")) socket = FRONTEND; else if (streq (socket_name, "BACKEND")) socket = BACKEND; else { zsys_error ("zproxy: invalid proxy socket selection: %s", socket_name); assert (false); } zstr_free (&socket_name); return socket; } static void s_self_configure (self_t *self, zsock_t **sock_p, zmsg_t *request, proxy_socket selected_socket) { char *type_name = zmsg_popstr (request); assert (type_name); char *endpoints = zmsg_popstr (request); assert (endpoints); if (self->verbose) zsys_info ("zproxy: - %s type=%s attach=%s authentication=%s", s_self_selected_socket_name (selected_socket), type_name, endpoints, s_self_selected_socket_auth (self->auth_type [selected_socket])); assert (*sock_p == NULL); *sock_p = s_self_create_socket (self, type_name, endpoints, selected_socket); assert (*sock_p); zstr_free (&type_name); zstr_free (&endpoints); } static void s_self_add_to_poller_when_configured (self_t *self) { if (self->frontend && self->backend) { zpoller_add(self->poller, self->frontend); zpoller_add(self->poller, self->backend); } } // -------------------------------------------------------------------------- // Handle a command from calling application static int s_self_handle_pipe (self_t *self) { // Get the whole message off the pipe in one go zmsg_t *request = zmsg_recv (self->pipe); if (!request) return -1; // Interrupted char *command = zmsg_popstr (request); assert (command); if (self->verbose) zsys_info ("zproxy: API command=%s", command); if (streq (command, "FRONTEND")) { s_self_configure (self, &self->frontend, request, FRONTEND); s_self_add_to_poller_when_configured (self); zsock_signal (self->pipe, 0); } else if (streq (command, "BACKEND")) { s_self_configure (self, &self->backend, request, BACKEND); s_self_add_to_poller_when_configured (self); zsock_signal (self->pipe, 0); } else if (streq (command, "CAPTURE")) { self->capture = zsock_new (ZMQ_PUSH); assert (self->capture); char *endpoint = zmsg_popstr (request); assert (endpoint); int rc = zsock_connect (self->capture, "%s", endpoint); assert (rc == 0); zstr_free (&endpoint); zsock_signal (self->pipe, 0); } else if (streq (command, "PAUSE")) { zpoller_destroy (&self->poller); self->poller = zpoller_new (self->pipe, NULL); assert (self->poller); zsock_signal (self->pipe, 0); } else if (streq (command, "RESUME")) { zpoller_destroy (&self->poller); self->poller = zpoller_new (self->pipe, self->frontend, self->backend, NULL); assert (self->poller); zsock_signal (self->pipe, 0); } else if (streq (command, "VERBOSE")) { self->verbose = true; zsock_signal (self->pipe, 0); } else if (streq (command, "DOMAIN")) { proxy_socket selected_socket = s_self_selected_socket (request); char *domain = zmsg_popstr (request); assert (domain); zstr_free (&self->domain [selected_socket]); self->domain [selected_socket] = domain; zsock_signal (self->pipe, 0); } else if (streq (command, "PLAIN")) { proxy_socket selected_socket = s_self_selected_socket (request); self->auth_type [selected_socket] = AUTH_PLAIN; zsock_signal (self->pipe, 0); } else if (streq (command, "CURVE")) { proxy_socket selected_socket = s_self_selected_socket (request); self->auth_type [selected_socket] = AUTH_CURVE; char *public_key = zmsg_popstr (request); assert (public_key); char *secret_key = zmsg_popstr (request); assert (secret_key); zstr_free (&self->public_key [selected_socket]); zstr_free (&self->secret_key [selected_socket]); self->public_key [selected_socket] = public_key; self->secret_key [selected_socket] = secret_key; zsock_signal (self->pipe, 0); } else if (streq (command, "$TERM")) self->terminated = true; else { zsys_error ("zproxy: - invalid command: %s", command); assert (false); } zstr_free (&command); zmsg_destroy (&request); return 0; } // -------------------------------------------------------------------------- // Switch messages from an input socket to an output socket until there are // no messages left waiting. We use this loop rather than zmq_poll, to reduce // the cost of polling, which is non-trivial on some boxes (OS/X, mainly). static void s_self_switch (self_t *self, zsock_t *input, zsock_t *output) { // We use the low-level libzmq API for best performance void *zmq_input = zsock_resolve (input); void *zmq_output = zsock_resolve (output); void *zmq_capture = self->capture? zsock_resolve (self->capture): NULL; zmq_msg_t msg; zmq_msg_init (&msg); while (true) { if (zmq_recvmsg (zmq_input, &msg, ZMQ_DONTWAIT) == -1) break; // Presumably EAGAIN int send_flags = zsock_rcvmore (input)? ZMQ_SNDMORE: 0; if (zmq_capture) { zmq_msg_t dup; zmq_msg_init (&dup); zmq_msg_copy (&dup, &msg); if (zmq_sendmsg (zmq_capture, &dup, send_flags) == -1) zmq_msg_close (&dup); } if (zmq_sendmsg (zmq_output, &msg, send_flags) == -1) { zmq_msg_close (&msg); break; } } } // -------------------------------------------------------------------------- // zproxy() implements the zproxy actor interface void zproxy (zsock_t *pipe, void *unused) { self_t *self = s_self_new (pipe); assert (self); // Signal successful initialization zsock_signal (pipe, 0); while (!self->terminated) { zsock_t *which = (zsock_t *) zpoller_wait (self->poller, -1); if (zpoller_terminated (self->poller)) break; // Interrupted else if (which == self->pipe) s_self_handle_pipe (self); else if (which == self->frontend) s_self_switch (self, self->frontend, self->backend); else if (which == self->backend) s_self_switch (self, self->backend, self->frontend); } s_self_destroy (&self); } // -------------------------------------------------------------------------- // Selftest #if (ZMQ_VERSION_MAJOR == 4) #define LOCALENDPOINT "tcp://127.0.0.1:%d" static void s_create_test_sockets (zactor_t **proxy, zsock_t **faucet, zsock_t **sink, bool verbose) { zsock_destroy (faucet); zsock_destroy (sink); zactor_destroy (proxy); *faucet = zsock_new (ZMQ_PUSH); assert (*faucet); *sink = zsock_new (ZMQ_PULL); assert (*sink); *proxy = zactor_new (zproxy, NULL); assert (*proxy); if (verbose) { zstr_sendx (*proxy, "VERBOSE", NULL); zsock_wait (*proxy); } } static int s_get_available_port (void) { int port_nbr = -1; int attempts = 0; // Choosing a random port for better results in case multiple tests are running // in parallel on the same machine, such as during CI runs while (port_nbr == -1 && attempts++ < 10) { port_nbr = 49152 + randof (16383); zsock_t *server = zsock_new (ZMQ_PUSH); assert (server); port_nbr = zsock_bind (server, LOCALENDPOINT, port_nbr); zsock_destroy (&server); } if (port_nbr < 0) { zsys_error ("zproxy: failed to find an available port number"); assert (false); } return port_nbr; } // Checks whether client can connect to server // expect_success is used to synchronise the connect as sleeps are unreliable static bool s_can_connect (zactor_t **proxy, zsock_t **faucet, zsock_t **sink, const char *frontend, const char *backend, bool verbose, bool expect_success) { assert (*faucet); assert (*sink); assert (frontend); assert (backend); int rc = zsock_connect (*faucet, "%s", frontend); assert (rc == 0); rc = zsock_connect (*sink, "%s", backend); assert (rc == 0); if (expect_success) { zstr_send (*faucet, "Hello, World"); char *hello = zstr_recv (*sink); assert (hello); assert (streq (hello, "Hello, World")); zstr_free (&hello); } zframe_t *frame = zframe_from ("Hello, World"); rc = zframe_send (&frame, *faucet, expect_success ? 0 : ZFRAME_DONTWAIT); assert (rc == 0 || !expect_success); if (!expect_success && rc == -1) zframe_destroy (&frame); zpoller_t *poller = zpoller_new (*sink, NULL); assert (poller); bool success = (zpoller_wait (poller, 400) == *sink); zpoller_destroy (&poller); s_create_test_sockets (proxy, faucet, sink, verbose); return success; } static void s_bind_test_sockets (zactor_t *proxy, char **frontend, char **backend) { zstr_free (frontend); zstr_free (backend); assert (proxy); srandom ((uint) (time (NULL) ^ *(int *) proxy)); *frontend = zsys_sprintf (LOCALENDPOINT, s_get_available_port ()); *backend = zsys_sprintf (LOCALENDPOINT, s_get_available_port ()); // Wait a moment to make sure ports have time to unbind... zclock_sleep(200); zstr_sendx (proxy, "FRONTEND", "PULL", *frontend, NULL); zsock_wait (proxy); zstr_sendx (proxy, "BACKEND", "PUSH", *backend, NULL); zsock_wait (proxy); } #endif void zproxy_test (bool verbose) { printf (" * zproxy: "); if (verbose) printf ("\n"); // @selftest // Create and configure our proxy zactor_t *proxy = zactor_new (zproxy, NULL); assert (proxy); if (verbose) { zstr_sendx (proxy, "VERBOSE", NULL); zsock_wait (proxy); } zstr_sendx (proxy, "FRONTEND", "PULL", "inproc://frontend", NULL); zsock_wait (proxy); zstr_sendx (proxy, "BACKEND", "PUSH", "inproc://backend", NULL); zsock_wait (proxy); // Connect application sockets to proxy zsock_t *faucet = zsock_new_push (">inproc://frontend"); assert (faucet); zsock_t *sink = zsock_new_pull (">inproc://backend"); assert (sink); // Send some messages and check they arrived char *hello, *world; zstr_sendx (faucet, "Hello", "World", NULL); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); // Test pause/resume functionality zstr_sendx (proxy, "PAUSE", NULL); zsock_wait (proxy); zstr_sendx (faucet, "Hello", "World", NULL); zsock_set_rcvtimeo (sink, 100); zstr_recvx (sink, &hello, &world, NULL); assert (!hello && !world); zstr_sendx (proxy, "RESUME", NULL); zsock_wait (proxy); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); // Test capture functionality zsock_t *capture = zsock_new_pull ("inproc://capture"); assert (capture); // Switch on capturing, check that it works zstr_sendx (proxy, "CAPTURE", "inproc://capture", NULL); zsock_wait (proxy); zstr_sendx (faucet, "Hello", "World", NULL); zstr_recvx (sink, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); zstr_recvx (capture, &hello, &world, NULL); assert (streq (hello, "Hello")); assert (streq (world, "World")); zstr_free (&hello); zstr_free (&world); zsock_destroy (&faucet); zsock_destroy (&sink); zsock_destroy (&capture); zactor_destroy (&proxy); // Test socket creation dependency proxy = zactor_new (zproxy, NULL); assert (proxy); #ifdef WIN32 sink = zsock_new_sub(">inproc://backend", "whatever"); #else // vagrant vms don't like using shared storage for ipc pipes.. if (streq(getenv("USER"), "vagrant")) sink = zsock_new_sub (">ipc:///tmp/backend", "whatever"); else sink = zsock_new_sub (">ipc://backend", "whatever"); #endif // WIN32 assert (sink); #ifdef WIN32 zstr_sendx (proxy, "BACKEND", "XPUB", "inproc://backend", NULL); #else // vagrant vms don't like using shared storage for ipc pipes.. if (streq(getenv("USER"), "vagrant")) zstr_sendx(proxy, "BACKEND", "XPUB", "ipc:///tmp/backend", NULL); else zstr_sendx(proxy, "BACKEND", "XPUB", "ipc://backend", NULL); #endif zsock_wait (proxy); zsock_destroy(&sink); zactor_destroy(&proxy); #if (ZMQ_VERSION_MAJOR == 4) // Test authentication functionality const char *basedirpath = "src/selftest-rw/.test_zproxy"; const char *passfilepath = "src/selftest-rw/.test_zproxy/password-file"; const char *certfilepath = "src/selftest-rw/.test_zproxy/mycert.txt"; // Make sure old aborted tests do not hinder us zdir_t *dir = zdir_new (basedirpath, NULL); if (dir) { zdir_remove (dir, true); zdir_destroy (&dir); } zsys_file_delete (passfilepath); zsys_file_delete (certfilepath); zsys_dir_delete (basedirpath); // Create temporary directory for test files zsys_dir_create (basedirpath); char *frontend = NULL; char *backend = NULL; // Check there's no authentication s_create_test_sockets (&proxy, &faucet, &sink, verbose); s_bind_test_sockets (proxy, &frontend, &backend); bool success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // Install the authenticator zactor_t *auth = zactor_new (zauth, NULL); assert (auth); if (verbose) { zstr_sendx (auth, "VERBOSE", NULL); zsock_wait (auth); } // Check there's no authentication on a default NULL server s_bind_test_sockets (proxy, &frontend, &backend); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // When we set a domain on the server, we switch on authentication // for NULL sockets, but with no policies, the client connection // will be allowed. zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // Blacklist 127.0.0.1, connection should fail zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zstr_sendx (auth, "DENY", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, false); assert (!success); // Whitelist our address, which overrides the blacklist zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); zsock_wait (proxy); zstr_sendx (proxy, "DOMAIN", "BACKEND", "global", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zstr_sendx (auth, "ALLOW", "127.0.0.1", NULL); zsock_wait (auth); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // Try PLAIN authentication // Test negative case (no server-side passwords defined) zstr_sendx (proxy, "PLAIN", "FRONTEND", NULL); zsock_wait (proxy); zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zsock_set_plain_username (faucet, "admin"); zsock_set_plain_password (faucet, "Password"); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, false); assert (!success); // Test positive case (server-side passwords defined) FILE *password = fopen (passfilepath, "w"); assert (password); fprintf (password, "admin=Password\n"); fclose (password); zstr_sendx (proxy, "PLAIN", "FRONTEND", NULL); zsock_wait (proxy); zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); zsock_wait (proxy); zstr_sendx (proxy, "PLAIN", "BACKEND", NULL); zsock_wait (proxy); zstr_sendx (proxy, "DOMAIN", "BACKEND", "global", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zsock_set_plain_username (faucet, "admin"); zsock_set_plain_password (faucet, "Password"); zsock_set_plain_username (sink, "admin"); zsock_set_plain_password (sink, "Password"); zstr_sendx (auth, "PLAIN", passfilepath, NULL); zsock_wait (auth); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // Test negative case (bad client password) zstr_sendx (proxy, "PLAIN", "FRONTEND", NULL); zsock_wait (proxy); zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zsock_set_plain_username (faucet, "admin"); zsock_set_plain_password (faucet, "Bogus"); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, false); assert (!success); if (zsys_has_curve ()) { // We'll create two new certificates and save the client public // certificate on disk zcert_t *server_cert = zcert_new (); assert (server_cert); zcert_t *client_cert = zcert_new (); assert (client_cert); const char *public_key = zcert_public_txt (server_cert); const char *secret_key = zcert_secret_txt (server_cert); // Try CURVE authentication // Test without setting-up any authentication zstr_sendx (proxy, "CURVE", "FRONTEND", public_key, secret_key, NULL); zsock_wait (proxy); zstr_sendx (proxy, "DOMAIN", "FRONTEND", "global", NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zcert_apply (client_cert, faucet); zsock_set_curve_serverkey (faucet, public_key); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, false); assert (!success); // Test CURVE_ALLOW_ANY zstr_sendx (proxy, "CURVE", "FRONTEND", public_key, secret_key, NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zcert_apply (client_cert, faucet); zsock_set_curve_serverkey (faucet, public_key); zstr_sendx (auth, "CURVE", CURVE_ALLOW_ANY, NULL); zsock_wait (auth); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // Test with client certificate file in authentication folder zstr_sendx (proxy, "CURVE", "FRONTEND", public_key, secret_key, NULL); zsock_wait (proxy); zstr_sendx (proxy, "CURVE", "BACKEND", public_key, secret_key, NULL); zsock_wait (proxy); s_bind_test_sockets (proxy, &frontend, &backend); zcert_apply (client_cert, faucet); zsock_set_curve_serverkey (faucet, public_key); zcert_apply (client_cert, sink); zsock_set_curve_serverkey (sink, public_key); zcert_save_public (client_cert, certfilepath); zstr_sendx (auth, "CURVE", basedirpath, NULL); zsock_wait (auth); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); zcert_destroy (&server_cert); zcert_destroy (&client_cert); } // Remove the authenticator and check a normal connection works zactor_destroy (&auth); s_bind_test_sockets (proxy, &frontend, &backend); success = s_can_connect (&proxy, &faucet, &sink, frontend, backend, verbose, true); assert (success); // Cleanup zsock_destroy (&faucet); zsock_destroy (&sink); zactor_destroy (&proxy); zstr_free (&frontend); zstr_free (&backend); // Delete temporary directory and test files zsys_file_delete (passfilepath); zsys_file_delete (certfilepath); zsys_dir_delete (basedirpath); #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/test_randof.c0000664000372000037200000001442713222211156016636 0ustar00travistravis00000000000000/* ========================================================================= test_randof - development helper program to validate the range and dispersion of randof() implementation in current CZMQ codebase Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header test_randof - development helper program to validate the range and dispersion of randof() implementation in current CZMQ codebase @discuss @end */ // Custom testing, needs recompiling //#define ZSYS_RANDOF_MAX (INT32_MAX>>8) //#define ZSYS_RANDOF_FLT double //#define ZSYS_RANDOF_FUNC rand #include "czmq_classes.h" // Compiler can also tweak ZSYS_RANDOF_MAX to numeric or macroed value #ifndef TESTMAX //# define TESTMAX 999 # define TESTMAX (intmax_t)10000000 #endif #ifndef ITERMAX //# define ITERMAX 1000000000 # define ITERMAX (TESTMAX * 30) #endif #ifdef STRINGIZE_ #undef STRINGIZE_ #endif #ifdef STRINGIZE #undef STRINGIZE #endif #define STRINGIZE_(x) #x #define STRINGIZE(x) STRINGIZE_(x) int main (int argc, char *argv []) { bool verbose = false; int argn; intmax_t testmax = TESTMAX, itermax = ITERMAX, iteration = 0, testnbr = 0, rndmisses = 0; for (argn = 1; argn < argc; argn++) { if (streq (argv [argn], "--help") || streq (argv [argn], "-h")) { printf ("test_randof [options]\n"); printf (" --verbose / -v verbose test output\n"); printf (" --help / -h this information\n"); printf (" --test-range / -r NUM generate numbers from 0 to NUM-1 (default %jd)\n", (intmax_t)TESTMAX); printf (" --iterations / -i ITR run ITR takes at generating random values (default %jd); recommended at least 30*NUM\n", (intmax_t)ITERMAX); printf (" ZSYS_RANDOF_MAX is defined during compilation, this binary was built with \"%s\" (%jd)\n", STRINGIZE(ZSYS_RANDOF_MAX), (intmax_t)ZSYS_RANDOF_MAX); printf (" ZSYS_RANDOF_FLT is defined during compilation, this binary was built with \"%s\"\n", STRINGIZE(ZSYS_RANDOF_FLT)); printf (" ZSYS_RANDOF_FUNC is defined during compilation, this binary was built with \"%s\"\n", STRINGIZE(ZSYS_RANDOF_FUNC)); // TODO: CSV output mode to a file for pretty graphing of the spectrum? return 0; } else if (streq (argv [argn], "--verbose") || streq (argv [argn], "-v")) verbose = true; else if (streq (argv [argn], "--test-range") || streq (argv [argn], "-r")) { if (argn + 1 >= argc) { printf ("Option %s requires a value\n", argv [argn]); return 1; } if (1 != sscanf (argv[argn+1], "%jd", &testmax) ) { printf ("Failed to parse option %s from value %s\n", argv [argn], argv [argn+1]); return 1; } argn++; } else if (streq (argv [argn], "--iterations") || streq (argv [argn], "-i")) { if (argn + 1 >= argc) { printf ("Option %s requires a value\n", argv [argn]); return 1; } if (1 != sscanf (argv[argn+1], "%jd", &itermax) ) { printf ("Failed to parse option %s from value %s\n", argv [argn], argv [argn+1]); return 1; } argn++; } else { printf ("Unknown option: %s\n", argv [argn]); return 1; } } if (testmax <= 0) { printf ("Variable testmax is too small: %jd", testmax); return 1; } if (itermax <= 0) { printf ("Variable itermax is too small: %jd", itermax); return 1; } // WARNING: Code below implies that "size_t" used by zmalloc() and memset() // would suffice to count the testmax-based byte size on your platform #ifdef SIZE_MAX assert ( testmax < (SIZE_MAX / sizeof (size_t)) ); #endif // Insert main code here zsys_init (); if (verbose) zsys_info ("test_randof - development helper for randof() testing"); size_t *rndcnt = (size_t*)zmalloc (sizeof (size_t) * testmax); assert (rndcnt); memset (rndcnt, 0, sizeof (size_t) * testmax); unsigned int random_seed = (unsigned int) zclock_time (); srandom (random_seed); zsys_info ("test_randof : Running random loop for %jd iterations and %jd values (factor of %.6Lg) and random seed %u", itermax, testmax, (long double)itermax/(long double)testmax, random_seed); for (iteration = 0; iteration < itermax && !zsys_interrupted ; iteration++) { testnbr = randof (testmax); assert (testnbr != testmax); assert (testnbr < testmax); assert (testnbr >= 0); rndcnt[testnbr]++; } zsys_info ("test_randof : Testing hit-counts of %jd entries", testmax); for (iteration = 0; iteration < testmax && !zsys_interrupted; iteration++) { if (rndcnt[iteration] == 0) { if (verbose) zsys_warning("test_randof : random distribution fault : got 0 hits for %jd/%jd", iteration, testmax); rndmisses++; } } // Too many misses are suspicious... we can lose half the entries // for each bit not used in the assumed ZSYS_RANDOF_MAX... // We can also have a result-spectrum too discrete with smallish // ZSYS_RANDOF_MAX and largish testmax... zsys_info ("test_randof : Got %jd zero-entries (misses) from %jd range (%.4Lg %%) with ZSYS_RANDOF_MAX=%jd and %s precision and %s()", rndmisses, testmax, rndmisses ? ((long double)(rndmisses)/(long double)testmax)*100.0 : (long double)0.0, (intmax_t)ZSYS_RANDOF_MAX, STRINGIZE(ZSYS_RANDOF_FLT), STRINGIZE(ZSYS_RANDOF_FUNC) ); assert ( (rndmisses < (testmax / 3 )) ); free(rndcnt); return 0; } czmq-4.1.0/src/zactor.c0000664000372000037200000002357513222211156015634 0ustar00travistravis00000000000000/* ========================================================================= zactor - simple actor framework Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zactor class provides a simple actor framework. It replaces the CZMQ zthread class, which had a complex API that did not fit the CLASS standard. A CZMQ actor is implemented as a thread plus a PAIR-PAIR pipe. The constructor and destructor are always synchronized, so the caller can be sure all resources are created, and destroyed, when these calls complete. (This solves a major problem with zthread, that a caller could not be sure when a child thread had finished.) A zactor_t instance acts like a zsock_t and you can pass it to any CZMQ method that would take a zsock_t argument, including methods in zframe, zmsg, zstr, and zpoller. (zloop somehow escaped and needs catching.) An actor function MUST call zsock_signal (pipe) when initialized and MUST listen to pipe and exit on $TERM command. @discuss @end */ #include "czmq_classes.h" // zactor_t instances always have this tag as the first 4 octets of // their data, which lets us do runtime object typing & validation. #define ZACTOR_TAG 0x0005cafe // Structure of our class struct _zactor_t { uint32_t tag; // Object tag for runtime detection zsock_t *pipe; // Front-end pipe through to actor zactor_destructor_fn *destructor; // Custom destructor for actor, sends $TERM by default }; // This shims the OS thread APIs typedef struct { zactor_fn *handler; zsock_t *pipe; // Pipe back to parent void *args; // Application arguments } shim_t; // -------------------------------------------------------------------------- // Thread creation code, wrapping POSIX and Win32 thread APIs #if defined (__UNIX__) // Thread shim for UNIX calls the actual thread and cleans up afterwards. static void * s_thread_shim (void *args) { assert (args); shim_t *shim = (shim_t *) args; shim->handler (shim->pipe, shim->args); // Do not block, if the other end of the pipe is already deleted zsock_set_sndtimeo (shim->pipe, 0); zsock_signal (shim->pipe, 0); zsock_destroy (&shim->pipe); freen (shim); return NULL; } #elif defined (__WINDOWS__) // Thread shim for Windows that wraps a POSIX-style thread handler // and does the _endthreadex for us automatically. static unsigned __stdcall s_thread_shim (void *args) { assert (args); shim_t *shim = (shim_t *) args; shim->handler (shim->pipe, shim->args); // Do not block, if the other end of the pipe is already deleted zsock_set_sndtimeo (shim->pipe, 0); zsock_signal (shim->pipe, 0); zsock_destroy (&shim->pipe); freen (shim); _endthreadex (0); // Terminates thread return 0; } #endif // Sends $TERM string to child static void s_zactor_destructor (zactor_t *self) { assert (self); if (zstr_send (self->pipe, "$TERM") == 0) zsock_wait (self->pipe); } // -------------------------------------------------------------------------- // Create a new actor. zactor_t * zactor_new (zactor_fn actor, void *args) { zactor_t *self = (zactor_t *) zmalloc (sizeof (zactor_t)); assert (self); self->tag = ZACTOR_TAG; self->destructor = s_zactor_destructor; shim_t *shim = (shim_t *) zmalloc (sizeof (shim_t)); assert (shim); shim->pipe = zsys_create_pipe (&self->pipe); assert (shim->pipe); shim->handler = actor; shim->args = args; #if defined (__UNIX__) pthread_t thread; pthread_create (&thread, NULL, s_thread_shim, shim); pthread_detach (thread); #elif defined (__WINDOWS__) HANDLE handle = (HANDLE) _beginthreadex ( NULL, // Handle is private to this process 0, // Use a default stack size for new thread &s_thread_shim, // Start real thread function via this shim shim, // Which gets arguments shim CREATE_SUSPENDED, // Set thread priority before starting it NULL); // We don't use the thread ID assert (handle); // Set child thread priority to same as current int priority = GetThreadPriority (GetCurrentThread ()); SetThreadPriority (handle, priority); // Start thread & release resources ResumeThread (handle); CloseHandle (handle); #endif // Mandatory handshake for new actor so that constructor returns only // when actor has also initialized. This eliminates timing issues at // application start up. zsock_wait (self->pipe); return self; } // -------------------------------------------------------------------------- // Destroy the actor. void zactor_destroy (zactor_t **self_p) { assert (self_p); if (*self_p) { zactor_t *self = *self_p; assert (zactor_is (self)); // Signal the actor to end and wait for the thread exit code // If the pipe isn't connected any longer, assume child thread // has already quit due to other reasons and don't collect the // exit signal. if (self->pipe) { zsock_set_sndtimeo (self->pipe, 0); self->destructor (self); zsock_destroy (&self->pipe); } self->tag = 0xDeadBeef; freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Send a zmsg message to the actor, take ownership of the message // and destroy when it has been sent. int zactor_send (zactor_t *self, zmsg_t **msg_p) { return zmsg_send (msg_p, self); } // -------------------------------------------------------------------------- // Receive a zmsg message from the actor. Returns NULL if the actor // was interrupted before the message could be received, or if there // was a timeout on the actor. zmsg_t * zactor_recv (zactor_t *self) { return zmsg_recv (self); } // -------------------------------------------------------------------------- // Probe the supplied object, and report if it looks like a zactor_t. bool zactor_is (void *self) { assert (self); return ((zactor_t *) self)->tag == ZACTOR_TAG; } // -------------------------------------------------------------------------- // Probe the supplied reference. If it looks like a zactor_t instance, // return the underlying libzmq actor handle; else if it looks like // a libzmq actor handle, return the supplied value. void * zactor_resolve (void *self) { assert (self); if (zactor_is (self)) return zsock_resolve (((zactor_t *) self)->pipe); else return self; } // -------------------------------------------------------------------------- // Return the actor's zsock handle. Use this when you absolutely need // to work with the zsock instance rather than the actor. zsock_t * zactor_sock (zactor_t *self) { assert (self); assert (zactor_is (self)); return self->pipe; } // -------------------------------------------------------------------------- // Change default destructor by custom function. Actor MUST be able to handle // new message instead of default $TERM. void zactor_set_destructor (zactor_t *self, zactor_destructor_fn destructor) { assert (self); self->destructor = destructor; } // -------------------------------------------------------------------------- // Actor // must call zsock_signal (pipe) when initialized // must listen to pipe and exit on $TERM command static void echo_actor (zsock_t *pipe, void *args) { // Do some initialization assert (streq ((char *) args, "Hello, World")); zsock_signal (pipe, 0); bool terminated = false; while (!terminated) { zmsg_t *msg = zmsg_recv (pipe); if (!msg) break; // Interrupted char *command = zmsg_popstr (msg); // All actors must handle $TERM in this way if (streq (command, "$TERM")) terminated = true; else // This is an example command for our test actor if (streq (command, "ECHO")) zmsg_send (&msg, pipe); else { puts ("E: invalid message to actor"); assert (false); } freen (command); zmsg_destroy (&msg); } } static void KTHXBAI_actor (zsock_t *pipe, void *args) { zsock_signal (pipe, 0); while (!zsys_interrupted) { char *str = zstr_recv (pipe); int done = streq (str, "$KTHXBAI"); zstr_free (&str); if (done) break; } } static void KTHXBAI_destructor (zactor_t *self) { assert (self); if (zstr_send (self->pipe, "$KTHXBAI") == 0) zsock_wait (self->pipe); } // -------------------------------------------------------------------------- // Selftest void zactor_test (bool verbose) { printf (" * zactor: "); // @selftest zactor_t *actor = zactor_new (echo_actor, "Hello, World"); assert (actor); zstr_sendx (actor, "ECHO", "This is a string", NULL); char *string = zstr_recv (actor); assert (streq (string, "This is a string")); freen (string); zactor_destroy (&actor); // custom destructor // KTHXBAI_actor ends on "$KTHXBAI" string zactor_t *KTHXBAI = zactor_new (KTHXBAI_actor, NULL); assert (KTHXBAI); // which is the one sent by KTHXBAI_destructor zactor_set_destructor (KTHXBAI, KTHXBAI_destructor); zactor_destroy (&KTHXBAI); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zgossip.c0000664000372000037200000005413113222211156016020 0ustar00travistravis00000000000000/* ========================================================================= zgossip - decentralized configuration management Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Implements a gossip protocol for decentralized configuration management. Your applications nodes form a loosely connected network (which can have cycles), and publish name/value tuples. Each node re-distributes the new tuples it receives, so that the entire network eventually achieves a consistent state. The current design does not expire tuples. Provides these commands (sent as multipart strings to the actor): * BIND endpoint -- binds the gossip service to specified endpoint * PORT -- returns the last TCP port, if any, used for binding * LOAD configfile -- load configuration from specified file * SET configpath value -- set configuration path = value * SAVE configfile -- save configuration to specified file * CONNECT endpoint -- connect the gossip service to the specified peer * PUBLISH key value -- publish a key/value pair to the gossip cluster * STATUS -- return number of key/value pairs held by gossip service * ZAP DOMAIN domain -- set the ZAP DOMAIN domain = value Returns these messages: * PORT number -- reply to PORT command * STATUS number -- reply to STATUS command * DELIVER key value -- new tuple delivered from network @discuss The gossip protocol distributes information around a loosely-connected network of gossip services. The information consists of name/value pairs published by applications at any point in the network. The goal of the gossip protocol is to create eventual consistency between all the using applications. The name/value pairs (tuples) can be used for configuration data, for status updates, for presence, or for discovery. When used for discovery, the gossip protocol works as an alternative to e.g. UDP beaconing. The gossip network consists of a set of loosely-coupled nodes that exchange tuples. Nodes can be connected across arbitrary transports, so the gossip network can have nodes that communicate over inproc, over IPC, and/or over TCP, at the same time. Each node runs the same stack, which is a server-client hybrid using a modified Harmony pattern (from Chapter 8 of the Guide): http://zguide.zeromq.org/page:all#True-Peer-Connectivity-Harmony-Pattern Each node provides a ROUTER socket that accepts client connections on an key defined by the application via a BIND command. The state machine for these connections is in zgossip.xml, and the generated code is in zgossip_engine.inc. Each node additionally creates outbound connections via DEALER sockets to a set of servers ("remotes"), and under control of the calling app, which sends CONNECT commands for each configured remote. The messages between client and server are defined in zgossip_msg.xml. We built this stack using the zeromq/zproto toolkit. To join the gossip network, a node connects to one or more peers. Each peer acts as a forwarder. This loosely-coupled network can scale to thousands of nodes. However the gossip protocol is NOT designed to be efficient, and should not be used for application data, as the same tuples may be sent many times across the network. The basic logic of the gossip service is to accept PUBLISH messages from its owning application, and to forward these to every remote, and every client it talks to. When a node gets a duplicate tuple, it throws it away. When a node gets a new tuple, it stores it, and forwards it as just described. At present there is no way to expire tuples from the network. The assumptions in this design are: * The data set is slow-changing. Thus, the cost of the gossip protocol is irrelevant with respect to other traffic. @end */ #include "czmq_classes.h" // TODO- project.xml? #ifdef CZMQ_BUILD_DRAFT_API #define CZMQ_ZGOSSIP_ZAP_DOMAIN "global" #endif // --------------------------------------------------------------------- // Forward declarations for the two main classes we use here typedef struct _server_t server_t; typedef struct _client_t client_t; typedef struct _tuple_t tuple_t; // --------------------------------------------------------------------- // This structure defines the context for each running server. Store // whatever properties and structures you need for the server. struct _server_t { // These properties must always be present in the server_t // and are set by the generated engine; do not modify them! zsock_t *pipe; // Actor pipe back to caller zconfig_t *config; // Current loaded configuration // Add any properties you need here zlistx_t *remotes; // Parents, as zsock_t instances zhashx_t *tuples; // Tuples, indexed by key tuple_t *cur_tuple; // Holds current tuple to publish zgossip_msg_t *message; // Message to broadcast char *public_key; char *secret_key; #ifdef CZMQ_BUILD_DRAFT_API char *zap_domain; #endif }; // --------------------------------------------------------------------- // This structure defines the state for each client connection. It will // be passed to each action in the 'self' argument. struct _client_t { // These properties must always be present in the client_t // and are set by the generated engine; do not modify them! server_t *server; // Reference to parent server zgossip_msg_t *message; // Message in and out }; // --------------------------------------------------------------------- // This structure defines one tuple that we track struct _tuple_t { zhashx_t *container; // Hash table that holds this item char *key; // Tuple key char *value; // Tuple value }; // Callback when we remove a tuple from its container static void tuple_free (void *argument) { tuple_t *self = (tuple_t *) argument; freen (self->key); freen (self->value); freen (self); } // Handle traffic from remotes static int remote_handler (zloop_t *loop, zsock_t *remote, void *argument); // --------------------------------------------------------------------- // Include the generated server engine #include "zgossip_engine.inc" // Allocate properties and structures for a new server instance. // Return 0 if OK, or -1 if there was an error. static int server_initialize (server_t *self) { // Default timeout for clients is one second; the caller can // override this with a SET message. engine_configure (self, "server/timeout", "1000"); self->message = zgossip_msg_new (); self->remotes = zlistx_new (); assert (self->remotes); zlistx_set_destructor (self->remotes, (czmq_destructor *) zsock_destroy); self->tuples = zhashx_new (); assert (self->tuples); #ifdef CZMQ_BUILD_DRAFT_API self->zap_domain = strdup(CZMQ_ZGOSSIP_ZAP_DOMAIN); #endif return 0; } // Free properties and structures for a server instance static void server_terminate (server_t *self) { zgossip_msg_destroy (&self->message); zlistx_destroy (&self->remotes); zhashx_destroy (&self->tuples); zstr_free (&self->public_key); zstr_free (&self->secret_key); #ifdef CZMQ_BUILD_DRAFT_API zstr_free (&self->zap_domain); #endif } // Connect to a remote server static void #ifdef CZMQ_BUILD_DRAFT_API server_connect (server_t *self, const char *endpoint, const char *public_key) #else server_connect (server_t *self, const char *endpoint) #endif { zsock_t *remote = zsock_new (ZMQ_DEALER); assert (remote); // No recovery if exhausted #ifdef CZMQ_BUILD_DRAFT_API if (public_key){ zcert_t *cert = zcert_new_from_txt (self->public_key, self->secret_key); zcert_apply(cert, remote); zsock_set_curve_serverkey (remote, public_key); #ifndef ZMQ_CURVE // legacy ZMQ support // inline incase the underlying assert is removed bool ZMQ_CURVE = false; #endif assert (zsock_mechanism (remote) == ZMQ_CURVE); zcert_destroy(&cert); } #endif // Never block on sending; we use an infinite HWM and buffer as many // messages as needed in outgoing pipes. Note that the maximum number // is the overall tuple set size. zsock_set_unbounded (remote); if (zsock_connect (remote, "%s", endpoint)) { zsys_warning ("bad zgossip endpoint '%s'", endpoint); zsock_destroy (&remote); return; } // Send HELLO and then PUBLISH for each tuple we have zgossip_msg_t *gossip = zgossip_msg_new (); zgossip_msg_set_id (gossip, ZGOSSIP_MSG_HELLO); zgossip_msg_send (gossip, remote); tuple_t *tuple = (tuple_t *) zhashx_first (self->tuples); while (tuple) { zgossip_msg_set_id (gossip, ZGOSSIP_MSG_PUBLISH); zgossip_msg_set_key (gossip, tuple->key); zgossip_msg_set_value (gossip, tuple->value); zgossip_msg_send (gossip, remote); tuple = (tuple_t *) zhashx_next (self->tuples); } // Now monitor this remote for incoming messages zgossip_msg_destroy (&gossip); engine_handle_socket (self, remote, remote_handler); zlistx_add_end (self->remotes, remote); } // Process an incoming tuple on this server. static void server_accept (server_t *self, const char *key, const char *value) { tuple_t *tuple = (tuple_t *) zhashx_lookup (self->tuples, key); if (tuple && streq (tuple->value, value)) return; // Duplicate tuple, do nothing // Create new tuple tuple = (tuple_t *) zmalloc (sizeof (tuple_t)); assert (tuple); tuple->container = self->tuples; tuple->key = strdup (key); tuple->value = strdup (value); // Store new tuple zhashx_update (tuple->container, key, tuple); zhashx_freefn (tuple->container, key, tuple_free); // Deliver to calling application zstr_sendx (self->pipe, "DELIVER", key, value, NULL); // Hold in server context so we can broadcast to all clients self->cur_tuple = tuple; engine_broadcast_event (self, NULL, forward_event); // Copy new tuple announcement to all remotes zgossip_msg_t *gossip = zgossip_msg_new (); zgossip_msg_set_id (gossip, ZGOSSIP_MSG_PUBLISH); zsock_t *remote = (zsock_t *) zlistx_first (self->remotes); while (remote) { zgossip_msg_set_key (gossip, tuple->key); zgossip_msg_set_value (gossip, tuple->value); zgossip_msg_send (gossip, remote); remote = (zsock_t *) zlistx_next (self->remotes); } zgossip_msg_destroy (&gossip); } // Process server API method, return reply message if any static zmsg_t * server_method (server_t *self, const char *method, zmsg_t *msg) { // Connect to a remote zmsg_t *reply = NULL; if (streq (method, "CONNECT")) { char *endpoint = zmsg_popstr (msg); assert (endpoint); #ifdef CZMQ_BUILD_DRAFT_API // leaving this in here for now because if/def changes the server_connect // function args. it doesn't look like server_connect is used anywhere else // but want to leave this in until we're sure this is stable.. char *public_key = zmsg_popstr (msg); server_connect (self, endpoint, public_key); zstr_free (&public_key); #else server_connect (self, endpoint); #endif zstr_free (&endpoint); } else if (streq (method, "PUBLISH")) { char *key = zmsg_popstr (msg); char *value = zmsg_popstr (msg); server_accept (self, key, value); zstr_free (&key); zstr_free (&value); } else if (streq (method, "STATUS")) { // Return number of tuples we have stored reply = zmsg_new (); assert (reply); zmsg_addstr (reply, "STATUS"); zmsg_addstrf (reply, "%d", (int) zhashx_size (self->tuples)); } #ifdef CZMQ_BUILD_DRAFT_API else if (streq (method, "SET PUBLICKEY")) { char *key = zmsg_popstr (msg); self->public_key = strdup (key); assert (self->public_key); zstr_free (&key); } else if (streq (method, "SET SECRETKEY")) { char *key = zmsg_popstr (msg); self->secret_key = strdup(key); assert (self->secret_key); zstr_free (&key); } else if (streq (method, "ZAP DOMAIN")) { char *value = zmsg_popstr (msg); zstr_free(&self->zap_domain); self->zap_domain = strdup(value); assert (self->zap_domain); zstr_free (&value); } #endif else zsys_error ("unknown zgossip method '%s'", method); return reply; } // Apply new configuration. static void server_configuration (server_t *self, zconfig_t *config) { ZPROTO_UNUSED(self); ZPROTO_UNUSED(config); // Apply new configuration } // Allocate properties and structures for a new client connection and // optionally engine_set_next_event (). Return 0 if OK, or -1 on error. static int client_initialize (client_t *self) { // Construct properties here return 0; } // Free properties and structures for a client connection static void client_terminate (client_t *self) { // Destroy properties here } // -------------------------------------------------------------------------- // get_first_tuple // static void get_first_tuple (client_t *self) { tuple_t *tuple = (tuple_t *) zhashx_first (self->server->tuples); if (tuple) { zgossip_msg_set_key (self->message, tuple->key); zgossip_msg_set_value (self->message, tuple->value); engine_set_next_event (self, ok_event); } else engine_set_next_event (self, finished_event); } // -------------------------------------------------------------------------- // get_next_tuple // static void get_next_tuple (client_t *self) { tuple_t *tuple = (tuple_t *) zhashx_next (self->server->tuples); if (tuple) { zgossip_msg_set_key (self->message, tuple->key); zgossip_msg_set_value (self->message, tuple->value); engine_set_next_event (self, ok_event); } else engine_set_next_event (self, finished_event); } // -------------------------------------------------------------------------- // store_tuple_if_new // static void store_tuple_if_new (client_t *self) { server_accept (self->server, zgossip_msg_key (self->message), zgossip_msg_value (self->message)); } // -------------------------------------------------------------------------- // get_tuple_to_forward // static void get_tuple_to_forward (client_t *self) { // Hold this in server->cur_tuple so it's available to all // clients; the whole broadcast operation happens in one thread // so there's no risk of confusion here. tuple_t *tuple = self->server->cur_tuple; zgossip_msg_set_key (self->message, tuple->key); zgossip_msg_set_value (self->message, tuple->value); } // -------------------------------------------------------------------------- // Handle messages coming from remotes static int remote_handler (zloop_t *loop, zsock_t *remote, void *argument) { server_t *self = (server_t *) argument; if (zgossip_msg_recv (self->message, remote)) return -1; // Interrupted if (zgossip_msg_id (self->message) == ZGOSSIP_MSG_PUBLISH) server_accept (self, zgossip_msg_key (self->message), zgossip_msg_value (self->message)); else if (zgossip_msg_id (self->message) == ZGOSSIP_MSG_INVALID) { // Connection was reset, so send HELLO again zgossip_msg_set_id (self->message, ZGOSSIP_MSG_HELLO); zgossip_msg_send (self->message, remote); } else if (zgossip_msg_id (self->message) == ZGOSSIP_MSG_PONG) assert (true); // Do nothing with PONGs return 0; } // -------------------------------------------------------------------------- // Selftest void zgossip_test (bool verbose) { printf (" * zgossip: "); if (verbose) printf ("\n"); // @selftest // Test basic client-to-server operation of the protocol zactor_t *server = zactor_new (zgossip, "server"); assert (server); if (verbose) zstr_send (server, "VERBOSE"); zstr_sendx (server, "BIND", "inproc://zgossip", NULL); zsock_t *client = zsock_new (ZMQ_DEALER); assert (client); zsock_set_rcvtimeo (client, 2000); int rc = zsock_connect (client, "inproc://zgossip"); assert (rc == 0); // Send HELLO, which gets no message zgossip_msg_t *message = zgossip_msg_new (); zgossip_msg_set_id (message, ZGOSSIP_MSG_HELLO); zgossip_msg_send (message, client); // Send PING, expect PONG back zgossip_msg_set_id (message, ZGOSSIP_MSG_PING); zgossip_msg_send (message, client); zgossip_msg_recv (message, client); assert (zgossip_msg_id (message) == ZGOSSIP_MSG_PONG); zgossip_msg_destroy (&message); zactor_destroy (&server); zsock_destroy (&client); // Test peer-to-peer operations zactor_t *base = zactor_new (zgossip, "base"); assert (base); if (verbose) zstr_send (base, "VERBOSE"); // Set a 100msec timeout on clients so we can test expiry zstr_sendx (base, "SET", "server/timeout", "100", NULL); zstr_sendx (base, "BIND", "inproc://base", NULL); zactor_t *alpha = zactor_new (zgossip, "alpha"); assert (alpha); zstr_sendx (alpha, "CONNECT", "inproc://base", NULL); zstr_sendx (alpha, "PUBLISH", "inproc://alpha-1", "service1", NULL); zstr_sendx (alpha, "PUBLISH", "inproc://alpha-2", "service2", NULL); zactor_t *beta = zactor_new (zgossip, "beta"); assert (beta); zstr_sendx (beta, "CONNECT", "inproc://base", NULL); zstr_sendx (beta, "PUBLISH", "inproc://beta-1", "service1", NULL); zstr_sendx (beta, "PUBLISH", "inproc://beta-2", "service2", NULL); // got nothing zclock_sleep (200); zstr_send (alpha, "STATUS"); char *command, *status, *key, *value; zstr_recvx (alpha, &command, &key, &value, NULL); assert (streq (command, "DELIVER")); assert (streq (key, "inproc://alpha-1")); assert (streq (value, "service1")); zstr_free (&command); zstr_free (&key); zstr_free (&value); zstr_recvx (alpha, &command, &key, &value, NULL); assert (streq (command, "DELIVER")); assert (streq (key, "inproc://alpha-2")); assert (streq (value, "service2")); zstr_free (&command); zstr_free (&key); zstr_free (&value); zstr_recvx (alpha, &command, &key, &value, NULL); assert (streq (command, "DELIVER")); assert (streq (key, "inproc://beta-1")); assert (streq (value, "service1")); zstr_free (&command); zstr_free (&key); zstr_free (&value); zstr_recvx (alpha, &command, &key, &value, NULL); assert (streq (command, "DELIVER")); assert (streq (key, "inproc://beta-2")); assert (streq (value, "service2")); zstr_free (&command); zstr_free (&key); zstr_free (&value); zstr_recvx (alpha, &command, &status, NULL); assert (streq (command, "STATUS")); assert (atoi (status) == 4); zstr_free (&command); zstr_free (&status); zactor_destroy (&base); zactor_destroy (&alpha); zactor_destroy (&beta); #ifdef CZMQ_BUILD_DRAFT_API // curve if (zsys_has_curve()) { if (verbose) printf("testing CURVE support"); zclock_sleep (2000); zactor_t *auth = zactor_new(zauth, NULL); assert (auth); if (verbose) { zstr_sendx (auth, "VERBOSE", NULL); zsock_wait (auth); } zstr_sendx(auth,"ALLOW","127.0.0.1",NULL); zsock_wait(auth); zstr_sendx (auth, "CURVE", CURVE_ALLOW_ANY, NULL); zsock_wait (auth); server = zactor_new (zgossip, "server"); if (verbose) zstr_send (server, "VERBOSE"); assert (server); zcert_t *client1_cert = zcert_new (); zcert_t *server_cert = zcert_new (); zstr_sendx (server, "SET PUBLICKEY", zcert_public_txt (server_cert), NULL); zstr_sendx (server, "SET SECRETKEY", zcert_secret_txt (server_cert), NULL); zstr_sendx (server, "ZAP DOMAIN", "TEST", NULL); zstr_sendx (server, "BIND", "tcp://127.0.0.1:*", NULL); zstr_sendx (server, "PORT", NULL); zstr_recvx (server, &command, &value, NULL); assert (streq (command, "PORT")); int port = atoi (value); zstr_free (&command); zstr_free (&value); char endpoint [32]; sprintf (endpoint, "tcp://127.0.0.1:%d", port); zactor_t *client1 = zactor_new (zgossip, "client"); if (verbose) zstr_send (client1, "VERBOSE"); assert (client1); zstr_sendx (client1, "SET PUBLICKEY", zcert_public_txt (client1_cert), NULL); zstr_sendx (client1, "SET SECRETKEY", zcert_secret_txt (client1_cert), NULL); zstr_sendx (client1, "ZAP DOMAIN", "TEST", NULL); const char *public_txt = zcert_public_txt (server_cert); zstr_sendx (client1, "CONNECT", endpoint, public_txt, NULL); zstr_sendx (client1, "PUBLISH", "tcp://127.0.0.1:9001", "service1", NULL); zclock_sleep (500); zstr_send (server, "STATUS"); zclock_sleep (500); zstr_recvx (server, &command, &key, &value, NULL); assert (streq (command, "DELIVER")); assert (streq (value, "service1")); zstr_free (&command); zstr_free (&key); zstr_free (&value); zstr_sendx (client1, "$TERM", NULL); zstr_sendx (server, "$TERM", NULL); zclock_sleep(500); zcert_destroy (&client1_cert); zcert_destroy (&server_cert); zactor_destroy (&client1); zactor_destroy (&server); zactor_destroy (&auth); } #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/platform.h0000664000372000037200000001466013222211336016156 0ustar00travistravis00000000000000/* src/platform.h. Generated from platform.h.in by configure. */ /* src/platform.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ /* #undef AC_APPLE_UNIVERSAL_BUILD */ /* Architecture of the build host */ /* #undef BUILD_ARCH */ /* Build date */ /* #undef BUILD_DATE */ /* Build host name */ /* #undef BUILD_HOST */ /* The fine user who built the package */ /* #undef BUILD_USER */ /* Provide draft classes and methods */ /* #undef CZMQ_BUILD_DRAFT_API */ /* Have AIX OS */ /* #undef CZMQ_HAVE_AIX */ /* Have Android OS */ /* #undef CZMQ_HAVE_ANDROID */ /* Have Cygwin */ /* #undef CZMQ_HAVE_CYGWIN */ /* Have FreeBSD OS */ /* #undef CZMQ_HAVE_FREEBSD */ /* Have GNU/Hurd OS */ /* #undef CZMQ_HAVE_GNU */ /* Have HPUX OS */ /* #undef CZMQ_HAVE_HPUX */ /* Have Linux OS */ #define CZMQ_HAVE_LINUX 1 /* Have MinGW32 */ /* #undef CZMQ_HAVE_MINGW32 */ /* Have NetBSD OS */ /* #undef CZMQ_HAVE_NETBSD */ /* Have OpenBSD OS */ /* #undef CZMQ_HAVE_OPENBSD */ /* Have DarwinOSX OS */ /* #undef CZMQ_HAVE_OSX */ /* Have QNX Neutrino OS */ /* #undef CZMQ_HAVE_QNXNTO */ /* Have Solaris OS */ /* #undef CZMQ_HAVE_SOLARIS */ /* Have Windows OS */ /* #undef CZMQ_HAVE_WINDOWS */ /* Define to 1 if you have the header file. */ #define HAVE_ARPA_INET_H 1 /* Define to 1 if you have the header file. */ #define HAVE_DLFCN_H 1 /* Define to 1 if you have the header file. */ #define HAVE_ERRNO_H 1 /* Define to 1 if you have the `getifaddrs' function. */ #define HAVE_GETIFADDRS 1 /* Define to 1 if you have the `gettimeofday' function. */ #define HAVE_GETTIMEOFDAY 1 /* Define to 1 if you have the header file. */ #define HAVE_IFADDRS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 /* The optional liblz4 library is to be used */ #define HAVE_LIBLZ4 1 /* The optional libsystemd library is to be used */ /* #undef HAVE_LIBSYSTEMD */ /* Define to 1 if you have the header file. */ #define HAVE_LIMITS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_LINUX_WIRELESS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the `memset' function. */ /* #undef HAVE_MEMSET */ /* Define to 1 if you have the header file. */ #define HAVE_NETINET_IN_H 1 /* Define to 1 if you have the header file. */ #define HAVE_NETINET_TCP_H 1 /* Define to 1 if you have the header file. */ #define HAVE_NET_IF_H 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_NET_IF_MEDIA_H */ /* Define to 1 if you have the `perror' function. */ #define HAVE_PERROR 1 /* Define to 1 if you have the header file. */ #define HAVE_PTHREAD_H 1 /* Define to 1 if stdbool.h conforms to C99. */ #define HAVE_STDBOOL_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDDEF_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 /* The optional uuid library is to be used */ #define HAVE_UUID 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_WINDOWS_H */ /* Define to 1 if the system has the type `_Bool'. */ #define HAVE__BOOL 1 /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" /* Name of package */ #define PACKAGE "czmq" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "zeromq-dev@lists.zeromq.org" /* Define to the full name of this package. */ #define PACKAGE_NAME "czmq" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "czmq 4.1.0" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "czmq" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "4.1.0" /* CZMQ major version */ #define PACKAGE_VERSION_MAJOR 4 /* CZMQ minor version */ #define PACKAGE_VERSION_MINOR 1 /* CZMQ patchlevel */ #define PACKAGE_VERSION_PATCH 0 /* Define as the return type of signal handlers (`int' or `void'). */ #define RETSIGTYPE void /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define to 1 if you can safely include both and . */ #define TIME_WITH_SYS_TIME 1 /* Version number of package */ #define VERSION "4.1.0" /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN /* # undef WORDS_BIGENDIAN */ # endif #endif /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ /* #undef _UINT32_T */ /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus /* #undef inline */ #endif /* Define to `unsigned int' if does not define. */ /* #undef size_t */ /* Define to `int' if does not define. */ /* #undef ssize_t */ /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ /* #undef uint32_t */ /* Define to empty if the keyword `volatile' does not work. Warning: valid code using `volatile' can become incorrect without. Disable with care. */ /* #undef volatile */ czmq-4.1.0/src/zuuid.c0000664000372000037200000002204013222211156015454 0ustar00travistravis00000000000000/* ========================================================================= zuuid - UUID support class Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zuuid class generates UUIDs and provides methods for working with them. If you build CZMQ with libuuid, on Unix/Linux, it will use that library. On Windows it will use UuidCreate(). Otherwise it will use a random number generator to produce convincing imitations of UUIDs. @discuss @end */ #include "czmq_classes.h" // Structure of our class struct _zuuid_t { byte uuid [ZUUID_LEN]; // Binary UUID char str [ZUUID_STR_LEN + 1]; // Printable UUID char *str_canonical; // Canonical UUID, if any }; // -------------------------------------------------------------------------- // Constructor zuuid_t * zuuid_new (void) { zuuid_t *self = (zuuid_t *) zmalloc (sizeof (zuuid_t)); assert (self); #if defined (__WINDOWS__) // Windows always has UUID support UUID uuid; assert (sizeof (uuid) == ZUUID_LEN); UuidCreate (&uuid); zuuid_set (self, (byte *) &uuid); #elif defined (HAVE_UUID) uuid_t uuid; assert (sizeof (uuid) == ZUUID_LEN); uuid_generate (uuid); zuuid_set (self, (byte *) uuid); #elif defined (__UTYPE_OPENBSD) || defined (__UTYPE_FREEBSD) || defined (__UTYPE_NETBSD) uuid_t uuid; uint32_t status = 0; uuid_create (&uuid, &status); if (status != uuid_s_ok) { zuuid_destroy (&self); return NULL; } byte buffer [ZUUID_LEN]; uuid_enc_be (&buffer, &uuid); zuuid_set (self, buffer); #else // No UUID system calls, so generate a random string byte uuid [ZUUID_LEN]; int fd = open ("/dev/urandom", O_RDONLY); if (fd != -1) { ssize_t bytes_read = read (fd, uuid, ZUUID_LEN); assert (bytes_read == ZUUID_LEN); close (fd); zuuid_set (self, uuid); } else { // We couldn't read /dev/urandom and we have no alternative // strategy zsys_error (strerror (errno)); assert (false); } #endif return self; } // ----------------------------------------------------------------- // Destructor void zuuid_destroy (zuuid_t **self_p) { assert (self_p); if (*self_p) { zuuid_t *self = *self_p; freen (self->str_canonical); freen (self); *self_p = NULL; } } // ----------------------------------------------------------------- // Create UUID object from supplied ZUUID_LEN-octet value zuuid_t * zuuid_new_from (const byte *source) { zuuid_t *self = (zuuid_t *) zmalloc (sizeof (zuuid_t)); assert (self); zuuid_set (self, source); return self; } // ----------------------------------------------------------------- // Set UUID to new supplied ZUUID_LEN-octet value void zuuid_set (zuuid_t *self, const byte *source) { assert (self); memcpy (self->uuid, source, ZUUID_LEN); char hex_char [] = "0123456789ABCDEF"; int byte_nbr; for (byte_nbr = 0; byte_nbr < ZUUID_LEN; byte_nbr++) { uint val = (self->uuid) [byte_nbr]; self->str [byte_nbr * 2 + 0] = hex_char [val >> 4]; self->str [byte_nbr * 2 + 1] = hex_char [val & 15]; } self->str [ZUUID_LEN * 2] = 0; zstr_free (&self->str_canonical); } // ----------------------------------------------------------------- // Set UUID to new supplied string value skipping '-' and '{' '}' // optional delimiters. Return 0 if OK, else returns -1. int zuuid_set_str (zuuid_t *self, const char *source) { assert (self); assert (source); uint byte_nbr = 0; while (*source) { if (*source == '-' || *source == '{' || *source == '}') source++; else { // Get two hex digits uint value; if (sscanf (source, "%02x", &value) != 1) return -1; if (byte_nbr < ZUUID_LEN) { self->uuid [byte_nbr] = (byte) value; self->str [byte_nbr * 2 + 0] = toupper(*source++); self->str [byte_nbr * 2 + 1] = toupper(*source++); byte_nbr++; } else return -1; } } zstr_free (&self->str_canonical); return 0; } // ----------------------------------------------------------------- // Return UUID binary data const byte * zuuid_data (zuuid_t *self) { assert (self); return self->uuid; } // ----------------------------------------------------------------- // Return UUID binary size size_t zuuid_size (zuuid_t *self) { assert (self); return ZUUID_LEN; } // ----------------------------------------------------------------- // Returns UUID as string const char * zuuid_str (zuuid_t *self) { assert (self); return self->str; } // ----------------------------------------------------------------- // Return UUID in the canonical string format: 8-4-4-4-12, in lower // case. Caller does not modify or free returned value. See // http://en.wikipedia.org/wiki/Universally_unique_identifier const char * zuuid_str_canonical (zuuid_t *self) { assert (self); if (!self->str_canonical) self->str_canonical = (char *) zmalloc (8 + 4 + 4 + 4 + 12 + 5); *self->str_canonical = 0; strncat (self->str_canonical, self->str, 8); strcat (self->str_canonical, "-"); strncat (self->str_canonical, self->str + 8, 4); strcat (self->str_canonical, "-"); strncat (self->str_canonical, self->str + 12, 4); strcat (self->str_canonical, "-"); strncat (self->str_canonical, self->str + 16, 4); strcat (self->str_canonical, "-"); strncat (self->str_canonical, self->str + 20, 12); int char_nbr; for (char_nbr = 0; char_nbr < 36; char_nbr++) self->str_canonical [char_nbr] = tolower (self->str_canonical [char_nbr]); return self->str_canonical; } // ----------------------------------------------------------------- // Store UUID blob into a target array void zuuid_export (zuuid_t *self, byte *target) { assert (self); memcpy (target, self->uuid, ZUUID_LEN); } // ----------------------------------------------------------------- // Check if UUID is same as supplied value bool zuuid_eq (zuuid_t *self, const byte *compare) { assert (self); return (memcmp (self->uuid, compare, ZUUID_LEN) == 0); } // ----------------------------------------------------------------- // Check if UUID is different from supplied value bool zuuid_neq (zuuid_t *self, const byte *compare) { assert (self); return (memcmp (self->uuid, compare, ZUUID_LEN) != 0); } // -------------------------------------------------------------------------- // Make copy of UUID object; if uuid is null, or memory was exhausted, // returns null. zuuid_t * zuuid_dup (zuuid_t *self) { if (self) return zuuid_new_from (zuuid_data (self)); else return NULL; } // -------------------------------------------------------------------------- // Print properties of the zuuid object. void zuuid_print (zuuid_t *self) { printf ("%s", zuuid_str_canonical (self)); } // -------------------------------------------------------------------------- // Selftest void zuuid_test (bool verbose) { printf (" * zuuid: "); // @selftest // Simple create/destroy test assert (ZUUID_LEN == 16); assert (ZUUID_STR_LEN == 32); zuuid_t *uuid = zuuid_new (); assert (uuid); assert (zuuid_size (uuid) == ZUUID_LEN); assert (strlen (zuuid_str (uuid)) == ZUUID_STR_LEN); zuuid_t *copy = zuuid_dup (uuid); assert (streq (zuuid_str (uuid), zuuid_str (copy))); // Check set/set_str/export methods const char *myuuid = "8CB3E9A9649B4BEF8DE225E9C2CEBB38"; const char *myuuid2 = "8CB3E9A9-649B-4BEF-8DE2-25E9C2CEBB38"; const char *myuuid3 = "{8CB3E9A9-649B-4BEF-8DE2-25E9C2CEBB38}"; const char *myuuid4 = "8CB3E9A9649B4BEF8DE225E9C2CEBB3838"; int rc = zuuid_set_str (uuid, myuuid); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid2); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid3); assert (rc == 0); assert (streq (zuuid_str (uuid), myuuid)); rc = zuuid_set_str (uuid, myuuid4); assert (rc == -1); byte copy_uuid [ZUUID_LEN]; zuuid_export (uuid, copy_uuid); zuuid_set (uuid, copy_uuid); assert (streq (zuuid_str (uuid), myuuid)); // Check the canonical string format assert (streq (zuuid_str_canonical (uuid), "8cb3e9a9-649b-4bef-8de2-25e9c2cebb38")); zuuid_destroy (&uuid); zuuid_destroy (©); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zloop.c0000664000372000037200000007774713222211156015507 0ustar00travistravis00000000000000/* ========================================================================= zloop - event-driven reactor Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zloop class provides an event-driven reactor pattern. The reactor handles zmq_pollitem_t items (pollers or writers, sockets or fds), and once-off or repeated timers. Its resolution is 1 msec. It uses a tickless timer to reduce CPU interrupts in inactive processes. @discuss @end */ #include "czmq_classes.h" typedef struct _s_reader_t s_reader_t; typedef struct _s_poller_t s_poller_t; typedef struct _s_timer_t s_timer_t; typedef struct _s_ticket_t s_ticket_t; // Structure of our class struct _zloop_t { zlistx_t *readers; // List of socket readers zlistx_t *pollers; // List of poll items zlistx_t *timers; // List of timers zlistx_t *tickets; // List of tickets int last_timer_id; // Most recent timer id size_t max_timers; // Limit on number of timers size_t ticket_delay; // Ticket delay value size_t poll_size; // Size of poll set zmq_pollitem_t *pollset; // zmq_poll set s_reader_t *readact; // Readers for this poll set s_poller_t *pollact; // Pollers for this poll set bool need_rebuild; // True if pollset needs rebuilding bool verbose; // True if verbose tracing wanted bool terminated; // True when stopped running bool nonstop; // Don't stop running on Ctrl-C zlistx_t *zombies; // List of timers to kill }; // Reactor elements are held as structures of their own struct _s_reader_t { void *list_handle; // Handle into list zsock_t *sock; // Socket to read from zloop_reader_fn *handler; // Function to execute void *arg; // Application argument to poll item int errors; // If too many errors, kill reader bool tolerant; // Unless configured as tolerant }; struct _s_poller_t { void *list_handle; // Handle into list zmq_pollitem_t item; // ZeroMQ socket or file descriptor zloop_fn *handler; // Function to execute void *arg; // Application argument to poll item int errors; // If too many errors, kill poller bool tolerant; // Unless configured as tolerant }; struct _s_timer_t { void *list_handle; // Handle into list int timer_id; // Unique timer id, used to cancel timer zloop_timer_fn *handler; // Function to execute size_t delay; // Delay (ms) between executing size_t times; // Number of times to repeat, 0 for forever void *arg; // Application argument to timer int64_t when; // Clock time when alarm goes off }; // As we pass void * to/from the caller for working with tickets, we // check validity using an object tag. This value is unique in CZMQ. #define TICKET_TAG 0x0007cafe struct _s_ticket_t { uint32_t tag; // Object tag for runtime detection void *list_handle; // Handle into list size_t delay; // Delay (ms) before executing int64_t when; // Clock time to invoke the ticket zloop_timer_fn *handler; // Function to execute (use timer fn) void *arg; // Application argument to function bool deleted; // Flag as deleted (to clean up later) }; static int s_next_timer_id (zloop_t *self) { return ++self->last_timer_id; } static s_reader_t * s_reader_new (zsock_t *sock, zloop_reader_fn handler, void *arg) { s_reader_t *self = (s_reader_t *) zmalloc (sizeof (s_reader_t)); assert (self); self->sock = sock; self->handler = handler; self->arg = arg; self->tolerant = false; // By default, errors are bad return self; } static void s_reader_destroy (s_reader_t **self_p) { assert (self_p); s_reader_t *self = *self_p; if (self) { freen (self); *self_p = NULL; } } static s_poller_t * s_poller_new (zmq_pollitem_t *item, zloop_fn handler, void *arg) { s_poller_t *self = (s_poller_t *) zmalloc (sizeof (s_poller_t)); assert (self); self->item = *item; self->handler = handler; self->arg = arg; self->tolerant = false; // By default, errors are bad return self; } static void s_poller_destroy (s_poller_t **self_p) { assert (self_p); s_poller_t *self = *self_p; if (self) { freen (self); *self_p = NULL; } } static s_timer_t * s_timer_new (int timer_id, size_t delay, size_t times, zloop_timer_fn handler, void *arg) { s_timer_t *self = (s_timer_t *) zmalloc (sizeof (s_timer_t)); assert (self); self->timer_id = timer_id; self->delay = delay; self->times = times; self->when = zclock_mono () + delay; self->handler = handler; self->arg = arg; return self; } static void s_timer_destroy (s_timer_t **self_p) { assert (self_p); s_timer_t *self = *self_p; if (self) { freen (self); *self_p = NULL; } } static int s_timer_comparator (s_timer_t *first, s_timer_t *second) { if (first->when > second->when) return 1; else if (first->when < second->when) return -1; else return 0; } static s_ticket_t * s_ticket_new (size_t delay, zloop_timer_fn handler, void *arg) { s_ticket_t *self = (s_ticket_t *) zmalloc (sizeof (s_ticket_t)); assert (self); self->tag = TICKET_TAG; self->delay = delay; self->when = zclock_mono () + delay; self->handler = handler; self->arg = arg; return self; } static void s_ticket_destroy (s_ticket_t **self_p) { assert (self_p); s_ticket_t *self = *self_p; if (self) { self->tag = 0xDeadBeef; freen (self); *self_p = NULL; } } static int s_ticket_comparator (s_ticket_t *first, s_ticket_t *second) { if (first->when > second->when) return 1; else if (first->when < second->when) return -1; else return 0; } // Remove timer with specified id, if it exists static void s_timer_remove (zloop_t *self, int timer_id) { s_timer_t *timer = (s_timer_t *) zlistx_first (self->timers); while (timer) { if (timer->timer_id == timer_id) { zlistx_delete (self->timers, timer->list_handle); break; } timer = (s_timer_t *) zlistx_next (self->timers); } } // We hold an array of pollers that matches the pollset, so we can // register/cancel pollers orthogonally to executing the pollset // activity on pollers. Returns 0 on success, -1 on failure. static int s_rebuild_pollset (zloop_t *self) { self->poll_size = zlistx_size (self->readers) + zlistx_size (self->pollers); freen (self->pollset); self->pollset = (zmq_pollitem_t *) zmalloc (self->poll_size * sizeof (zmq_pollitem_t)); assert (self->pollset); freen (self->readact); self->readact = (s_reader_t *) zmalloc (self->poll_size * sizeof (s_reader_t)); assert (self->readact); freen (self->pollact); self->pollact = (s_poller_t *) zmalloc (self->poll_size * sizeof (s_poller_t)); assert (self->pollact); s_reader_t *reader = (s_reader_t *) zlistx_first (self->readers); uint item_nbr = 0; while (reader) { zmq_pollitem_t poll_item = { zsock_resolve (reader->sock), 0, ZMQ_POLLIN, 0 }; self->pollset [item_nbr] = poll_item; self->readact [item_nbr] = *reader; item_nbr++; reader = (s_reader_t *) zlistx_next (self->readers); } s_poller_t *poller = (s_poller_t *) zlistx_first (self->pollers); while (poller) { self->pollset [item_nbr] = poller->item; self->pollact [item_nbr] = *poller; item_nbr++; poller = (s_poller_t *) zlistx_next (self->pollers); } self->need_rebuild = false; return 0; } static long s_tickless (zloop_t *self) { // Calculate tickless timer, up to 1 hour int64_t tickless = zclock_mono () + 1000 * 3600; // Scan timers, which are not sorted // TODO: sort timers properly on insertion s_timer_t *timer = (s_timer_t *) zlistx_first (self->timers); while (timer) { // Find earliest timer if (tickless > timer->when) tickless = timer->when; timer = (s_timer_t *) zlistx_next (self->timers); } // Tickets are sorted, so check first ticket s_ticket_t *ticket = (s_ticket_t *) zlistx_first (self->tickets); if (ticket && tickless > ticket->when) tickless = ticket->when; long timeout = (long) (tickless - zclock_mono ()); if (timeout < 0) timeout = 0; if (self->verbose) zsys_debug ("zloop polling for %d msec", (int) timeout); return timeout * ZMQ_POLL_MSEC; } // -------------------------------------------------------------------------- // Constructor zloop_t * zloop_new (void) { zloop_t *self = (zloop_t *) zmalloc (sizeof (zloop_t)); assert (self); self->readers = zlistx_new (); assert (self->readers); self->pollers = zlistx_new (); assert (self->pollers); self->timers = zlistx_new (); assert (self->timers); self->zombies = zlistx_new (); assert (self->zombies); self->tickets = zlistx_new (); assert (self->tickets); self->last_timer_id = 0; zlistx_set_destructor (self->readers, (czmq_destructor *) s_reader_destroy); zlistx_set_destructor (self->pollers, (czmq_destructor *) s_poller_destroy); zlistx_set_destructor (self->timers, (czmq_destructor *) s_timer_destroy); zlistx_set_comparator (self->timers, (czmq_comparator *) s_timer_comparator); zlistx_set_destructor (self->tickets, (czmq_destructor *) s_ticket_destroy); zlistx_set_comparator (self->tickets, (czmq_comparator *) s_ticket_comparator); return self; } // -------------------------------------------------------------------------- // Destructor void zloop_destroy (zloop_t **self_p) { assert (self_p); if (*self_p) { zloop_t *self = *self_p; // If we never started the loop, yet manipulated timers, we'll have // a zombie list while (zlistx_first (self->zombies)) { // Get timer_id back from pointer ptrdiff_t timer_id = (byte *) zlistx_detach (self->zombies, NULL) - (byte *) NULL; s_timer_remove (self, (int) timer_id); } zlistx_destroy (&self->zombies); zlistx_destroy (&self->readers); zlistx_destroy (&self->pollers); zlistx_destroy (&self->timers); zlistx_destroy (&self->tickets); freen (self->pollset); freen (self->readact); freen (self->pollact); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Register socket reader with the reactor. When the reader has messages, // the reactor will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the same socket more than once, // each instance will invoke its corresponding handler. int zloop_reader (zloop_t *self, zsock_t *sock, zloop_reader_fn handler, void *arg) { assert (self); assert (sock); s_reader_t *reader = s_reader_new (sock, handler, arg); if (reader) { reader->list_handle = zlistx_add_end (self->readers, reader); assert (reader->list_handle); self->need_rebuild = true; if (self->verbose) zsys_debug ("zloop: register %s reader", zsock_type_str (sock)); return 0; } else return -1; } // -------------------------------------------------------------------------- // Cancel a socket reader from the reactor. If multiple readers exist for // same socket, cancels ALL of them. void zloop_reader_end (zloop_t *self, zsock_t *sock) { assert (self); assert (sock); s_reader_t *reader = (s_reader_t *) zlistx_first (self->readers); while (reader) { if (reader->sock == sock) { zlistx_delete (self->readers, reader->list_handle); self->need_rebuild = true; } reader = (s_reader_t *) zlistx_next (self->readers); } if (self->verbose) zsys_debug ("zloop: cancel %s reader", zsock_type_str (sock)); } // -------------------------------------------------------------------------- // Configure a registered reader to ignore errors. If you do not set this, // then reader that have errors are removed from the reactor silently. void zloop_reader_set_tolerant (zloop_t *self, zsock_t *sock) { assert (self); assert (sock); s_reader_t *reader = (s_reader_t *) zlistx_first (self->readers); while (reader) { if (reader->sock == sock) reader->tolerant = true; reader = (s_reader_t *) zlistx_next (self->readers); } } // -------------------------------------------------------------------------- // Register low-level libzmq pollitem with the reactor. When the pollitem // is ready, will call the handler, passing the arg. Returns 0 if OK, -1 // if there was an error. If you register the pollitem more than once, each // instance will invoke its corresponding handler. A pollitem with // socket=NULL and fd=0 means 'poll on FD zero'. int zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg) { assert (self); if (item->socket && streq (zsys_sockname (zsock_type (item->socket)), "UNKNOWN")) return -1; s_poller_t *poller = s_poller_new (item, handler, arg); assert (poller); poller->list_handle = zlistx_add_end (self->pollers, poller); assert (poller->list_handle); self->need_rebuild = true; if (self->verbose) zsys_debug ("zloop: register %s poller (%p, %d)", item->socket? zsys_sockname (zsock_type (item->socket)): "FD", item->socket, item->fd); return 0; } // -------------------------------------------------------------------------- // Cancel a pollitem from the reactor, specified by socket or FD. If both // are specified, uses only socket. If multiple poll items exist for same // socket/FD, cancels ALL of them. void zloop_poller_end (zloop_t *self, zmq_pollitem_t *item) { assert (self); s_poller_t *poller = (s_poller_t *) zlistx_first (self->pollers); while (poller) { bool match = false; if (item->socket) { if (item->socket == poller->item.socket) match = true; } else { if (item->fd == poller->item.fd) match = true; } if (match) { zlistx_delete (self->pollers, poller->list_handle); // Force rebuild to avoid reading from freed poller self->need_rebuild = true; } poller = (s_poller_t *) zlistx_next (self->pollers); } if (self->verbose) zsys_debug ("zloop: cancel %s poller (%p, %d)", item->socket? zsys_sockname (zsock_type (item->socket)): "FD", item->socket, item->fd); } // -------------------------------------------------------------------------- // Configure a registered poller to ignore errors. If you do not set this, // then poller that have errors are removed from the reactor silently. void zloop_poller_set_tolerant (zloop_t *self, zmq_pollitem_t *item) { assert (self); // Find matching poller(s) and mark as tolerant s_poller_t *poller = (s_poller_t *) zlistx_first (self->pollers); while (poller) { bool match = false; if (item->socket) { if (item->socket == poller->item.socket) match = true; } else { if (item->fd == poller->item.fd) match = true; } if (match) poller->tolerant = true; poller = (s_poller_t *) zlistx_next (self->pollers); } } // -------------------------------------------------------------------------- // Register a timer that expires after some delay and repeats some number of // times. At each expiry, will call the handler, passing the arg. To run a // timer forever, use 0 times. Returns a timer_id that is used to cancel the // timer in the future. Returns -1 if there was an error. int zloop_timer (zloop_t *self, size_t delay, size_t times, zloop_timer_fn handler, void *arg) { assert (self); // Catch excessive use of timers if (self->max_timers && zlistx_size (self->timers) == self->max_timers) { zsys_error ("zloop: timer limit reached (max=%d)", self->max_timers); return -1; } int timer_id = s_next_timer_id (self); s_timer_t *timer = s_timer_new (timer_id, delay, times, handler, arg); if (timer) { timer->list_handle = zlistx_add_end (self->timers, timer); assert (timer->list_handle); if (self->verbose) zsys_debug ("zloop: register timer id=%d delay=%d times=%d", timer_id, (int) delay, (int) times); return timer_id; } else return -1; } // -------------------------------------------------------------------------- // Cancel a timer by timer id (as returned by zloop_timer()). // Returns 0 on success. int zloop_timer_end (zloop_t *self, int timer_id) { assert (self); if (self->terminated) s_timer_remove (self, timer_id); else // We cannot touch self->timers because we may be executing that // from inside the poll loop. So, we hold the arg on the zombie // list, and process that list when we're done executing timers. // This hack lets us store an integer timer ID as a pointer zlistx_add_end (self->zombies, (byte *) NULL + timer_id); if (self->verbose) zsys_debug ("zloop: cancel timer id=%d", timer_id); return 0; } // -------------------------------------------------------------------------- // Register a ticket timer. Ticket timers are very fast in the case where // you use a lot of timers (thousands), and frequently remove and add them. // The main use case is expiry timers for servers that handle many clients, // and which reset the expiry timer for each message received from a client. // Whereas normal timers perform poorly as the number of clients grows, the // cost of ticket timers is constant, no matter the number of clients. You // must set the ticket delay using zloop_set_ticket_delay before creating a // ticket. Returns a handle to the timer that you should use in // zloop_ticket_reset and zloop_ticket_delete. void * zloop_ticket (zloop_t *self, zloop_timer_fn handler, void *arg) { assert (self); assert (self->ticket_delay > 0); s_ticket_t *ticket = s_ticket_new (self->ticket_delay, handler, arg); if (ticket) { ticket->list_handle = zlistx_add_end (self->tickets, ticket); assert (ticket->list_handle); } return ticket; } // -------------------------------------------------------------------------- // Reset a ticket timer, which moves it to the end of the ticket list and // resets its execution time. This is a very fast operation. void zloop_ticket_reset (zloop_t *self, void *handle) { s_ticket_t *ticket = (s_ticket_t *) handle; assert (ticket->tag == TICKET_TAG); ticket->when = zclock_mono () + ticket->delay; zlistx_move_end (self->tickets, ticket->list_handle); } // -------------------------------------------------------------------------- // Delete a ticket timer. We do not actually delete the ticket here, as // other code may still refer to the ticket. We mark as deleted, and remove // later and safely. void zloop_ticket_delete (zloop_t *self, void *handle) { s_ticket_t *ticket = (s_ticket_t *) handle; assert (ticket->tag == TICKET_TAG); ticket->deleted = true; // Move deleted tickets to end of list for fast cleanup zlistx_move_end (self->tickets, ticket->list_handle); } // -------------------------------------------------------------------------- // Set the ticket delay, which applies to all tickets. If you lower the // delay and there are already tickets created, the results are undefined. void zloop_set_ticket_delay (zloop_t *self, size_t ticket_delay) { assert (self); self->ticket_delay = ticket_delay; } // -------------------------------------------------------------------------- // Set verbose tracing of reactor on/off void zloop_set_verbose (zloop_t *self, bool verbose) { assert (self); self->verbose = verbose; } // -------------------------------------------------------------------------- // By default the reactor stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void zloop_set_nonstop (zloop_t *self, bool nonstop) { assert (self); self->nonstop = nonstop; } // -------------------------------------------------------------------------- // Set hard limit on number of timers allowed. Setting more than a small // number of timers (10-100) can have a dramatic impact on the performance // of the reactor. For high-volume cases, use ticket timers. If the hard // limit is reached, the reactor stops creating new timers and logs an // error. void zloop_set_max_timers (zloop_t *self, size_t max_timers) { assert (self); self->max_timers = max_timers; } // -------------------------------------------------------------------------- // Start the reactor. Takes control of the thread and returns when the 0MQ // context is terminated or the process is interrupted, or any event handler // returns -1. Event handlers may register new sockets and timers, and // cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler, // positive on internal error int zloop_start (zloop_t *self) { assert (self); int rc = 0; // Main reactor loop while (!zsys_interrupted || self->nonstop) { if (self->need_rebuild) { // If s_rebuild_pollset() fails, break out of the loop and // return its error rc = s_rebuild_pollset (self); if (rc) break; } rc = zmq_poll (self->pollset, (int) self->poll_size, s_tickless (self)); if (rc == -1 || (zsys_interrupted && !self->nonstop)) { if (self->verbose) zsys_debug ("zloop: interrupted"); rc = 0; break; // Context has been shut down } // Handle any timers that have now expired int64_t time_now = zclock_mono (); s_timer_t *timer = (s_timer_t *) zlistx_first (self->timers); while (timer) { if (time_now >= timer->when) { if (self->verbose) zsys_debug ("zloop: call timer handler id=%d", timer->timer_id); rc = timer->handler (self, timer->timer_id, timer->arg); if (rc == -1) break; // Timer handler signaled break if (timer->times && --timer->times == 0) zlistx_delete (self->timers, timer->list_handle); else timer->when += timer->delay; } timer = (s_timer_t *) zlistx_next (self->timers); } // Handle any tickets that have now expired s_ticket_t *ticket = (s_ticket_t *) zlistx_first (self->tickets); while (ticket && time_now >= ticket->when) { if (self->verbose) zsys_debug ("zloop: call ticket handler"); if (!ticket->deleted && ticket->handler (self, 0, ticket->arg) == -1) { rc = -1; // Trigger exit from zloop_start break; // Ticket handler signaled break } zlistx_delete (self->tickets, ticket->list_handle); ticket = (s_ticket_t *) zlistx_next (self->tickets); } // Handle any tickets that were flagged for deletion ticket = (s_ticket_t *) zlistx_last (self->tickets); while (ticket && ticket->deleted) { zlistx_delete (self->tickets, ticket->list_handle); ticket = (s_ticket_t *) zlistx_last (self->tickets); } // Check if timers changed pollset if (self->need_rebuild) continue; // Handle any readers and pollers that are ready size_t item_nbr; for (item_nbr = 0; item_nbr < self->poll_size && rc >= 0; item_nbr++) { s_reader_t *reader = &self->readact [item_nbr]; if (reader->handler) { if ((self->pollset [item_nbr].revents & ZMQ_POLLERR) && !reader->tolerant) { if (self->verbose) zsys_warning ("zloop: can't read %s socket: %s", zsock_type_str (reader->sock), zmq_strerror (zmq_errno ())); // Give handler one chance to handle error, then kill // reader because it'll disrupt the reactor otherwise. if (reader->errors++) { zloop_reader_end (self, reader->sock); self->pollset [item_nbr].revents = 0; } } else reader->errors = 0; // A non-error happened if (self->pollset [item_nbr].revents) { if (self->verbose) zsys_debug ("zloop: call %s socket handler", zsock_type_str (reader->sock)); rc = reader->handler (self, reader->sock, reader->arg); if (rc == -1 || self->need_rebuild) break; } } else { s_poller_t *poller = &self->pollact [item_nbr]; assert (self->pollset [item_nbr].socket == poller->item.socket); if ((self->pollset [item_nbr].revents & ZMQ_POLLERR) && !poller->tolerant) { if (self->verbose) zsys_warning ("zloop: can't poll %s socket (%p, %d): %s", poller->item.socket? zsys_sockname (zsock_type (poller->item.socket)): "FD", poller->item.socket, poller->item.fd, zmq_strerror (zmq_errno ())); // Give handler one chance to handle error, then kill // poller because it'll disrupt the reactor otherwise. if (poller->errors++) { zloop_poller_end (self, &poller->item); self->pollset [item_nbr].revents = 0; } } else poller->errors = 0; // A non-error happened if (self->pollset [item_nbr].revents) { if (self->verbose) zsys_debug ("zloop: call %s socket handler (%p, %d)", poller->item.socket? zsys_sockname (zsock_type (poller->item.socket)): "FD", poller->item.socket, poller->item.fd); rc = poller->handler (self, &self->pollset [item_nbr], poller->arg); if (rc == -1 || self->need_rebuild) break; } } } // Now handle any timer zombies // This is going to be slow if we have many timers; we might use // a faster lookup on the timer list. while (zlistx_first (self->zombies)) { // Get timer_id back from pointer ptrdiff_t timer_id = (byte *) zlistx_detach (self->zombies, NULL) - (byte *) NULL; s_timer_remove (self, (int) timer_id); } if (rc == -1) break; } self->terminated = true; return rc; } // -------------------------------------------------------------------------- // Selftest static int s_cancel_timer_event (zloop_t *loop, int timer_id, void *arg) { // We are handling timer 2, and will cancel timer 1 int cancel_timer_id = *((int *) arg); return zloop_timer_end (loop, cancel_timer_id); } static int s_timer_event (zloop_t *loop, int timer_id, void *output) { zstr_send (output, "PING"); return 0; } static int s_socket_event (zloop_t *loop, zsock_t *handle, void *arg) { // Just end the reactor return -1; } static int s_timer_event3 (zloop_t *loop, int timer_id, void *called) { *((bool*) called) = true; // end the reactor return -1; } static int s_socket_event1 (zloop_t *loop, zsock_t *reader, void *called) { *((bool*) called) = true; // end the reactor return -1; } static int s_timer_event4 (zloop_t *loop, int timer_id, void *arg) { // Just end the looper return -1; } static int s_timer_event5 (zloop_t *loop, int timer_id, void *arg) { // remove reader from loop zloop_reader_end(loop, (zsock_t *) arg); // end reactor on next run zloop_timer(loop, 1, 1, s_timer_event4, NULL); return 0; } void zloop_test (bool verbose) { printf (" * zloop: "); int rc = 0; // @selftest // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new (ZMQ_PAIR); assert (output); zsock_bind (output, "inproc://zloop.test"); zsock_t *input = zsock_new (ZMQ_PAIR); assert (input); zsock_connect (input, "inproc://zloop.test"); zloop_t *loop = zloop_new (); assert (loop); zloop_set_verbose (loop, verbose); // Create a timer that will be cancelled int timer_id = zloop_timer (loop, 1000, 1, s_timer_event, NULL); zloop_timer (loop, 5, 1, s_cancel_timer_event, &timer_id); // After 20 msecs, send a ping message to output3 zloop_timer (loop, 20, 1, s_timer_event, output); // Set up some tickets that will never expire zloop_set_ticket_delay (loop, 10000); void *ticket1 = zloop_ticket (loop, s_timer_event, NULL); void *ticket2 = zloop_ticket (loop, s_timer_event, NULL); void *ticket3 = zloop_ticket (loop, s_timer_event, NULL); // When we get the ping message, end the reactor rc = zloop_reader (loop, input, s_socket_event, NULL); assert (rc == 0); zloop_reader_set_tolerant (loop, input); zloop_start (loop); zloop_ticket_delete (loop, ticket1); zloop_ticket_delete (loop, ticket2); zloop_ticket_delete (loop, ticket3); // Check whether loop properly ignores zsys_interrupted flag // when asked to zloop_destroy (&loop); loop = zloop_new (); bool timer_event_called = false; zloop_timer (loop, 1, 1, s_timer_event3, &timer_event_called); zsys_interrupted = 1; zloop_start (loop); // zloop returns immediately without giving any handler a chance to run assert (!timer_event_called); zloop_set_nonstop (loop, true); zloop_start (loop); // zloop runs the handler which will terminate the loop assert (timer_event_called); zsys_interrupted = 0; // Check if reader removed in timer is not called zloop_destroy (&loop); loop = zloop_new (); bool socket_event_called = false; zloop_reader (loop, output, s_socket_event1, &socket_event_called); zloop_timer (loop, 0, 1, s_timer_event5, output); zstr_send (input, "PING"); zloop_start (loop); assert (!socket_event_called); // cleanup zloop_destroy (&loop); assert (loop == NULL); zsock_destroy (&input); zsock_destroy (&output); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zbeacon.c0000664000372000037200000005671713222211156015757 0ustar00travistravis00000000000000/* ========================================================================= zbeacon - LAN discovery and presence Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zbeacon class implements a peer-to-peer discovery service for local networks. A beacon can broadcast and/or capture service announcements using UDP messages on the local area network. This implementation uses IPv4 UDP broadcasts. You can define the format of your outgoing beacons, and set a filter that validates incoming beacons. Beacons are sent and received asynchronously in the background. @discuss This class replaces zbeacon_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). @end */ #include "czmq_classes.h" // Constants #define INTERVAL_DFLT 1000 // Default interval = 1 second // -------------------------------------------------------------------------- // The self_t structure holds the state for one actor instance typedef struct { zsock_t *pipe; // Actor command pipe SOCKET udpsock; // UDP socket for send/recv SOCKET udpsock_send; // UDP socket for IPv6 send char port_nbr [7]; // UDP port number we work on int interval; // Beacon broadcast interval int64_t ping_at; // Next broadcast time zframe_t *transmit; // Beacon transmit data zframe_t *filter; // Beacon filter data inaddr_storage_t broadcast; // Our broadcast address bool terminated; // Did caller ask us to quit? bool verbose; // Verbose logging enabled? char hostname [NI_MAXHOST]; // Saved host name } self_t; static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; zframe_destroy (&self->transmit); zframe_destroy (&self->filter); if (self->udpsock) // don't close STDIN zsys_udp_close (self->udpsock); freen (self); *self_p = NULL; } } static self_t * s_self_new (zsock_t *pipe) { self_t *self = (self_t *) zmalloc (sizeof (self_t)); assert (self); self->pipe = pipe; return self; } // -------------------------------------------------------------------------- // Prepare beacon to work on specified UPD port. static void s_self_prepare_udp (self_t *self) { // Create our UDP socket if (self->udpsock) zsys_udp_close (self->udpsock); if (self->udpsock_send) zsys_udp_close (self->udpsock_send); self->hostname [0] = 0; // For IPv6 we need two sockets. At least on Linux, IPv6 multicast packets // are NOT received despite joining the group and setting the interface // option UNLESS the socket is bound to in6_addrany, which means the kernel // will select an arbitrary IP address as the source when sending beacons // out. This breaks zbeacon as the protocol uses the source address of a // beacon to find the endpoint of a peer, which is then random and // useless (could even be associated with a different interface, eg: a // virtual bridge). // As a workaround, use a different socket to send packets. So the socket // that receives can be bound to in6_addrany, and the socket that sends // can be bound to the actual intended host address. self->udpsock = zsys_udp_new (false); if (self->udpsock == INVALID_SOCKET) { self->udpsock_send = INVALID_SOCKET; return; } self->udpsock_send = zsys_udp_new (false); if (self->udpsock_send == INVALID_SOCKET) { zsys_udp_close (self->udpsock); self->udpsock = INVALID_SOCKET; return; } // Get the network interface fro ZSYS_INTERFACE or else use first // broadcast interface defined on system. ZSYS_INTERFACE=* means // use INADDR_ANY + INADDR_BROADCAST. const char *iface = zsys_interface (); struct addrinfo *bind_to = NULL; struct addrinfo *send_to = NULL; struct addrinfo hint; memset (&hint, 0, sizeof(struct addrinfo)); hint.ai_flags = AI_NUMERICHOST; #if !defined (CZMQ_HAVE_ANDROID) && !defined (CZMQ_HAVE_FREEBSD) hint.ai_flags |= AI_V4MAPPED; #endif hint.ai_socktype = SOCK_DGRAM; hint.ai_protocol = IPPROTO_UDP; hint.ai_family = zsys_ipv6 () ? AF_INET6 : AF_INET; int rc; int found_iface = 0; unsigned int if_index = 0; if (streq (iface, "*")) { // Wildcard means bind to INADDR_ANY and send to INADDR_BROADCAST // IE - getaddrinfo with NULL as first parameter or 255.255.255.255 // (or IPv6 multicast link-local all-node group ff02::1 hint.ai_flags = hint.ai_flags | AI_PASSIVE; rc = getaddrinfo (NULL, self->port_nbr, &hint, &bind_to); assert (rc == 0); if (zsys_ipv6()) { // Default is link-local all-node multicast group rc = getaddrinfo (zsys_ipv6_mcast_address (), self->port_nbr, &hint, &send_to); assert (rc == 0); } else { rc = getaddrinfo ("255.255.255.255", self->port_nbr, &hint, &send_to); assert (rc == 0); } found_iface = 1; } // if ZSYS_INTERFACE is a single digit, use the corresponding interface in // the interface list else if (strlen (iface) == 1 && iface[0] >= '0' && iface[0] <= '9') { int if_number = atoi (iface); ziflist_t *iflist = ziflist_new_ipv6 (); assert (iflist); const char *name = ziflist_first (iflist); int idx = -1; while (name) { idx++; if (idx == if_number && ((ziflist_is_ipv6 (iflist) && zsys_ipv6 ()) || (!ziflist_is_ipv6 (iflist) && !zsys_ipv6 ()))) { // Using inet_addr instead of inet_aton or inet_atop // because these are not supported in Win XP rc = getaddrinfo (ziflist_address (iflist), self->port_nbr, &hint, &bind_to); assert (rc == 0); rc = getaddrinfo (ziflist_broadcast (iflist), self->port_nbr, &hint, &send_to); assert (rc == 0); if_index = if_nametoindex (name); if (self->verbose) zsys_info ("zbeacon: interface=%s address=%s broadcast=%s", name, ziflist_address (iflist), ziflist_broadcast (iflist)); found_iface = 1; break; // iface is known, so allow it } name = ziflist_next (iflist); } ziflist_destroy (&iflist); } else if (zsys_ipv6 () && strneq("", zsys_ipv6_address ()) && strneq (iface, "")) { rc = getaddrinfo (zsys_ipv6_address (), self->port_nbr, &hint, &bind_to); assert (rc == 0); // A user might set a link-local address without appending %iface if (IN6_IS_ADDR_LINKLOCAL (&((in6addr_t *)bind_to->ai_addr)->sin6_addr) && !strchr (zsys_ipv6_address (), '%')) { char address_and_iface [NI_MAXHOST] = {0}; strcat (address_and_iface, zsys_ipv6_address ()); strcat (address_and_iface, "%"); strcat (address_and_iface, iface); rc = getaddrinfo (address_and_iface, self->port_nbr, &hint, &bind_to); assert (rc == 0); } rc = getaddrinfo (zsys_ipv6_mcast_address (), self->port_nbr, &hint, &send_to); assert (rc == 0); if_index = if_nametoindex (iface); if (self->verbose) zsys_info ("zbeacon: interface=%s address=%s broadcast=%s", iface, zsys_ipv6_address (), zsys_ipv6_mcast_address ()); found_iface = 1; } else { // Look for matching interface, or first ziflist item ziflist_t *iflist = ziflist_new_ipv6 (); assert (iflist); const char *name = ziflist_first (iflist); while (name) { // If IPv6 is not enabled ignore IPv6 interfaces. if ((streq (iface, name) || streq (iface, "")) && ((ziflist_is_ipv6 (iflist) && zsys_ipv6 ()) || (!ziflist_is_ipv6 (iflist) && !zsys_ipv6 ()))) { rc = getaddrinfo (ziflist_address (iflist), self->port_nbr, &hint, &bind_to); assert (rc == 0); rc = getaddrinfo (ziflist_broadcast (iflist), self->port_nbr, &hint, &send_to); assert (rc == 0); if_index = if_nametoindex (name); if (self->verbose) zsys_info ("zbeacon: interface=%s address=%s broadcast=%s", name, ziflist_address (iflist), ziflist_broadcast (iflist)); found_iface = 1; break; // iface is known, so allow it } name = ziflist_next (iflist); } ziflist_destroy (&iflist); } if (found_iface) { inaddr_storage_t bind_address; // On Windows we bind to the host address // On *NIX we bind to INADDR_ANY or in6addr_any, otherwise multicast // packets will be filtered out despite joining the group #if (defined (__WINDOWS__)) memcpy (&bind_address, bind_to->ai_addr, bind_to->ai_addrlen); #else memcpy (&bind_address, send_to->ai_addr, send_to->ai_addrlen); if (zsys_ipv6 ()) bind_address.__inaddr_u.__addr6.sin6_addr = in6addr_any; else bind_address.__inaddr_u.__addr.sin_addr.s_addr = htonl (INADDR_ANY); #endif memcpy (&self->broadcast, send_to->ai_addr, send_to->ai_addrlen); if (zsys_ipv6()) { struct ipv6_mreq mreq; mreq.ipv6mr_interface = if_index; memcpy (&mreq.ipv6mr_multiaddr, &(((in6addr_t *)(send_to->ai_addr))->sin6_addr), sizeof (struct in6_addr)); if (setsockopt (self->udpsock, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *)&mreq, sizeof (mreq))) zsys_socket_error ("zbeacon: setsockopt IPV6_JOIN_GROUP failed"); if (setsockopt (self->udpsock, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char *)&if_index, sizeof (if_index))) zsys_socket_error ("zbeacon: setsockopt IPV6_MULTICAST_IF failed"); if (setsockopt (self->udpsock_send, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *)&mreq, sizeof (mreq))) zsys_socket_error ("zbeacon: setsockopt IPV6_JOIN_GROUP failed"); if (setsockopt (self->udpsock_send, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char *)&if_index, sizeof (if_index))) zsys_socket_error ("zbeacon: setsockopt IPV6_MULTICAST_IF failed"); } // If bind fails, we close the socket for opening again later (next poll interval) if (bind (self->udpsock_send, bind_to->ai_addr, bind_to->ai_addrlen) || bind (self->udpsock, (struct sockaddr *)&bind_address, zsys_ipv6 () ? sizeof (in6addr_t) : sizeof (inaddr_t))) { zsys_debug ("zbeacon: Unable to bind to broadcast address, reason=%s", strerror (errno)); zsys_udp_close (self->udpsock); self->udpsock = INVALID_SOCKET; zsys_udp_close (self->udpsock_send); self->udpsock_send = INVALID_SOCKET; } else if (streq (iface, "*")) { strcpy(self->hostname, "*"); if (self->verbose) zsys_info ("zbeacon: configured, hostname=%s", self->hostname); } else if (getnameinfo (bind_to->ai_addr, bind_to->ai_addrlen, self->hostname, NI_MAXHOST, NULL, 0, NI_NUMERICHOST) == 0) { if (self->verbose) zsys_info ("zbeacon: configured, hostname=%s", self->hostname); } } else { // No valid interface. Close the socket so that we can try again later zsys_udp_close(self->udpsock); self->udpsock = INVALID_SOCKET; zsys_udp_close (self->udpsock_send); self->udpsock_send = INVALID_SOCKET; } freeaddrinfo (bind_to); freeaddrinfo (send_to); } // -------------------------------------------------------------------------- // Prepare beacon to work on specified UPD port, reply hostname to // pipe (or "" if this failed) static void s_self_configure (self_t *self, int port_nbr) { assert (port_nbr); snprintf (self->port_nbr, 7, "%d", port_nbr); s_self_prepare_udp (self); zstr_send (self->pipe, self->hostname); if (streq (self->hostname, "")) zsys_error ("No broadcast interface found, (ZSYS_INTERFACE=%s)", zsys_interface ()); } // -------------------------------------------------------------------------- // Handle a command from calling application static int s_self_handle_pipe (self_t *self) { // Get just the command off the pipe char *command = zstr_recv (self->pipe); if (!command) return -1; // Interrupted if (self->verbose) zsys_info ("zbeacon: API command=%s", command); if (streq (command, "VERBOSE")) self->verbose = true; else if (streq (command, "CONFIGURE")) { int port; int rc = zsock_recv (self->pipe, "i", &port); assert (rc == 0); s_self_configure (self, port); } else if (streq (command, "PUBLISH")) { zframe_destroy (&self->transmit); zsock_recv (self->pipe, "fi", &self->transmit, &self->interval); assert (zframe_size (self->transmit) <= UDP_FRAME_MAX); if (self->interval == 0) self->interval = INTERVAL_DFLT; // Start broadcasting immediately self->ping_at = zclock_mono (); } else if (streq (command, "SILENCE")) zframe_destroy (&self->transmit); else if (streq (command, "SUBSCRIBE")) { zframe_destroy (&self->filter); self->filter = zframe_recv (self->pipe); assert (zframe_size (self->filter) <= UDP_FRAME_MAX); } else if (streq (command, "UNSUBSCRIBE")) zframe_destroy (&self->filter); else if (streq (command, "$TERM")) self->terminated = true; else { zsys_error ("zbeacon: - invalid command: %s", command); assert (false); } zstr_free (&command); return 0; } // -------------------------------------------------------------------------- // Receive and filter the waiting beacon static void s_self_handle_udp (self_t *self) { assert (self); char peername [NI_MAXHOST]; zframe_t *frame = zsys_udp_recv (self->udpsock, peername, NI_MAXHOST); if (!frame) return; // If filter is set, check that beacon matches it bool is_valid = false; if (self->filter) { byte *filter_data = zframe_data (self->filter); size_t filter_size = zframe_size (self->filter); if (zframe_size (frame) >= filter_size && memcmp (zframe_data (frame), filter_data, filter_size) == 0) is_valid = true; } // If valid, discard our own broadcasts, which UDP echoes to us if (is_valid && self->transmit) { byte *transmit_data = zframe_data (self->transmit); size_t transmit_size = zframe_size (self->transmit); if (zframe_size (frame) == transmit_size && memcmp (zframe_data (frame), transmit_data, transmit_size) == 0) is_valid = false; } // If still a valid beacon, send on to the API if (is_valid) { zmsg_t *msg = zmsg_new (); assert (msg); zmsg_addstr (msg, peername); zmsg_append (msg, &frame); if (zmsg_send (&msg, self->pipe) < 0) zmsg_destroy (&msg); } else zframe_destroy (&frame); } // -------------------------------------------------------------------------- // Send the beacon over UDP static int s_emit_beacon (self_t *self) { #if defined (__WINDOWS__) // Windows doesn't broadcast on all interfaces when using INADDR_BROADCAST // only the interface with the highest metric (as seen in `route print`) // so send a packet per interface to each broadcast address if (streq (zsys_interface (), "*") && !zsys_ipv6 ()) { INTERFACE_INFO interface_list [64]; DWORD bytes_received = 0; int rc = WSAIoctl (self->udpsock, SIO_GET_INTERFACE_LIST, 0, 0, &interface_list, sizeof (interface_list), &bytes_received, NULL, NULL); assert (rc != SOCKET_ERROR); int num_interfaces = bytes_received / sizeof (INTERFACE_INFO); // iiBroadcastAddress is always 255.255.255.255 need to calculate the specific broadcast address using the netmask // keep the same parameters as self->broadcast but just replace the address for each interface inaddr_t addr; memcpy(&addr, &self->broadcast, sizeof (inaddr_t)); for (int i = 0; i < num_interfaces; ++i) { addr.sin_addr.S_un.S_addr = (interface_list[i].iiAddress.AddressIn.sin_addr.S_un.S_addr | ~(interface_list[i].iiNetmask.AddressIn.sin_addr.S_un.S_addr)); if (zsys_udp_send (self->udpsock_send, self->transmit, (inaddr_t *)&addr, sizeof (inaddr_t))) { // Send failed, cause zbeacon to re-init socket return -1; } } return 0; } #endif return zsys_udp_send (self->udpsock_send, self->transmit, (inaddr_t *)&self->broadcast, zsys_ipv6 () ? sizeof (in6addr_t) : sizeof (inaddr_t)); } // -------------------------------------------------------------------------- // zbeacon() implements the zbeacon actor interface void zbeacon (zsock_t *pipe, void *args) { self_t *self = s_self_new (pipe); assert (self); // Signal successful initialization zsock_signal (pipe, 0); while (!self->terminated) { // Poll on API pipe and on UDP socket zmq_pollitem_t pollitems [] = { { zsock_resolve (self->pipe), 0, ZMQ_POLLIN, 0 }, { NULL, self->udpsock, ZMQ_POLLIN, 0 } }; long timeout = -1; if (self->transmit) { timeout = (long) (self->ping_at - zclock_mono ()); if (timeout < 0) timeout = 0; } int pollset_size = (self->udpsock && self->udpsock != INVALID_SOCKET) ? 2: 1; if (zmq_poll (pollitems, pollset_size, timeout * ZMQ_POLL_MSEC) == -1) break; // Interrupted if (pollitems [0].revents & ZMQ_POLLIN) s_self_handle_pipe (self); if (pollitems [1].revents & ZMQ_POLLIN) s_self_handle_udp (self); if (self->transmit && zclock_mono () >= self->ping_at) { // Send beacon to any listening peers if (!self->udpsock_send || self->udpsock_send == INVALID_SOCKET || s_emit_beacon(self)) { const char *reason = (!self->udpsock_send || self->udpsock_send == INVALID_SOCKET) ? "invalid socket" : strerror (errno); zsys_debug ("zbeacon: failed to transmit, attempting reconnection. reason=%s", reason); // Try to recreate UDP socket on interface s_self_prepare_udp (self); } self->ping_at = zclock_mono () + self->interval; } } s_self_destroy (&self); } // -------------------------------------------------------------------------- // Selftest void zbeacon_test (bool verbose) { printf (" * zbeacon: "); if (verbose) printf ("\n"); // @selftest // Test 1 - two beacons, one speaking, one listening // Create speaker beacon to broadcast our service zactor_t *speaker = zactor_new (zbeacon, NULL); assert (speaker); if (verbose) zstr_sendx (speaker, "VERBOSE", NULL); zsock_send (speaker, "si", "CONFIGURE", 9999); char *hostname = zstr_recv (speaker); if (!*hostname) { printf ("OK (skipping test, no UDP broadcasting)\n"); zactor_destroy (&speaker); freen (hostname); return; } freen (hostname); // Create listener beacon on port 9999 to lookup service zactor_t *listener = zactor_new (zbeacon, NULL); assert (listener); if (verbose) zstr_sendx (listener, "VERBOSE", NULL); zsock_send (listener, "si", "CONFIGURE", 9999); hostname = zstr_recv (listener); assert (*hostname); freen (hostname); // We will broadcast the magic value 0xCAFE byte announcement [2] = { 0xCA, 0xFE }; zsock_send (speaker, "sbi", "PUBLISH", announcement, 2, 100); // We will listen to anything (empty subscription) zsock_send (listener, "sb", "SUBSCRIBE", "", 0); // Wait for at most 1/2 second if there's no broadcasting zsock_set_rcvtimeo (listener, 500); char *ipaddress = zstr_recv (listener); if (ipaddress) { zframe_t *content = zframe_recv (listener); assert (zframe_size (content) == 2); assert (zframe_data (content) [0] == 0xCA); assert (zframe_data (content) [1] == 0xFE); zframe_destroy (&content); zstr_free (&ipaddress); zstr_sendx (speaker, "SILENCE", NULL); } zactor_destroy (&listener); zactor_destroy (&speaker); // Test subscription filter using a 3-node setup zactor_t *node1 = zactor_new (zbeacon, NULL); assert (node1); zsock_send (node1, "si", "CONFIGURE", 5670); hostname = zstr_recv (node1); assert (*hostname); freen (hostname); zactor_t *node2 = zactor_new (zbeacon, NULL); assert (node2); zsock_send (node2, "si", "CONFIGURE", 5670); hostname = zstr_recv (node2); assert (*hostname); freen (hostname); zactor_t *node3 = zactor_new (zbeacon, NULL); assert (node3); zsock_send (node3, "si", "CONFIGURE", 5670); hostname = zstr_recv (node3); assert (*hostname); freen (hostname); zsock_send (node1, "sbi", "PUBLISH", "NODE/1", 6, 250); zsock_send (node2, "sbi", "PUBLISH", "NODE/2", 6, 250); zsock_send (node3, "sbi", "PUBLISH", "RANDOM", 6, 250); zsock_send (node1, "sb", "SUBSCRIBE", "NODE", 4); // Poll on three API sockets at once zpoller_t *poller = zpoller_new (node1, node2, node3, NULL); assert (poller); int64_t stop_at = zclock_mono () + 1000; while (zclock_mono () < stop_at) { long timeout = (long) (stop_at - zclock_mono ()); if (timeout < 0) timeout = 0; void *which = zpoller_wait (poller, timeout * ZMQ_POLL_MSEC); if (which) { assert (which == node1); char *ipaddress, *received; zstr_recvx (node1, &ipaddress, &received, NULL); assert (streq (received, "NODE/2")); zstr_free (&ipaddress); zstr_free (&received); } } zpoller_destroy (&poller); // Stop listening zstr_sendx (node1, "UNSUBSCRIBE", NULL); // Stop all node broadcasts zstr_sendx (node1, "SILENCE", NULL); zstr_sendx (node2, "SILENCE", NULL); zstr_sendx (node3, "SILENCE", NULL); // Destroy the test nodes zactor_destroy (&node1); zactor_destroy (&node2); zactor_destroy (&node3); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/ziflist.c0000664000372000037200000004032113222211156016002 0ustar00travistravis00000000000000/* ========================================================================= ziflist - list of network interfaces available on system Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The ziflist class takes a snapshot of the network interfaces that the system currently supports (this can change arbitrarily, especially on mobile devices). The caller can then access the network interface information using an iterator that works like zlistx. Only stores those interfaces with broadcast capability, and ignores the loopback interface. @discuss @end */ #include "czmq_classes.h" // Structure of an interface typedef struct { char *name; char *address; char *netmask; char *broadcast; bool is_ipv6; } interface_t; // -------------------------------------------------------------------------- // interface destructor static void s_interface_destroy (interface_t **self_p) { assert (self_p); interface_t *self = *self_p; if (self) { freen (self->name); freen (self->address); freen (self->netmask); freen (self->broadcast); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // interface constructor static interface_t * s_interface_new (char *name, struct sockaddr *address, struct sockaddr *netmask, struct sockaddr *broadcast) { char hbuf[NI_MAXHOST]; int rc; interface_t *self = (interface_t *) zmalloc (sizeof (interface_t)); assert (self); self->name = strdup (name); assert (self->name); rc = getnameinfo (address, address->sa_family == AF_INET ? sizeof (struct sockaddr_in) : sizeof (struct sockaddr_in6), hbuf, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); assert (rc == 0); // Some platform's getnameinfo, like Solaris, appear not to append the // interface name when parsing a link-local IPv6 address. These addresses // cannot be used without the interface, so we must append it manually. if (address->sa_family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL (&((struct sockaddr_in6 *)address)->sin6_addr) && !strchr (hbuf, '%')) { strcat (hbuf, "%"); strcat (hbuf, name); } self->address = strdup (hbuf); assert (self->address); rc = getnameinfo (netmask, netmask->sa_family == AF_INET ? sizeof (struct sockaddr_in) : sizeof (struct sockaddr_in6), hbuf, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); assert (rc == 0); self->netmask = strdup (hbuf); assert (self->netmask); if (address->sa_family == AF_INET) { // If the returned broadcast address is the same as source // address, build the broadcast address from the source // address and netmask. if (((inaddr_t *)address)->sin_addr.s_addr == ((inaddr_t *)broadcast)->sin_addr.s_addr) ((inaddr_t *)broadcast)->sin_addr.s_addr |= ~(((inaddr_t *)netmask)->sin_addr.s_addr); rc = getnameinfo (broadcast, sizeof (struct sockaddr_in), hbuf, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); assert (rc == 0); self->broadcast = strdup (hbuf); assert (self->broadcast); } else { // The default is link-local all-node multicast group fe02::1 self->broadcast = strdup (zsys_ipv6_mcast_address ()); assert (self->broadcast); } self->is_ipv6 = address->sa_family == AF_INET6 ? true : false; return self; } // Structure of our class struct _ziflist_t; // -------------------------------------------------------------------------- // Get a list of network interfaces currently defined on the system ziflist_t * ziflist_new (void) { ziflist_t *self = (ziflist_t *) zlistx_new (); assert (self); zlistx_set_destructor ((zlistx_t *) self, (czmq_destructor *) s_interface_destroy); ziflist_reload (self); return self; } // -------------------------------------------------------------------------- // Get a list of network interfaces currently defined on the system // Includes IPv6 interfaces ziflist_t * ziflist_new_ipv6 (void) { ziflist_t *self = (ziflist_t *) zlistx_new (); assert (self); zlistx_set_destructor ((zlistx_t *) self, (czmq_destructor *) s_interface_destroy); ziflist_reload_ipv6 (self); return self; } // Print properties of the ziflist object. // -------------------------------------------------------------------------- void ziflist_print (ziflist_t *self) { interface_t *iface; for (iface = (interface_t *) zlistx_first ((zlistx_t *) self); iface != NULL; iface = (interface_t *) zlistx_next ((zlistx_t *) self)) { zsys_info (" - interface name : %s", iface->name); zsys_info (" - interface address : %s", iface->address); zsys_info (" - interface netmask : %s", iface->netmask); zsys_info (" - interface broadcast : %s", iface->broadcast); } } // -------------------------------------------------------------------------- // Destroy a ziflist instance void ziflist_destroy (ziflist_t **self_p) { zlistx_destroy ((zlistx_t **) self_p); } #ifdef __UNIX__ // -------------------------------------------------------------------------- // Helper function to verify if one interface's flags are what we want. static bool s_valid_flags (short flags, bool ipv6) { return (flags & IFF_UP) // Only use interfaces that are running && !(flags & IFF_LOOPBACK) // Ignore loopback interface && ((ipv6 || (flags & IFF_BROADCAST)) // Only use interfaces that have BROADCAST && (!ipv6 || (flags & IFF_MULTICAST))) // or IPv6 and MULTICAST # if defined (IFF_SLAVE) && !(flags & IFF_SLAVE) // Ignore devices that are bonding slaves. # endif && !(flags & IFF_POINTOPOINT); // Ignore point to point interfaces. } #endif // -------------------------------------------------------------------------- // Helper to reload network interfaces from system static void s_reload (ziflist_t *self, bool ipv6) { assert (self); zlistx_t *list = (zlistx_t *) self; zlistx_purge (list); #if defined (HAVE_GETIFADDRS) struct ifaddrs *interfaces; if (getifaddrs (&interfaces) == 0) { struct ifaddrs *interface = interfaces; while (interface) { // On Solaris, loopback interfaces have a NULL in ifa_broadaddr if (interface->ifa_addr && (interface->ifa_broadaddr || (ipv6 && (interface->ifa_addr->sa_family == AF_INET6))) &&(interface->ifa_addr->sa_family == AF_INET || (ipv6 && (interface->ifa_addr->sa_family == AF_INET6))) // Seems to be needed for running VirtualBox VMs on MacOS (see #1802) &&(interface->ifa_netmask->sa_family == AF_INET || (ipv6 && (interface->ifa_netmask->sa_family == AF_INET6))) && s_valid_flags (interface->ifa_flags, ipv6 && (interface->ifa_addr->sa_family == AF_INET6))) { interface_t *item = s_interface_new (interface->ifa_name, interface->ifa_addr, interface->ifa_netmask, interface->ifa_broadaddr); if (item) zlistx_add_end (list, item); } interface = interface->ifa_next; } } freeifaddrs (interfaces); # elif defined (__UNIX__) int sock = socket (AF_INET, SOCK_DGRAM, 0); if (sock != -1) { int num_interfaces = 0; struct ifconf ifconfig = { 0 }; // First ioctl call gets us length of buffer; second call gets us contents if (!ioctl (sock, SIOCGIFCONF, (caddr_t) &ifconfig, sizeof (struct ifconf))) { ifconfig.ifc_buf = (char *) zmalloc (ifconfig.ifc_len); if (!ioctl (sock, SIOCGIFCONF, (caddr_t) &ifconfig, sizeof (struct ifconf))) num_interfaces = ifconfig.ifc_len / sizeof (struct ifreq); } int index; for (index = 0; index < num_interfaces; index++) { struct ifreq *ifr = &ifconfig.ifc_req [index]; // Check interface flags bool is_valid = false; // Get interface properties inaddr_t address = { 0 }; if (!ioctl (sock, SIOCGIFADDR, (caddr_t) ifr, sizeof (struct ifreq))) address = *((inaddr_t *) &ifr->ifr_addr); else is_valid = false; if (!ioctl (sock, SIOCGIFFLAGS, (caddr_t) ifr, sizeof (struct ifreq))) is_valid = s_valid_flags (ifr->ifr_flags, ipv6 && (address.sin_family == AF_INET6)); inaddr_t broadcast = { 0 }; if (!ioctl (sock, SIOCGIFBRDADDR, (caddr_t) ifr, sizeof (struct ifreq))) broadcast = *((inaddr_t *) &ifr->ifr_addr); else is_valid = false; inaddr_t netmask = { 0 }; if (!ioctl (sock, SIOCGIFNETMASK, (caddr_t) ifr, sizeof (struct ifreq))) netmask = *((inaddr_t *) &ifr->ifr_addr); else is_valid = false; if (is_valid) { interface_t *item = s_interface_new (ifr->ifr_name, (struct sockaddr *)&address, (struct sockaddr *)&netmask, (struct sockaddr *)&broadcast); if (item) zlistx_add_end (list, item); } } freen (ifconfig.ifc_buf); close (sock); } # elif defined (__WINDOWS__) // TODO: IPv6 support ULONG addr_size = 0; DWORD rc = GetAdaptersAddresses (AF_INET, GAA_FLAG_INCLUDE_PREFIX, NULL, NULL, &addr_size); assert (rc == ERROR_BUFFER_OVERFLOW); static const int maxTries = 3; int iterations = 0; PIP_ADAPTER_ADDRESSES pip_addresses = NULL; do { pip_addresses = (PIP_ADAPTER_ADDRESSES) zmalloc (addr_size); rc = GetAdaptersAddresses (AF_INET, GAA_FLAG_INCLUDE_PREFIX, NULL, pip_addresses, &addr_size); if (rc == ERROR_BUFFER_OVERFLOW) { freen (pip_addresses); pip_addresses = NULL; } else { break; } ++iterations; } while ((rc == ERROR_BUFFER_OVERFLOW) && (iterations < maxTries)); assert (rc == NO_ERROR); PIP_ADAPTER_ADDRESSES cur_address = pip_addresses; while (cur_address) { PIP_ADAPTER_UNICAST_ADDRESS pUnicast = cur_address->FirstUnicastAddress; PIP_ADAPTER_PREFIX pPrefix = cur_address->FirstPrefix; PWCHAR friendlyName = cur_address->FriendlyName; size_t asciiSize = wcstombs (0, friendlyName, 0) + 1; char *asciiFriendlyName = (char *) zmalloc (asciiSize); wcstombs (asciiFriendlyName, friendlyName, asciiSize); bool valid = (cur_address->OperStatus == IfOperStatusUp) && (pUnicast && pPrefix) && (pUnicast->Address.lpSockaddr->sa_family == AF_INET) && (pPrefix->PrefixLength <= 32); if (valid) { struct sockaddr_in address, netmask, broadcast; address = *(struct sockaddr_in *)pUnicast->Address.lpSockaddr; address.sin_family = AF_INET; netmask.sin_addr.s_addr = htonl ((0xffffffffU) << (32 - pPrefix->PrefixLength)); netmask.sin_family = AF_INET; broadcast = address; broadcast.sin_addr.s_addr |= ~(netmask.sin_addr.s_addr); interface_t *item = s_interface_new (asciiFriendlyName, (struct sockaddr *)&address, (struct sockaddr *)&netmask, (struct sockaddr *)&broadcast); if (item) zlistx_add_end (list, item); } freen (asciiFriendlyName); cur_address = cur_address->Next; } freen (pip_addresses); # else # error "Interface detection TBD on this operating system" # endif } // -------------------------------------------------------------------------- // Reload network interfaces from system void ziflist_reload (ziflist_t *self) { s_reload (self, false); } // -------------------------------------------------------------------------- // Reload network interfaces from system, including IPv6 void ziflist_reload_ipv6 (ziflist_t *self) { s_reload (self, true); } // -------------------------------------------------------------------------- // Return the number of network interfaces on system size_t ziflist_size (ziflist_t *self) { assert (self); return zlistx_size ((zlistx_t *) self); } // -------------------------------------------------------------------------- // Get first network interface, return NULL if there are none const char * ziflist_first (ziflist_t *self) { assert (self); interface_t *iface = (interface_t *) zlistx_first ((zlistx_t *) self); if (iface) return iface->name; else return NULL; } // -------------------------------------------------------------------------- // Get next network interface, return NULL if we hit the last one const char * ziflist_next (ziflist_t *self) { assert (self); interface_t *iface = (interface_t *) zlistx_next ((zlistx_t *) self); if (iface) return iface->name; else return NULL; } // -------------------------------------------------------------------------- // Return the current interface IP address as a printable string const char * ziflist_address (ziflist_t *self) { assert (self); interface_t *iface = (interface_t *) zlistx_item ((zlistx_t *) self); if (iface) return iface->address; else return NULL; } // -------------------------------------------------------------------------- // Return the current interface broadcast address as a printable string const char * ziflist_broadcast (ziflist_t *self) { assert (self); interface_t *iface = (interface_t *) zlistx_item ((zlistx_t *) self); if (iface) return iface->broadcast; else return NULL; } // -------------------------------------------------------------------------- // Return the current interface network mask as a printable string const char * ziflist_netmask (ziflist_t *self) { assert (self); interface_t *iface = (interface_t *) zlistx_item ((zlistx_t *) self); if (iface) return iface->netmask; else return NULL; } // -------------------------------------------------------------------------- // Return true if the current interface uses IPv6 bool ziflist_is_ipv6 (ziflist_t *self) { assert (self); interface_t *iface = (interface_t *) zlistx_item ((zlistx_t *) self); return iface->is_ipv6; } // -------------------------------------------------------------------------- // Selftest for this class void ziflist_test (bool verbose) { printf (" * ziflist: "); if (verbose) printf ("\n"); // TODO: for any Windows dev, any alternative to this? #if defined (__WINDOWS__) WORD version_requested = MAKEWORD (2, 2); WSADATA wsa_data; int rc = WSAStartup (version_requested, &wsa_data); assert (rc == 0); assert (LOBYTE (wsa_data.wVersion) == 2 && HIBYTE (wsa_data.wVersion) == 2); #endif // @selftest ziflist_t *iflist = ziflist_new (); assert (iflist); size_t items = ziflist_size (iflist); if (verbose) { printf ("ziflist: interfaces=%zu\n", ziflist_size (iflist)); const char *name = ziflist_first (iflist); while (name) { printf (" - name=%s address=%s netmask=%s broadcast=%s\n", name, ziflist_address (iflist), ziflist_netmask (iflist), ziflist_broadcast (iflist)); name = ziflist_next (iflist); } } ziflist_reload (iflist); assert (items == ziflist_size (iflist)); ziflist_destroy (&iflist); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zmonitor.c0000664000372000037200000003164213222211156016205 0ustar00travistravis00000000000000/* ========================================================================= zmonitor - socket event monitor Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zmonitor actor provides an API for obtaining socket events such as connected, listen, disconnected, etc. Socket events are only available for sockets connecting or bound to ipc:// and tcp:// endpoints. @discuss This class wraps the ZMQ socket monitor API, see zmq_socket_monitor for details. Works on all versions of libzmq from 3.2 onwards. This class replaces zproxy_v2, and is meant for applications that use the CZMQ v3 API (meaning, zsock). @end */ #include "czmq_classes.h" // -------------------------------------------------------------------------- // The self_t structure holds the state for one actor instance typedef struct { zsock_t *pipe; // Actor command pipe zpoller_t *poller; // Socket poller void *monitored; // Monitored libzmq socket zsock_t *sink; // Sink for monitor events int events; // Monitored event mask bool terminated; // Did caller ask us to quit? bool verbose; // Verbose logging enabled? } self_t; static void s_self_destroy (self_t **self_p) { assert (self_p); if (*self_p) { self_t *self = *self_p; #if defined (ZMQ_EVENT_ALL) zmq_socket_monitor (self->monitored, NULL, 0); #endif zpoller_destroy (&self->poller); zsock_destroy (&self->sink); freen (self); *self_p = NULL; } } static self_t * s_self_new (zsock_t *pipe, void *sock) { self_t *self = (self_t *) zmalloc (sizeof (self_t)); assert (self); self->pipe = pipe; self->monitored = zsock_resolve (sock); self->poller = zpoller_new (self->pipe, NULL); assert (self->poller); return self; } // -------------------------------------------------------------------------- // Add listener for specified event static void s_self_listen (self_t *self, const char *event) { #if defined (ZMQ_EVENT_ALL) if (streq (event, "CONNECTED")) self->events |= ZMQ_EVENT_CONNECTED; else if (streq (event, "CONNECT_DELAYED")) self->events |= ZMQ_EVENT_CONNECT_DELAYED; else if (streq (event, "CONNECT_RETRIED")) self->events |= ZMQ_EVENT_CONNECT_RETRIED; else if (streq (event, "LISTENING")) self->events |= ZMQ_EVENT_LISTENING; else if (streq (event, "BIND_FAILED")) self->events |= ZMQ_EVENT_BIND_FAILED; else if (streq (event, "ACCEPTED")) self->events |= ZMQ_EVENT_ACCEPTED; else if (streq (event, "ACCEPT_FAILED")) self->events |= ZMQ_EVENT_ACCEPT_FAILED; else if (streq (event, "CLOSED")) self->events |= ZMQ_EVENT_CLOSED; else if (streq (event, "CLOSE_FAILED")) self->events |= ZMQ_EVENT_CLOSE_FAILED; else if (streq (event, "DISCONNECTED")) self->events |= ZMQ_EVENT_DISCONNECTED; else #if defined (ZMQ_EVENT_MONITOR_STOPPED) if (streq (event, "MONITOR_STOPPED")) self->events |= ZMQ_EVENT_MONITOR_STOPPED; else #endif #if defined (ZMQ_EVENT_HANDSHAKE_FAILED) if (streq (event, "HANDSHAKE_FAILED")) self->events |= ZMQ_EVENT_HANDSHAKE_FAILED; else #endif #if defined (ZMQ_EVENT_HANDSHAKE_SUCCEED) if (streq (event, "HANDSHAKE_SUCCEED")) self->events |= ZMQ_EVENT_HANDSHAKE_SUCCEED; else #endif #if defined (ZMQ_EVENT_HANDSHAKE_SUCCEEDED) if (streq (event, "HANDSHAKE_SUCCEEDED")) self->events |= ZMQ_EVENT_HANDSHAKE_SUCCEEDED; else #endif #if defined (ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL) if (streq (event, "HANDSHAKE_FAILED_NO_DETAIL")) self->events |= ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL; else #endif #if defined (ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL) if (streq (event, "HANDSHAKE_FAILED_PROTOCOL")) self->events |= ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL; else #endif #if defined (ZMQ_EVENT_HANDSHAKE_FAILED_AUTH) if (streq (event, "HANDSHAKE_FAILED_AUTH")) self->events |= ZMQ_EVENT_HANDSHAKE_FAILED_AUTH; else #endif if (streq (event, "ALL")) self->events |= ZMQ_EVENT_ALL; else zsys_warning ("zmonitor: - invalid listen event=%s", event); #endif } // -------------------------------------------------------------------------- // Start monitoring static void s_self_start (self_t *self) { assert (!self->sink); char *endpoint = zsys_sprintf ("inproc://zmonitor-%p", self->monitored); assert (endpoint); int rc; #if defined (ZMQ_EVENT_ALL) rc = zmq_socket_monitor (self->monitored, endpoint, self->events); assert (rc == 0); #endif self->sink = zsock_new (ZMQ_PAIR); assert (self->sink); rc = zsock_connect (self->sink, "%s", endpoint); assert (rc == 0); zpoller_add (self->poller, self->sink); freen (endpoint); } // -------------------------------------------------------------------------- // Handle a command from calling application static int s_self_handle_pipe (self_t *self) { // Get the whole message off the pipe in one go zmsg_t *request = zmsg_recv (self->pipe); if (!request) return -1; // Interrupted char *command = zmsg_popstr (request); if (!command) { s_self_destroy (&self); return -1; } if (self->verbose) zsys_info ("zmonitor: API command=%s", command); if (streq (command, "LISTEN")) { char *event = zmsg_popstr (request); while (event) { if (self->verbose) zsys_info ("zmonitor: - listening to event=%s", event); s_self_listen (self, event); zstr_free (&event); event = zmsg_popstr (request); } } else if (streq (command, "START")) { s_self_start (self); zsock_signal (self->pipe, 0); } else if (streq (command, "VERBOSE")) self->verbose = true; else if (streq (command, "$TERM")) self->terminated = true; else { zsys_error ("zmonitor: - invalid command: %s", command); assert (false); } zstr_free (&command); zmsg_destroy (&request); return 0; } // Handle event from socket monitor static void s_self_handle_sink (self_t *self) { #if defined (ZMQ_EVENT_ALL) #if (ZMQ_VERSION_MAJOR >= 4) // First frame is event number and value zframe_t *frame = zframe_recv (self->sink); int event = *(uint16_t *) (zframe_data (frame)); int value = *(uint32_t *) (zframe_data (frame) + 2); // Address is in second message frame char *address = zstr_recv (self->sink); zframe_destroy (&frame); #elif (ZMQ_VERSION_MAJOR == 3 && ZMQ_VERSION_MINOR == 2) // zmq_event_t is passed as-is in the frame zframe_t *frame = zframe_recv (self->sink); zmq_event_t *eptr = (zmq_event_t *) zframe_data (frame); int event = eptr->event; int value = eptr->data.listening.fd; char *address = strdup (eptr->data.listening.addr); assert (address); zframe_destroy (&frame); #else // We can't plausibly be here with other versions of libzmq assert (false); #endif // Now map event to text equivalent char *name; switch (event) { case ZMQ_EVENT_ACCEPTED: name = "ACCEPTED"; break; case ZMQ_EVENT_ACCEPT_FAILED: name = "ACCEPT_FAILED"; break; case ZMQ_EVENT_BIND_FAILED: name = "BIND_FAILED"; break; case ZMQ_EVENT_CLOSED: name = "CLOSED"; break; case ZMQ_EVENT_CLOSE_FAILED: name = "CLOSE_FAILED"; break; case ZMQ_EVENT_DISCONNECTED: name = "DISCONNECTED"; break; case ZMQ_EVENT_CONNECTED: name = "CONNECTED"; break; case ZMQ_EVENT_CONNECT_DELAYED: name = "CONNECT_DELAYED"; break; case ZMQ_EVENT_CONNECT_RETRIED: name = "CONNECT_RETRIED"; break; case ZMQ_EVENT_LISTENING: name = "LISTENING"; break; #if defined (ZMQ_EVENT_MONITOR_STOPPED) case ZMQ_EVENT_MONITOR_STOPPED: name = "MONITOR_STOPPED"; break; #endif #if defined (ZMQ_EVENT_HANDSHAKE_FAILED) case ZMQ_EVENT_HANDSHAKE_FAILED: name = "HANDSHAKE_FAILED"; break; #endif #if defined (ZMQ_EVENT_HANDSHAKE_SUCCEED) case ZMQ_EVENT_HANDSHAKE_SUCCEED: name = "HANDSHAKE_SUCCEED"; break; #endif #if defined (ZMQ_EVENT_HANDSHAKE_SUCCEEDED) case ZMQ_EVENT_HANDSHAKE_SUCCEEDED: name = "HANDSHAKE_SUCCEEDED"; break; #endif #if defined (ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL) case ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL: name = "HANDSHAKE_FAILED_NO_DETAIL"; break; #endif #if defined (ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL) case ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL: name = "HANDSHAKE_FAILED_PROTOCOL"; break; #endif #if defined (ZMQ_EVENT_HANDSHAKE_FAILED_AUTH) case ZMQ_EVENT_HANDSHAKE_FAILED_AUTH: name = "HANDSHAKE_FAILED_AUTH"; break; #endif default: zsys_error ("illegal socket monitor event: %d", event); name = "UNKNOWN"; break; } if (self->verbose) zsys_info ("zmonitor: %s - %s", name, address); zstr_sendfm (self->pipe, "%s", name); zstr_sendfm (self->pipe, "%d", value); zstr_send (self->pipe, address); freen (address); #endif } // -------------------------------------------------------------------------- // zmonitor() implements the zmonitor actor interface void zmonitor (zsock_t *pipe, void *sock) { self_t *self = s_self_new (pipe, sock); assert (self); // Signal successful initialization zsock_signal (pipe, 0); while (!self->terminated) { zsock_t *which = (zsock_t *) zpoller_wait (self->poller, -1); if (which == self->pipe) s_self_handle_pipe (self); else if (which == self->sink) s_self_handle_sink (self); else if (zpoller_terminated (self->poller)) break; // Interrupted } s_self_destroy (&self); } // -------------------------------------------------------------------------- // Selftest #if defined (ZMQ_EVENT_ALL) static void s_assert_event (zactor_t *self, char *expected) { zmsg_t *msg = zmsg_recv (self); assert (msg); char *event = zmsg_popstr (msg); assert (streq (event, expected)); freen (event); zmsg_destroy (&msg); } #endif void zmonitor_test (bool verbose) { printf (" * zmonitor: "); if (verbose) printf ("\n"); #if defined (ZMQ_EVENT_ALL) // @selftest zsock_t *client = zsock_new (ZMQ_DEALER); assert (client); zactor_t *clientmon = zactor_new (zmonitor, client); assert (clientmon); if (verbose) zstr_sendx (clientmon, "VERBOSE", NULL); zstr_sendx (clientmon, "LISTEN", "LISTENING", "ACCEPTED", NULL); #if defined (ZMQ_EVENT_HANDSHAKE_SUCCEED) zstr_sendx (clientmon, "LISTEN", "HANDSHAKE_SUCCEED", NULL); #endif #if defined (ZMQ_EVENT_HANDSHAKE_SUCCEEDED) zstr_sendx (clientmon, "LISTEN", "HANDSHAKE_SUCCEEDED", NULL); #endif zstr_sendx (clientmon, "START", NULL); zsock_wait (clientmon); zsock_t *server = zsock_new (ZMQ_DEALER); assert (server); zactor_t *servermon = zactor_new (zmonitor, server); assert (servermon); if (verbose) zstr_sendx (servermon, "VERBOSE", NULL); zstr_sendx (servermon, "LISTEN", "CONNECTED", "DISCONNECTED", NULL); zstr_sendx (servermon, "START", NULL); zsock_wait (servermon); // Allow a brief time for the message to get there... zmq_poll (NULL, 0, 200); // Check client is now listening int port_nbr = zsock_bind (client, "tcp://127.0.0.1:*"); assert (port_nbr != -1); s_assert_event (clientmon, "LISTENING"); // Check server connected to client zsock_connect (server, "tcp://127.0.0.1:%d", port_nbr); s_assert_event (servermon, "CONNECTED"); // Check client accepted connection s_assert_event (clientmon, "ACCEPTED"); #if defined (ZMQ_EVENT_HANDSHAKE_SUCCEED) s_assert_event (clientmon, "HANDSHAKE_SUCCEED"); #endif #if defined (ZMQ_EVENT_HANDSHAKE_SUCCEEDED) s_assert_event (clientmon, "HANDSHAKE_SUCCEEDED"); #endif zactor_destroy (&clientmon); zactor_destroy (&servermon); zsock_destroy (&client); zsock_destroy (&server); #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zpoller.c0000664000372000037200000002725313222211156016016 0ustar00travistravis00000000000000/* ========================================================================= zpoller - trivial socket poller class Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. =========================================================================*/ /* @header The zpoller class provides a minimalist interface to ZeroMQ's zmq_poll API, for the very common case of reading from a number of sockets. It does not provide polling for output, nor polling on file handles. If you need either of these, use the zmq_poll API directly. @discuss The class implements the poller using the zmq_poller API if that exists, else does the work itself. @end */ #include "czmq_classes.h" // Structure of our class struct _zpoller_t { #ifdef ZMQ_HAVE_POLLER void *zmq_poller; // ZMQ poller structure #else zlist_t *reader_list; // List of sockets to read from zmq_pollitem_t *poll_set; // Current zmq_poll set void **poll_readers; // Matching table of socket readers size_t poll_size; // Size of poll set bool need_rebuild; // Does pollset need rebuilding? #endif bool expired; // Did poll timer expire? bool terminated; // Did poll call end with EINTR? bool nonstop; // Don't stop running on Ctrl-C }; #ifndef ZMQ_HAVE_POLLER static int s_rebuild_poll_set (zpoller_t *self) { freen (self->poll_set); self->poll_set = NULL; freen (self->poll_readers); self->poll_readers = NULL; self->poll_size = zlist_size (self->reader_list); self->poll_set = (zmq_pollitem_t *) zmalloc (self->poll_size * sizeof (zmq_pollitem_t)); self->poll_readers = (void **) zmalloc (self->poll_size * sizeof (void *)); if (!self->poll_set || !self->poll_readers) return -1; uint reader_nbr = 0; void *reader = zlist_first (self->reader_list); while (reader) { self->poll_readers [reader_nbr] = reader; void *socket = zsock_resolve (reader); if (socket == NULL) { self->poll_set [reader_nbr].socket = NULL; self->poll_set [reader_nbr].fd = *(SOCKET *) reader; } else self->poll_set [reader_nbr].socket = socket; self->poll_set [reader_nbr].events = ZMQ_POLLIN; reader_nbr++; reader = zlist_next (self->reader_list); } self->need_rebuild = false; return 0; } #endif // -------------------------------------------------------------------------- // Create new poller, specifying zero or more readers. The list of // readers ends in a NULL. Each reader can be a zsock_t instance, a // zactor_t instance, a libzmq socket (void *), or a file handle. zpoller_t * zpoller_new (void *reader, ...) { zpoller_t *self = (zpoller_t *) zmalloc (sizeof (zpoller_t)); assert (self); #ifdef ZMQ_HAVE_POLLER self->zmq_poller = zmq_poller_new (); assert (self->zmq_poller); #else self->reader_list = zlist_new (); assert (self->reader_list); #endif va_list args; va_start (args, reader); while (reader) { if (zpoller_add (self, reader)) { zpoller_destroy (&self); break; } reader = va_arg (args, void *); } va_end (args); return self; } // -------------------------------------------------------------------------- // Destroy a poller void zpoller_destroy (zpoller_t **self_p) { assert (self_p); if (*self_p) { zpoller_t *self = *self_p; #ifdef ZMQ_HAVE_POLLER zmq_poller_destroy (&self->zmq_poller); #else zlist_destroy (&self->reader_list); freen (self->poll_readers); freen (self->poll_set); #endif freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may // be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. int zpoller_add (zpoller_t *self, void *reader) { assert (self); assert (reader); int rc = 0; #ifdef ZMQ_HAVE_POLLER void *socket = zsock_resolve (reader); if (socket) rc = zmq_poller_add (self->zmq_poller, socket, reader, ZMQ_POLLIN); else rc = zmq_poller_add_fd (self->zmq_poller, *(SOCKET *) reader, reader, ZMQ_POLLIN); #else zlist_append (self->reader_list, reader); self->need_rebuild = true; #endif return rc; } // -------------------------------------------------------------------------- // Remove a reader from the poller; returns 0 if OK, -1 on failure. The reader // must have been passed during construction, or in an zpoller_add () call. int zpoller_remove (zpoller_t *self, void *reader) { assert (self); assert (reader); int rc = 0; #ifdef ZMQ_HAVE_POLLER void *socket = zsock_resolve (reader); if (socket) rc = zmq_poller_remove (self->zmq_poller, socket); else rc = zmq_poller_remove_fd (self->zmq_poller, *(SOCKET *) reader); #else size_t num_readers_before = zlist_size (self->reader_list); zlist_remove (self->reader_list, reader); // won't fail with non-existent reader size_t num_readers_after = zlist_size (self->reader_list); if (num_readers_before != num_readers_after) self->need_rebuild = true; else { errno = EINVAL; rc = -1; } #endif return rc; } // -------------------------------------------------------------------------- // By default the poller stops if the process receives a SIGINT or SIGTERM // signal. This makes it impossible to shut-down message based architectures // like zactors. This method lets you switch off break handling. The default // nonstop setting is off (false). void zpoller_set_nonstop (zpoller_t *self, bool nonstop) { assert (self); self->nonstop = nonstop; } // -------------------------------------------------------------------------- // Poll the registered readers for I/O, return first reader that has input. // The reader will be a libzmq void * socket, or a zsock_t or zactor_t // instance as specified in zpoller_new/zpoller_add. The timeout should be // zero or greater, or -1 to wait indefinitely. Socket priority is defined // by their order in the poll list. If you need a balanced poll, use the low // level zmq_poll method directly. If the poll call was interrupted (SIGINT), // or the ZMQ context was destroyed, or the timeout expired, returns NULL. // You can test the actual exit condition by calling zpoller_expired () and // zpoller_terminated (). The timeout is in msec. void * zpoller_wait (zpoller_t *self, int timeout) { assert (self); self->expired = false; if (zsys_interrupted && !self->nonstop) { self->terminated = true; return NULL; } else self->terminated = false; #ifdef ZMQ_HAVE_POLLER zmq_poller_event_t event; if (!zmq_poller_wait (self->zmq_poller, &event, timeout * ZMQ_POLL_MSEC)) return event.user_data; else if (errno == ETIMEDOUT || errno == EAGAIN) self->expired = true; else if (zsys_interrupted && !self->nonstop) self->terminated = true; return NULL; #else if (self->need_rebuild) s_rebuild_poll_set (self); int rc = zmq_poll (self->poll_set, (int) self->poll_size, timeout * ZMQ_POLL_MSEC); if (rc > 0) { uint reader = 0; for (reader = 0; reader < self->poll_size; reader++) if (self->poll_set [reader].revents & ZMQ_POLLIN) return self->poll_readers [reader]; } else if (rc == -1 || (zsys_interrupted && !self->nonstop)) self->terminated = true; else if (rc == 0) self->expired = true; return NULL; #endif } // -------------------------------------------------------------------------- // Return true if the last zpoller_wait () call ended because the timeout // expired, without any error. bool zpoller_expired (zpoller_t *self) { assert (self); return self->expired; } // -------------------------------------------------------------------------- // Return true if the last zpoller_wait () call ended because the process // was interrupted, or the parent context was destroyed. bool zpoller_terminated (zpoller_t *self) { assert (self); return self->terminated; } // -------------------------------------------------------------------------- // Self test of this class void zpoller_test (bool verbose) { printf (" * zpoller: "); // @selftest // Create a few sockets zsock_t *vent = zsock_new (ZMQ_PUSH); assert (vent); int port_nbr = zsock_bind (vent, "tcp://127.0.0.1:*"); assert (port_nbr != -1); zsock_t *sink = zsock_new (ZMQ_PULL); assert (sink); int rc = zsock_connect (sink, "tcp://127.0.0.1:%d", port_nbr); assert (rc != -1); zsock_t *bowl = zsock_new (ZMQ_PULL); assert (bowl); zsock_t *dish = zsock_new (ZMQ_PULL); assert (dish); // Set up poller zpoller_t *poller = zpoller_new (bowl, dish, NULL); assert (poller); // Add a reader to the existing poller rc = zpoller_add (poller, sink); assert (rc == 0); zstr_send (vent, "Hello, World"); // We expect a message only on the sink zsock_t *which = (zsock_t *) zpoller_wait (poller, -1); assert (which == sink); assert (zpoller_expired (poller) == false); assert (zpoller_terminated (poller) == false); char *message = zstr_recv (which); assert (streq (message, "Hello, World")); zstr_free (&message); // Stop polling reader rc = zpoller_remove (poller, sink); assert (rc == 0); // Removing a non-existent reader shall fail rc = zpoller_remove (poller, sink); assert (rc == -1); assert (errno == EINVAL); // Check we can poll an FD rc = zsock_connect (bowl, "tcp://127.0.0.1:%d", port_nbr); assert (rc != -1); SOCKET fd = zsock_fd (bowl); rc = zpoller_add (poller, (void *) &fd); assert (rc != -1); zstr_send (vent, "Hello again, world"); assert (zpoller_wait (poller, 500) == &fd); // Check zpoller_set_nonstop () zsys_interrupted = 1; zpoller_wait (poller, 0); assert (zpoller_terminated (poller)); zpoller_set_nonstop (poller, true); zpoller_wait (poller, 0); assert (!zpoller_terminated (poller)); zsys_interrupted = 0; zpoller_destroy (&poller); zsock_destroy (&vent); zsock_destroy (&sink); zsock_destroy (&bowl); zsock_destroy (&dish); #ifdef ZMQ_SERVER // Check thread safe sockets zpoller_destroy (&poller); zsock_t *client = zsock_new (ZMQ_CLIENT); assert (client); zsock_t *server = zsock_new (ZMQ_SERVER); assert (server); poller = zpoller_new (client, server, NULL); assert (poller); port_nbr = zsock_bind (server, "tcp://127.0.0.1:*"); assert (port_nbr != -1); rc = zsock_connect (client, "tcp://127.0.0.1:%d", port_nbr); assert (rc != -1); zstr_send (client, "Hello, World"); // We expect a message only on the server which = (zsock_t *) zpoller_wait (poller, -1); assert (which == server); assert (zpoller_expired (poller) == false); assert (zpoller_terminated (poller) == false); message = zstr_recv (which); assert (streq (message, "Hello, World")); zstr_free (&message); zpoller_destroy (&poller); zsock_destroy (&client); zsock_destroy (&server); #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zmakecert.c0000664000372000037200000000352413222211156016307 0ustar00travistravis00000000000000/* zmakecert [filename] Certificate generator for ZeroMQ CURVE security. Produces two files: * {filename} - public certificate * {filename}_secret - secret certificate Default filename is mycert.txt. Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "czmq_classes.h" // Get and store one header in certificate static int s_get_meta (zcert_t *cert, char *prompt, char *name) { printf ("%s ", prompt); char value [256]; if (fgets (value, 256, stdin) == NULL) return -1; if (strlen (value) && value [strlen (value) - 1] == '\n') value [strlen (value) - 1] = 0; if (*value) zcert_set_meta (cert, name, "%s", value); return 0; } int main (int argc, char *argv []) { int argn = 1; char *filename = "mycert.txt"; if (argn < argc) filename = argv [argn++]; zsys_info ("Creating new CURVE certificate in %s", filename); zcert_t *cert = zcert_new (); if (s_get_meta (cert, "Enter your full name:", "name") || s_get_meta (cert, "Enter your email address:", "email") || s_get_meta (cert, "Enter your organization:", "organization")) return -1; char *timestr = zclock_timestr (); zcert_set_meta (cert, "created-by", "CZMQ zmakecert"); zcert_set_meta (cert, "date-created", "%s", timestr); freen (timestr); zcert_dump (cert); zcert_save (cert, filename); zsys_info ("CURVE certificate created in %s and %s_secret", filename, filename); zcert_destroy (&cert); return 0; } czmq-4.1.0/src/selftest-ro/0000775000372000037200000000000013222211156016421 5ustar00travistravis00000000000000czmq-4.1.0/src/selftest-ro/.gitkeep0000664000372000037200000000000013222211156020040 0ustar00travistravis00000000000000czmq-4.1.0/src/zlist.c0000664000372000037200000004172413222211156015473 0ustar00travistravis00000000000000/* ========================================================================= zlist - simple generic list container Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header Provides a generic container implementing a fast singly-linked list. You can use this to construct multi-dimensional lists, and other structures together with other generic containers like zhash. This is a simple class. For demanding applications we recommend using zlistx. @discuss To iterate through a list, use zlist_first to get the first item, then loop while not null, and do zlist_next at the end of each iteration. @end */ #include "czmq_classes.h" // List node, used internally only typedef struct _node_t { struct _node_t *next; void *item; zlist_free_fn *free_fn; } node_t; // --------------------------------------------------------------------- // Structure of our class struct _zlist_t { node_t *head; // First item in list, if any node_t *tail; // Last item in list, if any node_t *cursor; // Current cursors for iteration size_t size; // Number of items in list bool autofree; // If true, free items in destructor zlist_compare_fn *compare_fn; // Function to compare two list item for // less than, equals or greater than }; // -------------------------------------------------------------------------- // List constructor zlist_t * zlist_new (void) { zlist_t *self = (zlist_t *) zmalloc (sizeof (zlist_t)); assert (self); return self; } // -------------------------------------------------------------------------- // List destructor void zlist_destroy (zlist_t **self_p) { assert (self_p); if (*self_p) { zlist_t *self = *self_p; zlist_purge (self); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor pointing at the head item, or NULL if the list is empty. void * zlist_first (zlist_t *self) { assert (self); self->cursor = self->head; if (self->cursor) return self->cursor->item; else return NULL; } // -------------------------------------------------------------------------- // Return the next item. If the list is empty, returns NULL. To move to // the start of the list call zlist_first (). Advances the cursor. void * zlist_next (zlist_t *self) { assert (self); if (self->cursor) self->cursor = self->cursor->next; else self->cursor = self->head; if (self->cursor) return self->cursor->item; else return NULL; } // -------------------------------------------------------------------------- // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor pointing at the tail item, or NULL if the list is empty. void * zlist_last (zlist_t *self) { assert (self); self->cursor = self->tail; if (self->cursor) return self->cursor->item; else return NULL; } // -------------------------------------------------------------------------- // Return the item at the head of list. If the list is empty, returns NULL. // Leaves cursor as-is. void * zlist_head (zlist_t *self) { assert (self); return self->head? self->head->item: NULL; } // -------------------------------------------------------------------------- // Return the item at the tail of list. If the list is empty, returns NULL. // Leaves cursor as-is. void * zlist_tail (zlist_t *self) { assert (self); return self->tail? self->tail->item: NULL; } // -------------------------------------------------------------------------- // Return current item in the list. If the list is empty, or the cursor // passed the end of the list, returns NULL. Does not change the cursor. void * zlist_item (zlist_t *self) { assert (self); if (self->cursor) return self->cursor->item; else return NULL; } // -------------------------------------------------------------------------- // Append an item to the end of the list, return 0 if OK or -1 if this // failed for some reason. int zlist_append (zlist_t *self, void *item) { if (!item) return -1; node_t *node = (node_t *) zmalloc (sizeof (node_t)); assert (node); // If necessary, take duplicate of (string) item if (self->autofree) { item = strdup ((char *) item); assert (item); } node->item = item; if (self->tail) self->tail->next = node; else self->head = node; self->tail = node; node->next = NULL; self->size++; self->cursor = NULL; return 0; } // -------------------------------------------------------------------------- // Push an item to the start of the list, return 0 if OK or -1 if this // failed for some reason. int zlist_push (zlist_t *self, void *item) { if (!item) return -1; node_t *node = (node_t *) zmalloc (sizeof (node_t)); assert (node); // If necessary, take duplicate of (string) item if (self->autofree) { item = strdup ((char *) item); assert (item); } node->item = item; node->next = self->head; self->head = node; if (self->tail == NULL) self->tail = node; self->size++; self->cursor = NULL; return 0; } // -------------------------------------------------------------------------- // Remove item from the beginning of the list, returns NULL if none void * zlist_pop (zlist_t *self) { node_t *node = self->head; void *item = NULL; if (node) { item = node->item; self->head = node->next; if (self->tail == node) self->tail = NULL; freen (node); self->size--; } self->cursor = NULL; return item; } // -------------------------------------------------------------------------- // Checks if an item already is present. Uses compare method to determine if // items are equal. If the compare method is NULL the check will only compare // pointers. Returns true if item is present else false. bool zlist_exists (zlist_t *self, void *item) { assert (self); assert (item); node_t *node = self->head; while (node) { if (self->compare_fn) { if ((*self->compare_fn)(node->item, item) == 0) return true; } else if (node->item == item) return true; node = node->next; } return false; } // -------------------------------------------------------------------------- // Remove the item from the list, if present. Safe to call on items that // are not in the list. void zlist_remove (zlist_t *self, void *item) { node_t *node, *prev = NULL; // First off, we need to find the list node for (node = self->head; node != NULL; node = node->next) { if (self->compare_fn) { if ((*self->compare_fn)(node->item, item) == 0) break; } else if (node->item == item) break; prev = node; } if (node) { if (prev) prev->next = node->next; else self->head = node->next; if (node->next == NULL) self->tail = prev; if (self->cursor == node) self->cursor = prev; if (self->autofree) freen (node->item); else if (node->free_fn) (node->free_fn)(node->item); freen (node); self->size--; } } // -------------------------------------------------------------------------- // Make a copy of list. If the list has autofree set, the copied list will // duplicate all items, which must be strings. Otherwise, the list will hold // pointers back to the items in the original list. If list is null, returns // NULL. zlist_t * zlist_dup (zlist_t *self) { if (!self) return NULL; zlist_t *copy = zlist_new (); assert (copy); if (self->autofree) zlist_autofree(copy); copy->compare_fn = self->compare_fn; node_t *node; for (node = self->head; node; node = node->next) { if (zlist_append (copy, node->item) == -1) { zlist_destroy (©); break; } } return copy; } // -------------------------------------------------------------------------- // Purge all items from list void zlist_purge (zlist_t *self) { assert (self); node_t *node = self->head; while (node) { node_t *next = node->next; if (self->autofree) freen (node->item); else if (node->free_fn) (node->free_fn)(node->item); freen (node); node = next; } self->head = NULL; self->tail = NULL; self->cursor = NULL; self->size = 0; } // -------------------------------------------------------------------------- // Return the number of items in the list size_t zlist_size (zlist_t *self) { return self->size; } // -------------------------------------------------------------------------- // Sort the list. If the compare function is null, sorts the list by // ascending key value using a straight ASCII comparison. If you specify // a compare function, this decides how items are sorted. The sort is not // stable, so may reorder items with the same keys. The algorithm used is // combsort, a compromise between performance and simplicity. void zlist_sort (zlist_t *self, zlist_compare_fn compare_fn) { zlist_compare_fn *compare = compare_fn; if (!compare) { compare = self->compare_fn; if (!compare) compare = (zlist_compare_fn *) strcmp; } // Uses a comb sort, which is simple and reasonably fast. // See http://en.wikipedia.org/wiki/Comb_sort size_t gap = self->size; bool swapped = false; while (gap > 1 || swapped) { if (gap > 1) gap = (size_t) ((double) gap / 1.3); node_t *base = self->head; node_t *test = self->head; size_t jump = gap; while (jump--) test = test->next; swapped = false; while (base && test) { if ((*compare) (base->item, test->item) > 0) { // It's trivial to swap items in a generic container void *item = base->item; base->item = test->item; test->item = item; swapped = true; } base = base->next; test = test->next; } } } // -------------------------------------------------------------------------- // Sets a compare function for this list. The function compares two items. // It returns an integer less than, equal to, or greater than zero if the // first item is found, respectively, to be less than, to match, or be // greater than the second item. // This function is used for sorting, removal and exists checking. void zlist_comparefn (zlist_t *self, zlist_compare_fn fn) { assert (self); self->compare_fn = fn; } // -------------------------------------------------------------------------- // Set a free function for the specified list item. When the item is // destroyed, the free function, if any, is called on that item. // Use this when list items are dynamically allocated, to ensure that // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. // Returns the item, or NULL if there is no such item. void * zlist_freefn (zlist_t *self, void *item, zlist_free_fn fn, bool at_tail) { node_t *node = self->head; if (at_tail) node = self->tail; while (node) { if (node->item == item) { node->free_fn = fn; return item; } node = node->next; } return NULL; } // -------------------------------------------------------------------------- // Set list for automatic item destruction; item values MUST be strings. // By default a list item refers to a value held elsewhere. When you set // this, each time you append or push a list item, zlist will take a copy // of the string value. Then, when you destroy the list, it will free all // item values automatically. If you use any other technique to allocate // list values, you must free them explicitly before destroying the list. // The usual technique is to pop list items and destroy them, until the // list is empty. void zlist_autofree (zlist_t *self) { assert (self); self->autofree = true; } static void s_zlist_free (void *data) { zlist_t *self = (zlist_t *) data; zlist_destroy (&self); } // -------------------------------------------------------------------------- // Runs selftest of class void zlist_test (bool verbose) { printf (" * zlist: "); // @selftest zlist_t *list = zlist_new (); assert (list); assert (zlist_size (list) == 0); // Three items we'll use as test data // List items are void *, not particularly strings char *cheese = "boursin"; char *bread = "baguette"; char *wine = "bordeaux"; zlist_append (list, cheese); assert (zlist_size (list) == 1); assert ( zlist_exists (list, cheese)); assert (!zlist_exists (list, bread)); assert (!zlist_exists (list, wine)); zlist_append (list, bread); assert (zlist_size (list) == 2); assert ( zlist_exists (list, cheese)); assert ( zlist_exists (list, bread)); assert (!zlist_exists (list, wine)); zlist_append (list, wine); assert (zlist_size (list) == 3); assert ( zlist_exists (list, cheese)); assert ( zlist_exists (list, bread)); assert ( zlist_exists (list, wine)); assert (zlist_head (list) == cheese); assert (zlist_next (list) == cheese); assert (zlist_first (list) == cheese); assert (zlist_tail (list) == wine); assert (zlist_next (list) == bread); assert (zlist_first (list) == cheese); assert (zlist_next (list) == bread); assert (zlist_next (list) == wine); assert (zlist_next (list) == NULL); // After we reach end of list, next wraps around assert (zlist_next (list) == cheese); assert (zlist_size (list) == 3); zlist_remove (list, wine); assert (zlist_size (list) == 2); assert (zlist_first (list) == cheese); zlist_remove (list, cheese); assert (zlist_size (list) == 1); assert (zlist_first (list) == bread); zlist_remove (list, bread); assert (zlist_size (list) == 0); zlist_append (list, cheese); zlist_append (list, bread); assert (zlist_last (list) == bread); zlist_remove (list, bread); assert (zlist_last (list) == cheese); zlist_remove (list, cheese); assert (zlist_last (list) == NULL); zlist_push (list, cheese); assert (zlist_size (list) == 1); assert (zlist_first (list) == cheese); zlist_push (list, bread); assert (zlist_size (list) == 2); assert (zlist_first (list) == bread); assert (zlist_item (list) == bread); zlist_append (list, wine); assert (zlist_size (list) == 3); assert (zlist_first (list) == bread); zlist_t *sub_list = zlist_dup (list); assert (sub_list); assert (zlist_size (sub_list) == 3); zlist_sort (list, NULL); char *item; item = (char *) zlist_pop (list); assert (item == bread); item = (char *) zlist_pop (list); assert (item == wine); item = (char *) zlist_pop (list); assert (item == cheese); assert (zlist_size (list) == 0); assert (zlist_size (sub_list) == 3); zlist_push (list, sub_list); zlist_t *sub_list_2 = zlist_dup (sub_list); zlist_append (list, sub_list_2); assert (zlist_freefn (list, sub_list, &s_zlist_free, false) == sub_list); assert (zlist_freefn (list, sub_list_2, &s_zlist_free, true) == sub_list_2); zlist_destroy (&list); // Test autofree functionality list = zlist_new (); assert (list); zlist_autofree (list); // Set equals function otherwise equals will not work as autofree copies strings zlist_comparefn (list, (zlist_compare_fn *) strcmp); zlist_push (list, bread); zlist_append (list, cheese); assert (zlist_size (list) == 2); zlist_append (list, wine); assert (zlist_exists (list, wine)); zlist_remove (list, wine); assert (!zlist_exists (list, wine)); assert (streq ((const char *) zlist_first (list), bread)); item = (char *) zlist_pop (list); assert (streq (item, bread)); freen (item); item = (char *) zlist_pop (list); assert (streq (item, cheese)); freen (item); zlist_destroy (&list); assert (list == NULL); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/platform.h.in0000664000372000037200000001373713222211332016563 0ustar00travistravis00000000000000/* src/platform.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Architecture of the build host */ #undef BUILD_ARCH /* Build date */ #undef BUILD_DATE /* Build host name */ #undef BUILD_HOST /* The fine user who built the package */ #undef BUILD_USER /* Provide draft classes and methods */ #undef CZMQ_BUILD_DRAFT_API /* Have AIX OS */ #undef CZMQ_HAVE_AIX /* Have Android OS */ #undef CZMQ_HAVE_ANDROID /* Have Cygwin */ #undef CZMQ_HAVE_CYGWIN /* Have FreeBSD OS */ #undef CZMQ_HAVE_FREEBSD /* Have GNU/Hurd OS */ #undef CZMQ_HAVE_GNU /* Have HPUX OS */ #undef CZMQ_HAVE_HPUX /* Have Linux OS */ #undef CZMQ_HAVE_LINUX /* Have MinGW32 */ #undef CZMQ_HAVE_MINGW32 /* Have NetBSD OS */ #undef CZMQ_HAVE_NETBSD /* Have OpenBSD OS */ #undef CZMQ_HAVE_OPENBSD /* Have DarwinOSX OS */ #undef CZMQ_HAVE_OSX /* Have QNX Neutrino OS */ #undef CZMQ_HAVE_QNXNTO /* Have Solaris OS */ #undef CZMQ_HAVE_SOLARIS /* Have Windows OS */ #undef CZMQ_HAVE_WINDOWS /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_ERRNO_H /* Define to 1 if you have the `getifaddrs' function. */ #undef HAVE_GETIFADDRS /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the header file. */ #undef HAVE_IFADDRS_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* The optional liblz4 library is to be used */ #undef HAVE_LIBLZ4 /* The optional libsystemd library is to be used */ #undef HAVE_LIBSYSTEMD /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_WIRELESS_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_TCP_H /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_H /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_MEDIA_H /* Define to 1 if you have the `perror' function. */ #undef HAVE_PERROR /* Define to 1 if you have the header file. */ #undef HAVE_PTHREAD_H /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* The optional uuid library is to be used */ #undef HAVE_UUID /* Define to 1 if you have the header file. */ #undef HAVE_WINDOWS_H /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* CZMQ major version */ #undef PACKAGE_VERSION_MAJOR /* CZMQ minor version */ #undef PACKAGE_VERSION_MINOR /* CZMQ patchlevel */ #undef PACKAGE_VERSION_PATCH /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Version number of package */ #undef VERSION /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT32_T /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if does not define. */ #undef ssize_t /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef uint32_t /* Define to empty if the keyword `volatile' does not work. Warning: valid code using `volatile' can become incorrect without. Disable with care. */ #undef volatile czmq-4.1.0/src/Makemodule-local.am0000664000372000037200000000077513222211156017655 0ustar00travistravis00000000000000# Project-local changes to auto-generated content # Android-qt requires this special link dependency if ON_ANDROID src_libczmq_la_LIBADD += -llog endif # Add a way to customize test_randof binary for quick recompiles, e.g. # gmake test_randof_macros="-DZSYS_RANDOF_FLT=double -DZSYS_RANDOF_MAX=INT8_MAX" src/test_randof if ENABLE_TEST_RANDOF src_test_randof_CPPFLAGS += $(test_randof_macros) endif check-py: src/libczmq.la $(LIBTOOL) --mode=execute -dlopen src/libczmq.la python bindings/python/test.py czmq-4.1.0/src/CMakeLists-local.txt0000664000372000037200000000122013222211156017775 0ustar00travistravis00000000000000# pthread requires special checks and flags to be added find_package(Threads) if(THREADS_HAVE_PTHREAD_ARG) if(CZMQ_BUILD_SHARED) target_compile_options(PUBLIC czmq "-pthread") endif() if(CZMQ_BUILD_STATIC) target_compile_options(PUBLIC czmq-static "-pthread") endif() endif() if(CMAKE_THREAD_LIBS_INIT) if(CZMQ_BUILD_SHARED) target_link_libraries(czmq "${CMAKE_THREAD_LIBS_INIT}") endif() if(CZMQ_BUILD_STATIC) target_link_libraries(czmq-static "${CMAKE_THREAD_LIBS_INIT}") endif() endif() # at least C99 is required for zdir which uses ‘for’ loop initial declarations set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") czmq-4.1.0/src/czmq_classes.h0000664000372000037200000003501513222211156017016 0ustar00travistravis00000000000000/* ========================================================================= czmq_classes - private header file Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ ========================================================================= */ #ifndef CZMQ_CLASSES_H_INCLUDED #define CZMQ_CLASSES_H_INCLUDED // Platform definitions, must come first #include "platform.h" // External API #include "../include/czmq.h" // Extra headers // Opaque class structures to allow forward references #ifndef ZGOSSIP_MSG_T_DEFINED typedef struct _zgossip_msg_t zgossip_msg_t; #define ZGOSSIP_MSG_T_DEFINED #endif // Internal API #include "zgossip_msg.h" // *** To avoid double-definitions, only define if building without draft *** #ifndef CZMQ_BUILD_DRAFT_API // *** Draft callbacks, defined for internal use only *** // Function to be called on zactor_destroy. Default behavior is to send zmsg_t with string "$TERM" in a first frame. // // An example - to send $KTHXBAI string // // if (zstr_send (self->pipe, "$KTHXBAI") == 0) // zsock_wait (self->pipe); typedef void (zactor_destructor_fn) ( zactor_t *self); // *** Draft method, defined for internal use only *** // Change default destructor by custom function. Actor MUST be able to handle new message instead of default $TERM. CZMQ_PRIVATE void zactor_set_destructor (zactor_t *self, zactor_destructor_fn destructor); // *** Draft method, defined for internal use only *** // Accepts public/secret key text pair from caller // Caller owns return value and must destroy it when done. CZMQ_PRIVATE zcert_t * zcert_new_from_txt (const char *public_txt, const char *secret_txt); // *** Draft method, defined for internal use only *** // Unset certificate metadata. CZMQ_PRIVATE void zcert_unset_meta (zcert_t *self, const char *name); // *** Draft callbacks, defined for internal use only *** // Loaders retrieve certificates from an arbitrary source. typedef void (zcertstore_loader) ( zcertstore_t *self); // Destructor for loader state. typedef void (zcertstore_destructor) ( void **self_p); // *** Draft method, defined for internal use only *** // Override the default disk loader with a custom loader fn. CZMQ_PRIVATE void zcertstore_set_loader (zcertstore_t *self, zcertstore_loader loader, zcertstore_destructor destructor, void *state); // *** Draft method, defined for internal use only *** // Empty certificate hashtable. This wrapper exists to be friendly to bindings, // which don't usually have access to struct internals. CZMQ_PRIVATE void zcertstore_empty (zcertstore_t *self); // *** Draft method, defined for internal use only *** // Return a list of all the certificates in the store. // The caller takes ownership of the zlistx_t object and is responsible // for destroying it. The caller does not take ownership of the zcert_t // objects. // Caller owns return value and must destroy it when done. CZMQ_PRIVATE zlistx_t * zcertstore_certs (zcertstore_t *self); // *** Draft method, defined for internal use only *** // Destroy subtree (all children) CZMQ_PRIVATE void zconfig_remove_subtree (zconfig_t *self); // *** Draft method, defined for internal use only *** // Destroy node and subtree (all children) CZMQ_PRIVATE void zconfig_remove (zconfig_t **self_p); // *** Draft method, defined for internal use only *** // Create new temporary file for writing via tmpfile. File is automaticaly // deleted on destroy // Caller owns return value and must destroy it when done. CZMQ_PRIVATE zfile_t * zfile_tmp (void); // *** Draft method, defined for internal use only *** // Return frame routing ID, if the frame came from a ZMQ_SERVER socket. // Else returns zero. CZMQ_PRIVATE uint32_t zframe_routing_id (zframe_t *self); // *** Draft method, defined for internal use only *** // Set routing ID on frame. This is used if/when the frame is sent to a // ZMQ_SERVER socket. CZMQ_PRIVATE void zframe_set_routing_id (zframe_t *self, uint32_t routing_id); // *** Draft method, defined for internal use only *** // Return frame group of radio-dish pattern. CZMQ_PRIVATE const char * zframe_group (zframe_t *self); // *** Draft method, defined for internal use only *** // Set group on frame. This is used if/when the frame is sent to a // ZMQ_RADIO socket. // Return -1 on error, 0 on success. CZMQ_PRIVATE int zframe_set_group (zframe_t *self, const char *group); // *** Draft method, defined for internal use only *** // Same as pack but uses a user-defined serializer function to convert items // into longstr. // Caller owns return value and must destroy it when done. CZMQ_PRIVATE zframe_t * zhashx_pack_own (zhashx_t *self, zhashx_serializer_fn serializer); // *** Draft method, defined for internal use only *** // Same as unpack but uses a user-defined deserializer function to convert // a longstr back into item format. // Caller owns return value and must destroy it when done. CZMQ_PRIVATE zhashx_t * zhashx_unpack_own (zframe_t *frame, zhashx_deserializer_fn deserializer); // *** Draft method, defined for internal use only *** // Get a list of network interfaces currently defined on the system // Includes IPv6 interfaces // Caller owns return value and must destroy it when done. CZMQ_PRIVATE ziflist_t * ziflist_new_ipv6 (void); // *** Draft method, defined for internal use only *** // Reload network interfaces from system, including IPv6 CZMQ_PRIVATE void ziflist_reload_ipv6 (ziflist_t *self); // *** Draft method, defined for internal use only *** // Return true if the current interface uses IPv6 CZMQ_PRIVATE bool ziflist_is_ipv6 (ziflist_t *self); // *** Draft method, defined for internal use only *** // Return message routing ID, if the message came from a ZMQ_SERVER socket. // Else returns zero. CZMQ_PRIVATE uint32_t zmsg_routing_id (zmsg_t *self); // *** Draft method, defined for internal use only *** // Set routing ID on message. This is used if/when the message is sent to a // ZMQ_SERVER socket. CZMQ_PRIVATE void zmsg_set_routing_id (zmsg_t *self, uint32_t routing_id); // *** Draft method, defined for internal use only *** // Create a SERVER socket. Default action is bind. // Caller owns return value and must destroy it when done. CZMQ_PRIVATE zsock_t * zsock_new_server (const char *endpoint); // *** Draft method, defined for internal use only *** // Create a CLIENT socket. Default action is connect. // Caller owns return value and must destroy it when done. CZMQ_PRIVATE zsock_t * zsock_new_client (const char *endpoint); // *** Draft method, defined for internal use only *** // Create a RADIO socket. Default action is bind. // Caller owns return value and must destroy it when done. CZMQ_PRIVATE zsock_t * zsock_new_radio (const char *endpoint); // *** Draft method, defined for internal use only *** // Create a DISH socket. Default action is connect. // Caller owns return value and must destroy it when done. CZMQ_PRIVATE zsock_t * zsock_new_dish (const char *endpoint); // *** Draft method, defined for internal use only *** // Create a GATHER socket. Default action is bind. // Caller owns return value and must destroy it when done. CZMQ_PRIVATE zsock_t * zsock_new_gather (const char *endpoint); // *** Draft method, defined for internal use only *** // Create a SCATTER socket. Default action is connect. // Caller owns return value and must destroy it when done. CZMQ_PRIVATE zsock_t * zsock_new_scatter (const char *endpoint); // *** Draft method, defined for internal use only *** // Return socket routing ID if any. This returns 0 if the socket is not // of type ZMQ_SERVER or if no request was already received on it. CZMQ_PRIVATE uint32_t zsock_routing_id (zsock_t *self); // *** Draft method, defined for internal use only *** // Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. // This will be used when sending messages on the socket via the zsock API. CZMQ_PRIVATE void zsock_set_routing_id (zsock_t *self, uint32_t routing_id); // *** Draft method, defined for internal use only *** // Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. CZMQ_PRIVATE int zsock_join (void *self, const char *group); // *** Draft method, defined for internal use only *** // Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. // Returns 0 if OK, -1 if failed. CZMQ_PRIVATE int zsock_leave (void *self, const char *group); // *** Draft method, defined for internal use only *** // De-compress and receive C string from socket, received as a message // with two frames: size of the uncompressed string, and the string itself. // Caller must free returned string using zstr_free(). Returns NULL if the // context is being terminated or the process was interrupted. // Caller owns return value and must destroy it when done. CZMQ_PRIVATE char * zstr_recv_compress (void *source); // *** Draft method, defined for internal use only *** // Compress and send a C string to a socket, as a message with two frames: // size of the uncompressed string, and the string itself. The string is // sent without trailing null byte; to read this you can use // zstr_recv_compress, or a similar method that de-compresses and adds a // null terminator on the received string. CZMQ_PRIVATE int zstr_send_compress (void *dest, const char *string); // *** Draft method, defined for internal use only *** // Compress and send a C string to a socket, as zstr_send_compress(), // with a MORE flag, so that you can send further strings in the same // multi-part message. CZMQ_PRIVATE int zstr_sendm_compress (void *dest, const char *string); // *** Draft method, defined for internal use only *** // Accepts a void pointer and returns a fresh character string. If source // is null, returns an empty string. // Caller owns return value and must destroy it when done. CZMQ_PRIVATE char * zstr_str (void *source); // *** Draft method, defined for internal use only *** // Configure the threshold value of filesystem object age per st_mtime // that should elapse until we consider that object "stable" at the // current zclock_time() moment. // The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c // which generally depends on host OS, with fallback value of 5000. CZMQ_PRIVATE void zsys_set_file_stable_age_msec (int64_t file_stable_age_msec); // *** Draft method, defined for internal use only *** // Return current threshold value of file stable age in msec. // This can be used in code that chooses to wait for this timeout // before testing if a filesystem object is "stable" or not. CZMQ_PRIVATE int64_t zsys_file_stable_age_msec (void); // *** Draft constants, defined for internal use only *** #define ZGOSSIP_MSG_HELLO 1 // #define ZGOSSIP_MSG_PUBLISH 2 // #define ZGOSSIP_MSG_PING 3 // #define ZGOSSIP_MSG_PONG 4 // #define ZGOSSIP_MSG_INVALID 5 // // *** Draft method, defined for internal use only *** // Create a new empty zgossip_msg // Caller owns return value and must destroy it when done. CZMQ_PRIVATE zgossip_msg_t * zgossip_msg_new (void); // *** Draft method, defined for internal use only *** // Destroy a zgossip_msg instance CZMQ_PRIVATE void zgossip_msg_destroy (zgossip_msg_t **self_p); // *** Draft method, defined for internal use only *** // Receive a zgossip_msg from the socket. Returns 0 if OK, -1 if // there was an error. Blocks if there is no message waiting. CZMQ_PRIVATE int zgossip_msg_recv (zgossip_msg_t *self, zsock_t *input); // *** Draft method, defined for internal use only *** // Send the zgossip_msg to the output socket, does not destroy it CZMQ_PRIVATE int zgossip_msg_send (zgossip_msg_t *self, zsock_t *output); // *** Draft method, defined for internal use only *** // Print contents of message to stdout CZMQ_PRIVATE void zgossip_msg_print (zgossip_msg_t *self); // *** Draft method, defined for internal use only *** // Get the message routing id, as a frame CZMQ_PRIVATE zframe_t * zgossip_msg_routing_id (zgossip_msg_t *self); // *** Draft method, defined for internal use only *** // Set the message routing id from a frame CZMQ_PRIVATE void zgossip_msg_set_routing_id (zgossip_msg_t *self, zframe_t *routing_id); // *** Draft method, defined for internal use only *** // Get the zgossip_msg message id CZMQ_PRIVATE int zgossip_msg_id (zgossip_msg_t *self); // *** Draft method, defined for internal use only *** // Set the zgossip_msg message id CZMQ_PRIVATE void zgossip_msg_set_id (zgossip_msg_t *self, int id); // *** Draft method, defined for internal use only *** // Get the zgossip_msg message id as printable text CZMQ_PRIVATE const char * zgossip_msg_command (zgossip_msg_t *self); // *** Draft method, defined for internal use only *** // Get the key field CZMQ_PRIVATE const char * zgossip_msg_key (zgossip_msg_t *self); // *** Draft method, defined for internal use only *** // Set the key field CZMQ_PRIVATE void zgossip_msg_set_key (zgossip_msg_t *self, const char *key); // *** Draft method, defined for internal use only *** // Get the value field CZMQ_PRIVATE const char * zgossip_msg_value (zgossip_msg_t *self); // *** Draft method, defined for internal use only *** // Set the value field CZMQ_PRIVATE void zgossip_msg_set_value (zgossip_msg_t *self, const char *value); // *** Draft method, defined for internal use only *** // Get the ttl field CZMQ_PRIVATE uint32_t zgossip_msg_ttl (zgossip_msg_t *self); // *** Draft method, defined for internal use only *** // Set the ttl field CZMQ_PRIVATE void zgossip_msg_set_ttl (zgossip_msg_t *self, uint32_t ttl); // *** Draft method, defined for internal use only *** // Self test of this class. CZMQ_PRIVATE void zgossip_msg_test (bool verbose); // Self test for private classes CZMQ_PRIVATE void czmq_private_selftest (bool verbose); #endif // CZMQ_BUILD_DRAFT_API #endif czmq-4.1.0/src/zfile.c0000664000372000037200000006463713222211156015447 0ustar00travistravis00000000000000/* ========================================================================= zfile - provides methods to work with files in a portable fashion. Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zfile class provides methods to work with disk files. A file object provides the modified date, current size, and type of the file. You can create a file object for a filename that does not yet exist. To read or write data from the file, use the input and output methods, and then read and write chunks. The output method lets you both read and write chunks, at any offset. Finally, this class provides portable symbolic links. If a filename ends in ".ln", the first line of text in the file is read, and used as the underlying file for read/write operations. This lets you manipulate (e.g.) copy symbolic links without copying the perhaps very large files they point to. @discuss This class is a new API, deprecating the old zfile class (which still exists but is implemented in zsys now). @end */ #include "czmq_classes.h" // Structure of our class struct _zfile_t { // Properties for all file objects char *fullname; // File name with path char *link; // Optional linked file bool exists; // true if file exists bool stable; // true if file is stable bool eof; // true if at end of file FILE *handle; // Read/write handle zdigest_t *digest; // File digest, if known char *curline; // Last read line, if any size_t linemax; // Size of allocated buffer bool remove_on_destroy; // Whenever delete file on destroy // Typically for tempfiles int fd; // File descriptor - set up by zfile_tmp bool close_fd; // XXX: for some reason self->fd == 0 in // zdir and zdir_patch tests, this is a // workaround for the problem // Properties from files that exist on file system time_t modified; // Modification time off_t cursize; // Size of the file mode_t mode; // POSIX permission bits }; // -------------------------------------------------------------------------- // Constructor // If file exists, populates properties. CZMQ supports portable symbolic // links, which are files with the extension ".ln". A symbolic link is a // text file containing one line, the filename of a target file. Reading // data from the symbolic link actually reads from the target file. Path // may be NULL, in which case it is not used. zfile_t * zfile_new (const char *path, const char *name) { zfile_t *self = (zfile_t *) zmalloc (sizeof (zfile_t)); assert (self); // Format full path to file if (path) { self->fullname = (char *) zmalloc (strlen (path) + strlen (name) + 2); assert (self->fullname); sprintf (self->fullname, "%s/%s", path, name); } else self->fullname = strdup (name); // Resolve symbolic link if possible if (strlen (self->fullname) > 3 && streq (self->fullname + strlen (self->fullname) - 3, ".ln")) { FILE *handle = fopen (self->fullname, "r"); if (handle) { char buffer [256]; if (fgets (buffer, 256, handle)) { // We have the contents of the symbolic link if (buffer [strlen (buffer) - 1] == '\n') buffer [strlen (buffer) - 1] = 0; self->link = strdup (buffer); // Chop ".ln" off name for external use if (self->link) self->fullname [strlen (self->fullname) - 3] = 0; else { fclose (handle); zfile_destroy (&self); return NULL; } } fclose (handle); } } self->handle = 0; zfile_restat (self); self->fd = -1; self->close_fd = false; return self; } // -------------------------------------------------------------------------- // Constructor // Create new temporary file for writing via tmpfile. File is automaticaly // deleted on destroy zfile_t * zfile_tmp (void) { zfile_t *self = NULL; #if defined (__WINDOWS__) DWORD result; UINT value; char name [MAX_PATH]; char path [MAX_PATH]; result = GetTempPathA (MAX_PATH, path); if (result > MAX_PATH || (result == 0)) return NULL; value = GetTempFileNameA (path, "CZMQ_ZFILE", 0, name); if (value == 0) return NULL; self = (zfile_t *) zmalloc (sizeof (zfile_t)); assert (self); self->fullname = strdup (name); self->handle = fopen (self->fullname, "w"); #else char buffer [PATH_MAX]; strcpy (buffer, "/tmp/czmq_zfile.XXXXXX"); int fd = mkstemp (buffer); if (fd == -1) return NULL; self = (zfile_t *) zmalloc (sizeof (zfile_t)); assert (self); self->fd = fd; self->close_fd = true; self->fullname = strdup (buffer); self->handle = fdopen (self->fd, "w"); #endif if (!self->handle) { if (self->close_fd) close (self->fd); zstr_free (&self->fullname); free (self); return NULL; } self->remove_on_destroy = true; zfile_restat (self); return self; } // -------------------------------------------------------------------------- // Destroy a file item void zfile_destroy (zfile_t **self_p) { assert (self_p); if (*self_p) { zfile_t *self = *self_p; zdigest_destroy (&self->digest); if (self->remove_on_destroy) zfile_remove (self); zfile_close (self); freen (self->fullname); freen (self->curline); freen (self->link); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Duplicate a file item, returns a newly constructed item. If the file // is null, or memory was exhausted, returns null. zfile_t * zfile_dup (zfile_t *self) { if (self) { zfile_t *copy = (zfile_t *) zmalloc (sizeof (zfile_t)); assert (copy); copy->fullname = strdup (self->fullname); assert (copy->fullname); copy->modified = self->modified; copy->cursize = self->cursize; copy->link = self->link? strdup (self->link): NULL; copy->mode = self->mode; return copy; } else return NULL; } // -------------------------------------------------------------------------- // Return file name, remove path if provided const char * zfile_filename (zfile_t *self, const char *path) { assert (self); char *name = self->fullname; if (path && strlen (self->fullname) >= strlen (path) && memcmp (self->fullname, path, strlen (path)) == 0) { name += strlen (path); while (*name == '/') name++; } return name; } // -------------------------------------------------------------------------- // Refresh file properties from disk; this is not done automatically // on access methods, otherwise it is not possible to compare directory // snapshots. void zfile_restat (zfile_t *self) { assert (self); struct stat stat_buf; char *real_name = self->link? self->link: self->fullname; if (stat (real_name, &stat_buf) == 0) { self->cursize = stat_buf.st_size; self->modified = stat_buf.st_mtime; self->mode = zsys_file_mode (real_name); self->stable = zsys_file_stable (real_name); } else { if(self->handle) { long cpos = ftell(self->handle); fseek(self->handle, 0L, SEEK_END); self->cursize = ftell(self->handle); fseek(self->handle, cpos, SEEK_SET); } else { self->cursize = 0; } self->modified = 0; self->mode = 0; self->stable = false; } zdigest_destroy (&self->digest); } // -------------------------------------------------------------------------- // Return when the file was last modified. If you want this to reflect the // current situation, call zfile_restat before checking this property. time_t zfile_modified (zfile_t *self) { assert (self); return self->modified; } // -------------------------------------------------------------------------- // Return the last-known size of the file. If you want this to reflect the // current situation, call zfile_restat before checking this property. off_t zfile_cursize (zfile_t *self) { assert (self); return self->cursize; } // -------------------------------------------------------------------------- // Return true if the file is a directory. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool zfile_is_directory (zfile_t *self) { assert (self); return S_ISDIR (self->mode); } // -------------------------------------------------------------------------- // Return true if the file is a regular file. If you want this to reflect // any external changes, call zfile_restat before checking this property. bool zfile_is_regular (zfile_t *self) { assert (self); return S_ISREG (self->mode); } // -------------------------------------------------------------------------- // Return true if the file is readable by this process. If you want this to // reflect any external changes, call zfile_restat before checking this // property. bool zfile_is_readable (zfile_t *self) { assert (self); return (self->mode & S_IRUSR) != 0; } // -------------------------------------------------------------------------- // Return true if the file is writeable by this process. If you want this // to reflect any external changes, call zfile_restat before checking this // property. bool zfile_is_writeable (zfile_t *self) { assert (self); return (self->mode & S_IWUSR) != 0; } // -------------------------------------------------------------------------- // Check if file has stopped changing and can be safely processed. // If you want this to reflect the current situation, call zfile_restat // before checking this property. bool zfile_is_stable (zfile_t *self) { assert (self); return self->stable; } // -------------------------------------------------------------------------- // Return true if the file was changed on disk since the zfile_t object // was created, or the last zfile_restat() call made on it. Note that the // file will not necessarily yet be stable. bool zfile_has_changed (zfile_t *self) { assert (self); struct stat stat_buf; char *real_name = self->link? self->link: self->fullname; if (stat (real_name, &stat_buf) == 0) { // It's not a foolproof heuristic but catches most cases if (stat_buf.st_mtime != self->modified || stat_buf.st_size != self->cursize) return true; } return false; } // -------------------------------------------------------------------------- // Remove the file void zfile_remove (zfile_t *self) { assert (self); // Restore ".ln" in file name if this was a symbolic link if (self->link) self->fullname [strlen (self->fullname)] = '.'; zfile_close (self); zsys_file_delete (self->fullname); } // -------------------------------------------------------------------------- // Open file for reading // Returns 0 if OK, -1 if not found or not accessible int zfile_input (zfile_t *self) { assert (self); if (self->handle) zfile_close (self); char *real_name = self->link? self->link: self->fullname; self->handle = fopen (real_name, "rb"); if (self->handle) { struct stat stat_buf; if (stat (real_name, &stat_buf) == 0) { self->cursize = stat_buf.st_size; } else { long cpos = ftell(self->handle); fseek(self->handle, 0L, SEEK_END); self->cursize = ftell(self->handle); fseek(self->handle, cpos, SEEK_SET); } } return self->handle? 0: -1; } // -------------------------------------------------------------------------- // Open file for writing, creating directory if needed // File is created if necessary; chunks can be written to file at any // location. Returns 0 if OK, -1 if error. int zfile_output (zfile_t *self) { int rc; assert (self); // Create file path if it doesn't exist char *file_path = strdup (self->fullname); if (!file_path) return -1; char *last_slash = strrchr (file_path, '/'); if (last_slash) *last_slash = 0; // Wipe symbolic link if that's what the file was if (self->link) { freen (self->link); self->link = NULL; } rc = zsys_dir_create (file_path); freen (file_path); if (rc != 0) return -1; // Create file if it doesn't exist if (self->handle) zfile_close (self); self->handle = fopen (self->fullname, "r+b"); if (!self->handle) self->handle = fopen (self->fullname, "w+b"); return self->handle? 0: -1; } // -------------------------------------------------------------------------- // Read chunk from file at specified position. If this was the last chunk, // sets the eof property. Returns a null chunk in case of error. zchunk_t * zfile_read (zfile_t *self, size_t bytes, off_t offset) { assert (self); assert (self->handle); self->eof = false; // Calculate real number of bytes to read if (offset > self->cursize) { // if we tried to read 'after' the cursise, then we are at the end bytes = 0; self->eof = true; } else if (bytes > (size_t) (self->cursize - offset)) { // if we are trying to read more than there is, we are at the end self->eof = true; bytes = (size_t) (self->cursize - offset); } if (fseek (self->handle, (long) offset, SEEK_SET) == -1) { return NULL; } return zchunk_read (self->handle, bytes); } // -------------------------------------------------------------------------- // Returns the eof property. bool zfile_eof (zfile_t *self) { assert (self); return self->eof; } // -------------------------------------------------------------------------- // Write chunk to file at specified position // Return 0 if OK, else -1 int zfile_write (zfile_t *self, zchunk_t *chunk, off_t offset) { assert (self); assert (self->handle); int rc = fseek (self->handle, (long) offset, SEEK_SET); if (rc >= 0) rc = zchunk_write (chunk, self->handle); return rc; } // -------------------------------------------------------------------------- // Read next line of text from file. Returns a pointer to the text line, // or NULL if there was nothing more to read from the file. const char * zfile_readln (zfile_t *self) { assert (self); assert (self->handle); // Opportunistically allocate line buffer if needed; we'll grow this // if needed, so the initial linemax is not a big deal if (!self->curline) { self->linemax = 512; self->curline = (char *) malloc (self->linemax); assert (self->curline); } uint char_nbr = 0; while (true) { int cur_char = fgetc (self->handle); if (cur_char == '\r') continue; // Skip CR in MS-DOS format files else if (cur_char == EOF && char_nbr == 0) return NULL; // Signal end of file else if (cur_char == '\n' || cur_char == EOF) cur_char = 0; if (char_nbr == self->linemax - 1) { self->linemax *= 2; self->curline = (char *) realloc (self->curline, self->linemax); } self->curline [char_nbr++] = cur_char; if (cur_char == 0) break; } return self->curline; } // -------------------------------------------------------------------------- // Close file, if open void zfile_close (zfile_t *self) { assert (self); if (self->handle) { fclose (self->handle); self->handle = 0; zfile_restat (self); self->eof = false; } if (self->close_fd) close (self->fd); } // -------------------------------------------------------------------------- // Return file handle, if opened FILE * zfile_handle (zfile_t *self) { assert (self); return self->handle; } // -------------------------------------------------------------------------- // Calculate SHA1 digest for file, using zdigest class. const char * zfile_digest (zfile_t *self) { assert (self); if (!self->digest) { if (zfile_input (self) == -1) return NULL; // Problem reading file // Now calculate hash for file data, chunk by chunk long blocksz = 65535; off_t offset = 0; self->digest = zdigest_new (); if (!self->digest) return NULL; zchunk_t *chunk = zfile_read (self, blocksz, offset); while (zchunk_size (chunk)) { zdigest_update (self->digest, zchunk_data (chunk), zchunk_size (chunk)); zchunk_destroy (&chunk); // off_t is defined as long (32 bit on Windows, 64 bit otherwise) // This guards against overflow in both contexts. if (blocksz > LONG_MAX - offset) return NULL; offset += blocksz; chunk = zfile_read (self, (size_t) blocksz, offset); } zchunk_destroy (&chunk); fclose (self->handle); self->handle = 0; } return zdigest_string (self->digest); } // Deprecated API, moved to zsys class. The zfile class works with // an object instance, which is more consistent with the CLASS style // and lets us do more interesting things. These functions were // essentially about portability, so now sit in zsys. bool zfile_exists (const char *filename) { return zsys_file_exists (filename); } ssize_t zfile_size (const char *filename) { return zsys_file_size (filename); } mode_t zfile_mode (const char *filename) { return zsys_file_mode (filename); } int zfile_delete (const char *filename) { return zsys_file_delete (filename); } bool zfile_stable (const char *filename) { return zsys_file_stable (filename); } int zfile_mkdir (const char *pathname) { return zsys_dir_create (pathname); } int zfile_rmdir (const char *pathname) { return zsys_dir_delete (pathname); } void zfile_mode_private (void) { zsys_file_mode_private (); } void zfile_mode_default (void) { zsys_file_mode_default (); } // -------------------------------------------------------------------------- // Self test of this class void zfile_test (bool verbose) { printf (" * zfile: "); // @selftest const char *SELFTEST_DIR_RW = "src/selftest-rw"; const char *testbasedir = "this"; const char *testsubdir = "is/a/test"; const char *testfile = "bilbo"; const char *testlink = "bilbo.ln"; char *basedirpath = NULL; // subdir in a test, under SELFTEST_DIR_RW char *dirpath = NULL; // subdir in a test, under basedirpath char *filepath = NULL; // pathname to testfile in a test, in dirpath char *linkpath = NULL; // pathname to testlink in a test, in dirpath basedirpath = zsys_sprintf ("%s/%s", SELFTEST_DIR_RW, testbasedir); assert (basedirpath); dirpath = zsys_sprintf ("%s/%s", basedirpath, testsubdir); assert (dirpath); filepath = zsys_sprintf ("%s/%s", dirpath, testfile); assert (filepath); linkpath = zsys_sprintf ("%s/%s", dirpath, testlink); assert (linkpath); // This subtest is specifically for NULL as current directory, so // no SELFTEST_DIR_RW here; testfile should have no slashes inside. // Normally tests clean up in zfile_destroy(), but if a selftest run // dies e.g. on assert(), workspace remains dirty. Better clean it up. if (zfile_exists (testfile) ) { if (verbose) zsys_debug ("zfile_test() has to remove ./%s that should not have been here", testfile); zfile_delete (testfile); } zfile_t *file = zfile_new (NULL, testfile); assert (file); assert (streq (zfile_filename (file, "."), testfile)); assert (zfile_is_readable (file) == false); zfile_destroy (&file); // Create a test file in some random subdirectory if (verbose) zsys_debug ("zfile_test() at timestamp %" PRIi64 ": " "Creating new zfile %s", zclock_time(), filepath ); if (zfile_exists (filepath) ) { if (verbose) zsys_debug ("zfile_test() has to remove %s that should not have been here", filepath); zfile_delete (filepath); } file = zfile_new (dirpath, testfile); assert (file); int rc = zfile_output (file); assert (rc == 0); zchunk_t *chunk = zchunk_new (NULL, 100); assert (chunk); zchunk_fill (chunk, 0, 100); // Write 100 bytes at position 1,000,000 in the file if (verbose) zsys_debug ("zfile_test() at timestamp %" PRIi64 ": " "Writing 100 bytes at position 1,000,000 in the file", zclock_time() ); rc = zfile_write (file, chunk, 1000000); if (verbose) zsys_debug ("zfile_test() at timestamp %" PRIi64 ": " "Wrote 100 bytes at position 1,000,000 in the file, result code %d", zclock_time(), rc ); assert (rc == 0); zchunk_destroy (&chunk); zfile_close (file); assert (zfile_is_readable (file)); assert (zfile_cursize (file) == 1000100); if (verbose) zsys_debug ("zfile_test() at timestamp %" PRIi64 ": " "Testing if file is NOT stable (is younger than 1 sec)", zclock_time() ); assert (!zfile_is_stable (file)); if (verbose) zsys_debug ("zfile_test() at timestamp %" PRIi64 ": " "Passed the lag-dependent tests", zclock_time() ); assert (zfile_digest (file)); // Now truncate file from outside int handle = open (filepath, O_WRONLY | O_TRUNC | O_BINARY, 0); assert (handle >= 0); rc = write (handle, "Hello, World\n", 13); assert (rc == 13); close (handle); assert (zfile_has_changed (file)); #ifdef CZMQ_BUILD_DRAFT_API zclock_sleep ((int)zsys_file_stable_age_msec() + 50); #else zclock_sleep (5050); #endif assert (zfile_has_changed (file)); assert (!zfile_is_stable (file)); zfile_restat (file); assert (zfile_is_stable (file)); assert (streq (zfile_digest (file), "4AB299C8AD6ED14F31923DD94F8B5F5CB89DFB54")); // Check we can read from file rc = zfile_input (file); assert (rc == 0); chunk = zfile_read (file, 1000100, 0); assert (chunk); assert (zchunk_size (chunk) == 13); zchunk_destroy (&chunk); zfile_close (file); // Check we can read lines from file rc = zfile_input (file); assert (rc == 0); const char *line = zfile_readln (file); assert (streq (line, "Hello, World")); line = zfile_readln (file); assert (line == NULL); zfile_close (file); // Try some fun with symbolic links zfile_t *link = zfile_new (dirpath, testlink); assert (link); rc = zfile_output (link); assert (rc == 0); fprintf (zfile_handle (link), "%s\n", filepath); zfile_destroy (&link); link = zfile_new (dirpath, testlink); assert (link); rc = zfile_input (link); assert (rc == 0); chunk = zfile_read (link, 1000100, 0); assert (chunk); assert (zchunk_size (chunk) == 13); zchunk_destroy (&chunk); zfile_destroy (&link); // Remove file and directory zdir_t *dir = zdir_new (basedirpath, NULL); assert (dir); assert (zdir_cursize (dir) == 26); zdir_remove (dir, true); assert (zdir_cursize (dir) == 0); zdir_destroy (&dir); // Check we can no longer read from file assert (zfile_is_readable (file)); zfile_restat (file); assert (!zfile_is_readable (file)); rc = zfile_input (file); assert (rc == -1); zfile_destroy (&file); // This set of tests is done, free the strings for reuse zstr_free (&basedirpath); zstr_free (&dirpath); zstr_free (&filepath); zstr_free (&linkpath); const char *eof_checkfile = "eof_checkfile"; filepath = zsys_sprintf ("%s/%s", SELFTEST_DIR_RW, eof_checkfile); assert (filepath); if (zfile_exists (filepath) ) { if (verbose) zsys_debug ("zfile_test() has to remove %s that should not have been here", filepath); zfile_delete (filepath); } zstr_free (&filepath); file = zfile_new (SELFTEST_DIR_RW, eof_checkfile); assert (file); // 1. Write something first rc = zfile_output (file); assert (rc == 0); chunk = zchunk_new ("123456789", 9); assert (chunk); rc = zfile_write (file, chunk, 0); assert (rc == 0); zchunk_destroy (&chunk); zfile_close (file); assert (zfile_cursize (file) == 9); // 2. Read the written something rc = zfile_input (file); assert (rc != -1); // try to read more bytes than there is in the file chunk = zfile_read (file, 1000, 0); assert (zfile_eof(file)); assert (zchunk_streq (chunk, "123456789")); zchunk_destroy (&chunk); // reading is ok chunk = zfile_read (file, 5, 0); assert (!zfile_eof(file)); assert (zchunk_streq (chunk, "12345")); zchunk_destroy (&chunk); // read from non zero offset until the end chunk = zfile_read (file, 5, 5); assert (zfile_eof(file)); assert (zchunk_streq (chunk, "6789")); zchunk_destroy (&chunk); zfile_remove (file); zfile_close (file); zfile_destroy (&file); #ifdef CZMQ_BUILD_DRAFT_API zfile_t *tempfile = zfile_tmp (); assert (tempfile); assert (zfile_filename (tempfile, NULL)); assert (zsys_file_exists (zfile_filename (tempfile, NULL))); zchunk_t *tchunk = zchunk_new ("HELLO", 6); assert (zfile_write (tempfile, tchunk, 0) == 0); zchunk_destroy (&tchunk); char *filename = strdup (zfile_filename (tempfile, NULL)); zfile_destroy (&tempfile); assert (!zsys_file_exists (filename)); zstr_free (&filename); #endif // CZMQ_BUILD_DRAFT_API #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zgossip_engine.inc0000664000372000037200000010632013222211156017672 0ustar00travistravis00000000000000/* ========================================================================= zgossip_engine - zgossip engine ** WARNING ************************************************************* THIS SOURCE FILE IS 100% GENERATED. If you edit this file, you will lose your changes at the next build cycle. This is great for temporary printf statements. DO NOT MAKE ANY CHANGES YOU WISH TO KEEP. The correct places for commits are: * The XML model used for this code generation: zgossip.xml, or * The code generation script that built this file: zproto_server_c ************************************************************************ Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifdef NDEBUG #undef NDEBUG #endif #define ZPROTO_UNUSED(object) (void)object // --------------------------------------------------------------------------- // State machine constants typedef enum { start_state = 1, have_tuple_state = 2, connected_state = 3, external_state = 4 } state_t; typedef enum { NULL_event = 0, terminate_event = 1, hello_event = 2, ok_event = 3, finished_event = 4, publish_event = 5, forward_event = 6, ping_event = 7, expired_event = 8 } event_t; // Names for state machine logging and error reporting static char * s_state_name [] = { "(NONE)", "start", "have tuple", "connected", "external" }; static char * s_event_name [] = { "(NONE)", "terminate", "HELLO", "ok", "finished", "PUBLISH", "forward", "PING", "expired" }; // --------------------------------------------------------------------------- // Context for the whole server task. This embeds the application-level // server context at its start (the entire structure, not a reference), // so we can cast a pointer between server_t and s_server_t arbitrarily. typedef struct { server_t server; // Application-level server context zsock_t *pipe; // Socket to back to caller API zsock_t *router; // Socket to talk to clients int port; // Server port bound to zloop_t *loop; // Reactor for server sockets zgossip_msg_t *message; // Message received or sent zhash_t *clients; // Clients we're connected to zconfig_t *config; // Configuration tree uint client_id; // Client identifier counter size_t timeout; // Default client expiry timeout bool verbose; // Verbose logging enabled? char *log_prefix; // Default log prefix } s_server_t; // --------------------------------------------------------------------------- // Context for each connected client. This embeds the application-level // client context at its start (the entire structure, not a reference), // so we can cast a pointer between client_t and s_client_t arbitrarily. typedef struct { client_t client; // Application-level client context s_server_t *server; // Parent server context char *hashkey; // Key into server->clients hash zframe_t *routing_id; // Routing_id back to client uint unique_id; // Client identifier in server state_t state; // Current state event_t event; // Current event event_t next_event; // The next event event_t exception; // Exception event, if any int wakeup; // zloop timer for client alarms void *ticket; // zloop ticket for client timeouts event_t wakeup_event; // Wake up with this event char log_prefix [41]; // Log prefix string } s_client_t; static int server_initialize (server_t *self); static void server_terminate (server_t *self); static zmsg_t * server_method (server_t *self, const char *method, zmsg_t *msg); static void server_configuration (server_t *self, zconfig_t *config); static int client_initialize (client_t *self); static void client_terminate (client_t *self); static void s_server_config_global (s_server_t *server); static void s_client_execute (s_client_t *client, event_t event); static int s_client_handle_wakeup (zloop_t *loop, int timer_id, void *argument); static int s_client_handle_ticket (zloop_t *loop, int timer_id, void *argument); static void get_first_tuple (client_t *self); static void get_next_tuple (client_t *self); static void store_tuple_if_new (client_t *self); static void get_tuple_to_forward (client_t *self); // --------------------------------------------------------------------------- // These methods are an internal API for actions // Set the next event, needed in at least one action in an internal // state; otherwise the state machine will wait for a message on the // router socket and treat that as the event. static void engine_set_next_event (client_t *client, event_t event) { if (client) { s_client_t *self = (s_client_t *) client; self->next_event = event; } } // Raise an exception with 'event', halting any actions in progress. // Continues execution of actions defined for the exception event. static void engine_set_exception (client_t *client, event_t event) { if (client) { s_client_t *self = (s_client_t *) client; self->exception = event; } } // Set wakeup alarm after 'delay' msecs. The next state should // handle the wakeup event. The alarm is cancelled on any other // event. static void engine_set_wakeup_event (client_t *client, size_t delay, event_t event) { if (client) { s_client_t *self = (s_client_t *) client; if (self->wakeup) { zloop_timer_end (self->server->loop, self->wakeup); self->wakeup = 0; } self->wakeup = zloop_timer ( self->server->loop, delay, 1, s_client_handle_wakeup, self); self->wakeup_event = event; } } // Execute 'event' on specified client. Use this to send events to // other clients. Cancels any wakeup alarm on that client. static void engine_send_event (client_t *client, event_t event) { if (client) { s_client_t *self = (s_client_t *) client; s_client_execute (self, event); } } // Execute 'event' on all clients known to the server. If you pass a // client argument, that client will not receive the broadcast. If you // want to pass any arguments, store them in the server context. static void engine_broadcast_event (server_t *server, client_t *client, event_t event) { if (server) { s_server_t *self = (s_server_t *) server; zlist_t *keys = zhash_keys (self->clients); char *key = (char *) zlist_first (keys); while (key) { s_client_t *target = (s_client_t *) zhash_lookup (self->clients, key); if (target != (s_client_t *) client) s_client_execute (target, event); key = (char *) zlist_next (keys); } zlist_destroy (&keys); } } // Poll actor or zsock for activity, invoke handler on any received // message. Handler must be a CZMQ zloop_fn function; receives server // as arg. static void engine_handle_socket (server_t *server, void *sock, zloop_reader_fn handler) { if (server) { s_server_t *self = (s_server_t *) server; // Resolve zactor_t -> zsock_t if (zactor_is (sock)) sock = zactor_sock ((zactor_t *) sock); else assert (zsock_is (sock)); if (handler != NULL) { int rc = zloop_reader (self->loop, (zsock_t *) sock, handler, self); assert (rc == 0); zloop_reader_set_tolerant (self->loop, (zsock_t *) sock); } else zloop_reader_end (self->loop, (zsock_t *) sock); } } // Register monitor function that will be called at regular intervals // by the server engine. Returns an identifier that can be used to cancel it. static int engine_set_monitor (server_t *server, size_t interval, zloop_timer_fn monitor) { if (server) { s_server_t *self = (s_server_t *) server; int rc = zloop_timer (self->loop, interval, 0, monitor, self); assert (rc >= 0); return rc; } return -1; } // Cancel the monitor function with the given identifier. static void engine_cancel_monitor (server_t *server, int identifier) { if (server) { s_server_t *self = (s_server_t *) server; int rc = zloop_timer_end (self->loop, identifier); assert (rc >= 0); } } // Set log file prefix; this string will be added to log data, to make // log data more searchable. The string is truncated to ~20 chars. static void engine_set_log_prefix (client_t *client, const char *string) { if (client) { s_client_t *self = (s_client_t *) client; snprintf (self->log_prefix, sizeof (self->log_prefix), "%6d:%-33s", self->unique_id, string); } } // Set a configuration value in the server's configuration tree. The // properties this engine uses are: server/verbose, server/timeout, and // server/background. You can also configure other abitrary properties. static void engine_configure (server_t *server, const char *path, const char *value) { if (server) { s_server_t *self = (s_server_t *) server; zconfig_put (self->config, path, value); s_server_config_global (self); } } // Return true if server is running in verbose mode, else return false. static bool engine_verbose (server_t *server) { if (server) { s_server_t *self = (s_server_t *) server; return self->verbose; } return false; } // Pedantic compilers don't like unused functions, so we call the whole // API, passing null references. It's nasty and horrid and sufficient. static void s_satisfy_pedantic_compilers (void) { engine_set_next_event (NULL, NULL_event); engine_set_exception (NULL, NULL_event); engine_set_wakeup_event (NULL, 0, NULL_event); engine_send_event (NULL, NULL_event); engine_broadcast_event (NULL, NULL, NULL_event); engine_handle_socket (NULL, 0, NULL); engine_set_monitor (NULL, 0, NULL); engine_cancel_monitor (NULL, 0); engine_set_log_prefix (NULL, NULL); engine_configure (NULL, NULL, NULL); engine_verbose (NULL); } // --------------------------------------------------------------------------- // Generic methods on protocol messages // TODO: replace with lookup table, since ID is one byte static event_t s_protocol_event (zgossip_msg_t *message) { assert (message); switch (zgossip_msg_id (message)) { case ZGOSSIP_MSG_HELLO: return hello_event; break; case ZGOSSIP_MSG_PUBLISH: return publish_event; break; case ZGOSSIP_MSG_PING: return ping_event; break; default: // Invalid zgossip_msg_t return terminate_event; } } // --------------------------------------------------------------------------- // Client methods static s_client_t * s_client_new (s_server_t *server, zframe_t *routing_id) { s_client_t *self = (s_client_t *) zmalloc (sizeof (s_client_t)); assert (self); assert ((s_client_t *) &self->client == self); self->server = server; self->hashkey = zframe_strhex (routing_id); self->routing_id = zframe_dup (routing_id); self->unique_id = server->client_id++; engine_set_log_prefix (&self->client, server->log_prefix); self->client.server = (server_t *) server; self->client.message = server->message; // If expiry timers are being used, create client ticket if (server->timeout) self->ticket = zloop_ticket (server->loop, s_client_handle_ticket, self); // Give application chance to initialize and set next event self->state = start_state; self->event = NULL_event; client_initialize (&self->client); return self; } static void s_client_destroy (s_client_t **self_p) { assert (self_p); if (*self_p) { s_client_t *self = *self_p; if (self->wakeup) zloop_timer_end (self->server->loop, self->wakeup); if (self->ticket) zloop_ticket_delete (self->server->loop, self->ticket); zframe_destroy (&self->routing_id); // Provide visual clue if application misuses client reference engine_set_log_prefix (&self->client, "*** TERMINATED ***"); client_terminate (&self->client); free (self->hashkey); free (self); *self_p = NULL; } } // Callback when we remove client from 'clients' hash table static void s_client_free (void *argument) { s_client_t *client = (s_client_t *) argument; s_client_destroy (&client); } // Execute state machine as long as we have events static void s_client_execute (s_client_t *self, event_t event) { self->next_event = event; // Cancel wakeup timer, if any was pending if (self->wakeup) { zloop_timer_end (self->server->loop, self->wakeup); self->wakeup = 0; } while (self->next_event > 0) { self->event = self->next_event; self->next_event = NULL_event; self->exception = NULL_event; if (self->server->verbose) { zsys_debug ("%s: %s:", self->log_prefix, s_state_name [self->state]); zsys_debug ("%s: %s", self->log_prefix, s_event_name [self->event]); } switch (self->state) { case start_state: if (self->event == hello_event) { if (!self->exception) { // get first tuple if (self->server->verbose) zsys_debug ("%s: $ get first tuple", self->log_prefix); get_first_tuple (&self->client); } if (!self->exception) self->state = have_tuple_state; } else if (self->event == ping_event) { if (!self->exception) { // send PONG if (self->server->verbose) zsys_debug ("%s: $ send PONG", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_PONG); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } } else if (self->event == expired_event) { if (!self->exception) { // terminate if (self->server->verbose) zsys_debug ("%s: $ terminate", self->log_prefix); self->next_event = terminate_event; } } else { // Handle unexpected protocol events if (!self->exception) { // send INVALID if (self->server->verbose) zsys_debug ("%s: $ send INVALID", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_INVALID); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } if (!self->exception) { // terminate if (self->server->verbose) zsys_debug ("%s: $ terminate", self->log_prefix); self->next_event = terminate_event; } } break; case have_tuple_state: if (self->event == ok_event) { if (!self->exception) { // send PUBLISH if (self->server->verbose) zsys_debug ("%s: $ send PUBLISH", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_PUBLISH); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } if (!self->exception) { // get next tuple if (self->server->verbose) zsys_debug ("%s: $ get next tuple", self->log_prefix); get_next_tuple (&self->client); } } else if (self->event == finished_event) { if (!self->exception) self->state = connected_state; } else { // Handle unexpected internal events zsys_warning ("%s: unhandled event %s in %s", self->log_prefix, s_event_name [self->event], s_state_name [self->state]); assert (false); } break; case connected_state: if (self->event == publish_event) { if (!self->exception) { // store tuple if new if (self->server->verbose) zsys_debug ("%s: $ store tuple if new", self->log_prefix); store_tuple_if_new (&self->client); } } else if (self->event == forward_event) { if (!self->exception) { // get tuple to forward if (self->server->verbose) zsys_debug ("%s: $ get tuple to forward", self->log_prefix); get_tuple_to_forward (&self->client); } if (!self->exception) { // send PUBLISH if (self->server->verbose) zsys_debug ("%s: $ send PUBLISH", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_PUBLISH); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } } else if (self->event == ping_event) { if (!self->exception) { // send PONG if (self->server->verbose) zsys_debug ("%s: $ send PONG", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_PONG); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } } else if (self->event == expired_event) { if (!self->exception) { // terminate if (self->server->verbose) zsys_debug ("%s: $ terminate", self->log_prefix); self->next_event = terminate_event; } } else { // Handle unexpected protocol events if (!self->exception) { // send INVALID if (self->server->verbose) zsys_debug ("%s: $ send INVALID", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_INVALID); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } if (!self->exception) { // terminate if (self->server->verbose) zsys_debug ("%s: $ terminate", self->log_prefix); self->next_event = terminate_event; } } break; case external_state: if (self->event == ping_event) { if (!self->exception) { // send PONG if (self->server->verbose) zsys_debug ("%s: $ send PONG", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_PONG); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } } else if (self->event == expired_event) { if (!self->exception) { // terminate if (self->server->verbose) zsys_debug ("%s: $ terminate", self->log_prefix); self->next_event = terminate_event; } } else { // Handle unexpected protocol events if (!self->exception) { // send INVALID if (self->server->verbose) zsys_debug ("%s: $ send INVALID", self->log_prefix); zgossip_msg_set_id (self->server->message, ZGOSSIP_MSG_INVALID); zgossip_msg_set_routing_id (self->server->message, self->routing_id); zgossip_msg_send (self->server->message, self->server->router); } if (!self->exception) { // terminate if (self->server->verbose) zsys_debug ("%s: $ terminate", self->log_prefix); self->next_event = terminate_event; } } break; } // If we had an exception event, interrupt normal programming if (self->exception) { if (self->server->verbose) zsys_debug ("%s: ! %s", self->log_prefix, s_event_name [self->exception]); self->next_event = self->exception; } if (self->next_event == terminate_event) { // Automatically calls s_client_destroy zhash_delete (self->server->clients, self->hashkey); break; } else if (self->server->verbose) zsys_debug ("%s: > %s", self->log_prefix, s_state_name [self->state]); } } // zloop callback when client ticket expires static int s_client_handle_ticket (zloop_t *loop, int timer_id, void *argument) { s_client_t *self = (s_client_t *) argument; self->ticket = NULL; // Ticket is now dead s_client_execute (self, expired_event); return 0; } // zloop callback when client wakeup timer expires static int s_client_handle_wakeup (zloop_t *loop, int timer_id, void *argument) { ZPROTO_UNUSED(loop); ZPROTO_UNUSED(timer_id); s_client_t *self = (s_client_t *) argument; s_client_execute (self, self->wakeup_event); return 0; } // Server methods static void s_server_config_global (s_server_t *self) { // Built-in server configuration options // // If we didn't already set verbose, check if the config tree wants it if (!self->verbose && atoi (zconfig_get (self->config, "server/verbose", "0"))) self->verbose = true; // Default client timeout is 60 seconds self->timeout = atoi ( zconfig_get (self->config, "server/timeout", "60000")); zloop_set_ticket_delay (self->loop, self->timeout); // Do we want to run server in the background? int background = atoi ( zconfig_get (self->config, "server/background", "0")); if (!background) zsys_set_logstream (stdout); } static s_server_t * s_server_new (zsock_t *pipe) { s_server_t *self = (s_server_t *) zmalloc (sizeof (s_server_t)); assert (self); assert ((s_server_t *) &self->server == self); self->pipe = pipe; self->router = zsock_new (ZMQ_ROUTER); assert (self->router); // By default the socket will discard outgoing messages above the // HWM of 1,000. This isn't helpful for high-volume streaming. We // will use a unbounded queue here. If applications need to guard // against queue overflow, they should use a credit-based flow // control scheme. zsock_set_unbounded (self->router); self->message = zgossip_msg_new (); self->clients = zhash_new (); self->config = zconfig_new ("root", NULL); self->loop = zloop_new (); srandom ((unsigned int) zclock_time ()); self->client_id = randof (1000); s_server_config_global (self); // Initialize application server context self->server.pipe = self->pipe; self->server.config = self->config; server_initialize (&self->server); s_satisfy_pedantic_compilers (); return self; } static void s_server_destroy (s_server_t **self_p) { assert (self_p); if (*self_p) { s_server_t *self = *self_p; zgossip_msg_destroy (&self->message); // Destroy clients before destroying the server zhash_destroy (&self->clients); server_terminate (&self->server); zsock_destroy (&self->router); zconfig_destroy (&self->config); zloop_destroy (&self->loop); free (self); *self_p = NULL; } } // Apply service-specific configuration tree: // * apply server configuration // * print any echo items in top-level sections // * apply sections that match methods static void s_server_config_service (s_server_t *self) { // Apply echo commands and class methods zconfig_t *section = zconfig_locate (self->config, "zgossip"); if (section) section = zconfig_child (section); while (section) { if (streq (zconfig_name (section), "echo")) zsys_notice ("%s", zconfig_value (section)); else if (streq (zconfig_name (section), "bind")) { char *endpoint = zconfig_get (section, "endpoint", "?"); if (zsock_bind (self->router, "%s", endpoint) == -1) zsys_warning ("could not bind to %s (%s)", endpoint, zmq_strerror (zmq_errno ())); } #if (ZMQ_VERSION_MAJOR >= 4) else if (streq (zconfig_name (section), "security")) { char *mechanism = zconfig_get (section, "mechanism", "null"); char *domain = zconfig_get (section, "domain", NULL); if (streq (mechanism, "null")) { zsys_notice ("server is using NULL security"); if (domain) zsock_set_zap_domain (self->router, NULL); } else if (streq (mechanism, "plain")) { zsys_notice ("server is using PLAIN security"); zsock_set_plain_server (self->router, 1); } #ifdef CZMQ_BUILD_DRAFT_API // TODO- zproto // https://github.com/zeromq/zproto/blob/master/src/zproto_server_c.gsl#L883 else if (streq (mechanism, "curve")) { zsys_notice ("using CURVE security"); const char *keyfile = zconfig_get (section, "secret-key", NULL); assert (keyfile); zcert_t *server_cert = zcert_load(keyfile); assert (server_cert); zcert_apply (server_cert, self->router); zsock_set_curve_server (self->router, 1); } #endif else zsys_warning ("mechanism=%s is not supported", mechanism); } #endif section = zconfig_next (section); } s_server_config_global (self); } // Process message from pipe static int s_server_handle_pipe (zloop_t *loop, zsock_t *reader, void *argument) { ZPROTO_UNUSED(loop); ZPROTO_UNUSED(reader); s_server_t *self = (s_server_t *) argument; zmsg_t *msg = zmsg_recv (self->pipe); if (!msg) return -1; // Interrupted; exit zloop char *method = zmsg_popstr (msg); if (self->verbose) zsys_debug ("%s: API command=%s", self->log_prefix, method); if (streq (method, "VERBOSE")) self->verbose = true; else if (streq (method, "$TERM")) { // Shutdown the engine zstr_free (&method); zmsg_destroy (&msg); return -1; } else if (streq (method, "BIND")) { // Bind to a specified endpoint, which may use an ephemeral port char *endpoint = zmsg_popstr (msg); #ifdef CZMQ_BUILD_DRAFT_API // TODO- expose self->router to application context ? // Add secret|public|zap to gsl(?) // move this block to custom server function when both keys are present if (self->server.secret_key) { zsock_set_zap_domain (self->router, self->server.zap_domain); zcert_t *cert = zcert_new_from_txt(self->server.public_key, self->server.secret_key); zcert_apply(cert, self->router); zsock_set_curve_server (self->router, 1); zcert_destroy(&cert); } // TODO- add this test in zproto_server_c.gsl #ifndef ZMQ_CURVE // zmq legacy bool ZMQ_CURVE = false; #endif if (self->server.secret_key) assert (zsock_mechanism (self->router) == ZMQ_CURVE); #endif self->port = zsock_bind (self->router, "%s", endpoint); if (self->port == -1) zsys_warning ("could not bind to %s", endpoint); zstr_free (&endpoint); } else if (streq (method, "PORT")) { // Return PORT + port number from the last bind, if any zstr_sendm (self->pipe, "PORT"); zstr_sendf (self->pipe, "%d", self->port); } else // Deprecated method name if (streq (method, "LOAD") || streq (method, "CONFIGURE")) { char *filename = zmsg_popstr (msg); zconfig_destroy (&self->config); self->config = zconfig_load (filename); if (self->config) { s_server_config_service (self); self->server.config = self->config; server_configuration (&self->server, self->config); } else { zsys_warning ("cannot load config file '%s'", filename); self->config = zconfig_new ("root", NULL); } zstr_free (&filename); } else if (streq (method, "SET")) { char *path = zmsg_popstr (msg); char *value = zmsg_popstr (msg); zconfig_put (self->config, path, value); if (streq (path, "server/animate")) { zsys_warning ("'%s' is deprecated, use VERBOSE command instead", path); self->verbose = (atoi (value) == 1); } s_server_config_global (self); zstr_free (&value); zstr_free (&path); } else if (streq (method, "SAVE")) { char *filename = zmsg_popstr (msg); if (zconfig_save (self->config, filename)) zsys_warning ("cannot save config file '%s'", filename); zstr_free (&filename); } else { // Execute custom method zmsg_t *reply = server_method (&self->server, method, msg); // If reply isn't null, send it to caller zmsg_send (&reply, self->pipe); } zstr_free (&method); zmsg_destroy (&msg); return 0; } // Handle a protocol message from the client static int s_server_handle_protocol (zloop_t *loop, zsock_t *reader, void *argument) { ZPROTO_UNUSED(loop); ZPROTO_UNUSED(reader); s_server_t *self = (s_server_t *) argument; // We process as many messages as we can, to reduce the overhead // of polling and the reactor: while (zsock_events (self->router) & ZMQ_POLLIN) { int rc = zgossip_msg_recv (self->message, self->router); if (rc == -1) return -1; // Interrupted; exit zloop // TODO: use binary hashing on routing_id char *hashkey = zframe_strhex (zgossip_msg_routing_id (self->message)); s_client_t *client = (s_client_t *) zhash_lookup (self->clients, hashkey); if (client == NULL) { client = s_client_new (self, zgossip_msg_routing_id (self->message)); zhash_insert (self->clients, hashkey, client); zhash_freefn (self->clients, hashkey, s_client_free); } free (hashkey); // Any input from client counts as activity if (client->ticket) zloop_ticket_reset (self->loop, client->ticket); if (rc == -2) { continue; // Malformed, but malformed_event doesn't exist // -> discard the message } // Pass to client state machine s_client_execute (client, s_protocol_event (self->message)); } return 0; } // Watch server config file and reload if changed static int s_watch_server_config (zloop_t *loop, int timer_id, void *argument) { ZPROTO_UNUSED(loop); ZPROTO_UNUSED(timer_id); s_server_t *self = (s_server_t *) argument; if (zconfig_has_changed (self->config) && zconfig_reload (&self->config) == 0) { s_server_config_service (self); self->server.config = self->config; server_configuration (&self->server, self->config); zsys_notice ("reloaded configuration from %s", zconfig_filename (self->config)); } return 0; } // --------------------------------------------------------------------------- // This is the server actor, which polls its two sockets and processes // incoming messages void zgossip (zsock_t *pipe, void *args) { // Initialize s_server_t *self = s_server_new (pipe); assert (self); zsock_signal (pipe, 0); // Actor argument may be a string used for logging self->log_prefix = args? (char *) args: ""; // Set-up server monitor to watch for config file changes engine_set_monitor ((server_t *) self, 1000, s_watch_server_config); // Set up handler for the two main sockets the server uses engine_handle_socket ((server_t *) self, self->pipe, s_server_handle_pipe); engine_handle_socket ((server_t *) self, self->router, s_server_handle_protocol); // Run reactor until there's a termination signal zloop_start (self->loop); // Reactor has ended s_server_destroy (&self); } czmq-4.1.0/src/zchunk.c0000664000372000037200000004166613222211156015635 0ustar00travistravis00000000000000/* ========================================================================= zchunk - work with memory chunks Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. =========================================================================*/ /* @header The zchunk class works with variable sized blobs. Not as efficient as ZeroMQ's messages but they do less weirdness and so are easier to understand. The chunk class has methods to read and write chunks from disk. @discuss @end */ #include "czmq_classes.h" // zchunk_t instances always have this tag as the first 4 octets of // their data, which lets us do runtime object typing & validation. #define ZCHUNK_TAG 0x0001cafe // Structure of our class struct _zchunk_t { uint32_t tag; // Object tag for runtime detection size_t size; // Current size of data part size_t max_size; // Maximum allocated size size_t consumed; // Amount already consumed zdigest_t *digest; // Chunk digest, if known byte *data; // Data part follows here }; // -------------------------------------------------------------------------- // Create a new chunk of the specified size. If you specify the data, it // is copied into the chunk. If you do not specify the data, the chunk is // allocated and left empty, and you can then add data using zchunk_append. zchunk_t * zchunk_new (const void *data, size_t size) { // Use malloc, not zmalloc, to avoid nullification costs zchunk_t *self = (zchunk_t *) malloc (sizeof (zchunk_t) + size); // Catch memory exhaustion in this specific class if (self) { self->tag = ZCHUNK_TAG; self->size = 0; self->max_size = size; self->consumed = 0; self->data = (byte *) self + sizeof (zchunk_t); self->digest = NULL; if (data) { self->size = size; memcpy (self->data, data, self->size); } } return self; } // -------------------------------------------------------------------------- // Destroy a chunk void zchunk_destroy (zchunk_t **self_p) { assert (self_p); if (*self_p) { zchunk_t *self = *self_p; assert (zchunk_is (self)); // If data was reallocated independently, free it independently if (self->data != (byte *) self + sizeof (zchunk_t)) freen (self->data); self->tag = 0xDeadBeef; zdigest_destroy (&self->digest); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Resizes chunk max_size as requested; chunk size is set to zero void zchunk_resize (zchunk_t *self, size_t size) { assert (self); assert (zchunk_is (self)); zdigest_destroy (&self->digest); // Set new sizes self->max_size = size; self->size = 0; // TODO: this is a bit annoying, is it needed? // We can't realloc the chunk itself, as the caller's reference // won't change. So we modify self->data only, depending on whether // it was already reallocated, or not. if (self->data == (byte *) self + sizeof (zchunk_t)) self->data = (byte *) malloc (self->max_size); else self->data = (byte *) realloc (self->data, self->max_size); } // -------------------------------------------------------------------------- // Return chunk current size size_t zchunk_size (zchunk_t *self) { assert (self); assert (zchunk_is (self)); return self->size; } // -------------------------------------------------------------------------- // Return chunk max size size_t zchunk_max_size (zchunk_t *self) { assert (self); assert (zchunk_is (self)); return self->max_size; } // -------------------------------------------------------------------------- // Return chunk data byte * zchunk_data (zchunk_t *self) { assert (self); assert (zchunk_is (self)); return self->data; } // -------------------------------------------------------------------------- // Set chunk data from user-supplied data; truncate if too large. Data may // be null. Returns actual size of chunk size_t zchunk_set (zchunk_t *self, const void *data, size_t size) { assert (self); assert (zchunk_is (self)); zdigest_destroy (&self->digest); if (size > self->max_size) size = self->max_size; if (data) memcpy (self->data, data, size); self->size = size; return size; } // -------------------------------------------------------------------------- // Fill chunk data from user-supplied octet // Returns actual size of chunk size_t zchunk_fill (zchunk_t *self, byte filler, size_t size) { assert (self); assert (zchunk_is (self)); zdigest_destroy (&self->digest); if (size > self->max_size) size = self->max_size; memset (self->data, filler, size); self->size = size; return size; } // -------------------------------------------------------------------------- // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, it is truncated. If you want to // grow the chunk to accommodate new data, use the zchunk_extend method. size_t zchunk_append (zchunk_t *self, const void *data, size_t size) { assert (self); assert (zchunk_is (self)); zdigest_destroy (&self->digest); if (self->size + size > self->max_size) size = self->max_size - self->size; memcpy (self->data + self->size, data, size); self->size += size; return self->size; } // -------------------------------------------------------------------------- // Append user-supplied data to chunk, return resulting chunk size. If the // data would exceeded the available space, the chunk grows in size. size_t zchunk_extend (zchunk_t *self, const void *data, size_t size) { assert (self); if (self->size + size > self->max_size) { self->max_size = (self->size + size) * 2; // We can't realloc the chunk itself, as the caller's reference // won't change. So we modify self->data only, depending on whether // it was already reallocated, or not. if (self->data == (byte *) self + sizeof (zchunk_t)) { byte *old_data = self->data; self->data = (byte *) malloc (self->max_size); memcpy (self->data, old_data, self->size); } else self->data = (byte *) realloc (self->data, self->max_size); } assert (self->size + size <= self->max_size); memcpy (self->data + self->size, data, size); self->size += size; return self->size; } // -------------------------------------------------------------------------- // Copy as much data from 'source' into the chunk as possible; returns the // new size of chunk. If all data from 'source' is used, returns exhausted // on the source chunk. Source can be consumed as many times as needed until // it is exhausted. If source was already exhausted, does not change chunk. size_t zchunk_consume (zchunk_t *self, zchunk_t *source) { assert (self); assert (zchunk_is (self)); assert (source); assert (zchunk_is (source)); // We can take at most this many bytes from source size_t size = source->size - source->consumed; // And we can store at most this many bytes in chunk if (self->size + size > self->max_size) size = self->max_size - self->size; memcpy (self->data + self->size, source->data + source->consumed, size); source->consumed += size; self->size += size; return self->size; } // -------------------------------------------------------------------------- // Returns true if the chunk was exhausted by consume methods, or if the // chunk has a size of zero. bool zchunk_exhausted (zchunk_t *self) { assert (self); assert (zchunk_is (self)); assert (self->consumed <= self->size); return self->consumed == self->size; } // -------------------------------------------------------------------------- // Read chunk from an open file descriptor zchunk_t * zchunk_read (FILE *handle, size_t bytes) { assert (handle); zchunk_t *self = zchunk_new (NULL, bytes); if (self) self->size = fread (self->data, 1, bytes, handle); return self; } // -------------------------------------------------------------------------- // Write chunk to an open file descriptor int zchunk_write (zchunk_t *self, FILE *handle) { assert (self); assert (zchunk_is (self)); size_t items = fwrite (self->data, 1, self->size, handle); int rc = (items < self->size)? -1: 0; return rc; } // -------------------------------------------------------------------------- // Try to slurp an entire file into a chunk. Will read up to maxsize of // the file. If maxsize is 0, will attempt to read the entire file and // fail with an assertion if that cannot fit into memory. Returns a new // chunk containing the file data, or NULL if the file could not be read. zchunk_t * zchunk_slurp (const char *filename, size_t maxsize) { size_t size = zsys_file_size (filename); if ((ssize_t) size == -1) return NULL; if (size > maxsize && maxsize != 0) size = maxsize; FILE *handle = fopen (filename, "r"); zchunk_t *chunk = zchunk_read (handle, size); assert (chunk); fclose (handle); return chunk; } // -------------------------------------------------------------------------- // Create copy of chunk, as new chunk object. Returns a fresh zchunk_t // object, or null if there was not enough heap memory. If chunk is null, // or memory was exhausted, returns null. zchunk_t * zchunk_dup (zchunk_t *self) { if (self) { assert (zchunk_is (self)); return zchunk_new (self->data, self->max_size); } else return NULL; } // -------------------------------------------------------------------------- // Return chunk data encoded as printable hex string. Caller must free // string when finished with it. char * zchunk_strhex (zchunk_t *self) { assert (self); assert (zchunk_is (self)); static const char hex_char [] = "0123456789ABCDEF"; size_t size = zchunk_size (self); byte *data = zchunk_data (self); char *hex_str = (char *) zmalloc (size * 2 + 1); if (!hex_str) return NULL; uint byte_nbr; for (byte_nbr = 0; byte_nbr < size; byte_nbr++) { hex_str [byte_nbr * 2 + 0] = hex_char [data [byte_nbr] >> 4]; hex_str [byte_nbr * 2 + 1] = hex_char [data [byte_nbr] & 15]; } hex_str [size * 2] = 0; return hex_str; } // -------------------------------------------------------------------------- // Return chunk data copied into freshly allocated string // Caller must free string when finished with it. char * zchunk_strdup (zchunk_t *self) { assert (self); assert (zchunk_is (self)); size_t size = zchunk_size (self); char *string = (char *) malloc (size + 1); if (string) { memcpy (string, zchunk_data (self), size); string [size] = 0; } return string; } // -------------------------------------------------------------------------- // Return true if chunk body is equal to string, excluding terminator bool zchunk_streq (zchunk_t *self, const char *string) { assert (self); assert (zchunk_is (self)); if (zchunk_size (self) == strlen (string) && memcmp (zchunk_data (self), string, strlen (string)) == 0) return true; else return false; } // -------------------------------------------------------------------------- // Create a zframe from a zchunk. The zframe can be sent in a message. zframe_t * zchunk_pack (zchunk_t *self) { assert (self); assert (zchunk_is (self)); return zframe_new (self->data, self->max_size); } // -------------------------------------------------------------------------- // Create a zchunk from a zframe. zchunk_t * zchunk_unpack (zframe_t *frame) { assert (frame); assert (zframe_is (frame)); return zchunk_new (zframe_data (frame), zframe_size (frame)); } // -------------------------------------------------------------------------- // Calculate SHA1 digest for chunk, using zdigest class. Caller should not // modify digest. const char * zchunk_digest (zchunk_t *self) { assert (self); if (!self->digest) self->digest = zdigest_new (); if (self->digest) { zdigest_update (self->digest, self->data, self->size); return zdigest_string (self->digest); } else return NULL; } // -------------------------------------------------------------------------- // Dump chunk to FILE stream, for debugging and tracing. void zchunk_fprint (zchunk_t *self, FILE *file) { assert (self); assert (zchunk_is (self)); fprintf (file, "--------------------------------------\n"); if (!self) { fprintf (file, "NULL"); return; } assert (self); int is_bin = 0; uint char_nbr; for (char_nbr = 0; char_nbr < self->size; char_nbr++) if (self->data [char_nbr] < 9 || self->data [char_nbr] > 127) is_bin = 1; fprintf (file, "[%03d] ", (int) self->size); for (char_nbr = 0; char_nbr < self->size; char_nbr++) { if (is_bin) { fprintf (file, "%02X", (unsigned char) self->data [char_nbr]); if (char_nbr > 35) { fprintf (file, "..."); break; } } else { fprintf (file, "%c", self->data [char_nbr]); if (char_nbr > 70) { fprintf (file, "..."); break; } } } fprintf (file, "\n"); } // -------------------------------------------------------------------------- // Dump message to stderr, for debugging and tracing. // See zchunk_fprint for details void zchunk_print (zchunk_t *self) { assert (self); assert (zchunk_is (self)); zchunk_fprint (self, stderr); } // -------------------------------------------------------------------------- // Probe the supplied object, and report if it looks like a zchunk_t. bool zchunk_is (void *self) { assert (self); return ((zchunk_t *) self)->tag == ZCHUNK_TAG; } // -------------------------------------------------------------------------- // Self test of this class void zchunk_test (bool verbose) { printf (" * zchunk: "); // @selftest zchunk_t *chunk = zchunk_new ("1234567890", 10); assert (chunk); assert (zchunk_size (chunk) == 10); assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0); zchunk_destroy (&chunk); chunk = zchunk_new (NULL, 10); assert (chunk); zchunk_append (chunk, "12345678", 8); zchunk_append (chunk, "90ABCDEF", 8); zchunk_append (chunk, "GHIJKLMN", 8); assert (memcmp (zchunk_data (chunk), "1234567890", 10) == 0); assert (zchunk_size (chunk) == 10); assert (zchunk_streq (chunk, "1234567890")); assert (streq (zchunk_digest (chunk), "01B307ACBA4F54F55AAFC33BB06BBBF6CA803E9A")); char *string = zchunk_strdup (chunk); assert (streq (string, "1234567890")); freen (string); string = zchunk_strhex (chunk); assert (streq (string, "31323334353637383930")); freen (string); zframe_t *frame = zchunk_pack (chunk); assert (frame); zchunk_t *chunk2 = zchunk_unpack (frame); assert (chunk2); assert (memcmp (zchunk_data (chunk2), "1234567890", 10) == 0); zframe_destroy (&frame); zchunk_destroy (&chunk2); zchunk_t *copy = zchunk_dup (chunk); assert (copy); assert (memcmp (zchunk_data (copy), "1234567890", 10) == 0); assert (zchunk_size (copy) == 10); zchunk_destroy (©); zchunk_destroy (&chunk); chunk = zchunk_new (NULL, 0); zchunk_extend (chunk, "12345678", 8); zchunk_extend (chunk, "90ABCDEF", 8); zchunk_extend (chunk, "GHIJKLMN", 8); assert (zchunk_size (chunk) == 24); assert (zchunk_streq (chunk, "1234567890ABCDEFGHIJKLMN")); zchunk_destroy (&chunk); copy = zchunk_new ("1234567890abcdefghij", 20); assert (copy); chunk = zchunk_new (NULL, 8); assert (chunk); zchunk_consume (chunk, copy); assert (!zchunk_exhausted (copy)); assert (memcmp (zchunk_data (chunk), "12345678", 8) == 0); zchunk_set (chunk, NULL, 0); zchunk_consume (chunk, copy); assert (!zchunk_exhausted (copy)); assert (memcmp (zchunk_data (chunk), "90abcdef", 8) == 0); zchunk_set (chunk, NULL, 0); zchunk_consume (chunk, copy); assert (zchunk_exhausted (copy)); assert (zchunk_size (chunk) == 4); assert (memcmp (zchunk_data (chunk), "ghij", 4) == 0); zchunk_destroy (©); zchunk_destroy (&chunk); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/ztimerset.c0000664000372000037200000001314613222211156016351 0ustar00travistravis00000000000000/* ========================================================================= ztimerset - timer set Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header ztimerset - timer set @discuss @end */ #include "czmq_classes.h" // Structure of our class struct _ztimerset_t { void* zmq_timers; }; // -------------------------------------------------------------------------- // Create a new ztimerset ztimerset_t * ztimerset_new (void) { #ifdef ZMQ_HAVE_TIMERS ztimerset_t *self = (ztimerset_t *) zmalloc (sizeof (ztimerset_t)); assert (self); self->zmq_timers = zmq_timers_new (); assert (self->zmq_timers); return self; #else return NULL; #endif } // -------------------------------------------------------------------------- // Destroy the ztimerset void ztimerset_destroy (ztimerset_t **self_p) { #ifdef ZMQ_HAVE_TIMERS assert (self_p); if (*self_p) { ztimerset_t *self = *self_p; zmq_timers_destroy (&self->zmq_timers); freen (self); *self_p = NULL; } #endif } // -------------------------------------------------------------------------- // Add a timer to the set. Returns timer id if OK, -1 on failure. int ztimerset_add (ztimerset_t *self, size_t interval, ztimerset_fn handler, void *arg) { #ifdef ZMQ_HAVE_TIMERS return zmq_timers_add (self->zmq_timers, interval, handler, arg); #else return -1; #endif } // -------------------------------------------------------------------------- // Cancel a timer. Returns 0 if OK, -1 on failure. int ztimerset_cancel (ztimerset_t *self, int timer_id) { #ifdef ZMQ_HAVE_TIMERS return zmq_timers_cancel (self->zmq_timers, timer_id); #else return -1; #endif } // -------------------------------------------------------------------------- // Set timer interval. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int ztimerset_set_interval (ztimerset_t *self, int timer_id, size_t interval) { #ifdef ZMQ_HAVE_TIMERS return zmq_timers_set_interval (self->zmq_timers, timer_id, interval); #else return -1; #endif } // -------------------------------------------------------------------------- // Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. // This method is slow, canceling the timer and adding a new one yield better performance. int ztimerset_reset (ztimerset_t *self, int timer_id) { #ifdef ZMQ_HAVE_TIMERS return zmq_timers_reset (self->zmq_timers, timer_id); #else return -1; #endif } // -------------------------------------------------------------------------- // Return the time until the next interval. // Should be used as timeout parameter for the zpoller wait method. // The timeout is in msec. int ztimerset_timeout (ztimerset_t *self) { #ifdef ZMQ_HAVE_TIMERS return zmq_timers_timeout (self->zmq_timers); #else return -1; #endif } // -------------------------------------------------------------------------- // Invoke callback function of all timers which their interval has elapsed. // Should be call after zpoller wait method. // Returns 0 if OK, -1 on failure. int ztimerset_execute (ztimerset_t *self) { #ifdef ZMQ_HAVE_TIMERS return zmq_timers_execute (self->zmq_timers); #else return -1; #endif } // -------------------------------------------------------------------------- // Self test of this class // Avoid -Werror=unused-function #ifdef ZMQ_HAVE_TIMERS static void handler (int timer_id, void *arg) { *((bool*)arg) = true; } #endif void ztimerset_test (bool verbose) { #ifdef ZMQ_HAVE_TIMERS printf (" * ztimerset: "); // @selftest // Simple create/destroy test ztimerset_t *self = ztimerset_new (); assert (self); // Adding timer bool timer_invoked = false; int timer_id = ztimerset_add (self, 100, handler, &timer_invoked); assert (timer_id != -1); int rc = ztimerset_execute (self); assert (rc == 0); assert (!timer_invoked); int timeout = ztimerset_timeout (self); assert (timeout > 0); zclock_sleep (timeout); rc = ztimerset_execute (self); assert (rc == 0); assert (timer_invoked); // Cancel timer timeout = ztimerset_timeout (self); assert (timeout > 0); rc = ztimerset_cancel (self, timer_id); assert (rc == 0); timeout = ztimerset_timeout (self); assert(timeout == -1); // Reset a timer timer_id = ztimerset_add (self, 100, handler, &timer_invoked); assert (timer_id != -1); timeout = ztimerset_timeout (self); assert (timeout > 0); zclock_sleep (timeout / 2); timeout = ztimerset_timeout (self); rc = ztimerset_reset(self, timer_id); assert (rc == 0); int timeout2 = ztimerset_timeout (self); assert (timeout2 > timeout); rc = ztimerset_cancel (self, timer_id); assert (rc == 0); // Set interval timer_id = ztimerset_add (self, 100, handler, &timer_invoked); assert (timer_id != -1); timeout = ztimerset_timeout (self); rc = ztimerset_set_interval(self, timer_id, 200); timeout2 = ztimerset_timeout (self); assert (timeout2 > timeout); ztimerset_destroy (&self); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); #endif } czmq-4.1.0/src/zgossip_msg.h0000664000372000037200000001073313222211156016673 0ustar00travistravis00000000000000/* ========================================================================= zgossip_msg - class description Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ #ifndef ZGOSSIP_MSG_H_INCLUDED #define ZGOSSIP_MSG_H_INCLUDED #ifdef __cplusplus extern "C" { #endif // @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT // @warning Please edit the model at "api/zgossip_msg.api" to make changes. // @interface // This is a draft class, and may change without notice. It is disabled in // stable builds by default. If you use this in applications, please ask // for it to be pushed to stable state. Use --enable-drafts to enable. #ifdef CZMQ_BUILD_DRAFT_API #define ZGOSSIP_MSG_HELLO 1 // #define ZGOSSIP_MSG_PUBLISH 2 // #define ZGOSSIP_MSG_PING 3 // #define ZGOSSIP_MSG_PONG 4 // #define ZGOSSIP_MSG_INVALID 5 // // *** Draft method, for development use, may change without warning *** // Create a new empty zgossip_msg CZMQ_PRIVATE zgossip_msg_t * zgossip_msg_new (void); // *** Draft method, for development use, may change without warning *** // Destroy a zgossip_msg instance CZMQ_PRIVATE void zgossip_msg_destroy (zgossip_msg_t **self_p); // *** Draft method, for development use, may change without warning *** // Receive a zgossip_msg from the socket. Returns 0 if OK, -1 if // there was an error. Blocks if there is no message waiting. CZMQ_PRIVATE int zgossip_msg_recv (zgossip_msg_t *self, zsock_t *input); // *** Draft method, for development use, may change without warning *** // Send the zgossip_msg to the output socket, does not destroy it CZMQ_PRIVATE int zgossip_msg_send (zgossip_msg_t *self, zsock_t *output); // *** Draft method, for development use, may change without warning *** // Print contents of message to stdout CZMQ_PRIVATE void zgossip_msg_print (zgossip_msg_t *self); // *** Draft method, for development use, may change without warning *** // Get the message routing id, as a frame CZMQ_PRIVATE zframe_t * zgossip_msg_routing_id (zgossip_msg_t *self); // *** Draft method, for development use, may change without warning *** // Set the message routing id from a frame CZMQ_PRIVATE void zgossip_msg_set_routing_id (zgossip_msg_t *self, zframe_t *routing_id); // *** Draft method, for development use, may change without warning *** // Get the zgossip_msg message id CZMQ_PRIVATE int zgossip_msg_id (zgossip_msg_t *self); // *** Draft method, for development use, may change without warning *** // Set the zgossip_msg message id CZMQ_PRIVATE void zgossip_msg_set_id (zgossip_msg_t *self, int id); // *** Draft method, for development use, may change without warning *** // Get the zgossip_msg message id as printable text CZMQ_PRIVATE const char * zgossip_msg_command (zgossip_msg_t *self); // *** Draft method, for development use, may change without warning *** // Get the key field CZMQ_PRIVATE const char * zgossip_msg_key (zgossip_msg_t *self); // *** Draft method, for development use, may change without warning *** // Set the key field CZMQ_PRIVATE void zgossip_msg_set_key (zgossip_msg_t *self, const char *key); // *** Draft method, for development use, may change without warning *** // Get the value field CZMQ_PRIVATE const char * zgossip_msg_value (zgossip_msg_t *self); // *** Draft method, for development use, may change without warning *** // Set the value field CZMQ_PRIVATE void zgossip_msg_set_value (zgossip_msg_t *self, const char *value); // *** Draft method, for development use, may change without warning *** // Get the ttl field CZMQ_PRIVATE uint32_t zgossip_msg_ttl (zgossip_msg_t *self); // *** Draft method, for development use, may change without warning *** // Set the ttl field CZMQ_PRIVATE void zgossip_msg_set_ttl (zgossip_msg_t *self, uint32_t ttl); // *** Draft method, for development use, may change without warning *** // Self test of this class. CZMQ_PRIVATE void zgossip_msg_test (bool verbose); #endif // CZMQ_BUILD_DRAFT_API // @end #ifdef __cplusplus } #endif #endif czmq-4.1.0/src/zstr.c0000664000372000037200000003747113222211156015334 0ustar00travistravis00000000000000/* ========================================================================= zstr - sending and receiving strings Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zstr class provides utility functions for sending and receiving C strings across 0MQ sockets. It sends strings without a terminating null, and appends a null byte on received strings. This class is for simple message sending. @discuss Memory Wire +-------------+---+ +---+-------------+ Send | S t r i n g | 0 | ----> | 6 | S t r i n g | +-------------+---+ +---+-------------+ Wire Heap +---+-------------+ +-------------+---+ Recv | 6 | S t r i n g | ----> | S t r i n g | 0 | +---+-------------+ +-------------+---+ @end */ #include "czmq_classes.h" #ifdef HAVE_LIBLZ4 #include static void s_free_compress (void *data, void *hint) { free (data); } #endif static int s_send_string (void *dest, bool more, char *string, bool compress) { assert (dest); void *handle = zsock_resolve (dest); size_t len = strlen (string); zmq_msg_t message; if (compress) { #ifdef HAVE_LIBLZ4 size_t compressed_len = LZ4_compressBound (len); if (compressed_len == 0) return -1; char *buffer = (char *)malloc (compressed_len ); if (!buffer) return -1; // LZ4_compress has been deprecated in newer versions, but // the new APIs are not available for older distros #if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7 int rc = LZ4_compress_default (string, buffer, len, compressed_len); #else int rc = LZ4_compress (string, buffer, len); #endif if (rc == 0) { free (buffer); return -1; } zmq_msg_t size_frame; zmq_msg_init_size (&size_frame, sizeof (size_t)); memcpy (zmq_msg_data (&size_frame), &len, sizeof (size_t)); #if defined (ZMQ_SERVER) // Set routing ID if we're sending to a SERVER socket (ZMQ 4.2 and later) if (zsock_is (dest) && zsock_type (dest) == ZMQ_SERVER) zmq_msg_set_routing_id (&size_frame, zsock_routing_id ((zsock_t *) dest)); #endif if (zmq_sendmsg (handle, &size_frame, ZMQ_SNDMORE) == -1) { free (buffer); zmq_msg_close (&size_frame); return -1; } // Optimisation: use zero-copy send. The common use case for // compressed data is large buffers, so avoiding an extra malloc + copy // is worth the extra few lines of code rc = zmq_msg_init_data (&message, buffer, rc, s_free_compress, NULL); // Assert on OOM assert (rc != -1); #else return -1; #endif } else { int rc = zmq_msg_init_size (&message, len); assert (rc == 0); memcpy (zmq_msg_data (&message), string, len); } #if defined (ZMQ_SERVER) // Set routing ID if we're sending to a SERVER socket (ZMQ 4.2 and later) if (zsock_is (dest) && zsock_type (dest) == ZMQ_SERVER) zmq_msg_set_routing_id (&message, zsock_routing_id ((zsock_t *) dest)); #endif if (zmq_sendmsg (handle, &message, more? ZMQ_SNDMORE: 0) == -1) { zmq_msg_close (&message); return -1; } else return 0; } // -------------------------------------------------------------------------- // Receive C string from socket. Caller must free returned string using // zstr_free(). Returns NULL if the context is being terminated or the // process was interrupted. char * zstr_recv (void *source) { assert (source); void *handle = zsock_resolve (source); zmq_msg_t message; zmq_msg_init (&message); if (zmq_recvmsg (handle, &message, 0) < 0) return NULL; #if defined (ZMQ_SERVER) // Grab routing ID if we're reading from a SERVER socket (ZMQ 4.2 and later) if (zsock_is (source) && zsock_type (source) == ZMQ_SERVER) zsock_set_routing_id ((zsock_t *) source, zmq_msg_routing_id (&message)); #endif size_t size = zmq_msg_size (&message); char *string = (char *) malloc (size + 1); if (string) { memcpy (string, zmq_msg_data (&message), size); string [size] = 0; } zmq_msg_close (&message); return string; } // -------------------------------------------------------------------------- // Receive a series of strings (until NULL) from multipart data. // Each string is allocated and filled with string data; if there // are not enough frames, unallocated strings are set to NULL. // Returns -1 if the message could not be read, else returns the // number of strings filled, zero or more. Free each returned string // using zstr_free(). If not enough strings are provided, remaining // multipart frames in the message are dropped. int zstr_recvx (void *source, char **string_p, ...) { assert (source); void *handle = zsock_resolve (source); zmsg_t *msg = zmsg_recv (handle); if (!msg) return -1; #if defined (ZMQ_SERVER) // Grab routing ID if we're reading from a SERVER socket (ZMQ 4.2 and later) if (zsock_is (source) && zsock_type (source) == ZMQ_SERVER) zsock_set_routing_id ((zsock_t *) source, zmsg_routing_id (msg)); #endif // Filter a signal that may come from a dying actor if (zmsg_signal (msg) >= 0) { zmsg_destroy (&msg); return -1; } int count = 0; va_list args; va_start (args, string_p); while (string_p) { *string_p = zmsg_popstr (msg); string_p = va_arg (args, char **); count++; } va_end (args); zmsg_destroy (&msg); return count; } // -------------------------------------------------------------------------- // De-compress and receive C string from socket, received as a message // with two frames: size of the uncompressed string, and the string itself. // Caller must free returned string using zstr_free(). Returns NULL if the // context is being terminated or the process was interrupted. // Caller owns return value and must destroy it when done. char * zstr_recv_compress (void *source) { assert (source); #ifndef HAVE_LIBLZ4 return NULL; #else void *handle = zsock_resolve (source); zmsg_t *msg = zmsg_recv (handle); if (!msg) return NULL; #if defined (ZMQ_SERVER) // Grab routing ID if we're reading from a SERVER socket (ZMQ 4.2 and later) if (zsock_is (source) && zsock_type (source) == ZMQ_SERVER) zsock_set_routing_id ((zsock_t *) source, zmsg_routing_id (msg)); #endif // Filter a signal that may come from a dying actor if (zmsg_signal (msg) >= 0) { zmsg_destroy (&msg); return NULL; } // Size and data if (zmsg_size (msg) != 2) { zmsg_destroy (&msg); return NULL; } size_t size = *((size_t *)zframe_data (zmsg_first (msg))); char *string = (char *) malloc (size + 1); if (string) { zframe_t *data_frame = zmsg_next (msg); int rc = LZ4_decompress_safe ((char *)zframe_data (data_frame), string, zframe_size (data_frame), size); string [size] = 0; if (rc < 0) { zstr_free (&string); } } zmsg_destroy (&msg); return string; #endif } // -------------------------------------------------------------------------- // Send a C string to a socket, as a frame. The string is sent without // trailing null byte; to read this you can use zstr_recv, or a similar // method that adds a null terminator on the received string. String // may be NULL, which is sent as "". int zstr_send (void *dest, const char *string) { assert (dest); return s_send_string (dest, false, string? (char *) string: "", false); } // -------------------------------------------------------------------------- // Send a C string to a socket, as zstr_send(), with a MORE flag, so that // you can send further strings in the same multi-part message. String // may be NULL, which is sent as "". int zstr_sendm (void *dest, const char *string) { assert (dest); assert (string); return s_send_string (dest, true, (char *) string, false); } // -------------------------------------------------------------------------- // Send a formatted string to a socket. Note that you should NOT use // user-supplied strings in the format (they may contain '%' which // will create security holes). int zstr_sendf (void *dest, const char *format, ...) { assert (dest); assert (format); va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); if (!string) return -1; va_end (argptr); int rc = s_send_string (dest, false, string, false); zstr_free (&string); return rc; } // -------------------------------------------------------------------------- // Send a formatted string to a socket, as for zstr_sendf(), with a // MORE flag, so that you can send further strings in the same multi-part // message. int zstr_sendfm (void *dest, const char *format, ...) { assert (dest); assert (format); va_list argptr; va_start (argptr, format); char *string = zsys_vprintf (format, argptr); if (!string) return -1; va_end (argptr); int rc = s_send_string (dest, true, string, false); zstr_free (&string); return rc; } // -------------------------------------------------------------------------- // Send a series of strings (until NULL) as multipart data // Returns 0 if the strings could be sent OK, or -1 on error. int zstr_sendx (void *dest, const char *string, ...) { zmsg_t *msg = zmsg_new (); if (!msg) return -1; va_list args; va_start (args, string); while (string) { zmsg_addstr (msg, string); string = va_arg (args, char *); } va_end (args); #if defined (ZMQ_SERVER) // Grab routing ID if we're reading from a SERVER socket (ZMQ 4.2 and later) if (zsock_is (dest) && zsock_type (dest) == ZMQ_SERVER) zmsg_set_routing_id (msg, zsock_routing_id ((zsock_t *) dest)); #endif if (zmsg_send (&msg, dest) < 0) { zmsg_destroy(&msg); return -1; } else return 0; } // Compress and send a C string to a socket, as a message with two frames: // size of the uncompressed string, and the string itself. The string is // sent without trailing null byte; to read this you can use // zstr_recv_compress, or a similar method that de-compresses and adds a // null terminator on the received string. int zstr_send_compress (void *dest, const char *string) { assert (dest); return s_send_string (dest, false, (char *) string, true); } // Compress and send a C string to a socket, as zstr_send_compress(), // with a MORE flag, so that you can send further strings in the same // multi-part message. int zstr_sendm_compress (void *dest, const char *string) { assert (dest); assert (string); return s_send_string (dest, true, (char *) string, true); } // -------------------------------------------------------------------------- // Accepts a void pointer and returns a fresh character string. If source is // null, returns an empty string. char * zstr_str (void *source) { if (source) return strdup ((char *) source); else return strdup (""); } // -------------------------------------------------------------------------- // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. void zstr_free (char **string_p) { assert (string_p); free (*string_p); *string_p = NULL; } // -------------------------------------------------------------------------- // DEPRECATED as poor style -- callers should use zloop or zpoller // Receive C string from socket, if socket had input ready. Caller must // free returned string using zstr_free. Returns NULL if there was no input // waiting, or if the context was terminated. Use zsys_interrupted to exit // any loop that relies on this method. char * zstr_recv_nowait (void *dest) { assert (dest); void *handle = zsock_resolve (dest); zmq_msg_t message; zmq_msg_init (&message); if (zmq_recvmsg (handle, &message, ZMQ_DONTWAIT) < 0) return NULL; size_t size = zmq_msg_size (&message); char *string = (char *) malloc (size + 1); if (string) { memcpy (string, zmq_msg_data (&message), size); string [size] = 0; } zmq_msg_close (&message); return string; } // -------------------------------------------------------------------------- // Selftest void zstr_test (bool verbose) { printf (" * zstr: "); // @selftest // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new_pair ("@inproc://zstr.test"); assert (output); zsock_t *input = zsock_new_pair (">inproc://zstr.test"); assert (input); // Send ten strings, five strings with MORE flag and then END int string_nbr; for (string_nbr = 0; string_nbr < 10; string_nbr++) zstr_sendf (output, "this is string %d", string_nbr); zstr_sendx (output, "This", "is", "almost", "the", "very", "END", NULL); // Read and count until we receive END string_nbr = 0; for (string_nbr = 0;; string_nbr++) { char *string = zstr_recv (input); assert (string); if (streq (string, "END")) { zstr_free (&string); break; } zstr_free (&string); } assert (string_nbr == 15); #ifdef HAVE_LIBLZ4 int ret = zstr_send_compress (output, "loooong"); assert (ret == 0); char *string = zstr_recv_compress (input); assert (string); assert (streq (string, "loooong")); zstr_free (&string); zstr_send_compress (output, "loooong"); assert (ret == 0); zmsg_t *msg = zmsg_recv (input); assert (msg); assert (*((size_t *)zframe_data (zmsg_first (msg))) == strlen ("loooong")); zmsg_destroy (&msg); #endif zsock_destroy (&input); zsock_destroy (&output); #if defined (ZMQ_SERVER) // Test SERVER/CLIENT over zstr zsock_t *server = zsock_new_server ("inproc://zstr-test-routing"); zsock_t *client = zsock_new_client ("inproc://zstr-test-routing");; assert (server); assert (client); // Try normal ping-pong to check reply routing ID int rc = zstr_send (client, "Hello"); assert (rc == 0); char *request = zstr_recv (server); assert (streq (request, "Hello")); assert (zsock_routing_id (server)); freen (request); rc = zstr_send (server, "World"); assert (rc == 0); char *reply = zstr_recv (client); assert (streq (reply, "World")); freen (reply); rc = zstr_sendf (server, "%s", "World"); assert (rc == 0); reply = zstr_recv (client); assert (streq (reply, "World")); freen (reply); // Try ping-pong using sendx and recx rc = zstr_sendx (client, "Hello", NULL); assert (rc == 0); rc = zstr_recvx (server, &request, NULL); assert (rc >= 0); assert (streq (request, "Hello")); freen (request); rc = zstr_sendx (server, "World", NULL); assert (rc == 0); rc = zstr_recvx (client, &reply, NULL); assert (rc >= 0); assert (streq (reply, "World")); freen (reply); // Client and server disallow multipart rc = zstr_sendm (client, "Hello"); assert (rc == -1); rc = zstr_sendm (server, "World"); assert (rc == -1); zsock_destroy (&client); zsock_destroy (&server); #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zframe.c0000664000372000037200000005150213222211156015605 0ustar00travistravis00000000000000/* ========================================================================= zframe - working with single message frames Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header The zframe class provides methods to send and receive single message frames across 0MQ sockets. A 'frame' corresponds to one zmq_msg_t. When you read a frame from a socket, the zframe_more() method indicates if the frame is part of an unfinished multipart message. The zframe_send method normally destroys the frame, but with the ZFRAME_REUSE flag, you can send the same frame many times. Frames are binary, and this class has no special support for text data. @discuss @end */ #include "czmq_classes.h" // zframe_t instances always have this tag as the first 4 octets of // their data, which lets us do runtime object typing & validation. #define ZFRAME_TAG 0x0002cafe // Structure of our class struct _zframe_t { uint32_t tag; // Object tag for runtime detection zmq_msg_t zmsg; // zmq_msg_t blob for frame int more; // More flag, from last read uint32_t routing_id; // Routing ID back to sender, if any #ifdef ZMQ_GROUP_MAX_LENGTH char group[ZMQ_GROUP_MAX_LENGTH + 1]; #endif }; // -------------------------------------------------------------------------- // Constructor; if size is >0, allocates frame with that size, and if data // is not null, copies data into frame. zframe_t * zframe_new (const void *data, size_t size) { zframe_t *self = (zframe_t *) zmalloc (sizeof (zframe_t)); assert (self); self->tag = ZFRAME_TAG; if (size) { // Catch heap exhaustion in this specific case if (zmq_msg_init_size (&self->zmsg, size)) { zframe_destroy (&self); return NULL; } if (data) memcpy (zmq_msg_data (&self->zmsg), data, size); } else zmq_msg_init (&self->zmsg); return self; } // -------------------------------------------------------------------------- // Create an empty (zero-sized) frame. The caller is responsible for // destroying the return value when finished with it. zframe_t * zframe_new_empty (void) { zframe_t *self = (zframe_t *) zmalloc (sizeof (zframe_t)); assert (self); self->tag = ZFRAME_TAG; zmq_msg_init (&self->zmsg); return self; } // -------------------------------------------------------------------------- // Destructor void zframe_destroy (zframe_t **self_p) { assert (self_p); if (*self_p) { zframe_t *self = *self_p; assert (zframe_is (self)); zmq_msg_close (&self->zmsg); self->tag = 0xDeadBeef; freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Create a frame with a specified string content. // The caller is responsible for destroying the return value when finished with it. zframe_t * zframe_from (const char *string) { return zframe_new (string, strlen (string)); } // -------------------------------------------------------------------------- // Receive frame from socket, returns zframe_t object or NULL if the recv // was interrupted. Does a blocking recv, if you want to not block then use // zpoller or zloop. zframe_t * zframe_recv (void *source) { assert (source); void *handle = zsock_resolve (source); zframe_t *self = zframe_new (NULL, 0); assert (self); if (zmq_recvmsg (handle, &self->zmsg, 0) < 0) { zframe_destroy (&self); return NULL; // Interrupted or terminated } self->more = zsock_rcvmore (source); #if defined (ZMQ_SERVER) // Grab routing ID if we're reading from a SERVER socket (ZMQ 4.2 and later) if (zsock_type (source) == ZMQ_SERVER) self->routing_id = zmq_msg_routing_id (&self->zmsg); #endif #if defined (ZMQ_DISH) // Grab group if we're reading from a DISH Socket (ZMQ 4.2 and later) if (zsock_type (source) == ZMQ_DISH) strcpy (self->group, zmq_msg_group (&self->zmsg)); #endif return self; } // -------------------------------------------------------------------------- // Send frame to socket, destroy after sending unless ZFRAME_REUSE is // set or the attempt to send the message errors out. int zframe_send (zframe_t **self_p, void *dest, int flags) { assert (dest); assert (self_p); void *handle = zsock_resolve (dest); if (*self_p) { zframe_t *self = *self_p; assert (zframe_is (self)); int send_flags = (flags & ZFRAME_MORE)? ZMQ_SNDMORE: 0; send_flags |= (flags & ZFRAME_DONTWAIT)? ZMQ_DONTWAIT: 0; if (flags & ZFRAME_REUSE) { zmq_msg_t copy; zmq_msg_init (©); if (zmq_msg_copy (©, &self->zmsg)) return -1; #if defined (ZMQ_SERVER) if (zsock_type (dest) == ZMQ_SERVER) zmq_msg_set_routing_id (©, self->routing_id); #endif #if defined (ZMQ_RADIO) if (zsock_type (dest) == ZMQ_RADIO) zmq_msg_set_group (©, self->group); #endif if (zmq_sendmsg (handle, ©, send_flags) == -1) { zmq_msg_close (©); return -1; } } else { #if defined (ZMQ_SERVER) if (zsock_type (dest) == ZMQ_SERVER) zmq_msg_set_routing_id (&self->zmsg, self->routing_id); #endif #if defined (ZMQ_RADIO) if (zsock_type (dest) == ZMQ_RADIO) zmq_msg_set_group (&self->zmsg, self->group); #endif if (zmq_sendmsg (handle, &self->zmsg, send_flags) >= 0) zframe_destroy (self_p); else return -1; } } return 0; } // -------------------------------------------------------------------------- // Return size of frame. size_t zframe_size (zframe_t *self) { assert (self); assert (zframe_is (self)); return zmq_msg_size (&self->zmsg); } // -------------------------------------------------------------------------- // Return pointer to frame data. byte * zframe_data (zframe_t *self) { assert (self); assert (zframe_is (self)); return (byte *) zmq_msg_data (&self->zmsg); } // -------------------------------------------------------------------------- // Return meta data property for frame. // The caller shall not modify or free the returned value, which shall be // owned by the message. const char * zframe_meta (zframe_t *self, const char *property) { #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (4, 1, 0)) assert (self); assert (zframe_is (self)); return zmq_msg_gets (&self->zmsg, property); #else return NULL; #endif } // -------------------------------------------------------------------------- // Create a new frame that duplicates an existing frame. If frame is null, // or memory was exhausted, returns null. zframe_t * zframe_dup (zframe_t *self) { if (self) { assert (zframe_is (self)); return zframe_new (zframe_data (self), zframe_size (self)); } else return NULL; } // -------------------------------------------------------------------------- // Return frame data encoded as printable hex string, useful for 0MQ UUIDs. // Caller must free string when finished with it. char * zframe_strhex (zframe_t *self) { assert (self); assert (zframe_is (self)); static const char hex_char [] = "0123456789ABCDEF"; size_t size = zframe_size (self); byte *data = zframe_data (self); char *hex_str = (char *) malloc (size * 2 + 1); if (!hex_str) return NULL; uint byte_nbr; for (byte_nbr = 0; byte_nbr < size; byte_nbr++) { hex_str [byte_nbr * 2 + 0] = hex_char [data [byte_nbr] >> 4]; hex_str [byte_nbr * 2 + 1] = hex_char [data [byte_nbr] & 15]; } hex_str [size * 2] = 0; return hex_str; } // -------------------------------------------------------------------------- // Return frame data copied into freshly allocated string // Caller must free string when finished with it. char * zframe_strdup (zframe_t *self) { assert (self); assert (zframe_is (self)); size_t size = zframe_size (self); char *string = (char *) malloc (size + 1); assert (string); memcpy (string, zframe_data (self), size); string [size] = 0; return string; } // -------------------------------------------------------------------------- // Return true if frame body is equal to string, excluding terminator bool zframe_streq (zframe_t *self, const char *string) { assert (self); assert (zframe_is (self)); if (zframe_size (self) == strlen (string) && memcmp (zframe_data (self), string, strlen (string)) == 0) return true; else return false; } // -------------------------------------------------------------------------- // Return frame MORE indicator (1 or 0), set when reading frame from socket // or by the zframe_set_more() method. int zframe_more (zframe_t *self) { assert (self); assert (zframe_is (self)); return self->more; } // -------------------------------------------------------------------------- // Set frame MORE indicator (1 or 0). Note this is NOT used when sending // frame to socket, you have to specify flag explicitly. void zframe_set_more (zframe_t *self, int more) { assert (self); assert (zframe_is (self)); assert (more == 0 || more == 1); self->more = more; } // -------------------------------------------------------------------------- // Return frame routing ID, if the frame came from a ZMQ_SERVER socket. // Else returns zero. uint32_t zframe_routing_id (zframe_t *self) { assert (self); assert (zframe_is (self)); return self->routing_id; } // -------------------------------------------------------------------------- // Set routing ID on frame. This is used if/when the frame is sent to a // ZMQ_SERVER socket. void zframe_set_routing_id (zframe_t *self, uint32_t routing_id) { assert (self); assert (zframe_is (self)); self->routing_id = routing_id; } // -------------------------------------------------------------------------- // Return frame group of radio-dish pattern. const char * zframe_group (zframe_t *self) { assert (self); #ifdef ZMQ_DISH return self->group; #else return NULL; #endif } // -------------------------------------------------------------------------- // Set group on frame. This is used if/when the frame is sent to a // ZMQ_RADIO socket. // Return -1 on error, 0 on success. int zframe_set_group (zframe_t *self, const char *group) { #ifdef ZMQ_RADIO if (strlen(group) > ZMQ_GROUP_MAX_LENGTH) { errno = EINVAL; return -1; } strcpy (self->group, group); return 0; #else errno = EINVAL; return -1; #endif } // -------------------------------------------------------------------------- // Return true if two frames have identical size and data bool zframe_eq (zframe_t *self, zframe_t *other) { if (!self || !other) return false; // Tolerate null references here else { assert (zframe_is (self)); assert (zframe_is (other)); if (zframe_size (self) == zframe_size (other) && memcmp (zframe_data (self), zframe_data (other), zframe_size (self)) == 0) return true; else return false; } } // -------------------------------------------------------------------------- // Set new contents for frame void zframe_reset (zframe_t *self, const void *data, size_t size) { assert (self); assert (zframe_is (self)); assert (data); zmq_msg_close (&self->zmsg); zmq_msg_init_size (&self->zmsg, size); memcpy (zmq_msg_data (&self->zmsg), data, size); } // -------------------------------------------------------------------------- // Send message to zsys log sink (may be stdout, or system facility as // configured by zsys_set_logstream). Prefix shows before frame, if not null. void zframe_print (zframe_t *self, const char *prefix) { assert (self); assert (zframe_is (self)); byte *data = zframe_data (self); size_t size = zframe_size (self); // Probe data to check if it looks like unprintable binary int is_bin = 0; uint char_nbr; for (char_nbr = 0; char_nbr < size; char_nbr++) if (data [char_nbr] < 9 || data [char_nbr] > 127) is_bin = 1; char buffer [256] = ""; snprintf (buffer, 30, "%s[%03d] ", prefix? prefix: "", (int) size); size_t max_size = is_bin? 35: 70; const char *ellipsis = ""; if (size > max_size) { size = max_size; ellipsis = "..."; } for (char_nbr = 0; char_nbr < size; char_nbr++) { if (is_bin) sprintf (buffer + strlen (buffer), "%02X", (unsigned char) data [char_nbr]); else sprintf (buffer + strlen (buffer), "%c", data [char_nbr]); } strcat (buffer, ellipsis); zsys_debug (buffer); } // -------------------------------------------------------------------------- // Probe the supplied object, and report if it looks like a zframe_t. bool zframe_is (void *self) { assert (self); return ((zframe_t *) self)->tag == ZFRAME_TAG; } // -------------------------------------------------------------------------- // DEPRECATED as poor style -- callers should use zloop or zpoller // Receive a new frame off the socket. Returns newly allocated frame, or // NULL if there was no input waiting, or if the read was interrupted. zframe_t * zframe_recv_nowait (void *source) { assert (source); void *handle = zsock_resolve (source); zframe_t *self = zframe_new (NULL, 0); assert (self); if (zmq_recvmsg (handle, &self->zmsg, ZMQ_DONTWAIT) < 0) { zframe_destroy (&self); return NULL; // Interrupted or terminated } self->more = zsock_rcvmore (source); #if defined (ZMQ_SERVER) // Grab routing ID if we're reading from a SERVER socket (ZMQ 4.2 and later) if (zsock_type (source) == ZMQ_SERVER) self->routing_id = zmq_msg_routing_id (&self->zmsg); #endif #if defined (ZMQ_DISH) // Grab group if we're reading from a DISH Socket (ZMQ 4.2 and later) if (zsock_type (source) == ZMQ_DISH) strcpy (self->group, zmq_msg_group (&self->zmsg)); #endif return self; } // -------------------------------------------------------------------------- // DEPRECATED as inconsistent; breaks principle that logging should all go // to a single destination. // Print contents of frame to FILE stream, prefix is ignored if null. void zframe_fprint (zframe_t *self, const char *prefix, FILE *file) { assert (self); assert (zframe_is (self)); if (prefix) fprintf (file, "%s", prefix); byte *data = zframe_data (self); size_t size = zframe_size (self); int is_bin = 0; uint char_nbr; for (char_nbr = 0; char_nbr < size; char_nbr++) if (data [char_nbr] < 9 || data [char_nbr] > 127) is_bin = 1; fprintf (file, "[%03d] ", (int) size); size_t max_size = is_bin? 35: 70; const char *ellipsis = ""; if (size > max_size) { size = max_size; ellipsis = "..."; } for (char_nbr = 0; char_nbr < size; char_nbr++) { if (is_bin) fprintf (file, "%02X", (unsigned char) data [char_nbr]); else fprintf (file, "%c", data [char_nbr]); } fprintf (file, "%s\n", ellipsis); } // -------------------------------------------------------------------------- // Selftest void zframe_test (bool verbose) { printf (" * zframe: "); int rc; zframe_t* frame; // @selftest // Create two PAIR sockets and connect over inproc zsock_t *output = zsock_new (ZMQ_PAIR); assert (output); int port = zsock_bind (output, "tcp://127.0.0.1:*"); assert (port != -1); zsock_t *input = zsock_new (ZMQ_PAIR); assert (input); rc = zsock_connect (input, "tcp://127.0.0.1:%d", port); assert (rc != -1); // Send five different frames, test ZFRAME_MORE int frame_nbr; for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) { frame = zframe_new ("Hello", 5); assert (frame); rc = zframe_send (&frame, output, ZFRAME_MORE); assert (rc == 0); } // Send same frame five times, test ZFRAME_REUSE frame = zframe_new ("Hello", 5); assert (frame); for (frame_nbr = 0; frame_nbr < 5; frame_nbr++) { rc = zframe_send (&frame, output, ZFRAME_MORE + ZFRAME_REUSE); assert (rc == 0); } assert (frame); zframe_t *copy = zframe_dup (frame); assert (zframe_eq (frame, copy)); zframe_destroy (&frame); assert (!zframe_eq (frame, copy)); assert (zframe_size (copy) == 5); zframe_destroy (©); assert (!zframe_eq (frame, copy)); // Test zframe_new_empty frame = zframe_new_empty (); assert (frame); assert (zframe_size (frame) == 0); zframe_destroy (&frame); // Send END frame frame = zframe_new ("NOT", 3); assert (frame); zframe_reset (frame, "END", 3); char *string = zframe_strhex (frame); assert (streq (string, "454E44")); freen (string); string = zframe_strdup (frame); assert (streq (string, "END")); freen (string); rc = zframe_send (&frame, output, 0); assert (rc == 0); // Read and count until we receive END frame_nbr = 0; for (frame_nbr = 0;; frame_nbr++) { zframe_t *frame = zframe_recv (input); if (zframe_streq (frame, "END")) { zframe_destroy (&frame); break; } assert (zframe_more (frame)); zframe_set_more (frame, 0); assert (zframe_more (frame) == 0); zframe_destroy (&frame); } assert (frame_nbr == 10); #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (4, 1, 0)) // Test zframe_meta frame = zframe_new ("Hello", 5); assert (frame); rc = zframe_send (&frame, output, 0); assert (rc == 0); frame = zframe_recv (input); const char *meta = zframe_meta (frame, "Socket-Type"); assert (meta != NULL); assert (streq (meta, "PAIR")); assert (zframe_meta (frame, "nonexistent") == NULL); zframe_destroy (&frame); #endif zsock_destroy (&input); zsock_destroy (&output); #if defined (ZMQ_SERVER) // Create server and client sockets and connect over inproc zsock_t *server = zsock_new_server ("inproc://zframe-test-routing"); assert (server); zsock_t *client = zsock_new_client ("inproc://zframe-test-routing"); assert (client); // Send request from client to server zframe_t *request = zframe_new ("Hello", 5); assert (request); rc = zframe_send (&request, client, 0); assert (rc == 0); assert (!request); // Read request and send reply request = zframe_recv (server); assert (request); assert (zframe_streq (request, "Hello")); assert (zframe_routing_id (request)); zframe_t *reply = zframe_new ("World", 5); assert (reply); zframe_set_routing_id (reply, zframe_routing_id (request)); rc = zframe_send (&reply, server, 0); assert (rc == 0); zframe_destroy (&request); // Read reply reply = zframe_recv (client); assert (zframe_streq (reply, "World")); assert (zframe_routing_id (reply) == 0); zframe_destroy (&reply); // Client and server disallow multipart frame = zframe_new ("Hello", 5); rc = zframe_send (&frame, client, ZFRAME_MORE); assert (rc == -1); rc = zframe_send (&frame, server, ZFRAME_MORE); assert (rc == -1); zframe_destroy (&frame); zsock_destroy (&client); zsock_destroy (&server); #endif #ifdef ZMQ_RADIO // Create radio and dish sockets and connect over inproc zsock_t *radio = zsock_new_radio ("inproc://zframe-test-radio"); assert (radio); zsock_t *dish = zsock_new_dish ("inproc://zframe-test-radio"); assert (dish); // Join the group rc = zsock_join (dish, "World"); assert (rc == 0); // Publish message from radio zframe_t *message = zframe_new ("Hello", 5); assert (message); rc = zframe_set_group (message, "World"); assert (rc == 0); rc = zframe_send (&message, radio, 0); assert (rc == 0); assert (!message); // Receive the message from dish message = zframe_recv (dish); assert (message); assert (zframe_streq (message, "Hello")); assert (strcmp("World", zframe_group (message)) == 0); zframe_destroy (&message); zsock_destroy (&dish); zsock_destroy (&radio); #endif #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/zdir.c0000664000372000037200000010222313222211156015266 0ustar00travistravis00000000000000/* ========================================================================= zdir - work with file-system directories Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. =========================================================================*/ /* @header The zdir class gives access to the file system index. It will load a directory tree (a directory plus all child directories) into a zdir structure and then let you navigate that structure. It exists mainly to wrap non-portable OS functions to do this. @discuss @end */ #include "czmq_classes.h" // Structure of our class struct _zdir_t { char *path; // Directory name + separator zlist_t *files; // List of files in directory zlist_t *subdirs; // List of subdirectories time_t modified; // Most recent file including subdirs off_t cursize; // Total file size including subdirs size_t count; // Total file count including subdirs bool trimmed; // Load only top level directory }; #if (defined (WIN32)) static void s_win32_populate_entry (zdir_t *self, WIN32_FIND_DATAA *entry) { if (entry->cFileName [0] == '.') ; // Skip hidden files else // If we have a subdirectory, go load that if (entry->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (!self->trimmed) { zdir_t *subdir = zdir_new (entry->cFileName, self->path); zlist_append (self->subdirs, subdir); } } else { // Add file entry to directory list zfile_t *file = zfile_new (self->path, entry->cFileName); assert (file); zlist_append (self->files, file); } } #else static void s_posix_populate_entry (zdir_t *self, struct dirent *entry) { // Skip . and .. if (streq (entry->d_name, ".") || streq (entry->d_name, "..")) return; char fullpath [1024 + 1]; snprintf (fullpath, 1024, "%s/%s", self->path, entry->d_name); struct stat stat_buf; if (stat (fullpath, &stat_buf)) return; if (entry->d_name [0] == '.') ; // Skip hidden files else // If we have a subdirectory, go load that if (S_ISDIR (stat_buf.st_mode)) { if (!self->trimmed) { zdir_t *subdir = zdir_new (entry->d_name, self->path); assert (subdir); zlist_append (self->subdirs, subdir); } } else { // Add file entry to directory list zfile_t *file = zfile_new (self->path, entry->d_name); assert (file); zlist_append (self->files, file); } } #endif #ifndef WIN32 static pthread_mutex_t s_readdir_mutex = PTHREAD_MUTEX_INITIALIZER; #endif // -------------------------------------------------------------------------- // Create a new directory item that loads in the full tree of the specified // path, optionally located under some parent path. If parent is "-", then // loads only the top-level directory, and does not use parent as a path. zdir_t * zdir_new (const char *path, const char *parent) { zdir_t *self = (zdir_t *) zmalloc (sizeof (zdir_t)); assert (self); if (parent) { if (streq (parent, "-")) { self->trimmed = true; self->path = strdup (path); if (!self->path) { zdir_destroy (&self); return NULL; } } else { self->path = (char *) zmalloc (strlen (path) + strlen (parent) + 2); if (self->path) sprintf (self->path, "%s/%s", parent, path); else { zdir_destroy (&self); return NULL; } } } else { self->path = strdup (path); if (!self->path) { zdir_destroy (&self); return NULL; } } if (self->path) self->files = zlist_new (); if (self->files) self->subdirs = zlist_new (); if (!self->subdirs) { zdir_destroy (&self); return NULL; } #if (defined (WIN32)) // On Windows, replace backslashes by normal slashes char *path_clean_ptr = self->path; while (*path_clean_ptr) { if (*path_clean_ptr == '\\') *path_clean_ptr = '/'; path_clean_ptr++; } // Remove any trailing slash if (self->path [strlen (self->path) - 1] == '/') self->path [strlen (self->path) - 1] = 0; // Win32 wants a wildcard at the end of the path char *wildcard = (char *) zmalloc (strlen (self->path) + 3); if (!wildcard) { zdir_destroy (&self); return NULL; } sprintf (wildcard, "%s/*", self->path); WIN32_FIND_DATAA entry; HANDLE handle = FindFirstFileA (wildcard, &entry); freen (wildcard); if (handle != INVALID_HANDLE_VALUE) { // We have read an entry, so return those values s_win32_populate_entry (self, &entry); while (FindNextFileA (handle, &entry)) s_win32_populate_entry (self, &entry); FindClose (handle); } #else // Remove any trailing slash if (self->path [strlen (self->path) - 1] == '/') self->path [strlen (self->path) - 1] = 0; DIR *handle = opendir (self->path); if (handle) { // readdir_r is deprecated in glibc 2.24, but readdir is still not // guaranteed to be thread safe if the same directory is accessed // by different threads at the same time. Unfortunately given it was // not a constraint before we cannot change it now as it would be an // API breakage. Use a global lock when scanning the directory to // work around it. pthread_mutex_lock (&s_readdir_mutex); struct dirent *entry = readdir (handle); pthread_mutex_unlock (&s_readdir_mutex); while (entry != NULL) { // Beware of recursion. Lock only around readdir calls. s_posix_populate_entry (self, entry); pthread_mutex_lock (&s_readdir_mutex); entry = readdir (handle); pthread_mutex_unlock (&s_readdir_mutex); } closedir (handle); } #endif else { zdir_destroy (&self); return NULL; } // Update directory signatures zdir_t *subdir = (zdir_t *) zlist_first (self->subdirs); while (subdir) { if (self->modified < subdir->modified) self->modified = subdir->modified; self->cursize += subdir->cursize; self->count += subdir->count; subdir = (zdir_t *) zlist_next (self->subdirs); } zfile_t *file = (zfile_t *) zlist_first (self->files); while (file) { if (self->modified < zfile_modified (file)) self->modified = zfile_modified (file); self->cursize += zfile_cursize (file); self->count += 1; file = (zfile_t *) zlist_next (self->files); } return self; } // -------------------------------------------------------------------------- // Destroy a directory item void zdir_destroy (zdir_t **self_p) { assert (self_p); if (*self_p) { zdir_t *self = *self_p; if (self->subdirs) while (zlist_size (self->subdirs)) { zdir_t *subdir = (zdir_t *) zlist_pop (self->subdirs); zdir_destroy (&subdir); } if (self->files) while (zlist_size (self->files)) { zfile_t *file = (zfile_t *) zlist_pop (self->files); zfile_destroy (&file); } zlist_destroy (&self->subdirs); zlist_destroy (&self->files); freen (self->path); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Return directory path const char * zdir_path (zdir_t *self) { return self->path; } // -------------------------------------------------------------------------- // Return last modification time for directory. time_t zdir_modified (zdir_t *self) { assert (self); return self->modified; } // -------------------------------------------------------------------------- // Return total hierarchy size, in bytes of data contained in all files // in the directory tree. off_t zdir_cursize (zdir_t *self) { assert (self); return self->cursize; } // -------------------------------------------------------------------------- // Return directory count size_t zdir_count (zdir_t *self) { assert (self); return self->count; } // -------------------------------------------------------------------------- // Returns a sorted array of zfile objects; returns a single block of memory, // that you destroy by calling zdir_flatten_free(). Each entry in the array // is a pointer to a zfile_t item already allocated in the zdir tree. The // array ends with a null pointer. Do not destroy the original zdir tree // until you are done with this array. static int s_dir_flatten (zdir_t *self, zfile_t **files, int index); static int s_dir_compare (void *item1, void *item2); static int s_file_compare (void *item1, void *item2); zfile_t ** zdir_flatten (zdir_t *self) { size_t flat_size; if (self) flat_size = self->count + 1; else flat_size = 1; // Just null terminator zfile_t **files = (zfile_t **) zmalloc (sizeof (zfile_t *) * flat_size); uint index = 0; if (self) index = s_dir_flatten (self, files, index); return files; } // Flatten one directory, calls itself recursively static int s_dir_flatten (zdir_t *self, zfile_t **files, int index) { // First flatten the normal files zlist_sort (self->files, s_file_compare); zfile_t *file = (zfile_t *) zlist_first (self->files); while (file) { files [index++] = file; file = (zfile_t *) zlist_next (self->files); } // Now flatten subdirectories, recursively zlist_sort (self->subdirs, s_dir_compare); zdir_t *subdir = (zdir_t *) zlist_first (self->subdirs); while (subdir) { index = s_dir_flatten (subdir, files, index); subdir = (zdir_t *) zlist_next (self->subdirs); } return index; } // Compare two subdirs, true if they need swapping static int s_dir_compare (void *item1, void *item2) { assert (item1); assert (item2); return strcmp (zdir_path ((zdir_t *) item1), zdir_path ((zdir_t *) item2)); } // Compare two files, true if they need swapping. We sort by ascending name. static int s_file_compare (void *item1, void *item2) { assert (item1); assert (item2); return strcmp (zfile_filename ((zfile_t *) item1, NULL), zfile_filename ((zfile_t *) item2, NULL)); } // -------------------------------------------------------------------------- // Free a provided string, and nullify the parent pointer. Safe to call on // a null pointer. void zdir_flatten_free (zfile_t ***files_p) { assert (files_p); freen (*files_p); *files_p = NULL; } // -------------------------------------------------------------------------- // Returns a sorted list of zfile objects; Each entry in the list is a pointer // to a zfile_t item already allocated in the zdir tree. Do not destroy the // original zdir tree until you are done with this list. zlist_t * zdir_list (zdir_t *self) { zfile_t **files = zdir_flatten (self); zlist_t *list = zlist_new (); size_t index; if (files) { for (index = 0 ; files[index] ; index++) { zlist_append (list, files[index]); } } zdir_flatten_free (&files); return list; } // -------------------------------------------------------------------------- // Remove directory, optionally including all files that it contains, at // all levels. If force is false, will only remove the directory if empty. // If force is true, will remove all files and all subdirectories. void zdir_remove (zdir_t *self, bool force) { // If forced, remove all subdirectories and files if (force) { zfile_t *file = (zfile_t *) zlist_pop (self->files); while (file) { zfile_remove (file); zfile_destroy (&file); file = (zfile_t *) zlist_pop (self->files); } zdir_t *subdir = (zdir_t *) zlist_pop (self->subdirs); while (subdir) { zdir_remove (subdir, force); zdir_destroy (&subdir); subdir = (zdir_t *) zlist_pop (self->subdirs); } self->cursize = 0; self->count = 0; } // Remove if empty if (zlist_size (self->files) == 0 && zlist_size (self->subdirs) == 0) zsys_dir_delete (self->path); } // -------------------------------------------------------------------------- // Calculate differences between two versions of a directory tree. // Returns a list of zdir_patch_t patches. Either older or newer may // be null, indicating the directory is empty/absent. If alias is set, // generates virtual filename (minus path, plus alias). zlist_t * zdir_diff (zdir_t *older, zdir_t *newer, const char *alias) { zlist_t *patches = zlist_new (); if (!patches) return NULL; zfile_t **old_files = zdir_flatten (older); zfile_t **new_files = zdir_flatten (newer); int old_index = 0; int new_index = 0; // Note that both lists are sorted, so detecting differences // is rather trivial while (old_files [old_index] || new_files [new_index]) { zfile_t *old_file = old_files [old_index]; zfile_t *new_file = new_files [new_index]; int cmp; if (!old_file) cmp = 1; // Old file was deleted at end of list else if (!new_file) cmp = -1; // New file was added at end of list else cmp = strcmp (zfile_filename (old_file, NULL), zfile_filename (new_file, NULL)); if (cmp > 0) { // New file was created if (zfile_is_stable (new_file)) { int rc = zlist_append (patches, zdir_patch_new (newer->path, new_file, patch_create, alias)); if (rc != 0) { zlist_destroy (&patches); break; } } old_index--; } else if (cmp < 0) { // Old file was deleted if (zfile_is_stable (old_file)) { int rc = zlist_append (patches, zdir_patch_new (older->path, old_file, patch_delete, alias)); if (rc != 0) { zlist_destroy (&patches); break; } } new_index--; } else if (cmp == 0 && zfile_is_stable (new_file)) { if (zfile_is_stable (old_file)) { // Old file was modified or replaced // Since we don't check file contents, treat as created // Could better do SHA check on file here if (zfile_modified (new_file) != zfile_modified (old_file) || zfile_cursize (new_file) != zfile_cursize (old_file)) { int rc = zlist_append (patches, zdir_patch_new (newer->path, new_file, patch_create, alias)); if (rc != 0) { zlist_destroy (&patches); break; } } } else { // File was created over some period of time int rc = zlist_append (patches, zdir_patch_new (newer->path, new_file, patch_create, alias)); if (rc != 0) { zlist_destroy (&patches); break; } } } old_index++; new_index++; } freen (old_files); freen (new_files); return patches; } // -------------------------------------------------------------------------- // Return full contents of directory as a patch list. If alias is set, // generates virtual filename (minus path, plus alias). zlist_t * zdir_resync (zdir_t *self, const char *alias) { zlist_t *patches = zlist_new (); if (!patches) return NULL; zfile_t **files = zdir_flatten (self); uint index; for (index = 0;; index++) { zfile_t *file = files [index]; if (!file) break; if (zlist_append (patches, zdir_patch_new ( self->path, file, patch_create, alias))) { zlist_destroy (&patches); break; } } freen (files); return patches; } // -------------------------------------------------------------------------- // Load directory cache; returns a hash table containing the SHA-1 digests // of every file in the tree. The cache is saved between runs in .cache. // The caller must destroy the hash table when done with it. zhash_t * zdir_cache (zdir_t *self) { assert (self); // Load any previous cache from disk zhash_t *cache = zhash_new (); if (!cache) return NULL; zhash_autofree (cache); char *cache_file = (char *) zmalloc (strlen (self->path) + strlen ("/.cache") + 1); if (!cache_file) { zhash_destroy (&cache); return NULL; } sprintf (cache_file, "%s/.cache", self->path); zhash_load (cache, cache_file); // Recalculate digest for any new files zfile_t **files = zdir_flatten (self); uint index; for (index = 0;; index++) { zfile_t *file = files [index]; if (!file) break; const char *filename = zfile_filename (file, self->path); if (zhash_lookup (cache, zfile_filename (file, self->path)) == NULL) { int rc = zhash_insert (cache, filename, (void *) zfile_digest (file)); if (rc != 0) { zhash_destroy (&cache); break; } } } freen (files); // Save cache to disk for future reference if (cache) zhash_save (cache, cache_file); freen (cache_file); return cache; } // -------------------------------------------------------------------------- // Print contents of directory to open stream void zdir_fprint (zdir_t *self, FILE *stream, int indent) { assert (self); zfile_t **files = zdir_flatten (self); uint index; for (index = 0;; index++) { zfile_t *file = files [index]; if (!file) break; fprintf (stream, "%s\n", zfile_filename (file, NULL)); } zdir_flatten_free (&files); } // -------------------------------------------------------------------------- // Print contents of directory to stdout void zdir_print (zdir_t *self, int indent) { zdir_fprint (self, stdout, indent); } // -------------------------------------------------------------------------- // Watch a directory for changes typedef struct _zdir_watch_t { zsock_t *pipe; // actor command channel zloop_t *loop; // event reactor int read_timer_id; // the zloop timer id to signal directory updating bool verbose; // extra logging to be printed zhash_t *subs; // path -> zdir_watch_sub_t instance hashtable for each active subscription } zdir_watch_t; typedef struct _zdir_watch_sub_t { zdir_t *dir; } zdir_watch_sub_t; static int s_on_read_timer (zloop_t *loop, int timer_id, void *arg) { zdir_watch_t *watch = (zdir_watch_t *) arg; void *data; for (data = zhash_first (watch->subs); data != NULL; data = zhash_next (watch->subs)) { zdir_watch_sub_t *sub = (zdir_watch_sub_t *) data; zdir_t *new_dir = zdir_new (zdir_path (sub->dir), NULL); if (!new_dir) { if (watch->verbose) zsys_error ("zdir_watch: Unable to create new zdir for path %s", zdir_path (sub->dir)); continue; } // Determine if anything has changed. zlist_t *diff = zdir_diff (sub->dir, new_dir, ""); // Do memory management before error handling... zdir_destroy (&sub->dir); sub->dir = new_dir; if (!diff) { if (watch->verbose) zsys_error ("zdir_watch: Unable to create diff for path %s", zdir_path (sub->dir)); continue; } if (zlist_size (diff) > 0) { if (watch->verbose) { zdir_patch_t *patch = (zdir_patch_t *) zlist_first (diff); zsys_info ("zdir_watch: Found %d changes in %s:", zlist_size (diff), zdir_path (sub->dir)); while (patch) { zsys_info ("zdir_watch: %s %s", zfile_filename (zdir_patch_file (patch), NULL), zdir_patch_op (patch) == ZDIR_PATCH_CREATE? "created": "deleted"); patch = (zdir_patch_t *) zlist_next (diff); } } if (zsock_send (watch->pipe, "sp", zdir_path (sub->dir), diff) != 0) { if (watch->verbose) zsys_error ("zdir_watch: Unable to send patch list for path %s", zdir_path (sub->dir)); zlist_destroy (&diff); } // Successfully sent `diff` list - now owned by receiver } else { zlist_destroy (&diff); } } return 0; } static void s_zdir_watch_destroy (zdir_watch_t **watch_p) { assert (watch_p); if (*watch_p) { zdir_watch_t *watch = *watch_p; zloop_destroy (&watch->loop); zhash_destroy (&watch->subs); freen (watch); *watch_p = NULL; } } static void s_sub_free (void *data) { zdir_watch_sub_t *sub = (zdir_watch_sub_t *) data; zdir_destroy (&sub->dir); freen (sub); } static void s_zdir_watch_subscribe (zdir_watch_t *watch, const char *path) { if (watch->verbose) zsys_info ("zdir_watch: Subscribing to directory path: %s", path); zdir_watch_sub_t *sub = (zdir_watch_sub_t *) zmalloc (sizeof (zdir_watch_sub_t)); sub->dir = zdir_new (path, NULL); if (!sub->dir) { if (watch->verbose) zsys_error ("zdir_watch: Unable to create zdir for path: %s", path); zsock_signal (watch->pipe, 1); return; } int rc = zhash_insert (watch->subs, path, sub); if (rc) { if (watch->verbose) zsys_error ("zdir_watch: Unable to insert path '%s' into subscription list", path); zsock_signal (watch->pipe, 1); return; } void *item = zhash_freefn (watch->subs, path, s_sub_free); if (item != sub) { if (watch->verbose) zsys_error ("zdir_watch: Unable to set free fn for path %s", path); zsock_signal (watch->pipe, 1); return; } if (watch->verbose) zsys_info ("zdir_watch: Successfully subscribed to %s", path); zsock_signal (watch->pipe, 0); } static void s_zdir_watch_unsubscribe (zdir_watch_t *watch, const char *path) { if (watch->verbose) zsys_info ("zdir_watch: Unsubscribing from directory path: %s", path); zhash_delete (watch->subs, path); if (watch->verbose) zsys_info ("zdir_watch: Successfully unsubscribed from %s", path); zsock_signal (watch->pipe, 0); } static int s_zdir_watch_timeout (zdir_watch_t *watch, int timeout) { if (watch->verbose) zsys_info ("zdir_watch: Setting directory poll timeout to %d", timeout); if (watch->read_timer_id != -1) { zloop_timer_end (watch->loop, watch->read_timer_id); watch->read_timer_id = -1; } watch->read_timer_id = zloop_timer (watch->loop, timeout, 0, s_on_read_timer, watch); if (watch->verbose) zsys_info ("zdir_watch: Successfully set directory poll timeout to %d", timeout); return 0; } static zdir_watch_t * s_zdir_watch_new (zsock_t *pipe) { zdir_watch_t *watch = (zdir_watch_t *) zmalloc (sizeof (zdir_watch_t)); if (!watch) return NULL; watch->pipe = pipe; watch->read_timer_id = -1; watch->verbose = false; return watch; } static int s_on_command (zloop_t *loop, zsock_t *reader, void *arg) { zdir_watch_t *watch = (zdir_watch_t *) arg; zmsg_t *msg = zmsg_recv (watch->pipe); assert (msg); char *command = zmsg_popstr (msg); assert (command); if (watch->verbose) zsys_info ("zdir_watch: Command received: %s", command); if (streq (command, "$TERM")) { zstr_free (&command); zmsg_destroy (&msg); return -1; } else if (streq (command, "VERBOSE")) { watch->verbose = true; zsock_signal (watch->pipe, 0); } else if (streq (command, "SUBSCRIBE")) { char *path = zmsg_popstr (msg); if (path) { s_zdir_watch_subscribe (watch, path); freen (path); } else { if (watch->verbose) zsys_error ("zdir_watch: Unable to extract path from SUBSCRIBE message"); zsock_signal (watch->pipe, 1); } } else if (streq (command, "UNSUBSCRIBE")) { char *path = zmsg_popstr (msg); if (path) { assert (path); s_zdir_watch_unsubscribe (watch, path); freen (path); } else { if (watch->verbose) zsys_error ("zdir_watch: Unable to extract path from UNSUBSCRIBE message"); zsock_signal (watch->pipe, 1); } } else if (streq (command, "TIMEOUT")) { char *timeout_string = zmsg_popstr (msg); if (timeout_string) { int timeout = atoi (timeout_string); zsock_signal (watch->pipe, s_zdir_watch_timeout (watch, timeout)); freen (timeout_string); } else { if (watch->verbose) zsys_error ("zdir_watch: Unable to extract time from TIMEOUT message"); zsock_signal (watch->pipe, 1); } } else { if (watch->verbose) zsys_warning ("zdir_watch: Unknown command '%s'", command); zsock_signal (watch->pipe, 1); } freen (command); zmsg_destroy (&msg); return 0; } // -------------------------------------------------------------------------- // Create a new zdir_watch actor instance void zdir_watch (zsock_t *pipe, void *unused) { zdir_watch_t *watch = s_zdir_watch_new (pipe); assert (watch); watch->loop = zloop_new (); assert (watch->loop); watch->subs = zhash_new (); assert (watch->subs); zloop_reader (watch->loop, pipe, s_on_command, watch); zloop_reader_set_tolerant (watch->loop, pipe); // command pipe needs to be tolerant, otherwise we'd have a hard time shutting down s_zdir_watch_timeout (watch, 250); // default poll time of 250ms // Signal initialization zsock_signal (pipe, 0); // Dispatch above handlers zloop_start (watch->loop); if (watch->verbose) zsys_info ("zdir_watch: Complete"); // signal destruction zsock_signal (watch->pipe, 0); // Done - cleanup and exit s_zdir_watch_destroy (&watch); } // -------------------------------------------------------------------------- // Self test of this class void zdir_test (bool verbose) { printf (" * zdir: "); // @selftest const char *SELFTEST_DIR_RW = "src/selftest-rw"; const char *testbasedir = "zdir-test-dir"; const char *testfile1 = "initial_file"; const char *testfile2 = "test_abc"; char *basedirpath = NULL; // subdir in a test, under SELFTEST_DIR_RW char *filepath1 = NULL; // pathname to testfile in a test, in dirpath char *filepath2 = NULL; // pathname to testfile in a test, in dirpath basedirpath = zsys_sprintf ("%s/%s", SELFTEST_DIR_RW, testbasedir); assert (basedirpath); filepath1 = zsys_sprintf ("%s/%s", basedirpath, testfile1); assert (filepath1); filepath2 = zsys_sprintf ("%s/%s", basedirpath, testfile2); assert (filepath2); /* char *relfilepath2 = NULL; // pathname to testfile in a test, in dirpath relfilepath2 = zsys_sprintf ("%s/%s", testbasedir, testfile2); assert (relfilepath2); */ // Make sure old aborted tests do not hinder us zdir_t *dir = zdir_new (basedirpath, NULL); if (dir) { zdir_remove (dir, true); zdir_destroy (&dir); } zsys_file_delete (filepath1); zsys_file_delete (filepath2); zsys_dir_delete (basedirpath); dir = zdir_new ("does-not-exist", NULL); if (dir) { zdir_remove (dir, true); zdir_destroy (&dir); } // need to create a file in the test directory we're watching // in order to ensure the directory exists zfile_t *initfile = zfile_new (basedirpath, testfile1); assert (initfile); zfile_output (initfile); fprintf (zfile_handle (initfile), "initial file\n"); zfile_close (initfile); zfile_destroy (&initfile); zdir_t *older = zdir_new (basedirpath, NULL); assert (older); if (verbose) { printf ("\n"); zdir_dump (older, 0); } zdir_t *newer = zdir_new (SELFTEST_DIR_RW, NULL); assert (newer); zlist_t *patches = zdir_diff (older, newer, "/"); assert (patches); while (zlist_size (patches)) { zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches); zdir_patch_destroy (&patch); } zlist_destroy (&patches); zdir_destroy (&older); zdir_destroy (&newer); zdir_t *nosuch = zdir_new ("does-not-exist", NULL); assert (nosuch == NULL); // zdir_watch test: zactor_t *watch = zactor_new (zdir_watch, NULL); assert (watch); int synced; if (verbose) { zsock_send (watch, "s", "VERBOSE"); synced = zsock_wait(watch); assert ( synced == 0); } // wait for initial file to become 'stable' #ifdef CZMQ_BUILD_DRAFT_API zclock_sleep ((int)zsys_file_stable_age_msec() + 50); #else zclock_sleep (5050); #endif zsock_send (watch, "si", "TIMEOUT", 100); synced = zsock_wait(watch); assert (synced == 0); zsock_send (watch, "ss", "SUBSCRIBE", basedirpath); synced = zsock_wait(watch); assert(synced == 0); zsock_send (watch, "ss", "UNSUBSCRIBE", basedirpath); synced = zsock_wait(watch); assert(synced == 0); zsock_send (watch, "ss", "SUBSCRIBE", basedirpath); synced = zsock_wait(watch); assert(synced == 0); zfile_t *newfile = zfile_new (basedirpath, testfile2); zfile_output (newfile); fprintf (zfile_handle (newfile), "test file\n"); zfile_close (newfile); zpoller_t *watch_poll = zpoller_new (watch, NULL); // poll for a certain timeout before giving up and failing the test void* polled = NULL; #ifdef CZMQ_BUILD_DRAFT_API polled = zpoller_wait(watch_poll, (int)zsys_file_stable_age_msec() + 150); #else polled = zpoller_wait(watch_poll, 5150); #endif assert (polled == watch); // wait for notification of the file being added char *path; int rc = zsock_recv (watch, "sp", &path, &patches); assert (rc == 0); assert (streq (path, basedirpath)); freen (path); if (verbose) zsys_debug("zdir_test() : added : zlist_size (patches)=%d", zlist_size (patches) ); assert (zlist_size (patches) == 1); zdir_patch_t *patch = (zdir_patch_t *) zlist_pop (patches); if (verbose) zsys_debug("zdir_test() : added : zdir_patch_path (patch)='%s'", zdir_patch_path (patch) ); assert (streq (zdir_patch_path (patch), basedirpath)); zfile_t *patch_file = zdir_patch_file (patch); if (verbose) zsys_debug("zdir_test() : added : zfile_filename (patch_file, \"\")='%s'", zfile_filename (patch_file, "") ); assert (streq (zfile_filename (patch_file, ""), filepath2)); zdir_patch_destroy (&patch); zlist_destroy (&patches); // remove the file zfile_remove (newfile); zfile_destroy (&newfile); // poll for a certain timeout before giving up and failing the test. #ifdef CZMQ_BUILD_DRAFT_API polled = zpoller_wait(watch_poll, (int)zsys_file_stable_age_msec() + 150); #else polled = zpoller_wait(watch_poll, 5150); #endif assert (polled == watch); // wait for notification of the file being removed rc = zsock_recv (watch, "sp", &path, &patches); assert (rc == 0); assert (streq (path, basedirpath)); freen (path); if (verbose) zsys_debug("zdir_test() : removed : zlist_size (patches)=%d", zlist_size (patches) ); assert (zlist_size (patches) == 1); patch = (zdir_patch_t *) zlist_pop (patches); if (verbose) zsys_debug("zdir_test() : removed : zdir_patch_path (patch)='%s'", zdir_patch_path (patch) ); assert (streq (zdir_patch_path (patch), basedirpath)); patch_file = zdir_patch_file (patch); if (verbose) zsys_debug("zdir_test() : removed : zfile_filename (patch_file, \"\")='%s'", zfile_filename (patch_file, "") ); assert (streq (zfile_filename (patch_file, ""), filepath2)); zdir_patch_destroy (&patch); zlist_destroy (&patches); zpoller_destroy (&watch_poll); zactor_destroy (&watch); // clean up by removing the test directory. dir = zdir_new (basedirpath, NULL); assert (dir); zdir_remove (dir, true); zdir_destroy (&dir); zstr_free (&basedirpath); zstr_free (&filepath1); zstr_free (&filepath2); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); } czmq-4.1.0/src/Makemodule.am0000664000372000037200000002531013222211156016555 0ustar00travistravis00000000000000################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ program_libs = src/libczmq.la ${project_libs} # Programs need to link the c++ runtime if everything was compiled statically. if !ENABLE_SHARED program_libs += -lstdc++ -lm endif lib_LTLIBRARIES += src/libczmq.la pkgconfig_DATA = src/libczmq.pc include_HEADERS = \ include/czmq_prelude.h \ include/czmq.h \ include/zactor.h \ include/zarmour.h \ include/zcert.h \ include/zcertstore.h \ include/zchunk.h \ include/zclock.h \ include/zconfig.h \ include/zdigest.h \ include/zdir.h \ include/zdir_patch.h \ include/zfile.h \ include/zframe.h \ include/zhash.h \ include/zhashx.h \ include/ziflist.h \ include/zlist.h \ include/zlistx.h \ include/zloop.h \ include/zmsg.h \ include/zpoller.h \ include/zsock.h \ include/zstr.h \ include/zsys.h \ include/zuuid.h \ include/zauth.h \ include/zbeacon.h \ include/zgossip.h \ include/zmonitor.h \ include/zproxy.h \ include/zrex.h \ include/czmq_library.h if ENABLE_DRAFTS include_HEADERS += \ include/zargs.h \ include/zproc.h \ include/ztimerset.h \ include/ztrie.h endif src_libczmq_la_SOURCES = \ src/zactor.c \ src/zarmour.c \ src/zcert.c \ src/zcertstore.c \ src/zchunk.c \ src/zclock.c \ src/zconfig.c \ src/zdigest.c \ src/zdir.c \ src/zdir_patch.c \ src/zfile.c \ src/zframe.c \ src/zhash.c \ src/zhashx.c \ src/ziflist.c \ src/zlist.c \ src/zlistx.c \ src/zloop.c \ src/zmsg.c \ src/zpoller.c \ src/zsock.c \ src/zstr.c \ src/zsys.c \ src/zuuid.c \ src/zauth.c \ src/zbeacon.c \ src/zgossip.c \ src/zgossip_engine.inc \ src/zmonitor.c \ src/zproxy.c \ src/zrex.c \ src/zgossip_msg.c \ src/zsock_option.inc \ src/zgossip_engine.inc \ src/zhash_primes.inc \ src/foreign/sha1/sha1.inc_c \ src/foreign/sha1/sha1.h \ src/foreign/slre/slre.inc_c \ src/foreign/slre/slre.h \ src/foreign/slre/readme.txt \ src/platform.h if ENABLE_DRAFTS src_libczmq_la_SOURCES += \ src/zargs.c \ src/zproc.c \ src/ztimerset.c \ src/ztrie.c endif if ENABLE_DRAFTS src_libczmq_la_SOURCES += \ src/czmq_private_selftest.c endif src_libczmq_la_CPPFLAGS = ${AM_CPPFLAGS} src_libczmq_la_LDFLAGS = \ -version-info @LTVER@ \ $(LIBTOOL_EXTRA_LDFLAGS) if ON_MINGW src_libczmq_la_LDFLAGS += \ -no-undefined \ -avoid-version endif if ON_CYGWIN src_libczmq_la_LDFLAGS += \ -no-undefined \ -avoid-version endif src_libczmq_la_LIBADD = ${project_libs} if ENABLE_ZMAKECERT bin_PROGRAMS += src/zmakecert src_zmakecert_CPPFLAGS = ${AM_CPPFLAGS} src_zmakecert_LDADD = ${program_libs} src_zmakecert_SOURCES = src/zmakecert.c endif #ENABLE_ZMAKECERT if ENABLE_ZSP noinst_PROGRAMS += src/zsp src_zsp_CPPFLAGS = ${AM_CPPFLAGS} src_zsp_LDADD = ${program_libs} src_zsp_SOURCES = src/zsp.c endif #ENABLE_ZSP if ENABLE_TEST_RANDOF noinst_PROGRAMS += src/test_randof src_test_randof_CPPFLAGS = ${AM_CPPFLAGS} src_test_randof_LDADD = ${program_libs} src_test_randof_SOURCES = src/test_randof.c endif #ENABLE_TEST_RANDOF if ENABLE_CZMQ_SELFTEST check_PROGRAMS += src/czmq_selftest noinst_PROGRAMS += src/czmq_selftest src_czmq_selftest_CPPFLAGS = ${AM_CPPFLAGS} src_czmq_selftest_LDADD = ${program_libs} src_czmq_selftest_SOURCES = src/czmq_selftest.c endif #ENABLE_CZMQ_SELFTEST # Install api files into /usr/local/share/zproject apidir = @datadir@/zproject/czmq dist_api_DATA = \ api/zactor.api \ api/zargs.api \ api/zarmour.api \ api/zcert.api \ api/zcertstore.api \ api/zchunk.api \ api/zclock.api \ api/zconfig.api \ api/zdigest.api \ api/zdir.api \ api/zdir_patch.api \ api/zfile.api \ api/zframe.api \ api/zhash.api \ api/zhashx.api \ api/ziflist.api \ api/zlist.api \ api/zlistx.api \ api/zloop.api \ api/zmsg.api \ api/zpoller.api \ api/zproc.api \ api/zsock_option.api \ api/zsock.api \ api/zstr.api \ api/zsys.api \ api/ztimerset.api \ api/ztrie.api \ api/zuuid.api \ api/zgossip_msg.api # define custom target for all products of /src src: \ src/zmakecert \ src/zsp \ src/test_randof \ src/czmq_selftest \ src/libczmq.la # Produce generated code from models in the src directory code: cd $(srcdir)/src; gsl -topdir:.. -zproject:1 -q sockopts.xml cd $(srcdir)/src; gsl -topdir:.. -zproject:1 -q zgossip.xml cd $(srcdir)/src; gsl -topdir:.. -zproject:1 -private:1 -q zgossip_msg.xml cd $(srcdir); gsl -target:- project.xml # Directories with test fixtures optionally provided by the project, # and with volatile RW data possibly created by a selftest program. # It is up to the project authors to populate the RO directory with # filenames called from the selftest methods, if any. They will be # EXTRA_DISTed by the recipes generated with with zproject, however, # and copied into builddir (if different from srcdir) to simplify # the "distcheck" and similar tests (so selftest can use same paths). # Note that the RO directory must exist to fulfill EXTRA_DIST, so we # add a stub file that can be committed to SCM by project developers. # The RW directory will be automatically wiped by "make distclean". SELFTEST_DIR_RO = src/selftest-ro SELFTEST_DIR_RW = src/selftest-rw # This is recreated on every invocation (as a selftest dependency), # so tests run in a clean environment $(top_builddir)/$(SELFTEST_DIR_RW): rm -rf "$@" mkdir -p "$@" # Note: for some reason "$<" misfired in rule below on Travis, so be explicit if USING_VPATH $(abs_top_builddir)/$(SELFTEST_DIR_RO): $(abs_top_srcdir)/$(SELFTEST_DIR_RO) @echo " COPYDIR $(SELFTEST_DIR_RO)"; \ rm -rf "$@"; \ cp -r "$(abs_top_srcdir)/$(SELFTEST_DIR_RO)" "$@" $(top_builddir)/$(SELFTEST_DIR_RO): $(abs_top_builddir)/$(SELFTEST_DIR_RO) endif $(SELFTEST_DIR_RO): $(top_builddir)/$(SELFTEST_DIR_RO) CLEANFILES += $(top_builddir)/$(SELFTEST_DIR_RW)/* # Note that this syntax dists the whole directory - including subdirs (if any) EXTRA_DIST += $(SELFTEST_DIR_RO) clean-local: clean-local-selftest-ro clean-local-selftest-rw .PHONY: clean-local-selftest-ro clean-local-selftest-ro: @if test "$(top_builddir)" != "$(top_srcdir)" ; then \ if test -d "$(top_builddir)/$(SELFTEST_DIR_RO)" ; then \ chmod -R u+w "$(top_builddir)/$(SELFTEST_DIR_RO)" ; \ rm -rf "$(top_builddir)/$(SELFTEST_DIR_RO)" ; \ fi; \ fi # Unlike CLEANFILES setting above, this one whould also wipe created subdirs .PHONY: clean-local-selftest-rw clean-local-selftest-rw: @if test "$(top_builddir)" != "$(top_srcdir)" ; then \ if test -d "$(top_builddir)/$(SELFTEST_DIR_RW)" ; then \ chmod -R u+w "$(top_builddir)/$(SELFTEST_DIR_RW)" ; \ rm -rf "$(top_builddir)/$(SELFTEST_DIR_RW)" ; \ fi; \ fi check-empty-selftest-rw: if test -e $(top_builddir)/$(SELFTEST_DIR_RW) ; then \ if test `find "$(top_builddir)/$(SELFTEST_DIR_RW)" | wc -l` -lt 1 ; then \ echo "FATAL: selftest did not tidy up the data it wrote" >&2 ; \ find "$(top_builddir)/$(SELFTEST_DIR_RW)" ; \ exit 2; \ else true ; fi; \ else true ; fi check-local: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute $(builddir)/src/czmq_selftest $(MAKE) check-empty-selftest-rw check-verbose: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute $(builddir)/src/czmq_selftest -v $(MAKE) check-empty-selftest-rw # Run the selftest binary under valgrind to check for memory leaks memcheck: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute valgrind --tool=memcheck \ --leak-check=full --show-reachable=yes --error-exitcode=1 \ --suppressions=$(srcdir)/src/.valgrind.supp \ $(VALGRIND_OPTIONS) \ $(builddir)/src/czmq_selftest $(MAKE) check-empty-selftest-rw memcheck-verbose: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute valgrind --tool=memcheck \ --leak-check=full --show-reachable=yes --error-exitcode=1 \ --suppressions=$(srcdir)/src/.valgrind.supp \ $(VALGRIND_OPTIONS) \ $(builddir)/src/czmq_selftest -v $(MAKE) check-empty-selftest-rw # Run the selftest binary under valgrind to check for performance leaks callcheck: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute valgrind --tool=callgrind \ $(VALGRIND_OPTIONS) \ $(builddir)/src/czmq_selftest $(MAKE) check-empty-selftest-rw callcheck-verbose: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute valgrind --tool=callgrind \ $(VALGRIND_OPTIONS) \ $(builddir)/src/czmq_selftest -v $(MAKE) check-empty-selftest-rw # Run the selftest binary under gdb for debugging debug: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute gdb -q \ $(builddir)/src/czmq_selftest $(MAKE) check-empty-selftest-rw debug-verbose: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute gdb -q \ $(builddir)/src/czmq_selftest -v $(MAKE) check-empty-selftest-rw # Run the selftest binary with verbose switch for tracing animate: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) $(LIBTOOL) --mode=execute $(builddir)/src/czmq_selftest -v $(MAKE) check-empty-selftest-rw animate-verbose: animate if WITH_GCOV coverage: src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) @echo "you had called configure --with-gcov" lcov --base-directory . --directory . --zerocounters -q $(MAKE) check lcov --base-directory . --directory . --capture -o coverage.info lcov --remove coverage.info "/usr*" -o coverage.info lcov --remove coverage.info "czmq_selftest.c" -o coverage.info $(RM) -rf coverage/* genhtml -o coverage/ -t "czmq test coverage" --num-spaces 4 coverage.info else coverage: src/czmq_selftest @echo "call make clean && configure --with-gcov to enable code coverage" @exit 1 endif ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ czmq-4.1.0/src/zarmour.c0000664000372000037200000007400113222211156016017 0ustar00travistravis00000000000000/* ========================================================================= zarmour - armoured text encoding and decoding Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ /* @header zarmour - armoured text encoding and decoding @discuss The zarmour class implements encoding and decoding of armoured text data. The following codecs are implemented: * RFC 4648 (http://www.ietf.org/rfc/rfc4648.txt) - base64 - base64url - base32 - base32hex - base16 * Z85 (http://rfc.zeromq.org/spec:32) All RFC4648 base64 and base32 variants support padding the output. The pad character is configurable. Default is padding on, with character '='. Additionally, in some cases (e.g. MIME), splitting the output into lines of a specific length is required. This feature is also supported, though turned off by default. The z85 mode does neither padding nor line breaks; it is merely a wrapping of the corresponding libzmq methods. Encoding will assert if input length is not divisible by 4 and decoding will assert if input length is not divisible by 5. @end */ #include "czmq_classes.h" #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 3, 0)) # define _INCLUDE_Z85 #endif // Structure of our class struct _zarmour_t { int mode; // The current mode (Base64/32/16/Z85, STD/URL) bool pad; // Should output be padded? char pad_char; // The pad character bool line_breaks; // Should output be broken into lines? size_t line_length; // The line length to use char *line_end; }; // Textual names of modes static char *s_mode_names [] = { "base64", "base64url", "base32", "base32hex", "base16", "z85" }; // -------------------------------------------------------------------------- // Create a new zarmour zarmour_t * zarmour_new (void) { zarmour_t *self = (zarmour_t *) zmalloc (sizeof (zarmour_t)); assert (self); // Setup default as RFC4648 paragraph 4 self->mode = ZARMOUR_MODE_BASE64_STD; self->pad = true; self->pad_char = '='; self->line_breaks = false; self->line_length = 72; self->line_end = strdup ("\n"); assert (self->line_end); return self; } // -------------------------------------------------------------------------- // Destroy the zarmour void zarmour_destroy (zarmour_t **self_p) { assert (self_p); if (*self_p) { zarmour_t *self = *self_p; freen (self->line_end); freen (self); *self_p = NULL; } } // -------------------------------------------------------------------------- // Helper macros for encoding/decoding #define _NO_CONVERT(c) (c) #define _UPPER_CASE(c) ((c) & ((c) & 0x40? 0xdf: 0xff)) #define _NEXT_CHAR(i, n, c, a, u) \ while ((n) < (c) && !strchr ((a), (u (*(n))))) \ ++ (n); \ (i) = (byte) ((n) < (c)? (strchr ((a), (u (*(n)))) - (a)): 0xff); \ ++ (n) // RFC 4648 Paragraph 4 (standard base64 alphabet) static char // 0----5----0----5----0----5----0----5----0----5----0----5----0--- s_base64_alphabet [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; // RFC 4648 Paragraph 5 (URL & filename friendly base64 alphabet) static char // 0----5----0----5----0----5----0----5----0----5----0----5----0--- s_base64url_alphabet [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; static char * s_base64_encode (const byte *data, size_t length, const char *alphabet, bool pad, char pad_char) { size_t extra_chars = ((length % 3)? length % 3 + 1: 0); size_t pad_chars = (pad && extra_chars)? 4 - extra_chars: 0; size_t str_chars = 4 *(length / 3) + extra_chars + pad_chars; char *str = (char *) zmalloc (str_chars + 1); if (!str) return NULL; char *enc = str; const byte *needle = data, *ceiling = data + length; while (needle < ceiling) { *enc++ = alphabet [(*needle) >> 2]; if (needle + 1 < ceiling) { *enc++ = alphabet [((*needle << 4) & 0x30) | (*(needle + 1) >> 4)]; if (needle + 2 < ceiling) { *enc++ = alphabet [((*(needle + 1) << 2) & 0x3c) | (*(needle + 2) >> 6)]; *enc++ = alphabet [*(needle + 2) & 0x3f]; } else *enc++ = alphabet [(*(needle + 1) << 2) & 0x3c]; } else *enc++ = alphabet [(*needle << 4) & 0x30]; needle += 3; } while (pad && enc < str + str_chars) *enc++ = pad_char; *enc = 0; return str; } static byte * s_base64_decode (const char *data, size_t *size, const char *alphabet, size_t linebreakchars) { size_t length = strlen (data); while (length > 0 && !strchr (alphabet, data [length - 1])) --length; const byte *needle = (const byte *) data; const byte *ceiling = (const byte *) (data + length); length -= linebreakchars; *size = 3 * (length / 4) + ((length % 4)? length % 4 - 1 : 0) + 1; byte *bytes = (byte *) zmalloc (*size); if (!bytes) return NULL; byte *dec = bytes; byte i1, i2, i3, i4; while (needle < ceiling) { _NEXT_CHAR (i1, needle, ceiling, alphabet, _NO_CONVERT); _NEXT_CHAR (i2, needle, ceiling, alphabet, _NO_CONVERT); if (i1 != 0xff && i2 != 0xff) *dec++ = i1 << 2 | i2 >> 4; _NEXT_CHAR (i3, needle, ceiling, alphabet, _NO_CONVERT); if (i2 != 0xff && i3 != 0xff) *dec++ = i2 << 4 | i3 >> 2; _NEXT_CHAR (i4, needle, ceiling, alphabet, _NO_CONVERT); if (i3 != 0xff && i4 != 0xff) *dec++ = i3 << 6 | i4; } *dec = 0; return bytes; } // RFC 4648 Paragraph 6 (standard base32 alphabet) static char // 0----5----0----5----0----5----0- s_base32_alphabet [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; // RFC 4648 Paragraph 7 (base32hex alphabet) static char // 0----5----0----5----0----5----0- s_base32hex_alphabet [] = "0123456789ABCDEFGHIJKLMNOPQRSTUV"; static char * s_base32_encode (const byte *data, size_t length, const char *alphabet, bool pad, char pad_char) { size_t extra_bytes = length % 5, extra_chars = 0; switch (extra_bytes) { case 1: extra_chars = 2; break; case 2: extra_chars = 4; break; case 3: extra_chars = 5; break; case 4: extra_chars = 7; break; } size_t pad_chars = (pad && extra_chars)? 8 - extra_chars: 0; size_t str_chars = 8 *(length / 5) + extra_chars + pad_chars; char *str = (char *) zmalloc (str_chars + 1); if (!str) return NULL; char *enc = str; const byte *needle = data, *ceiling = data + length; while (needle < ceiling) { *enc++ = alphabet [(*needle) >> 3]; if (needle + 1 < ceiling) { *enc++ = alphabet [((*needle << 2) & 0x1c) | (*(needle + 1) >> 6)]; *enc++ = alphabet [(*(needle + 1) >> 1) & 0x1f]; if (needle + 2 < ceiling) { *enc++ = alphabet [((*(needle + 1) << 4) & 0x10) | (*(needle + 2) >> 4)]; if (needle + 3 < ceiling) { *enc++ = alphabet [((*(needle + 2) << 1) & 0x1e) | (*(needle + 3) >> 7)]; *enc++ = alphabet [(*(needle + 3) >> 2) & 0x1f]; if (needle + 4 < ceiling) { *enc++ = alphabet [((*(needle + 3) << 3) & 0x18) | (*(needle + 4) >> 5)]; *enc++ = alphabet [*(needle + 4) & 0x1f]; } else *enc++ = alphabet [(*(needle + 3) << 3) & 0x18]; } else *enc++ = alphabet [(*(needle + 2) << 1) & 0x1e]; } else *enc++ = alphabet [(*(needle + 1) << 4) & 0x10]; } else *enc++ = alphabet [(*needle << 2) & 0x1c]; needle += 5; } while (enc < str + str_chars) *enc++ = pad_char; *enc = 0; return str; } static byte * s_base32_decode (const char *data, size_t *size, const char *alphabet, size_t linebreakchars) { size_t length = strlen (data); while (length > 0 && !strchr (alphabet, _UPPER_CASE (data [length - 1]))) --length; const byte *needle = (const byte *) data, *ceiling = (const byte *) (data + length); length -= linebreakchars; size_t extra_chars = length % 8, extra_bytes = 0; switch (extra_chars) { case 0: break; case 2: extra_bytes = 1; break; case 4: extra_bytes = 2; break; case 5: extra_bytes = 3; break; case 7: extra_bytes = 4; break; default: assert (false); break; } *size = 5 *(length / 8) + extra_bytes + 1; byte *bytes = (byte *) zmalloc (*size); if (!bytes) return NULL; byte *dec = bytes; byte i1, i2, i3, i4, i5, i6, i7, i8; while (needle < ceiling) { _NEXT_CHAR (i1, needle, ceiling, alphabet, _UPPER_CASE); _NEXT_CHAR (i2, needle, ceiling, alphabet, _UPPER_CASE); if (i1 != 0xff && i2 != 0xff) *dec++ = i1 << 3 | i2 >> 2; _NEXT_CHAR (i3, needle, ceiling, alphabet, _UPPER_CASE); _NEXT_CHAR (i4, needle, ceiling, alphabet, _UPPER_CASE); if (i2 != 0xff && i3 != 0xff && i4 != 0xff) *dec++ = i2 << 6 | i3 << 1 | i4 >> 4; _NEXT_CHAR (i5, needle, ceiling, alphabet, _UPPER_CASE); if (i4 != 0xff && i5 != 0xff) *dec++ = i4 << 4 | i5 >> 1; _NEXT_CHAR (i6, needle, ceiling, alphabet, _UPPER_CASE); _NEXT_CHAR (i7, needle, ceiling, alphabet, _UPPER_CASE); if (i5 != 0xff && i6 != 0xff && i7 != 0xff) *dec++ = i5 << 7 | i6 << 2 | i7 >> 3; _NEXT_CHAR (i8, needle, ceiling, alphabet, _UPPER_CASE); if (i7 != 0xff && i8 != 0xff) *dec++ = i7 << 5 | i8; } *dec = 0; return bytes; } // RFC 4648 Paragraph 8 (standard base16 alphabet) static char // 0----5----0----5 s_base16_alphabet [] = "0123456789ABCDEF"; static char * s_base16_encode (const byte *data, size_t length, const char *alphabet) { char *str = (char *) zmalloc (2 * length + 1); if (!str) return NULL; char *enc = str; const byte *needle = data, *ceiling = data + length; while (needle < ceiling) { *enc++ = alphabet [(*needle) >> 4]; *enc++ = alphabet [(*needle++) & 0x0f]; } *enc = 0; return str; } static byte * s_base16_decode (const char *data, size_t *size, const char *alphabet, size_t linebreakchars) { size_t length = strlen (data); const byte *needle = (const byte *) data, *ceiling = (const byte *) (data + length); length -= linebreakchars; *size = length / 2 + 1; byte *bytes = (byte *) zmalloc (*size); if (!bytes) return NULL; byte *dec = bytes; byte i1, i2; while (needle < ceiling) { _NEXT_CHAR (i1, needle, ceiling, alphabet, _UPPER_CASE); _NEXT_CHAR (i2, needle, ceiling, alphabet, _UPPER_CASE); if (i1 != 0xff && i2 != 0xff) *dec++ = i1 << 4 | i2; } *dec = 0; return bytes; } // Z85 encoding/decoding static char * s_z85_encode (const byte *data, size_t length) { assert (data != NULL); assert (length % 4 == 0); #ifdef _INCLUDE_Z85 char *str = (char *) zmalloc (5 * length / 4 + 1); char *result = zmq_z85_encode (str, (uint8_t *) data, length); if (result == NULL) { freen (str); str = NULL; } return str; #else return NULL; #endif } static byte * s_z85_decode (const char *data, size_t *size) { assert (data); assert (size); #ifdef _INCLUDE_Z85 size_t length = strlen (data); assert (length % 5 == 0); *size = 4 * length / 5 + 1; byte *bytes = (byte *) zmalloc (*size); uint8_t *result = zmq_z85_decode (bytes, (char *) data); if (result == NULL) { freen (bytes); bytes = NULL; } return bytes; #else return NULL; #endif } // -------------------------------------------------------------------------- // Decode an armoured string into a string of bytes. // The decoded output is null-terminated, so it may be treated // as a string, if that's what it was prior to encoding. // The caller is responsible for destroying the return value when finished with it. char * zarmour_encode (zarmour_t *self, const byte *data, size_t data_size) { assert (self); assert (data); char *encoded = NULL; switch (self->mode) { case ZARMOUR_MODE_BASE64_STD: encoded = s_base64_encode (data, data_size, s_base64_alphabet, self->pad, self->pad_char); break; case ZARMOUR_MODE_BASE64_URL: encoded = s_base64_encode (data, data_size, s_base64url_alphabet, self->pad, self->pad_char); break; case ZARMOUR_MODE_BASE32_STD: encoded = s_base32_encode (data, data_size, s_base32_alphabet, self->pad, self->pad_char); break; case ZARMOUR_MODE_BASE32_HEX: encoded = s_base32_encode (data, data_size, s_base32hex_alphabet, self->pad, self->pad_char); break; case ZARMOUR_MODE_BASE16: encoded = s_base16_encode (data, data_size, s_base16_alphabet); break; case ZARMOUR_MODE_Z85: encoded = s_z85_encode (data, data_size); break; } if (!encoded) return NULL; if (self->line_breaks && self->line_length > 0 && strlen (encoded) > self->line_length && self->mode != ZARMOUR_MODE_Z85) { char *line_end = self->line_end; size_t nbr_lines = strlen (encoded) / self->line_length; size_t new_length = nbr_lines *(self->line_length + strlen (line_end)) + strlen (encoded) % self->line_length; char *src = encoded; char *temp = encoded; encoded = (char *) zmalloc (new_length + 1); char *dest = encoded; while (strlen (src) >= self->line_length) { memcpy (dest, src, self->line_length); src += self->line_length; dest += self->line_length; if (*src) { memcpy (dest, line_end, strlen (line_end)); dest += strlen (line_end); } } if (*src) { memcpy (dest, src, strlen (src)); dest += strlen (src); } freen (temp); *dest = 0; } return encoded; } // -------------------------------------------------------------------------- // Decode an armoured string into a chunk. The decoded output is // null-terminated, so it may be treated as a string, if that's what // it was prior to encoding. // Caller owns return value and must destroy it when done. zchunk_t * zarmour_decode (zarmour_t *self, const char *data) { assert (self); assert (data); size_t linebreakchars = 0; char *line_end = self->line_end; const char *pos = data; while ((pos = strstr (pos, line_end))) { linebreakchars += strlen (line_end); pos += strlen (line_end); } byte *decoded = NULL; size_t size = 0; switch (self->mode) { case ZARMOUR_MODE_BASE64_STD: decoded = s_base64_decode (data, &size, s_base64_alphabet, linebreakchars); break; case ZARMOUR_MODE_BASE64_URL: decoded = s_base64_decode (data, &size, s_base64url_alphabet, linebreakchars); break; case ZARMOUR_MODE_BASE32_STD: decoded = s_base32_decode (data, &size, s_base32_alphabet, linebreakchars); break; case ZARMOUR_MODE_BASE32_HEX: decoded = s_base32_decode (data, &size, s_base32hex_alphabet, linebreakchars); break; case ZARMOUR_MODE_BASE16: decoded = s_base16_decode (data, &size, s_base16_alphabet, linebreakchars); break; case ZARMOUR_MODE_Z85: decoded = s_z85_decode (data, &size); break; } zchunk_t *ret = zchunk_new (decoded, size); freen (decoded); return ret; } // -------------------------------------------------------------------------- // Get the mode property. int zarmour_mode (zarmour_t *self) { assert (self); return self->mode; } // -------------------------------------------------------------------------- // Get printable string for mode. const char * zarmour_mode_str (zarmour_t *self) { assert (self); return s_mode_names [(int) self->mode]; } // -------------------------------------------------------------------------- // Set the mode property. void zarmour_set_mode (zarmour_t *self, int mode) { assert (self); self->mode = mode; } // -------------------------------------------------------------------------- // Return true if padding is turned on. bool zarmour_pad (zarmour_t *self) { assert (self); return self->pad; } // -------------------------------------------------------------------------- // Turn padding on or off. Default is on. void zarmour_set_pad (zarmour_t *self, bool pad) { assert (self); self->pad = pad; } // -------------------------------------------------------------------------- // Get the padding character. char zarmour_pad_char (zarmour_t *self) { assert (self); return self->pad_char; } // -------------------------------------------------------------------------- // Set the padding character. void zarmour_set_pad_char (zarmour_t *self, char pad_char) { assert (self); self->pad_char = pad_char; } // -------------------------------------------------------------------------- // Return if splitting output into lines is turned on. Default is off. bool zarmour_line_breaks (zarmour_t *self) { assert (self); return self->line_breaks; } // -------------------------------------------------------------------------- // Turn splitting output into lines on or off. void zarmour_set_line_breaks (zarmour_t *self, bool line_breaks) { assert (self); self->line_breaks = line_breaks; } // -------------------------------------------------------------------------- // Get the line length used for splitting lines. size_t zarmour_line_length (zarmour_t *self) { assert (self); return self->line_length; } // -------------------------------------------------------------------------- // Set the line length used for splitting lines. void zarmour_set_line_length (zarmour_t *self, size_t line_length) { assert (self); self->line_length = line_length; } // -------------------------------------------------------------------------- // Print properties of object void zarmour_print (zarmour_t *self) { assert (self); zsys_debug ("zarmour:"); zsys_debug (" mode: %s", zarmour_mode_str (self)); zsys_debug (" pad: %s", self->pad? "true": "false"); zsys_debug (" pad_char: '%c'", self->pad_char); zsys_debug (" line_breaks: %s", self->line_breaks? "true": "false"); zsys_debug (" line_length: %d", self->line_length); } // --------------------------------------------------------------------------- // Self test support functions static void s_armour_decode (zarmour_t *self, const char *test_string, const char *expected, bool verbose) { assert (self); assert (test_string); assert (expected); zchunk_t *chunk = zarmour_decode (self, test_string); assert (chunk); if (verbose) zsys_debug (" decoded '%s' into '%s'", test_string, (char *) zchunk_data (chunk)); assert (zchunk_size (chunk) == strlen (expected) + 1); assert (streq ((char *) zchunk_data (chunk), expected)); zchunk_destroy (&chunk); } static void s_armour_test (zarmour_t *self, const char *test_string, const char *expected, bool verbose) { assert (self); assert (test_string); assert (expected); char *encoded = zarmour_encode (self, (byte *) test_string, strlen (test_string)); assert (encoded); if (verbose) zsys_debug (" encoded '%s' into '%s' ('%s')", test_string, encoded, expected); assert (strlen (encoded) == strlen (expected)); assert (streq (encoded, expected)); s_armour_decode (self, encoded, test_string, verbose); freen (encoded); } static void s_armour_test_long (zarmour_t *self, byte *test_data, size_t length, bool verbose) { if (verbose) zarmour_print (self); char *test_string = zarmour_encode (self, test_data, length); assert (test_string); if (verbose) zsys_debug (" encoded %d bytes array to:\n%s", length, test_string); zchunk_t *chunk = zarmour_decode (self, test_string); assert (chunk); assert (zchunk_size (chunk) == length + 1); uint index; for (index = 0; index < length; index++) assert (zchunk_data (chunk)[index] == index); zchunk_destroy (&chunk); if (verbose) zsys_debug (" decoded %d bytes, all match", length); freen (test_string); } // -------------------------------------------------------------------------- // Selftest void zarmour_test (bool verbose) { printf (" * zarmour: "); if (verbose) printf ("\n"); // @selftest zarmour_t *self = zarmour_new (); assert (self); int mode = zarmour_mode (self); assert (mode == ZARMOUR_MODE_BASE64_STD); zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL); mode = zarmour_mode (self); assert (mode == ZARMOUR_MODE_BASE64_URL); assert (zarmour_pad (self)); zarmour_set_pad (self, false); assert (!zarmour_pad (self)); assert (zarmour_pad_char (self) == '='); zarmour_set_pad_char (self, '!'); assert (zarmour_pad_char (self) == '!'); zarmour_set_pad_char (self, '='); assert (zarmour_pad_char (self) == '='); assert (!zarmour_line_breaks (self)); zarmour_set_line_breaks (self, true); assert (zarmour_line_breaks (self)); assert (zarmour_line_length (self) == 72); zarmour_set_line_length (self, 64); assert (zarmour_line_length (self) == 64); // Test against test vectors from RFC4648. zarmour_set_mode (self, ZARMOUR_MODE_BASE64_STD); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg", verbose); s_armour_test (self, "fo", "Zm8", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg", verbose); s_armour_test (self, "fooba", "Zm9vYmE", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg==", verbose); s_armour_test (self, "fo", "Zm8=", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg==", verbose); s_armour_test (self, "fooba", "Zm9vYmE=", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, false); zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg", verbose); s_armour_test (self, "fo", "Zm8", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg", verbose); s_armour_test (self, "fooba", "Zm9vYmE", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "Zg==", verbose); s_armour_test (self, "fo", "Zm8=", verbose); s_armour_test (self, "foo", "Zm9v", verbose); s_armour_test (self, "foob", "Zm9vYg==", verbose); s_armour_test (self, "fooba", "Zm9vYmE=", verbose); s_armour_test (self, "foobar", "Zm9vYmFy", verbose); zarmour_set_pad (self, false); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_STD); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "MY", verbose); s_armour_test (self, "fo", "MZXQ", verbose); s_armour_test (self, "foo", "MZXW6", verbose); s_armour_test (self, "foob", "MZXW6YQ", verbose); s_armour_test (self, "fooba", "MZXW6YTB", verbose); s_armour_test (self, "foobar", "MZXW6YTBOI", verbose); s_armour_decode (self, "my", "f", verbose); s_armour_decode (self, "mzxq", "fo", verbose); s_armour_decode (self, "mzxw6", "foo", verbose); s_armour_decode (self, "mzxw6yq", "foob", verbose); s_armour_decode (self, "mzxw6ytb", "fooba", verbose); s_armour_decode (self, "mzxw6ytboi", "foobar", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "MY======", verbose); s_armour_test (self, "fo", "MZXQ====", verbose); s_armour_test (self, "foo", "MZXW6===", verbose); s_armour_test (self, "foob", "MZXW6YQ=", verbose); s_armour_test (self, "fooba", "MZXW6YTB", verbose); s_armour_test (self, "foobar", "MZXW6YTBOI======", verbose); s_armour_decode (self, "my======", "f", verbose); s_armour_decode (self, "mzxq====", "fo", verbose); s_armour_decode (self, "mzxw6===", "foo", verbose); s_armour_decode (self, "mzxw6yq=", "foob", verbose); s_armour_decode (self, "mzxw6ytb", "fooba", verbose); s_armour_decode (self, "mzxw6ytboi======", "foobar", verbose); zarmour_set_pad (self, false); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_HEX); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "CO", verbose); s_armour_test (self, "fo", "CPNG", verbose); s_armour_test (self, "foo", "CPNMU", verbose); s_armour_test (self, "foob", "CPNMUOG", verbose); s_armour_test (self, "fooba", "CPNMUOJ1", verbose); s_armour_test (self, "foobar", "CPNMUOJ1E8", verbose); s_armour_decode (self, "co", "f", verbose); s_armour_decode (self, "cpng", "fo", verbose); s_armour_decode (self, "cpnmu", "foo", verbose); s_armour_decode (self, "cpnmuog", "foob", verbose); s_armour_decode (self, "cpnmuoj1", "fooba", verbose); s_armour_decode (self, "cpnmuoj1e8", "foobar", verbose); zarmour_set_pad (self, true); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "CO======", verbose); s_armour_test (self, "fo", "CPNG====", verbose); s_armour_test (self, "foo", "CPNMU===", verbose); s_armour_test (self, "foob", "CPNMUOG=", verbose); s_armour_test (self, "fooba", "CPNMUOJ1", verbose); s_armour_test (self, "foobar", "CPNMUOJ1E8======", verbose); s_armour_decode (self, "co======", "f", verbose); s_armour_decode (self, "cpng====", "fo", verbose); s_armour_decode (self, "cpnmu===", "foo", verbose); s_armour_decode (self, "cpnmuog=", "foob", verbose); s_armour_decode (self, "cpnmuoj1", "fooba", verbose); s_armour_decode (self, "cpnmuoj1e8======", "foobar", verbose); zarmour_set_pad (self, true); zarmour_set_mode (self, ZARMOUR_MODE_BASE16); if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "f", "66", verbose); s_armour_test (self, "fo", "666F", verbose); s_armour_test (self, "foo", "666F6F", verbose); s_armour_test (self, "foob", "666F6F62", verbose); s_armour_test (self, "fooba", "666F6F6261", verbose); s_armour_test (self, "foobar", "666F6F626172", verbose); s_armour_decode (self, "666f", "fo", verbose); s_armour_decode (self, "666f6f", "foo", verbose); s_armour_decode (self, "666f6f62", "foob", verbose); s_armour_decode (self, "666f6f6261", "fooba", verbose); s_armour_decode (self, "666f6f626172", "foobar", verbose); #ifdef _INCLUDE_Z85 // Z85 test is homemade; using 0, 4 and 8 bytes, with precalculated // test vectors created with a libzmq test. // ---------------------------------------------------------------- // Make a fake curve key from hex (base16) string, making sure // there are no null bytes inside, so we can use our test utility zarmour_set_mode (self, ZARMOUR_MODE_BASE16); zarmour_set_line_breaks (self, false); zchunk_t *chunk = zarmour_decode (self, "4E6F87E2FB6EB22A1EF5E257B75D79124949565F0B8B36A878A4F03111C96E0B"); assert (chunk); zarmour_set_mode (self, ZARMOUR_MODE_Z85); // Z85 mode does not support padding or line breaks zarmour_set_pad (self, false); // so these two are superfluous; zarmour_set_line_breaks (self, false); // just for consistency if (verbose) zarmour_print (self); s_armour_test (self, "", "", verbose); s_armour_test (self, "foob", "w]zP%", verbose); s_armour_test (self, "foobar!!", "w]zP%vr9Im", verbose); s_armour_test (self, (char *) zchunk_data (chunk), "ph+{E}!&X?9}!I]W{sm(nL8@&3Yu{wC+<*-5Y[[#", verbose); zchunk_destroy (&chunk); #endif // Armouring longer byte array to test line breaks zarmour_set_pad (self, true); zarmour_set_line_breaks (self, true); byte test_data [256]; int index; for (index = 0; index < 256; index++) test_data [index] = index; zarmour_set_mode (self, ZARMOUR_MODE_BASE64_STD); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE64_URL); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_STD); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE32_HEX); s_armour_test_long (self, test_data, 256, verbose); zarmour_set_mode (self, ZARMOUR_MODE_BASE16); s_armour_test_long (self, test_data, 256, verbose); #ifdef _INCLUDE_Z85 zarmour_set_mode (self, ZARMOUR_MODE_Z85); s_armour_test_long (self, test_data, 256, verbose); #endif zarmour_destroy (&self); #if defined (__WINDOWS__) zsys_shutdown(); #endif // @end printf ("OK\n"); }