From 3bd8f83f6d412221e4673ceb90b8ca7fa74ff2f1 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Tue, 22 Sep 2009 13:00:05 +0200 Subject: language bindings use zmq_strerror instead of strerror --- bindings/cpp/zmq.hpp | 9 +-------- bindings/java/Context.cpp | 12 +++--------- bindings/java/Socket.cpp | 11 ++--------- bindings/python/pyzmq.cpp | 20 ++++++++++---------- bindings/ruby/rbzmq.cpp | 18 +++++++++--------- 5 files changed, 25 insertions(+), 45 deletions(-) diff --git a/bindings/cpp/zmq.hpp b/bindings/cpp/zmq.hpp index cf7d347..5c0ba7c 100644 --- a/bindings/cpp/zmq.hpp +++ b/bindings/cpp/zmq.hpp @@ -41,14 +41,7 @@ namespace zmq virtual const char *what () const throw () { -#if defined _MSC_VER -#pragma warning (push) -#pragma warning (disable:4996) -#endif - return strerror (errnum); -#if defined _MSC_VER -#pragma warning (pop) -#endif + return zmq_strerror (errnum); } private: diff --git a/bindings/java/Context.cpp b/bindings/java/Context.cpp index d2138c3..652a120 100644 --- a/bindings/java/Context.cpp +++ b/bindings/java/Context.cpp @@ -22,7 +22,8 @@ #include #include -#include "zmq.h" +#include "../c/zmq.h" + #include "org_zmq_Context.h" static jfieldID ctx_handle_fid = NULL; @@ -34,14 +35,7 @@ static void raise_exception (JNIEnv *env, int err) assert (exception_class); // Get text description of the exception. -#if defined _MSC_VER -#pragma warning (push) -#pragma warning (disable:4996) -#endif - const char *err_msg = strerror (err); -#if defined _MSC_VER -#pragma warning (pop) -#endif + const char *err_msg = zmq_strerror (err); // Raise the exception. int rc = env->ThrowNew (exception_class, err_msg); diff --git a/bindings/java/Socket.cpp b/bindings/java/Socket.cpp index cf6b1de..26c6003 100644 --- a/bindings/java/Socket.cpp +++ b/bindings/java/Socket.cpp @@ -23,8 +23,8 @@ #include #include "../../src/stdint.hpp" +#include "../c/zmq.h" -#include "zmq.h" #include "org_zmq_Socket.h" static jfieldID socket_handle_fid = NULL; @@ -37,14 +37,7 @@ static void raise_exception (JNIEnv *env, int err) assert (exception_class); // Get text description of the exception. -#if defined _MSC_VER -#pragma warning (push) -#pragma warning (disable:4996) -#endif - const char *err_msg = strerror (err); -#if defined _MSC_VER -#pragma warning (pop) -#endif + const char *err_msg = zmq_strerror (err); // Raise the exception. int rc = env->ThrowNew (exception_class, err_msg); diff --git a/bindings/python/pyzmq.cpp b/bindings/python/pyzmq.cpp index 32f30fe..54c16de 100644 --- a/bindings/python/pyzmq.cpp +++ b/bindings/python/pyzmq.cpp @@ -64,7 +64,7 @@ int context_init (context_t *self, PyObject *args, PyObject *kwdict) assert (!self->handle); self->handle = zmq_init (app_threads, io_threads, flags); if (!self->handle) { - PyErr_SetString (PyExc_SystemError, strerror (errno)); + PyErr_SetString (PyExc_SystemError, zmq_strerror (errno)); return -1; } @@ -76,7 +76,7 @@ void context_dealloc (context_t *self) if (self->handle) { int rc = zmq_term (self->handle); if (rc != 0) - PyErr_SetString (PyExc_SystemError, strerror (errno)); + PyErr_SetString (PyExc_SystemError, zmq_strerror (errno)); } self->ob_type->tp_free ((PyObject*) self); @@ -114,7 +114,7 @@ int socket_init (socket_t *self, PyObject *args, PyObject *kwdict) assert (!self->handle); self->handle = zmq_socket (context->handle, socket_type); if (!self->handle) { - PyErr_SetString (PyExc_SystemError, strerror (errno)); + PyErr_SetString (PyExc_SystemError, zmq_strerror (errno)); return -1; } @@ -126,7 +126,7 @@ void socket_dealloc (socket_t *self) if (self->handle) { int rc = zmq_close (self->handle); if (rc != 0) - PyErr_SetString (PyExc_SystemError, strerror (errno)); + PyErr_SetString (PyExc_SystemError, zmq_strerror (errno)); } self->ob_type->tp_free ((PyObject*) self); @@ -171,7 +171,7 @@ PyObject *socket_setsockopt (socket_t *self, PyObject *args, PyObject *kwdict) } if (rc != 0) { - PyErr_SetString (PyExc_SystemError, strerror (errno)); + PyErr_SetString (PyExc_SystemError, zmq_strerror (errno)); return NULL; } @@ -191,7 +191,7 @@ PyObject *socket_bind (socket_t *self, PyObject *args, PyObject *kwdict) int rc = zmq_bind (self->handle, addr); if (rc != 0) { - PyErr_SetString (PyExc_SystemError, strerror (errno)); + PyErr_SetString (PyExc_SystemError, zmq_strerror (errno)); return NULL; } @@ -211,7 +211,7 @@ PyObject *socket_connect (socket_t *self, PyObject *args, PyObject *kwdict) int rc = zmq_connect (self->handle, addr); if (rc != 0) { - PyErr_SetString (PyExc_SystemError, strerror (errno)); + PyErr_SetString (PyExc_SystemError, zmq_strerror (errno)); return NULL; } @@ -233,7 +233,7 @@ PyObject *socket_send (socket_t *self, PyObject *args, PyObject *kwdict) zmq_msg_t data; int rc = zmq_msg_init_size (&data, PyString_Size (msg)); if (rc != 0) { - PyErr_SetString (PyExc_SystemError, strerror (errno)); + PyErr_SetString (PyExc_SystemError, zmq_strerror (errno)); return NULL; } memcpy (zmq_msg_data (&data), PyString_AsString (msg), @@ -247,7 +247,7 @@ PyObject *socket_send (socket_t *self, PyObject *args, PyObject *kwdict) return PyBool_FromLong (0); if (rc != 0) { - PyErr_SetString (PyExc_SystemError, strerror (errno)); + PyErr_SetString (PyExc_SystemError, zmq_strerror (errno)); return NULL; } @@ -264,7 +264,7 @@ PyObject *socket_flush (socket_t *self, PyObject *args, PyObject *kwdict) int rc = zmq_flush (self->handle); if (rc != 0) { - PyErr_SetString (PyExc_SystemError, strerror (errno)); + PyErr_SetString (PyExc_SystemError, zmq_strerror (errno)); return NULL; } diff --git a/bindings/ruby/rbzmq.cpp b/bindings/ruby/rbzmq.cpp index 83bb2b6..6112972 100644 --- a/bindings/ruby/rbzmq.cpp +++ b/bindings/ruby/rbzmq.cpp @@ -44,7 +44,7 @@ static VALUE context_initialize (VALUE self_, VALUE app_threads_, void *ctx = zmq_init (NUM2INT (app_threads_), NUM2INT (io_threads_), NUM2INT (flags_)); if (!ctx) { - rb_raise (rb_eRuntimeError, strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (errno)); return Qnil; } @@ -76,7 +76,7 @@ static VALUE socket_initialize (VALUE self_, VALUE context_, VALUE type_) void *s = zmq_socket (DATA_PTR (context_), NUM2INT (type_)); if (!s) { - rb_raise (rb_eRuntimeError, strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (errno)); return Qnil; } @@ -123,7 +123,7 @@ static VALUE socket_setsockopt (VALUE self_, VALUE option_, } if (rc != 0) { - rb_raise (rb_eRuntimeError, strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (errno)); return Qnil; } @@ -137,7 +137,7 @@ static VALUE socket_bind (VALUE self_, VALUE addr_) int rc = zmq_bind (DATA_PTR (self_), rb_string_value_cstr (&addr_)); if (rc != 0) { - rb_raise (rb_eRuntimeError, strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (errno)); return Qnil; } @@ -150,7 +150,7 @@ static VALUE socket_connect (VALUE self_, VALUE addr_) int rc = zmq_connect (DATA_PTR (self_), rb_string_value_cstr (&addr_)); if (rc != 0) { - rb_raise (rb_eRuntimeError, strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (errno)); return Qnil; } @@ -166,7 +166,7 @@ static VALUE socket_send (VALUE self_, VALUE msg_, VALUE flags_) zmq_msg_t msg; int rc = zmq_msg_init_size (&msg, RSTRING_LEN (msg_)); if (rc != 0) { - rb_raise (rb_eRuntimeError, strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (errno)); return Qnil; } memcpy (zmq_msg_data (&msg), RSTRING_PTR (msg_), RSTRING_LEN (msg_)); @@ -179,7 +179,7 @@ static VALUE socket_send (VALUE self_, VALUE msg_, VALUE flags_) } if (rc != 0) { - rb_raise (rb_eRuntimeError, strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (errno)); rc = zmq_msg_close (&msg); assert (rc == 0); return Qnil; @@ -196,7 +196,7 @@ static VALUE socket_flush (VALUE self_) int rc = zmq_flush (DATA_PTR (self_)); if (rc != 0) { - rb_raise (rb_eRuntimeError, strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (errno)); return Qnil; } @@ -219,7 +219,7 @@ static VALUE socket_recv (VALUE self_, VALUE flags_) } if (rc != 0) { - rb_raise (rb_eRuntimeError, strerror (errno)); + rb_raise (rb_eRuntimeError, zmq_strerror (errno)); rc = zmq_msg_close (&msg); assert (rc == 0); return Qnil; -- cgit v1.2.3