ZMQ.inc

#If 0 

    BASIC translation of zmq.h - June 2011 - Coast Research

    Version 2.1.7
                               
    Copyright (c) 2007-2010 iMatix Corporation

    This file is part OF ØMQ.

    ØMQ 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.

    ØMQ 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/>. 

#EndIf

         

TYPE WSAdata
    wVersion       AS WORD
    wHighVersion   AS WORD
    szDescription  AS ASCIIZ * 257 ' (%WSADESCRIPTION_LEN + 1)
    xFiller1       AS STRING * 3
    szSystemStatus AS ASCIIZ * 129 ' (%WSASYS_STATUS_LEN + 1)
    xFiller2       AS STRING * 3
    iMaxSockets    AS WORD
    iMaxUdpDg      AS WORD
    lpVendorInfo   AS ASCIIZ PTR
END TYPE

DECLARE FUNCTION WSAStartup LIB "wsock32.dll" ALIAS "WSAStartup" (BYVAL wVR AS WORD, lpWSAD AS WSAData) AS LONG
DECLARE FUNCTION WSACleanup LIB "wsock32.dll" ALIAS "WSACleanup" () AS LONG
DECLARE FUNCTION WSAGetLastError LIB "wsock32.dll" ALIAS "WSAGetLastError" () AS LONG

         
%ZMQ_VERSION_MAJOR      = 2
%ZMQ_VERSION_MINOR      = 1
%ZMQ_VERSION_PATCH      = 7
                       
                       
%ZMQ_HAUSNUMERO         = 156384712 ' avoid collision with other errno ranges
                       
%ENOTSUP                = %ZMQ_HAUSNUMERO + 1  ' POSIX errors
%EPROTONOSUPPORT        = %ZMQ_HAUSNUMERO + 2  '
%ENOBUFS                = %ZMQ_HAUSNUMERO + 3  '
%ENETDOWN               = %ZMQ_HAUSNUMERO + 4  '
%EADDRINUSE             = %ZMQ_HAUSNUMERO + 5  '
%EADDRNOTAVAIL          = %ZMQ_HAUSNUMERO + 6  '
%ECONNREFUSED           = %ZMQ_HAUSNUMERO + 7  '
%EINPROGRESS            = %ZMQ_HAUSNUMERO + 8  '
%ENOTSOCK               = %ZMQ_HAUSNUMERO + 9  '
                       
%EFSM                   = %ZMQ_HAUSNUMERO + 51 ' Native ØMQ error codes
%ENOCOMPATPROTO         = %ZMQ_HAUSNUMERO + 52 ' 
%ETERM                  = %ZMQ_HAUSNUMERO + 53 '
%EMTHREAD               = %ZMQ_HAUSNUMERO + 54 '
                       
                       
%ZMQ_MAX_VSM_SIZE       = 30  ' Max size of "Very Small Message". VSMs are passed by value to reduce memory alloc/dealloc
                       
%ZMQ_DELIMITER          = 31  ' Message type - may be stored in 'content' member of the
%ZMQ_VSM                = 32  ' Message type - message instead of regular pointer to the data
                       
                       
                       
                       
%ZMQ_MSG_MORE           = 1   ' Message flags. ZMQ_MSG_SHARED is strictly speaking NOT a message flag
%ZMQ_MSG_SHARED         = 128 ' (it has no equivalent IN the wire format), however, making  it a flag
                              ' allows us TO pack the stucture tigher AND thus improve performance. 
%ZMQ_MSG_MASK           = 129 ' Merges ALL the flags
                       
                       
%ZMQ_MSG_TBC            = 1   ' Message flag
%ZMQ_MSG_SHARED         = 128 ' strictly speaking not a message flag
                          
%ZMQ_POLL               = 1   ' ØMQ infrastructure (a.k.a. context) initialisation & termination
                       
