#
#
# patch "ChangeLog"
# from [e0d6c3c715b22bd42c3a768f204521777b6a5a55]
# to [547deacf9f6f8f766248e88ab668d67188671dff]
#
# patch "netxx/accept.cxx"
# from [da35bd93be31e46fec595e6e5a28e3fa9793f151]
# to [61ab2bb4c059529f3d29e6793844ea4ca6cea464]
#
# patch "netxx/datagram.cxx"
# from [ffef08e25afb734472d40f80ffc604cabad71de0]
# to [cb81586c446b5d395cf2bfe216a2023c374e02ba]
#
# patch "netxx/osutil.cxx"
# from [e8f242ec8e84cb58b22d28464d466abdb47216d7]
# to [78a1f1cc7884eb330bfda22b9102121216f969b7]
#
# patch "netxx/osutil.h"
# from [d852d45641d2b6a72f9627b9ef3b3517247e1693]
# to [2d6b18c5ab154f0583ef11a42f3670ec13cb7ce7]
#
# patch "netxx/peer.cxx"
# from [8840c1e7f828fd2cbb9b89b6180553babe3d27db]
# to [86cab6617c37d0b1611237f83c3bb45ab19fe3ef]
#
# patch "netxx/probe_select.cxx"
# from [766d53d2275bd18efd1455c05062b9dda15e5f44]
# to [289d3f5c02b6c76de896fc2e84463713c4b77549]
#
# patch "netxx/recvfrom.cxx"
# from [a26eb4af8eb69d1da3aca0957b146abbc042c175]
# to [600cf08e1406ff1bd94f7bc8fca77540f0d9db13]
#
# patch "netxx/resolve_gethostbyname.cxx"
# from [dcbcbaf6733936797b1edfdd9d27008103763e27]
# to [3685bf3afb0545aebf31d3bc277d01f9a312bcb7]
#
# patch "netxx/serverbase.cxx"
# from [9176551c9ec983187f6a52590d84131e125a37d5]
# to [601bf254688ae70030b4d21fd48dbda7673a0410]
#
# patch "netxx/socket.cxx"
# from [0c8369851edd780cf88e497c5b4dda1948652a04]
# to [b6525dbe4fba6d50fb4831ae54950ee3f9e9d991]
#
# patch "netxx/sockopt.cxx"
# from [ab62347537609eed77b7c6f7a2b9806cc49be9ea]
# to [c1aeaeb2defba81c103fbde102894373b9bc55de]
#
# patch "netxx/streambase.cxx"
# from [33f2fe8674145f789fdb7a4645a820e08288e07c]
# to [ff108a2ac000dd3d662248ed8fab89e3c7ebd7c4]
#
# patch "netxx/streamserver.cxx"
# from [d884534c226c204e3145522c6d0ed02c58e1d0ac]
# to [7421c6078a24a4d3818fe748f908a4c6b01b1fd3]
#
============================================================
--- ChangeLog e0d6c3c715b22bd42c3a768f204521777b6a5a55
+++ ChangeLog 547deacf9f6f8f766248e88ab668d67188671dff
@@ -1,3 +1,12 @@
+2006-05-24 Matthew Gregan
+
+ * netxx/osutil.{cxx,h}: Add OS-specific strerror function. This
+ continues to call strerror() on POSIX, and tries using
+ FormatMessage() and a built-in error message table on Win32.
+ * netxx/{accept,datagram,peer,probe_select,recvfrom}.cxx,
+ netxx/{resolve_gethostbyname,serverbase,socket,sockopt}.cxx,
+ netxx/{streambase,streamserver}.cxx: s/strerror/Netxx::str_error/g.
+
2006-05-23 Timothy Brownawell
* tester.cc tester.lua: New files, which will eventually become a
============================================================
--- netxx/accept.cxx da35bd93be31e46fec595e6e5a28e3fa9793f151
+++ netxx/accept.cxx 61ab2bb4c059529f3d29e6793844ea4ca6cea464
@@ -72,7 +72,7 @@
default:
{
std::string error("accept(2) error: ");
- error += strerror(error_code);
+ error += str_error(error_code);
throw Netxx::Exception(error);
}
}
============================================================
--- netxx/datagram.cxx ffef08e25afb734472d40f80ffc604cabad71de0
+++ netxx/datagram.cxx cb81586c446b5d395cf2bfe216a2023c374e02ba
@@ -204,7 +204,7 @@
signed_size_type rc;
if ( (rc = sendto(pimpl_->socket_.get_socketfd(), buffer_ptr, length, 0, sa, sa_size)) < 0) {
std::string error("sendto(2) failure: ");
- error += strerror(get_last_error());
+ error += str_error(get_last_error());
throw Exception(error);
}
@@ -290,7 +290,7 @@
if (connect(socket.get_socketfd(), sa, sa_size) != 0) {
std::string error("connect(2) failed: ");
- error += strerror(Netxx::get_last_error());
+ error += Netxx::str_error(Netxx::get_last_error());
throw Netxx::NetworkException(error);
}
}
@@ -314,7 +314,7 @@
if (bind(socket.get_socketfd(), reinterpret_cast(saun), saun_size) != 0) {
std::string error("bind(2) error: ");
- error += strerror(Netxx::get_last_error());
+ error += Netxx::str_error(Netxx::get_last_error());
throw Netxx::NetworkException(error);
}
@@ -337,7 +337,7 @@
if ( (fd = mkstemp(buffer)) < 0) {
std::string error("can't create temporary file: ");
- error += strerror(Netxx::get_last_error());
+ error += Netxx::str_error(Netxx::get_last_error());
throw Netxx::NetworkException(error);
}
============================================================
--- netxx/osutil.cxx e8f242ec8e84cb58b22d28464d466abdb47216d7
+++ netxx/osutil.cxx 78a1f1cc7884eb330bfda22b9102121216f969b7
@@ -36,6 +36,7 @@
// declaration include
#include "common.h"
+#include
//####################################################################
Netxx::error_type Netxx::get_last_error (void)
@@ -51,3 +52,105 @@
#endif
}
//####################################################################
+std::string Netxx::str_error(Netxx::error_type errnum)
+{
+#if defined (WIN32)
+
+ std::ostringstream s;
+
+ // try FormatMessage first--this will probably fail for anything < Win2k.
+ LPTSTR msg;
+ if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
+ 0, errnum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ reinterpret_cast(&msg), 0,
+ static_cast(0)) != 0) {
+ s << msg;
+ LocalFree(msg);
+ } else {
+ // if it failed, try using our own table.
+ struct {
+ DWORD n;
+ char const * m;
+ } error_msgs[] = {
+ { WSAEINTR, "interrupted function call" },
+ { WSAEBADF, "invalid socket handle" },
+ { WSAEACCES, "access denied" },
+ { WSAEFAULT, "invalid address" },
+ { WSAEINVAL, "invalid argument" },
+ { WSAEMFILE, "too many open files" },
+ { WSAEWOULDBLOCK, "resource temporarily unavailable" },
+ { WSAEINPROGRESS, "operation in progress" },
+ { WSAEALREADY, "operating already in progress" },
+ { WSAENOTSOCK, "not a socket" },
+ { WSAEDESTADDRREQ, "destination address required" },
+ { WSAEMSGSIZE, "message too long" },
+ { WSAEPROTOTYPE, "incorrect protocol for socket" },
+ { WSAENOPROTOOPT, "invalid protocol option" },
+ { WSAEPROTONOSUPPORT, "protocol not supported" },
+ { WSAESOCKTNOSUPPORT, "socket type not supported" },
+ { WSAEOPNOTSUPP, "operation not supported" },
+ { WSAEPFNOSUPPORT, "protocol family not supported" },
+ { WSAEAFNOSUPPORT, "address family not supported" },
+ { WSAEADDRINUSE, "address already in use" },
+ { WSAEADDRNOTAVAIL, "unable to assign requested address" },
+ { WSAENETDOWN, "network down" },
+ { WSAENETUNREACH, "network unreachable" },
+ { WSAENETRESET, "dropped connection on reset" },
+ { WSAECONNABORTED, "connection aborted" },
+ { WSAECONNRESET, "connect reset by peer" },
+ { WSAENOBUFS, "no buffer space available" },
+ { WSAEISCONN, "socket already connected" },
+ { WSAENOTCONN, "socket not connected" },
+ { WSAESHUTDOWN, "connection shut down" },
+ { WSAETOOMANYREFS, "too many references to kernel object" },
+ { WSAETIMEDOUT, "connection timed out" },
+ { WSAECONNREFUSED, "connection refused" },
+ { WSAELOOP, "unable to translate name" },
+ { WSAENAMETOOLONG, "name or name component too long" },
+ { WSAEHOSTDOWN, "host down" },
+ { WSAEHOSTUNREACH, "host unreachable" },
+ { WSAENOTEMPTY, "unable to remove non-empty directory" },
+ { WSAEPROCLIM, "process limit exceeded" },
+ { WSAEUSERS, "quota exceeded" },
+ { WSAEDQUOT, "disk quota exceeded" },
+ { WSAESTALE, "stale socket handle" },
+ { WSAEREMOTE, "item not available locally" },
+ { WSASYSNOTREADY, "network service not available" },
+ { WSAVERNOTSUPPORTED, "unsupported winsock version requested" },
+ { WSANOTINITIALISED, "winsock not initialised" },
+ { WSAEDISCON, "peer disconnecting" },
+ { WSAENOMORE, "no further lookup results" },
+ { WSAECANCELLED, "lookup cancelled" },
+ { WSAEINVALIDPROCTABLE, "invalid procedure call table" },
+ { WSAEINVALIDPROVIDER, "invalid service provider" },
+ { WSAEPROVIDERFAILEDINIT, "service provider initialization failed" },
+ { WSASYSCALLFAILURE, "system call failure" },
+ { WSASERVICE_NOT_FOUND, "unknown service" },
+ { WSATYPE_NOT_FOUND, "unknown type" },
+ { WSA_E_NO_MORE, "no further lookup results" },
+ { WSA_E_CANCELLED, "lookup cancelled" },
+ { WSAEREFUSED, "lookup query refused" },
+ { WSAHOST_NOT_FOUND, "unknown host" },
+ { WSATRY_AGAIN, "try again" },
+ { WSANO_RECOVERY, "non-recoverable lookup failure" },
+ { WSANO_DATA, "no data found" },
+ { 0, 0 }
+ };
+
+ for (unsigned i = 0; error_msgs[i].m != 0; ++i)
+ if (error_msgs[i].n == errnum) {
+ s << error_msgs[i].m;
+ break;
+ }
+ }
+
+ s << " (" << errnum << ")";
+ return s.str();
+
+#else
+
+ return strerror(errnum);
+
+#endif
+}
+//####################################################################
============================================================
--- netxx/osutil.h d852d45641d2b6a72f9627b9ef3b3517247e1693
+++ netxx/osutil.h 2d6b18c5ab154f0583ef11a42f3670ec13cb7ce7
@@ -77,15 +77,16 @@
# include
# include
-
#endif
+#include
#include "config.h"
namespace Netxx
{
typedef int error_type;
error_type get_last_error (void);
+ std::string str_error(error_type);
#if defined(HAVE_SOCKLEN_T)
============================================================
--- netxx/peer.cxx 8840c1e7f828fd2cbb9b89b6180553babe3d27db
+++ netxx/peer.cxx 86cab6617c37d0b1611237f83c3bb45ab19fe3ef
@@ -165,7 +165,7 @@
int rc;
if ( (rc = getsockname(get_socketfd(), &sau.sa, sa_size_ptr))) {
- throw Exception(strerror(errno));
+ throw Exception(str_error(errno));
}
switch (sau.sa.sa_family) {
============================================================
--- netxx/probe_select.cxx 766d53d2275bd18efd1455c05062b9dda15e5f44
+++ netxx/probe_select.cxx 289d3f5c02b6c76de896fc2e84463713c4b77549
@@ -223,7 +223,7 @@
default:
{
std::string error("select(2): ");
- error += strerror(error_code);
+ error += str_error(error_code);
throw Exception(error);
}
}
============================================================
--- netxx/recvfrom.cxx a26eb4af8eb69d1da3aca0957b146abbc042c175
+++ netxx/recvfrom.cxx 600cf08e1406ff1bd94f7bc8fca77540f0d9db13
@@ -75,7 +75,7 @@
default:
{
std::string error("recvfrom(2) failed: ");
- error += strerror(error_code);
+ error += str_error(error_code);
throw Exception(error);
}
}
============================================================
--- netxx/resolve_gethostbyname.cxx dcbcbaf6733936797b1edfdd9d27008103763e27
+++ netxx/resolve_gethostbyname.cxx 3685bf3afb0545aebf31d3bc277d01f9a312bcb7
@@ -82,7 +82,7 @@
std::string error("name resolution failure for "); error += hostname;
// HACK: Winsock uses a totally different error reporting mechanism.
#ifndef WIN32
- error += ": "; error += hstrerror(h_errno);
+ error += ": "; error += hstr_error(h_errno);
#endif // WIN32
throw NetworkException(error);
}
============================================================
--- netxx/serverbase.cxx 9176551c9ec983187f6a52590d84131e125a37d5
+++ netxx/serverbase.cxx 601bf254688ae70030b4d21fd48dbda7673a0410
@@ -137,7 +137,7 @@
if (bind(socketfd, sa, sa_size) != 0) {
std::string error("bind(2) error: ");
- error += strerror(Netxx::get_last_error());
+ error += Netxx::str_error(Netxx::get_last_error());
throw NetworkException(error);
}
============================================================
--- netxx/socket.cxx 0c8369851edd780cf88e497c5b4dda1948652a04
+++ netxx/socket.cxx b6525dbe4fba6d50fb4831ae54950ee3f9e9d991
@@ -85,7 +85,7 @@
if ( (socket_fd = socket(socket_domain, socket_type, 0)) < 0) {
std::string error("failure from socket(2): ");
- error += strerror(get_last_error());
+ error += str_error(get_last_error());
throw Exception(error);
}
@@ -133,7 +133,7 @@
if (dup_socket < 0) {
std::string error("dup(2) call failed: ");
- error += strerror(get_last_error());
+ error += str_error(get_last_error());
throw Exception(error);
}
# endif
@@ -204,7 +204,7 @@
default:
{
std::string error("send failed: ");
- error += strerror(error_code);
+ error += str_error(error_code);
throw Exception(error);
}
}
@@ -261,7 +261,7 @@
default:
{
std::string error("recv failure: ");
- error += strerror(error_code);
+ error += str_error(error_code);
throw Exception(error);
}
}
============================================================
--- netxx/sockopt.cxx ab62347537609eed77b7c6f7a2b9806cc49be9ea
+++ netxx/sockopt.cxx c1aeaeb2defba81c103fbde102894373b9bc55de
@@ -114,7 +114,7 @@
if (setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, val, sizeof(on)) != 0) {
std::string error("setsockopt(2) failure: ");
- error += strerror(get_last_error());
+ error += str_error(get_last_error());
throw Exception(error);
}
@@ -128,12 +128,12 @@
os_socklen_type so_len(sizeof(so_error));
if ( (so_return = getsockopt(socket_, SOL_SOCKET, SO_ERROR, val, &so_len)) < 0) {
- message = strerror(so_return);
+ message = str_error(so_return);
return false;
}
if (so_error) {
- message = strerror(so_error);
+ message = str_error(so_error);
return false;
}
============================================================
--- netxx/streambase.cxx 33f2fe8674145f789fdb7a4645a820e08288e07c
+++ netxx/streambase.cxx ff108a2ac000dd3d662248ed8fab89e3c7ebd7c4
@@ -165,7 +165,7 @@
return socket_options.check_for_error(message);
}
- message = strerror(error_code);
+ message = Netxx::str_error(error_code);
return false;
}
============================================================
--- netxx/streamserver.cxx d884534c226c204e3145522c6d0ed02c58e1d0ac
+++ netxx/streamserver.cxx 7421c6078a24a4d3818fe748f908a4c6b01b1fd3
@@ -113,7 +113,7 @@
for (Netxx::size_type i=0; i