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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [string/] [strerror.c] - Blame information for rev 171

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

Line No. Rev Author Line
1 148 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-
287
 
288
RETURNS
289
This function returns a pointer to a string.  Your application must
290
not modify that string.
291
 
292
PORTABILITY
293
ANSI C requires <<strerror>>, but does not specify the strings used
294
for each error number.
295
 
296
Although this implementation of <<strerror>> is reentrant, ANSI C
297
declares that subsequent calls to <<strerror>> may overwrite the
298
result string; therefore portable code cannot depend on the reentrancy
299
of this subroutine.
300
 
301
This implementation of <<strerror>> provides for user-defined
302
extensibility.  <<errno.h>> defines <[__ELASTERROR]>, which can be
303
used as a base for user-defined error values.  If the user supplies a
304
routine named <<_user_strerror>>, and <[errnum]> passed to
305
<<strerror>> does not match any of the supported values,
306
<<_user_strerror>> is called with <[errnum]> as its argument.
307
 
308
<<_user_strerror>> takes one argument of type <[int]>, and returns a
309
character pointer.  If <[errnum]> is unknown to <<_user_strerror>>,
310
<<_user_strerror>> returns <[NULL]>.  The default <<_user_strerror>>
311
returns <[NULL]> for all input values.
312
 
313
<<strerror>> requires no supporting OS subroutines.
314
 
315
QUICKREF
316
        strerror ansi pure
317
*/
318
 
319
#include <errno.h>
320
#include <string.h>
321
 
322
char *
323
_DEFUN (strerror, (errnum),
324
        int errnum)