%ZMQ_PAIR               = 0   ' ØMQ socket types
%ZMQ_PUB                = 1   '
%ZMQ_SUB                = 2   '
%ZMQ_REQ                = 3   '
%ZMQ_REP                = 4   '
%ZMQ_DEALER             = 5   '
%ZMQ_ROUTER             = 6   '
%ZMQ_PULL               = 7   '
%ZMQ_PUSH               = 8   '
%ZMQ_XPUB               = 9   '
%ZMQ_XSUB               = 10  '
'%ZMQ_XREQ ZMQ_DEALER     ' Old ALIAS, remove IN 3.x
'%ZMQ_XREP ZMQ_ROUTER     ' Old ALIAS, remove IN 3.x
'%ZMQ_UPSTREAM ZMQ_PULL   ' Old ALIAS, remove IN 3.x
'%ZMQ_DOWNSTREAM ZMQ_PUSH ' Old ALIAS, remove IN 3.x
   
                                                
%ZMQ_HWM                = 1  ' ØMQ Socket options
%ZMQ_SWAP               = 3
%ZMQ_AFFINITY           = 4
%ZMQ_IDENTITY           = 5
%ZMQ_SUBSCRIBE          = 6
%ZMQ_UNSUBSCRIBE        = 7
%ZMQ_RATE               = 8
%ZMQ_RECOVERY_IVL       = 9
%ZMQ_MCAST_LOOP         = 10
%ZMQ_SNDBUF             = 11
%ZMQ_RCVBUF             = 12
%ZMQ_RCVMORE            = 13
%ZMQ_FD                 = 14
%ZMQ_EVENTS             = 15
%ZMQ_TYPE               = 16
%ZMQ_LINGER             = 17
%ZMQ_RECONNECT_IVL      = 18
%ZMQ_BACKLOG            = 19
%ZMQ_RECOVERY_IVL_MSEC  = 20 ' OPT. recovery time, reconcile IN 3.x 
%ZMQ_RECONNECT_IVL_MAX  = 21


%ZMQ_NOBLOCK            = 1   ' ØMQ Send/recv options
%ZMQ_NOFLUSH            = 2   '
%ZMQ_SNDMORE            = 2   '     
                       
%ZMQ_POLLIN             = 1   ' ØMQ I/O multiplexing
%ZMQ_POLLOUT            = 2
%ZMQ_POLLERR            = 4
                                                 
%ZMQ_STREAMER           = 1   ' ØMQ Built-in devices
%ZMQ_FORWARDER          = 2
%ZMQ_QUEUE              = 3




TYPE zmq_pollitem_t     ' I/O multiplexing
    pSocket AS DWORD    ' void *socket;
    fd      AS LONG     ' int fd;
    events  AS INTEGER  ' short events;
    revents AS INTEGER  ' short revents;
END TYPE
        
 
'  Shared message buffer. Message data are either allocated in one
'  continuous block along with this structure - thus avoiding one
'  malloc/free pair or they are stored in used-supplied memory.
'  In the latter case, ffn member stores pointer to the function to be
'  used to deallocate the data. If the buffer is actually shared
'  (there are at least 2 references to it) refcount member contains number of references.
TYPE msg_content_t
    pData    AS DWORD ' void *DATA;
    DataLen  AS DWORD ' size_t SIZE;
    pFree    AS DWORD ' zmq_free_fn *ffn;
    phInt    AS DWORD ' void *hint;  
    refcnt   AS LONG  ' atomic_counter_t refcnt - Set counter value (not thread-safe).
END TYPE              ' A class that represents an integer that can be incremented/decremented in atomic fashion.

  
' Note: 'content' is not a pointer to the raw data, it is pointer to msg_content_t structure
TYPE zmq_msg_t                          ' Message structure
    pContent  AS msg_content_t PTR      ' pointer to msg_content_t structure
    flags     AS BYTE                   ' unsigned char flags;
    vsm_size  AS BYTE                   ' unsigned char vsm_size
    vsm_data(%ZMQ_MAX_VSM_SIZE) AS BYTE ' unsigned char vsm_data [ZMQ_MAX_VSM_SIZE]
END TYPE


TYPE ZMQ_free_fn        '
    pData AS DWORD      ' void *DATA
    hInt  AS DWORD      ' void *hint
END TYPE 



'------------ Sockets
       
'ZMQ_EXPORT void *zmq_init        (int app_threads, int io_threads, int flags)
DECLARE FUNCTION zmq_init CDECL LIB "libzmq.dll" ALIAS "zmq_init" ( BYVAL io_threads AS LONG ) AS DWORD

'ZMQ_EXPORT INT  zmq_connect (void *s, const char *ADDR)
DECLARE FUNCTION zmq_connect CDECL LIB "libzmq.dll" ALIAS "zmq_connect" ( BYVAL pSoc AS DWORD, BYVAL psAddr AS DWORD ) AS LONG
 
'ZMQ_EXPORT INT  zmq_bind (void *s, const char *ADDR)
DECLARE FUNCTION zmq_bind CDECL LIB "libzmq.dll" ALIAS "zmq_bind" ( BYVAL pSoc AS DWORD, BYVAL psAddr AS DWORD ) AS LONG

