/[dtapublic]/projs/trunk/shared_source/c_tcl_base_7_5_w_mods/tclwinerror.c
ViewVC logotype

Contents of /projs/trunk/shared_source/c_tcl_base_7_5_w_mods/tclwinerror.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 44 - (show annotations) (download)
Fri Oct 14 02:09:58 2016 UTC (8 years ago) by dashley
File MIME type: text/plain
File size: 11677 byte(s)
Rename for reorganization.
1 /* $Header: /cvsroot/esrg/sfesrg/esrgpcpj/shared/tcl_base/tclwinerror.c,v 1.1.1.1 2001/06/13 04:48:48 dtashley Exp $ */
2
3 /*
4 * tclWinError.c --
5 *
6 * This file contains code for converting from Win32 errors to
7 * errno errors.
8 *
9 * Copyright (c) 1995-1996 by Sun Microsystems, Inc.
10 *
11 * See the file "license.terms" for information on usage and redistribution
12 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 *
14 * RCS: @(#) $Id: tclwinerror.c,v 1.1.1.1 2001/06/13 04:48:48 dtashley Exp $
15 */
16
17 #include "tclWinInt.h"
18
19 /*
20 * The following table contains the mapping from Win32 errors to
21 * errno errors.
22 */
23
24 static char errorTable[] = {
25 0,
26 EINVAL, /* ERROR_INVALID_FUNCTION 1 */
27 ENOENT, /* ERROR_FILE_NOT_FOUND 2 */
28 ENOENT, /* ERROR_PATH_NOT_FOUND 3 */
29 EMFILE, /* ERROR_TOO_MANY_OPEN_FILES 4 */
30 EACCES, /* ERROR_ACCESS_DENIED 5 */
31 EBADF, /* ERROR_INVALID_HANDLE 6 */
32 ENOMEM, /* ERROR_ARENA_TRASHED 7 */
33 ENOMEM, /* ERROR_NOT_ENOUGH_MEMORY 8 */
34 ENOMEM, /* ERROR_INVALID_BLOCK 9 */
35 E2BIG, /* ERROR_BAD_ENVIRONMENT 10 */
36 ENOEXEC, /* ERROR_BAD_FORMAT 11 */
37 EACCES, /* ERROR_INVALID_ACCESS 12 */
38 EINVAL, /* ERROR_INVALID_DATA 13 */
39 EFAULT, /* ERROR_OUT_OF_MEMORY 14 */
40 ENOENT, /* ERROR_INVALID_DRIVE 15 */
41 EACCES, /* ERROR_CURRENT_DIRECTORY 16 */
42 EXDEV, /* ERROR_NOT_SAME_DEVICE 17 */
43 ENOENT, /* ERROR_NO_MORE_FILES 18 */
44 EROFS, /* ERROR_WRITE_PROTECT 19 */
45 ENXIO, /* ERROR_BAD_UNIT 20 */
46 EBUSY, /* ERROR_NOT_READY 21 */
47 EIO, /* ERROR_BAD_COMMAND 22 */
48 EIO, /* ERROR_CRC 23 */
49 EIO, /* ERROR_BAD_LENGTH 24 */
50 EIO, /* ERROR_SEEK 25 */
51 EIO, /* ERROR_NOT_DOS_DISK 26 */
52 ENXIO, /* ERROR_SECTOR_NOT_FOUND 27 */
53 EBUSY, /* ERROR_OUT_OF_PAPER 28 */
54 EIO, /* ERROR_WRITE_FAULT 29 */
55 EIO, /* ERROR_READ_FAULT 30 */
56 EIO, /* ERROR_GEN_FAILURE 31 */
57 EACCES, /* ERROR_SHARING_VIOLATION 32 */
58 EACCES, /* ERROR_LOCK_VIOLATION 33 */
59 ENXIO, /* ERROR_WRONG_DISK 34 */
60 ENFILE, /* ERROR_FCB_UNAVAILABLE 35 */
61 ENFILE, /* ERROR_SHARING_BUFFER_EXCEEDED 36 */
62 EINVAL, /* 37 */
63 EINVAL, /* 38 */
64 ENOSPC, /* ERROR_HANDLE_DISK_FULL 39 */
65 EINVAL, /* 40 */
66 EINVAL, /* 41 */
67 EINVAL, /* 42 */
68 EINVAL, /* 43 */
69 EINVAL, /* 44 */
70 EINVAL, /* 45 */
71 EINVAL, /* 46 */
72 EINVAL, /* 47 */
73 EINVAL, /* 48 */
74 EINVAL, /* 49 */
75 ENODEV, /* ERROR_NOT_SUPPORTED 50 */
76 EBUSY, /* ERROR_REM_NOT_LIST 51 */
77 EEXIST, /* ERROR_DUP_NAME 52 */
78 ENOENT, /* ERROR_BAD_NETPATH 53 */
79 EBUSY, /* ERROR_NETWORK_BUSY 54 */
80 ENODEV, /* ERROR_DEV_NOT_EXIST 55 */
81 EAGAIN, /* ERROR_TOO_MANY_CMDS 56 */
82 EIO, /* ERROR_ADAP_HDW_ERR 57 */
83 EIO, /* ERROR_BAD_NET_RESP 58 */
84 EIO, /* ERROR_UNEXP_NET_ERR 59 */
85 EINVAL, /* ERROR_BAD_REM_ADAP 60 */
86 EFBIG, /* ERROR_PRINTQ_FULL 61 */
87 ENOSPC, /* ERROR_NO_SPOOL_SPACE 62 */
88 ENOENT, /* ERROR_PRINT_CANCELLED 63 */
89 ENOENT, /* ERROR_NETNAME_DELETED 64 */
90 EACCES, /* ERROR_NETWORK_ACCESS_DENIED 65 */
91 ENODEV, /* ERROR_BAD_DEV_TYPE 66 */
92 ENOENT, /* ERROR_BAD_NET_NAME 67 */
93 ENFILE, /* ERROR_TOO_MANY_NAMES 68 */
94 EIO, /* ERROR_TOO_MANY_SESS 69 */
95 EAGAIN, /* ERROR_SHARING_PAUSED 70 */
96 EINVAL, /* ERROR_REQ_NOT_ACCEP 71 */
97 EAGAIN, /* ERROR_REDIR_PAUSED 72 */
98 EINVAL, /* 73 */
99 EINVAL, /* 74 */
100 EINVAL, /* 75 */
101 EINVAL, /* 76 */
102 EINVAL, /* 77 */
103 EINVAL, /* 78 */
104 EINVAL, /* 79 */
105 EEXIST, /* ERROR_FILE_EXISTS 80 */
106 EINVAL, /* 81 */
107 ENOSPC, /* ERROR_CANNOT_MAKE 82 */
108 EIO, /* ERROR_FAIL_I24 83 */
109 ENFILE, /* ERROR_OUT_OF_STRUCTURES 84 */
110 EEXIST, /* ERROR_ALREADY_ASSIGNED 85 */
111 EPERM, /* ERROR_INVALID_PASSWORD 86 */
112 EINVAL, /* ERROR_INVALID_PARAMETER 87 */
113 EIO, /* ERROR_NET_WRITE_FAULT 88 */
114 EAGAIN, /* ERROR_NO_PROC_SLOTS 89 */
115 EINVAL, /* 90 */
116 EINVAL, /* 91 */
117 EINVAL, /* 92 */
118 EINVAL, /* 93 */
119 EINVAL, /* 94 */
120 EINVAL, /* 95 */
121 EINVAL, /* 96 */
122 EINVAL, /* 97 */
123 EINVAL, /* 98 */
124 EINVAL, /* 99 */
125 EINVAL, /* 100 */
126 EINVAL, /* 101 */
127 EINVAL, /* 102 */
128 EINVAL, /* 103 */
129 EINVAL, /* 104 */
130 EINVAL, /* 105 */
131 EINVAL, /* 106 */
132 EXDEV, /* ERROR_DISK_CHANGE 107 */
133 EAGAIN, /* ERROR_DRIVE_LOCKED 108 */
134 EPIPE, /* ERROR_BROKEN_PIPE 109 */
135 ENOENT, /* ERROR_OPEN_FAILED 110 */
136 EINVAL, /* ERROR_BUFFER_OVERFLOW 111 */
137 ENOSPC, /* ERROR_DISK_FULL 112 */
138 EMFILE, /* ERROR_NO_MORE_SEARCH_HANDLES 113 */
139 EBADF, /* ERROR_INVALID_TARGET_HANDLE 114 */
140 EFAULT, /* ERROR_PROTECTION_VIOLATION 115 */
141 EINVAL, /* 116 */
142 EINVAL, /* 117 */
143 EINVAL, /* 118 */
144 EINVAL, /* 119 */
145 EINVAL, /* 120 */
146 EINVAL, /* 121 */
147 EINVAL, /* 122 */
148 ENOENT, /* ERROR_INVALID_NAME 123 */
149 EINVAL, /* 124 */
150 EINVAL, /* 125 */
151 EINVAL, /* 126 */
152 ESRCH, /* ERROR_PROC_NOT_FOUND 127 */
153 ECHILD, /* ERROR_WAIT_NO_CHILDREN 128 */
154 ECHILD, /* ERROR_CHILD_NOT_COMPLETE 129 */
155 EBADF, /* ERROR_DIRECT_ACCESS_HANDLE 130 */
156 EINVAL, /* 131 */
157 ESPIPE, /* ERROR_SEEK_ON_DEVICE 132 */
158 EINVAL, /* 133 */
159 EINVAL, /* 134 */
160 EINVAL, /* 135 */
161 EINVAL, /* 136 */
162 EINVAL, /* 137 */
163 EINVAL, /* 138 */
164 EINVAL, /* 139 */
165 EINVAL, /* 140 */
166 EINVAL, /* 141 */
167 EAGAIN, /* ERROR_BUSY_DRIVE 142 */
168 EINVAL, /* 143 */
169 EINVAL, /* 144 */
170 EEXIST, /* ERROR_DIR_NOT_EMPTY 145 */
171 EINVAL, /* 146 */
172 EINVAL, /* 147 */
173 EINVAL, /* 148 */
174 EINVAL, /* 149 */
175 EINVAL, /* 150 */
176 EINVAL, /* 151 */
177 EINVAL, /* 152 */
178 EINVAL, /* 153 */
179 EINVAL, /* 154 */
180 EINVAL, /* 155 */
181 EINVAL, /* 156 */
182 EINVAL, /* 157 */
183 EACCES, /* ERROR_NOT_LOCKED 158 */
184 EINVAL, /* 159 */
185 EINVAL, /* 160 */
186 ENOENT, /* ERROR_BAD_PATHNAME 161 */
187 EINVAL, /* 162 */
188 EINVAL, /* 163 */
189 EINVAL, /* 164 */
190 EINVAL, /* 165 */
191 EINVAL, /* 166 */
192 EACCES, /* ERROR_LOCK_FAILED 167 */
193 EINVAL, /* 168 */
194 EINVAL, /* 169 */
195 EINVAL, /* 170 */
196 EINVAL, /* 171 */
197 EINVAL, /* 172 */
198 EINVAL, /* 173 */
199 EINVAL, /* 174 */
200 EINVAL, /* 175 */
201 EINVAL, /* 176 */
202 EINVAL, /* 177 */
203 EINVAL, /* 178 */
204 EINVAL, /* 179 */
205 EINVAL, /* 180 */
206 EINVAL, /* 181 */
207 EINVAL, /* 182 */
208 EEXIST, /* ERROR_ALREADY_EXISTS 183 */
209 ECHILD, /* ERROR_NO_CHILD_PROCESS 184 */
210 EINVAL, /* 185 */
211 EINVAL, /* 186 */
212 EINVAL, /* 187 */
213 EINVAL, /* 188 */
214 EINVAL, /* 189 */
215 EINVAL, /* 190 */
216 EINVAL, /* 191 */
217 EINVAL, /* 192 */
218 EINVAL, /* 193 */
219 EINVAL, /* 194 */
220 EINVAL, /* 195 */
221 EINVAL, /* 196 */
222 EINVAL, /* 197 */
223 EINVAL, /* 198 */
224 EINVAL, /* 199 */
225 EINVAL, /* 200 */
226 EINVAL, /* 201 */
227 EINVAL, /* 202 */
228 EINVAL, /* 203 */
229 EINVAL, /* 204 */
230 EINVAL, /* 205 */
231 ENAMETOOLONG,/* ERROR_FILENAME_EXCED_RANGE 206 */
232 EINVAL, /* 207 */
233 EINVAL, /* 208 */
234 EINVAL, /* 209 */
235 EINVAL, /* 210 */
236 EINVAL, /* 211 */
237 EINVAL, /* 212 */
238 EINVAL, /* 213 */
239 EINVAL, /* 214 */
240 EINVAL, /* 215 */
241 EINVAL, /* 216 */
242 EINVAL, /* 217 */
243 EINVAL, /* 218 */
244 EINVAL, /* 219 */
245 EINVAL, /* 220 */
246 EINVAL, /* 221 */
247 EINVAL, /* 222 */
248 EINVAL, /* 223 */
249 EINVAL, /* 224 */
250 EINVAL, /* 225 */
251 EINVAL, /* 226 */
252 EINVAL, /* 227 */
253 EINVAL, /* 228 */
254 EINVAL, /* 229 */
255 EPIPE, /* ERROR_BAD_PIPE 230 */
256 EAGAIN, /* ERROR_PIPE_BUSY 231 */
257 EPIPE, /* ERROR_NO_DATA 232 */
258 EPIPE, /* ERROR_PIPE_NOT_CONNECTED 233 */
259 EINVAL, /* 234 */
260 EINVAL, /* 235 */
261 EINVAL, /* 236 */
262 EINVAL, /* 237 */
263 EINVAL, /* 238 */
264 EINVAL, /* 239 */
265 EINVAL, /* 240 */
266 EINVAL, /* 241 */
267 EINVAL, /* 242 */
268 EINVAL, /* 243 */
269 EINVAL, /* 244 */
270 EINVAL, /* 245 */
271 EINVAL, /* 246 */
272 EINVAL, /* 247 */
273 EINVAL, /* 248 */
274 EINVAL, /* 249 */
275 EINVAL, /* 250 */
276 EINVAL, /* 251 */
277 EINVAL, /* 252 */
278 EINVAL, /* 253 */
279 EINVAL, /* 254 */
280 EINVAL, /* 255 */
281 EINVAL, /* 256 */
282 EINVAL, /* 257 */
283 EINVAL, /* 258 */
284 EINVAL, /* 259 */
285 EINVAL, /* 260 */
286 EINVAL, /* 261 */
287 EINVAL, /* 262 */
288 EINVAL, /* 263 */
289 EINVAL, /* 264 */
290 EINVAL, /* 265 */
291 EINVAL, /* 266 */
292 ENOTDIR, /* ERROR_DIRECTORY 267 */
293 };
294
295 static const unsigned int tableLen = sizeof(errorTable);
296
297 /*
298 * The following table contains the mapping from WinSock errors to
299 * errno errors.
300 */
301
302 static int wsaErrorTable[] = {
303 EWOULDBLOCK, /* WSAEWOULDBLOCK */
304 EINPROGRESS, /* WSAEINPROGRESS */
305 EALREADY, /* WSAEALREADY */
306 ENOTSOCK, /* WSAENOTSOCK */
307 EDESTADDRREQ, /* WSAEDESTADDRREQ */
308 EMSGSIZE, /* WSAEMSGSIZE */
309 EPROTOTYPE, /* WSAEPROTOTYPE */
310 ENOPROTOOPT, /* WSAENOPROTOOPT */
311 EPROTONOSUPPORT, /* WSAEPROTONOSUPPORT */
312 ESOCKTNOSUPPORT, /* WSAESOCKTNOSUPPORT */
313 EOPNOTSUPP, /* WSAEOPNOTSUPP */
314 EPFNOSUPPORT, /* WSAEPFNOSUPPORT */
315 EAFNOSUPPORT, /* WSAEAFNOSUPPORT */
316 EADDRINUSE, /* WSAEADDRINUSE */
317 EADDRNOTAVAIL, /* WSAEADDRNOTAVAIL */
318 ENETDOWN, /* WSAENETDOWN */
319 ENETUNREACH, /* WSAENETUNREACH */
320 ENETRESET, /* WSAENETRESET */
321 ECONNABORTED, /* WSAECONNABORTED */
322 ECONNRESET, /* WSAECONNRESET */
323 ENOBUFS, /* WSAENOBUFS */
324 EISCONN, /* WSAEISCONN */
325 ENOTCONN, /* WSAENOTCONN */
326 ESHUTDOWN, /* WSAESHUTDOWN */
327 ETOOMANYREFS, /* WSAETOOMANYREFS */
328 ETIMEDOUT, /* WSAETIMEDOUT */
329 ECONNREFUSED, /* WSAECONNREFUSED */
330 ELOOP, /* WSAELOOP */
331 ENAMETOOLONG, /* WSAENAMETOOLONG */
332 EHOSTDOWN, /* WSAEHOSTDOWN */
333 EHOSTUNREACH, /* WSAEHOSTUNREACH */
334 ENOTEMPTY, /* WSAENOTEMPTY */
335 EAGAIN, /* WSAEPROCLIM */
336 EUSERS, /* WSAEUSERS */
337 EDQUOT, /* WSAEDQUOT */
338 ESTALE, /* WSAESTALE */
339 EREMOTE, /* WSAEREMOTE */
340 };
341
342 /*
343 *----------------------------------------------------------------------
344 *
345 * TclWinConvertError --
346 *
347 * This routine converts a Win32 error into an errno value.
348 *
349 * Results:
350 * None.
351 *
352 * Side effects:
353 * Sets the errno global variable.
354 *
355 *----------------------------------------------------------------------
356 */
357
358 void
359 TclWinConvertError(errCode)
360 DWORD errCode; /* Win32 error code. */
361 {
362 if (errCode >= tableLen) {
363 Tcl_SetErrno(EINVAL);
364 } else {
365 Tcl_SetErrno(errorTable[errCode]);
366 }
367 }
368
369 /*
370 *----------------------------------------------------------------------
371 *
372 * TclWinConvertWSAError --
373 *
374 * This routine converts a WinSock error into an errno value.
375 *
376 * Results:
377 * None.
378 *
379 * Side effects:
380 * Sets the errno global variable.
381 *
382 *----------------------------------------------------------------------
383 */
384
385 void
386 TclWinConvertWSAError(errCode)
387 DWORD errCode; /* Win32 error code. */
388 {
389 if ((errCode >= WSAEWOULDBLOCK) && (errCode <= WSAEREMOTE)) {
390 Tcl_SetErrno(wsaErrorTable[errCode - WSAEWOULDBLOCK]);
391 } else {
392 Tcl_SetErrno(EINVAL);
393 }
394 }
395
396
397 /* $History: tclwinerror.c $
398 *
399 * ***************** Version 1 *****************
400 * User: Dtashley Date: 1/02/01 Time: 12:38a
401 * Created in $/IjuScripter, IjuConsole/Source/Tcl Base
402 * Initial check-in.
403 */
404
405 /* End of TCLWINERROR.C */

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25