libzmq.pxd 5.72 KB
Newer Older
1 2 3
"""All the C imports for 0MQ"""

#
4
#    Copyright (c) 2010-2011 Brian E. Granger & Min Ragan-Kelley
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#
#    This file is part of pyzmq.
#
#    pyzmq is free software; you can redistribute it and/or modify it under
#    the terms of the Lesser GNU General Public License as published by
#    the Free Software Foundation; either version 3 of the License, or
#    (at your option) any later version.
#
#    pyzmq is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    Lesser GNU General Public License for more details.
#
#    You should have received a copy of the Lesser GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Import the C header files
#-----------------------------------------------------------------------------

30 31 32 33 34 35
cdef extern from *:
    ctypedef void* const_void_ptr "const void *"

cdef extern from "allocate.h":
    object allocate(size_t n, void **pp)

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
cdef extern from "errno.h" nogil:
    enum: ZMQ_EINVAL "EINVAL"
    enum: ZMQ_EAGAIN "EAGAIN"
    enum: ZMQ_EFAULT "EFAULT"
    enum: ZMQ_ENOMEM "ENOMEM"
    enum: ZMQ_ENODEV "ENODEV"

cdef extern from "string.h" nogil:
    void *memcpy(void *dest, void *src, size_t n)
    size_t strlen(char *s)

cdef extern from "zmq_compat.h":
    ctypedef signed long long int64_t "pyzmq_int64_t"

cdef extern from "zmq.h" nogil:

    void _zmq_version "zmq_version"(int *major, int *minor, int *patch)
53 54 55
    
    ctypedef int fd_t "ZMQ_FD_T"
    
56 57 58 59 60
    enum: ZMQ_VERSION_MAJOR
    enum: ZMQ_VERSION_MINOR
    enum: ZMQ_VERSION_PATCH
    enum: ZMQ_VERSION

61 62 63 64 65 66 67 68 69
    enum: ZMQ_HAUSNUMERO
    enum: ZMQ_ENOTSUP "ENOTSUP"
    enum: ZMQ_EPROTONOSUPPORT "EPROTONOSUPPORT"
    enum: ZMQ_ENOBUFS "ENOBUFS"
    enum: ZMQ_ENETDOWN "ENETDOWN"
    enum: ZMQ_EADDRINUSE "EADDRINUSE"
    enum: ZMQ_EADDRNOTAVAIL "EADDRNOTAVAIL"
    enum: ZMQ_ECONNREFUSED "ECONNREFUSED"
    enum: ZMQ_EINPROGRESS "EINPROGRESS"
70
    enum: ZMQ_ENOTSOCK "ENOTSOCK"
71 72 73
    enum: ZMQ_EFSM "EFSM"
    enum: ZMQ_ENOCOMPATPROTO "ENOCOMPATPROTO"
    enum: ZMQ_ETERM "ETERM"
74
    enum: ZMQ_ECANTROUTE "ECANTROUTE"
75
    enum: ZMQ_EMTHREAD "EMTHREAD"
76 77 78 79 80 81 82 83 84 85
    
    enum: errno
    char *zmq_strerror (int errnum)
    int zmq_errno()

    enum: ZMQ_MAX_VSM_SIZE # 30
    enum: ZMQ_DELIMITER # 31
    enum: ZMQ_VSM # 32
    enum: ZMQ_MSG_MORE # 1
    enum: ZMQ_MSG_SHARED # 128
86 87 88
    
    # blackbox def for zmq_msg_t
    ctypedef void * zmq_msg_t "zmq_msg_t"
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
    
    ctypedef void zmq_free_fn(void *data, void *hint)
    
    int zmq_msg_init (zmq_msg_t *msg)
    int zmq_msg_init_size (zmq_msg_t *msg, size_t size)
    int zmq_msg_init_data (zmq_msg_t *msg, void *data,
        size_t size, zmq_free_fn *ffn, void *hint)
    int zmq_msg_close (zmq_msg_t *msg)
    int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src)
    int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src)
    void *zmq_msg_data (zmq_msg_t *msg)
    size_t zmq_msg_size (zmq_msg_t *msg)

    void *zmq_init (int io_threads)
    int zmq_term (void *context)

    enum: ZMQ_PAIR # 0
    enum: ZMQ_PUB # 1
    enum: ZMQ_SUB # 2
    enum: ZMQ_REQ # 3
    enum: ZMQ_REP # 4
    enum: ZMQ_XREQ # 5