'ZMQ_EXPORT void *zmq_socket (void *context, INT TYPE)
DECLARE FUNCTION zmq_socket CDECL LIB "libzmq.dll" ALIAS "zmq_socket" ( BYVAL pContext AS DWORD, BYVAL SocType AS LONG ) AS DWORD ' PTR 

'ZMQ_EXPORT INT  zmq_setsockopt (void *s, INT OPTION, const void *optval, size_t optvallen)
DECLARE FUNCTION zmq_setsockopt CDECL LIB "libzmq.dll" ALIAS "zmq_setsockopt" ( BYVAL pSoc AS DWORD, BYVAL Optn AS LONG, BYVAL OptVal AS DWORD, BYVAL OptValLen AS LONG ) AS LONG
                               
'ZMQ_EXPORT INT zmq_getsockopt (void *s, INT OPTION,        void *optval, size_t *optvallen)
DECLARE FUNCTION zmq_getsockopt CDECL LIB "libzmq.dll" ALIAS "zmq_getsockopt" ( BYVAL pSoc AS DWORD, BYVAL Optn AS LONG, BYVAL OptVal AS DWORD, OptValLen AS LONG ) AS LONG
    
'ZMQ_EXPORT INT  zmq_send (void *s, zmq_msg_t *msg, INT flags)
DECLARE FUNCTION zmq_send CDECL LIB "libzmq.dll" ALIAS "zmq_send" ( BYVAL pSoc AS DWORD, BYVAL pMsg AS ZMQ_msg_t PTR, BYVAL flags AS LONG ) AS LONG

'ZMQ_EXPORT INT  zmq_flush (void *s)
DECLARE FUNCTION zmq_flush CDECL LIB "libzmq.dll" ALIAS "zmq_flush" ( BYVAL pSoc AS DWORD ) AS LONG

'ZMQ_EXPORT INT  zmq_recv (void *s, zmq_msg_t *msg, INT flags)
DECLARE FUNCTION zmq_recv CDECL LIB "libzmq.dll" ALIAS "zmq_recv" ( BYVAL pSoc AS DWORD, BYVAL pMsg AS ZMQ_msg_t PTR, BYVAL flags AS LONG ) AS LONG
           
'ZMQ_EXPORT INT  zmq_poll ( ZMQ_pollitem_t *items, INT nitems, LONG TIMEOUT) 
DECLARE FUNCTION zmq_poll CDECL LIB "libzmq.dll" ALIAS "zmq_poll" ( BYVAL pItems AS ZMQ_pollitem_t PTR, BYVAL nItems AS LONG, BYVAL Tymeout AS LONG ) AS LONG
               
'ZMQ_EXPORT INT  zmq_close (void *s)
DECLARE FUNCTION zmq_close CDECL LIB "libzmq.dll" ALIAS "zmq_close" ( BYVAL pSoc AS DWORD ) AS LONG

'ZMQ_EXPORT int  zmq_term          (void *context)
DECLARE FUNCTION zmq_term CDECL LIB "libzmq.dll" ALIAS "zmq_term" ( BYVAL pCtxt AS DWORD ) AS LONG   
  


'------------ Messages

'ZMQ_EXPORT INT  zmq_msg_init      ( ZMQ_msg_t *msg )
DECLARE FUNCTION zmq_msg_init CDECL LIB "libzmq.dll" ALIAS "zmq_msg_init" ( BYVAL pMsg AS ZMQ_msg_t PTR ) AS LONG

'ZMQ_EXPORT int  zmq_msg_init_size ( ZMQ_msg_t *msg, size_t size)
DECLARE FUNCTION zmq_msg_init_size CDECL LIB "libzmq.dll" ALIAS "zmq_msg_init_size" ( BYVAL pMsg AS ZMQ_msg_t PTR, BYVAL tSize AS DWORD ) AS LONG

'ZMQ_EXPORT INT  zmq_msg_init_data ( ZMQ_msg_t *msg, void *DATA, size_t SIZE, zmq_free_fn *ffn, void *hint)
DECLARE FUNCTION zmq_msg_init_data CDECL LIB "libzmq.dll" ALIAS "zmq_msg_init_data" ( BYVAL pMsg AS ZMQ_msg_t PTR, BYVAL pData AS DWORD, BYVAL tSize AS DWORD, _
                                    BYVAL pffn AS zmq_free_fn PTR, BYVAL hint AS DWORD ) AS LONG

'ZMQ_EXPORT int  zmq_msg_move      ( ZMQ_msg_t *dest, zmq_msg_t *src)
DECLARE FUNCTION zmq_msg_move CDECL LIB "libzmq.dll" ALIAS "zmq_msg_move" ( BYVAL dest AS ZMQ_msg_t PTR, BYVAL src AS ZMQ_msg_t PTR ) AS LONG
                                 
