• Main Page
  • Classes
  • Files
  • File List

XArchWindows.cpp

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2012 Bolton Software Ltd.
00004  * Copyright (C) 2002 Chris Schoeneman
00005  * 
00006  * This package is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * found in the file COPYING that should have accompanied this file.
00009  * 
00010  * This package is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #include "XArchWindows.h"
00020 #include "CArchNetworkWinsock.h"
00021 
00022 //
00023 // XArchEvalWindows
00024 //
00025 
00026 XArchEval*
00027 XArchEvalWindows::clone() const throw()
00028 {
00029     return new XArchEvalWindows(m_errno);
00030 }
00031 
00032 std::string
00033 XArchEvalWindows::eval() const throw()
00034 {
00035     char* cmsg;
00036     if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
00037                             FORMAT_MESSAGE_IGNORE_INSERTS |
00038                             FORMAT_MESSAGE_FROM_SYSTEM,
00039                             0,
00040                             m_errno,
00041                             MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
00042                             (LPTSTR)&cmsg,
00043                             0,
00044                             NULL) == 0) {
00045         cmsg = NULL;
00046         return "Unknown error";
00047     }
00048     std::string smsg(cmsg);
00049     LocalFree(cmsg);
00050     return smsg;
00051 }
00052 
00053 
00054 //
00055 // XArchEvalWinsock
00056 //
00057 
00058 XArchEval*
00059 XArchEvalWinsock::clone() const throw()
00060 {
00061     return new XArchEvalWinsock(m_errno);
00062 }
00063 
00064 std::string
00065 XArchEvalWinsock::eval() const throw()
00066 {
00067     // built-in windows function for looking up error message strings
00068     // may not look up network error messages correctly.  we'll have
00069     // to do it ourself.
00070     static const struct { int m_code; const char* m_msg; } s_netErrorCodes[] = {
00071         /* 10004 */{WSAEINTR,           "The (blocking) call was canceled via WSACancelBlockingCall"},
00072         /* 10009 */{WSAEBADF,           "Bad file handle"},
00073         /* 10013 */{WSAEACCES,          "The requested address is a broadcast address, but the appropriate flag was not set"},
00074         /* 10014 */{WSAEFAULT,          "WSAEFAULT"},
00075         /* 10022 */{WSAEINVAL,          "WSAEINVAL"},
00076         /* 10024 */{WSAEMFILE,          "No more file descriptors available"},
00077         /* 10035 */{WSAEWOULDBLOCK,     "Socket is marked as non-blocking and no connections are present or the receive operation would block"},
00078         /* 10036 */{WSAEINPROGRESS,     "A blocking Windows Sockets operation is in progress"},
00079         /* 10037 */{WSAEALREADY,        "The asynchronous routine being canceled has already completed"},
00080         /* 10038 */{WSAENOTSOCK,        "At least on descriptor is not a socket"},
00081         /* 10039 */{WSAEDESTADDRREQ,    "A destination address is required"},
00082         /* 10040 */{WSAEMSGSIZE,        "The datagram was too large to fit into the specified buffer and was truncated"},
00083         /* 10041 */{WSAEPROTOTYPE,      "The specified protocol is the wrong type for this socket"},
00084         /* 10042 */{WSAENOPROTOOPT,     "The option is unknown or unsupported"},
00085         /* 10043 */{WSAEPROTONOSUPPORT,"The specified protocol is not supported"},
00086         /* 10044 */{WSAESOCKTNOSUPPORT,"The specified socket type is not supported by this address family"},
00087         /* 10045 */{WSAEOPNOTSUPP,      "The referenced socket is not a type that supports that operation"},
00088         /* 10046 */{WSAEPFNOSUPPORT,    "BSD: Protocol family not supported"},
00089         /* 10047 */{WSAEAFNOSUPPORT,    "The specified address family is not supported"},
00090         /* 10048 */{WSAEADDRINUSE,      "The specified address is already in use"},
00091         /* 10049 */{WSAEADDRNOTAVAIL,   "The specified address is not available from the local machine"},
00092         /* 10050 */{WSAENETDOWN,        "The Windows Sockets implementation has detected that the network subsystem has failed"},
00093         /* 10051 */{WSAENETUNREACH,     "The network can't be reached from this host at this time"},
00094         /* 10052 */{WSAENETRESET,       "The connection must be reset because the Windows Sockets implementation dropped it"},
00095         /* 10053 */{WSAECONNABORTED,    "The virtual circuit was aborted due to timeout or other failure"},
00096         /* 10054 */{WSAECONNRESET,      "The virtual circuit was reset by the remote side"},
00097         /* 10055 */{WSAENOBUFS,         "No buffer space is available or a buffer deadlock has occured. The socket cannot be created"},
00098         /* 10056 */{WSAEISCONN,         "The socket is already connected"},
00099         /* 10057 */{WSAENOTCONN,        "The socket is not connected"},
00100         /* 10058 */{WSAESHUTDOWN,       "The socket has been shutdown"},
00101         /* 10059 */{WSAETOOMANYREFS,    "BSD: Too many references"},
00102         /* 10060 */{WSAETIMEDOUT,       "Attempt to connect timed out without establishing a connection"},
00103         /* 10061 */{WSAECONNREFUSED,    "Connection was refused"},
00104         /* 10062 */{WSAELOOP,           "Undocumented WinSock error code used in BSD"},
00105         /* 10063 */{WSAENAMETOOLONG,    "Undocumented WinSock error code used in BSD"},
00106         /* 10064 */{WSAEHOSTDOWN,       "Undocumented WinSock error code used in BSD"},
00107         /* 10065 */{WSAEHOSTUNREACH,    "No route to host"},
00108         /* 10066 */{WSAENOTEMPTY,       "Undocumented WinSock error code"},
00109         /* 10067 */{WSAEPROCLIM,        "Undocumented WinSock error code"},
00110         /* 10068 */{WSAEUSERS,          "Undocumented WinSock error code"},
00111         /* 10069 */{WSAEDQUOT,          "Undocumented WinSock error code"},
00112         /* 10070 */{WSAESTALE,          "Undocumented WinSock error code"},
00113         /* 10071 */{WSAEREMOTE,         "Undocumented WinSock error code"},
00114         /* 10091 */{WSASYSNOTREADY,     "Underlying network subsytem is not ready for network communication"},
00115         /* 10092 */{WSAVERNOTSUPPORTED, "The version of WinSock API support requested is not provided in this implementation"},
00116         /* 10093 */{WSANOTINITIALISED,  "WinSock subsystem not properly initialized"},
00117         /* 10101 */{WSAEDISCON,         "Virtual circuit has gracefully terminated connection"},
00118         /* 11001 */{WSAHOST_NOT_FOUND,  "The specified host is unknown"},
00119         /* 11002 */{WSATRY_AGAIN,       "A temporary error occurred on an authoritative name server"},
00120         /* 11003 */{WSANO_RECOVERY,     "A non-recoverable name server error occurred"},
00121         /* 11004 */{WSANO_DATA,         "The requested name is valid but does not have an IP address"},
00122         /* end   */{0,                  NULL}
00123     };
00124 
00125     for (unsigned int i = 0; s_netErrorCodes[i].m_code != 0; ++i) {
00126         if (s_netErrorCodes[i].m_code == m_errno) {
00127             return s_netErrorCodes[i].m_msg;
00128         }
00129     }
00130     return "Unknown error";
00131 }

Generated on Sun May 26 2013 00:00:05 for Synergy by  doxygen 1.7.1