Diff
Not logged in

Differences From Artifact [c4f58cfbd6]:

To Artifact [139e39f051]:


1

2
3
4
5


6
7
8
9
10


11
12

13
14
15
16
17
18
19
20
21
22
23
24

25
26
27
28
29
30
31
32

1
2
3


4
5
6
7
8


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

25

26
27
28
29
30
31
32
-
+


-
-
+
+



-
-
+
+


+











-
+
-







/* 
/*
 * tclWinError.c --
 *
 *	This file contains code for converting from Win32 errors to
 *	errno errors.
 *	This file contains code for converting from Win32 errors to errno
 *	errors.
 *
 * Copyright (c) 1995-1996 by Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include "tclInt.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
 * The following table contains the mapping from Win32 errors to errno errors.
 * errno errors.
 */

static CONST unsigned char errorTable[] = {
    0,
    EINVAL,	/* ERROR_INVALID_FUNCTION	1 */
    ENOENT,	/* ERROR_FILE_NOT_FOUND		2 */
    ENOENT,	/* ERROR_PATH_NOT_FOUND		3 */
297
298
299
300
301
302
303
304

305
306
307
308
309
310
311
297
298
299
300
301
302
303

304
305
306
307
308
309
310
311







-
+







};

/*
 * The following table contains the mapping from WinSock errors to
 * errno errors.
 */

static CONST unsigned char wsaErrorTable[] = {
static CONST int wsaErrorTable[] = {
    EWOULDBLOCK,	/* WSAEWOULDBLOCK */
    EINPROGRESS,	/* WSAEINPROGRESS */
    EALREADY,		/* WSAEALREADY */
    ENOTSOCK,		/* WSAENOTSOCK */
    EDESTADDRREQ,	/* WSAEDESTADDRREQ */
    EMSGSIZE,		/* WSAEMSGSIZE */
    EPROTOTYPE,		/* WSAEPROTOTYPE */
354
355
356
357
358
359
360
361
362


363
364

365
366
367
368
369
370
371
354
355
356
357
358
359
360


361
362
363

364
365
366
367
368
369
370
371







-
-
+
+

-
+







 * Side effects:
 *	Sets the errno global variable.
 *
 *----------------------------------------------------------------------
 */

void
TclWinConvertError(errCode)
    DWORD errCode;		/* Win32 error code. */
TclWinConvertError(
    DWORD errCode)		/* Win32 error code. */
{
    if (errCode >= sizeof(errorTable)) {
    if (errCode >= sizeof(errorTable)/sizeof(errorTable[0])) {
	Tcl_SetErrno(EINVAL);
    } else {
	Tcl_SetErrno(errorTable[errCode]);
    }
}

/*
381
382
383
384
385
386
387
388
389


390
391
392
393



394
395

396
397









381
382
383
384
385
386
387


388
389
390



391
392
393
394

395
396
397
398
399
400
401
402
403
404
405
406







-
-
+
+

-
-
-
+
+
+

-
+


+
+
+
+
+
+
+
+
+
 * Side effects:
 *	Sets the errno global variable.
 *
 *----------------------------------------------------------------------
 */

void
TclWinConvertWSAError(errCode)
    DWORD errCode;		/* Win32 error code. */
TclWinConvertWSAError(
    DWORD errCode)		/* Win32 error code. */
{
	errCode -= WSAEWOULDBLOCK;
    if ((errCode <= (DWORD) sizeof(wsaErrorTable))) {
	Tcl_SetErrno(wsaErrorTable[errCode]);
    errCode -= WSAEWOULDBLOCK;
    if (errCode >= sizeof(wsaErrorTable)/sizeof(wsaErrorTable[0])) {
	Tcl_SetErrno(EINVAL);
    } else {
	Tcl_SetErrno(EINVAL);
	Tcl_SetErrno(wsaErrorTable[errCode]);
    }
}

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * tab-width: 8
 * End:
 */