OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [string/] [strerror.c] - Blame information for rev 57

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/***
2
**** CAUTION!!! KEEP DOC CONSISTENT---if you change text of a message
3
****            here, change two places:
4
****            1) the leading doc section (alphabetized by macro)
5
****            2) the real text inside switch(errnum)
6
***/
7
 
8
/*
9
FUNCTION
10
        <<strerror>>---convert error number to string
11
 
12
INDEX
13
        strerror
14
 
15
ANSI_SYNOPSIS
16
        #include <string.h>
17
        char *strerror(int <[errnum]>);
18
 
19
TRAD_SYNOPSIS
20
        #include <string.h>
21
        char *strerror(<[errnum]>)
22
        int <[errnum]>;
23
 
24
DESCRIPTION
25
<<strerror>> converts the error number <[errnum]> into a
26
string.  The value of <[errnum]> is usually a copy of <<errno>>.
27
If <<errnum>> is not a known error number, the result points to an
28
empty string.
29
 
30
This implementation of <<strerror>> prints out the following strings
31
for each of the values defined in `<<errno.h>>':
32
 
33
o+
34
o E2BIG
35
Arg list too long
36
 
37
o EACCES
38
Permission denied
39
 
40
o EADV
41
Advertise error
42
 
43
o EAGAIN
44
No more processes
45
 
46
o EBADF
47
Bad file number
48
 
49
o EBADMSG
50
Bad message
51
 
52
o EBUSY
53
Device or resource busy
54
 
55
o ECHILD
56
No children
57
 
58
o ECOMM
59
Communication error
60
 
61
o EDEADLK
62
Deadlock
63
 
64
o EEXIST
65
File exists
66
 
67
o EDOM
68
Math argument
69
 
70
o EFAULT
71
Bad address
72
 
73
o EFBIG
74
File too large
75
 
76
o EIDRM
77
Identifier removed
78
 
79
o EINTR
80
Interrupted system call
81
 
82
o EINVAL
83
Invalid argument
84
 
85
o EIO
86
I/O error
87
 
88
o EISDIR
89
Is a directory
90
 
91
o ELIBACC
92
Cannot access a needed shared library
93
 
94
o ELIBBAD
95
Accessing a corrupted shared library
96
 
97
o ELIBEXEC
98
Cannot exec a shared library directly
99
 
100
o ELIBMAX
101
Attempting to link in more shared libraries than system limit
102
 
103
o ELIBSCN
104
<<.lib>> section in a.out corrupted
105
 
106
o EMFILE
107
Too many open files
108
 
109
o EMLINK
110
Too many links
111
 
112
o EMULTIHOP
113
Multihop attempted
114
 
115
o ENAMETOOLONG
116
File or path name too long
117
 
118
o ENFILE
119
Too many open files in system
120
 
121
o ENODEV
122
No such device
123
 
124
o ENOENT
125
No such file or directory
126
 
127
o ENOEXEC
128
Exec format error
129
 
130
o ENOLCK
131
No lock
132
 
133
o ENOLINK
134
Virtual circuit is gone
135
 
136
o ENOMEM
137
Not enough space
138
 
139
o ENOMSG
140
No message of desired type
141
 
142
o ENONET
143
Machine is not on the network
144
 
145
o ENOPKG
146
No package
147
 
148
o ENOSPC
149
No space left on device
150
 
151
o ENOSR
152
No stream resources
153
 
154
o ENOSTR
155
Not a stream
156
 
157
o ENOSYS
158
Function not implemented
159
 
160
o ENOTBLK
161
Block device required
162
 
163
o ENOTDIR
164
Not a directory
165
 
166
o ENOTEMPTY
167
Directory not empty
168
 
169
o ENOTTY
170
Not a character device
171
 
172
o ENXIO
173
No such device or address
174
 
175
o EPERM
176
Not owner
177
 
178
o EPIPE
179
Broken pipe
180
 
181
o EPROTO
182
Protocol error
183
 
184
o ERANGE
185
Result too large
186
 
187
o EREMOTE
188
Resource is remote
189
 
190
o EROFS
191
Read-only file system
192
 
193
o ESPIPE
194
Illegal seek
195
 
196
o ESRCH
197
No such process
198
 
199
o ESRMNT
200
Srmount error
201
 
202
o ETIME
203
Stream ioctl timeout
204
 
205
o ETXTBSY
206
Text file busy
207
 
208
o EXDEV
209
Cross-device link
210
 
211
o-
212
 
213
RETURNS
214
This function returns a pointer to a string.  Your application must
215
not modify that string.
216
 
217
PORTABILITY
218
ANSI C requires <<strerror>>, but does not specify the strings used
219
for each error number.
220
 
221
Although this implementation of <<strerror>> is reentrant, ANSI C
222
declares that subsequent calls to <<strerror>> may overwrite the
223
result string; therefore portable code cannot depend on the reentrancy
224
of this subroutine.
225
 
226
This implementation of <<strerror>> provides for user-defined
227
extensibility.  <<errno.h>> defines <[__ELASTERROR]>, which can be
228
used as a base for user-defined error values.  If the user supplies a
229
routine named <<_user_strerror>>, and <[errnum]> passed to
230
<<strerror>> does not match any of the supported values,
231
<<_user_strerror>> is called with <[errnum]> as its argument.
232
 
233
<<_user_strerror>> takes one argument of type <[int]>, and returns a
234
character pointer.  If <[errnum]> is unknown to <<_user_strerror>>,
235
<<_user_strerror>> returns <[NULL]>.  The default <<_user_strerror>>
236
returns <[NULL]> for all input values.
237
 
238
<<strerror>> requires no supporting OS subroutines.
239
 
240
QUICKREF
241
        strerror ansi pure
242
*/
243
 
