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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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