325
{
326
  char *error;
327
  extern char *_user_strerror _PARAMS ((int));
328
 
329
  switch (errnum)
330
    {
331
/* go32 defines EPERM as EACCES */
332
#if defined (EPERM) && (!defined (EACCES) || (EPERM != EACCES))
333
    case EPERM:
334
      error = "Not owner";
335
      break;
336
#endif
337
#ifdef ENOENT
338
    case ENOENT:
339
      error = "No such file or directory";
340
      break;
341
#endif
342
#ifdef ESRCH
343
    case ESRCH:
344
      error = "No such process";
345
      break;
346
#endif
347
#ifdef EINTR
348
    case EINTR:
349
      error = "Interrupted system call";
350
      break;
351
#endif
352
#ifdef EIO
353
    case EIO:
354
      error = "I/O error";
355
      break;
356
#endif
357
/* go32 defines ENXIO as ENODEV */
358
#if defined (ENXIO) && (!defined (ENODEV) || (ENXIO != ENODEV))
359
    case ENXIO:
360
      error = "No such device or address";
361
      break;
362
#endif
363
#ifdef E2BIG
364
    case E2BIG:
365
      error = "Arg list too long";
366
      break;
367
#endif
368
#ifdef ENOEXEC
369
    case ENOEXEC:
370
      error = "Exec format error";
371
      break;
372
#endif
373
#ifdef EALREADY
374
    case EALREADY:
375
      error = "Socket already connected";
376
      break;
377
#endif
378
#ifdef EBADF
379
    case EBADF:
380
      error = "Bad file number";
381
      break;
382
#endif
383
#ifdef ECHILD
384
    case ECHILD:
385
      error = "No children";
386
      break;
387
#endif
388
#ifdef EDESTADDRREQ
389
    case EDESTADDRREQ:
390
      error = "Destination address required";
391
      break;
392
#endif
393
#ifdef EAGAIN
394
    case EAGAIN:
395
      error = "No more processes";
396
      break;
397
#endif
398
#ifdef ENOMEM
399
    case ENOMEM:
400
      error = "Not enough space";
401
      break;
402
#endif
403
#ifdef EACCES
404
    case EACCES:
405
      error = "Permission denied";
406
      break;
407
#endif
408
#ifdef EFAULT
409
    case EFAULT:
410
      error = "Bad address";
411
      break;
412
#endif
413
#ifdef ENOTBLK
414
    case ENOTBLK:
415
      error = "Block device required";
416
      break;
417
#endif
418
#ifdef EBUSY
419
    case EBUSY:
420
      error = "Device or resource busy";
421
      break;
422
#endif
423
#ifdef EEXIST
424
    case EEXIST:
425
      error = "File exists";
426
      break;
427
#endif
428
#ifdef EXDEV
429
    case EXDEV:
430
      error = "Cross-device link";
431
      break;
432
#endif
433
#ifdef ENODEV
434
    case ENODEV:
435
      error = "No such device";
436
      break;
437
#endif
438
#ifdef ENOTDIR
439
    case ENOTDIR:
440
      error = "Not a directory";
441
      break;
442
#endif
443
#ifdef EHOSTDOWN
444
    case EHOSTDOWN:
445
      error = "Host is down";
446
      break;
447
#endif
448
#ifdef EINPROGRESS
449
    case EINPROGRESS:
450
      error = "Connection already in progress";
451
      break;
452
#endif
453
#ifdef EISDIR
454
    case EISDIR:
455
      error = "Is a directory";
456
      break;
457
#endif
458
#ifdef EINVAL
459
    case EINVAL:
460
      error = "Invalid argument";
461
      break;
462
#endif
463
#ifdef ENETDOWN
464
    case ENETDOWN:
465
      error = "Network interface is not configured";
466
      break;
467
#endif
468
#ifdef ENFILE
469
    case ENFILE:
470
      error = "Too many open files in system";
471
      break;
472
#endif
473
#ifdef EMFILE
474
    case EMFILE:
475
      error = "Too many open files";
476
      break;
477
#endif
478
#ifdef ENOTTY
479
    case ENOTTY:
480
      error = "Not a character device";
481
      break;
482
#endif
483
#ifdef ETXTBSY
484
    case ETXTBSY:
485
      error = "Text file busy";
486
      break;
487
#endif
488
#ifdef EFBIG
489
    case EFBIG:
490
      error = "File too large";
491
      break;
492
#endif
493
#ifdef EHOSTUNREACH
494
    case EHOSTUNREACH:
495
      error = "Host is unreachable";
496
      break;
497
#endif
498
#ifdef ENOSPC
499
    case ENOSPC:
500
      error = "No space left on device";
501
      break;
502
#endif
503
#ifdef ENOTSUP
504
    case ENOTSUP:
505
      error = "Not supported";
506
      break;
507
#endif
508
#ifdef ESPIPE
509
    case ESPIPE:
510
      error = "Illegal seek";
511
      break;
512
#endif
513
#ifdef EROFS
514
    case EROFS:
515
      error = "Read-only file system";
516
      break;
517
#endif
518
#ifdef EMLINK
519
    case EMLINK:
520
      error = "Too many links";
521
      break;
522
#endif
523
#ifdef EPIPE
524
    case EPIPE:
525
      error = "Broken pipe";
526
      break;
527
#endif
528
#ifdef EDOM
529
    case EDOM:
530
      error = "Math argument";
531
      break;
532
#endif
533
#ifdef ERANGE
534
    case ERANGE:
535
      error = "Result too large";
536
      break;
537
#endif
538
#ifdef ENOMSG
539
    case ENOMSG:
540
      error = "No message of desired type";
541
      break;
542
#endif
543
#ifdef EIDRM
544
    case EIDRM:
545
      error = "Identifier removed";
546
      break;
547
#endif
548
#ifdef EDEADLK
549
    case EDEADLK:
550
      error = "Deadlock";
551
      break;
552
#endif
553
#ifdef ENETUNREACH
554
    case  ENETUNREACH:
555
      error = "Network is unreachable";
556
      break;
557
#endif
558
#ifdef ENOLCK
559
    case ENOLCK:
560
      error = "No lock";
561
      break;
562
#endif
563
#ifdef ENOSTR
564
    case ENOSTR:
565
      error = "Not a stream";
566
      break;
567
#endif
568
#ifdef ETIME
569
    case ETIME:
570
      error = "Stream ioctl timeout";
571
      break;
572
#endif
573
#ifdef ENOSR
574
    case ENOSR:
575
      error = "No stream resources";
576
      break;
577
#endif
578
#ifdef ENONET
579
    case ENONET:
580
      error = "Machine is not on the network";
581
      break;
582
#endif
583
#ifdef ENOPKG
584
    case ENOPKG:
585
      error = "No package";
586
      break;
587
#endif
588
#ifdef EREMOTE
589
    case EREMOTE:
590
      error = "Resource is remote";
591
      break;
592
#endif
593
#ifdef ENOLINK
594
    case ENOLINK:
595
      error = "Virtual circuit is gone";
596
      break;
597
#endif
598
#ifdef EADV
599
    case EADV:
600
      error = "Advertise error";
601
      break;
602
#endif
603
#ifdef ESRMNT
604
    case ESRMNT:
605
      error = "Srmount error";
606
      break;
607
#endif
608
#ifdef ECOMM
609
    case ECOMM:
610
      error = "Communication error";
611
      break;
612
#endif
613
#ifdef EPROTO
614
    case EPROTO:
615
      error = "Protocol error";
616
      break;
617
#endif
618
#ifdef EPROTONOSUPPORT
619
    case EPROTONOSUPPORT:
620
      error = "Unknown protocol";
621
      break;
622
#endif
623
#ifdef EMULTIHOP
624
    case EMULTIHOP:
625
      error = "Multihop attempted";
626
      break;
627
#endif
628
#ifdef EBADMSG
629
    case EBADMSG:
630
      error = "Bad message";
631
      break;
632
#endif
633
#ifdef ELIBACC
634
    case ELIBACC:
635
      error = "Cannot access a needed shared library";
636
      break;
637
#endif
638
#ifdef ELIBBAD
639
    case ELIBBAD:
640
      error = "Accessing a corrupted shared library";
641
      break;
642
#endif
643
#ifdef ELIBSCN
644
    case ELIBSCN:
645
      error = ".lib section in a.out corrupted";
646
      break;
647
#endif
648
#ifdef ELIBMAX
649
    case ELIBMAX:
650
      error = "Attempting to link in more shared libraries than system limit";
651
      break;
652
#endif
653
#ifdef ELIBEXEC
654
    case ELIBEXEC:
655
      error = "Cannot exec a shared library directly";
656
      break;
657
#endif
658
#ifdef ENOSYS
659
    case ENOSYS:
660
      error = "Function not implemented";
661
      break;
662
#endif
663
#ifdef ENMFILE
664
    case ENMFILE:
665
      error = "No more files";
666
      break;
667
#endif
668
#ifdef ENOTEMPTY
669
    case ENOTEMPTY:
670
      error = "Directory not empty";
671
      break;
672
#endif
673
#ifdef ENAMETOOLONG
674
    case ENAMETOOLONG:
675
      error = "File or path name too long";
676
      break;
677
#endif
678
#ifdef ELOOP
679
    case ELOOP:
680
      error = "Too many symbolic links";
681
      break;
682
#endif
683
#ifdef ENOBUFS
684
    case ENOBUFS:
685
      error = "No buffer space available";
686
      break;
687
#endif
688
#ifdef EAFNOSUPPORT
689
    case EAFNOSUPPORT:
690
      error = "Address family not supported by protocol family";
691
      break;
692
#endif
693
#ifdef EPROTOTYPE
694
    case EPROTOTYPE:
695
      error = "Protocol wrong type for socket";
696
      break;
697
#endif
698
#ifdef ENOTSOCK
699
    case ENOTSOCK:
700
      error = "Socket operation on non-socket";
701
      break;
702
#endif
703
#ifdef ENOPROTOOPT
704
    case ENOPROTOOPT:
705
      error = "Protocol not available";
706
      break;
707
#endif
708
#ifdef ESHUTDOWN
709
    case ESHUTDOWN:
710
      error = "Can't send after socket shutdown";
711
      break;
712
#endif
713
#ifdef ECONNREFUSED
714
    case ECONNREFUSED:
715
      error = "Connection refused";
716
      break;
717
#endif
718
#ifdef EADDRINUSE
719
    case EADDRINUSE:
720
      error = "Address already in use";
721
      break;
722
#endif
723
#ifdef ECONNABORTED
724
    case ECONNABORTED:
725
      error = "Software caused connection abort";
726
      break;
727
#endif
728
#if (defined(EWOULDBLOCK) && (!defined (EAGAIN) || (EWOULDBLOCK != EAGAIN)))
729
    case EWOULDBLOCK:
730
        error = "Operation would block";
731
        break;
732
#endif
733
#ifdef ENOTCONN
734
    case ENOTCONN:
735
        error = "Socket is not connected";
736
        break;
737
#endif
738
#ifdef ESOCKTNOSUPPORT
739
    case ESOCKTNOSUPPORT:
740
        error = "Socket type not supported";
741
        break;
742
#endif
743
#ifdef EISCONN
744
    case EISCONN:
745
        error = "Socket is already connected";
746
        break;
747
#endif
748
#ifdef ECANCELED
749
    case ECANCELED:
750
        error = "Operation canceled";
751
        break;
752
#endif
753
#ifdef ENOTRECOVERABLE
754
    case ENOTRECOVERABLE:
755
        error = "State not recoverable";
756
        break;
757
#endif
758
#ifdef EOWNERDEAD
759
    case EOWNERDEAD:
760
        error = "Previous owner died";
761
        break;
762
#endif
763
#if defined(EOPNOTSUPP) && (!defined(ENOTSUP) || (ENOTSUP != EOPNOTSUPP))
764
    case EOPNOTSUPP:
765
        error = "Operation not supported on socket";
766
        break;
767
#endif
768
#ifdef EMSGSIZE
769
    case EMSGSIZE:
770
        error = "Message too long";
771
        break;
772
#endif
773
#ifdef ETIMEDOUT
774
    case ETIMEDOUT:
775
        error = "Connection timed out";
776
        break;
777
#endif
778
    default:
779
      if ((error = _user_strerror (errnum)) == 0)
780
        error = "";
781
      break;
782
    }
783
 
784
  return error;
785
}

powered by: WebSVN 2.1.0

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