diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/xs.h | 246 | ||||
-rw-r--r-- | include/xs_utils.h (renamed from include/zmq_utils.h) | 30 | ||||
-rw-r--r-- | include/zmq.h | 246 |
3 files changed, 261 insertions, 261 deletions
diff --git a/include/xs.h b/include/xs.h new file mode 100644 index 0000000..05d98ab --- /dev/null +++ b/include/xs.h @@ -0,0 +1,246 @@ +/* + Copyright (c) 2009-2012 250bpm s.r.o. + Copyright (c) 2007-2010 iMatix Corporation + Copyright (c) 2011 VMware, Inc. + Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file + + This file is part of Crossroads project. + + Crossroads is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Crossroads 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 + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __XS_H_INCLUDED__ +#define __XS_H_INCLUDED__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <errno.h> +#include <stddef.h> +#if defined _WIN32 +#include <winsock2.h> +#endif + +/* Handle DSO symbol visibility */ +#if defined _WIN32 +# if defined DLL_EXPORT +# define XS_EXPORT __declspec(dllexport) +# else +# define XS_EXPORT __declspec(dllimport) +# endif +#else +# if defined __SUNPRO_C || defined __SUNPRO_CC +# define XS_EXPORT __global +# elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER +# define XS_EXPORT __attribute__ ((visibility("default"))) +# else +# define XS_EXPORT +# endif +#endif + +/******************************************************************************/ +/* Crossroads versioning support. */ +/******************************************************************************/ + +/* Version macros for compile-time API version detection */ +#define XS_VERSION_MAJOR 0 +#define XS_VERSION_MINOR 0 +#define XS_VERSION_PATCH 0 + +#define XS_MAKE_VERSION(major, minor, patch) \ + ((major) * 10000 + (minor) * 100 + (patch)) +#define XS_VERSION \ + XS_MAKE_VERSION(XS_VERSION_MAJOR, XS_VERSION_MINOR, XS_VERSION_PATCH) + +/* Run-time API version detection */ +XS_EXPORT void xs_version (int *major, int *minor, int *patch); + +/******************************************************************************/ +/* Crossroads errors. */ +/******************************************************************************/ + +/* A number random enough not to collide with different errno ranges on */ +/* different OSes. The assumption is that error_t is at least 32-bit type. */ +#define XS_HAUSNUMERO 156384712 + +/* On Windows platform some of the standard POSIX errnos are not defined. */ +#ifndef ENOTSUP +#define ENOTSUP (XS_HAUSNUMERO + 1) +#endif +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT (XS_HAUSNUMERO + 2) +#endif +#ifndef ENOBUFS +#define ENOBUFS (XS_HAUSNUMERO + 3) +#endif +#ifndef ENETDOWN +#define ENETDOWN (XS_HAUSNUMERO + 4) +#endif +#ifndef EADDRINUSE +#define EADDRINUSE (XS_HAUSNUMERO + 5) +#endif +#ifndef EADDRNOTAVAIL +#define EADDRNOTAVAIL (XS_HAUSNUMERO + 6) +#endif +#ifndef ECONNREFUSED +#define ECONNREFUSED (XS_HAUSNUMERO + 7) +#endif +#ifndef EINPROGRESS +#define EINPROGRESS (XS_HAUSNUMERO + 8) +#endif +#ifndef ENOTSOCK +#define ENOTSOCK (XS_HAUSNUMERO + 9) +#endif +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT (XS_HAUSNUMERO + 10) +#endif + +/* Native Crossroads error codes. */ +#define EFSM (XS_HAUSNUMERO + 51) +#define ENOCOMPATPROTO (XS_HAUSNUMERO + 52) +#define ETERM (XS_HAUSNUMERO + 53) +#define EMTHREAD (XS_HAUSNUMERO + 54) + +/* This function retrieves the errno as it is known to Crossroads library. */ +/* The goal of this function is to make the code 100% portable, including */ +/* where Crossroads are compiled with certain CRT library (on Windows) is */ +/* linked to an application that uses different CRT library. */ +XS_EXPORT int xs_errno (void); + +/* Resolves system errors and Crossroads errors to human-readable string. */ +XS_EXPORT const char *xs_strerror (int errnum); + +/******************************************************************************/ +/* Crossroads message definition. */ +/******************************************************************************/ + +typedef struct {unsigned char _ [32];} xs_msg_t; + +typedef void (xs_free_fn) (void *data, void *hint); + +XS_EXPORT int xs_msg_init (xs_msg_t *msg); +XS_EXPORT int xs_msg_init_size (xs_msg_t *msg, size_t size); +XS_EXPORT int xs_msg_init_data (xs_msg_t *msg, void *data, + size_t size, xs_free_fn *ffn, void *hint); +XS_EXPORT int xs_msg_close (xs_msg_t *msg); +XS_EXPORT int xs_msg_move (xs_msg_t *dest, xs_msg_t *src); +XS_EXPORT int xs_msg_copy (xs_msg_t *dest, xs_msg_t *src); +XS_EXPORT void *xs_msg_data (xs_msg_t *msg); +XS_EXPORT size_t xs_msg_size (xs_msg_t *msg); +XS_EXPORT int xs_getmsgopt (xs_msg_t *msg, int option, void *optval, + size_t *optvallen); + +/******************************************************************************/ +/* Crossroads infrastructure initialisation & termination. */ +/******************************************************************************/ + +XS_EXPORT void *xs_init (int io_threads); +XS_EXPORT int xs_term (void *context); + +/******************************************************************************/ +/* Crossroads socket definition. */ +/******************************************************************************/ + +/* Socket types. */ +#define XS_PAIR 0 +#define XS_PUB 1 +#define XS_SUB 2 +#define XS_REQ 3 +#define XS_REP 4 +#define XS_XREQ 5 +#define XS_XREP 6 +#define XS_PULL 7 +#define XS_PUSH 8 +#define XS_XPUB 9 +#define XS_XSUB 10 + +#define XS_ROUTER XS_XREP +#define XS_DEALER XS_XREQ + +/* Socket options. */ +#define XS_AFFINITY 4 +#define XS_IDENTITY 5 +#define XS_SUBSCRIBE 6 +#define XS_UNSUBSCRIBE 7 +#define XS_RATE 8 +#define XS_RECOVERY_IVL 9 +#define XS_SNDBUF 11 +#define XS_RCVBUF 12 +#define XS_RCVMORE 13 +#define XS_FD 14 +#define XS_EVENTS 15 +#define XS_TYPE 16 +#define XS_LINGER 17 +#define XS_RECONNECT_IVL 18 +#define XS_BACKLOG 19 +#define XS_RECONNECT_IVL_MAX 21 +#define XS_MAXMSGSIZE 22 +#define XS_SNDHWM 23 +#define XS_RCVHWM 24 +#define XS_MULTICAST_HOPS 25 +#define XS_RCVTIMEO 27 +#define XS_SNDTIMEO 28 +#define XS_IPV4ONLY 31 + +/* Message options */ +#define XS_MORE 1 + +/* Send/recv options. */ +#define XS_DONTWAIT 1 +#define XS_SNDMORE 2 + +XS_EXPORT void *xs_socket (void *context, int type); +XS_EXPORT int xs_close (void *s); +XS_EXPORT int xs_setsockopt (void *s, int option, const void *optval, + size_t optvallen); +XS_EXPORT int xs_getsockopt (void *s, int option, void *optval, + size_t *optvallen); +XS_EXPORT int xs_bind (void *s, const char *addr); +XS_EXPORT int xs_connect (void *s, const char *addr); +XS_EXPORT int xs_send (void *s, const void *buf, size_t len, int flags); +XS_EXPORT int xs_recv (void *s, void *buf, size_t len, int flags); +XS_EXPORT int xs_sendmsg (void *s, xs_msg_t *msg, int flags); +XS_EXPORT int xs_recvmsg (void *s, xs_msg_t *msg, int flags); + +/******************************************************************************/ +/* I/O multiplexing. */ +/******************************************************************************/ + +#define XS_POLLIN 1 +#define XS_POLLOUT 2 +#define XS_POLLERR 4 + +typedef struct +{ + void *socket; +#if defined _WIN32 + SOCKET fd; +#else + int fd; +#endif + short events; + short revents; +} xs_pollitem_t; + +XS_EXPORT int xs_poll (xs_pollitem_t *items, int nitems, long timeout); + +#undef XS_EXPORT + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/zmq_utils.h b/include/xs_utils.h index 341d639..c1171fe 100644 --- a/include/zmq_utils.h +++ b/include/xs_utils.h @@ -1,15 +1,15 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads 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 GNU Lesser General Public License for more details. @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef __ZMQ_UTILS_H_INCLUDED__ -#define __ZMQ_UTILS_H_INCLUDED__ +#ifndef __XS_UTILS_H_INCLUDED__ +#define __XS_UTILS_H_INCLUDED__ #ifdef __cplusplus extern "C" { @@ -28,17 +28,17 @@ extern "C" { /* Handle DSO symbol visibility */ #if defined _WIN32 # if defined DLL_EXPORT -# define ZMQ_EXPORT __declspec(dllexport) +# define XS_EXPORT __declspec(dllexport) # else -# define ZMQ_EXPORT __declspec(dllimport) +# define XS_EXPORT __declspec(dllimport) # endif #else # if defined __SUNPRO_C || defined __SUNPRO_CC -# define ZMQ_EXPORT __global +# define XS_EXPORT __global # elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER -# define ZMQ_EXPORT __attribute__ ((visibility("default"))) +# define XS_EXPORT __attribute__ ((visibility("default"))) # else -# define ZMQ_EXPORT +# define XS_EXPORT # endif #endif @@ -46,16 +46,16 @@ extern "C" { /* about minutiae of time-related functions on different OS platforms. */ /* Starts the stopwatch. Returns the handle to the watch. */ -ZMQ_EXPORT void *zmq_stopwatch_start (void); +XS_EXPORT void *xs_stopwatch_start (void); /* Stops the stopwatch. Returns the number of microseconds elapsed since */ /* the stopwatch was started. */ -ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_); +XS_EXPORT unsigned long xs_stopwatch_stop (void *watch_); /* Sleeps for specified number of seconds. */ -ZMQ_EXPORT void zmq_sleep (int seconds_); +XS_EXPORT void xs_sleep (int seconds_); -#undef ZMQ_EXPORT +#undef XS_EXPORT #ifdef __cplusplus } diff --git a/include/zmq.h b/include/zmq.h deleted file mode 100644 index 5dc1146..0000000 --- a/include/zmq.h +++ /dev/null @@ -1,246 +0,0 @@ -/* - Copyright (c) 2009-2011 250bpm s.r.o. - Copyright (c) 2007-2010 iMatix Corporation - Copyright (c) 2011 VMware, Inc. - Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - - This file is part of 0MQ. - - 0MQ is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - 0MQ 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 - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef __ZMQ_H_INCLUDED__ -#define __ZMQ_H_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <errno.h> -#include <stddef.h> -#if defined _WIN32 -#include <winsock2.h> -#endif - -/* Handle DSO symbol visibility */ -#if defined _WIN32 -# if defined DLL_EXPORT -# define ZMQ_EXPORT __declspec(dllexport) -# else -# define ZMQ_EXPORT __declspec(dllimport) -# endif -#else -# if defined __SUNPRO_C || defined __SUNPRO_CC -# define ZMQ_EXPORT __global -# elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER -# define ZMQ_EXPORT __attribute__ ((visibility("default"))) -# else -# define ZMQ_EXPORT -# endif -#endif - -/******************************************************************************/ -/* 0MQ versioning support. */ -/******************************************************************************/ - -/* Version macros for compile-time API version detection */ -#define ZMQ_VERSION_MAJOR 3 -#define ZMQ_VERSION_MINOR 1 -#define ZMQ_VERSION_PATCH 1 - -#define ZMQ_MAKE_VERSION(major, minor, patch) \ - ((major) * 10000 + (minor) * 100 + (patch)) -#define ZMQ_VERSION \ - ZMQ_MAKE_VERSION(ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH) - -/* Run-time API version detection */ -ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch); - -/******************************************************************************/ -/* 0MQ errors. */ -/******************************************************************************/ - -/* A number random enough not to collide with different errno ranges on */ -/* different OSes. The assumption is that error_t is at least 32-bit type. */ -#define ZMQ_HAUSNUMERO 156384712 - -/* On Windows platform some of the standard POSIX errnos are not defined. */ -#ifndef ENOTSUP -#define ENOTSUP (ZMQ_HAUSNUMERO + 1) -#endif -#ifndef EPROTONOSUPPORT -#define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2) -#endif -#ifndef ENOBUFS -#define ENOBUFS (ZMQ_HAUSNUMERO + 3) -#endif -#ifndef ENETDOWN -#define ENETDOWN (ZMQ_HAUSNUMERO + 4) -#endif -#ifndef EADDRINUSE -#define EADDRINUSE (ZMQ_HAUSNUMERO + 5) -#endif -#ifndef EADDRNOTAVAIL -#define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6) -#endif -#ifndef ECONNREFUSED -#define ECONNREFUSED (ZMQ_HAUSNUMERO + 7) -#endif -#ifndef EINPROGRESS -#define EINPROGRESS (ZMQ_HAUSNUMERO + 8) -#endif -#ifndef ENOTSOCK -#define ENOTSOCK (ZMQ_HAUSNUMERO + 9) -#endif -#ifndef EAFNOSUPPORT -#define EAFNOSUPPORT (ZMQ_HAUSNUMERO + 10) -#endif - -/* Native 0MQ error codes. */ -#define EFSM (ZMQ_HAUSNUMERO + 51) -#define ENOCOMPATPROTO (ZMQ_HAUSNUMERO + 52) -#define ETERM (ZMQ_HAUSNUMERO + 53) -#define EMTHREAD (ZMQ_HAUSNUMERO + 54) - -/* This function retrieves the errno as it is known to 0MQ library. The goal */ -/* of this function is to make the code 100% portable, including where 0MQ */ -/* compiled with certain CRT library (on Windows) is linked to an */ -/* application that uses different CRT library. */ -ZMQ_EXPORT int zmq_errno (void); - -/* Resolves system errors and 0MQ errors to human-readable string. */ -ZMQ_EXPORT const char *zmq_strerror (int errnum); - -/******************************************************************************/ -/* 0MQ message definition. */ -/******************************************************************************/ - -typedef struct {unsigned char _ [32];} zmq_msg_t; - -typedef void (zmq_free_fn) (void *data, void *hint); - -ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg); -ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg, size_t size); -ZMQ_EXPORT int zmq_msg_init_data (zmq_msg_t *msg, void *data, - size_t size, zmq_free_fn *ffn, void *hint); -ZMQ_EXPORT int zmq_msg_close (zmq_msg_t *msg); -ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src); -ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src); -ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg); -ZMQ_EXPORT size_t zmq_msg_size (zmq_msg_t *msg); -ZMQ_EXPORT int zmq_getmsgopt (zmq_msg_t *msg, int option, void *optval, - size_t *optvallen); - -/******************************************************************************/ -/* 0MQ infrastructure (a.k.a. context) initialisation & termination. */ -/******************************************************************************/ - -ZMQ_EXPORT void *zmq_init (int io_threads); -ZMQ_EXPORT int zmq_term (void *context); - -/******************************************************************************/ -/* 0MQ socket definition. */ -/******************************************************************************/ - -/* Socket types. */ -#define ZMQ_PAIR 0 -#define ZMQ_PUB 1 -#define ZMQ_SUB 2 -#define ZMQ_REQ 3 -#define ZMQ_REP 4 -#define ZMQ_XREQ 5 -#define ZMQ_XREP 6 -#define ZMQ_PULL 7 -#define ZMQ_PUSH 8 -#define ZMQ_XPUB 9 -#define ZMQ_XSUB 10 - -#define ZMQ_ROUTER ZMQ_XREP -#define ZMQ_DEALER ZMQ_XREQ - -/* Socket options. */ -#define ZMQ_AFFINITY 4 -#define ZMQ_IDENTITY 5 -#define ZMQ_SUBSCRIBE 6 -#define ZMQ_UNSUBSCRIBE 7 -#define ZMQ_RATE 8 -#define ZMQ_RECOVERY_IVL 9 -#define ZMQ_SNDBUF 11 -#define ZMQ_RCVBUF 12 -#define ZMQ_RCVMORE 13 -#define ZMQ_FD 14 -#define ZMQ_EVENTS 15 -#define ZMQ_TYPE 16 -#define ZMQ_LINGER 17 -#define ZMQ_RECONNECT_IVL 18 -#define ZMQ_BACKLOG 19 -#define ZMQ_RECONNECT_IVL_MAX 21 -#define ZMQ_MAXMSGSIZE 22 -#define ZMQ_SNDHWM 23 -#define ZMQ_RCVHWM 24 -#define ZMQ_MULTICAST_HOPS 25 -#define ZMQ_RCVTIMEO 27 -#define ZMQ_SNDTIMEO 28 -#define ZMQ_IPV4ONLY 31 - -/* Message options */ -#define ZMQ_MORE 1 - -/* Send/recv options. */ -#define ZMQ_DONTWAIT 1 -#define ZMQ_SNDMORE 2 - -ZMQ_EXPORT void *zmq_socket (void *context, int type); -ZMQ_EXPORT int zmq_close (void *s); -ZMQ_EXPORT int zmq_setsockopt (void *s, int option, const void *optval, - size_t optvallen); -ZMQ_EXPORT int zmq_getsockopt (void *s, int option, void *optval, - size_t *optvallen); -ZMQ_EXPORT int zmq_bind (void *s, const char *addr); -ZMQ_EXPORT int zmq_connect (void *s, const char *addr); -ZMQ_EXPORT int zmq_send (void *s, const void *buf, size_t len, int flags); -ZMQ_EXPORT int zmq_recv (void *s, void *buf, size_t len, int flags); -ZMQ_EXPORT int zmq_sendmsg (void *s, zmq_msg_t *msg, int flags); -ZMQ_EXPORT int zmq_recvmsg (void *s, zmq_msg_t *msg, int flags); - -/******************************************************************************/ -/* I/O multiplexing. */ -/******************************************************************************/ - -#define ZMQ_POLLIN 1 -#define ZMQ_POLLOUT 2 -#define ZMQ_POLLERR 4 - -typedef struct -{ - void *socket; -#if defined _WIN32 - SOCKET fd; -#else - int fd; -#endif - short events; - short revents; -} zmq_pollitem_t; - -ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout); - -#undef ZMQ_EXPORT - -#ifdef __cplusplus -} -#endif - -#endif - |