111
    enum: ZMQ_DEALER # 5 or 12
112
    enum: ZMQ_XREP # 6
113
    enum: ZMQ_ROUTER # 6 or 11 or 13
114 115
    enum: ZMQ_PULL # 7
    enum: ZMQ_PUSH # 8
116 117
    enum: ZMQ_XPUB # 9
    enum: ZMQ_XSUB # 10
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
    enum: ZMQ_UPSTREAM # 7
    enum: ZMQ_DOWNSTREAM # 8

    enum: ZMQ_HWM # 1
    enum: ZMQ_SWAP # 3
    enum: ZMQ_AFFINITY # 4
    enum: ZMQ_IDENTITY # 5
    enum: ZMQ_SUBSCRIBE # 6
    enum: ZMQ_UNSUBSCRIBE # 7
    enum: ZMQ_RATE # 8
    enum: ZMQ_RECOVERY_IVL # 9
    enum: ZMQ_MCAST_LOOP # 10
    enum: ZMQ_SNDBUF # 11
    enum: ZMQ_RCVBUF # 12
    enum: ZMQ_RCVMORE # 13
133 134 135 136 137 138 139 140 141 142 143
    enum: ZMQ_FD # 14
    enum: ZMQ_EVENTS # 15
    enum: ZMQ_TYPE # 16
    enum: ZMQ_LINGER # 17
    enum: ZMQ_RECONNECT_IVL # 18
    enum: ZMQ_BACKLOG # 19
    enum: ZMQ_RECOVERY_IVL_MSEC # 20
    enum: ZMQ_RECONNECT_IVL_MAX # 21
    enum: ZMQ_MAXMSGSIZE # 22
    enum: ZMQ_SNDHWM # 23
    enum: ZMQ_RCVHWM # 24
144 145 146 147 148
    enum: ZMQ_MULTICAST_HOPS # 25
    enum: ZMQ_RCVTIMEO # 27
    enum: ZMQ_SNDTIMEO # 28
    enum: ZMQ_RCVLABEL # 29
    enum: ZMQ_RCVCMD # 30
149 150

    enum: ZMQ_NOBLOCK # 1
151
    enum: ZMQ_DONTWAIT # 1
152
    enum: ZMQ_SNDMORE # 2
153 154
    enum: ZMQ_SNDLABEL # 4
    enum: ZMQ_SNDCMD # 8
155 156 157 158 159 160 161

    void *zmq_socket (void *context, int type)
    int zmq_close (void *s)
    int zmq_setsockopt (void *s, int option, void *optval, size_t optvallen)
    int zmq_getsockopt (void *s, int option, void *optval, size_t *optvallen)
    int zmq_bind (void *s, char *addr)
    int zmq_connect (void *s, char *addr)
162 163 164 165 166 167
    # send/recv
    int zmq_sendmsg (void *s, zmq_msg_t *msg, int flags)
    int zmq_recvmsg (void *s, zmq_msg_t *msg, int flags)
    int zmq_sendbuf (void *s, const_void_ptr buf, size_t n, int flags)
    int zmq_recvbuf (void *s, void *buf, size_t n, int flags)

168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
    enum: ZMQ_POLLIN # 1
    enum: ZMQ_POLLOUT # 2
    enum: ZMQ_POLLERR # 4

    ctypedef struct zmq_pollitem_t:
        void *socket
        int fd
        # #if defined _WIN32
        #     SOCKET fd;
        short events
        short revents

    int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout)

    enum: ZMQ_STREAMER
    enum: ZMQ_FORWARDER
    enum: ZMQ_QUEUE
185
    # removed in libzmq
186 187 188 189 190 191 192 193
    int zmq_device (int device_, void *insocket_, void *outsocket_)

cdef extern from "zmq_utils.h" nogil:

    void *zmq_stopwatch_start ()
    unsigned long zmq_stopwatch_stop (void *watch_)
    void zmq_sleep (int seconds_)