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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libc/] [string/] [strerror.c] - Blame information for rev 841

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

Line No. Rev Author Line
1 207 jeremybenn
/***
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 EADDRINUSE
41
Address already in use
42
 
43
o EADV
44
Advertise error
45
 
46
o EAFNOSUPPORT
47
Address family not supported by protocol family
48
 
49
o EAGAIN
50
No more processes
51
 
52
o EALREADY
53
Socket already connected
54
 
55
o EBADF
56
Bad file number
57
 
58
o EBADMSG
59
Bad message
60
 
61
o EBUSY
62
Device or resource busy
63
 
64
o ECHILD
65
No children
66
 
67
o ECOMM
68
Communication error
69
 
70
o ECONNABORTED
71
Software caused connection abort
72
 
73
o ECONNREFUSED
74
Connection refused
75
 
76
o EDEADLK
77
Deadlock
78
 
79
o EDESTADDRREQ
80
Destination address required
81
 
82
o EEXIST
83
File exists
84
 
85
o EDOM
86
Math argument
87
 
88
o EFAULT
89
Bad address
90
 
91
o EFBIG
92
File too large
93
 
94
o EHOSTDOWN
95
Host is down
96
 
97
o EHOSTUNREACH
98
Host is unreachable
99
 
100
o EIDRM
101
Identifier removed
102
 
103
o EINPROGRESS
104
Connection already in progress
105
 
106
o EINTR
107
Interrupted system call
108
 
109
o EINVAL
110
Invalid argument
111
 
112
o EIO
113
I/O error
114
 
115
o EISCONN
116
Socket is already connected
117
 
118
o EISDIR
119
Is a directory
120
 
121
o ELIBACC
122
Cannot access a needed shared library
123
 
124
o ELIBBAD
125
Accessing a corrupted shared library
126
 
127
o ELIBEXEC
128
Cannot exec a shared library directly
129
 
130
o ELIBMAX
131
Attempting to link in more shared libraries than system limit
132
 
133
o ELIBSCN
134
<<.lib>> section in a.out corrupted
135
 
136
o EMFILE
137
Too many open files
138
 
139
o EMLINK
140
Too many links
141
 
142
o EMSGSIZE
143
Message too long
144
 
145
o EMULTIHOP
146
Multihop attempted
147
 
148
o ENAMETOOLONG
149
File or path name too long
150
 
151
o ENETDOWN
152
Network interface not configured
153
 
154
o ENETUNREACH
155
Network is unreachable
156
 
157
o ENFILE
158
Too many open files in system
159
 
160
o ENODEV
161
No such device
162
 
163
o ENOENT
164
No such file or directory
165
 
166
o ENOEXEC
167
Exec format error
168
 
169
o ENOLCK
170
No lock
171
 
172
o ENOLINK
173
Virtual circuit is gone
174
 
175
o ENOMEM
176
Not enough space
177
 
178
o ENOMSG
179
No message of desired type
180
 
181
o ENONET
182
Machine is not on the network
183
 
184
o ENOPKG
185
No package
186
 
187
o ENOPROTOOPT
188
Protocol not available
189
 
190
o ENOSPC
191
No space left on device
192
 
193
o ENOSR
194
No stream resources
195
 
196
o ENOSTR
197
Not a stream
198
 
199
o ENOSYS
200
Function not implemented
201
 
202
o ENOTBLK
203
Block device required
204
 
205
o ENOTCONN
206
Socket is not connected
207
 
208
o ENOTDIR
209
Not a directory
210
 
211
o ENOTEMPTY
212
Directory not empty
213
 
214
o ENOTSOCK
215
Socket operation on non-socket
216
 
217
o ENOTSUP
218
Not supported
219
 
220
o ENOTTY
221
Not a character device
222
 
223
o ENXIO
224
No such device or address
225
 
226
o EPERM
227
Not owner
228
 
229
o EPIPE
230
Broken pipe
231
 
232
o EPROTO
233
Protocol error
234
 
235
o EPROTOTYPE
236
Protocol wrong type for socket
237
 
238
o EPROTONOSUPPORT
239
Unknown protocol
240
 
241
o ERANGE
242
Result too large
243
 
244
o EREMOTE
245
Resource is remote
246
 
247
o EROFS
248
Read-only file system
249
 
250
o ESHUTDOWN
251
Can't send after socket shutdown
252
 
253
o ESOCKTNOSUPPORT
254
Socket type not supported
255
 
256
o ESPIPE
257
Illegal seek
258
 
259
o ESRCH
260
No such process
261
 
262
o ESRMNT
263
Srmount error
264
 
265
o ETIME
266
Stream ioctl timeout
267
 
268
o ETIMEDOUT
269
Connection timed out
270
 
271
o ETXTBSY
272
Text file busy
273
 
274
o EXDEV
275
Cross-device link
276
 
277
o ECANCELED
278
Operation canceled
279
 
280
o ENOTRECOVERABLE
281
State not recoverable
282
 
283
o EOWNERDEAD
284
Previous owner died
285
 
286
o ESTRPIPE
287
Strings pipe error
288
 
289
o-
290
 
291
RETURNS
292
This function returns a pointer to a string.  Your application must
293
not modify that string.
294
 
295
PORTABILITY
296
ANSI C requires <<strerror>>, but does not specify the strings used
297
for each error number.
298
 
299
Although this implementation of <<strerror>> is reentrant, ANSI C
300
declares that subsequent calls to <<strerror>> may overwrite the
301
result string; therefore portable code cannot depend on the reentrancy
302
of this subroutine.
303
 
304
This implementation of <<strerror>> provides for user-defined
305
extensibility.  <<errno.h>> defines <[__ELASTERROR]>, which can be
306
used as a base for user-defined error values.  If the user supplies a
307
routine named <<_user_strerror>>, and <[errnum]> passed to
308
<<strerror>> does not match any of the supported values,
309
<<_user_strerror>> is called with <[errnum]> as its argument.
310
 
311
<<_user_strerror>> takes one argument of type <[int]>, and returns a
312
character pointer.  If <[errnum]> is unknown to <<_user_strerror>>,
313
<<_user_strerror>> returns <[NULL]>.  The default <<_user_strerror>>
314
returns <[NULL]> for all input values.
315
 
316
<<strerror>> requires no supporting OS subroutines.
317
 
318
QUICKREF
319
        strerror ansi pure
320
*/
321
 
