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

Properties

Name Value
svn:eol-style native
svn:keywords Header

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25