1 | /* $Id: nocrt-strerror.cpp 96073 2022-08-06 00:20:33Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - No-CRT - Convert errno value to string.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2022 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.alldomusa.eu.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #define IPRT_NO_CRT_FOR_3RD_PARTY
|
---|
32 | #include "internal/nocrt.h"
|
---|
33 | #include <iprt/nocrt/string.h>
|
---|
34 | #include <iprt/nocrt/errno.h>
|
---|
35 | #include <iprt/assert.h>
|
---|
36 |
|
---|
37 |
|
---|
38 | #undef strerror
|
---|
39 | const char *RT_NOCRT(strerror)(int iErrNo)
|
---|
40 | {
|
---|
41 | /*
|
---|
42 | * Process error codes.
|
---|
43 | *
|
---|
44 | * (Use a switch and not a table since the numbers vary among compilers
|
---|
45 | * and OSes. So we let the compiler switch optimizer handle speed issues.)
|
---|
46 | *
|
---|
47 | * This switch is arranged like the Linux i386 errno.h! This switch is mirrored
|
---|
48 | * by RTErrConvertToErrno and RTErrConvertFromErrno.
|
---|
49 | */
|
---|
50 | switch (iErrNo)
|
---|
51 | { /* Linux number */
|
---|
52 | case 0: return "no error";
|
---|
53 | #ifdef EPERM
|
---|
54 | RT_CASE_RET_STR(EPERM); /* 1 */
|
---|
55 | #endif
|
---|
56 | #ifdef ENOENT
|
---|
57 | RT_CASE_RET_STR(ENOENT);
|
---|
58 | #endif
|
---|
59 | #ifdef ESRCH
|
---|
60 | RT_CASE_RET_STR(ESRCH);
|
---|
61 | #endif
|
---|
62 | #ifdef EINTR
|
---|
63 | RT_CASE_RET_STR(EINTR);
|
---|
64 | #endif
|
---|
65 | #ifdef EIO
|
---|
66 | RT_CASE_RET_STR(EIO);
|
---|
67 | #endif
|
---|
68 | #ifdef ENXIO
|
---|
69 | RT_CASE_RET_STR(ENXIO); /** @todo fix this duplicate error */
|
---|
70 | #endif
|
---|
71 | #ifdef E2BIG
|
---|
72 | RT_CASE_RET_STR(E2BIG);
|
---|
73 | #endif
|
---|
74 | #ifdef ENOEXEC
|
---|
75 | RT_CASE_RET_STR(ENOEXEC);
|
---|
76 | #endif
|
---|
77 | #ifdef EBADF
|
---|
78 | RT_CASE_RET_STR(EBADF);
|
---|
79 | #endif
|
---|
80 | #ifdef ECHILD
|
---|
81 | RT_CASE_RET_STR(ECHILD); /* 10 */ /** @todo fix duplicate error */
|
---|
82 | #endif
|
---|
83 | #ifdef EAGAIN
|
---|
84 | RT_CASE_RET_STR(EAGAIN);
|
---|
85 | #endif
|
---|
86 | #ifdef ENOMEM
|
---|
87 | RT_CASE_RET_STR(ENOMEM);
|
---|
88 | #endif
|
---|
89 | #ifdef EACCES
|
---|
90 | RT_CASE_RET_STR(EACCES); /** @todo fix duplicate error */
|
---|
91 | #endif
|
---|
92 | #ifdef EFAULT
|
---|
93 | RT_CASE_RET_STR(EFAULT);
|
---|
94 | #endif
|
---|
95 | #ifdef ENOTBLK
|
---|
96 | RT_CASE_RET_STR(ENOTBLK);
|
---|
97 | #endif
|
---|
98 | #ifdef EBUSY
|
---|
99 | RT_CASE_RET_STR(EBUSY);
|
---|
100 | #endif
|
---|
101 | #ifdef EEXIST
|
---|
102 | RT_CASE_RET_STR(EEXIST);
|
---|
103 | #endif
|
---|
104 | #ifdef EXDEV
|
---|
105 | RT_CASE_RET_STR(EXDEV);
|
---|
106 | #endif
|
---|
107 | #ifdef ENODEV
|
---|
108 | RT_CASE_RET_STR(ENODEV); /** @todo fix duplicate error */
|
---|
109 | #endif
|
---|
110 | #ifdef ENOTDIR
|
---|
111 | RT_CASE_RET_STR(ENOTDIR); /* 20 */
|
---|
112 | #endif
|
---|
113 | #ifdef EISDIR
|
---|
114 | RT_CASE_RET_STR(EISDIR);
|
---|
115 | #endif
|
---|
116 | #ifdef EINVAL
|
---|
117 | RT_CASE_RET_STR(EINVAL);
|
---|
118 | #endif
|
---|
119 | #ifdef ENFILE
|
---|
120 | RT_CASE_RET_STR(ENFILE); /** @todo fix duplicate error */
|
---|
121 | #endif
|
---|
122 | #ifdef EMFILE
|
---|
123 | RT_CASE_RET_STR(EMFILE);
|
---|
124 | #endif
|
---|
125 | #ifdef ENOTTY
|
---|
126 | RT_CASE_RET_STR(ENOTTY);
|
---|
127 | #endif
|
---|
128 | #ifdef ETXTBSY
|
---|
129 | RT_CASE_RET_STR(ETXTBSY);
|
---|
130 | #endif
|
---|
131 | #ifdef EFBIG
|
---|
132 | RT_CASE_RET_STR(EFBIG);
|
---|
133 | #endif
|
---|
134 | #ifdef ENOSPC
|
---|
135 | RT_CASE_RET_STR(ENOSPC);
|
---|
136 | #endif
|
---|
137 | #ifdef ESPIPE
|
---|
138 | RT_CASE_RET_STR(ESPIPE);
|
---|
139 | #endif
|
---|
140 | #ifdef EROFS
|
---|
141 | RT_CASE_RET_STR(EROFS); /* 30 */
|
---|
142 | #endif
|
---|
143 | #ifdef EMLINK
|
---|
144 | RT_CASE_RET_STR(EMLINK);
|
---|
145 | #endif
|
---|
146 | #ifdef EPIPE
|
---|
147 | RT_CASE_RET_STR(EPIPE);
|
---|
148 | #endif
|
---|
149 | #ifdef EDOM
|
---|
150 | RT_CASE_RET_STR(EDOM); /** @todo fix duplicate error */
|
---|
151 | #endif
|
---|
152 | #ifdef ERANGE
|
---|
153 | RT_CASE_RET_STR(ERANGE); /** @todo fix duplicate error */
|
---|
154 | #endif
|
---|
155 | #ifdef EDEADLK
|
---|
156 | RT_CASE_RET_STR(EDEADLK);
|
---|
157 | #endif
|
---|
158 | #ifdef ENAMETOOLONG
|
---|
159 | RT_CASE_RET_STR(ENAMETOOLONG);
|
---|
160 | #endif
|
---|
161 | #ifdef ENOLCK
|
---|
162 | RT_CASE_RET_STR(ENOLCK);
|
---|
163 | #endif
|
---|
164 | #ifdef ENOSYS /** @todo map this differently on solaris. */
|
---|
165 | RT_CASE_RET_STR(ENOSYS);
|
---|
166 | #endif
|
---|
167 | #ifdef ENOTEMPTY
|
---|
168 | RT_CASE_RET_STR(ENOTEMPTY);
|
---|
169 | #endif
|
---|
170 | #ifdef ELOOP
|
---|
171 | RT_CASE_RET_STR(ELOOP); /* 40 */
|
---|
172 | #endif
|
---|
173 | //41??
|
---|
174 | #ifdef ENOMSG
|
---|
175 | RT_CASE_RET_STR(ENOMSG);
|
---|
176 | #endif
|
---|
177 | #ifdef EIDRM
|
---|
178 | RT_CASE_RET_STR(EIDRM);
|
---|
179 | #endif
|
---|
180 | #ifdef ECHRNG
|
---|
181 | RT_CASE_RET_STR(ECHRNG);
|
---|
182 | #endif
|
---|
183 | #ifdef EL2NSYNC
|
---|
184 | RT_CASE_RET_STR(EL2NSYNC);
|
---|
185 | #endif
|
---|
186 | #ifdef EL3HLT
|
---|
187 | RT_CASE_RET_STR(EL3HLT);
|
---|
188 | #endif
|
---|
189 | #ifdef EL3RST
|
---|
190 | RT_CASE_RET_STR(EL3RST);
|
---|
191 | #endif
|
---|
192 | #ifdef ELNRNG
|
---|
193 | RT_CASE_RET_STR(ELNRNG);
|
---|
194 | #endif
|
---|
195 | #ifdef EUNATCH
|
---|
196 | RT_CASE_RET_STR(EUNATCH);
|
---|
197 | #endif
|
---|
198 | #ifdef ENOCSI
|
---|
199 | RT_CASE_RET_STR(ENOCSI);
|
---|
200 | #endif
|
---|
201 | #ifdef EL2HLT
|
---|
202 | RT_CASE_RET_STR(EL2HLT);
|
---|
203 | #endif
|
---|
204 | #ifdef EBADE
|
---|
205 | RT_CASE_RET_STR(EBADE);
|
---|
206 | #endif
|
---|
207 | #ifdef EBADR
|
---|
208 | RT_CASE_RET_STR(EBADR);
|
---|
209 | #endif
|
---|
210 | #ifdef EXFULL
|
---|
211 | RT_CASE_RET_STR(EXFULL);
|
---|
212 | #endif
|
---|
213 | #ifdef ENOANO
|
---|
214 | RT_CASE_RET_STR(ENOANO);
|
---|
215 | #endif
|
---|
216 | #ifdef EBADRQC
|
---|
217 | RT_CASE_RET_STR(EBADRQC);
|
---|
218 | #endif
|
---|
219 | #ifdef EBADSLT
|
---|
220 | RT_CASE_RET_STR(EBADSLT);
|
---|
221 | #endif
|
---|
222 | //case 58:
|
---|
223 | #ifdef EBFONT
|
---|
224 | RT_CASE_RET_STR(EBFONT);
|
---|
225 | #endif
|
---|
226 | #ifdef ENOSTR
|
---|
227 | RT_CASE_RET_STR(ENOSTR);
|
---|
228 | #endif
|
---|
229 | #ifdef ENODATA
|
---|
230 | RT_CASE_RET_STR(ENODATA);
|
---|
231 | #endif
|
---|
232 | #ifdef ETIME
|
---|
233 | RT_CASE_RET_STR(ETIME);
|
---|
234 | #endif
|
---|
235 | #ifdef ENOSR
|
---|
236 | RT_CASE_RET_STR(ENOSR);
|
---|
237 | #endif
|
---|
238 | #ifdef ENONET
|
---|
239 | RT_CASE_RET_STR(ENONET);
|
---|
240 | #endif
|
---|
241 | #ifdef ENOPKG
|
---|
242 | RT_CASE_RET_STR(ENOPKG);
|
---|
243 | #endif
|
---|
244 | #ifdef EREMOTE
|
---|
245 | RT_CASE_RET_STR(EREMOTE);
|
---|
246 | #endif
|
---|
247 | #ifdef ENOLINK
|
---|
248 | RT_CASE_RET_STR(ENOLINK);
|
---|
249 | #endif
|
---|
250 | #ifdef EADV
|
---|
251 | RT_CASE_RET_STR(EADV);
|
---|
252 | #endif
|
---|
253 | #ifdef ESRMNT
|
---|
254 | RT_CASE_RET_STR(ESRMNT);
|
---|
255 | #endif
|
---|
256 | #ifdef ECOMM
|
---|
257 | RT_CASE_RET_STR(ECOMM);
|
---|
258 | #endif
|
---|
259 | #ifdef EPROTO
|
---|
260 | RT_CASE_RET_STR(EPROTO);
|
---|
261 | #endif
|
---|
262 | #ifdef EMULTIHOP
|
---|
263 | RT_CASE_RET_STR(EMULTIHOP);
|
---|
264 | #endif
|
---|
265 | #ifdef EDOTDOT
|
---|
266 | RT_CASE_RET_STR(EDOTDOT);
|
---|
267 | #endif
|
---|
268 | #ifdef EBADMSG
|
---|
269 | RT_CASE_RET_STR(EBADMSG);
|
---|
270 | #endif
|
---|
271 | #ifdef EOVERFLOW
|
---|
272 | RT_CASE_RET_STR(EOVERFLOW); /** @todo fix duplicate error? */
|
---|
273 | #endif
|
---|
274 | #ifdef ENOTUNIQ
|
---|
275 | RT_CASE_RET_STR(ENOTUNIQ);
|
---|
276 | #endif
|
---|
277 | #ifdef EBADFD
|
---|
278 | RT_CASE_RET_STR(EBADFD); /** @todo fix duplicate error? */
|
---|
279 | #endif
|
---|
280 | #ifdef EREMCHG
|
---|
281 | RT_CASE_RET_STR(EREMCHG);
|
---|
282 | #endif
|
---|
283 | #ifdef ELIBACC
|
---|
284 | RT_CASE_RET_STR(ELIBACC);
|
---|
285 | #endif
|
---|
286 | #ifdef ELIBBAD
|
---|
287 | RT_CASE_RET_STR(ELIBBAD);
|
---|
288 | #endif
|
---|
289 | #ifdef ELIBSCN
|
---|
290 | RT_CASE_RET_STR(ELIBSCN);
|
---|
291 | #endif
|
---|
292 | #ifdef ELIBMAX
|
---|
293 | RT_CASE_RET_STR(ELIBMAX);
|
---|
294 | #endif
|
---|
295 | #ifdef ELIBEXEC
|
---|
296 | RT_CASE_RET_STR(ELIBEXEC);
|
---|
297 | #endif
|
---|
298 | #ifdef EILSEQ
|
---|
299 | RT_CASE_RET_STR(EILSEQ);
|
---|
300 | #endif
|
---|
301 | #ifdef ERESTART
|
---|
302 | RT_CASE_RET_STR(ERESTART);/** @todo fix duplicate error?*/
|
---|
303 | #endif
|
---|
304 | #ifdef ESTRPIPE
|
---|
305 | RT_CASE_RET_STR(ESTRPIPE);
|
---|
306 | #endif
|
---|
307 | #ifdef EUSERS
|
---|
308 | RT_CASE_RET_STR(EUSERS);
|
---|
309 | #endif
|
---|
310 | #ifdef ENOTSOCK
|
---|
311 | RT_CASE_RET_STR(ENOTSOCK);
|
---|
312 | #endif
|
---|
313 | #ifdef EDESTADDRREQ
|
---|
314 | RT_CASE_RET_STR(EDESTADDRREQ);
|
---|
315 | #endif
|
---|
316 | #ifdef EMSGSIZE
|
---|
317 | RT_CASE_RET_STR(EMSGSIZE);
|
---|
318 | #endif
|
---|
319 | #ifdef EPROTOTYPE
|
---|
320 | RT_CASE_RET_STR(EPROTOTYPE);
|
---|
321 | #endif
|
---|
322 | #ifdef ENOPROTOOPT
|
---|
323 | RT_CASE_RET_STR(ENOPROTOOPT);
|
---|
324 | #endif
|
---|
325 | #ifdef EPROTONOSUPPORT
|
---|
326 | RT_CASE_RET_STR(EPROTONOSUPPORT);
|
---|
327 | #endif
|
---|
328 | #ifdef ESOCKTNOSUPPORT
|
---|
329 | RT_CASE_RET_STR(ESOCKTNOSUPPORT);
|
---|
330 | #endif
|
---|
331 | #ifdef EOPNOTSUPP /** @todo map this differently on solaris. */
|
---|
332 | RT_CASE_RET_STR(EOPNOTSUPP);
|
---|
333 | #endif
|
---|
334 | #ifdef EPFNOSUPPORT
|
---|
335 | RT_CASE_RET_STR(EPFNOSUPPORT);
|
---|
336 | #endif
|
---|
337 | #ifdef EAFNOSUPPORT
|
---|
338 | RT_CASE_RET_STR(EAFNOSUPPORT);
|
---|
339 | #endif
|
---|
340 | #ifdef EADDRINUSE
|
---|
341 | RT_CASE_RET_STR(EADDRINUSE);
|
---|
342 | #endif
|
---|
343 | #ifdef EADDRNOTAVAIL
|
---|
344 | RT_CASE_RET_STR(EADDRNOTAVAIL);
|
---|
345 | #endif
|
---|
346 | #ifdef ENETDOWN
|
---|
347 | RT_CASE_RET_STR(ENETDOWN);
|
---|
348 | #endif
|
---|
349 | #ifdef ENETUNREACH
|
---|
350 | RT_CASE_RET_STR(ENETUNREACH);
|
---|
351 | #endif
|
---|
352 | #ifdef ENETRESET
|
---|
353 | RT_CASE_RET_STR(ENETRESET);
|
---|
354 | #endif
|
---|
355 | #ifdef ECONNABORTED
|
---|
356 | RT_CASE_RET_STR(ECONNABORTED);
|
---|
357 | #endif
|
---|
358 | #ifdef ECONNRESET
|
---|
359 | RT_CASE_RET_STR(ECONNRESET);
|
---|
360 | #endif
|
---|
361 | #ifdef ENOBUFS
|
---|
362 | RT_CASE_RET_STR(ENOBUFS);
|
---|
363 | #endif
|
---|
364 | #ifdef EISCONN
|
---|
365 | RT_CASE_RET_STR(EISCONN);
|
---|
366 | #endif
|
---|
367 | #ifdef ENOTCONN
|
---|
368 | RT_CASE_RET_STR(ENOTCONN);
|
---|
369 | #endif
|
---|
370 | #ifdef ESHUTDOWN
|
---|
371 | RT_CASE_RET_STR(ESHUTDOWN);
|
---|
372 | #endif
|
---|
373 | #ifdef ETOOMANYREFS
|
---|
374 | RT_CASE_RET_STR(ETOOMANYREFS);
|
---|
375 | #endif
|
---|
376 | #ifdef ETIMEDOUT
|
---|
377 | RT_CASE_RET_STR(ETIMEDOUT);
|
---|
378 | #endif
|
---|
379 | #ifdef ECONNREFUSED
|
---|
380 | RT_CASE_RET_STR(ECONNREFUSED);
|
---|
381 | #endif
|
---|
382 | #ifdef EHOSTDOWN
|
---|
383 | RT_CASE_RET_STR(EHOSTDOWN);
|
---|
384 | #endif
|
---|
385 | #ifdef EHOSTUNREACH
|
---|
386 | RT_CASE_RET_STR(EHOSTUNREACH);
|
---|
387 | #endif
|
---|
388 | #ifdef EALREADY
|
---|
389 | # if !defined(ENOLCK) || (EALREADY != ENOLCK)
|
---|
390 | RT_CASE_RET_STR(EALREADY);
|
---|
391 | # endif
|
---|
392 | #endif
|
---|
393 | #ifdef EINPROGRESS
|
---|
394 | # if !defined(ENODEV) || (EINPROGRESS != ENODEV)
|
---|
395 | RT_CASE_RET_STR(EINPROGRESS);
|
---|
396 | # endif
|
---|
397 | #endif
|
---|
398 | #ifdef ESTALE
|
---|
399 | RT_CASE_RET_STR(ESTALE); /* 116: Stale NFS file handle */
|
---|
400 | #endif
|
---|
401 | #ifdef EUCLEAN
|
---|
402 | RT_CASE_RET_STR(EUCLEAN);
|
---|
403 | #endif
|
---|
404 | #ifdef ENOTNAM
|
---|
405 | RT_CASE_RET_STR(ENOTNAM);
|
---|
406 | #endif
|
---|
407 | #ifdef ENAVAIL
|
---|
408 | RT_CASE_RET_STR(ENAVAIL);
|
---|
409 | #endif
|
---|
410 | #ifdef EISNAM
|
---|
411 | RT_CASE_RET_STR(EISNAM);
|
---|
412 | #endif
|
---|
413 | #ifdef EREMOTEIO
|
---|
414 | RT_CASE_RET_STR(EREMOTEIO);
|
---|
415 | #endif
|
---|
416 | #ifdef EDQUOT
|
---|
417 | RT_CASE_RET_STR(EDQUOT); /** @todo fix duplicate error */
|
---|
418 | #endif
|
---|
419 | #ifdef ENOMEDIUM
|
---|
420 | RT_CASE_RET_STR(ENOMEDIUM);
|
---|
421 | #endif
|
---|
422 | #ifdef EMEDIUMTYPE
|
---|
423 | RT_CASE_RET_STR(EMEDIUMTYPE);
|
---|
424 | #endif
|
---|
425 | #if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
|
---|
426 | RT_CASE_RET_STR(EWOULDBLOCK);
|
---|
427 | #endif
|
---|
428 |
|
---|
429 | /* Non-linux */
|
---|
430 |
|
---|
431 | #ifdef EPROCLIM
|
---|
432 | RT_CASE_RET_STR(EPROCLIM);
|
---|
433 | #endif
|
---|
434 | #ifdef EDOOFUS
|
---|
435 | # if EDOOFUS != EINVAL
|
---|
436 | RT_CASE_RET_STR(EDOOFUS);
|
---|
437 | # endif
|
---|
438 | #endif
|
---|
439 | #ifdef ENOTSUP
|
---|
440 | # ifndef EOPNOTSUPP
|
---|
441 | RT_CASE_RET_STR(ENOTSUP);
|
---|
442 | # else
|
---|
443 | # if ENOTSUP != EOPNOTSUPP
|
---|
444 | RT_CASE_RET_STR(ENOTSUP);
|
---|
445 | # endif
|
---|
446 | # endif
|
---|
447 | #endif
|
---|
448 | default:
|
---|
449 | AssertLogRelMsgFailedReturn(("Unhandled error code %d\n", iErrNo), "unknown-errno-value");
|
---|
450 | }
|
---|
451 | }
|
---|
452 | RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strerror);
|
---|
453 |
|
---|