Subversion Repositories Kolibri OS

Rev

Rev 4874 | Details | Compare with Previous | Last modification | View Log | RSS feed

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