diff -Nru czmq-4.1.0/api/python_cffi.slurp czmq-4.1.1/api/python_cffi.slurp --- czmq-4.1.0/api/python_cffi.slurp 1970-01-01 00:00:00.000000000 +0000 +++ czmq-4.1.1/api/python_cffi.slurp 2018-03-22 22:18:37.000000000 +0000 @@ -0,0 +1,4006 @@ +################################################################################ +# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # +# Read the zproject/README.md for information about making permanent changes. # +################################################################################ +# Python cffi compatible file slurp + +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, "$KTHXBAI") == 0) +// zsock_wait (self); +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); + +// Return command line arguments (the first item is the executable) or +// NULL if not set. +zlist_t * + zproc_args (zproc_t *self); + +// Setup the command line arguments, the first item must be an (absolute) filename +// to run. +void + zproc_set_args (zproc_t *self, zlist_t **arguments); + +// Setup the command line arguments, the first item must be an (absolute) filename +// to run. Variadic function, must be NULL terminated. +void + zproc_set_argsx (zproc_t *self, const char *arguments, ...); + +// Setup the environment variables for the process. +void + zproc_set_env (zproc_t *self, zhash_t **arguments); + +// 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, return just before execve/CreateProcess. +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); + +// 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); + +// Check if default interrupt handler of Ctrl-C or SIGTERM was called. +// Does not work if ZSYS_SIGHANDLER is false and code does not call +// set interrupted on signal. +bool + zsys_is_interrupted (void); + +// Set interrupted flag. This is done by default signal handler, however +// this can be handy for language bindings or cases without default +// signal handler. +void + zsys_set_interrupted (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 whether to use zero copy strategy in libzmq. If the environment +// variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. +// Otherwise the default is 1. +void + zsys_set_zero_copy_recv (int zero_copy); + +// Return ZMQ_ZERO_COPY_RECV option. +int + zsys_zero_copy_recv (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); + +''') diff -Nru czmq-4.1.0/api/zactor.api czmq-4.1.1/api/zactor.api --- czmq-4.1.0/api/zactor.api 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/api/zactor.api 2018-03-22 22:18:37.000000000 +0000 @@ -21,8 +21,8 @@ An example - to send $KTHXBAI string - if (zstr_send (self->pipe, "$KTHXBAI") == 0) - zsock_wait (self->pipe); + if (zstr_send (self, "$KTHXBAI") == 0) + zsock_wait (self); diff -Nru czmq-4.1.0/api/zproc.api czmq-4.1.1/api/zproc.api --- czmq-4.1.0/api/zproc.api 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/api/zproc.api 2018-03-22 22:18:37.000000000 +0000 @@ -20,15 +20,27 @@ Destroy zproc, wait until process ends. + + Return command line arguments (the first item is the executable) or + NULL if not set. + + + Setup the command line arguments, the first item must be an (absolute) filename to run. - + + + + + Setup the command line arguments, the first item must be an (absolute) filename + to run. Variadic function, must be NULL terminated. + Setup the environment variables for the process. - + @@ -71,7 +83,7 @@ - Starts the process. + Starts the process, return just before execve/CreateProcess. @@ -111,137 +123,4 @@ - - - - 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 - - diff -Nru czmq-4.1.0/api/zsys.api czmq-4.1.1/api/zsys.api --- czmq-4.1.0/api/zsys.api 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/api/zsys.api 2018-03-22 22:18:37.000000000 +0000 @@ -86,6 +86,19 @@ *** This is for CZMQ internal use only and may change arbitrarily *** + + Check if default interrupt handler of Ctrl-C or SIGTERM was called. + Does not work if ZSYS_SIGHANDLER is false and code does not call + set interrupted on signal. + + + + + Set interrupted flag. This is done by default signal handler, however + this can be handy for language bindings or cases without default + signal handler. + + Return 1 if file exists, else zero @@ -303,6 +316,18 @@ + + Configure whether to use zero copy strategy in libzmq. If the environment + variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. + Otherwise the default is 1. + + + + + Return ZMQ_ZERO_COPY_RECV option. + + + Configure the threshold value of filesystem object age per st_mtime that should elapse until we consider that object "stable" at the diff -Nru czmq-4.1.0/bindings/jni/android/build.sh czmq-4.1.1/bindings/jni/android/build.sh --- czmq-4.1.0/bindings/jni/android/build.sh 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/jni/android/build.sh 2018-03-22 22:18:37.000000000 +0000 @@ -52,7 +52,7 @@ echo "******** Building czmq.jar for Android" # Copy class files into org/zeromq/etc. -unzip -q ../../build/libs/czmq-jni-4.1.0.jar +unzip -q ../../build/libs/czmq-jni-4.1.1.jar # Copy native libraries into lib/armeabi mkdir -p lib/armeabi diff -Nru czmq-4.1.0/bindings/jni/build.gradle czmq-4.1.1/bindings/jni/build.gradle --- czmq-4.1.0/bindings/jni/build.gradle 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/jni/build.gradle 2018-03-22 22:18:37.000000000 +0000 @@ -12,7 +12,7 @@ } group = "org.zeromq" -version = "4.1.0" +version = "4.1.1" repositories { mavenLocal() @@ -136,8 +136,8 @@ vcsUrl = 'https://github.com/zeromq/czmq.git' githubRepo = System.getenv('BINTRAY_USER_ORG') + '/czmq' version { - name = '4.1.0' - vcsTag= '4.1.0' + name = '4.1.1' + vcsTag= '4.1.1' } } } diff -Nru czmq-4.1.0/bindings/jni/msvc/resource.rc czmq-4.1.1/bindings/jni/msvc/resource.rc --- czmq-4.1.0/bindings/jni/msvc/resource.rc 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/jni/msvc/resource.rc 2018-03-22 22:18:37.000000000 +0000 @@ -49,8 +49,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,1,0,0 - PRODUCTVERSION 4,1,0,0 + FILEVERSION 4,1,1,0 + PRODUCTVERSION 4,1,1,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -67,12 +67,12 @@ BEGIN VALUE "CompanyName", "The AUTHORS" VALUE "FileDescription", "The high-level C binding for 0MQ" - VALUE "FileVersion", "4.1.0.0" + VALUE "FileVersion", "4.1.1.0" VALUE "InternalName", "CZMQ" VALUE "LegalCopyright", "Copyright (c) the Authors" VALUE "OriginalFilename", "libczmq.dll" VALUE "ProductName", "CZMQ" - VALUE "ProductVersion", "4.1.0.0" + VALUE "ProductVersion", "4.1.1.0" END END BLOCK "VarFileInfo" diff -Nru czmq-4.1.0/bindings/jni/README.md czmq-4.1.1/bindings/jni/README.md --- czmq-4.1.0/bindings/jni/README.md 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/jni/README.md 2018-03-22 22:18:37.000000000 +0000 @@ -49,7 +49,7 @@ 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 Java classes into a jar file czmq-jni-4.1.1.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. diff -Nru czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zproc.c czmq-4.1.1/bindings/jni/src/main/c/org_zeromq_czmq_Zproc.c --- czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zproc.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/jni/src/main/c/org_zeromq_czmq_Zproc.c 2018-03-22 22:18:37.000000000 +0000 @@ -25,16 +25,31 @@ zproc_destroy ((zproc_t **) &self); } +JNIEXPORT jlong JNICALL +Java_org_zeromq_czmq_Zproc__1_1args (JNIEnv *env, jclass c, jlong self) +{ + jlong args_ = (jlong) (intptr_t) zproc_args ((zproc_t *) (intptr_t) self); + return args_; +} + +JNIEXPORT void JNICALL +Java_org_zeromq_czmq_Zproc__1_1setArgs (JNIEnv *env, jclass c, jlong self, jlong arguments) +{ + zproc_set_args ((zproc_t *) (intptr_t) self, (zlist_t **) (intptr_t) &arguments); +} + JNIEXPORT void JNICALL -Java_org_zeromq_czmq_Zproc__1_1setArgs (JNIEnv *env, jclass c, jlong self, jlong args) +Java_org_zeromq_czmq_Zproc__1_1setArgsx (JNIEnv *env, jclass c, jlong self, jstring arguments) { - zproc_set_args ((zproc_t *) (intptr_t) self, (zlistx_t *) (intptr_t) args); + char *arguments_ = (char *) (*env)->GetStringUTFChars (env, arguments, NULL); + zproc_set_argsx ((zproc_t *) (intptr_t) self, arguments_); + (*env)->ReleaseStringUTFChars (env, arguments, arguments_); } JNIEXPORT void JNICALL -Java_org_zeromq_czmq_Zproc__1_1setEnv (JNIEnv *env, jclass c, jlong self, jlong args) +Java_org_zeromq_czmq_Zproc__1_1setEnv (JNIEnv *env, jclass c, jlong self, jlong arguments) { - zproc_set_env ((zproc_t *) (intptr_t) self, (zhashx_t *) (intptr_t) args); + zproc_set_env ((zproc_t *) (intptr_t) self, (zhash_t **) (intptr_t) &arguments); } JNIEXPORT void JNICALL @@ -130,146 +145,6 @@ 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) { diff -Nru czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zsys.c czmq-4.1.1/bindings/jni/src/main/c/org_zeromq_czmq_Zsys.c --- czmq-4.1.0/bindings/jni/src/main/c/org_zeromq_czmq_Zsys.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/jni/src/main/c/org_zeromq_czmq_Zsys.c 2018-03-22 22:18:37.000000000 +0000 @@ -69,6 +69,19 @@ } JNIEXPORT jboolean JNICALL +Java_org_zeromq_czmq_Zsys__1_1isInterrupted (JNIEnv *env, jclass c) +{ + jboolean is_interrupted_ = (jboolean) zsys_is_interrupted (); + return is_interrupted_; +} + +JNIEXPORT void JNICALL +Java_org_zeromq_czmq_Zsys__1_1setInterrupted (JNIEnv *env, jclass c) +{ + zsys_set_interrupted (); +} + +JNIEXPORT jboolean JNICALL Java_org_zeromq_czmq_Zsys__1_1fileExists (JNIEnv *env, jclass c, jstring filename) { char *filename_ = (char *) (*env)->GetStringUTFChars (env, filename, NULL); @@ -258,6 +271,19 @@ } JNIEXPORT void JNICALL +Java_org_zeromq_czmq_Zsys__1_1setZeroCopyRecv (JNIEnv *env, jclass c, jint zero_copy) +{ + zsys_set_zero_copy_recv ((int) zero_copy); +} + +JNIEXPORT jint JNICALL +Java_org_zeromq_czmq_Zsys__1_1zeroCopyRecv (JNIEnv *env, jclass c) +{ + jint zero_copy_recv_ = (jint) zsys_zero_copy_recv (); + return zero_copy_recv_; +} + +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); diff -Nru czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zproc.java czmq-4.1.1/bindings/jni/src/main/java/org/zeromq/czmq/Zproc.java --- czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zproc.java 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/jni/src/main/java/org/zeromq/czmq/Zproc.java 2018-03-22 22:18:37.000000000 +0000 @@ -39,19 +39,35 @@ self = 0; } /* + Return command line arguments (the first item is the executable) or + NULL if not set. + */ + native static long __args (long self); + public Zlist args () { + return new Zlist (__args (self)); + } + /* 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); + native static void __setArgs (long self, long arguments); + public void setArgs (Zlist arguments) { + __setArgs (self, arguments.self); + } + /* + Setup the command line arguments, the first item must be an (absolute) filename + to run. Variadic function, must be NULL terminated. + */ + native static void __setArgsx (long self, String arguments); + public void setArgsx (String arguments []) { + __setArgsx (self, arguments [0]); } /* Setup the environment variables for the process. */ - native static void __setEnv (long self, long args); - public void setEnv (Zhashx args) { - __setEnv (self, args.self); + native static void __setEnv (long self, long arguments); + public void setEnv (Zhash arguments) { + __setEnv (self, arguments.self); } /* Connects process stdin with a readable ('>', connect) zeromq socket. If @@ -105,7 +121,7 @@ return __stderr (self); } /* - Starts the process. + Starts the process, return just before execve/CreateProcess. */ native static int __run (long self); public int run () { @@ -161,167 +177,6 @@ __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); diff -Nru czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zsys.java czmq-4.1.1/bindings/jni/src/main/java/org/zeromq/czmq/Zsys.java --- czmq-4.1.0/bindings/jni/src/main/java/org/zeromq/czmq/Zsys.java 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/jni/src/main/java/org/zeromq/czmq/Zsys.java 2018-03-22 22:18:37.000000000 +0000 @@ -92,6 +92,24 @@ __catchInterrupts (); } /* + Check if default interrupt handler of Ctrl-C or SIGTERM was called. + Does not work if ZSYS_SIGHANDLER is false and code does not call + set interrupted on signal. + */ + native static boolean __isInterrupted (); + public boolean isInterrupted () { + return __isInterrupted (); + } + /* + Set interrupted flag. This is done by default signal handler, however + this can be handy for language bindings or cases without default + signal handler. + */ + native static void __setInterrupted (); + public void setInterrupted () { + __setInterrupted (); + } + /* Return 1 if file exists, else zero */ native static boolean __fileExists (String filename); @@ -297,6 +315,22 @@ return __maxMsgsz (); } /* + Configure whether to use zero copy strategy in libzmq. If the environment + variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. + Otherwise the default is 1. + */ + native static void __setZeroCopyRecv (int zeroCopy); + public void setZeroCopyRecv (int zeroCopy) { + __setZeroCopyRecv (zeroCopy); + } + /* + Return ZMQ_ZERO_COPY_RECV option. + */ + native static int __zeroCopyRecv (); + public int zeroCopyRecv () { + return __zeroCopyRecv (); + } + /* 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. diff -Nru czmq-4.1.0/bindings/lua_ffi/czmq_ffi.lua czmq-4.1.1/bindings/lua_ffi/czmq_ffi.lua --- czmq-4.1.0/bindings/lua_ffi/czmq_ffi.lua 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/lua_ffi/czmq_ffi.lua 2018-03-22 22:18:37.000000000 +0000 @@ -61,8 +61,8 @@ // // An example - to send $KTHXBAI string // -// if (zstr_send (self->pipe, "$KTHXBAI") == 0) -// zsock_wait (self->pipe); +// if (zstr_send (self, "$KTHXBAI") == 0) +// zsock_wait (self); typedef void (zactor_destructor_fn) ( zactor_t *self); @@ -2251,14 +2251,24 @@ void zproc_destroy (zproc_t **self_p); +// Return command line arguments (the first item is the executable) or +// NULL if not set. +zlist_t * + zproc_args (zproc_t *self); + // 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); + zproc_set_args (zproc_t *self, zlist_t **arguments); + +// Setup the command line arguments, the first item must be an (absolute) filename +// to run. Variadic function, must be NULL terminated. +void + zproc_set_argsx (zproc_t *self, const char *arguments, ...); // Setup the environment variables for the process. void - zproc_set_env (zproc_t *self, zhashx_t *args); + zproc_set_env (zproc_t *self, zhash_t **arguments); // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc @@ -2293,7 +2303,7 @@ void * zproc_stderr (zproc_t *self); -// Starts the process. +// Starts the process, return just before execve/CreateProcess. int zproc_run (zproc_t *self); @@ -2325,113 +2335,6 @@ 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); @@ -3588,6 +3491,18 @@ void zsys_catch_interrupts (void); +// Check if default interrupt handler of Ctrl-C or SIGTERM was called. +// Does not work if ZSYS_SIGHANDLER is false and code does not call +// set interrupted on signal. +bool + zsys_is_interrupted (void); + +// Set interrupted flag. This is done by default signal handler, however +// this can be handy for language bindings or cases without default +// signal handler. +void + zsys_set_interrupted (void); + // Return 1 if file exists, else zero bool zsys_file_exists (const char *filename); @@ -3752,6 +3667,16 @@ int zsys_max_msgsz (void); +// Configure whether to use zero copy strategy in libzmq. If the environment +// variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. +// Otherwise the default is 1. +void + zsys_set_zero_copy_recv (int zero_copy); + +// Return ZMQ_ZERO_COPY_RECV option. +int + zsys_zero_copy_recv (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. diff -Nru czmq-4.1.0/bindings/nodejs/binding.cc czmq-4.1.1/bindings/nodejs/binding.cc --- czmq-4.1.0/bindings/nodejs/binding.cc 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/nodejs/binding.cc 2018-03-22 22:18:37.000000000 +0000 @@ -4213,7 +4213,9 @@ // Prototypes Nan::SetPrototypeMethod (tpl, "destroy", destroy); Nan::SetPrototypeMethod (tpl, "defined", defined); + Nan::SetPrototypeMethod (tpl, "args", _args); Nan::SetPrototypeMethod (tpl, "setArgs", _set_args); + Nan::SetPrototypeMethod (tpl, "setArgsx", _set_argsx); Nan::SetPrototypeMethod (tpl, "setEnv", _set_env); Nan::SetPrototypeMethod (tpl, "run", _run); Nan::SetPrototypeMethod (tpl, "returncode", _returncode); @@ -4222,24 +4224,6 @@ 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 ()); @@ -4278,16 +4262,43 @@ info.GetReturnValue ().Set (Nan::New (zproc->self != NULL)); } +NAN_METHOD (Zproc::_args) { + Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); + zlist_t *result = zproc_args (zproc->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 (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); + Zlist *arguments = Nan::ObjectWrap::Unwrap(info [0].As()); + zproc_set_args (zproc->self, &arguments->self); +} + +NAN_METHOD (Zproc::_set_argsx) { + Zproc *zproc = Nan::ObjectWrap::Unwrap (info.Holder ()); + char *arguments; + if (info [0]->IsUndefined ()) + return Nan::ThrowTypeError ("method requires a `arguments`"); + else + if (!info [0]->IsString ()) + return Nan::ThrowTypeError ("`arguments` must be a string"); + //else { // bjornw: remove brackets to keep scope + Nan::Utf8String arguments_utf8 (info [0].As()); + arguments = *arguments_utf8; + //} //bjornw end + zproc_set_argsx (zproc->self, (const char *)arguments); } 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); + Zhash *arguments = Nan::ObjectWrap::Unwrap(info [0].As()); + zproc_set_env (zproc->self, &arguments->self); } NAN_METHOD (Zproc::_run) { @@ -4369,228 +4380,6 @@ 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`"); @@ -7051,6 +6840,8 @@ Nan::SetPrototypeMethod (tpl, "createPipe", _create_pipe); Nan::SetPrototypeMethod (tpl, "handlerReset", _handler_reset); Nan::SetPrototypeMethod (tpl, "catchInterrupts", _catch_interrupts); + Nan::SetPrototypeMethod (tpl, "isInterrupted", _is_interrupted); + Nan::SetPrototypeMethod (tpl, "setInterrupted", _set_interrupted); Nan::SetPrototypeMethod (tpl, "fileExists", _file_exists); Nan::SetPrototypeMethod (tpl, "fileModified", _file_modified); Nan::SetPrototypeMethod (tpl, "fileMode", _file_mode); @@ -7075,6 +6866,8 @@ Nan::SetPrototypeMethod (tpl, "socketLimit", _socket_limit); Nan::SetPrototypeMethod (tpl, "setMaxMsgsz", _set_max_msgsz); Nan::SetPrototypeMethod (tpl, "maxMsgsz", _max_msgsz); + Nan::SetPrototypeMethod (tpl, "setZeroCopyRecv", _set_zero_copy_recv); + Nan::SetPrototypeMethod (tpl, "zeroCopyRecv", _zero_copy_recv); Nan::SetPrototypeMethod (tpl, "setFileStableAgeMsec", _set_file_stable_age_msec); Nan::SetPrototypeMethod (tpl, "fileStableAgeMsec", _file_stable_age_msec); Nan::SetPrototypeMethod (tpl, "setLinger", _set_linger); @@ -7164,6 +6957,15 @@ zsys_catch_interrupts (); } +NAN_METHOD (Zsys::_is_interrupted) { + bool result = zsys_is_interrupted (); + info.GetReturnValue ().Set (Nan::New(result)); +} + +NAN_METHOD (Zsys::_set_interrupted) { + zsys_set_interrupted (); +} + NAN_METHOD (Zsys::_file_exists) { char *filename; if (info [0]->IsUndefined ()) @@ -7505,6 +7307,28 @@ info.GetReturnValue ().Set (Nan::New(result)); } +NAN_METHOD (Zsys::_set_zero_copy_recv) { + if (info [0]->IsUndefined ()) + return Nan::ThrowTypeError ("method requires a `zero copy`"); + + //int zero_copy; // bjornw typedef - if using c_type, then you get 'int * major' but it needs to be 'int major'. later using the FromJust() returns an int + int zero_copy; + + + if (info [0]->IsNumber ()) + { + zero_copy = Nan::To(info [0]).FromJust (); + } + else + return Nan::ThrowTypeError ("`zero copy` must be a number"); + zsys_set_zero_copy_recv ((int) zero_copy); +} + +NAN_METHOD (Zsys::_zero_copy_recv) { + int result = zsys_zero_copy_recv (); + 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`"); diff -Nru czmq-4.1.0/bindings/nodejs/binding.h czmq-4.1.1/bindings/nodejs/binding.h --- czmq-4.1.0/bindings/nodejs/binding.h 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/nodejs/binding.h 2018-03-22 22:18:37.000000000 +0000 @@ -589,7 +589,9 @@ static NAN_METHOD (New); static NAN_METHOD (destroy); static NAN_METHOD (defined); + static NAN_METHOD (_args); static NAN_METHOD (_set_args); + static NAN_METHOD (_set_argsx); static NAN_METHOD (_set_env); static NAN_METHOD (_run); static NAN_METHOD (_returncode); @@ -598,24 +600,6 @@ 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); }; @@ -828,6 +812,8 @@ static NAN_METHOD (_create_pipe); static NAN_METHOD (_handler_reset); static NAN_METHOD (_catch_interrupts); + static NAN_METHOD (_is_interrupted); + static NAN_METHOD (_set_interrupted); static NAN_METHOD (_file_exists); static NAN_METHOD (_file_modified); static NAN_METHOD (_file_mode); @@ -852,6 +838,8 @@ static NAN_METHOD (_socket_limit); static NAN_METHOD (_set_max_msgsz); static NAN_METHOD (_max_msgsz); + static NAN_METHOD (_set_zero_copy_recv); + static NAN_METHOD (_zero_copy_recv); static NAN_METHOD (_set_file_stable_age_msec); static NAN_METHOD (_file_stable_age_msec); static NAN_METHOD (_set_linger); diff -Nru czmq-4.1.0/bindings/nodejs/README.md czmq-4.1.1/bindings/nodejs/README.md --- czmq-4.1.0/bindings/nodejs/README.md 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/nodejs/README.md 2018-03-22 22:18:37.000000000 +0000 @@ -2186,14 +2186,28 @@ Methods: ``` -nothing my_zproc.setArgs (Zlistx) +zlist my_zproc.args () +``` + +Return command line arguments (the first item is the executable) or +NULL if not set. + +``` +nothing my_zproc.setArgs (Zlist) ``` Setup the command line arguments, the first item must be an (absolute) filename to run. ``` -nothing my_zproc.setEnv (Zhashx) +nothing my_zproc.setArgsx (String) +``` + +Setup the command line arguments, the first item must be an (absolute) filename +to run. Variadic function, must be NULL terminated. + +``` +nothing my_zproc.setEnv (Zhash) ``` Setup the environment variables for the process. @@ -2202,7 +2216,7 @@ integer my_zproc.run () ``` -Starts the process. +Starts the process, return just before execve/CreateProcess. ``` integer my_zproc.returncode () @@ -2241,149 +2255,6 @@ 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) ``` @@ -3773,6 +3644,22 @@ *** This is for CZMQ internal use only and may change arbitrarily *** ``` +boolean my_zsys.isInterrupted () +``` + +Check if default interrupt handler of Ctrl-C or SIGTERM was called. +Does not work if ZSYS_SIGHANDLER is false and code does not call +set interrupted on signal. + +``` +nothing my_zsys.setInterrupted () +``` + +Set interrupted flag. This is done by default signal handler, however +this can be handy for language bindings or cases without default +signal handler. + +``` boolean my_zsys.fileExists (String) ``` @@ -3954,6 +3841,20 @@ Return maximum message size. ``` +nothing my_zsys.setZeroCopyRecv (Number) +``` + +Configure whether to use zero copy strategy in libzmq. If the environment +variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. +Otherwise the default is 1. + +``` +integer my_zsys.zeroCopyRecv () +``` + +Return ZMQ_ZERO_COPY_RECV option. + +``` nothing my_zsys.setFileStableAgeMsec (Number) ``` diff -Nru czmq-4.1.0/bindings/python/ci_build.sh czmq-4.1.1/bindings/python/ci_build.sh --- czmq-4.1.0/bindings/python/ci_build.sh 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python/ci_build.sh 2018-03-22 22:18:37.000000000 +0000 @@ -56,4 +56,7 @@ ./configure --enable-drafts=yes "${CONFIG_OPTS[@]}" make VERBOSE=1 install -LD_LIBRARY_PATH=$BUILD_PREFIX/lib python bindings/python/test.py +# LD_LIBRARY_PATH/DYLD_LIBRARY_PATH do not work anymore on OSX, change directory instead +BASE_PWD=${PWD} +cd ${BUILD_PREFIX}/lib +LD_LIBRARY_PATH=$BUILD_PREFIX/lib python ${BASE_PWD}/bindings/python/test.py diff -Nru czmq-4.1.0/bindings/python/czmq/_czmq_ctypes.py czmq-4.1.1/bindings/python/czmq/_czmq_ctypes.py --- czmq-4.1.0/bindings/python/czmq/_czmq_ctypes.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python/czmq/_czmq_ctypes.py 2018-03-22 22:18:37.000000000 +0000 @@ -4816,10 +4816,14 @@ lib.zproc_new.argtypes = [] lib.zproc_destroy.restype = None lib.zproc_destroy.argtypes = [POINTER(zproc_p)] +lib.zproc_args.restype = zlist_p +lib.zproc_args.argtypes = [zproc_p] lib.zproc_set_args.restype = None -lib.zproc_set_args.argtypes = [zproc_p, zlistx_p] +lib.zproc_set_args.argtypes = [zproc_p, POINTER(zlist_p)] +lib.zproc_set_argsx.restype = None +lib.zproc_set_argsx.argtypes = [zproc_p, c_char_p] lib.zproc_set_env.restype = None -lib.zproc_set_env.argtypes = [zproc_p, zhashx_p] +lib.zproc_set_env.argtypes = [zproc_p, POINTER(zhash_p)] lib.zproc_set_stdin.restype = None lib.zproc_set_stdin.argtypes = [zproc_p, c_void_p] lib.zproc_set_stdout.restype = None @@ -4848,42 +4852,6 @@ 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] @@ -4937,18 +4905,32 @@ "Determine whether the object is valid by converting to boolean" # Python 2 return self._as_parameter_.__nonzero__() - def set_args(self, args): + def args(self): + """ + Return command line arguments (the first item is the executable) or +NULL if not set. + """ + return Zlist(lib.zproc_args(self._as_parameter_), True) + + def set_args(self, arguments): """ Setup the command line arguments, the first item must be an (absolute) filename to run. """ - return lib.zproc_set_args(self._as_parameter_, args) + return lib.zproc_set_args(self._as_parameter_, byref(zlist_p.from_param(arguments))) + + def set_argsx(self, arguments, *args): + """ + Setup the command line arguments, the first item must be an (absolute) filename +to run. Variadic function, must be NULL terminated. + """ + return lib.zproc_set_argsx(self._as_parameter_, arguments, *args) - def set_env(self, args): + def set_env(self, arguments): """ Setup the environment variables for the process. """ - return lib.zproc_set_env(self._as_parameter_, args) + return lib.zproc_set_env(self._as_parameter_, byref(zhash_p.from_param(arguments))) def set_stdin(self, socket): """ @@ -4997,7 +4979,7 @@ def run(self): """ - Starts the process. + Starts the process, return just before execve/CreateProcess. """ return lib.zproc_run(self._as_parameter_) @@ -5044,167 +5026,6 @@ 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. @@ -7205,6 +7026,10 @@ lib.zsys_handler_reset.argtypes = [] lib.zsys_catch_interrupts.restype = None lib.zsys_catch_interrupts.argtypes = [] +lib.zsys_is_interrupted.restype = c_bool +lib.zsys_is_interrupted.argtypes = [] +lib.zsys_set_interrupted.restype = None +lib.zsys_set_interrupted.argtypes = [] lib.zsys_file_exists.restype = c_bool lib.zsys_file_exists.argtypes = [c_char_p] lib.zsys_file_modified.restype = c_int @@ -7263,6 +7088,10 @@ lib.zsys_set_max_msgsz.argtypes = [c_int] lib.zsys_max_msgsz.restype = c_int lib.zsys_max_msgsz.argtypes = [] +lib.zsys_set_zero_copy_recv.restype = None +lib.zsys_set_zero_copy_recv.argtypes = [c_int] +lib.zsys_zero_copy_recv.restype = c_int +lib.zsys_zero_copy_recv.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 @@ -7430,6 +7259,24 @@ return lib.zsys_catch_interrupts() @staticmethod + def is_interrupted(): + """ + Check if default interrupt handler of Ctrl-C or SIGTERM was called. +Does not work if ZSYS_SIGHANDLER is false and code does not call +set interrupted on signal. + """ + return lib.zsys_is_interrupted() + + @staticmethod + def set_interrupted(): + """ + Set interrupted flag. This is done by default signal handler, however +this can be handy for language bindings or cases without default +signal handler. + """ + return lib.zsys_set_interrupted() + + @staticmethod def file_exists(filename): """ Return 1 if file exists, else zero @@ -7681,6 +7528,22 @@ return lib.zsys_max_msgsz() @staticmethod + def set_zero_copy_recv(zero_copy): + """ + Configure whether to use zero copy strategy in libzmq. If the environment +variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. +Otherwise the default is 1. + """ + return lib.zsys_set_zero_copy_recv(zero_copy) + + @staticmethod + def zero_copy_recv(): + """ + Return ZMQ_ZERO_COPY_RECV option. + """ + return lib.zsys_zero_copy_recv() + + @staticmethod def set_file_stable_age_msec(file_stable_age_msec): """ Configure the threshold value of filesystem object age per st_mtime diff -Nru czmq-4.1.0/bindings/python/setup.py czmq-4.1.1/bindings/python/setup.py --- czmq-4.1.0/bindings/python/setup.py 1970-01-01 00:00:00.000000000 +0000 +++ czmq-4.1.1/bindings/python/setup.py 2018-03-22 22:18:37.000000000 +0000 @@ -0,0 +1,20 @@ +################################################################################ +# 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", + version = "4.1.1", + license = "mplv2", + description = """Python bindings of: the high-level c binding for 0mq""", + url = "https://github.com/zeromq/czmq", + packages = ["czmq"], + install_requires = [ + ], +) +################################################################################ +# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # +# Read the zproject/README.md for information about making permanent changes. # +################################################################################ diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/cdefs.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/cdefs.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/cdefs.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/cdefs.py 2018-03-22 22:18:37.000000000 +0000 @@ -68,8 +68,8 @@ // // An example - to send $KTHXBAI string // -// if (zstr_send (self->pipe, "$KTHXBAI") == 0) -// zsock_wait (self->pipe); +// if (zstr_send (self, "$KTHXBAI") == 0) +// zsock_wait (self); typedef void (zactor_destructor_fn) ( zactor_t *self); @@ -2258,14 +2258,24 @@ void zproc_destroy (zproc_t **self_p); +// Return command line arguments (the first item is the executable) or +// NULL if not set. +zlist_t * + zproc_args (zproc_t *self); + // 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); + zproc_set_args (zproc_t *self, zlist_t **arguments); + +// Setup the command line arguments, the first item must be an (absolute) filename +// to run. Variadic function, must be NULL terminated. +void + zproc_set_argsx (zproc_t *self, const char *arguments, ...); // Setup the environment variables for the process. void - zproc_set_env (zproc_t *self, zhashx_t *args); + zproc_set_env (zproc_t *self, zhash_t **arguments); // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc @@ -2300,7 +2310,7 @@ void * zproc_stderr (zproc_t *self); -// Starts the process. +// Starts the process, return just before execve/CreateProcess. int zproc_run (zproc_t *self); @@ -2332,113 +2342,6 @@ 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); @@ -3595,6 +3498,18 @@ void zsys_catch_interrupts (void); +// Check if default interrupt handler of Ctrl-C or SIGTERM was called. +// Does not work if ZSYS_SIGHANDLER is false and code does not call +// set interrupted on signal. +bool + zsys_is_interrupted (void); + +// Set interrupted flag. This is done by default signal handler, however +// this can be handy for language bindings or cases without default +// signal handler. +void + zsys_set_interrupted (void); + // Return 1 if file exists, else zero bool zsys_file_exists (const char *filename); @@ -3759,6 +3674,16 @@ int zsys_max_msgsz (void); +// Configure whether to use zero copy strategy in libzmq. If the environment +// variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. +// Otherwise the default is 1. +void + zsys_set_zero_copy_recv (int zero_copy); + +// Return ZMQ_ZERO_COPY_RECV option. +int + zsys_zero_copy_recv (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. diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/__init__.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/__init__.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/__init__.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/__init__.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,9 +2,15 @@ # 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 utils from .Zactor import * from .Zargs import * +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 from .Zarmour import * from .Zcert import * from .Zcertstore import * @@ -13,8 +19,13 @@ from .Zconfig import * from .Zdigest import * from .Zdir import * +CREATE = 1 # Creates a new file +DELETE = 2 # Delete a file from .ZdirPatch import * from .Zfile import * +MORE = 1 # +REUSE = 2 # +DONTWAIT = 4 # from .Zframe import * from .Zhash import * from .Zhashx import * diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zactor.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zactor.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zactor.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zactor.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zargs.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zargs.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zargs.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zargs.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zarmour.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zarmour.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zarmour.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zarmour.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zcert.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zcert.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zcert.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zcert.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zcertstore.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zcertstore.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zcertstore.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zcertstore.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zchunk.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zchunk.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zchunk.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zchunk.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zclock.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zclock.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zclock.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zclock.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zconfig.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zconfig.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zconfig.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zconfig.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zdigest.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zdigest.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zdigest.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zdigest.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/ZdirPatch.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/ZdirPatch.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/ZdirPatch.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/ZdirPatch.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zdir.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zdir.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zdir.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zdir.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zfile.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zfile.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zfile.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zfile.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zframe.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zframe.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zframe.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zframe.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zhash.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zhash.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zhash.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zhash.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zhashx.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zhashx.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zhashx.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zhashx.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Ziflist.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Ziflist.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Ziflist.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Ziflist.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zlist.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zlist.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zlist.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zlist.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zlistx.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zlistx.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zlistx.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zlistx.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zloop.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zloop.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zloop.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zloop.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zmsg.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zmsg.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zmsg.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zmsg.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zpoller.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zpoller.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zpoller.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zpoller.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zproc.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zproc.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zproc.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zproc.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib @@ -26,18 +26,39 @@ # 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): + def args(self): + """ + Return command line arguments (the first item is the executable) or + NULL if not set. + """ + return utils.lib.zproc_args(self._p) + + def set_args(self, arguments): """ Setup the command line arguments, the first item must be an (absolute) filename to run. """ - utils.lib.zproc_set_args(self._p, args._p) + foo = utils.to_strings (argv_p) + if foo is not None: + foo_p = utils.ffi.new("struct _zlist_t *[1]") + foo_p [0] = foo + utils.lib.dproto_set_argv(self._p, foo_p) + return + + utils.lib.zproc_set_args(self._p, arguments._p) + + def set_argsx(self, arguments, ): + """ + Setup the command line arguments, the first item must be an (absolute) filename + to run. Variadic function, must be NULL terminated. + """ + utils.lib.zproc_set_argsx(self._p, utils.to_bytes(arguments), ) - def set_env(self, args): + def set_env(self, arguments): """ Setup the environment variables for the process. """ - utils.lib.zproc_set_env(self._p, args._p) + utils.lib.zproc_set_env(self._p, arguments._p) def set_stdin(self, socket): """ @@ -86,7 +107,7 @@ def run(self): """ - Starts the process. + Starts the process, return just before execve/CreateProcess. """ return utils.lib.zproc_run(self._p) @@ -132,149 +153,6 @@ """ 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. diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zsock.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zsock.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zsock.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zsock.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zstr.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zstr.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zstr.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zstr.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zsys.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zsys.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zsys.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zsys.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib @@ -87,6 +87,22 @@ """ utils.lib.zsys_catch_interrupts() + def is_interrupted(): + """ + Check if default interrupt handler of Ctrl-C or SIGTERM was called. + Does not work if ZSYS_SIGHANDLER is false and code does not call + set interrupted on signal. + """ + return utils.lib.zsys_is_interrupted() + + def set_interrupted(): + """ + Set interrupted flag. This is done by default signal handler, however + this can be handy for language bindings or cases without default + signal handler. + """ + utils.lib.zsys_set_interrupted() + def file_exists(filename): """ Return 1 if file exists, else zero @@ -309,6 +325,20 @@ """ return utils.lib.zsys_max_msgsz() + def set_zero_copy_recv(zero_copy): + """ + Configure whether to use zero copy strategy in libzmq. If the environment + variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. + Otherwise the default is 1. + """ + utils.lib.zsys_set_zero_copy_recv(zero_copy) + + def zero_copy_recv(): + """ + Return ZMQ_ZERO_COPY_RECV option. + """ + return utils.lib.zsys_zero_copy_recv() + def set_file_stable_age_msec(file_stable_age_msec): """ Configure the threshold value of filesystem object age per st_mtime diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Ztimerset.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Ztimerset.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Ztimerset.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Ztimerset.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Ztrie.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Ztrie.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Ztrie.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Ztrie.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zuuid.py czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zuuid.py --- czmq-4.1.0/bindings/python_cffi/czmq_cffi/Zuuid.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/czmq_cffi/Zuuid.py 2018-03-22 22:18:37.000000000 +0000 @@ -2,7 +2,7 @@ # 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 utils from . import destructors libczmq_destructors = destructors.lib diff -Nru czmq-4.1.0/bindings/python_cffi/setup.py czmq-4.1.1/bindings/python_cffi/setup.py --- czmq-4.1.0/bindings/python_cffi/setup.py 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/python_cffi/setup.py 2018-03-22 22:18:37.000000000 +0000 @@ -6,7 +6,7 @@ setup( name = "czmq_cffi", - version = "4.1.0", + version = "4.1.1", license = "mplv2", description = """Python cffi bindings of: the high-level c binding for 0mq""", packages = ["czmq_cffi", ], diff -Nru czmq-4.1.0/bindings/qml/src/QmlZproc.cpp czmq-4.1.1/bindings/qml/src/QmlZproc.cpp --- czmq-4.1.0/bindings/qml/src/QmlZproc.cpp 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/qml/src/QmlZproc.cpp 2018-03-22 22:18:37.000000000 +0000 @@ -9,16 +9,32 @@ /// +// Return command line arguments (the first item is the executable) or +// NULL if not set. +QmlZlist *QmlZproc::args () { + QmlZlist *retQ_ = new QmlZlist (); + retQ_->self = zproc_args (self); + return retQ_; +}; + +/// // 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); +void QmlZproc::setArgs (QmlZlist *arguments) { + zproc_set_args (self, &arguments->self); +}; + +/// +// Setup the command line arguments, the first item must be an (absolute) filename +// to run. Variadic function, must be NULL terminated. +void QmlZproc::setArgsx (const QString &arguments) { + zproc_set_argsx (self, arguments.toUtf8().data()); }; /// // Setup the environment variables for the process. -void QmlZproc::setEnv (QmlZhashx *args) { - zproc_set_env (self, args->self); +void QmlZproc::setEnv (QmlZhash *arguments) { + zproc_set_env (self, &arguments->self); }; /// @@ -67,7 +83,7 @@ }; /// -// Starts the process. +// Starts the process, return just before execve/CreateProcess. int QmlZproc::run () { return zproc_run (self); }; @@ -121,152 +137,6 @@ /// -// 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); diff -Nru czmq-4.1.0/bindings/qml/src/QmlZproc.h czmq-4.1.1/bindings/qml/src/QmlZproc.h --- czmq-4.1.0/bindings/qml/src/QmlZproc.h 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/qml/src/QmlZproc.h 2018-03-22 22:18:37.000000000 +0000 @@ -28,12 +28,20 @@ static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZproc.cpp public slots: + // Return command line arguments (the first item is the executable) or + // NULL if not set. + QmlZlist *args (); + // Setup the command line arguments, the first item must be an (absolute) filename // to run. - void setArgs (QmlZlistx *args); + void setArgs (QmlZlist *arguments); + + // Setup the command line arguments, the first item must be an (absolute) filename + // to run. Variadic function, must be NULL terminated. + void setArgsx (const QString &arguments); // Setup the environment variables for the process. - void setEnv (QmlZhashx *args); + void setEnv (QmlZhash *arguments); // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc @@ -62,7 +70,7 @@ // not initialized or external sockets. void *stderr (); - // Starts the process. + // Starts the process, return just before execve/CreateProcess. int run (); // process exit code @@ -98,95 +106,6 @@ }; 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); diff -Nru czmq-4.1.0/bindings/qml/src/QmlZsys.cpp czmq-4.1.1/bindings/qml/src/QmlZsys.cpp --- czmq-4.1.0/bindings/qml/src/QmlZsys.cpp 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/qml/src/QmlZsys.cpp 2018-03-22 22:18:37.000000000 +0000 @@ -93,6 +93,22 @@ }; /// +// Check if default interrupt handler of Ctrl-C or SIGTERM was called. +// Does not work if ZSYS_SIGHANDLER is false and code does not call +// set interrupted on signal. +bool QmlZsysAttached::isInterrupted () { + return zsys_is_interrupted (); +}; + +/// +// Set interrupted flag. This is done by default signal handler, however +// this can be handy for language bindings or cases without default +// signal handler. +void QmlZsysAttached::setInterrupted () { + zsys_set_interrupted (); +}; + +/// // Return 1 if file exists, else zero bool QmlZsysAttached::fileExists (const QString &filename) { return zsys_file_exists (filename.toUtf8().data()); @@ -317,6 +333,20 @@ }; /// +// Configure whether to use zero copy strategy in libzmq. If the environment +// variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. +// Otherwise the default is 1. +void QmlZsysAttached::setZeroCopyRecv (int zeroCopy) { + zsys_set_zero_copy_recv (zeroCopy); +}; + +/// +// Return ZMQ_ZERO_COPY_RECV option. +int QmlZsysAttached::zeroCopyRecv () { + return zsys_zero_copy_recv (); +}; + +/// // 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. diff -Nru czmq-4.1.0/bindings/qml/src/QmlZsys.h czmq-4.1.1/bindings/qml/src/QmlZsys.h --- czmq-4.1.0/bindings/qml/src/QmlZsys.h 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/qml/src/QmlZsys.h 2018-03-22 22:18:37.000000000 +0000 @@ -89,6 +89,16 @@ // *** This is for CZMQ internal use only and may change arbitrarily *** void catchInterrupts (); + // Check if default interrupt handler of Ctrl-C or SIGTERM was called. + // Does not work if ZSYS_SIGHANDLER is false and code does not call + // set interrupted on signal. + bool isInterrupted (); + + // Set interrupted flag. This is done by default signal handler, however + // this can be handy for language bindings or cases without default + // signal handler. + void setInterrupted (); + // Return 1 if file exists, else zero bool fileExists (const QString &filename); @@ -224,6 +234,14 @@ // Return maximum message size. int maxMsgsz (); + // Configure whether to use zero copy strategy in libzmq. If the environment + // variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. + // Otherwise the default is 1. + void setZeroCopyRecv (int zeroCopy); + + // Return ZMQ_ZERO_COPY_RECV option. + int zeroCopyRecv (); + // 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. diff -Nru czmq-4.1.0/bindings/qt/buildlib/buildlib.pro czmq-4.1.1/bindings/qt/buildlib/buildlib.pro --- czmq-4.1.0/bindings/qt/buildlib/buildlib.pro 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/qt/buildlib/buildlib.pro 2018-03-22 22:18:37.000000000 +0000 @@ -3,7 +3,7 @@ # Read the zproject/README.md for information about making permanent changes. # ################################################################################ TEMPLATE = lib -VERSION = 4.1.0 +VERSION = 4.1.1 CONFIG += qt dll qczmq-buildlib mac:CONFIG += absolute_library_soname win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release build_all diff -Nru czmq-4.1.0/bindings/qt/src/qzproc.cpp czmq-4.1.1/bindings/qt/src/qzproc.cpp --- czmq-4.1.0/bindings/qt/src/qzproc.cpp 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/qt/src/qzproc.cpp 2018-03-22 22:18:37.000000000 +0000 @@ -32,19 +32,28 @@ } /// +// Return command line arguments (the first item is the executable) or +// NULL if not set. +QZlist * QZproc::args () +{ + QZlist *rv = new QZlist (zproc_args (self)); + return rv; +} + +/// // Setup the command line arguments, the first item must be an (absolute) filename // to run. -void QZproc::setArgs (QZlistx *args) +void QZproc::setArgs (QZlist *arguments) { - zproc_set_args (self, args->self); + zproc_set_args (self, &arguments->self); } /// // Setup the environment variables for the process. -void QZproc::setEnv (QZhashx *args) +void QZproc::setEnv (QZhash *arguments) { - zproc_set_env (self, args->self); + zproc_set_env (self, &arguments->self); } @@ -106,7 +115,7 @@ } /// -// Starts the process. +// Starts the process, return just before execve/CreateProcess. int QZproc::run () { int rv = zproc_run (self); @@ -169,187 +178,6 @@ } -/// -// 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) diff -Nru czmq-4.1.0/bindings/qt/src/qzproc.h czmq-4.1.1/bindings/qt/src/qzproc.h --- czmq-4.1.0/bindings/qt/src/qzproc.h 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/qt/src/qzproc.h 2018-03-22 22:18:37.000000000 +0000 @@ -25,12 +25,16 @@ // Destroy zproc, wait until process ends. ~QZproc (); + // Return command line arguments (the first item is the executable) or + // NULL if not set. + QZlist * args (); + // Setup the command line arguments, the first item must be an (absolute) filename // to run. - void setArgs (QZlistx *args); + void setArgs (QZlist *arguments); // Setup the environment variables for the process. - void setEnv (QZhashx *args); + void setEnv (QZhash *arguments); // Connects process stdin with a readable ('>', connect) zeromq socket. If // socket argument is NULL, zproc creates own managed pair of inproc @@ -59,7 +63,7 @@ // not initialized or external sockets. void * stderr (); - // Starts the process. + // Starts the process, return just before execve/CreateProcess. int run (); // process exit code @@ -83,95 +87,6 @@ // 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); diff -Nru czmq-4.1.0/bindings/qt/src/qzsys.cpp czmq-4.1.1/bindings/qt/src/qzsys.cpp --- czmq-4.1.0/bindings/qt/src/qzsys.cpp 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/qt/src/qzsys.cpp 2018-03-22 22:18:37.000000000 +0000 @@ -110,6 +110,26 @@ } /// +// Check if default interrupt handler of Ctrl-C or SIGTERM was called. +// Does not work if ZSYS_SIGHANDLER is false and code does not call +// set interrupted on signal. +bool QZsys::isInterrupted () +{ + bool rv = zsys_is_interrupted (); + return rv; +} + +/// +// Set interrupted flag. This is done by default signal handler, however +// this can be handy for language bindings or cases without default +// signal handler. +void QZsys::setInterrupted () +{ + zsys_set_interrupted (); + +} + +/// // Return 1 if file exists, else zero bool QZsys::fileExists (const QString &filename) { @@ -362,6 +382,24 @@ return rv; } +/// +// Configure whether to use zero copy strategy in libzmq. If the environment +// variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. +// Otherwise the default is 1. +void QZsys::setZeroCopyRecv (int zeroCopy) +{ + zsys_set_zero_copy_recv (zeroCopy); + +} + +/// +// Return ZMQ_ZERO_COPY_RECV option. +int QZsys::zeroCopyRecv () +{ + int rv = zsys_zero_copy_recv (); + return rv; +} + /// // Configure the threshold value of filesystem object age per st_mtime // that should elapse until we consider that object "stable" at the diff -Nru czmq-4.1.0/bindings/qt/src/qzsys.h czmq-4.1.1/bindings/qt/src/qzsys.h --- czmq-4.1.0/bindings/qt/src/qzsys.h 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/qt/src/qzsys.h 2018-03-22 22:18:37.000000000 +0000 @@ -66,6 +66,16 @@ // *** This is for CZMQ internal use only and may change arbitrarily *** static void catchInterrupts (); + // Check if default interrupt handler of Ctrl-C or SIGTERM was called. + // Does not work if ZSYS_SIGHANDLER is false and code does not call + // set interrupted on signal. + static bool isInterrupted (); + + // Set interrupted flag. This is done by default signal handler, however + // this can be handy for language bindings or cases without default + // signal handler. + static void setInterrupted (); + // Return 1 if file exists, else zero static bool fileExists (const QString &filename); @@ -189,6 +199,14 @@ // Return maximum message size. static int maxMsgsz (); + // Configure whether to use zero copy strategy in libzmq. If the environment + // variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. + // Otherwise the default is 1. + static void setZeroCopyRecv (int zeroCopy); + + // Return ZMQ_ZERO_COPY_RECV option. + static int zeroCopyRecv (); + // 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. diff -Nru czmq-4.1.0/bindings/ruby/lib/czmq/ffi/version.rb czmq-4.1.1/bindings/ruby/lib/czmq/ffi/version.rb --- czmq-4.1.0/bindings/ruby/lib/czmq/ffi/version.rb 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/ruby/lib/czmq/ffi/version.rb 2018-03-22 22:18:37.000000000 +0000 @@ -5,7 +5,7 @@ module CZMQ module FFI - VERSION = '4.1.0' + VERSION = '4.1.1' end end diff -Nru czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zactor.rb czmq-4.1.1/bindings/ruby/lib/czmq/ffi/zactor.rb --- czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zactor.rb 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/ruby/lib/czmq/ffi/zactor.rb 2018-03-22 22:18:37.000000000 +0000 @@ -95,8 +95,8 @@ # # An example - to send $KTHXBAI string # - # if (zstr_send (self->pipe, "$KTHXBAI") == 0) - # zsock_wait (self->pipe); + # if (zstr_send (self, "$KTHXBAI") == 0) + # zsock_wait (self); # typedef void (zactor_destructor_fn) ( # zactor_t *self); # diff -Nru czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zproc.rb czmq-4.1.1/bindings/ruby/lib/czmq/ffi/zproc.rb --- czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zproc.rb 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/ruby/lib/czmq/ffi/zproc.rb 2018-03-22 22:18:37.000000000 +0000 @@ -92,28 +92,53 @@ result end + # Return command line arguments (the first item is the executable) or + # NULL if not set. + # + # @return [Zlist] + def args() + raise DestroyedError unless @ptr + self_p = @ptr + result = ::CZMQ::FFI.zproc_args(self_p) + result = Zlist.__new result, true + result + end + # Setup the command line arguments, the first item must be an (absolute) filename # to run. # - # @param args [Zlistx, #__ptr] + # @param arguments [#__ptr_give_ref] # @return [void] - def set_args(args) + def set_args(arguments) raise DestroyedError unless @ptr self_p = @ptr - args = args.__ptr if args - result = ::CZMQ::FFI.zproc_set_args(self_p, args) + arguments = arguments.__ptr_give_ref + result = ::CZMQ::FFI.zproc_set_args(self_p, arguments) + result + end + + # Setup the command line arguments, the first item must be an (absolute) filename + # to run. Variadic function, must be NULL terminated. + # + # @param arguments [String, #to_s, nil] + # @param args [Array] see https://github.com/ffi/ffi/wiki/examples#using-varargs + # @return [void] + def set_argsx(arguments, *args) + raise DestroyedError unless @ptr + self_p = @ptr + result = ::CZMQ::FFI.zproc_set_argsx(self_p, arguments, *args) result end # Setup the environment variables for the process. # - # @param args [Zhashx, #__ptr] + # @param arguments [#__ptr_give_ref] # @return [void] - def set_env(args) + def set_env(arguments) raise DestroyedError unless @ptr self_p = @ptr - args = args.__ptr if args - result = ::CZMQ::FFI.zproc_set_env(self_p, args) + arguments = arguments.__ptr_give_ref + result = ::CZMQ::FFI.zproc_set_env(self_p, arguments) result end @@ -189,7 +214,7 @@ result end - # Starts the process. + # Starts the process, return just before execve/CreateProcess. # # @return [Integer] def run() @@ -275,209 +300,6 @@ 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] diff -Nru czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zsys.rb czmq-4.1.1/bindings/ruby/lib/czmq/ffi/zsys.rb --- czmq-4.1.0/bindings/ruby/lib/czmq/ffi/zsys.rb 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/ruby/lib/czmq/ffi/zsys.rb 2018-03-22 22:18:37.000000000 +0000 @@ -197,6 +197,26 @@ result end + # Check if default interrupt handler of Ctrl-C or SIGTERM was called. + # Does not work if ZSYS_SIGHANDLER is false and code does not call + # set interrupted on signal. + # + # @return [Boolean] + def self.is_interrupted() + result = ::CZMQ::FFI.zsys_is_interrupted() + result + end + + # Set interrupted flag. This is done by default signal handler, however + # this can be handy for language bindings or cases without default + # signal handler. + # + # @return [void] + def self.set_interrupted() + result = ::CZMQ::FFI.zsys_set_interrupted() + result + end + # Return 1 if file exists, else zero # # @param filename [String, #to_s, nil] @@ -523,6 +543,26 @@ result end + # Configure whether to use zero copy strategy in libzmq. If the environment + # variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. + # Otherwise the default is 1. + # + # @param zero_copy [Integer, #to_int, #to_i] + # @return [void] + def self.set_zero_copy_recv(zero_copy) + zero_copy = Integer(zero_copy) + result = ::CZMQ::FFI.zsys_set_zero_copy_recv(zero_copy) + result + end + + # Return ZMQ_ZERO_COPY_RECV option. + # + # @return [Integer] + def self.zero_copy_recv() + result = ::CZMQ::FFI.zsys_zero_copy_recv() + 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. diff -Nru czmq-4.1.0/bindings/ruby/lib/czmq/ffi.rb czmq-4.1.1/bindings/ruby/lib/czmq/ffi.rb --- czmq-4.1.0/bindings/ruby/lib/czmq/ffi.rb 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/bindings/ruby/lib/czmq/ffi.rb 2018-03-22 22:18:37.000000000 +0000 @@ -516,7 +516,9 @@ attach_function :zproc_new, [], :pointer, **opts attach_function :zproc_destroy, [:pointer], :void, **opts + attach_function :zproc_args, [:pointer], :pointer, **opts attach_function :zproc_set_args, [:pointer, :pointer], :void, **opts + attach_function :zproc_set_argsx, [:pointer, :string, :varargs], :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 @@ -532,24 +534,6 @@ 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' @@ -764,6 +748,8 @@ 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_is_interrupted, [], :bool, **opts + attach_function :zsys_set_interrupted, [], :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 @@ -793,6 +779,8 @@ 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_zero_copy_recv, [:int], :void, **opts + attach_function :zsys_zero_copy_recv, [], :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 diff -Nru czmq-4.1.0/CMakeLists.txt czmq-4.1.1/CMakeLists.txt --- czmq-4.1.0/CMakeLists.txt 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/CMakeLists.txt 2018-03-22 22:18:37.000000000 +0000 @@ -16,6 +16,8 @@ # Select flags SET(CMAKE_C_FLAGS_RELEASE "-O3") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules) + # Will be used to add flags to pkg-config useful when apps want to statically link set(pkg_config_libs_private "") @@ -164,7 +166,7 @@ ######################################################################## set(CZMQ_VERSION_MAJOR 4) set(CZMQ_VERSION_MINOR 1) -set(CZMQ_VERSION_PATCH 0) +set(CZMQ_VERSION_PATCH 1) set(CZMQ_VERSION "${CZMQ_VERSION_MAJOR}.${CZMQ_VERSION_MINOR}.${CZMQ_VERSION_PATCH}") message(STATUS "Detected CZMQ Version - ${CZMQ_VERSION}") @@ -232,6 +234,8 @@ ######################################################################## # library ######################################################################## + + include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include") set (czmq_sources src/zactor.c @@ -295,8 +299,8 @@ 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) + add_library (czmq_objects OBJECT ${czmq_sources}) + set_property(TARGET czmq_objects PROPERTY POSITION_INDEPENDENT_CODE ON) ENDIF (NOT MSVC) # shared @@ -304,7 +308,7 @@ IF (MSVC) add_library(czmq SHARED ${czmq_sources}) ELSE (MSVC) - add_library(czmq SHARED $) + add_library(czmq SHARED $) ENDIF (MSVC) set_target_properties (czmq PROPERTIES @@ -337,7 +341,7 @@ IF (MSVC) add_library(czmq-static STATIC ${czmq_sources}) ELSE (MSVC) - add_library(czmq-static STATIC $) + add_library(czmq-static STATIC $) ENDIF (MSVC) set_target_properties(czmq-static PROPERTIES @@ -372,7 +376,7 @@ ######################################################################## # pkgconfig ######################################################################## -set (VERSION "4.1.0") +set (VERSION "4.1.1") set (prefix "${CMAKE_INSTALL_PREFIX}") set (exec_prefix "\${prefix}") set (libdir "\${prefix}/lib${LIB_SUFFIX}") @@ -604,6 +608,8 @@ TARGET distclean ) +include(ClangFormat) + ######################################################################## # summary ######################################################################## diff -Nru czmq-4.1.0/configure czmq-4.1.1/configure --- czmq-4.1.0/configure 2017-12-31 16:39:54.000000000 +0000 +++ czmq-4.1.1/configure 2018-03-22 22:20:19.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for czmq 4.1.0. +# Generated by GNU Autoconf 2.69 for czmq 4.1.1. # # Report bugs to . # @@ -590,8 +590,8 @@ # Identity of this package. PACKAGE_NAME='czmq' PACKAGE_TARNAME='czmq' -PACKAGE_VERSION='4.1.0' -PACKAGE_STRING='czmq 4.1.0' +PACKAGE_VERSION='4.1.1' +PACKAGE_STRING='czmq 4.1.1' PACKAGE_BUGREPORT='zeromq-dev@lists.zeromq.org' PACKAGE_URL='' @@ -685,10 +685,17 @@ libzmq_LIBS libzmq_CFLAGS pkgconfigdir +WITH_CLANG_FORMAT_FALSE +WITH_CLANG_FORMAT_TRUE +WITH_CLANG_FORMAT +CLANG_FORMAT ENABLE_ASAN_FALSE ENABLE_ASAN_TRUE WITH_GCOV_FALSE WITH_GCOV_TRUE +WITH_CPPCHECK_FALSE +WITH_CPPCHECK_TRUE +WITH_CPPCHECK PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG @@ -1396,7 +1403,7 @@ # 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. +\`configure' configures czmq 4.1.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1466,7 +1473,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of czmq 4.1.0:";; + short | recursive ) echo "Configuration of czmq 4.1.1:";; esac cat <<\_ACEOF @@ -1628,7 +1635,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -czmq configure 4.1.0 +czmq configure 4.1.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2105,7 +2112,7 @@ 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 +It was created by czmq $as_me 4.1.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2972,7 +2979,7 @@ # Define the identity of the package. PACKAGE='czmq' - VERSION='4.1.0' + VERSION='4.1.1' cat >>confdefs.h <<_ACEOF @@ -3245,12 +3252,12 @@ # # Libtool -version-info (ABI version) # -# Currently 5:0:1 ("stable"). Don't change this unless you +# Currently 5:1: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" +LTVER="5:1:1" # building in a subdirectory? @@ -12894,6 +12901,55 @@ +# See if cppcheck is in PATH; this variable unblocks the "cppcheck" recipe +# (note that "make cppcheck.xml" can be used - and perhaps fail - regardless) +# Extract the first word of "cppcheck", so it can be a program name with args. +set dummy cppcheck; 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_WITH_CPPCHECK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$WITH_CPPCHECK"; then + ac_cv_prog_WITH_CPPCHECK="$WITH_CPPCHECK" # 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_WITH_CPPCHECK="true" + $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_WITH_CPPCHECK" && ac_cv_prog_WITH_CPPCHECK="false" +fi +fi +WITH_CPPCHECK=$ac_cv_prog_WITH_CPPCHECK +if test -n "$WITH_CPPCHECK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WITH_CPPCHECK" >&5 +$as_echo "$WITH_CPPCHECK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if $WITH_CPPCHECK; then + WITH_CPPCHECK_TRUE= + WITH_CPPCHECK_FALSE='#' +else + WITH_CPPCHECK_TRUE='#' + WITH_CPPCHECK_FALSE= +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; } @@ -12969,6 +13025,145 @@ $as_echo "no" >&6; } fi +# See if clang-format is in PATH; the result unblocks the relevant recipes +WITH_CLANG_FORMAT="" +if test x"$CLANG_FORMAT" = x; then : + # Extract the first word of "clang-format", so it can be a program name with args. +set dummy clang-format; 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_CLANG_FORMAT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $CLANG_FORMAT in + [\\/]* | ?:[\\/]*) + ac_cv_path_CLANG_FORMAT="$CLANG_FORMAT" # 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_CLANG_FORMAT="$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 +CLANG_FORMAT=$ac_cv_path_CLANG_FORMAT +if test -n "$CLANG_FORMAT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CLANG_FORMAT" >&5 +$as_echo "$CLANG_FORMAT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +else + # Extract the first word of "$CLANG_FORMAT", so it can be a program name with args. +set dummy $CLANG_FORMAT; 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_WITH_CLANG_FORMAT+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$WITH_CLANG_FORMAT"; then + ac_cv_prog_WITH_CLANG_FORMAT="$WITH_CLANG_FORMAT" # 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_WITH_CLANG_FORMAT="true" + $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_WITH_CLANG_FORMAT" && ac_cv_prog_WITH_CLANG_FORMAT="fail" +fi +fi +WITH_CLANG_FORMAT=$ac_cv_prog_WITH_CLANG_FORMAT +if test -n "$WITH_CLANG_FORMAT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WITH_CLANG_FORMAT" >&5 +$as_echo "$WITH_CLANG_FORMAT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test x"$CLANG_FORMAT" != x && test x"$WITH_CLANG_FORMAT" = x; then : + if test -x "$CLANG_FORMAT"; then : + WITH_CLANG_FORMAT=true +else + # Extract the first word of "$CLANG_FORMAT", so it can be a program name with args. +set dummy $CLANG_FORMAT; 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_WITH_CLANG_FORMAT+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$WITH_CLANG_FORMAT"; then + ac_cv_prog_WITH_CLANG_FORMAT="$WITH_CLANG_FORMAT" # 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_WITH_CLANG_FORMAT="true" + $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_WITH_CLANG_FORMAT" && ac_cv_prog_WITH_CLANG_FORMAT="false" +fi +fi +WITH_CLANG_FORMAT=$ac_cv_prog_WITH_CLANG_FORMAT +if test -n "$WITH_CLANG_FORMAT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WITH_CLANG_FORMAT" >&5 +$as_echo "$WITH_CLANG_FORMAT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +fi +if test "$WITH_CLANG_FORMAT" = fail; then : + as_fn_error $? "Caller explicitly referenced CLANG_FORMAT=$CLANG_FORMAT which was not found" "$LINENO" 5 +fi + if $WITH_CLANG_FORMAT; then + WITH_CLANG_FORMAT_TRUE= + WITH_CLANG_FORMAT_FALSE='#' +else + WITH_CLANG_FORMAT_TRUE='#' + WITH_CLANG_FORMAT_FALSE= +fi + + # Set pkgconfigdir # Check whether --with-pkgconfigdir was given. @@ -13010,6 +13205,10 @@ withval=$with_libzmq; search_libzmq="yes" +else + + search_libzmq="yes" + fi case x"${with_libzmq}" in #( @@ -13298,6 +13497,10 @@ withval=$with_uuid; search_uuid="yes" +else + + search_uuid="yes" + fi case x"${with_uuid}" in #( @@ -13592,6 +13795,10 @@ withval=$with_libsystemd; search_libsystemd="yes" +else + + search_libsystemd="yes" + fi case x"${with_libsystemd}" in #( @@ -13886,6 +14093,10 @@ withval=$with_liblz4; search_liblz4="yes" +else + + search_liblz4="yes" + fi case x"${with_liblz4}" in #( @@ -15534,7 +15745,7 @@ fi # Specify output files -ac_config_files="$ac_config_files Makefile doc/Makefile src/libczmq.pc" +ac_config_files="$ac_config_files Makefile doc/Makefile include/Makefile src/libczmq.pc" @@ -15676,6 +15887,10 @@ Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${WITH_CPPCHECK_TRUE}" && test -z "${WITH_CPPCHECK_FALSE}"; then + as_fn_error $? "conditional \"WITH_CPPCHECK\" 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 @@ -15692,6 +15907,10 @@ as_fn_error $? "conditional \"ENABLE_ASAN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${WITH_CLANG_FORMAT_TRUE}" && test -z "${WITH_CLANG_FORMAT_FALSE}"; then + as_fn_error $? "conditional \"WITH_CLANG_FORMAT\" 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. @@ -16146,7 +16365,7 @@ # 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 +This file was extended by czmq $as_me 4.1.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16212,7 +16431,7 @@ 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 +czmq config.status 4.1.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -16625,6 +16844,7 @@ "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; + "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; "src/libczmq.pc") CONFIG_FILES="$CONFIG_FILES src/libczmq.pc" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; @@ -18073,6 +18293,11 @@ echo " check for memory leaks" echo " - 'make coverage' generate project's selftest coverage report" echo " expects --with-gcov option for configure" +echo " - 'make clang-format-check' check if project sources conform" +echo " to style requirements" +echo " - 'make clang-format' modify project sources to conform" +echo " to style requirements" +echo " - 'make clang-format-diff' modify as above and print 'git diff'" echo ################################################################################ diff -Nru czmq-4.1.0/configure.ac czmq-4.1.1/configure.ac --- czmq-4.1.0/configure.ac 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/configure.ac 2018-03-22 22:18:37.000000000 +0000 @@ -7,7 +7,7 @@ # 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_INIT([czmq],[4.1.1],[zeromq-dev@lists.zeromq.org]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_MACRO_DIR(config) @@ -31,12 +31,12 @@ # # Libtool -version-info (ABI version) # -# Currently 5:0:1 ("stable"). Don't change this unless you +# Currently 5:1: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" +LTVER="5:1:1" AC_SUBST(LTVER) # building in a subdirectory? @@ -61,6 +61,11 @@ # Optional project-local hook (acinclude.m4, add AC_DEFUN([AX_PROJECT_LOCAL_HOOK], [whatever]) ) AX_PROJECT_LOCAL_HOOK +# See if cppcheck is in PATH; this variable unblocks the "cppcheck" recipe +# (note that "make cppcheck.xml" can be used - and perhaps fail - regardless) +AC_CHECK_PROG([WITH_CPPCHECK], [cppcheck], [true], [false]) +AM_CONDITIONAL(WITH_CPPCHECK, $WITH_CPPCHECK) + # Code coverage AC_MSG_CHECKING([whether to enable GCov]) AC_ARG_WITH(gcov, [AS_HELP_STRING([--with-gcov=yes/no], @@ -97,6 +102,19 @@ AC_MSG_RESULT([no]) fi +# See if clang-format is in PATH; the result unblocks the relevant recipes +WITH_CLANG_FORMAT="" +AS_IF([test x"$CLANG_FORMAT" = x], + [AC_PATH_PROG([CLANG_FORMAT], [clang-format], [])], + [AC_CHECK_PROG([WITH_CLANG_FORMAT], [$CLANG_FORMAT], [true], [fail])]) +AS_IF([test x"$CLANG_FORMAT" != x && test x"$WITH_CLANG_FORMAT" = x], + [AS_IF([test -x "$CLANG_FORMAT"], + [WITH_CLANG_FORMAT=true], + [AC_CHECK_PROG([WITH_CLANG_FORMAT], [$CLANG_FORMAT], [true], [false])])]) +AS_IF([test "$WITH_CLANG_FORMAT" = fail], + [AC_MSG_ERROR([Caller explicitly referenced CLANG_FORMAT=$CLANG_FORMAT which was not found])]) +AM_CONDITIONAL([WITH_CLANG_FORMAT], [$WITH_CLANG_FORMAT]) + # Set pkgconfigdir AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH], [Path to the pkgconfig directory [[LIBDIR/pkgconfig]]]), @@ -132,7 +150,9 @@ [ search_libzmq="yes" ], - []) + [ + search_libzmq="yes" + ]) AS_CASE([x"${with_libzmq}"], [xyes], [search_libzmq="yes"], [xno], [search_libzmq="no"]) @@ -219,7 +239,9 @@ [ search_uuid="yes" ], - []) + [ + search_uuid="yes" + ]) AS_CASE([x"${with_uuid}"], [xyes], [search_uuid="yes"], [xno], [search_uuid="no"]) @@ -304,7 +326,9 @@ [ search_libsystemd="yes" ], - []) + [ + search_libsystemd="yes" + ]) AS_CASE([x"${with_libsystemd}"], [xyes], [search_libsystemd="yes"], [xno], [search_libsystemd="no"]) @@ -389,7 +413,9 @@ [ search_liblz4="yes" ], - []) + [ + search_liblz4="yes" + ]) AS_CASE([x"${with_liblz4}"], [xyes], [search_liblz4="yes"], [xno], [search_liblz4="no"]) @@ -769,6 +795,7 @@ # Specify output files AC_CONFIG_FILES([Makefile doc/Makefile + include/Makefile src/libczmq.pc ]) @@ -845,6 +872,11 @@ echo " check for memory leaks" echo " - 'make coverage' generate project's selftest coverage report" echo " expects --with-gcov option for configure" +echo " - 'make clang-format-check' check if project sources conform" +echo " to style requirements" +echo " - 'make clang-format' modify project sources to conform" +echo " to style requirements" +echo " - 'make clang-format-diff' modify as above and print 'git diff'" echo ]) diff -Nru czmq-4.1.0/debian/changelog czmq-4.1.1/debian/changelog --- czmq-4.1.0/debian/changelog 2018-01-01 18:43:52.000000000 +0000 +++ czmq-4.1.1/debian/changelog 2018-04-29 15:50:27.000000000 +0000 @@ -1,3 +1,18 @@ +czmq (4.1.1-2) unstable; urgency=medium + + * Add 0001-fix-kfreebsd-ftbfs.patch to fix build on GNU/kFreeBSD. + * Bump Standards-Version to 4.1.4, no changes. + + -- Luca Boccassi Sun, 29 Apr 2018 16:50:27 +0100 + +czmq (4.1.1-1) unstable; urgency=medium + + * New upstream version 4.1.1 + * Drop 0001-fix-hurd-ftbfs.patch, merged upstream. + * Move repository to Salsa. + + -- Luca Boccassi Fri, 23 Mar 2018 10:17:01 +0000 + czmq (4.1.0-2) unstable; urgency=medium * Backport 0001-fix-hurd-ftbfs.patch to fix build on Hurd. diff -Nru czmq-4.1.0/debian/control czmq-4.1.1/debian/control --- czmq-4.1.0/debian/control 2018-01-01 13:25:05.000000000 +0000 +++ czmq-4.1.1/debian/control 2018-04-29 15:49:54.000000000 +0000 @@ -10,11 +10,11 @@ libsystemd-dev [linux-any], asciidoc-base | asciidoc , xmlto , -Standards-Version: 4.1.3 +Standards-Version: 4.1.4 Section: libs Homepage: http://czmq.zeromq.org/ -Vcs-Git: https://anonscm.debian.org/git/collab-maint/czmq.git -Vcs-Browser: https://anonscm.debian.org/cgit/collab-maint/czmq.git +Vcs-Git: https://salsa.debian.org/debian/czmq.git +Vcs-Browser: https://salsa.debian.org/debian/czmq Package: libczmq4 Architecture: any diff -Nru czmq-4.1.0/debian/patches/0001-fix-hurd-ftbfs.patch czmq-4.1.1/debian/patches/0001-fix-hurd-ftbfs.patch --- czmq-4.1.0/debian/patches/0001-fix-hurd-ftbfs.patch 2018-01-01 18:42:57.000000000 +0000 +++ czmq-4.1.1/debian/patches/0001-fix-hurd-ftbfs.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -Description: Fix build on GNU/Hurd -Forwarded: https://github.com/zeromq/czmq/pull/1828 -Author: Luca Boccassi -Last-Update: 2018-01-01 ---- a/src/zfile.c -+++ b/src/zfile.c -@@ -141,7 +141,11 @@ zfile_tmp (void) - self->fullname = strdup (name); - self->handle = fopen (self->fullname, "w"); - #else -+# if (defined (PATH_MAX)) - char buffer [PATH_MAX]; -+# else -+ char buffer [1024]; -+# endif - strcpy (buffer, "/tmp/czmq_zfile.XXXXXX"); - int fd = mkstemp (buffer); - if (fd == -1) --- -2.14.2 - diff -Nru czmq-4.1.0/debian/patches/0001-fix-kfreebsd-ftbfs.patch czmq-4.1.1/debian/patches/0001-fix-kfreebsd-ftbfs.patch --- czmq-4.1.0/debian/patches/0001-fix-kfreebsd-ftbfs.patch 1970-01-01 00:00:00.000000000 +0000 +++ czmq-4.1.1/debian/patches/0001-fix-kfreebsd-ftbfs.patch 2018-04-29 15:48:44.000000000 +0000 @@ -0,0 +1,29 @@ +Description: Fix build on Debian GNU/kFreeBSD +Forwarded: https://github.com/zeromq/czmq/pull/1907 +Author: Luca Boccassi +Last-Update: 2018-04-29 +--- a/include/czmq_prelude.h ++++ b/include/czmq_prelude.h +@@ -695,10 +695,7 @@ + #if defined (__UTYPE_OSX) && !defined (HAVE_UUID) + # define HAVE_UUID 1 + #endif +-#if defined (__UTYPE_FREEBSD) && !defined (HAVE_UUID) +-# define HAVE_UUID 1 +-#endif +-#if defined (HAVE_UUID) ++#if defined (HAVE_UUID) || defined (__UTYPE_FREEBSD) + # if defined (__UTYPE_FREEBSD) || defined (__UTYPE_NETBSD) || defined(__UTYPE_OPENBSD) + # include + # elif defined __UTYPE_HPUX +--- a/src/zuuid.c ++++ b/src/zuuid.c +@@ -47,7 +47,7 @@ + assert (sizeof (uuid) == ZUUID_LEN); + UuidCreate (&uuid); + zuuid_set (self, (byte *) &uuid); +-#elif defined (HAVE_UUID) && !defined (__UTYPE_FREEBSD) ++#elif defined (HAVE_UUID) + uuid_t uuid; + assert (sizeof (uuid) == ZUUID_LEN); + uuid_generate (uuid); diff -Nru czmq-4.1.0/debian/patches/series czmq-4.1.1/debian/patches/series --- czmq-4.1.0/debian/patches/series 2018-01-01 18:41:04.000000000 +0000 +++ czmq-4.1.1/debian/patches/series 2018-04-29 15:48:36.000000000 +0000 @@ -1 +1 @@ -0001-fix-hurd-ftbfs.patch +0001-fix-kfreebsd-ftbfs.patch diff -Nru czmq-4.1.0/doc/Makefile.am czmq-4.1.1/doc/Makefile.am --- czmq-4.1.0/doc/Makefile.am 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/doc/Makefile.am 2018-03-22 22:18:37.000000000 +0000 @@ -42,9 +42,9 @@ asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \ -aczmq_version=@PACKAGE_VERSION@ -o$@ $< .xml.1: - xmlto man $< + xmlto -o $(@D) man $< .xml.3: - xmlto man $< + xmlto -o $(@D) man $< # Special handling for project overview whose basename may collide # with a main or class name @@ -52,7 +52,7 @@ asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \ -aczmq_version=@PACKAGE_VERSION@ -o$@ $< .xml7.7: - xmlto man $< + xmlto -o $(@D) man $< # List of *.txt and *.doc files generated during build from comments # in project program source files and further processed into manpages. @@ -200,8 +200,12 @@ zrex.txt: $(top_srcdir)/src/zrex.c "$(srcdir)/mkman" "zrex" "$(builddir)/zrex.txt" "$(srcdir)/.." +### Note: for mains, we keep the source name rather than flattened name:c +### so that the manpages for binary programs match their name, at expense +### of perhaps being built in a subdirectory under doc/. GENERATED_DOCS += zmakecert.txt zmakecert.doc zmakecert.txt: $(top_srcdir)/src/zmakecert.c + mkdir -p "$(builddir)/$(@D)" "$(srcdir)/mkman" "zmakecert" "$(builddir)/zmakecert.txt" "$(srcdir)/.." diff -Nru czmq-4.1.0/doc/Makefile.in czmq-4.1.1/doc/Makefile.in --- czmq-4.1.0/doc/Makefile.in 2017-12-31 16:39:55.000000000 +0000 +++ czmq-4.1.1/doc/Makefile.in 2018-03-22 22:20:20.000000000 +0000 @@ -166,6 +166,7 @@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CLANG_FORMAT = @CLANG_FORMAT@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ @@ -221,6 +222,8 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +WITH_CLANG_FORMAT = @WITH_CLANG_FORMAT@ +WITH_CPPCHECK = @WITH_CPPCHECK@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -314,6 +317,10 @@ # List of *.txt and *.doc files generated during build from comments # in project program source files and further processed into manpages. + +### Note: for mains, we keep the source name rather than flattened name:c +### so that the manpages for binary programs match their name, at expense +### of perhaps being built in a subdirectory under doc/. @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 \ @@ -681,9 +688,9 @@ @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@ xmlto -o $(@D) man $< @BUILD_DOC_TRUE@.xml.3: -@BUILD_DOC_TRUE@ xmlto man $< +@BUILD_DOC_TRUE@ xmlto -o $(@D) man $< # Special handling for project overview whose basename may collide # with a main or class name @@ -691,7 +698,7 @@ @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 $< +@BUILD_DOC_TRUE@ xmlto -o $(@D) man $< # No-op, docs and texts are generated by mkman in one shot - just # make a dependency that can not parallelize and break stuff. @@ -767,6 +774,7 @@ @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@ mkdir -p "$(builddir)/$(@D)" @BUILD_DOC_TRUE@ "$(srcdir)/mkman" "zmakecert" "$(builddir)/zmakecert.txt" "$(srcdir)/.." @BUILD_DOC_TRUE@clean-local: diff -Nru czmq-4.1.0/doc/mkman czmq-4.1.1/doc/mkman --- czmq-4.1.0/doc/mkman 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/doc/mkman 2018-03-22 22:18:37.000000000 +0000 @@ -93,7 +93,7 @@ $cat_text = "Program for "; last; } - elsif (/MAN3.*$name\.3/) { + elsif (/MAN3.*$outp_basename\.3/) { $source = "$rootsrcdir/src/$name.c"; $header = "$rootsrcdir/include/$name.h"; $cat = 3; diff -Nru czmq-4.1.0/include/czmq_library.h czmq-4.1.1/include/czmq_library.h --- czmq-4.1.0/include/czmq_library.h 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/include/czmq_library.h 2018-03-22 22:18:37.000000000 +0000 @@ -28,7 +28,7 @@ // 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_VERSION_PATCH 1 #define CZMQ_MAKE_VERSION(major, minor, patch) \ ((major) * 10000 + (minor) * 100 + (patch)) @@ -176,9 +176,18 @@ #endif // CZMQ_BUILD_DRAFT_API #ifdef CZMQ_BUILD_DRAFT_API + +#ifdef __cplusplus +extern "C" { +#endif + // Self test for private classes CZMQ_EXPORT void - czmq_private_selftest (bool verbose); + czmq_private_selftest (bool verbose, const char *subtest); + +#ifdef __cplusplus +} +#endif #endif // CZMQ_BUILD_DRAFT_API #endif diff -Nru czmq-4.1.0/include/czmq_prelude.h czmq-4.1.1/include/czmq_prelude.h --- czmq-4.1.0/include/czmq_prelude.h 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/include/czmq_prelude.h 2018-03-22 22:18:37.000000000 +0000 @@ -386,6 +386,16 @@ # define S_ISREG(m) (((m) & S_IFREG) != 0) #endif +#if defined (_MAX_PATH) && !defined (PATH_MAX) +# define PATH_MAX _MAX_PATH +#endif +#if !defined (PATH_MAX) +# define PATH_MAX 1024 +#endif + +#if defined (WIN32) +# define getcwd _getcwd +#endif //- Check compiler data type sizes ------------------------------------------ @@ -525,8 +535,10 @@ # if (!defined (__cplusplus) && (!defined (inline))) # define inline __inline # endif -# define strtoull _strtoui64 -# define atoll _atoi64 +# if (!defined (__MINGW32__)) +# define strtoull _strtoui64 +# define atoll _atoi64 +# endif # define srandom srand # define TIMEZONE _timezone # if (!defined (__MINGW32__)) @@ -683,6 +695,9 @@ #if defined (__UTYPE_OSX) && !defined (HAVE_UUID) # define HAVE_UUID 1 #endif +#if defined (__UTYPE_FREEBSD) && !defined (HAVE_UUID) +# define HAVE_UUID 1 +#endif #if defined (HAVE_UUID) # if defined (__UTYPE_FREEBSD) || defined (__UTYPE_NETBSD) || defined(__UTYPE_OPENBSD) # include diff -Nru czmq-4.1.0/include/Makefile.am czmq-4.1.1/include/Makefile.am --- czmq-4.1.0/include/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ czmq-4.1.1/include/Makefile.am 2018-03-22 22:18:37.000000000 +0000 @@ -0,0 +1,53 @@ +################################################################################ +# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # +# Read the zproject/README.md for information about making permanent changes. # +################################################################################ +include_HEADERS = \ + czmq_prelude.h \ + czmq.h \ + zactor.h \ + zarmour.h \ + zcert.h \ + zcertstore.h \ + zchunk.h \ + zclock.h \ + zconfig.h \ + zdigest.h \ + zdir.h \ + zdir_patch.h \ + zfile.h \ + zframe.h \ + zhash.h \ + zhashx.h \ + ziflist.h \ + zlist.h \ + zlistx.h \ + zloop.h \ + zmsg.h \ + zpoller.h \ + zsock.h \ + zstr.h \ + zsys.h \ + zuuid.h \ + zauth.h \ + zbeacon.h \ + zgossip.h \ + zmonitor.h \ + zproxy.h \ + zrex.h \ + czmq_library.h + +if ENABLE_DRAFTS +include_HEADERS += \ + zargs.h \ + zproc.h \ + ztimerset.h \ + ztrie.h + +endif + + +################################################################################ +# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # +# Read the zproject/README.md for information about making permanent changes. # +################################################################################ diff -Nru czmq-4.1.0/include/Makefile.in czmq-4.1.1/include/Makefile.in --- czmq-4.1.0/include/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ czmq-4.1.1/include/Makefile.in 2018-03-22 22:20:20.000000000 +0000 @@ -0,0 +1,603 @@ +# 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@ +@ENABLE_DRAFTS_TRUE@am__append_1 = \ +@ENABLE_DRAFTS_TRUE@ zargs.h \ +@ENABLE_DRAFTS_TRUE@ zproc.h \ +@ENABLE_DRAFTS_TRUE@ ztimerset.h \ +@ENABLE_DRAFTS_TRUE@ ztrie.h + +subdir = include +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(am__include_HEADERS_DIST) +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__include_HEADERS_DIST = czmq_prelude.h czmq.h zactor.h zarmour.h \ + zcert.h zcertstore.h zchunk.h zclock.h zconfig.h zdigest.h \ + zdir.h zdir_patch.h zfile.h zframe.h zhash.h zhashx.h \ + ziflist.h zlist.h zlistx.h zloop.h zmsg.h zpoller.h zsock.h \ + zstr.h zsys.h zuuid.h zauth.h zbeacon.h zgossip.h zmonitor.h \ + zproxy.h zrex.h czmq_library.h zargs.h zproc.h ztimerset.h \ + ztrie.h +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)$(includedir)" +HEADERS = $(include_HEADERS) +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 +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@ +CLANG_FORMAT = @CLANG_FORMAT@ +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@ +WITH_CLANG_FORMAT = @WITH_CLANG_FORMAT@ +WITH_CPPCHECK = @WITH_CPPCHECK@ +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@ + +################################################################################ +# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # +# Read the zproject/README.md for information about making permanent changes. # +################################################################################ +include_HEADERS = czmq_prelude.h czmq.h zactor.h zarmour.h zcert.h \ + zcertstore.h zchunk.h zclock.h zconfig.h zdigest.h zdir.h \ + zdir_patch.h zfile.h zframe.h zhash.h zhashx.h ziflist.h \ + zlist.h zlistx.h zloop.h zmsg.h zpoller.h zsock.h zstr.h \ + zsys.h zuuid.h zauth.h zbeacon.h zgossip.h zmonitor.h zproxy.h \ + zrex.h czmq_library.h $(am__append_1) +all: all-am + +.SUFFIXES: +$(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 include/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign include/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-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) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(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-am + +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" +cscopelist: cscopelist-am + +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 + +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 +check-am: all-am +check: check-am +all-am: Makefile $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-includeHEADERS + +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-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-includeHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libtool cscopelist-am ctags ctags-am distclean \ + distclean-generic distclean-libtool distclean-tags 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-includeHEADERS install-info install-info-am \ + install-man 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 tags-am uninstall uninstall-am \ + uninstall-includeHEADERS + + +################################################################################ +# 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: diff -Nru czmq-4.1.0/include/zactor.h czmq-4.1.1/include/zactor.h --- czmq-4.1.0/include/zactor.h 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/include/zactor.h 2018-03-22 22:18:37.000000000 +0000 @@ -73,8 +73,8 @@ // // An example - to send $KTHXBAI string // -// if (zstr_send (self->pipe, "$KTHXBAI") == 0) -// zsock_wait (self->pipe); +// if (zstr_send (self, "$KTHXBAI") == 0) +// zsock_wait (self); typedef void (zactor_destructor_fn) ( zactor_t *self); diff -Nru czmq-4.1.0/include/zproc.h czmq-4.1.1/include/zproc.h --- czmq-4.1.0/include/zproc.h 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/include/zproc.h 2018-03-22 22:18:37.000000000 +0000 @@ -39,15 +39,28 @@ zproc_destroy (zproc_t **self_p); // *** Draft method, for development use, may change without warning *** +// Return command line arguments (the first item is the executable) or +// NULL if not set. +// Caller owns return value and must destroy it when done. +CZMQ_EXPORT zlist_t * + zproc_args (zproc_t *self); + +// *** 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); + zproc_set_args (zproc_t *self, zlist_t **arguments); + +// *** Draft method, for development use, may change without warning *** +// Setup the command line arguments, the first item must be an (absolute) filename +// to run. Variadic function, must be NULL terminated. +CZMQ_EXPORT void + zproc_set_argsx (zproc_t *self, const char *arguments, ...); // *** 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); + zproc_set_env (zproc_t *self, zhash_t **arguments); // *** Draft method, for development use, may change without warning *** // Connects process stdin with a readable ('>', connect) zeromq socket. If @@ -89,7 +102,7 @@ zproc_stderr (zproc_t *self); // *** Draft method, for development use, may change without warning *** -// Starts the process. +// Starts the process, return just before execve/CreateProcess. CZMQ_EXPORT int zproc_run (zproc_t *self); @@ -129,132 +142,6 @@ 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); diff -Nru czmq-4.1.0/include/zsys.h czmq-4.1.1/include/zsys.h --- czmq-4.1.0/include/zsys.h 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/include/zsys.h 2018-03-22 22:18:37.000000000 +0000 @@ -404,6 +404,32 @@ #ifdef CZMQ_BUILD_DRAFT_API // *** Draft method, for development use, may change without warning *** +// Check if default interrupt handler of Ctrl-C or SIGTERM was called. +// Does not work if ZSYS_SIGHANDLER is false and code does not call +// set interrupted on signal. +CZMQ_EXPORT bool + zsys_is_interrupted (void); + +// *** Draft method, for development use, may change without warning *** +// Set interrupted flag. This is done by default signal handler, however +// this can be handy for language bindings or cases without default +// signal handler. +CZMQ_EXPORT void + zsys_set_interrupted (void); + +// *** Draft method, for development use, may change without warning *** +// Configure whether to use zero copy strategy in libzmq. If the environment +// variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. +// Otherwise the default is 1. +CZMQ_EXPORT void + zsys_set_zero_copy_recv (int zero_copy); + +// *** Draft method, for development use, may change without warning *** +// Return ZMQ_ZERO_COPY_RECV option. +CZMQ_EXPORT int + zsys_zero_copy_recv (void); + +// *** 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. diff -Nru czmq-4.1.0/Makefile.am czmq-4.1.1/Makefile.am --- czmq-4.1.0/Makefile.am 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/Makefile.am 2018-03-22 22:18:37.000000000 +0000 @@ -19,7 +19,10 @@ project_libs = ${libzmq_LIBS} ${uuid_LIBS} ${systemd_LIBS} ${lz4_LIBS} SUBDIRS = doc +SUBDIRS += include DIST_SUBDIRS = doc +DIST_SUBDIRS += include + lib_LTLIBRARIES = bin_PROGRAMS = noinst_PROGRAMS = diff -Nru czmq-4.1.0/Makefile.in czmq-4.1.1/Makefile.in --- czmq-4.1.0/Makefile.in 2017-12-31 16:39:55.000000000 +0000 +++ czmq-4.1.1/Makefile.in 2018-03-22 22:20:20.000000000 +0000 @@ -23,7 +23,6 @@ - VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' am__make_running_with_option = \ @@ -105,39 +104,34 @@ $(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 \ + $(dist_api_DATA) $(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@am__append_3 = 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@am__append_4 = \ @ON_MINGW_TRUE@ -no-undefined \ @ON_MINGW_TRUE@ -avoid-version -@ON_CYGWIN_TRUE@am__append_6 = \ +@ON_CYGWIN_TRUE@am__append_5 = \ @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_ZMAKECERT_TRUE@am__append_6 = src/zmakecert +@ENABLE_ZSP_TRUE@am__append_7 = src/zsp +@ENABLE_TEST_RANDOF_TRUE@am__append_8 = src/test_randof +@ENABLE_CZMQ_SELFTEST_TRUE@am__append_9 = src/czmq_selftest @ENABLE_CZMQ_SELFTEST_TRUE@am__append_10 = src/czmq_selftest -@ENABLE_CZMQ_SELFTEST_TRUE@am__append_11 = src/czmq_selftest +@WITH_CLANG_FORMAT_TRUE@am__append_11 = clang-format-check # Android-qt requires this special link dependency @ON_ANDROID_TRUE@am__append_12 = -llog @@ -185,8 +179,7 @@ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ - "$(DESTDIR)$(apidir)" "$(DESTDIR)$(pkgconfigdir)" \ - "$(DESTDIR)$(includedir)" + "$(DESTDIR)$(apidir)" "$(DESTDIR)$(pkgconfigdir)" LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -321,20 +314,6 @@ *) (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 = \ @@ -596,6 +575,7 @@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CLANG_FORMAT = @CLANG_FORMAT@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ @@ -651,6 +631,8 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +WITH_CLANG_FORMAT = @WITH_CLANG_FORMAT@ +WITH_CPPCHECK = @WITH_CPPCHECK@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -732,8 +714,8 @@ -I$(srcdir)/include project_libs = ${libzmq_LIBS} ${uuid_LIBS} ${systemd_LIBS} ${lz4_LIBS} -SUBDIRS = doc -DIST_SUBDIRS = doc +SUBDIRS = doc include +DIST_SUBDIRS = doc include lib_LTLIBRARIES = src/libczmq.la noinst_LTLIBRARIES = # Prepare variables that can be populated (appended) in generated Makefiles or @@ -756,18 +738,6 @@ ################################################################################ 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 \ @@ -780,10 +750,10 @@ 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/platform.h $(am__append_3) src_libczmq_la_CPPFLAGS = ${AM_CPPFLAGS} src_libczmq_la_LDFLAGS = -version-info @LTVER@ \ - $(LIBTOOL_EXTRA_LDFLAGS) $(am__append_5) $(am__append_6) + $(LIBTOOL_EXTRA_LDFLAGS) $(am__append_4) $(am__append_5) 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} @@ -805,6 +775,7 @@ # Install api files into /usr/local/share/zproject apidir = @datadir@/zproject/czmq dist_api_DATA = \ + api/python_cffi.slurp \ api/zactor.api \ api/zargs.api \ api/zarmour.api \ @@ -849,6 +820,38 @@ # The RW directory will be automatically wiped by "make distclean". SELFTEST_DIR_RO = src/selftest-ro SELFTEST_DIR_RW = src/selftest-rw + +# A series of tests that the codebase and recipes are pretty, easy +# to maintain and with predictable behavior. These generally are not +# expected to directly expose functional issues in the code, but +# still - there can be many reasons for failing such tests, and +# many lurking issues uncoverable by making code stylish again. +CHECK_STYLE_DEPS = check-gitignore $(am__append_11) +@WITH_CLANG_FORMAT_TRUE@ALL_SOURCE_FILES = $(wildcard \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/src/*.c \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/src/*.cc \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/src/*.cpp \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/src/*.h \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/src/*.hpp \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tests/*.c \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tests/*.cc \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tests/*.cpp \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tests/*.h \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tests/*.hpp \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/perf/*.c \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/perf/*.cc \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/perf/*.cpp \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/perf/*.h \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/perf/*.hpp \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tools/*.c \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tools/*.cc \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tools/*.cpp \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tools/*.h \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/tools/*.hpp \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/include/*.h \ +@WITH_CLANG_FORMAT_TRUE@ $(top_srcdir)/include/*.hpp \ +@WITH_CLANG_FORMAT_TRUE@ ) + all: all-recursive .SUFFIXES: @@ -1556,27 +1559,6 @@ @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. @@ -2031,12 +2013,12 @@ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local check: check-recursive -all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) $(HEADERS) +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) install-binPROGRAMS: install-libLTLIBRARIES installdirs: installdirs-recursive installdirs-am: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(apidir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)"; do \ + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(apidir)" "$(DESTDIR)$(pkgconfigdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive @@ -2101,8 +2083,7 @@ info-am: -install-data-am: install-dist_apiDATA install-includeHEADERS \ - install-pkgconfigDATA +install-data-am: install-dist_apiDATA install-pkgconfigDATA install-dvi: install-dvi-recursive @@ -2151,8 +2132,7 @@ ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-dist_apiDATA \ - uninstall-includeHEADERS uninstall-libLTLIBRARIES \ - uninstall-pkgconfigDATA + uninstall-libLTLIBRARIES uninstall-pkgconfigDATA .MAKE: $(am__recursive_targets) check-am install-am install-strip @@ -2169,15 +2149,14 @@ 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 \ + install-html-am 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-libLTLIBRARIES uninstall-pkgconfigDATA @@ -2309,12 +2288,131 @@ @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 +check-style: $(CHECK_STYLE_DEPS) + +# Check if any sources need to be fixed, report the filenames and an error code +@WITH_CLANG_FORMAT_TRUE@clang-format-check: $(ALL_SOURCE_FILES) +@WITH_CLANG_FORMAT_TRUE@ @if test -z "$(CLANG_FORMAT)" ; then \ +@WITH_CLANG_FORMAT_TRUE@ echo "FAILURE: CLANG_FORMAT program was not specified or found" >&2 ; \ +@WITH_CLANG_FORMAT_TRUE@ exit 1 ; \ +@WITH_CLANG_FORMAT_TRUE@ fi +@WITH_CLANG_FORMAT_TRUE@ @FAILED=0 ; IFS=";" ; IDS="`printf '\n\b'`" ; export IFS IDS; \ +@WITH_CLANG_FORMAT_TRUE@ for FILE in $(ALL_SOURCE_FILES) ; do \ +@WITH_CLANG_FORMAT_TRUE@ test -s $$FILE || continue ; \ +@WITH_CLANG_FORMAT_TRUE@ $(CLANG_FORMAT) -style=file -output-replacements-xml "$$FILE" | grep "/dev/null && \ +@WITH_CLANG_FORMAT_TRUE@ { echo "$$FILE is not correctly formatted" >&2 ; FAILED=1; } ; \ +@WITH_CLANG_FORMAT_TRUE@ done; \ +@WITH_CLANG_FORMAT_TRUE@ if test "$$FAILED" != 0 ; then \ +@WITH_CLANG_FORMAT_TRUE@ exit 1 ; \ +@WITH_CLANG_FORMAT_TRUE@ fi + +# Change source formatting +@WITH_CLANG_FORMAT_TRUE@clang-format: $(ALL_SOURCE_FILES) +@WITH_CLANG_FORMAT_TRUE@ @if test -z "$(CLANG_FORMAT)" ; then \ +@WITH_CLANG_FORMAT_TRUE@ echo "FAILURE: CLANG_FORMAT program was not specified or found" >&2 ; \ +@WITH_CLANG_FORMAT_TRUE@ exit 1 ; \ +@WITH_CLANG_FORMAT_TRUE@ fi +@WITH_CLANG_FORMAT_TRUE@ $(CLANG_FORMAT) -style=file -i $(ALL_SOURCE_FILES) + +# Change source formatting AND report the diff +@WITH_CLANG_FORMAT_TRUE@clang-format-diff: clang-format +@WITH_CLANG_FORMAT_TRUE@ git diff $(ALL_SOURCE_FILES) + +# A destructive (will change code in workspace) but informative check; this is +# primarily intended for CI temporary workspaces where mutilation is acceptable. +# The envvar/makearg CI_REQUIRE_GOOD_CLANG_FORMAT manages if this test is fatal. +@WITH_CLANG_FORMAT_TRUE@clang-format-check-CI: +@WITH_CLANG_FORMAT_TRUE@ @echo "CI-checking code style ..." >&2 +@WITH_CLANG_FORMAT_TRUE@ @if $(MAKE) clang-format-check ; then \ +@WITH_CLANG_FORMAT_TRUE@ echo "SUCCESS : Style checks have passed" >&2 ; \ +@WITH_CLANG_FORMAT_TRUE@ else \ +@WITH_CLANG_FORMAT_TRUE@ echo "" >&2 ; \ +@WITH_CLANG_FORMAT_TRUE@ if test -n "$(CLANG_FORMAT)" ; then \ +@WITH_CLANG_FORMAT_TRUE@ echo "Style mismatches were found by clang-format; detailing below:" >&2 ; \ +@WITH_CLANG_FORMAT_TRUE@ $(MAKE) VERBOSE=1 clang-format-diff ; \ +@WITH_CLANG_FORMAT_TRUE@ fi ; \ +@WITH_CLANG_FORMAT_TRUE@ if test x"$(CI_REQUIRE_GOOD_CLANG_FORMAT)" = xtrue ; then \ +@WITH_CLANG_FORMAT_TRUE@ echo "FAILED : Style checks have failed and CI_REQUIRE_GOOD_CLANG_FORMAT==true" >&2 ; \ +@WITH_CLANG_FORMAT_TRUE@ exit 1 ; \ +@WITH_CLANG_FORMAT_TRUE@ fi ; \ +@WITH_CLANG_FORMAT_TRUE@ echo "WARNING : Style checks have failed, but the result is not-fatal because CI_REQUIRE_GOOD_CLANG_FORMAT!=true" >&2 ; \ +@WITH_CLANG_FORMAT_TRUE@ fi + +@WITH_CLANG_FORMAT_FALSE@clang-format clang-format-check clang-format-diff: +@WITH_CLANG_FORMAT_FALSE@ @echo "Install the clang-format program, reconfigure and re-run this request" +@WITH_CLANG_FORMAT_FALSE@ @exit 1 + +@WITH_CLANG_FORMAT_FALSE@clang-format-check-CI: +@WITH_CLANG_FORMAT_FALSE@ @echo "Install the clang-format program, reconfigure and re-run this request" +@WITH_CLANG_FORMAT_FALSE@ @if test x"$(CI_REQUIRE_GOOD_CLANG_FORMAT)" = xtrue ; then \ +@WITH_CLANG_FORMAT_FALSE@ echo "FAILED : Style checks have failed and CI_REQUIRE_GOOD_CLANG_FORMAT==true" >&2 ; \ +@WITH_CLANG_FORMAT_FALSE@ exit 1 ; \ +@WITH_CLANG_FORMAT_FALSE@ fi ; \ +@WITH_CLANG_FORMAT_FALSE@ echo "WARNING : Style checks have failed, but the result is not-fatal because CI_REQUIRE_GOOD_CLANG_FORMAT!=true" >&2 + +# Note: analysis is not a target executed by default, so there is no +# safety-net for the "cppcheck.xml" recipe; there is one for the wrapper. +# A developer is expected to install tools in build environment, if needed. +# The results can be used to produce some statistics how project quality +# changes over many builds (with a relevant Jenkins plugin, for example). +@WITH_CPPCHECK_TRUE@cppcheck: cppcheck.xml +@WITH_CPPCHECK_FALSE@cppcheck: +@WITH_CPPCHECK_FALSE@ @echo "NOT ENABLED: cppcheck static analysis. Please install the toolkit and reconfigure, and/or make cppcheck.xml directly." + +cppcheck.xml: + @echo "Performing cppcheck static analysis..." + cppcheck --enable=all --inconclusive --xml --xml-version=2 . 2>"$@" + @echo "The cppcheck static analysis is done" + +# Note: this recipe tests that the Git-based workspace reports no changed +# or untracked files - meaning there are no unexpected behaviors in the +# recipes (when checking after a build), and nothing was missed while +# updating the project structure (when checking in the midst of development +# or after regenerating the zproject skeletons), for example. For best +# results, developers are advised to also run this after executing their +# tests, to make sure they are stateless and clean as well. Caller may +# export envvar (or pass make argument) CI_REQUIRE_GOOD_GITIGNORE=false +# to explicitly disable fatality of this check, while still logging it. + +# This recipe is "stateless" by itself, not causing any workspace changes: +check-gitignore: + @(if which git >/dev/null 2>&1 ; then \ + RES=0; \ + echo "Checking for untracked and not-ignored files in the workspace (should have no output below)..."; \ + git status -s | egrep '^\?\? ' && RES=1 ; \ + echo "Checking for modified tracked files in the workspace (should have no output below)..."; \ + git status -s | egrep '^ *M ' && RES=1 && git diff | cat ; \ + if [ "$$RES" = 0 ]; then \ + echo "PASS: $@"; exit 0 ; \ + else \ + if [ x"$(CI_REQUIRE_GOOD_GITIGNORE)" = xfalse ] ; then \ + echo "WARNING: $@ found newly changed or untracked and not-ignored files (not a test failure due to CI_REQUIRE_GOOD_GITIGNORE==false)"; exit 0 ; \ + fi; \ + echo "FAIL: $@ (see workspace checks above)"; exit 1; \ + fi; \ + else \ + echo "SKIP: $@ (no git)"; exit 0 ; \ + fi ) + +# This calls the recipe above after building the project products and +# the selftest binary, and preparing the workspace for self-testing: +check-gitignore-all: all src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) + $@$(MAKE) check-gitignore ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # ################################################################################ +# Make sure there is the helper utility for the zproc tests +@ENABLE_ZSP_TRUE@coverage \ +@ENABLE_ZSP_TRUE@ check-local check-verbose \ +@ENABLE_ZSP_TRUE@ memcheck memcheck-verbose \ +@ENABLE_ZSP_TRUE@ debug debug-verbose \ +@ENABLE_ZSP_TRUE@ callcheck callcheck-verbose \ +@ENABLE_ZSP_TRUE@ animate animate-verbose \ +@ENABLE_ZSP_TRUE@ : src/zsp + check-py: src/libczmq.la $(LIBTOOL) --mode=execute -dlopen src/libczmq.la python bindings/python/test.py diff -Nru czmq-4.1.0/NEWS czmq-4.1.1/NEWS --- czmq-4.1.0/NEWS 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/NEWS 2018-03-22 22:18:37.000000000 +0000 @@ -1,3 +1,75 @@ +CZMQ version 4.1.1 stable, released on 2018/03/22 +================================================= + +* New DRAFT APIs have been added to the zsys class to get and set + the zsys_interrupted global variable: + - zsys_is_interrupted + - zsys_set_interrupted + The following DRAFT APIs wrap a new libzmq context API (minimum + libzmq version with DRAFTs enabled required: 4.2.4): + - zsys_set_zero_copy_recv + - zsys_zero_copy_recv + See zsys manpage for more info. + +* New DRAFT APIs have been added to the zproc class to set and get + the command line arguments string: + - zproc_args + - zproc_set_argsx + The zproc_set_args and zproc_set_env DRAFT APIs have had their + signature changed. + See the zproc manpage for more details. + +* Existing DRAFT APIs have been deleted from to the zproc class as they + are redundant and already offered by zsys: + - zproc_log_debug + - zproc_log_info + - zproc_log_notice + - zproc_log_warning + - zproc_log_error + - zproc_set_log_system + - zproc_set_log_sender + - zproc_set_log_ident + - zproc_biface + - zproc_set_biface + - zproc_set_max_sockets + - zproc_set_io_threads + - zproc_run_as + - zproc_daemonize + - zproc_hostname + - zproc_has_curve + - zproc_interrupted + - zproc_czmq_version + +* Exising DRAFT APIs to create DRAFT sockets will now return ENOTSUP + instead of EINVAL when libzmq does not support the socket type: + - zsock_new_server + - zsock_new_client + - zsock_new_radio + - zsock_new_dish + - zsock_new_scatter + - zsock_new_gather + - zsock_join + - zsock_leave + +* Fixed #1828 - fix build on GNU/Hurd + +* Fixed #1829 - fix build on FreeBSD 10.4 and 11.1 + +* Fixed #1840 - implement basic zproc support for Windows + +* Fixed #1847 - fix test segfault when no USER env variable exists + +* Fixed #1848 - fix zsock_resolve when using many thousands of sockets + +* Fixed #1853 - use SIGTERM on Windows as SIGKILL does not exist + +* Fixed #1858 - fix build on MINGGW + +* Fixed #1875 - fix build with GCC 8 + +* Fixed #1876 - fix crash in zsys_shutdown with libzmq 4.2.4 built with + Tweetnacl + CZMQ version 4.1.0 stable, released on 2017/12/31 ================================================= diff -Nru czmq-4.1.0/src/czmq_classes.h czmq-4.1.1/src/czmq_classes.h --- czmq-4.1.0/src/czmq_classes.h 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/czmq_classes.h 2018-03-22 22:18:37.000000000 +0000 @@ -44,8 +44,8 @@ // // An example - to send $KTHXBAI string // -// if (zstr_send (self->pipe, "$KTHXBAI") == 0) -// zsock_wait (self->pipe); +// if (zstr_send (self, "$KTHXBAI") == 0) +// zsock_wait (self); typedef void (zactor_destructor_fn) ( zactor_t *self); @@ -270,6 +270,32 @@ zstr_str (void *source); // *** Draft method, defined for internal use only *** +// Check if default interrupt handler of Ctrl-C or SIGTERM was called. +// Does not work if ZSYS_SIGHANDLER is false and code does not call +// set interrupted on signal. +CZMQ_PRIVATE bool + zsys_is_interrupted (void); + +// *** Draft method, defined for internal use only *** +// Set interrupted flag. This is done by default signal handler, however +// this can be handy for language bindings or cases without default +// signal handler. +CZMQ_PRIVATE void + zsys_set_interrupted (void); + +// *** Draft method, defined for internal use only *** +// Configure whether to use zero copy strategy in libzmq. If the environment +// variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. +// Otherwise the default is 1. +CZMQ_PRIVATE void + zsys_set_zero_copy_recv (int zero_copy); + +// *** Draft method, defined for internal use only *** +// Return ZMQ_ZERO_COPY_RECV option. +CZMQ_PRIVATE int + zsys_zero_copy_recv (void); + +// *** 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. @@ -381,7 +407,7 @@ // Self test for private classes CZMQ_PRIVATE void - czmq_private_selftest (bool verbose); + czmq_private_selftest (bool verbose, const char *subtest); #endif // CZMQ_BUILD_DRAFT_API diff -Nru czmq-4.1.0/src/czmq_private_selftest.c czmq-4.1.1/src/czmq_private_selftest.c --- czmq-4.1.0/src/czmq_private_selftest.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/czmq_private_selftest.c 2018-03-22 22:18:37.000000000 +0000 @@ -27,10 +27,11 @@ // void -czmq_private_selftest (bool verbose) +czmq_private_selftest (bool verbose, const char *subtest) { // Tests for stable private classes: - zgossip_msg_test (verbose); + if (streq (subtest, "$ALL") || streq (subtest, "zgossip_msg_test")) + zgossip_msg_test (verbose); } /* ################################################################################ diff -Nru czmq-4.1.0/src/czmq_selftest.c czmq-4.1.1/src/czmq_selftest.c --- czmq-4.1.0/src/czmq_selftest.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/czmq_selftest.c 2018-03-22 22:18:37.000000000 +0000 @@ -21,55 +21,64 @@ #include "czmq_classes.h" +#include +#include + typedef struct { - const char *testname; - void (*test) (bool); + const char *testname; // test name, can be called from command line this way + void (*test) (bool); // function to run the test (or NULL for private tests) + bool stable; // true if class is declared as stable + bool pub; // true if class is declared as public + const char *subtest; // name of private subtest to run } 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 }, + { "zactor", zactor_test, true, true, NULL }, + { "zarmour", zarmour_test, true, true, NULL }, + { "zcert", zcert_test, true, true, NULL }, + { "zcertstore", zcertstore_test, true, true, NULL }, + { "zchunk", zchunk_test, true, true, NULL }, + { "zclock", zclock_test, true, true, NULL }, + { "zconfig", zconfig_test, true, true, NULL }, + { "zdigest", zdigest_test, true, true, NULL }, + { "zdir", zdir_test, true, true, NULL }, + { "zdir_patch", zdir_patch_test, true, true, NULL }, + { "zfile", zfile_test, true, true, NULL }, + { "zframe", zframe_test, true, true, NULL }, + { "zhash", zhash_test, true, true, NULL }, + { "zhashx", zhashx_test, true, true, NULL }, + { "ziflist", ziflist_test, true, true, NULL }, + { "zlist", zlist_test, true, true, NULL }, + { "zlistx", zlistx_test, true, true, NULL }, + { "zloop", zloop_test, true, true, NULL }, + { "zmsg", zmsg_test, true, true, NULL }, + { "zpoller", zpoller_test, true, true, NULL }, + { "zsock", zsock_test, true, true, NULL }, + { "zstr", zstr_test, true, true, NULL }, + { "zsys", zsys_test, true, true, NULL }, + { "zuuid", zuuid_test, true, true, NULL }, + { "zauth", zauth_test, true, true, NULL }, + { "zbeacon", zbeacon_test, true, true, NULL }, + { "zgossip", zgossip_test, true, true, NULL }, + { "zmonitor", zmonitor_test, true, true, NULL }, + { "zproxy", zproxy_test, true, true, NULL }, + { "zrex", zrex_test, true, true, NULL }, #ifdef CZMQ_BUILD_DRAFT_API // Tests for draft public classes: - { "zargs", zargs_test }, - { "zproc", zproc_test }, - { "ztimerset", ztimerset_test }, - { "ztrie", ztrie_test }, + { "zargs", zargs_test, false, true, NULL }, + { "zproc", zproc_test, false, true, NULL }, + { "ztimerset", ztimerset_test, false, true, NULL }, + { "ztrie", ztrie_test, false, true, NULL }, #endif // CZMQ_BUILD_DRAFT_API #ifdef CZMQ_BUILD_DRAFT_API - { "private_classes", czmq_private_selftest }, +// Tests for stable/draft private classes: +// Now built only with --enable-drafts, so even stable builds are hidden behind the flag + { "zgossip_msg", NULL, true, false, "zgossip_msg_test" }, + { "private_classes", NULL, false, false, "$ALL" }, // compat option for older projects #endif // CZMQ_BUILD_DRAFT_API - {0, 0} // Sentinel + {NULL, NULL, 0, 0, NULL} // Sentinel }; // ------------------------------------------------------------------------- @@ -81,8 +90,8 @@ test_available (const char *testname) { test_item_t *item; - for (item = all_tests; item->test; item++) { - if (streq (testname, item->testname)) + for (item = all_tests; item->testname; item++) { + if (strcmp (testname, item->testname) == 0) return item; } return NULL; @@ -97,12 +106,45 @@ { test_item_t *item; printf ("Running czmq selftests...\n"); - for (item = all_tests; item->test; item++) - item->test (verbose); + for (item = all_tests; item->testname; item++) { + if (strcmp (item->testname, "private_classes") == 0) + continue; + if (!item->subtest) + item->test (verbose); +#ifdef CZMQ_BUILD_DRAFT_API // selftest is still in draft + else + czmq_private_selftest (verbose, item->subtest); +#endif // CZMQ_BUILD_DRAFT_API + } printf ("Tests passed OK\n"); } +static void +test_list (void) +{ + test_item_t *item; + puts ("Available tests:"); + for (item = all_tests; item->testname; item++) + printf (" %-40s - %s %s\n", + item->testname, + item->stable ? "stable" : "draft", + item->pub ? "public" : "private" + ); +} + +static void +test_number (void) +{ + int n = 0; + test_item_t *item; + for (item = all_tests; item->testname; item++) { + if (strcmp (item->testname, "private_classes") == 0) + n++; + } + printf ("%d\n", n); +} + int main (int argc, char **argv) { @@ -110,8 +152,8 @@ test_item_t *test = 0; int argn; for (argn = 1; argn < argc; argn++) { - if (streq (argv [argn], "--help") - || streq (argv [argn], "-h")) { + if (strcmp (argv [argn], "--help") == 0 + || strcmp (argv [argn], "-h") == 0) { puts ("czmq_selftest.c [options] ..."); puts (" --verbose / -v verbose test output"); puts (" --number / -n report number of tests"); @@ -120,59 +162,24 @@ puts (" --continue / -c continue on exception (on Windows)"); return 0; } - if (streq (argv [argn], "--verbose") - || streq (argv [argn], "-v")) + if (strcmp (argv [argn], "--verbose") == 0 + || strcmp (argv [argn], "-v") == 0) verbose = true; else - if (streq (argv [argn], "--number") - || streq (argv [argn], "-n")) { - puts ("35"); + if (strcmp (argv [argn], "--number") == 0 + || strcmp (argv [argn], "-n") == 0) { + test_number (); 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"); + if (strcmp (argv [argn], "--list") == 0 + || strcmp (argv [argn], "-l") == 0) { + test_list (); return 0; } else - if (streq (argv [argn], "--test") - || streq (argv [argn], "-t")) { + if (strcmp (argv [argn], "--test") == 0 + || strcmp (argv [argn], "-t") == 0) { argn++; if (argn >= argc) { fprintf (stderr, "--test needs an argument\n"); @@ -185,8 +192,8 @@ } } else - if (streq (argv [argn], "--continue") - || streq (argv [argn], "-c")) { + if (strcmp (argv [argn], "--continue") == 0 + || strcmp (argv [argn], "-c") == 0) { #ifdef _MSC_VER // When receiving an abort signal, only print to stderr (no dialog) _set_abort_behavior (0, _WRITE_ABORT_MSG); @@ -205,7 +212,12 @@ if (test) { printf ("Running czmq test '%s'...\n", test->testname); - test->test (verbose); + if (!test->subtest) + test->test (verbose); +#ifdef CZMQ_BUILD_DRAFT_API // selftest is still in draft + else + czmq_private_selftest (verbose, test->subtest); +#endif // CZMQ_BUILD_DRAFT_API } else test_runall (verbose); diff -Nru czmq-4.1.0/src/Makemodule.am czmq-4.1.1/src/Makemodule.am --- czmq-4.1.0/src/Makemodule.am 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/Makemodule.am 2018-03-22 22:18:37.000000000 +0000 @@ -12,49 +12,6 @@ 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 \ @@ -164,6 +121,7 @@ # Install api files into /usr/local/share/zproject apidir = @datadir@/zproject/czmq dist_api_DATA = \ + api/python_cffi.slurp \ api/zactor.api \ api/zargs.api \ api/zarmour.api \ @@ -347,6 +305,158 @@ @exit 1 endif +# A series of tests that the codebase and recipes are pretty, easy +# to maintain and with predictable behavior. These generally are not +# expected to directly expose functional issues in the code, but +# still - there can be many reasons for failing such tests, and +# many lurking issues uncoverable by making code stylish again. +CHECK_STYLE_DEPS = check-gitignore +if WITH_CLANG_FORMAT +CHECK_STYLE_DEPS += clang-format-check +endif +check-style: $(CHECK_STYLE_DEPS) + +if WITH_CLANG_FORMAT +ALL_SOURCE_FILES = $(wildcard \ + $(top_srcdir)/src/*.c \ + $(top_srcdir)/src/*.cc \ + $(top_srcdir)/src/*.cpp \ + $(top_srcdir)/src/*.h \ + $(top_srcdir)/src/*.hpp \ + $(top_srcdir)/tests/*.c \ + $(top_srcdir)/tests/*.cc \ + $(top_srcdir)/tests/*.cpp \ + $(top_srcdir)/tests/*.h \ + $(top_srcdir)/tests/*.hpp \ + $(top_srcdir)/perf/*.c \ + $(top_srcdir)/perf/*.cc \ + $(top_srcdir)/perf/*.cpp \ + $(top_srcdir)/perf/*.h \ + $(top_srcdir)/perf/*.hpp \ + $(top_srcdir)/tools/*.c \ + $(top_srcdir)/tools/*.cc \ + $(top_srcdir)/tools/*.cpp \ + $(top_srcdir)/tools/*.h \ + $(top_srcdir)/tools/*.hpp \ + $(top_srcdir)/include/*.h \ + $(top_srcdir)/include/*.hpp \ + ) + +# Check if any sources need to be fixed, report the filenames and an error code +clang-format-check: $(ALL_SOURCE_FILES) + @if test -z "$(CLANG_FORMAT)" ; then \ + echo "FAILURE: CLANG_FORMAT program was not specified or found" >&2 ; \ + exit 1 ; \ + fi + @FAILED=0 ; IFS=";" ; IDS="`printf '\n\b'`" ; export IFS IDS; \ + for FILE in $(ALL_SOURCE_FILES) ; do \ + test -s $$FILE || continue ; \ + $(CLANG_FORMAT) -style=file -output-replacements-xml "$$FILE" | grep "/dev/null && \ + { echo "$$FILE is not correctly formatted" >&2 ; FAILED=1; } ; \ + done; \ + if test "$$FAILED" != 0 ; then \ + exit 1 ; \ + fi + +# Change source formatting +clang-format: $(ALL_SOURCE_FILES) + @if test -z "$(CLANG_FORMAT)" ; then \ + echo "FAILURE: CLANG_FORMAT program was not specified or found" >&2 ; \ + exit 1 ; \ + fi + $(CLANG_FORMAT) -style=file -i $(ALL_SOURCE_FILES) + +# Change source formatting AND report the diff +clang-format-diff: clang-format + git diff $(ALL_SOURCE_FILES) + +# A destructive (will change code in workspace) but informative check; this is +# primarily intended for CI temporary workspaces where mutilation is acceptable. +# The envvar/makearg CI_REQUIRE_GOOD_CLANG_FORMAT manages if this test is fatal. +clang-format-check-CI: + @echo "CI-checking code style ..." >&2 + @if $(MAKE) clang-format-check ; then \ + echo "SUCCESS : Style checks have passed" >&2 ; \ + else \ + echo "" >&2 ; \ + if test -n "$(CLANG_FORMAT)" ; then \ + echo "Style mismatches were found by clang-format; detailing below:" >&2 ; \ + $(MAKE) VERBOSE=1 clang-format-diff ; \ + fi ; \ + if test x"$(CI_REQUIRE_GOOD_CLANG_FORMAT)" = xtrue ; then \ + echo "FAILED : Style checks have failed and CI_REQUIRE_GOOD_CLANG_FORMAT==true" >&2 ; \ + exit 1 ; \ + fi ; \ + echo "WARNING : Style checks have failed, but the result is not-fatal because CI_REQUIRE_GOOD_CLANG_FORMAT!=true" >&2 ; \ + fi + +else +clang-format clang-format-check clang-format-diff: + @echo "Install the clang-format program, reconfigure and re-run this request" + @exit 1 + +clang-format-check-CI: + @echo "Install the clang-format program, reconfigure and re-run this request" + @if test x"$(CI_REQUIRE_GOOD_CLANG_FORMAT)" = xtrue ; then \ + echo "FAILED : Style checks have failed and CI_REQUIRE_GOOD_CLANG_FORMAT==true" >&2 ; \ + exit 1 ; \ + fi ; \ + echo "WARNING : Style checks have failed, but the result is not-fatal because CI_REQUIRE_GOOD_CLANG_FORMAT!=true" >&2 +endif + +# Note: analysis is not a target executed by default, so there is no +# safety-net for the "cppcheck.xml" recipe; there is one for the wrapper. +# A developer is expected to install tools in build environment, if needed. +# The results can be used to produce some statistics how project quality +# changes over many builds (with a relevant Jenkins plugin, for example). +if WITH_CPPCHECK +cppcheck: cppcheck.xml +else +cppcheck: + @echo "NOT ENABLED: cppcheck static analysis. Please install the toolkit and reconfigure, and/or make cppcheck.xml directly." +endif + +cppcheck.xml: + @echo "Performing cppcheck static analysis..." + cppcheck --enable=all --inconclusive --xml --xml-version=2 . 2>"$@" + @echo "The cppcheck static analysis is done" + +# Note: this recipe tests that the Git-based workspace reports no changed +# or untracked files - meaning there are no unexpected behaviors in the +# recipes (when checking after a build), and nothing was missed while +# updating the project structure (when checking in the midst of development +# or after regenerating the zproject skeletons), for example. For best +# results, developers are advised to also run this after executing their +# tests, to make sure they are stateless and clean as well. Caller may +# export envvar (or pass make argument) CI_REQUIRE_GOOD_GITIGNORE=false +# to explicitly disable fatality of this check, while still logging it. + +# This recipe is "stateless" by itself, not causing any workspace changes: +check-gitignore: + @(if which git >/dev/null 2>&1 ; then \ + RES=0; \ + echo "Checking for untracked and not-ignored files in the workspace (should have no output below)..."; \ + git status -s | egrep '^\?\? ' && RES=1 ; \ + echo "Checking for modified tracked files in the workspace (should have no output below)..."; \ + git status -s | egrep '^ *M ' && RES=1 && git diff | cat ; \ + if [ "$$RES" = 0 ]; then \ + echo "PASS: $@"; exit 0 ; \ + else \ + if [ x"$(CI_REQUIRE_GOOD_GITIGNORE)" = xfalse ] ; then \ + echo "WARNING: $@ found newly changed or untracked and not-ignored files (not a test failure due to CI_REQUIRE_GOOD_GITIGNORE==false)"; exit 0 ; \ + fi; \ + echo "FAIL: $@ (see workspace checks above)"; exit 1; \ + fi; \ + else \ + echo "SKIP: $@ (no git)"; exit 0 ; \ + fi ) + +# This calls the recipe above after building the project products and +# the selftest binary, and preparing the workspace for self-testing: +check-gitignore-all: all src/czmq_selftest $(top_builddir)/$(SELFTEST_DIR_RW) $(top_builddir)/$(SELFTEST_DIR_RO) + $@$(MAKE) check-gitignore + + ################################################################################ # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # # Read the zproject/README.md for information about making permanent changes. # diff -Nru czmq-4.1.0/src/Makemodule-local.am czmq-4.1.1/src/Makemodule-local.am --- czmq-4.1.0/src/Makemodule-local.am 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/Makemodule-local.am 2018-03-22 22:18:37.000000000 +0000 @@ -11,5 +11,16 @@ src_test_randof_CPPFLAGS += $(test_randof_macros) endif +# Make sure there is the helper utility for the zproc tests +if ENABLE_ZSP +coverage \ + check-local check-verbose \ + memcheck memcheck-verbose \ + debug debug-verbose \ + callcheck callcheck-verbose \ + animate animate-verbose \ + : src/zsp +endif + check-py: src/libczmq.la $(LIBTOOL) --mode=execute -dlopen src/libczmq.la python bindings/python/test.py diff -Nru czmq-4.1.0/src/platform.h czmq-4.1.1/src/platform.h --- czmq-4.1.0/src/platform.h 2017-12-31 16:39:58.000000000 +0000 +++ czmq-4.1.1/src/platform.h 2018-03-22 22:20:23.000000000 +0000 @@ -174,7 +174,7 @@ #define PACKAGE_NAME "czmq" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "czmq 4.1.0" +#define PACKAGE_STRING "czmq 4.1.1" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "czmq" @@ -183,7 +183,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "4.1.0" +#define PACKAGE_VERSION "4.1.1" /* CZMQ major version */ #define PACKAGE_VERSION_MAJOR 4 @@ -192,7 +192,7 @@ #define PACKAGE_VERSION_MINOR 1 /* CZMQ patchlevel */ -#define PACKAGE_VERSION_PATCH 0 +#define PACKAGE_VERSION_PATCH 1 /* Define as the return type of signal handlers (`int' or `void'). */ #define RETSIGTYPE void @@ -204,7 +204,7 @@ #define TIME_WITH_SYS_TIME 1 /* Version number of package */ -#define VERSION "4.1.0" +#define VERSION "4.1.1" /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ diff -Nru czmq-4.1.0/src/zactor.c czmq-4.1.1/src/zactor.c --- czmq-4.1.0/src/zactor.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/zactor.c 2018-03-22 22:18:37.000000000 +0000 @@ -35,7 +35,7 @@ // 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 +#define ZACTOR_TAG 0xcafe0005 // Structure of our class @@ -300,8 +300,33 @@ static void KTHXBAI_destructor (zactor_t *self) { assert (self); - if (zstr_send (self->pipe, "$KTHXBAI") == 0) - zsock_wait (self->pipe); + if (zstr_send (self, "$KTHXBAI") == 0) + zsock_wait (self); +} + +static void +BSEND_actor (zsock_t *pipe, void *args) { + + zsock_signal (pipe, 0); + while (!zsys_interrupted) { + char *str = NULL; + void *ptr = NULL; + int r = zsock_brecv (pipe, "s", &str, &ptr); + if (r == -1) + break; + int done = streq (str, "$TERM"); + if (done) + break; + } +} + +static void +BSEND_destructor (zactor_t *self) { + assert (self); + const char *str = "$TERM"; + const void *ptr = str; + if (zsock_bsend (self, "s", str, ptr) == 0) + zsock_wait (self); } // -------------------------------------------------------------------------- @@ -329,6 +354,12 @@ zactor_set_destructor (KTHXBAI, KTHXBAI_destructor); zactor_destroy (&KTHXBAI); + // custom destructor + // destructor using bsend/brecv + zactor_t *BSEND = zactor_new (BSEND_actor, NULL); + assert (BSEND); + zactor_set_destructor (BSEND, BSEND_destructor); + zactor_destroy (&BSEND); #if defined (__WINDOWS__) zsys_shutdown(); #endif diff -Nru czmq-4.1.0/src/zchunk.c czmq-4.1.1/src/zchunk.c --- czmq-4.1.0/src/zchunk.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/zchunk.c 2018-03-22 22:18:37.000000000 +0000 @@ -23,7 +23,7 @@ // 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 +#define ZCHUNK_TAG 0xcafe0001 // Structure of our class diff -Nru czmq-4.1.0/src/zfile.c czmq-4.1.1/src/zfile.c --- czmq-4.1.0/src/zfile.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/zfile.c 2018-03-22 22:18:37.000000000 +0000 @@ -141,8 +141,18 @@ self->fullname = strdup (name); self->handle = fopen (self->fullname, "w"); #else + +# if (defined (PATH_MAX)) char buffer [PATH_MAX]; - strcpy (buffer, "/tmp/czmq_zfile.XXXXXX"); +# else + # if (defined (_MAX_PATH)) + char buffer [_MAX_PATH]; + # else + char buffer [1024]; + # endif +# endif + memset (buffer, 0, sizeof (buffer)); + strncpy (buffer, "/tmp/czmq_zfile.XXXXXX", sizeof(buffer)-1); int fd = mkstemp (buffer); if (fd == -1) return NULL; diff -Nru czmq-4.1.0/src/zframe.c czmq-4.1.1/src/zframe.c --- czmq-4.1.0/src/zframe.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/zframe.c 2018-03-22 22:18:37.000000000 +0000 @@ -28,7 +28,7 @@ // 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 +#define ZFRAME_TAG 0xcafe0002 // Structure of our class @@ -409,7 +409,7 @@ strcpy (self->group, group); return 0; #else - errno = EINVAL; + errno = ENOTSUP; return -1; #endif } @@ -745,6 +745,12 @@ zsock_destroy (&dish); zsock_destroy (&radio); +#else + frame = zframe_new ("Hello", 5); + rc = zframe_set_group (frame, "World"); + assert(rc == -1); + assert(errno == ENOTSUP); + zframe_destroy (&frame); #endif #if defined (__WINDOWS__) diff -Nru czmq-4.1.0/src/zlistx.c czmq-4.1.1/src/zlistx.c --- czmq-4.1.0/src/zlistx.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/zlistx.c 2018-03-22 22:18:37.000000000 +0000 @@ -26,7 +26,7 @@ #include "czmq_classes.h" -#define NODE_TAG 0x0006cafe +#define NODE_TAG 0xcafe0006 // List node, used internally only diff -Nru czmq-4.1.0/src/zloop.c czmq-4.1.1/src/zloop.c --- czmq-4.1.0/src/zloop.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/zloop.c 2018-03-22 22:18:37.000000000 +0000 @@ -81,7 +81,7 @@ // 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 +#define TICKET_TAG 0xcafe0007 struct _s_ticket_t { uint32_t tag; // Object tag for runtime detection diff -Nru czmq-4.1.0/src/zmsg.c czmq-4.1.1/src/zmsg.c --- czmq-4.1.0/src/zmsg.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/zmsg.c 2018-03-22 22:18:37.000000000 +0000 @@ -25,7 +25,7 @@ // 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 +#define ZMSG_TAG 0xcafe0003 // Structure of our class diff -Nru czmq-4.1.0/src/zproc.c czmq-4.1.1/src/zproc.c --- czmq-4.1.0/src/zproc.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/zproc.c 2018-03-22 22:18:37.000000000 +0000 @@ -1,13 +1,13 @@ /* ========================================================================= 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. - + 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/. + file, You can obtain one at http://mozilla.org/MPL/2.0/. ========================================================================= */ @@ -41,7 +41,7 @@ |zmq://stdin |zmq://stdout |zmq://stderr | | [zproc supervisor] | +----------------------------------------+ - + ----------> zeromq magic here <----------- +----------------------------------------+ @@ -58,6 +58,17 @@ #include "czmq_classes.h" +#if defined (__UNIX__) +# if defined (__UTYPE_OSX) +// issue#1836 +#include +#define environ (*_NSGetEnviron ()) +# else +extern char **environ; // should be declared as a part of unistd.h, but fail in some targets in Travis + // declare it explicitly +# endif +#endif + // For getcwd() variants #if (defined (WIN32)) # include @@ -65,6 +76,10 @@ # include #endif +#if defined (__UTYPE_OSX) +#include +#endif + #define ZPROC_RUNNING -42 // ####### internal helpers for zproc ####### @@ -180,7 +195,9 @@ // ####### internal helpers for zproc ####### struct _zproc_t { -#if ! defined (__WINDOWS__) +#if defined (__WINDOWS__) + PROCESS_INFORMATION piProcInfo; +#else //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; @@ -196,21 +213,19 @@ int stdoutpipe [2]; // stdout pipe int stderrpipe [2]; // stderr pipe + zpair_t *execpair; // pair used to synchronize zproc_run with actor 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 + zlist_t *args; // command line arguments + zhash_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 +#if ZMQ_VERSION_MAJOR < 4 zsys_error ("Cannot use zproc with zmq older than 4"); return NULL; #endif @@ -224,7 +239,18 @@ zproc_t *self = (zproc_t*) zmalloc (sizeof (zproc_t)); self->verbose = false; + self->stdinpipe [0] = -1; + self->stdinpipe [1] = -1; + self->stdoutpipe [0] = -1; + self->stdoutpipe [1] = -1; + self->stderrpipe [0] = -1; + self->stderrpipe [1] = -1; + zuuid_t *uuid = zuuid_new (); + self->execpair = zpair_new ( + zsys_sprintf ("#inproc://zproc-%s-exec", zuuid_str_canonical (uuid)) + ); + zpair_mkpair (self->execpair); self->stdinpair = zpair_new ( zsys_sprintf ("#inproc://zproc-%s-stdin", zuuid_str_canonical (uuid)) ); @@ -239,6 +265,7 @@ return self; } + void zproc_destroy (zproc_t **self_p) { assert (self_p); @@ -247,36 +274,84 @@ 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]); + if (self->stdinpipe [0] != -1) { + close (self->stdinpipe [0]); + close (self->stdinpipe [1]); + } + if (self->stdoutpipe [0] != -1) { + close (self->stdoutpipe [0]); + close (self->stdoutpipe [1]); + } + if (self->stderrpipe [0] != -1) { + close (self->stderrpipe [0]); + close (self->stderrpipe [1]); + } + zpair_destroy (&self->execpair); zpair_destroy (&self->stdinpair); zpair_destroy (&self->stdoutpair); zpair_destroy (&self->stderrpair); - zlistx_destroy (&self->args); - zhashx_destroy (&self->env); - freen (self); + zlist_destroy (&self->args); + zhash_destroy (&self->env); + free (self); *self_p = NULL; } } +// -------------------------------------------------------------------------- +// Return command line arguments (the first item is the executable) or +// NULL if not set. +// Caller owns return value and must destroy it when done. + +zlist_t * +zproc_args (zproc_t *self) +{ + assert (self); + if (self->args) { + zlist_t *args_dup = zlist_dup (self->args); + assert (args_dup); + return args_dup; + } + return NULL; +} + + void -zproc_set_args (zproc_t *self, zlistx_t *args) { +zproc_set_args (zproc_t *self, zlist_t **args_p) { assert (self); - zlistx_destroy (&self->args); + assert (*args_p); + zlist_t *args = *args_p; + zlist_destroy (&self->args); self->args = args; + *args_p = NULL; } +// Setup the command line arguments, the first item must be an (absolute) filename +// to run. Variadic function, must be NULL terminated. void -zproc_set_env (zproc_t *self, zhashx_t *env) { + zproc_set_argsx (zproc_t *self, const char *args, ...) +{ + assert (self); + va_list vargs; + va_start (vargs, args); + zlist_t *zargs = zlist_new (); + zlist_autofree (zargs); + while (args) { + zlist_append (zargs, (void*) args); + args = va_arg (vargs, const char *); + } + zproc_set_args (self, &zargs); +} + +void +zproc_set_env (zproc_t *self, zhash_t **env_p) { assert (self); - zhashx_destroy (&self->env); + assert (*env_p); + zhash_t *env = *env_p; + zhash_destroy (&self->env); self->env = env; + *env_p = NULL; } void @@ -286,7 +361,8 @@ zsys_error ("zproc_set_stdin not implemented for Windows"); return; #else - assert (self->stdinpipe [0] == 0); + if (self->stdinpipe [0] != -1) + return; int r = pipe (self->stdinpipe); assert (r == 0); @@ -304,7 +380,8 @@ zsys_error ("zproc_set_stdout not implemented for Windows"); return; #else - assert (self->stdoutpipe [0] == 0); + if (self->stdoutpipe [0] != -1) + return; int r = pipe (self->stdoutpipe); assert (r == 0); @@ -322,7 +399,8 @@ zsys_error ("zproc_set_stdout not implemented for Windows"); return; #else - assert (self->stderrpipe [0] == 0); + if (self->stderrpipe [0] != -1) + return; int r = pipe (self->stderrpipe); assert (r == 0); @@ -351,22 +429,16 @@ 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); + assert (zproc_pid(self)); 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; + return self->piProcInfo.dwProcessId; #else return self->pid; #endif @@ -376,11 +448,16 @@ static int s_fd_in_handler (zloop_t *self, zmq_pollitem_t *item, void *socket) { -#define BUF_SIZE 1024 +#if defined (PIPE_BUF) +# define BUF_SIZE PIPE_BUF +#else +# define BUF_SIZE 65535 +#endif byte buf [BUF_SIZE]; ssize_t r = 1; while (r > 0) { + memset (buf, '\0', BUF_SIZE); r = read (item->fd, buf, BUF_SIZE); if (r == -1) { zsys_error ("read from fd %d: %s", item->fd, strerror (errno)); @@ -452,18 +529,48 @@ static int s_zproc_execve (zproc_t *self) { + assert (self); #if defined(__WINDOWS__) - zsys_debug ("s_zproc_execve not implemented on Windows"); - return -1; + STARTUPINFOA siStartInfo; + ZeroMemory (&siStartInfo, sizeof (siStartInfo)); + + char *commandline = strdup ((char *)zlist_first (self->args)); + char *arg = (char *) zlist_next (self->args); + while (arg) { + char *tmp = zsys_sprintf ("%s %s", commandline, arg); + zstr_free (&commandline); + commandline = tmp; + arg = (char *) zlist_next (self->args); + } + if (self->verbose) + zsys_debug ("zproc: command to start: %s", commandline); + + siStartInfo.cb = sizeof (siStartInfo); + zsock_signal (zpair_write (self->execpair), 0); + self->running = CreateProcessA( + NULL, // app name + commandline, // command line + NULL, // process security attributes + NULL, // primary thread security attributes + TRUE, // handles are not inherited + 0, // creation flags + NULL, // use parent's environment + NULL , // use parent's current directory + &siStartInfo, // STARTUPINFO pointer + &self->piProcInfo); // receives PROCESS_INFORMATION + WaitForInputIdle (self->piProcInfo.hProcess, 1000); + if (self->verbose) + zsys_debug ("zproc: %s", self->running ? "started" : "failed to start"); + zstr_free (&commandline); + return 0; #else - assert (self); int r; - char *filename = (char*) zlistx_first (self->args); + char *filename = (char*) zlist_first (self->args); self->pid = fork (); if (self->pid == 0) { - - if (self->stdinpipe [0] != 0) { + // Child + if (self->stdinpipe [0] != -1) { int o_flags = fcntl (self->stdinpipe [0], F_GETFL); int n_flags = o_flags & (~O_NONBLOCK); fcntl (self->stdinpipe [0], F_SETFL, n_flags); @@ -472,42 +579,49 @@ } // redirect stdout if set_stdout was called - if (self->stdoutpipe [0] != 0) { + if (self->stdoutpipe [0] != -1) { close (self->stdoutpipe [0]); dup2 (self->stdoutpipe [1], STDOUT_FILENO); } - // redirect stdout if set_stderr was called - if (self->stderrpipe [0] != 0) { + // redirect stderr if set_stderr was called + if (self->stderrpipe [0] != -1) { 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); + char **argv2 = arr_new (zlist_size (self->args) + 1); size_t i = 0; - for (char *arg = (char*) zlistx_first (self->args); + for (char *arg = (char*) zlist_first (self->args); arg != NULL; - arg = (char*) zlistx_next (self->args)) { + arg = (char*) zlist_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); + char **env = NULL; - 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++; + if (self->env) { + env = arr_new (zhash_size (self->env) + 1); + + i = 0; + for (char *arg = (char*) zhash_first (self->env); + arg != NULL; + arg = (char*) zhash_next (self->env)) { + char *name = (char*) zhash_cursor (self->env); + arr_add_ref (env, i, zsys_sprintf ("%s=%s", name, arg)); + i++; + } + arr_add_ref (env, i, NULL); } - arr_add_ref (env, i, NULL); + else + env = environ; + zsock_signal (zpair_write (self->execpair), 0); r = execve (filename, argv2, env); if (r == -1) { zsys_error ("fail to run %s: %s", filename, strerror (errno)); @@ -519,27 +633,29 @@ } else if (self->pid == -1) { + // Error (still in parent) zsys_error ("error fork: %s", strerror (errno)); exit (EXIT_FAILURE); } else { + // Parent if (self->verbose) zsys_debug ("process %s with pid %d started", filename, self->pid); - if (self->stdinpipe [0] != 0) { + if (self->stdinpipe [0] != -1) { 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) { + if (self->stdoutpipe [1] != -1) { s_zproc_addfd (self, self->stdoutpipe [0], zpair_write (self->stdoutpair), ZMQ_POLLIN); - close(self->stdoutpipe[1]); + close (self->stdoutpipe[1]); } // add a handler for read end of stderr - if (self->stderrpipe [1] != 0) { + if (self->stderrpipe [1] != -1) { s_zproc_addfd (self, self->stderrpipe [0], zpair_write (self->stderrpair), ZMQ_POLLIN); - close(self->stderrpipe[1]); + close (self->stderrpipe[1]); } } @@ -569,6 +685,8 @@ } s_zproc_execve (self); + zsock_wait (self->execpair); + zsock_signal (pipe, 0); } end: @@ -600,14 +718,10 @@ 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) { + if (!self->args || zlist_size (self->args) == 0) { zsys_error ("No arguments, nothing to run. Call zproc_set_args before"); return -1; } @@ -617,13 +731,36 @@ self->return_code = ZPROC_RUNNING; zstr_send (self->actor, "RUN"); + zsock_wait (self->actor); return 0; } int zproc_wait (zproc_t *self, bool wait) { #if defined (__WINDOWS__) - zsys_error ("zproc not yet implemented for Windows"); + if (!self->running) { + if (self->verbose) + zsys_debug ("zproc_wait: not running"); + return self->return_code; + } + + uint32_t r = WaitForSingleObject (self->piProcInfo.hProcess, wait ? INFINITE : 0); + if (self->verbose) + zsys_debug ("zproc_wait [%d]:\twaitforsingleobject, r=%d", zproc_pid (self), r); + if (!wait && r == 0x00000102) { + // still running + return self->return_code; + } + if (r == 0) { + // finished + DWORD exitcode = 0; + if (!GetExitCodeProcess(self->piProcInfo.hProcess, &exitcode)) + zsys_error ("zproc_wait: [%d]\tfailed to get exit code", zproc_pid (self)); + self->return_code = exitcode; + CloseHandle (self->piProcInfo.hProcess); + CloseHandle (self->piProcInfo.hThread); + return self->return_code; + } return -1; #else assert (self); @@ -648,16 +785,18 @@ 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); + if (self->verbose) + zsys_debug ("zproc_wait [%d]:\tWIFEXITED, self->return_code=%d", self->pid, self->return_code); + return self->return_code; } else if (WIFSIGNALED(status)) { - if (self->verbose) - zsys_debug ("zproc_wait [%d]:\tWIFSIGNALED", self->pid); self->running = false; self->return_code = - WTERMSIG(status); + if (self->verbose) + zsys_debug ("zproc_wait [%d]:\tWIFSIGNALED, self->return_code=%d", self->pid, self->return_code); + return self->return_code; /* if (WCOREDUMP(status)) { @@ -674,13 +813,8 @@ 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); + assert (zproc_pid (self)); return zproc_wait (self, false) == ZPROC_RUNNING; -#endif } void * @@ -694,13 +828,22 @@ zproc_kill (zproc_t *self, int signum) { assert (self); #if defined (__WINDOWS__) - zsys_debug ("zproc_kill not implemented on Windows"); - return; + if (zproc_pid (self)) { + if (signum == SIGTERM) { + if (! TerminateProcess (self->piProcInfo.hProcess, 255)) + zsys_error ("zproc_kill [%d]:\tTerminateProcess failed", zproc_pid (self)); + zproc_wait (self, false); + } else { + zsys_error ("zproc_kill: [%d]:\tOnly SIGTERM is implemented on windows", zproc_pid (self)); + } + } #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); + if (zproc_pid (self) > 0) { + 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 } @@ -711,246 +854,6 @@ } // -------------------------------------------------------------------------- -// 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 @@ -958,11 +861,6 @@ { 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; @@ -974,70 +872,61 @@ return; } - // @selftest // 0. initialization if (verbose) { printf("\n"); } +#ifdef __WINDOWS__ +# define ZSPBIN "zsp.exe" +#else +# define ZSPBIN "zsp" +#endif // 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"; + if (zsys_file_exists ("src/" ZSPBIN) || zsys_file_exists ("./src/" ZSPBIN)) + file = "./src/" ZSPBIN; else - if (zsys_file_exists ("../zsp")) + if (zsys_file_exists ("../" ZSPBIN)) // 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"; + if (zsys_file_exists ("_build/../src/" ZSPBIN)) + file = "_build/../src/" ZSPBIN; else - if (zsys_file_exists ("_build/src/zsp")) - file = "_build/src/zsp"; + if (zsys_file_exists ("_build/src/" ZSPBIN)) + file = "_build/src/" ZSPBIN; else - if (zsys_file_exists ("../_build/src/zsp")) - file = "../_build/src/zsp"; + if (zsys_file_exists ("../_build/src/" ZSPBIN)) + file = "../_build/src/" ZSPBIN; else - if (zsys_file_exists ("../../_build/src/zsp")) - file = "../../_build/src/zsp"; + if (zsys_file_exists ("../../_build/src/" ZSPBIN)) + file = "../../_build/src/" ZSPBIN; else - if (zsys_file_exists ("_build/sub/src/zsp")) - file = "_build/sub/src/zsp"; + if (zsys_file_exists ("_build/sub/src/" ZSPBIN)) + file = "_build/sub/src/" ZSPBIN; else - if (zsys_file_exists ("../_build/sub/src/zsp")) - file = "../_build/sub/src/zsp"; + if (zsys_file_exists ("../_build/sub/src/" ZSPBIN)) + file = "../_build/sub/src/" ZSPBIN; else - if (zsys_file_exists ("../../_build/sub/src/zsp")) - file = "../../_build/sub/src/zsp"; + if (zsys_file_exists ("../../_build/sub/src/" ZSPBIN)) + file = "../../_build/sub/src/" ZSPBIN; else - if (zsys_file_exists ("zsp") || zsys_file_exists ("./zsp")) - file = "./zsp"; + if (zsys_file_exists ("" ZSPBIN) || zsys_file_exists ("./" ZSPBIN)) + file = "./" ZSPBIN; else - if (zsys_file_exists ("../src/zsp")) - file = "../src/zsp"; + if (zsys_file_exists ("../src/" ZSPBIN)) + file = "../src/" ZSPBIN; 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 + char cwd [PATH_MAX]; 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; @@ -1046,22 +935,80 @@ zsys_info ("zproc_test() : detected a zsp binary at %s\n", file); } - // Create new subproc instance + // @selftest + + // variable file contains path to zsp executable: + // char *file = "path/to/zsp"; + +#if defined (__WINDOWS__) + printf ("Very limited (on Windows) "); + { + zsys_init (); + zproc_t *self = zproc_new (); + assert (self); + + zproc_set_verbose (self, verbose); + zproc_set_argsx (self, file, "-v", NULL); + zproc_run (self); + zclock_sleep (100); // to let actor start the process + assert (zproc_pid (self)); + + zproc_kill (self, SIGTERM); + assert (zproc_returncode (self) == 255); + zproc_destroy (&self); + } + printf ("OK\n"); + return; +#endif + // Test case #1: run command, wait until it ends and get the (stdandard) output zproc_t *self = zproc_new (); + assert (self); + zproc_set_verbose (self, verbose); + + // join stdout of the process to zeromq socket + // all data will be readable from zproc_stdout socket + assert (!zproc_stdout (self)); + zproc_set_stdout (self, NULL); + assert (zproc_stdout (self)); + + zproc_set_argsx (self, file, "--help", NULL); + + if (verbose) + zsys_debug("zproc_test() : launching helper '%s' --help", file ); + + int r = zproc_run (self); + assert (r == 0); + zframe_t *frame; + zsock_brecv (zproc_stdout (self), "f", &frame); + assert (frame); + assert (zframe_data (frame)); + // TODO: real test + if (verbose) + zframe_print (frame, "1:"); + zframe_destroy (&frame); + r = zproc_wait (self, true); + assert (r == 0); + zproc_destroy (&self); + + // Test case #2: use never ending subprocess and poller to read data from it + // Create new zproc instance + 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); + zlist_t *args = zlist_new (); + zlist_autofree (args); + zlist_append (args, file); + zlist_append (args, "--stdout"); + zproc_set_args (self, &args); + + zhash_t *env = zhash_new (); + zhash_autofree (env); + zhash_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 diff -Nru czmq-4.1.0/src/zproxy.c czmq-4.1.1/src/zproxy.c --- czmq-4.1.0/src/zproxy.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/zproxy.c 2018-03-22 22:18:37.000000000 +0000 @@ -560,7 +560,7 @@ sink = zsock_new_sub(">inproc://backend", "whatever"); #else // vagrant vms don't like using shared storage for ipc pipes.. - if (streq(getenv("USER"), "vagrant")) + if (getenv("USER") && streq(getenv("USER"), "vagrant")) sink = zsock_new_sub (">ipc:///tmp/backend", "whatever"); else sink = zsock_new_sub (">ipc://backend", "whatever"); @@ -571,7 +571,7 @@ 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")) + if (getenv("USER") && streq(getenv("USER"), "vagrant")) zstr_sendx(proxy, "BACKEND", "XPUB", "ipc:///tmp/backend", NULL); else zstr_sendx(proxy, "BACKEND", "XPUB", "ipc://backend", NULL); diff -Nru czmq-4.1.0/src/zsock.c czmq-4.1.1/src/zsock.c --- czmq-4.1.0/src/zsock.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/zsock.c 2018-03-22 22:18:37.000000000 +0000 @@ -28,7 +28,7 @@ // 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 +#define ZSOCK_TAG 0xcafe0004 // This port range is defined by IANA for dynamic or private ports // We use this when choosing a port for dynamic binding. @@ -298,6 +298,7 @@ zsock_destroy (&sock); return sock; #else + // errno = ENOTSUP; // too late, stable API would be broken return NULL; // Not implemented #endif } @@ -321,6 +322,7 @@ zsock_destroy (&sock); return sock; #else + // errno = ENOTSUP; // too late, stable API would be broken return NULL; // Not implemented #endif } @@ -363,6 +365,7 @@ zsock_destroy (&sock); return sock; #else + // errno = ENOTSUP; // too late, stable API would be broken return NULL; // Not implemented #endif } @@ -385,6 +388,7 @@ zsock_destroy (&sock); return sock; #else + errno = ENOTSUP; return NULL; #endif } @@ -407,6 +411,7 @@ zsock_destroy (&sock); return sock; #else + errno = ENOTSUP; return NULL; #endif } @@ -430,6 +435,7 @@ zsock_destroy (&sock); return sock; #else + errno = ENOTSUP; return NULL; #endif } @@ -453,6 +459,7 @@ zsock_destroy (&sock); return sock; #else + errno = ENOTSUP; return NULL; #endif } @@ -476,6 +483,7 @@ zsock_destroy (&sock); return sock; #else + errno = ENOTSUP; return NULL; #endif } @@ -499,6 +507,7 @@ zsock_destroy (&sock); return sock; #else + errno = ENOTSUP; return NULL; #endif } @@ -1736,7 +1745,7 @@ #ifdef ZMQ_DISH return zmq_join (zsock_resolve (self), group); #else - errno = EINVAL; + errno = ENOTSUP; return -1; #endif } @@ -1753,7 +1762,7 @@ #ifdef ZMQ_DISH return zmq_leave (zsock_resolve (self), group); #else - errno = EINVAL; + errno = ENOTSUP; return -1; #endif } @@ -1912,17 +1921,17 @@ 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); + zsock_t *dealer = zsock_new (ZMQ_DEALER); + assert (dealer); + rc = zsock_attach (dealer, "@inproc://myendpoint,tcp://127.0.0.1:*,inproc://others", true); assert (rc == 0); - rc = zsock_attach (server, "", false); + rc = zsock_attach (dealer, "", false); assert (rc == 0); - rc = zsock_attach (server, NULL, true); + rc = zsock_attach (dealer, NULL, true); assert (rc == 0); - rc = zsock_attach (server, ">a,@b, c,, ", false); + rc = zsock_attach (dealer, ">a,@b, c,, ", false); assert (rc == -1); - zsock_destroy (&server); + zsock_destroy (&dealer); // Test zsock_endpoint method rc = zsock_bind (writer, "inproc://test.%s", "writer"); @@ -2099,7 +2108,7 @@ #ifdef ZMQ_SERVER // Test zsock_bsend/brecv pictures with binary encoding on SERVER and CLIENT sockets - server = zsock_new (ZMQ_SERVER); + zsock_t *server = zsock_new (ZMQ_SERVER); assert (server); port = zsock_bind (server, "tcp://127.0.0.1:*"); assert (port != -1); @@ -2165,6 +2174,16 @@ zsock_destroy (&client); zsock_destroy (&server); +#else + errno = 0; + zsock_t* server = zsock_new_server (NULL); + assert(server == NULL); + assert(errno == ENOTSUP); + + errno = 0; + zsock_t* client = zsock_new_client (NULL); + assert(client == NULL); + assert(errno == ENOTSUP); #endif #ifdef ZMQ_SCATTER @@ -2184,7 +2203,39 @@ zsock_destroy (&gather); zsock_destroy (&scatter); - +#else + errno = 0; + zsock_t* scatter = zsock_new_scatter (NULL); + assert(scatter == NULL); + assert(errno == ENOTSUP); + + errno = 0; + zsock_t* gather = zsock_new_gather (NULL); + assert(gather == NULL); + assert(errno == ENOTSUP); +#endif + +#ifndef ZMQ_RADIO + errno = 0; + zsock_t* radio = zsock_new_radio (NULL); + assert(radio == NULL); + assert(errno == ENOTSUP); + + errno = 0; + zsock_t* dish = zsock_new_dish (NULL); + assert(dish == NULL); + assert(errno == ENOTSUP); + + errno = 0; + zsock_t* sock = zsock_new_req (NULL); // any supported socket type + rc = zsock_join (sock, "group1"); + assert(rc == -1); + assert(errno == ENOTSUP); + errno = 0; + rc = zsock_leave (sock, "group1"); + assert(rc == -1); + assert(errno == ENOTSUP); + zsock_destroy (&sock); #endif // Check that we can send a zproto format message diff -Nru czmq-4.1.0/src/zsys.c czmq-4.1.1/src/zsys.c --- czmq-4.1.0/src/zsys.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/zsys.c 2018-03-22 22:18:37.000000000 +0000 @@ -99,6 +99,7 @@ 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= +static int s_zero_copy_recv = 1; // ZSYS_ZERO_COPY_RECV=1 // Track number of open sockets so we can zmq_term() safely static size_t s_open_sockets = 0; @@ -157,6 +158,9 @@ if (getenv ("ZSYS_MAX_MSGSZ")) s_max_msgsz = atoi (getenv ("ZSYS_MAX_MSGSZ")); + if (getenv ("ZSYS_ZERO_COPY_RECV")) + s_zero_copy_recv = atoi (getenv ("ZSYS_ZERO_COPY_RECV")); + if (getenv ("ZSYS_FILE_STABLE_AGE_MSEC")) s_file_stable_age_msec = atoi (getenv ("ZSYS_FILE_STABLE_AGE_MSEC")); @@ -205,7 +209,6 @@ 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 @@ -215,6 +218,8 @@ #endif s_initialized = true; + atexit (zsys_shutdown); + // 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")) @@ -237,6 +242,10 @@ zsys_set_max_msgsz (s_max_msgsz); +#if defined ZMQ_ZERO_COPY_RECV + zmq_ctx_set (s_process_ctx, ZMQ_ZERO_COPY_RECV, s_zero_copy_recv); +#endif + zsys_set_file_stable_age_msec (s_file_stable_age_msec); if (getenv ("ZSYS_THREAD_PRIORITY")) @@ -1491,6 +1500,37 @@ ZMUTEX_UNLOCK (s_mutex); } +// -------------------------------------------------------------------------- +// Configure whether to use zero copy strategy in libzmq. If the environment +// variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. +// Otherwise the default is 1. + +void +zsys_set_zero_copy_recv(int zero_copy) +{ + zsys_init (); + ZMUTEX_LOCK (s_mutex); + s_zero_copy_recv = zero_copy; +#if defined (ZMQ_ZERO_COPY_RECV) + zmq_ctx_set (s_process_ctx, ZMQ_ZERO_COPY_RECV, s_zero_copy_recv); +#endif + ZMUTEX_UNLOCK (s_mutex); +} + +// -------------------------------------------------------------------------- +// Return ZMQ_ZERO_COPY_RECV option. +int +zsys_zero_copy_recv() +{ + zsys_init (); + ZMUTEX_LOCK (s_mutex); +#if defined (ZMQ_ZERO_COPY_RECV) + s_zero_copy_recv = zmq_ctx_get (s_process_ctx, ZMQ_ZERO_COPY_RECV); +#endif + ZMUTEX_UNLOCK (s_mutex); + return s_zero_copy_recv; +} + // -------------------------------------------------------------------------- // Return maximum message size. @@ -1509,6 +1549,29 @@ // -------------------------------------------------------------------------- +// *** Draft method, for development use, may change without warning *** +// Check if default interrupt handler of Ctrl-C or SIGTERM was called. +// Does not work if ZSYS_SIGHANDLER is false and code does not call +// set interrupted on signal. +bool + zsys_is_interrupted (void) +{ + return zsys_interrupted != 0; +} + +// -------------------------------------------------------------------------- +// *** Draft method, for development use, may change without warning *** +// Set interrupted flag. This is done by default signal handler, however +// this can be handy for language bindings or cases without default +// signal handler. +void + zsys_set_interrupted (void) +{ + zctx_interrupted = 1; + zsys_interrupted = 1; +} + +// -------------------------------------------------------------------------- // 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. @@ -1986,7 +2049,6 @@ zstr_free (&string); } - // -------------------------------------------------------------------------- // Selftest @@ -2018,10 +2080,12 @@ freen (hostname); zsys_info ("system limit is %zu ZeroMQ sockets", zsys_socket_limit ()); } +#ifdef CZMQ_BUILD_DRAFT_API 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); +#endif // CZMQ_BUILD_DRAFT_API zsys_set_linger (0); zsys_set_sndhwm (1000); zsys_set_rcvhwm (1000); @@ -2030,6 +2094,10 @@ zsys_set_ipv6 (0); zsys_set_thread_priority (-1); zsys_set_thread_sched_policy (-1); + zsys_set_zero_copy_recv(0); + assert (0 == zsys_zero_copy_recv()); + zsys_set_zero_copy_recv(1); + assert (1 == zsys_zero_copy_recv()); // Test pipe creation zsock_t *pipe_back; diff -Nru czmq-4.1.0/src/zuuid.c czmq-4.1.1/src/zuuid.c --- czmq-4.1.0/src/zuuid.c 2017-12-31 16:38:06.000000000 +0000 +++ czmq-4.1.1/src/zuuid.c 2018-03-22 22:18:37.000000000 +0000 @@ -47,7 +47,7 @@ assert (sizeof (uuid) == ZUUID_LEN); UuidCreate (&uuid); zuuid_set (self, (byte *) &uuid); -#elif defined (HAVE_UUID) +#elif defined (HAVE_UUID) && !defined (__UTYPE_FREEBSD) uuid_t uuid; assert (sizeof (uuid) == ZUUID_LEN); uuid_generate (uuid); @@ -213,15 +213,16 @@ 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); + memcpy (self->str_canonical, self->str, 8); + self->str_canonical[8] = '-'; + memcpy (self->str_canonical + 9, self->str + 8, 4); + self->str_canonical[13] = '-'; + memcpy (self->str_canonical + 14, self->str + 12, 4); + self->str_canonical[18] = '-'; + memcpy (self->str_canonical + 19, self->str + 16, 4); + self->str_canonical[23] = '-'; + memcpy (self->str_canonical + 24, self->str + 20, 12); + self->str_canonical[36] = '\0'; int char_nbr; for (char_nbr = 0; char_nbr < 36; char_nbr++)