'ZMQ_EXPORT int  zmq_msg_copy      ( ZMQ_msg_t *dest, zmq_msg_t *src)
DECLARE FUNCTION zmq_msg_copy CDECL LIB "libzmq.dll" ALIAS "zmq_msg_copy" ( BYVAL dest AS ZMQ_msg_t PTR, BYVAL src AS ZMQ_msg_t PTR ) AS LONG

'ZMQ_EXPORT void *zmq_msg_data     ( ZMQ_msg_t *msg)
DECLARE FUNCTION zmq_msg_data CDECL LIB "libzmq.dll" ALIAS "zmq_msg_data" ( BYVAL pMsg AS ZMQ_msg_t PTR ) AS DWORD

'ZMQ_EXPORT size_t zmq_msg_size    ( ZMQ_msg_t *msg)
DECLARE FUNCTION zmq_msg_size CDECL LIB "libzmq.dll" ALIAS "zmq_msg_size" ( BYVAL pMsg AS ZMQ_msg_t PTR ) AS DWORD

'ZMQ_EXPORT int  zmq_msg_close     ( ZMQ_msg_t *msg)
DECLARE FUNCTION zmq_msg_close CDECL LIB "libzmq.dll" ALIAS "zmq_msg_close" ( BYVAL pMsg AS ZMQ_msg_t PTR ) AS LONG
                       


'------------ Misc
          
'ZMQ_EXPORT void zmq_version (INT *major, INT *minor, INT *patch)
DECLARE SUB      zmq_version CDECL LIB "libzmq.dll" ALIAS "zmq_version" ( pMajor AS LONG, pMinor AS LONG, pPatch AS LONG )
                
'ZMQ_EXPORT INT  zmq_errno()
DECLARE FUNCTION zmq_errno CDECL LIB "libzmq.dll" ALIAS "zmq_errno" () AS LONG

' ZMQ_EXPORT const char *zmq_strerror (INT errnum) 
DECLARE FUNCTION zmq_strerror CDECL LIB "libzmq.dll" ALIAS "zmq_strerror" ( BYVAL errnum AS LONG ) AS DWORD

'ZMQ_EXPORT void *zmq_stopwatch_start () 
DECLARE FUNCTION zmq_stopwatch_start CDECL LIB "libzmq.dll" ALIAS "zmq_stopwatch_start" () AS DWORD ' Returns the handle to the watch.

'ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_)
DECLARE FUNCTION zmq_stopwatch_stop CDECL LIB "libzmq.dll" ALIAS "zmq_stopwatch_stop" ( BYVAL pWatch AS DWORD ) AS DWORD ' Returns the number of microseconds elapsed since

'ZMQ_EXPORT void zmq_sleep (INT seconds_)
DECLARE SUB      zmq_sleep CDECL LIB "libzmq.dll" ALIAS "zmq_sleep" ( BYVAL Secs AS LONG ) '   Sleeps for specified number of seconds.
                          
'ZMQ_EXPORT INT zmq_device (INT device, void * insocket, void* outsocket); 
DECLARE FUNCTION zmq_device CDECL LIB "libzmq.dll" ALIAS "zmq_device" ( BYVAL device AS LONG, BYVAL pInSocket AS DWORD, BYVAL pOutSocket AS DWORD ) AS LONG
 

'------------ POSIX error codes
%EPERM         = 1
%ENOENT        = 2
%ESRCH         = 3
%EINTR         = 4
%EIO           = 5
%ENXIO         = 6
%E2BIG         = 7
%ENOEXEC       = 8
%EBADF         = 9
%ECHILD        = 10
%EAGAIN        = 11
%ENOMEM        = 12
%EACCES        = 13
%EFAULT        = 14

%EBUSY         = 16
%EEXIST        = 17
%EXDEV         = 18
%ENODEV        = 19
%ENOTDIR       = 20
%EISDIR        = 21
%ENFILE        = 23
%EMFILE        = 24
%ENOTTY        = 25
%EFBIG         = 27
%ENOSPC        = 28
%ESPIPE        = 29
%EROFS         = 30
%EMLINK        = 31
%EPIPE         = 32
%EDOM          = 33
%EDEADLK       = 36
%ENAMETOOLONG  = 38
%ENOLCK        = 39
%ENOSYS        = 40
%ENOTEMPTY     = 41

%EINVAL        = 22 ' Codes used in the Secure CRT functions
%ERANGE        = 34
%EILSEQ        = 42
%STRUNCATE     = 80
  

Comments