diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-03-22 21:34:27 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-03-22 21:34:27 (GMT) |
commit | 6013169f059a7d0002247ca588e7a44dbfcf5e4f (patch) | |
tree | a0689274b7976a41688599a7ac390b3ea85b3966 /win | |
parent | e33465ae30d33640ca8249ace31dcefbfafe7e0f (diff) | |
download | tcl-6013169f059a7d0002247ca588e7a44dbfcf5e4f.zip tcl-6013169f059a7d0002247ca588e7a44dbfcf5e4f.tar.gz tcl-6013169f059a7d0002247ca588e7a44dbfcf5e4f.tar.bz2 |
add TclWinConvertError and TclWinConvertWSAError for cygwin
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinError.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/win/tclWinError.c b/win/tclWinError.c index da1e335..d718584 100644 --- a/win/tclWinError.c +++ b/win/tclWinError.c @@ -10,14 +10,22 @@ * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#include "tclWinInt.h" +#include "tclPort.h" + +#ifndef WSAEWOULDBLOCK +# define WSAEWOULDBLOCK 10035L +#endif + +#ifndef __WIN32__ +# define DWORD unsigned int +#endif /* * The following table contains the mapping from Win32 errors to * errno errors. */ -static char errorTable[] = { +static CONST unsigned char errorTable[] = { 0, EINVAL, /* ERROR_INVALID_FUNCTION 1 */ ENOENT, /* ERROR_FILE_NOT_FOUND 2 */ @@ -285,17 +293,15 @@ static char errorTable[] = { EINVAL, /* 264 */ EINVAL, /* 265 */ EINVAL, /* 266 */ - ENOTDIR, /* ERROR_DIRECTORY 267 */ + ENOTDIR /* ERROR_DIRECTORY 267 */ }; -static const unsigned int tableLen = sizeof(errorTable); - /* * The following table contains the mapping from WinSock errors to * errno errors. */ -static int wsaErrorTable[] = { +static CONST unsigned char wsaErrorTable[] = { EWOULDBLOCK, /* WSAEWOULDBLOCK */ EINPROGRESS, /* WSAEINPROGRESS */ EALREADY, /* WSAEALREADY */ @@ -332,7 +338,7 @@ static int wsaErrorTable[] = { EUSERS, /* WSAEUSERS */ EDQUOT, /* WSAEDQUOT */ ESTALE, /* WSAESTALE */ - EREMOTE, /* WSAEREMOTE */ + EREMOTE /* WSAEREMOTE */ }; /* @@ -355,7 +361,7 @@ void TclWinConvertError(errCode) DWORD errCode; /* Win32 error code. */ { - if (errCode >= tableLen) { + if (errCode >= sizeof(errorTable)) { Tcl_SetErrno(EINVAL); } else { Tcl_SetErrno(errorTable[errCode]); @@ -382,8 +388,9 @@ void TclWinConvertWSAError(errCode) DWORD errCode; /* Win32 error code. */ { - if ((errCode >= WSAEWOULDBLOCK) && (errCode <= WSAEREMOTE)) { - Tcl_SetErrno(wsaErrorTable[errCode - WSAEWOULDBLOCK]); + errCode -= WSAEWOULDBLOCK; + if ((errCode <= (DWORD) sizeof(wsaErrorTable))) { + Tcl_SetErrno(wsaErrorTable[errCode]); } else { Tcl_SetErrno(EINVAL); } |