summaryrefslogtreecommitdiffstats
path: root/src/VBox/Runtime/common/err/nocrt-strerror.cpp
blob: e26136eaab6f88540e5a35c470da9367497ea3aa (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
/* $Id: nocrt-strerror.cpp $ */
/** @file
 * IPRT - No-CRT - Convert errno value to string.
 */

/*
 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
 *
 * This file is part of VirtualBox base platform packages, as
 * available from https://www.virtualbox.org.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, in version 3 of the
 * License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses>.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
 * in the VirtualBox distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 *
 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
 */


/*********************************************************************************************************************************
*   Header Files                                                                                                                 *
*********************************************************************************************************************************/
#define IPRT_NO_CRT_FOR_3RD_PARTY
#include "internal/nocrt.h"
#include <iprt/nocrt/string.h>
#include <iprt/nocrt/errno.h>
#include <iprt/assert.h>
#include <iprt/log.h>


#undef strerror
const char *RT_NOCRT(strerror)(int iErrNo)
{
    /*
     * Process error codes.
     *
     * (Use a switch and not a table since the numbers vary among compilers
     * and OSes. So we let the compiler switch optimizer handle speed issues.)
     *
     * This switch is arranged like the Linux i386 errno.h! This switch is mirrored
     * by RTErrConvertToErrno and RTErrConvertFromErrno.
     */
    switch (iErrNo)
    {                                                                           /* Linux number */
        case 0: return "no error";
#ifdef EPERM
        RT_CASE_RET_STR(EPERM);                      /*   1 */
#endif
#ifdef ENOENT
        RT_CASE_RET_STR(ENOENT);
#endif
#ifdef ESRCH
        RT_CASE_RET_STR(ESRCH);
#endif
#ifdef EINTR
        RT_CASE_RET_STR(EINTR);
#endif
#ifdef EIO
        RT_CASE_RET_STR(EIO);
#endif
#ifdef ENXIO
        RT_CASE_RET_STR(ENXIO); /** @todo fix this duplicate error */
#endif
#ifdef E2BIG
        RT_CASE_RET_STR(E2BIG);
#endif
#ifdef ENOEXEC
        RT_CASE_RET_STR(ENOEXEC);
#endif
#ifdef EBADF
        RT_CASE_RET_STR(EBADF);
#endif
#ifdef ECHILD
        RT_CASE_RET_STR(ECHILD);                  /*  10 */ /** @todo fix duplicate error */
#endif
#ifdef EAGAIN
        RT_CASE_RET_STR(EAGAIN);
#endif
#ifdef ENOMEM
        RT_CASE_RET_STR(ENOMEM);
#endif
#ifdef EACCES
        RT_CASE_RET_STR(EACCES); /** @todo fix duplicate error */
#endif
#ifdef EFAULT
        RT_CASE_RET_STR(EFAULT);
#endif
#ifdef ENOTBLK
        RT_CASE_RET_STR(ENOTBLK);
#endif
#ifdef EBUSY
        RT_CASE_RET_STR(EBUSY);
#endif
#ifdef EEXIST
        RT_CASE_RET_STR(EEXIST);
#endif
#ifdef EXDEV
        RT_CASE_RET_STR(EXDEV);
#endif
#ifdef ENODEV
        RT_CASE_RET_STR(ENODEV); /** @todo fix duplicate error */
#endif
#ifdef ENOTDIR
        RT_CASE_RET_STR(ENOTDIR);                     /*  20 */
#endif
#ifdef EISDIR
        RT_CASE_RET_STR(EISDIR);
#endif
#ifdef EINVAL
        RT_CASE_RET_STR(EINVAL);
#endif
#ifdef ENFILE
        RT_CASE_RET_STR(ENFILE); /** @todo fix duplicate error */
#endif
#ifdef EMFILE
        RT_CASE_RET_STR(EMFILE);
#endif
#ifdef ENOTTY
        RT_CASE_RET_STR(ENOTTY);
#endif
#ifdef ETXTBSY
        RT_CASE_RET_STR(ETXTBSY);
#endif
#ifdef EFBIG
        RT_CASE_RET_STR(EFBIG);
#endif
#ifdef ENOSPC
        RT_CASE_RET_STR(ENOSPC);
#endif
#ifdef ESPIPE
        RT_CASE_RET_STR(ESPIPE);
#endif
#ifdef EROFS
        RT_CASE_RET_STR(EROFS);                      /*  30 */
#endif
#ifdef EMLINK
         RT_CASE_RET_STR(EMLINK);
#endif
#ifdef EPIPE
        RT_CASE_RET_STR(EPIPE);
#endif
#ifdef EDOM
        RT_CASE_RET_STR(EDOM);  /** @todo fix duplicate error */
#endif
#ifdef ERANGE
        RT_CASE_RET_STR(ERANGE);  /** @todo fix duplicate error */
#endif
#ifdef EDEADLK
        RT_CASE_RET_STR(EDEADLK);
#endif
#ifdef ENAMETOOLONG
        RT_CASE_RET_STR(ENAMETOOLONG);
#endif
#ifdef ENOLCK
        RT_CASE_RET_STR(ENOLCK);
#endif
#ifdef ENOSYS /** @todo map this differently on solaris. */
        RT_CASE_RET_STR(ENOSYS);
#endif
#ifdef ENOTEMPTY
        RT_CASE_RET_STR(ENOTEMPTY);
#endif
#ifdef ELOOP
        RT_CASE_RET_STR(ELOOP);                  /*  40 */
#endif
        //41??
#ifdef ENOMSG
        RT_CASE_RET_STR(ENOMSG);
#endif
#ifdef EIDRM
        RT_CASE_RET_STR(EIDRM);
#endif
#ifdef ECHRNG
        RT_CASE_RET_STR(ECHRNG);
#endif
#ifdef EL2NSYNC
        RT_CASE_RET_STR(EL2NSYNC);
#endif
#ifdef EL3HLT
        RT_CASE_RET_STR(EL3HLT);
#endif
#ifdef EL3RST
        RT_CASE_RET_STR(EL3RST);
#endif
#ifdef ELNRNG
        RT_CASE_RET_STR(ELNRNG);
#endif
#ifdef EUNATCH
        RT_CASE_RET_STR(EUNATCH);
#endif
#ifdef ENOCSI
        RT_CASE_RET_STR(ENOCSI);
#endif
#ifdef EL2HLT
        RT_CASE_RET_STR(EL2HLT);
#endif
#ifdef EBADE
        RT_CASE_RET_STR(EBADE);
#endif
#ifdef EBADR
        RT_CASE_RET_STR(EBADR);
#endif
#ifdef EXFULL
        RT_CASE_RET_STR(EXFULL);
#endif
#ifdef ENOANO
        RT_CASE_RET_STR(ENOANO);
#endif
#ifdef EBADRQC
        RT_CASE_RET_STR(EBADRQC);
#endif
#ifdef EBADSLT
        RT_CASE_RET_STR(EBADSLT);
#endif
        //case 58:
#ifdef EBFONT
        RT_CASE_RET_STR(EBFONT);
#endif
#ifdef ENOSTR
        RT_CASE_RET_STR(ENOSTR);
#endif
#ifdef ENODATA
        RT_CASE_RET_STR(ENODATA);
#endif
#ifdef ETIME
        RT_CASE_RET_STR(ETIME);
#endif
#ifdef ENOSR
        RT_CASE_RET_STR(ENOSR);
#endif
#ifdef ENONET
        RT_CASE_RET_STR(ENONET);
#endif
#ifdef ENOPKG
        RT_CASE_RET_STR(ENOPKG);
#endif
#ifdef EREMOTE
        RT_CASE_RET_STR(EREMOTE);
#endif
#ifdef ENOLINK
        RT_CASE_RET_STR(ENOLINK);
#endif
#ifdef EADV
        RT_CASE_RET_STR(EADV);
#endif
#ifdef ESRMNT
        RT_CASE_RET_STR(ESRMNT);
#endif
#ifdef ECOMM
        RT_CASE_RET_STR(ECOMM);
#endif
#ifdef EPROTO
        RT_CASE_RET_STR(EPROTO);
#endif
#ifdef EMULTIHOP
        RT_CASE_RET_STR(EMULTIHOP);
#endif
#ifdef EDOTDOT
        RT_CASE_RET_STR(EDOTDOT);
#endif
#ifdef EBADMSG
        RT_CASE_RET_STR(EBADMSG);
#endif
#ifdef EOVERFLOW
        RT_CASE_RET_STR(EOVERFLOW); /** @todo fix duplicate error? */
#endif
#ifdef ENOTUNIQ
        RT_CASE_RET_STR(ENOTUNIQ);
#endif
#ifdef EBADFD
        RT_CASE_RET_STR(EBADFD); /** @todo fix duplicate error? */
#endif
#ifdef EREMCHG
        RT_CASE_RET_STR(EREMCHG);
#endif
#ifdef ELIBACC
        RT_CASE_RET_STR(ELIBACC);
#endif
#ifdef ELIBBAD
        RT_CASE_RET_STR(ELIBBAD);
#endif
#ifdef ELIBSCN
        RT_CASE_RET_STR(ELIBSCN);
#endif
#ifdef ELIBMAX
        RT_CASE_RET_STR(ELIBMAX);
#endif
#ifdef ELIBEXEC
        RT_CASE_RET_STR(ELIBEXEC);
#endif
#ifdef EILSEQ
        RT_CASE_RET_STR(EILSEQ);
#endif
#ifdef ERESTART
        RT_CASE_RET_STR(ERESTART);/** @todo fix duplicate error?*/
#endif
#ifdef ESTRPIPE
        RT_CASE_RET_STR(ESTRPIPE);
#endif
#ifdef EUSERS
        RT_CASE_RET_STR(EUSERS);
#endif
#ifdef ENOTSOCK
        RT_CASE_RET_STR(ENOTSOCK);
#endif
#ifdef EDESTADDRREQ
        RT_CASE_RET_STR(EDESTADDRREQ);
#endif
#ifdef EMSGSIZE
        RT_CASE_RET_STR(EMSGSIZE);
#endif
#ifdef EPROTOTYPE
        RT_CASE_RET_STR(EPROTOTYPE);
#endif
#ifdef ENOPROTOOPT
        RT_CASE_RET_STR(ENOPROTOOPT);
#endif
#ifdef EPROTONOSUPPORT
        RT_CASE_RET_STR(EPROTONOSUPPORT);
#endif
#ifdef ESOCKTNOSUPPORT
        RT_CASE_RET_STR(ESOCKTNOSUPPORT);
#endif
#ifdef EOPNOTSUPP /** @todo map this differently on solaris. */
        RT_CASE_RET_STR(EOPNOTSUPP);
#endif
#ifdef EPFNOSUPPORT
        RT_CASE_RET_STR(EPFNOSUPPORT);
#endif
#ifdef EAFNOSUPPORT
        RT_CASE_RET_STR(EAFNOSUPPORT);
#endif
#ifdef EADDRINUSE
        RT_CASE_RET_STR(EADDRINUSE);
#endif
#ifdef EADDRNOTAVAIL
        RT_CASE_RET_STR(EADDRNOTAVAIL);
#endif
#ifdef ENETDOWN
        RT_CASE_RET_STR(ENETDOWN);
#endif
#ifdef ENETUNREACH
        RT_CASE_RET_STR(ENETUNREACH);
#endif
#ifdef ENETRESET
        RT_CASE_RET_STR(ENETRESET);
#endif
#ifdef ECONNABORTED
        RT_CASE_RET_STR(ECONNABORTED);
#endif
#ifdef ECONNRESET
        RT_CASE_RET_STR(ECONNRESET);
#endif
#ifdef ENOBUFS
        RT_CASE_RET_STR(ENOBUFS);
#endif
#ifdef EISCONN
        RT_CASE_RET_STR(EISCONN);
#endif
#ifdef ENOTCONN
        RT_CASE_RET_STR(ENOTCONN);
#endif
#ifdef ESHUTDOWN
        RT_CASE_RET_STR(ESHUTDOWN);
#endif
#ifdef ETOOMANYREFS
        RT_CASE_RET_STR(ETOOMANYREFS);
#endif
#ifdef ETIMEDOUT
        RT_CASE_RET_STR(ETIMEDOUT);
#endif
#ifdef ECONNREFUSED
        RT_CASE_RET_STR(ECONNREFUSED);
#endif
#ifdef EHOSTDOWN
        RT_CASE_RET_STR(EHOSTDOWN);
#endif
#ifdef EHOSTUNREACH
        RT_CASE_RET_STR(EHOSTUNREACH);
#endif
#ifdef EALREADY
# if !defined(ENOLCK) || (EALREADY != ENOLCK)
        RT_CASE_RET_STR(EALREADY);
# endif
#endif
#ifdef EINPROGRESS
# if !defined(ENODEV) || (EINPROGRESS != ENODEV)
        RT_CASE_RET_STR(EINPROGRESS);
# endif
#endif
#ifdef ESTALE
        RT_CASE_RET_STR(ESTALE); /* 116: Stale NFS file handle */
#endif
#ifdef EUCLEAN
        RT_CASE_RET_STR(EUCLEAN);
#endif
#ifdef ENOTNAM
        RT_CASE_RET_STR(ENOTNAM);
#endif
#ifdef ENAVAIL
        RT_CASE_RET_STR(ENAVAIL);
#endif
#ifdef EISNAM
        RT_CASE_RET_STR(EISNAM);
#endif
#ifdef EREMOTEIO
        RT_CASE_RET_STR(EREMOTEIO);
#endif
#ifdef EDQUOT
        RT_CASE_RET_STR(EDQUOT); /** @todo fix duplicate error */
#endif
#ifdef ENOMEDIUM
        RT_CASE_RET_STR(ENOMEDIUM);
#endif
#ifdef EMEDIUMTYPE
        RT_CASE_RET_STR(EMEDIUMTYPE);
#endif
#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
        RT_CASE_RET_STR(EWOULDBLOCK);
#endif

        /* Non-linux */

#ifdef EPROCLIM
        RT_CASE_RET_STR(EPROCLIM);
#endif
#ifdef EDOOFUS
# if EDOOFUS != EINVAL
        RT_CASE_RET_STR(EDOOFUS);
# endif
#endif
#ifdef ENOTSUP
# ifndef EOPNOTSUPP
        RT_CASE_RET_STR(ENOTSUP);
# else
#  if ENOTSUP != EOPNOTSUPP
        RT_CASE_RET_STR(ENOTSUP);
#  endif
# endif
#endif
        default:
            AssertLogRelMsgFailedReturn(("Unhandled error code %d\n", iErrNo), "unknown-errno-value");
    }
}
RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strerror);