module System.ZMQ3.Base where
import Foreign
import Foreign.C.Types
import Foreign.C.String
import Control.Applicative
newtype ZMQMsg = ZMQMsg { content :: Ptr () } deriving (Eq, Ord)
instance Storable ZMQMsg where
alignment _ = 1
sizeOf _ = (32)
peek p = ZMQMsg <$> (\hsc_ptr -> peekByteOff hsc_ptr 0) p
poke p (ZMQMsg c) = (\hsc_ptr -> pokeByteOff hsc_ptr 0) p c
data ZMQPoll = ZMQPoll
{ pSocket :: !ZMQSocket
, pFd :: !CInt
, pEvents :: !CShort
, pRevents :: !CShort
}
instance Storable ZMQPoll where
alignment _ = 4
sizeOf _ = (12)
peek p = do
s <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p
f <- (\hsc_ptr -> peekByteOff hsc_ptr 4) p
e <- (\hsc_ptr -> peekByteOff hsc_ptr 8) p
re <- (\hsc_ptr -> peekByteOff hsc_ptr 10) p
return $ ZMQPoll s f e re
poke p (ZMQPoll s f e re) = do
(\hsc_ptr -> pokeByteOff hsc_ptr 0) p s
(\hsc_ptr -> pokeByteOff hsc_ptr 4) p f
(\hsc_ptr -> pokeByteOff hsc_ptr 8) p e
(\hsc_ptr -> pokeByteOff hsc_ptr 10) p re
type ZMQMsgPtr = Ptr ZMQMsg
type ZMQCtx = Ptr ()
type ZMQSocket = Ptr ()
type ZMQPollPtr = Ptr ZMQPoll
newtype ZMQSocketType = ZMQSocketType { typeVal :: CInt } deriving (Eq, Ord)
pair :: ZMQSocketType
pair = ZMQSocketType 0
pub :: ZMQSocketType
pub = ZMQSocketType 1
sub :: ZMQSocketType
sub = ZMQSocketType 2
xpub :: ZMQSocketType
xpub = ZMQSocketType 9
xsub :: ZMQSocketType
xsub = ZMQSocketType 10
request :: ZMQSocketType
request = ZMQSocketType 3
response :: ZMQSocketType
response = ZMQSocketType 4
dealer :: ZMQSocketType
dealer = ZMQSocketType 5
router :: ZMQSocketType
router = ZMQSocketType 6
pull :: ZMQSocketType
pull = ZMQSocketType 7
push :: ZMQSocketType
push = ZMQSocketType 8
newtype ZMQOption = ZMQOption { optVal :: CInt } deriving (Eq, Ord)
affinity :: ZMQOption
affinity = ZMQOption 4
backlog :: ZMQOption
backlog = ZMQOption 19
delayAttachOnConnect :: ZMQOption
delayAttachOnConnect = ZMQOption 39
events :: ZMQOption
events = ZMQOption 15
filedesc :: ZMQOption
filedesc = ZMQOption 14
identity :: ZMQOption
identity = ZMQOption 5
ipv4Only :: ZMQOption
ipv4Only = ZMQOption 31
lastEndpoint :: ZMQOption
lastEndpoint = ZMQOption 32
linger :: ZMQOption
linger = ZMQOption 17
maxMessageSize :: ZMQOption
maxMessageSize = ZMQOption 22
mcastHops :: ZMQOption
mcastHops = ZMQOption 25
rate :: ZMQOption
rate = ZMQOption 8
receiveBuf :: ZMQOption
receiveBuf = ZMQOption 12
receiveHighWM :: ZMQOption
receiveHighWM = ZMQOption 24
receiveMore :: ZMQOption
receiveMore = ZMQOption 13
receiveTimeout :: ZMQOption
receiveTimeout = ZMQOption 27
reconnectIVL :: ZMQOption
reconnectIVL = ZMQOption 18
reconnectIVLMax :: ZMQOption
reconnectIVLMax = ZMQOption 21
recoveryIVL :: ZMQOption
recoveryIVL = ZMQOption 9
routerMandatory :: ZMQOption
routerMandatory = ZMQOption 33
sendBuf :: ZMQOption
sendBuf = ZMQOption 11
sendHighWM :: ZMQOption
sendHighWM = ZMQOption 23
sendTimeout :: ZMQOption
sendTimeout = ZMQOption 28
subscribe :: ZMQOption
subscribe = ZMQOption 6
tcpAcceptFilter :: ZMQOption
tcpAcceptFilter = ZMQOption 38
tcpKeepAlive :: ZMQOption
tcpKeepAlive = ZMQOption 34
tcpKeepAliveCount :: ZMQOption
tcpKeepAliveCount = ZMQOption 35
tcpKeepAliveIdle :: ZMQOption
tcpKeepAliveIdle = ZMQOption 36
tcpKeepAliveInterval :: ZMQOption
tcpKeepAliveInterval = ZMQOption 37
unsubscribe :: ZMQOption
unsubscribe = ZMQOption 7
xpubVerbose :: ZMQOption
xpubVerbose = ZMQOption 40
newtype ZMQCtxOption = ZMQCtxOption { ctxOptVal :: CInt } deriving (Eq, Ord)
_ioThreads :: ZMQCtxOption
_ioThreads = ZMQCtxOption 1
_maxSockets :: ZMQCtxOption
_maxSockets = ZMQCtxOption 2
newtype ZMQEventType = ZMQEventType { eventTypeVal :: CInt } deriving (Eq, Ord)
connected :: ZMQEventType
connected = ZMQEventType 1
connectDelayed :: ZMQEventType
connectDelayed = ZMQEventType 2
connectRetried :: ZMQEventType
connectRetried = ZMQEventType 4
listening :: ZMQEventType
listening = ZMQEventType 8
bindFailed :: ZMQEventType
bindFailed = ZMQEventType 16
accepted :: ZMQEventType
accepted = ZMQEventType 32
acceptFailed :: ZMQEventType
acceptFailed = ZMQEventType 64
closed :: ZMQEventType
closed = ZMQEventType 128
closeFailed :: ZMQEventType
closeFailed = ZMQEventType 256
disconnected :: ZMQEventType
disconnected = ZMQEventType 512
allEvents :: ZMQEventType
allEvents = ZMQEventType 1023
zmqEventAddrOffset, zmqEventDataOffset :: Int
zmqEventAddrOffset = (4)
zmqEventDataOffset = (8)
newtype ZMQMsgOption = ZMQMsgOption { msgOptVal :: CInt } deriving (Eq, Ord)
more :: ZMQMsgOption
more = ZMQMsgOption 1
newtype ZMQFlag = ZMQFlag { flagVal :: CInt } deriving (Eq, Ord)
dontWait :: ZMQFlag
dontWait = ZMQFlag 1
sndMore :: ZMQFlag
sndMore = ZMQFlag 2
newtype ZMQPollEvent = ZMQPollEvent { pollVal :: CShort } deriving (Eq, Ord)
pollIn :: ZMQPollEvent
pollIn = ZMQPollEvent 1
pollOut :: ZMQPollEvent
pollOut = ZMQPollEvent 2
pollerr :: ZMQPollEvent
pollerr = ZMQPollEvent 4
foreign import ccall unsafe "zmq.h zmq_version"
c_zmq_version :: Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
foreign import ccall unsafe "zmq.h zmq_ctx_new"
c_zmq_ctx_new :: IO ZMQCtx
foreign import ccall unsafe "zmq.h zmq_ctx_destroy"
c_zmq_ctx_destroy :: ZMQCtx -> IO CInt
foreign import ccall unsafe "zmq.h zmq_ctx_get"
c_zmq_ctx_get :: ZMQCtx -> CInt -> IO CInt
foreign import ccall unsafe "zmq.h zmq_ctx_set"
c_zmq_ctx_set :: ZMQCtx -> CInt -> CInt -> IO CInt
foreign import ccall unsafe "zmq.h zmq_msg_init"
c_zmq_msg_init :: ZMQMsgPtr -> IO CInt
foreign import ccall unsafe "zmq.h zmq_msg_init_size"
c_zmq_msg_init_size :: ZMQMsgPtr -> CSize -> IO CInt
foreign import ccall unsafe "zmq.h zmq_msg_close"
c_zmq_msg_close :: ZMQMsgPtr -> IO CInt
foreign import ccall unsafe "zmq.h zmq_msg_data"
c_zmq_msg_data :: ZMQMsgPtr -> IO (Ptr a)
foreign import ccall unsafe "zmq.h zmq_msg_size"
c_zmq_msg_size :: ZMQMsgPtr -> IO CSize
foreign import ccall unsafe "zmq.h zmq_msg_get"
c_zmq_msg_get :: ZMQMsgPtr -> CInt -> IO CInt
foreign import ccall unsafe "zmq.h zmq_msg_set"
c_zmq_msg_set :: ZMQMsgPtr -> CInt -> CInt -> IO CInt
foreign import ccall unsafe "zmq.h zmq_socket"
c_zmq_socket :: ZMQCtx -> CInt -> IO ZMQSocket
foreign import ccall unsafe "zmq.h zmq_close"
c_zmq_close :: ZMQSocket -> IO CInt
foreign import ccall unsafe "zmq.h zmq_setsockopt"
c_zmq_setsockopt :: ZMQSocket
-> CInt
-> Ptr ()
-> CSize
-> IO CInt
foreign import ccall unsafe "zmq.h zmq_getsockopt"
c_zmq_getsockopt :: ZMQSocket
-> CInt
-> Ptr ()
-> Ptr CSize
-> IO CInt
foreign import ccall unsafe "zmq.h zmq_bind"
c_zmq_bind :: ZMQSocket -> CString -> IO CInt
foreign import ccall unsafe "zmq.h zmq_unbind"
c_zmq_unbind :: ZMQSocket -> CString -> IO CInt
foreign import ccall unsafe "zmq.h zmq_connect"
c_zmq_connect :: ZMQSocket -> CString -> IO CInt
foreign import ccall unsafe "zmq.h zmq_sendmsg"
c_zmq_sendmsg :: ZMQSocket -> ZMQMsgPtr -> CInt -> IO CInt
foreign import ccall unsafe "zmq.h zmq_recvmsg"
c_zmq_recvmsg :: ZMQSocket -> ZMQMsgPtr -> CInt -> IO CInt
foreign import ccall unsafe "zmq.h zmq_socket_monitor"
c_zmq_socket_monitor :: ZMQSocket -> CString -> CInt -> IO CInt
foreign import ccall unsafe "zmq.h zmq_strerror"
c_zmq_strerror :: CInt -> IO CString
foreign import ccall unsafe "zmq.h zmq_proxy"
c_zmq_proxy :: ZMQSocket -> ZMQSocket -> ZMQSocket -> IO CInt
foreign import ccall safe "zmq.h zmq_poll"
c_zmq_poll :: ZMQPollPtr -> CInt -> CLong -> IO CInt