1 /*  =========================================================================
2     zsys - system-level methods
3 
4     Copyright (c) the Contributors as noted in the AUTHORS file.
5     This file is part of CZMQ, the high-level C binding for 0MQ:
6     http://czmq.zeromq.org.
7 
8     This Source Code Form is subject to the terms of the Mozilla Public
9     License, v. 2.0. If a copy of the MPL was not distributed with this
10     file, You can obtain one at http://mozilla.org/MPL/2.0/.
11     =========================================================================
12 */
13 
14 #ifndef __ZSYS_H_INCLUDED__
15 #define __ZSYS_H_INCLUDED__
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #define UDP_FRAME_MAX   255         //  Max size of UDP frame
22 
23 //  @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT
24 //  @warning Please edit the model at "api/zsys.api" to make changes.
25 //  @interface
26 //  This is a stable class, and may not change except for emergencies. It
27 //  is provided in stable builds.
28 //  This class has draft methods, which may change over time. They are not
29 //  in stable releases, by default. Use --enable-drafts to enable.
30 // Callback for interrupt signal handler
31 typedef void (zsys_handler_fn) (
32     int signal_value);
33 
34 //  Initialize CZMQ zsys layer; this happens automatically when you create
35 //  a socket or an actor; however this call lets you force initialization
36 //  earlier, so e.g. logging is properly set-up before you start working.
37 //  Not threadsafe, so call only from main thread. Safe to call multiple
38 //  times. Returns global CZMQ context.
39 CZMQ_EXPORT void *
40     zsys_init (void);
41 
42 //  Optionally shut down the CZMQ zsys layer; this normally happens automatically
43 //  when the process exits; however this call lets you force a shutdown
44 //  earlier, avoiding any potential problems with atexit() ordering, especially
45 //  with Windows dlls.
46 CZMQ_EXPORT void
47     zsys_shutdown (void);
48 
49 //  Get a new ZMQ socket, automagically creating a ZMQ context if this is
50 //  the first time. Caller is responsible for destroying the ZMQ socket
51 //  before process exits, to avoid a ZMQ deadlock. Note: you should not use
52 //  this method in CZMQ apps, use zsock_new() instead.
53 //  *** This is for CZMQ internal use only and may change arbitrarily ***
54 CZMQ_EXPORT void *
55     zsys_socket (int type, const char *filename, size_t line_nbr);
56 
57 //  Destroy/close a ZMQ socket. You should call this for every socket you
58 //  create using zsys_socket().
59 //  *** This is for CZMQ internal use only and may change arbitrarily ***
60 CZMQ_EXPORT int
61     zsys_close (void *handle, const char *filename, size_t line_nbr);
62 
63 //  Return ZMQ socket name for socket type
64 //  *** This is for CZMQ internal use only and may change arbitrarily ***
65 CZMQ_EXPORT char *
66     zsys_sockname (int socktype);
67 
68 //  Create a pipe, which consists of two PAIR sockets connected over inproc.
69 //  The pipe is configured to use the zsys_pipehwm setting. Returns the
70 //  frontend socket successful, NULL if failed.
71 CZMQ_EXPORT zsock_t *
72     zsys_create_pipe (zsock_t **backend_p);
73 
74 //  Set interrupt handler; this saves the default handlers so that a
75 //  zsys_handler_reset () can restore them. If you call this multiple times
76 //  then the last handler will take affect. If handler_fn is NULL, disables
77 //  default SIGINT/SIGTERM handling in CZMQ.
78 CZMQ_EXPORT void
79     zsys_handler_set (zsys_handler_fn *handler_fn);
80 
81 //  Reset interrupt handler, call this at exit if needed
82 CZMQ_EXPORT void
83     zsys_handler_reset (void);
84 
85 //  Set default interrupt handler, so Ctrl-C or SIGTERM will set
86 //  zsys_interrupted. Idempotent; safe to call multiple times.
87 //  Can be suppressed by ZSYS_SIGHANDLER=false
88 //  *** This is for CZMQ internal use only and may change arbitrarily ***
89 CZMQ_EXPORT void
90     zsys_catch_interrupts (void);
91 
92 //  Return 1 if file exists, else zero
93 CZMQ_EXPORT bool
94     zsys_file_exists (const char *filename);
95 
96 //  Return file modification time. Returns 0 if the file does not exist.
97 CZMQ_EXPORT time_t
98     zsys_file_modified (const char *filename);
99 
100 //  Return file mode; provides at least support for the POSIX S_ISREG(m)
101 //  and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes.
102 //  Returns a mode_t cast to int, or -1 in case of error.
103 CZMQ_EXPORT int
104     zsys_file_mode (const char *filename);
105 
106 //  Delete file. Does not complain if the file is absent
107 CZMQ_EXPORT int
108     zsys_file_delete (const char *filename);
109 
110 //  Check if file is 'stable'
111 CZMQ_EXPORT bool
112     zsys_file_stable (const char *filename);
113 
114 //  Create a file path if it doesn't exist. The file path is treated as
115 //  printf format.
116 CZMQ_EXPORT int
117     zsys_dir_create (const char *pathname, ...);
118 
119 //  Remove a file path if empty; the pathname is treated as printf format.
120 CZMQ_EXPORT int
121     zsys_dir_delete (const char *pathname, ...);
122 
123 //  Move to a specified working directory. Returns 0 if OK, -1 if this failed.
124 CZMQ_EXPORT int
125     zsys_dir_change (const char *pathname);
126 
127 //  Set private file creation mode; all files created from here will be
128 //  readable/writable by the owner only.
129 CZMQ_EXPORT void
130     zsys_file_mode_private (void);
131 
132 //  Reset default file creation mode; all files created from here will use
133 //  process file mode defaults.
134 CZMQ_EXPORT void
135     zsys_file_mode_default (void);
136 
137 //  Return the CZMQ version for run-time API detection; returns version
138 //  number into provided fields, providing reference isn't null in each case.
139 CZMQ_EXPORT void
140     zsys_version (int *major, int *minor, int *patch);
141 
142 //  Format a string using printf formatting, returning a freshly allocated
143 //  buffer. If there was insufficient memory, returns NULL. Free the returned
144 //  string using zstr_free().
145 CZMQ_EXPORT char *
146     zsys_sprintf (const char *format, ...);
147 
148 //  Format a string with a va_list argument, returning a freshly allocated
149 //  buffer. If there was insufficient memory, returns NULL. Free the returned
150 //  string using zstr_free().
151 CZMQ_EXPORT char *
152     zsys_vprintf (const char *format, va_list argptr);
153 
154 //  Create UDP beacon socket; if the routable option is true, uses
155 //  multicast (not yet implemented), else uses broadcast. This method
156 //  and related ones might _eventually_ be moved to a zudp class.
157 //  *** This is for CZMQ internal use only and may change arbitrarily ***
158 CZMQ_EXPORT SOCKET
159     zsys_udp_new (bool routable);
160 
161 //  Close a UDP socket
162 //  *** This is for CZMQ internal use only and may change arbitrarily ***
163 CZMQ_EXPORT int
164     zsys_udp_close (SOCKET handle);
165 
166 //  Send zframe to UDP socket, return -1 if sending failed due to
167 //  interface having disappeared (happens easily with WiFi)
168 //  *** This is for CZMQ internal use only and may change arbitrarily ***
169 CZMQ_EXPORT int
170     zsys_udp_send (SOCKET udpsock, zframe_t *frame, inaddr_t *address, int addrlen);
171 
172 //  Receive zframe from UDP socket, and set address of peer that sent it
173 //  The peername must be a char [INET_ADDRSTRLEN] array if IPv6 is disabled or
174 //  NI_MAXHOST if it's enabled. Returns NULL when failing to get peer address.
175 //  *** This is for CZMQ internal use only and may change arbitrarily ***
176 CZMQ_EXPORT zframe_t *
177     zsys_udp_recv (SOCKET udpsock, char *peername, int peerlen);
178 
179 //  Handle an I/O error on some socket operation; will report and die on
180 //  fatal errors, and continue silently on "try again" errors.
181 //  *** This is for CZMQ internal use only and may change arbitrarily ***
182 CZMQ_EXPORT void
183     zsys_socket_error (const char *reason);
184 
185 //  Return current host name, for use in public tcp:// endpoints. Caller gets
186 //  a freshly allocated string, should free it using zstr_free(). If the host
187 //  name is not resolvable, returns NULL.
188 CZMQ_EXPORT char *
189     zsys_hostname (void);
190 
191 //  Move the current process into the background. The precise effect depends
192 //  on the operating system. On POSIX boxes, moves to a specified working
193 //  directory (if specified), closes all file handles, reopens stdin, stdout,
194 //  and stderr to the null device, and sets the process to ignore SIGHUP. On
195 //  Windows, does nothing. Returns 0 if OK, -1 if there was an error.
196 CZMQ_EXPORT int
197     zsys_daemonize (const char *workdir);
198 
199 //  Drop the process ID into the lockfile, with exclusive lock, and switch
200 //  the process to the specified group and/or user. Any of the arguments
201 //  may be null, indicating a no-op. Returns 0 on success, -1 on failure.
202 //  Note if you combine this with zsys_daemonize, run after, not before
203 //  that method, or the lockfile will hold the wrong process ID.
204 CZMQ_EXPORT int
205     zsys_run_as (const char *lockfile, const char *group, const char *user);
206 
207 //  Returns true if the underlying libzmq supports CURVE security.
208 //  Uses a heuristic probe according to the version of libzmq being used.
209 CZMQ_EXPORT bool
210     zsys_has_curve (void);
211 
212 //  Configure the number of I/O threads that ZeroMQ will use. A good
213 //  rule of thumb is one thread per gigabit of traffic in or out. The
214 //  default is 1, sufficient for most applications. If the environment
215 //  variable ZSYS_IO_THREADS is defined, that provides the default.
216 //  Note that this method is valid only before any socket is created.
217 CZMQ_EXPORT void
218     zsys_set_io_threads (size_t io_threads);
219 
220 //  Configure the scheduling policy of the ZMQ context thread pool.
221 //  Not available on Windows. See the sched_setscheduler man page or sched.h
222 //  for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY
223 //  is defined, that provides the default.
224 //  Note that this method is valid only before any socket is created.
225 CZMQ_EXPORT void
226     zsys_set_thread_sched_policy (int policy);
227 
228 //  Configure the scheduling priority of the ZMQ context thread pool.
229 //  Not available on Windows. See the sched_setscheduler man page or sched.h
230 //  for more information. If the environment variable ZSYS_THREAD_PRIORITY is
231 //  defined, that provides the default.
232 //  Note that this method is valid only before any socket is created.
233 CZMQ_EXPORT void
234     zsys_set_thread_priority (int priority);
235 
236 //  Configure the numeric prefix to each thread created for the internal
237 //  context's thread pool. This option is only supported on Linux.
238 //  If the environment variable ZSYS_THREAD_NAME_PREFIX is defined, that
239 //  provides the default.
240 //  Note that this method is valid only before any socket is created.
241 CZMQ_EXPORT void
242     zsys_set_thread_name_prefix (int prefix);
243 
244 //  Return thread name prefix.
245 CZMQ_EXPORT int
246     zsys_thread_name_prefix (void);
247 
248 //  Adds a specific CPU to the affinity list of the ZMQ context thread pool.
249 //  This option is only supported on Linux.
250 //  Note that this method is valid only before any socket is created.
251 CZMQ_EXPORT void
252     zsys_thread_affinity_cpu_add (int cpu);
253 
254 //  Removes a specific CPU to the affinity list of the ZMQ context thread pool.
255 //  This option is only supported on Linux.
256 //  Note that this method is valid only before any socket is created.
257 CZMQ_EXPORT void
258     zsys_thread_affinity_cpu_remove (int cpu);
259 
260 //  Configure the number of sockets that ZeroMQ will allow. The default
261 //  is 1024. The actual limit depends on the system, and you can query it
262 //  by using zsys_socket_limit (). A value of zero means "maximum".
263 //  Note that this method is valid only before any socket is created.
264 CZMQ_EXPORT void
265     zsys_set_max_sockets (size_t max_sockets);
266 
267 //  Return maximum number of ZeroMQ sockets that the system will support.
268 CZMQ_EXPORT size_t
269     zsys_socket_limit (void);
270 
271 //  Configure the maximum allowed size of a message sent.
272 //  The default is INT_MAX.
273 CZMQ_EXPORT void
274     zsys_set_max_msgsz (int max_msgsz);
275 
276 //  Return maximum message size.
277 CZMQ_EXPORT int
278     zsys_max_msgsz (void);
279 
280 //  Configure the default linger timeout in msecs for new zsock instances.
281 //  You can also set this separately on each zsock_t instance. The default
282 //  linger time is zero, i.e. any pending messages will be dropped. If the
283 //  environment variable ZSYS_LINGER is defined, that provides the default.
284 //  Note that process exit will typically be delayed by the linger time.
285 CZMQ_EXPORT void
286     zsys_set_linger (size_t linger);
287 
288 //  Configure the default outgoing pipe limit (HWM) for new zsock instances.
289 //  You can also set this separately on each zsock_t instance. The default
290 //  HWM is 1,000, on all versions of ZeroMQ. If the environment variable
291 //  ZSYS_SNDHWM is defined, that provides the default. Note that a value of
292 //  zero means no limit, i.e. infinite memory consumption.
293 CZMQ_EXPORT void
294     zsys_set_sndhwm (size_t sndhwm);
295 
296 //  Configure the default incoming pipe limit (HWM) for new zsock instances.
297 //  You can also set this separately on each zsock_t instance. The default
298 //  HWM is 1,000, on all versions of ZeroMQ. If the environment variable
299 //  ZSYS_RCVHWM is defined, that provides the default. Note that a value of
300 //  zero means no limit, i.e. infinite memory consumption.
301 CZMQ_EXPORT void
302     zsys_set_rcvhwm (size_t rcvhwm);
303 
304 //  Configure the default HWM for zactor internal pipes; this is set on both
305 //  ends of the pipe, for outgoing messages only (sndhwm). The default HWM is
306 //  1,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is
307 //  defined, that provides the default. Note that a value of zero means no
308 //  limit, i.e. infinite memory consumption.
309 CZMQ_EXPORT void
310     zsys_set_pipehwm (size_t pipehwm);
311 
312 //  Return the HWM for zactor internal pipes.
313 CZMQ_EXPORT size_t
314     zsys_pipehwm (void);
315 
316 //  Configure use of IPv6 for new zsock instances. By default sockets accept
317 //  and make only IPv4 connections. When you enable IPv6, sockets will accept
318 //  and connect to both IPv4 and IPv6 peers. You can override the setting on
319 //  each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the
320 //  environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the
321 //  default. Note: has no effect on ZMQ v2.
322 CZMQ_EXPORT void
323     zsys_set_ipv6 (int ipv6);
324 
325 //  Return use of IPv6 for zsock instances.
326 CZMQ_EXPORT int
327     zsys_ipv6 (void);
328 
329 //  Set network interface name to use for broadcasts, particularly zbeacon.
330 //  This lets the interface be configured for test environments where required.
331 //  For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is
332 //  the default when there is no specified interface. If the environment
333 //  variable ZSYS_INTERFACE is set, use that as the default interface name.
334 //  Setting the interface to "*" means "use all available interfaces".
335 CZMQ_EXPORT void
336     zsys_set_interface (const char *value);
337 
338 //  Return network interface to use for broadcasts, or "" if none was set.
339 CZMQ_EXPORT const char *
340     zsys_interface (void);
341 
342 //  Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon.
343 //  This needs to be set IPv6 is enabled as IPv6 can have multiple addresses
344 //  on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set,
345 //  use that as the default IPv6 address.
346 CZMQ_EXPORT void
347     zsys_set_ipv6_address (const char *value);
348 
349 //  Return IPv6 address to use for zbeacon reception, or "" if none was set.
350 CZMQ_EXPORT const char *
351     zsys_ipv6_address (void);
352 
353 //  Set IPv6 milticast address to use for sending zbeacon messages. This needs
354 //  to be set if IPv6 is enabled. If the environment variable
355 //  ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast
356 //  address.
357 CZMQ_EXPORT void
358     zsys_set_ipv6_mcast_address (const char *value);
359 
360 //  Return IPv6 multicast address to use for sending zbeacon, or "" if none was
361 //  set.
362 CZMQ_EXPORT const char *
363     zsys_ipv6_mcast_address (void);
364 
365 //  Configure the automatic use of pre-allocated FDs when creating new sockets.
366 //  If 0 (default), nothing will happen. Else, when a new socket is bound, the
367 //  system API will be used to check if an existing pre-allocated FD with a
368 //  matching port (if TCP) or path (if IPC) exists, and if it does it will be
369 //  set via the ZMQ_USE_FD socket option so that the library will use it
370 //  instead of creating a new socket.
371 CZMQ_EXPORT void
372     zsys_set_auto_use_fd (int auto_use_fd);
373 
374 //  Return use of automatic pre-allocated FDs for zsock instances.
375 CZMQ_EXPORT int
376     zsys_auto_use_fd (void);
377 
378 //  Set log identity, which is a string that prefixes all log messages sent
379 //  by this process. The log identity defaults to the environment variable
380 //  ZSYS_LOGIDENT, if that is set.
381 CZMQ_EXPORT void
382     zsys_set_logident (const char *value);
383 
384 //  Set stream to receive log traffic. By default, log traffic is sent to
385 //  stdout. If you set the stream to NULL, no stream will receive the log
386 //  traffic (it may still be sent to the system facility).
387 CZMQ_EXPORT void
388     zsys_set_logstream (FILE *stream);
389 
390 //  Sends log output to a PUB socket bound to the specified endpoint. To
391 //  collect such log output, create a SUB socket, subscribe to the traffic
392 //  you care about, and connect to the endpoint. Log traffic is sent as a
393 //  single string frame, in the same format as when sent to stdout. The
394 //  log system supports a single sender; multiple calls to this method will
395 //  bind the same sender to multiple endpoints. To disable the sender, call
396 //  this method with a null argument.
397 CZMQ_EXPORT void
398     zsys_set_logsender (const char *endpoint);
399 
400 //  Enable or disable logging to the system facility (syslog on POSIX boxes,
401 //  event log on Windows). By default this is disabled.
402 CZMQ_EXPORT void
403     zsys_set_logsystem (bool logsystem);
404 
405 //  Log error condition - highest priority
406 CZMQ_EXPORT void
407     zsys_error (const char *format, ...);
408 
409 //  Log warning condition - high priority
410 CZMQ_EXPORT void
411     zsys_warning (const char *format, ...);
412 
413 //  Log normal, but significant, condition - normal priority
414 CZMQ_EXPORT void
415     zsys_notice (const char *format, ...);
416 
417 //  Log informational message - low priority
418 CZMQ_EXPORT void
419     zsys_info (const char *format, ...);
420 
421 //  Log debug-level message - lowest priority
422 CZMQ_EXPORT void
423     zsys_debug (const char *format, ...);
424 
425 //  Self test of this class.
426 CZMQ_EXPORT void
427     zsys_test (bool verbose);
428 
429 #ifdef CZMQ_BUILD_DRAFT_API
430 //  *** Draft method, for development use, may change without warning ***
431 //  Check if default interrupt handler of Ctrl-C or SIGTERM was called.
432 //  Does not work if ZSYS_SIGHANDLER is false and code does not call
433 //  set interrupted on signal.
434 CZMQ_EXPORT bool
435     zsys_is_interrupted (void);
436 
437 //  *** Draft method, for development use, may change without warning ***
438 //  Set interrupted flag. This is done by default signal handler, however
439 //  this can be handy for language bindings or cases without default
440 //  signal handler.
441 CZMQ_EXPORT void
442     zsys_set_interrupted (void);
443 
444 //  *** Draft method, for development use, may change without warning ***
445 //  Format a string using printf formatting, returning a freshly allocated
446 //  buffer. If there was insufficient memory, returns NULL. Free the returned
447 //  string using zstr_free(). The hinted version allows to optimize by using
448 //  a larger starting buffer size (known to/assumed by the developer) and so
449 //  avoid reallocations.
450 CZMQ_EXPORT char *
451     zsys_sprintf_hint (int hint, const char *format, ...);
452 
453 //  *** Draft method, for development use, may change without warning ***
454 //  Configure the numeric prefix to each thread created for the internal
455 //  context's thread pool. This option is only supported on Linux.
456 //  If the environment variable ZSYS_THREAD_NAME_PREFIX_STR is defined, that
457 //  provides the default.
458 //  Note that this method is valid only before any socket is created.
459 CZMQ_EXPORT void
460     zsys_set_thread_name_prefix_str (const char *prefix);
461 
462 //  *** Draft method, for development use, may change without warning ***
463 //  Return thread name prefix.
464 CZMQ_EXPORT const char *
465     zsys_thread_name_prefix_str (void);
466 
467 //  *** Draft method, for development use, may change without warning ***
468 //  Configure whether to use zero copy strategy in libzmq. If the environment
469 //  variable ZSYS_ZERO_COPY_RECV is defined, that provides the default.
470 //  Otherwise the default is 1.
471 CZMQ_EXPORT void
472     zsys_set_zero_copy_recv (int zero_copy);
473 
474 //  *** Draft method, for development use, may change without warning ***
475 //  Return ZMQ_ZERO_COPY_RECV option.
476 CZMQ_EXPORT int
477     zsys_zero_copy_recv (void);
478 
479 //  *** Draft method, for development use, may change without warning ***
480 //  Configure the threshold value of filesystem object age per st_mtime
481 //  that should elapse until we consider that object "stable" at the
482 //  current zclock_time() moment.
483 //  The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c
484 //  which generally depends on host OS, with fallback value of 5000.
485 CZMQ_EXPORT void
486     zsys_set_file_stable_age_msec (int64_t file_stable_age_msec);
487 
488 //  *** Draft method, for development use, may change without warning ***
489 //  Return current threshold value of file stable age in msec.
490 //  This can be used in code that chooses to wait for this timeout
491 //  before testing if a filesystem object is "stable" or not.
492 CZMQ_EXPORT int64_t
493     zsys_file_stable_age_msec (void);
494 
495 //  *** Draft method, for development use, may change without warning ***
496 //  Test if ipv6 is available on the system. Return true if available.
497 //  The only way to reliably check is to actually open a socket and
498 //  try to bind it. (ported from libzmq)
499 CZMQ_EXPORT bool
500     zsys_ipv6_available (void);
501 
502 //  *** Draft method, for development use, may change without warning ***
503 //  Set IPv4 multicast address to use for sending zbeacon messages. By default
504 //  IPv4 multicast is NOT used. If the environment variable
505 //  ZSYS_IPV4_MCAST_ADDRESS is set, use that as the default IPv4 multicast
506 //  address. Calling this function or setting ZSYS_IPV4_MCAST_ADDRESS
507 //  will enable IPv4 zbeacon messages.
508 CZMQ_EXPORT void
509     zsys_set_ipv4_mcast_address (const char *value);
510 
511 //  *** Draft method, for development use, may change without warning ***
512 //  Return IPv4 multicast address to use for sending zbeacon, or NULL if none was
513 //  set.
514 CZMQ_EXPORT const char *
515     zsys_ipv4_mcast_address (void);
516 
517 //  *** Draft method, for development use, may change without warning ***
518 //  Set multicast TTL default is 1
519 CZMQ_EXPORT void
520     zsys_set_mcast_ttl (byte value);
521 
522 //  *** Draft method, for development use, may change without warning ***
523 //  Get multicast TTL
524 CZMQ_EXPORT byte
525     zsys_mcast_ttl (void);
526 
527 //  *** Draft method, for development use, may change without warning ***
528 //  Print formatted string. Format is specified by variable names
529 //  in Python-like format style
530 //
531 //  "%(KEY)s=%(VALUE)s", KEY=key, VALUE=value
532 //  become
533 //  "key=value"
534 //
535 //  Returns freshly allocated string or NULL in a case of error.
536 //  Not enough memory, invalid format specifier, name not in args
537 //  Caller owns return value and must destroy it when done.
538 CZMQ_EXPORT char *
539     zsys_zprintf (const char *format, zhash_t *args);
540 
541 //  *** Draft method, for development use, may change without warning ***
542 //  Return error string for given format/args combination.
543 //  Caller owns return value and must destroy it when done.
544 CZMQ_EXPORT char *
545     zsys_zprintf_error (const char *format, zhash_t *args);
546 
547 //  *** Draft method, for development use, may change without warning ***
548 //  Print formatted string. Format is specified by variable names
549 //  in Python-like format style
550 //
551 //  "%(KEY)s=%(VALUE)s", KEY=key, VALUE=value
552 //  become
553 //  "key=value"
554 //
555 //  Returns freshly allocated string or NULL in a case of error.
556 //  Not enough memory, invalid format specifier, name not in args
557 //  Caller owns return value and must destroy it when done.
558 CZMQ_EXPORT char *
559     zsys_zplprintf (const char *format, zconfig_t *args);
560 
561 //  *** Draft method, for development use, may change without warning ***
562 //  Return error string for given format/args combination.
563 //  Caller owns return value and must destroy it when done.
564 CZMQ_EXPORT char *
565     zsys_zplprintf_error (const char *format, zconfig_t *args);
566 
567 #endif // CZMQ_BUILD_DRAFT_API
568 //  @end
569 
570 //  Return size of file, or -1 if not found
571 CZMQ_EXPORT ssize_t
572     zsys_file_size (const char *filename);
573 
574 //  Global signal indicator, TRUE when user presses Ctrl-C or the process
575 //  gets a SIGTERM signal.
576 CZMQ_EXPORT extern volatile int zsys_interrupted;
577 //  Deprecated name for this variable
578 CZMQ_EXPORT extern volatile int zctx_interrupted;
579 
580 #ifdef __cplusplus
581 }
582 #endif
583 
584 #endif
585