|
0
|
1 //=========================================================================== |
|
|
2 // |
|
|
3 // strerror.cxx |
|
|
4 // |
|
|
5 // ANSI error code string routine |
|
|
6 // |
|
|
7 //=========================================================================== |
|
|
8 //####COPYRIGHTBEGIN#### |
|
|
9 // |
|
|
10 // ------------------------------------------- |
|
|
11 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
12 // Version 1.0 (the "License"); you may not use this file except in |
|
|
13 // compliance with the License. You may obtain a copy of the License at |
|
|
14 // http://sourceware.cygnus.com/ecos |
|
|
15 // |
|
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
18 // License for the specific language governing rights and limitations under |
|
|
19 // the License. |
|
|
20 // |
|
|
21 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
22 // September 30, 1998. |
|
|
23 // |
|
|
24 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. |
|
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //=========================================================================== |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
|
32 // Author(s): jlarmour@cygnus.co.uk |
|
|
33 // Contributors: jlarmour@cygnus.co.uk |
|
|
34 // Date: 1998-06-11 |
|
|
35 // Purpose: To provide the strerror() implementation |
|
|
36 // Description: This implements strerror() as described in ANSI chap 7.11.6.2 |
|
|
37 // Usage: See <cyg/error/codes.h> |
|
|
38 // |
|
|
39 //####DESCRIPTIONEND#### |
|
|
40 // |
|
|
41 //=========================================================================== |
|
|
42 |
|
|
43 |
|
|
44 // CONFIGURATION |
|
|
45 |
|
|
46 #include <pkgconf/error.h> // Configuration header |
|
|
47 |
|
|
48 // Include the C library? |
|
|
49 #ifdef CYGPKG_ERROR |
|
|
50 |
|
|
51 // INCLUDES |
|
|
52 |
|
|
53 #include <cyg/infra/cyg_type.h> // Common project-wide type definitions |
|
|
54 #include <cyg/infra/cyg_trac.h> // Tracing support |
|
|
55 #include <cyg/error/codes.h> // Error code definitions and header for this |
|
|
56 // file |
|
|
57 |
|
|
58 // EXPORTED SYMBOLS |
|
|
59 |
|
|
60 externC char * |
|
|
61 strerror( int errnum ) __attribute__ ((weak, alias("_strerror") )); |
|
|
62 |
|
|
63 // FUNCTIONS |
|
|
64 |
|
|
65 externC char * |
|
|
66 _strerror( int errnum ) |
|
|
67 { |
|
|
68 register char *s; |
|
|
69 |
|
|
70 CYG_REPORT_FUNCNAMETYPE( "_strerror", "String form of error is \"%s\"" ); |
|
|
71 |
|
|
72 switch (errnum) |
|
|
73 { |
|
|
74 |
|
|
75 #ifdef ENOERR |
|
|
76 case ENOERR: |
|
|
77 s = "No error"; |
|
|
78 break; |
|
|
79 #endif |
|
|
80 |
|
|
81 #ifdef EPERM |
|
|
82 case EPERM: |
|
|
83 s = "Not permitted"; |
|
|
84 break; |
|
|
85 #endif |
|
|
86 |
|
|
87 #ifdef ENOENT |
|
|
88 case ENOENT: |
|
|
89 s = "No such entity"; |
|
|
90 break; |
|
|
91 #endif |
|
|
92 |
|
|
93 #ifdef ESRCH |
|
|
94 case ESRCH: |
|
|
95 s = "No such process"; |
|
|
96 break; |
|
|
97 #endif |
|
|
98 |
|
|
99 #ifdef EINTR |
|
|
100 case EINTR: |
|
|
101 s = "Operation interrupted"; |
|
|
102 break; |
|
|
103 #endif |
|
|
104 |
|
|
105 #ifdef EIO |
|
|
106 case EIO: |
|
|
107 s = "I/O error"; |
|
|
108 break; |
|
|
109 #endif |
|
|
110 |
|
|
111 #ifdef EBADF |
|
|
112 case EBADF: |
|
|
113 s = "Bad file handle"; |
|
|
114 break; |
|
|
115 #endif |
|
|
116 |
|
|
117 #ifdef EAGAIN |
|
|
118 case EAGAIN: |
|
|
119 s = "Try again later"; |
|
|
120 break; |
|
|
121 #endif |
|
|
122 |
|
|
123 #ifdef ENOMEM |
|
|
124 case ENOMEM: |
|
|
125 s = "Out of memory"; |
|
|
126 break; |
|
|
127 #endif |
|
|
128 |
|
|
129 #ifdef EBUSY |
|
|
130 case EBUSY: |
|
|
131 s = "Resource busy"; |
|
|
132 break; |
|
|
133 #endif |
|
|
134 |
|
|
135 #ifdef ENODEV |
|
|
136 case ENODEV: |
|
|
137 s = "No such device"; |
|
|
138 break; |
|
|
139 #endif |
|
|
140 |
|
|
141 #ifdef EINVAL |
|
|
142 case EINVAL: |
|
|
143 s = "Invalid argument"; |
|
|
144 break; |
|
|
145 #endif |
|
|
146 |
|
|
147 #ifdef EMFILE |
|
|
148 case EMFILE: |
|
|
149 s = "Too many open files"; |
|
|
150 break; |
|
|
151 #endif |
|
|
152 |
|
|
153 #ifdef EDOM |
|
|
154 case EDOM: |
|
|
155 s = "Argument to math function outside valid domain"; |
|
|
156 break; |
|
|
157 #endif |
|
|
158 |
|
|
159 #ifdef ERANGE |
|
|
160 case ERANGE: |
|
|
161 s = "Math result cannot be represented"; |
|
|
162 break; |
|
|
163 #endif |
|
|
164 |
|
|
165 #ifdef ENOSYS |
|
|
166 case ENOSYS: |
|
|
167 s = "Function not implemented"; |
|
|
168 break; |
|
|
169 #endif |
|
|
170 |
|
|
171 #ifdef EEOF |
|
|
172 case EEOF: |
|
|
173 s = "End of file reached"; |
|
|
174 break; |
|
|
175 #endif |
|
|
176 |
|
|
177 #ifdef ENOSUPP |
|
|
178 case ENOSUPP: |
|
|
179 s = "Operation not supported"; |
|
|
180 break; |
|
|
181 #endif |
|
|
182 |
|
|
183 #ifdef EDEVNOSUPP |
|
|
184 case EDEVNOSUPP: |
|
|
185 s = "Device does not support this operation"; |
|
|
186 break; |
|
|
187 #endif |
|
|
188 |
|
|
189 default: |
|
|
190 s = "Unknown error"; |
|
|
191 break; |
|
|
192 |
|
|
193 } // switch |
|
|
194 |
|
|
195 CYG_REPORT_RETVAL(s); |
|
|
196 |
|
|
197 return s; |
|
|
198 } // _strerror() |
|
|
199 |
|
|
200 #endif // ifdef CYGPKG_ERROR |
|
|
201 |
|
|
202 // EOF strerror.cxx |