]> pd.if.org Git - pdclib/blob - functions/_PDCLIB/errno.c
0c959b7282bbbcc8d41c2da2d43bd96718eb1ac3
[pdclib] / functions / _PDCLIB / errno.c
1 /* $Id$ */
2
3 /* _PDCLIB_errno
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #define _PDCLIB_INT_H _PDCLIB_INT_H
10 #include <_PDCLIB_int.h>
11
12 #ifndef REGTEST
13
14 int _PDCLIB_errno = 0;
15
16 int * _PDCLIB_errno_func()
17 {
18     return &_PDCLIB_errno;
19 }
20
21 /* TODO: Doing this via a static array is not the way to do it. */
22 char const * _PDCLIB_errno_texts[] = {
23     "",
24     "ERANGE (Range error)",
25     "EDOM (Domain error)",
26     "EIO (I/O error)",
27     "EUNKNOWN (Unknown error)",
28     "EINVAL (Invalid parameter value)",
29     "ERETRY (I/O retries exceeded)"
30 };
31
32 #endif
33
34 #ifdef TEST
35 #include <_PDCLIB_test.h>
36
37 #include <errno.h>
38
39 int main()
40 {
41     errno = 0;
42     TESTCASE( errno == 0 );
43     errno = EDOM;
44     TESTCASE( errno == EDOM );
45     errno = ERANGE;
46     TESTCASE( errno == ERANGE );
47     return TEST_RESULTS;
48 }
49
50 #endif
51