summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2010-10-16 16:05:34 +0200
committerMartin Sustrik <sustrik@250bpm.com>2010-10-16 16:05:34 +0200
commit72b15a6dae6c199d847ebde5ac73de238f0ebf75 (patch)
treea94f630b5989bd6243f3a1ebf4d48df053e3772c /src
parent61d38fbeed89d69516b9976c60b7711fefed6411 (diff)
Implementation of zmq_strerror moved from zmq.cpp to err.cpp
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src')
-rw-r--r--src/err.cpp41
-rw-r--r--src/err.hpp9
-rw-r--r--src/zmq.cpp38
3 files changed, 48 insertions, 40 deletions
diff --git a/src/err.cpp b/src/err.cpp
index 17a9689..a44b7e0 100644
--- a/src/err.cpp
+++ b/src/err.cpp
@@ -22,6 +22,47 @@
#include "err.hpp"
#include "platform.hpp"
+const char *zmq::errno_to_string (int errno_)
+{
+ switch (errno_) {
+#if defined ZMQ_HAVE_WINDOWS
+ case ENOTSUP:
+ return "Not supported";
+ case EPROTONOSUPPORT:
+ return "Protocol not supported";
+ case ENOBUFS:
+ return "No buffer space available";
+ case ENETDOWN:
+ return "Network is down";
+ case EADDRINUSE:
+ return "Address in use";
+ case EADDRNOTAVAIL:
+ return "Address not available";
+ case ECONNREFUSED:
+ return "Connection refused";
+ case EINPROGRESS:
+ return "Operation in progress";
+#endif
+ case EFSM:
+ return "Operation cannot be accomplished in current state";
+ case ENOCOMPATPROTO:
+ return "The protocol is not compatible with the socket type";
+ case ETERM:
+ return "Context was terminated";
+ case EMTHREAD:
+ return "No thread available";
+ default:
+#if defined _MSC_VER
+#pragma warning (push)
+#pragma warning (disable:4996)
+#endif
+ return strerror (errno_);
+#if defined _MSC_VER
+#pragma warning (pop)
+#endif
+ }
+}
+
#ifdef ZMQ_HAVE_WINDOWS
const char *zmq::wsa_error()
diff --git a/src/err.hpp b/src/err.hpp
index 2b76569..a31eb9b 100644
--- a/src/err.hpp
+++ b/src/err.hpp
@@ -35,15 +35,18 @@
#include <netdb.h>
#endif
+namespace zmq
+{
+ const char *errno_to_string (int errno_);
+}
+
#ifdef ZMQ_HAVE_WINDOWS
namespace zmq
{
-
const char *wsa_error ();
void win_error (char *buffer_, size_t buffer_size_);
- void wsa_error_to_errno ();
-
+ void wsa_error_to_errno ();
}
// Provides convenient way to check WSA-style errors on Windows.
diff --git a/src/zmq.cpp b/src/zmq.cpp
index 7101f34..5fcf078 100644
--- a/src/zmq.cpp
+++ b/src/zmq.cpp
@@ -63,43 +63,7 @@ void zmq_version (int *major_, int *minor_, int *patch_)
const char *zmq_strerror (int errnum_)
{
- switch (errnum_) {
-#if defined ZMQ_HAVE_WINDOWS
- case ENOTSUP:
- return "Not supported";
- case EPROTONOSUPPORT:
- return "Protocol not supported";
- case ENOBUFS:
- return "No buffer space available";
- case ENETDOWN:
- return "Network is down";
- case EADDRINUSE:
- return "Address in use";
- case EADDRNOTAVAIL:
- return "Address not available";
- case ECONNREFUSED:
- return "Connection refused";
- case EINPROGRESS:
- return "Operation in progress";
-#endif
- case EFSM:
- return "Operation cannot be accomplished in current state";
- case ENOCOMPATPROTO:
- return "The protocol is not compatible with the socket type";
- case ETERM:
- return "Context was terminated";
- case EMTHREAD:
- return "No thread available";
- default:
-#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::errno_to_string (errnum_);
}
int zmq_msg_init (zmq_msg_t *msg_)