0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-27 15:41:05 +08:00

language bindings use zmq_strerror instead of strerror

This commit is contained in:
Martin Sustrik 2009-09-22 13:00:05 +02:00
parent a0db7f6b81
commit 3bd8f83f6d
5 changed files with 25 additions and 45 deletions

View File

@ -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:

View File

@ -22,7 +22,8 @@
#include <assert.h>
#include <errno.h>
#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);

View File

@ -23,8 +23,8 @@
#include <errno.h>
#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);

View File

@ -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;
}

View File

@ -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;