1"""All the C imports for 0MQ"""
2
3#
4#    Copyright (c) 2010 Brian E. Granger & Min Ragan-Kelley
5#
6#    This file is part of pyzmq.
7#
8#    pyzmq is free software; you can redistribute it and/or modify it under
9#    the terms of the Lesser GNU General Public License as published by
10#    the Free Software Foundation; either version 3 of the License, or
11#    (at your option) any later version.
12#
13#    pyzmq is distributed in the hope that it will be useful,
14#    but WITHOUT ANY WARRANTY; without even the implied warranty of
15#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16#    Lesser GNU General Public License for more details.
17#
18#    You should have received a copy of the Lesser GNU General Public License
19#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20#
21
22#-----------------------------------------------------------------------------
23# Imports
24#-----------------------------------------------------------------------------
25
26#-----------------------------------------------------------------------------
27# Import the C header files
28#-----------------------------------------------------------------------------
29
30cdef extern from *:
31    ctypedef void* const_void_ptr "const void *"
32    ctypedef char* const_char_ptr "const char *"
33
34cdef extern from "zmq_compat.h":
35    ctypedef signed long long int64_t "pyzmq_int64_t"
36
37include "constant_enums.pxi"
38
39cdef extern from "zmq.h" nogil:
40
41    void _zmq_version "zmq_version"(int *major, int *minor, int *patch)
42    
43    ctypedef int fd_t "ZMQ_FD_T"
44    
45    enum: errno
46    char *zmq_strerror (int errnum)
47    int zmq_errno()
48
49    void *zmq_ctx_new ()
50    int zmq_ctx_destroy (void *context)
51    int zmq_ctx_set (void *context, int option, int optval)
52    int zmq_ctx_get (void *context, int option)
53    void *zmq_init (int io_threads)
54    int zmq_term (void *context)
55    
56    # blackbox def for zmq_msg_t
57    ctypedef void * zmq_msg_t "zmq_msg_t"
58    
59    ctypedef void zmq_free_fn(void *data, void *hint)
60    
61    int zmq_msg_init (zmq_msg_t *msg)
62    int zmq_msg_init_size (zmq_msg_t *msg, size_t size)
63    int zmq_msg_init_data (zmq_msg_t *msg, void *data,
64        size_t size, zmq_free_fn *ffn, void *hint)
65    int zmq_msg_send (zmq_msg_t *msg, void *s, int flags)
66    int zmq_msg_recv (zmq_msg_t *msg, void *s, int flags)
67    int zmq_msg_close (zmq_msg_t *msg)
68    int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src)
69    int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src)
70    void *zmq_msg_data (zmq_msg_t *msg)
71    size_t zmq_msg_size (zmq_msg_t *msg)
72    int zmq_msg_more (zmq_msg_t *msg)
73    int zmq_msg_get (zmq_msg_t *msg, int option)
74    int zmq_msg_set (zmq_msg_t *msg, int option, int optval)
75    const_char_ptr zmq_msg_gets (zmq_msg_t *msg, const_char_ptr property)
76    int zmq_has (const_char_ptr capability)
77
78    void *zmq_socket (void *context, int type)
79    int zmq_close (void *s)
80    int zmq_setsockopt (void *s, int option, void *optval, size_t optvallen)
81    int zmq_getsockopt (void *s, int option, void *optval, size_t *optvallen)
82    int zmq_bind (void *s, char *addr)
83    int zmq_connect (void *s, char *addr)
84    int zmq_unbind (void *s, char *addr)
85    int zmq_disconnect (void *s, char *addr)
86
87    int zmq_socket_monitor (void *s, char *addr, int flags)
88    
89    # send/recv
90    int zmq_sendbuf (void *s, const_void_ptr buf, size_t n, int flags)
91    int zmq_recvbuf (void *s, void *buf, size_t n, int flags)
92
93    ctypedef struct zmq_pollitem_t:
94        void *socket
95        int fd
96        short events
97        short revents
98
99    int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout)
100
101    int zmq_device (int device_, void *insocket_, void *outsocket_)
102    int zmq_proxy (void *frontend, void *backend, void *capture)
103
104cdef extern from "zmq_utils.h" nogil:
105
106    void *zmq_stopwatch_start ()
107    unsigned long zmq_stopwatch_stop (void *watch_)
108    void zmq_sleep (int seconds_)
109    int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key)
110
111