322
#include <errno.h>
323
#include <string.h>
324
 
325
char *
326
_DEFUN (strerror, (errnum),
327
        int errnum)
328
{
329
  char *error;
330
  extern char *_user_strerror _PARAMS ((int));
331
 
332
  switch (errnum)
333
    {
334
/* go32 defines EPERM as EACCES */
335
#if defined (EPERM) && (!defined (EACCES) || (EPERM != EACCES))
336
    case EPERM:
337
      error = "Not owner";
338
      break;
339
#endif
340
#ifdef ENOENT
341
    case ENOENT:
342
      error = "No such file or directory";
343
      break;
344
#endif
345
#ifdef ESRCH
346
    case ESRCH:
347
      error = "No such process";
348
      break;
349
#endif
350
#ifdef EINTR
351
    case EINTR:
352
      error = "Interrupted system call";
353
      break;
354
#endif
355
#ifdef EIO
356
    case EIO:
357
      error = "I/O error";
358
      break;
359
#endif
360
/* go32 defines ENXIO as ENODEV */
361
#if defined (ENXIO) && (!defined (ENODEV) || (ENXIO != ENODEV))
362
    case ENXIO:
363
      error = "No such device or address";
364
      break;
365
#endif
366
#ifdef E2BIG
367
    case E2BIG:
368
      error = "Arg list too long";
369
      break;
370
#endif
371
#ifdef ENOEXEC
372
    case ENOEXEC:
373
      error = "Exec format error";
374
      break;
375
#endif
376
#ifdef EALREADY
377
    case EALREADY:
378
      error = "Socket already connected";
379
      break;
380
#endif
381
#ifdef EBADF
382
    case EBADF:
383
      error = "Bad file number";
384
      break;
385
#endif
386
#ifdef ECHILD
387
    case ECHILD:
388
      error = "No children";
389
      break;
390
#endif
391
#ifdef EDESTADDRREQ
392
    case EDESTADDRREQ:
393
      error = "Destination address required";
394
      break;
395
#endif
396
#ifdef EAGAIN
397
    case EAGAIN:
398
      error = "No more processes";
399
      break;
400
#endif
401
#ifdef ENOMEM
402
    case ENOMEM:
403
      error = "Not enough space";
404
      break;
405
#endif
406
#ifdef EACCES
407
    case EACCES:
408
      error = "Permission denied";
409
      break;
410
#endif
411
#ifdef EFAULT
412
    case EFAULT:
413
      error = "Bad address";
414
      break;
415
#endif
416
#ifdef ENOTBLK
417
    case ENOTBLK:
418
      error = "Block device required";
419
      break;
420
#endif
421
#ifdef EBUSY
422
    case EBUSY:
423
      error = "Device or resource busy";
424
      break;
425
#endif
426
#ifdef EEXIST
427
    case EEXIST:
428
      error = "File exists";
429
      break;
430
#endif
431
#ifdef EXDEV
432
    case EXDEV:
433
      error = "Cross-device link";
434
      break;
435
#endif
436
#ifdef ENODEV
437
    case ENODEV:
438
      error = "No such device";
439
      break;
440
#endif
441
#ifdef ENOTDIR
442
    case ENOTDIR:
443
      error = "Not a directory";
444
      break;
445
#endif
446
#ifdef EHOSTDOWN
447
    case EHOSTDOWN:
448
      error = "Host is down";
449
      break;
450
#endif
451
#ifdef EINPROGRESS
452
    case EINPROGRESS:
453
      error = "Connection already in progress";
454
      break;
455
#endif
456
#ifdef EISDIR
457
    case EISDIR:
458
      error = "Is a directory";
459
      break;
460
#endif
461
#ifdef EINVAL
462
    case EINVAL:
463
      error = "Invalid argument";
464
      break;
465
#endif
466
#ifdef ENETDOWN
467
    case ENETDOWN:
468
      error = "Network interface is not configured";
469
      break;
470
#endif
471
#ifdef ENFILE
472
    case ENFILE:
473
      error = "Too many open files in system";
474
      break;
475
#endif
476
#ifdef EMFILE
477
    case EMFILE:
478
      error = "Too many open files";
479
      break;
480
#endif
481
#ifdef ENOTTY
482
    case ENOTTY:
483
      error = "Not a character device";
484
      break;
485
#endif
486
#ifdef ETXTBSY
487
    case ETXTBSY:
488
      error = "Text file busy";
489
      break;
490
#endif
491
#ifdef EFBIG
492
    case EFBIG:
493
      error = "File too large";
494
      break;
495
#endif
496
#ifdef EHOSTUNREACH
497
    case EHOSTUNREACH:
498
      error = "Host is unreachable";
499
      break;
500
#endif
501
#ifdef ENOSPC
502
    case ENOSPC:
503
      error = "No space left on device";
504
      break;
505
#endif
506
#ifdef ENOTSUP
507
    case ENOTSUP:
508
      error = "Not supported";
509
      break;
510
#endif
511
#ifdef ESPIPE
512
    case ESPIPE:
513
      error = "Illegal seek";
514
      break;
515
#endif
516
#ifdef EROFS
517
    case EROFS:
518
      error = "Read-only file system";
519
      break;
520
#endif
521
#ifdef EMLINK
522
    case EMLINK:
523
      error = "Too many links";
524
      break;
525
#endif
526
#ifdef EPIPE
527
    case EPIPE:
528
      error = "Broken pipe";
529
      break;
530
#endif
531
#ifdef EDOM
532
    case EDOM:
533
      error = "Math argument";
534
      break;
535
#endif
536
#ifdef ERANGE
537
    case ERANGE:
538
      error = "Result too large";
539
      break;
540
#endif
541
#ifdef ENOMSG
542
    case ENOMSG:
543
      error = "No message of desired type";
544
      break;
545
#endif
546
#ifdef EIDRM
547
    case EIDRM:
548
      error = "Identifier removed";
549
      break;
550
#endif
551
#ifdef EDEADLK
552
    case EDEADLK:
553
      error = "Deadlock";
554
      break;
555
#endif
556
#ifdef ENETUNREACH
557
    case  ENETUNREACH:
558
      error = "Network is unreachable";
559
      break;
560
#endif
561
#ifdef ENOLCK
562
    case ENOLCK:
563
      error = "No lock";
564
      break;
565
#endif
566
#ifdef ENOSTR
567
    case ENOSTR:
568
      error = "Not a stream";
569
      break;
570
#endif
571
#ifdef ETIME
572
    case ETIME:
573
      error = "Stream ioctl timeout";
574
      break;
575
#endif
576
#ifdef ENOSR
577
    case ENOSR:
578
      error = "No stream resources";
579
      break;
580
#endif
581
#ifdef ENONET
582
    case ENONET:
583
      error = "Machine is not on the network";
584
      break;
585
#endif
586
#ifdef ENOPKG
587
    case ENOPKG:
588
      error = "No package";
589
      break;
590
#endif
591
#ifdef EREMOTE
592
    case EREMOTE:
593
      error = "Resource is remote";
594
      break;
595
#endif
596
#ifdef ENOLINK
597
    case ENOLINK:
598
      error = "Virtual circuit is gone";
599
      break;
600
#endif
601
#ifdef EADV
602
    case EADV:
603
      error = "Advertise error";
604
      break;
605
#endif
606
#ifdef ESRMNT
607
    case ESRMNT:
608
      error = "Srmount error";
609
      break;
610
#endif
611
#ifdef ECOMM
612
    case ECOMM:
613
      error = "Communication error";
614
      break;
615
#endif
616
#ifdef EPROTO
617
    case EPROTO:
618
      error = "Protocol error";
619
      break;
620
#endif
621
#ifdef EPROTONOSUPPORT
622
    case EPROTONOSUPPORT:
623
      error = "Unknown protocol";
624
      break;
625
#endif
626
#ifdef EMULTIHOP
627
    case EMULTIHOP:
628
      error = "Multihop attempted";
629
      break;
630
#endif
631
#ifdef EBADMSG
632
    case EBADMSG:
633
      error = "Bad message";
634
      break;
635
#endif
636
#ifdef ELIBACC
637
    case ELIBACC:
638
      error = "Cannot access a needed shared library";
639
      break;
640
#endif
641
#ifdef ELIBBAD
642
    case ELIBBAD:
643
      error = "Accessing a corrupted shared library";
644
      break;
645
#endif
646
#ifdef ELIBSCN
647
    case ELIBSCN:
648
      error = ".lib section in a.out corrupted";
649
      break;
650
#endif
651
#ifdef ELIBMAX
652
    case ELIBMAX:
653
      error = "Attempting to link in more shared libraries than system limit";
654
      break;
655
#endif
656
#ifdef ELIBEXEC
657
    case ELIBEXEC:
658
      error = "Cannot exec a shared library directly";
659
      break;
660
#endif
661
#ifdef ENOSYS
662
    case ENOSYS:
663
      error = "Function not implemented";
664
      break;
665
#endif
666
#ifdef ENMFILE
667
    case ENMFILE:
668
      error = "No more files";
669
      break;
670
#endif
671
#ifdef ENOTEMPTY
672
    case ENOTEMPTY:
673
      error = "Directory not empty";
674
      break;
675
#endif
676
#ifdef ENAMETOOLONG
677
    case ENAMETOOLONG:
678
      error = "File or path name too long";
679
      break;
680
#endif
681
#ifdef ELOOP
682
    case ELOOP:
683
      error = "Too many symbolic links";
684
      break;
685
#endif
686
#ifdef ENOBUFS
687
    case ENOBUFS:
688
      error = "No buffer space available";
689
      break;
690
#endif
691
#ifdef EAFNOSUPPORT
692
    case EAFNOSUPPORT:
693
      error = "Address family not supported by protocol family";
694
      break;
695
#endif
696
#ifdef EPROTOTYPE
697
    case EPROTOTYPE:
698
      error = "Protocol wrong type for socket";
699
      break;
700
#endif
701
#ifdef ENOTSOCK
702
    case ENOTSOCK:
703
      error = "Socket operation on non-socket";
704
      break;
705
#endif
706
#ifdef ENOPROTOOPT
707
    case ENOPROTOOPT:
708
      error = "Protocol not available";
709
      break;
710
#endif
711
#ifdef ESHUTDOWN
712
    case ESHUTDOWN:
713
      error = "Can't send after socket shutdown";
714
      break;
715
#endif
716
#ifdef ECONNREFUSED
717
    case ECONNREFUSED:
718
      error = "Connection refused";
719
      break;
720
#endif
721
#ifdef EADDRINUSE
722
    case EADDRINUSE:
723
      error = "Address already in use";
724
      break;
725
#endif
726
#ifdef ECONNABORTED
727
    case ECONNABORTED:
728
      error = "Software caused connection abort";
729
      break;
730
#endif
731
#if (defined(EWOULDBLOCK) && (!defined (EAGAIN) || (EWOULDBLOCK != EAGAIN)))
732
    case EWOULDBLOCK:
733
        error = "Operation would block";
734
        break;
735
#endif
736
#ifdef ENOTCONN
737
    case ENOTCONN:
738
        error = "Socket is not connected";
739
        break;
740
#endif
741
#ifdef ESOCKTNOSUPPORT
742
    case ESOCKTNOSUPPORT:
743
        error = "Socket type not supported";
744
        break;
745
#endif
746
#ifdef EISCONN
747
    case EISCONN:
748
        error = "Socket is already connected";
749
        break;
750
#endif
751
#ifdef ECANCELED
752
    case ECANCELED:
753
        error = "Operation canceled";
754
        break;
755
#endif
756
#ifdef ENOTRECOVERABLE
757
    case ENOTRECOVERABLE:
758
        error = "State not recoverable";
759
        break;
760
#endif
761
#ifdef EOWNERDEAD
762
    case EOWNERDEAD:
763
        error = "Previous owner died";
764
        break;
765
#endif
766
#ifdef ESTRPIPE
767
    case ESTRPIPE:
768
        error = "Streams pipe error";
769
        break;
770
#endif
771
#if defined(EOPNOTSUPP) && (!defined(ENOTSUP) || (ENOTSUP != EOPNOTSUPP))
772
    case EOPNOTSUPP:
773
        error = "Operation not supported on socket";
774
        break;
775
#endif
776
#ifdef EMSGSIZE
777
    case EMSGSIZE:
778
        error = "Message too long";
779
        break;
780
#endif
781
#ifdef ETIMEDOUT
782
    case ETIMEDOUT:
783
        error = "Connection timed out";
784
        break;
785
#endif
786
    default:
787
      if ((error = _user_strerror (errnum)) == 0)
788
        error = "";
789
      break;
790
    }
791
 
792
  return error;
793
}

powered by: WebSVN 2.1.0

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