244
#include <errno.h>
245
#include <string.h>
246
 
247
char *
248
_DEFUN (strerror, (errnum),
249
        int errnum)
250
{
251
  char *error;
252
  extern char *_user_strerror _PARAMS ((int));
253
 
254
  switch (errnum)
255
    {
256
/* go32 defines EPERM as EACCES */
257
#if defined (EPERM) && (!defined (EACCES) || (EPERM != EACCES))
258
    case EPERM:
259
      error = "Not owner";
260
      break;
261
#endif
262
#ifdef ENOENT
263
    case ENOENT:
264
      error = "No such file or directory";
265
      break;
266
#endif
267
#ifdef ESRCH
268
    case ESRCH:
269
      error = "No such process";
270
      break;
271
#endif
272
#ifdef EINTR
273
    case EINTR:
274
      error = "Interrupted system call";
275
      break;
276
#endif
277
#ifdef EIO
278
    case EIO:
279
      error = "I/O error";
280
      break;
281
#endif
282
/* go32 defines ENXIO as ENODEV */
283
#if defined (ENXIO) && (!defined (ENODEV) || (ENXIO != ENODEV))
284
    case ENXIO:
285
      error = "No such device or address";
286
      break;
287
#endif
288
#ifdef E2BIG
289
    case E2BIG:
290
      error = "Arg list too long";
291
      break;
292
#endif
293
#ifdef ENOEXEC
294
    case ENOEXEC:
295
      error = "Exec format error";
296
      break;
297
#endif
298
#ifdef EBADF
299
    case EBADF:
300
      error = "Bad file number";
301
      break;
302
#endif
303
#ifdef ECHILD
304
    case ECHILD:
305
      error = "No children";
306
      break;
307
#endif
308
#ifdef EAGAIN
309
    case EAGAIN:
310
      error = "No more processes";
311
      break;
312
#endif
313
#ifdef ENOMEM
314
    case ENOMEM:
315
      error = "Not enough space";
316
      break;
317
#endif
318
#ifdef EACCES
319
    case EACCES:
320
      error = "Permission denied";
321
      break;
322
#endif
323
#ifdef EFAULT
324
    case EFAULT:
325
      error = "Bad address";
326
      break;
327
#endif
328
#ifdef ENOTBLK
329
    case ENOTBLK:
330
      error = "Block device required";
331
      break;
332
#endif
333
#ifdef EBUSY
334
    case EBUSY:
335
      error = "Device or resource busy";
336
      break;
337
#endif
338
#ifdef EEXIST
339
    case EEXIST:
340
      error = "File exists";
341
      break;
342
#endif
343
#ifdef EXDEV
344
    case EXDEV:
345
      error = "Cross-device link";
346
      break;
347
#endif
348
#ifdef ENODEV
349
    case ENODEV:
350
      error = "No such device";
351
      break;
352
#endif
353
#ifdef ENOTDIR
354
    case ENOTDIR:
355
      error = "Not a directory";
356
      break;
357
#endif
358
#ifdef EISDIR
359
    case EISDIR:
360
      error = "Is a directory";
361
      break;
362
#endif
363
#ifdef EINVAL
364
    case EINVAL:
365
      error = "Invalid argument";
366
      break;
367
#endif
368
#ifdef ENFILE
369
    case ENFILE:
370
      error = "Too many open files in system";
371
      break;
372
#endif
373
#ifdef EMFILE
374
    case EMFILE:
375
      error = "Too many open files";
376
      break;
377
#endif
378
#ifdef ENOTTY
379
    case ENOTTY:
380
      error = "Not a character device";
381
      break;
382
#endif
383
#ifdef ETXTBSY
384
    case ETXTBSY:
385
      error = "Text file busy";
386
      break;
387
#endif
388
#ifdef EFBIG
389
    case EFBIG:
390
      error = "File too large";
391
      break;
392
#endif
393
#ifdef ENOSPC
394
    case ENOSPC:
395
      error = "No space left on device";
396
      break;
397
#endif
398
#ifdef ESPIPE
399
    case ESPIPE:
400
      error = "Illegal seek";
401
      break;
402
#endif
403
#ifdef EROFS
404
    case EROFS:
405
      error = "Read-only file system";
406
      break;
407
#endif
408
#ifdef EMLINK
409
    case EMLINK:
410
      error = "Too many links";
411
      break;
412
#endif
413
#ifdef EPIPE
414
    case EPIPE:
415
      error = "Broken pipe";
416
      break;
417
#endif
418
#ifdef EDOM
419
    case EDOM:
420
      error = "Math argument";
421
      break;
422
#endif
423
#ifdef ERANGE
424
    case ERANGE:
425
      error = "Result too large";
426
      break;
427
#endif
428
#ifdef ENOMSG
429
    case ENOMSG:
430
      error = "No message of desired type";
431
      break;
432
#endif
433
#ifdef EIDRM
434
    case EIDRM:
435
      error = "Identifier removed";
436
      break;
437
#endif
438
#ifdef EDEADLK
439
    case EDEADLK:
440
      error = "Deadlock";
441
      break;
442
#endif
443
#ifdef ENOLCK
444
    case ENOLCK:
445
      error = "No lock";
446
      break;
447
#endif
448
#ifdef ENOSTR
449
    case ENOSTR:
450
      error = "Not a stream";
451
      break;
452
#endif
453
#ifdef ETIME
454
    case ETIME:
455
      error = "Stream ioctl timeout";
456
      break;
457
#endif
458
#ifdef ENOSR
459
    case ENOSR:
460
      error = "No stream resources";
461
      break;
462
#endif
463
#ifdef ENONET
464
    case ENONET:
465
      error = "Machine is not on the network";
466
      break;
467
#endif
468
#ifdef ENOPKG
469
    case ENOPKG:
470
      error = "No package";
471
      break;
472
#endif
473
#ifdef EREMOTE
474
    case EREMOTE:
475
      error = "Resource is remote";
476
      break;
477
#endif
478
#ifdef ENOLINK
479
    case ENOLINK:
480
      error = "Virtual circuit is gone";
481
      break;
482
#endif
483
#ifdef EADV
484
    case EADV:
485
      error = "Advertise error";
486
      break;
487
#endif
488
#ifdef ESRMNT
489
    case ESRMNT:
490
      error = "Srmount error";
491
      break;
492
#endif
493
#ifdef ECOMM
494
    case ECOMM:
495
      error = "Communication error";
496
      break;
497
#endif
498
#ifdef EPROTO
499
    case EPROTO:
500
      error = "Protocol error";
501
      break;
502
#endif
503
#ifdef EMULTIHOP
504
    case EMULTIHOP:
505
      error = "Multihop attempted";
506
      break;
507
#endif
508
#ifdef EBADMSG
509
    case EBADMSG:
510
      error = "Bad message";
511
      break;
512
#endif
513
#ifdef ELIBACC
514
    case ELIBACC:
515
      error = "Cannot access a needed shared library";
516
      break;
517
#endif
518
#ifdef ELIBBAD
519
    case ELIBBAD:
520
      error = "Accessing a corrupted shared library";
521
      break;
522
#endif
523
#ifdef ELIBSCN
524
    case ELIBSCN:
525
      error = ".lib section in a.out corrupted";
526
      break;
527
#endif
528
#ifdef ELIBMAX
529
    case ELIBMAX:
530
      error = "Attempting to link in more shared libraries than system limit";
531
      break;
532
#endif
533
#ifdef ELIBEXEC
534
    case ELIBEXEC:
535
      error = "Cannot exec a shared library directly";
536
      break;
537
#endif
538
#ifdef ENOSYS
539
    case ENOSYS:
540
      error = "Function not implemented";
541
      break;
542
#endif
543
#ifdef ENMFILE
544
    case ENMFILE:
545
      error = "No more files";
546
      break;
547
#endif
548
#ifdef ENOTEMPTY
549
    case ENOTEMPTY:
550
      error = "Directory not empty";
551
      break;
552
#endif
553
#ifdef ENAMETOOLONG
554
    case ENAMETOOLONG:
555
      error = "File or path name too long";
556
      break;
557
#endif
558
#ifdef ELOOP
559
    case ELOOP:
560
      error = "Too many symbolic links";
561
      break;
562
#endif
563
#ifdef ENOBUFS
564
    case ENOBUFS:
565
      error = "No buffer space available";
566
      break;
567
#endif
568
#ifdef EAFNOSUPPORT
569
    case EAFNOSUPPORT:
570
      error = "Address family not supported by protocol family";
571
      break;
572
#endif
573
#ifdef EPROTOTYPE
574
    case EPROTOTYPE:
575
      error = "Protocol wrong type for socket";
576
      break;
577
#endif
578
#ifdef ENOTSOCK
579
    case ENOTSOCK:
580
      error = "Socket operation on non-socket";
581
      break;
582
#endif
583
#ifdef ENOPROTOOPT
584
    case ENOPROTOOPT:
585
      error = "Protocol not available";
586
      break;
587
#endif
588
#ifdef ESHUTDOWN
589
    case ESHUTDOWN:
590
      error = "Can't send after socket shutdown";
591
      break;
592
#endif
593
#ifdef ECONNREFUSED
594
    case ECONNREFUSED:
595
      error = "Connection refused";
596
      break;
597
#endif
598
#ifdef EADDRINUSE
599
    case EADDRINUSE:
600
      error = "Address already in use";
601
      break;
602
#endif
603
#ifdef ECONNABORTED
604
    case ECONNABORTED:
605
      error = "Software caused connection abort";
606
      break;
607
#endif
608 56 joel
#if (defined(EWOULDBLOCK) && (!defined (EAGAIN) || (EWOULDBLOCK != EAGAIN)))
609
    case EWOULDBLOCK:
610
        error = "Operation would block";
611
        break;
612
#endif
613
#ifdef ENOTCONN
614
    case ENOTCONN:
615
        error = "Socket is not connected";
616
        break;
617
#endif
618
#ifdef ESOCKTNOSUPPORT
619
    case ESOCKTNOSUPPORT:
620
        error = "Socket type not supported";
621
        break;
622
#endif
623
#ifdef EISCONN
624
    case EISCONN:
625
        error = "Socket is already connected";
626
        break;
627
#endif
628
#ifdef EOPNOTSUPP
629
    case EOPNOTSUPP:
630
        error = "Operation not supported on socket";
631
        break;
632
#endif
633
#ifdef EMSGSIZE
634
    case EMSGSIZE:
635
        error = "Message too long";
636
        break;
637
#endif
638
#ifdef ETIMEDOUT
639
    case ETIMEDOUT:
640
        error = "Connection timed out";
641
        break;
642
#endif
643 39 lampret
    default:
644
      if ((error = _user_strerror (errnum)) == 0)
645
        error = "";
646
      break;
647
    }
648
 
649
  return error;
650
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.