sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* *** CAUTION!!! KEEP DOC CONSISTENT---if you change text of a message
|
sl@0
|
16 |
* *** here, change two places:
|
sl@0
|
17 |
* *** 1) the leading doc section (alphabetized by macro)
|
sl@0
|
18 |
* *** 2) the real text inside switch(errnum)
|
sl@0
|
19 |
* FUNCTION
|
sl@0
|
20 |
* <<strerror>>---convert error number to string
|
sl@0
|
21 |
* INDEX
|
sl@0
|
22 |
* strerror
|
sl@0
|
23 |
* ANSI_SYNOPSIS
|
sl@0
|
24 |
* #include <string.h>
|
sl@0
|
25 |
* char *strerror(int <[errnum]>);
|
sl@0
|
26 |
* TRAD_SYNOPSIS
|
sl@0
|
27 |
* #include <string.h>
|
sl@0
|
28 |
* char *strerror(<[errnum]>)
|
sl@0
|
29 |
* int <[errnum]>;
|
sl@0
|
30 |
* <<strerror>> converts the error number <[errnum]> into a
|
sl@0
|
31 |
* string. The value of <[errnum]> is usually a copy of <<errno>>.
|
sl@0
|
32 |
* If <<errnum>> is not a known error number, the result points to an
|
sl@0
|
33 |
* empty string.
|
sl@0
|
34 |
* RETURNS
|
sl@0
|
35 |
* This function returns a pointer to a string. Your application must
|
sl@0
|
36 |
* not modify that string.
|
sl@0
|
37 |
* PORTABILITY
|
sl@0
|
38 |
* ANSI C requires <<strerror>>, but does not specify the strings used
|
sl@0
|
39 |
* for each error number.
|
sl@0
|
40 |
* Although this implementation of <<strerror>> is reentrant, ANSI C
|
sl@0
|
41 |
* declares that subsequent calls to <<strerror>> may overwrite the
|
sl@0
|
42 |
* result string; therefore portable code cannot depend on the reentrancy
|
sl@0
|
43 |
* of this subroutine.
|
sl@0
|
44 |
* <<strerror>> requires no supporting OS subroutines.
|
sl@0
|
45 |
* QUICKREF
|
sl@0
|
46 |
* strerror ansi pure
|
sl@0
|
47 |
*
|
sl@0
|
48 |
*
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
|
sl@0
|
51 |
|
sl@0
|
52 |
|
sl@0
|
53 |
#include <errno.h>
|
sl@0
|
54 |
#include <string.h>
|
sl@0
|
55 |
|
sl@0
|
56 |
/**
|
sl@0
|
57 |
Get pointer to error message string.
|
sl@0
|
58 |
Returns a pointer to a string with the error message
|
sl@0
|
59 |
corresponding to the errnum error number.
|
sl@0
|
60 |
The returned pointer points to a statically allocated string.
|
sl@0
|
61 |
Further calls to this function will overwrite its content.
|
sl@0
|
62 |
@param errnum Error number.
|
sl@0
|
63 |
*/
|
sl@0
|
64 |
EXPORT_C char *
|
sl@0
|
65 |
strerror (int errnum)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
char *error;
|
sl@0
|
68 |
|
sl@0
|
69 |
switch (errnum)
|
sl@0
|
70 |
{
|
sl@0
|
71 |
case EPERM:
|
sl@0
|
72 |
error = "Not owner";
|
sl@0
|
73 |
break;
|
sl@0
|
74 |
case ENOENT:
|
sl@0
|
75 |
error = "No such file or directory";
|
sl@0
|
76 |
break;
|
sl@0
|
77 |
case ESRCH:
|
sl@0
|
78 |
error = "No such process";
|
sl@0
|
79 |
break;
|
sl@0
|
80 |
case EINTR:
|
sl@0
|
81 |
error = "Interrupted system call";
|
sl@0
|
82 |
break;
|
sl@0
|
83 |
case EIO:
|
sl@0
|
84 |
error = "I/O error";
|
sl@0
|
85 |
break;
|
sl@0
|
86 |
case ENXIO:
|
sl@0
|
87 |
error = "No such device or address";
|
sl@0
|
88 |
break;
|
sl@0
|
89 |
case E2BIG:
|
sl@0
|
90 |
error = "Arg list too long";
|
sl@0
|
91 |
break;
|
sl@0
|
92 |
case ENOEXEC:
|
sl@0
|
93 |
error = "Exec format error";
|
sl@0
|
94 |
break;
|
sl@0
|
95 |
case EBADF:
|
sl@0
|
96 |
error = "Bad file number";
|
sl@0
|
97 |
break;
|
sl@0
|
98 |
case ECHILD:
|
sl@0
|
99 |
error = "No children";
|
sl@0
|
100 |
break;
|
sl@0
|
101 |
case EAGAIN:
|
sl@0
|
102 |
error = "No more processes";
|
sl@0
|
103 |
break;
|
sl@0
|
104 |
case ENOMEM:
|
sl@0
|
105 |
error = "Not enough space";
|
sl@0
|
106 |
break;
|
sl@0
|
107 |
case EACCES:
|
sl@0
|
108 |
error = "Permission denied";
|
sl@0
|
109 |
break;
|
sl@0
|
110 |
case EFAULT:
|
sl@0
|
111 |
error = "Bad address";
|
sl@0
|
112 |
break;
|
sl@0
|
113 |
case ENOTBLK:
|
sl@0
|
114 |
error = "Block device required";
|
sl@0
|
115 |
break;
|
sl@0
|
116 |
case EBUSY:
|
sl@0
|
117 |
error = "Device or resource busy";
|
sl@0
|
118 |
break;
|
sl@0
|
119 |
case EEXIST:
|
sl@0
|
120 |
error = "File exists";
|
sl@0
|
121 |
break;
|
sl@0
|
122 |
case EXDEV:
|
sl@0
|
123 |
error = "Cross-device link";
|
sl@0
|
124 |
break;
|
sl@0
|
125 |
case ENODEV:
|
sl@0
|
126 |
error = "No such device";
|
sl@0
|
127 |
break;
|
sl@0
|
128 |
case ENOTDIR:
|
sl@0
|
129 |
error = "Not a directory";
|
sl@0
|
130 |
break;
|
sl@0
|
131 |
case EISDIR:
|
sl@0
|
132 |
error = "Is a directory";
|
sl@0
|
133 |
break;
|
sl@0
|
134 |
case EINVAL:
|
sl@0
|
135 |
error = "Invalid argument";
|
sl@0
|
136 |
break;
|
sl@0
|
137 |
case ENFILE:
|
sl@0
|
138 |
error = "Too many open files in system";
|
sl@0
|
139 |
break;
|
sl@0
|
140 |
case EMFILE:
|
sl@0
|
141 |
error = "Too many open files";
|
sl@0
|
142 |
break;
|
sl@0
|
143 |
case ENOTTY:
|
sl@0
|
144 |
error = "Not a character device";
|
sl@0
|
145 |
break;
|
sl@0
|
146 |
case ETXTBSY:
|
sl@0
|
147 |
error = "Text file busy";
|
sl@0
|
148 |
break;
|
sl@0
|
149 |
case EFBIG:
|
sl@0
|
150 |
error = "File too large";
|
sl@0
|
151 |
break;
|
sl@0
|
152 |
case ENOSPC:
|
sl@0
|
153 |
error = "No space left on device";
|
sl@0
|
154 |
break;
|
sl@0
|
155 |
case ESPIPE:
|
sl@0
|
156 |
error = "Illegal seek";
|
sl@0
|
157 |
break;
|
sl@0
|
158 |
case EROFS:
|
sl@0
|
159 |
error = "Read-only file system";
|
sl@0
|
160 |
break;
|
sl@0
|
161 |
case EMLINK:
|
sl@0
|
162 |
error = "Too many links";
|
sl@0
|
163 |
break;
|
sl@0
|
164 |
case EPIPE:
|
sl@0
|
165 |
error = "Broken pipe";
|
sl@0
|
166 |
break;
|
sl@0
|
167 |
case EDOM:
|
sl@0
|
168 |
error = "Math argument";
|
sl@0
|
169 |
break;
|
sl@0
|
170 |
case ERANGE:
|
sl@0
|
171 |
error = "Result too large";
|
sl@0
|
172 |
break;
|
sl@0
|
173 |
case ENOMSG:
|
sl@0
|
174 |
error = "No message of desired type";
|
sl@0
|
175 |
break;
|
sl@0
|
176 |
case EIDRM:
|
sl@0
|
177 |
error = "Identifier removed";
|
sl@0
|
178 |
break;
|
sl@0
|
179 |
case EDEADLK:
|
sl@0
|
180 |
error = "Deadlock";
|
sl@0
|
181 |
break;
|
sl@0
|
182 |
case ENOLCK:
|
sl@0
|
183 |
error = "No lock";
|
sl@0
|
184 |
break;
|
sl@0
|
185 |
case ENOTSOCK: error = "Not a socket"; break;
|
sl@0
|
186 |
case EADDRNOTAVAIL: error = "Remote address not available"; break;
|
sl@0
|
187 |
case EAFNOSUPPORT: error = "Address not supported by protocol"; break;
|
sl@0
|
188 |
case EISCONN: error = "Socket already connected"; break;
|
sl@0
|
189 |
case ECONNREFUSED: error = "Connection refused by remote host"; break;
|
sl@0
|
190 |
case EADDRINUSE: error = "Address already in use"; break;
|
sl@0
|
191 |
case ETIMEDOUT: error = "Connection timed out"; break;
|
sl@0
|
192 |
case ENOSTR:
|
sl@0
|
193 |
error = "Not a stream";
|
sl@0
|
194 |
break;
|
sl@0
|
195 |
case ETIME:
|
sl@0
|
196 |
error = "Stream ioctl timeout";
|
sl@0
|
197 |
break;
|
sl@0
|
198 |
case ENOSR:
|
sl@0
|
199 |
error = "No stream resources";
|
sl@0
|
200 |
break;
|
sl@0
|
201 |
case ENONET:
|
sl@0
|
202 |
error = "Machine is not on the network";
|
sl@0
|
203 |
break;
|
sl@0
|
204 |
case ENOPKG:
|
sl@0
|
205 |
error = "No package";
|
sl@0
|
206 |
break;
|
sl@0
|
207 |
case EREMOTE:
|
sl@0
|
208 |
error = "Resource is remote";
|
sl@0
|
209 |
break;
|
sl@0
|
210 |
case ENOLINK:
|
sl@0
|
211 |
error = "Virtual circuit is gone";
|
sl@0
|
212 |
break;
|
sl@0
|
213 |
case EADV:
|
sl@0
|
214 |
error = "Advertise error";
|
sl@0
|
215 |
break;
|
sl@0
|
216 |
case ESRMNT:
|
sl@0
|
217 |
error = "Srmount error";
|
sl@0
|
218 |
break;
|
sl@0
|
219 |
case ECOMM:
|
sl@0
|
220 |
error = "Communication error";
|
sl@0
|
221 |
break;
|
sl@0
|
222 |
case EPROTO:
|
sl@0
|
223 |
error = "Protocol error";
|
sl@0
|
224 |
break;
|
sl@0
|
225 |
case EMULTIHOP:
|
sl@0
|
226 |
error = "Multihop attempted";
|
sl@0
|
227 |
break;
|
sl@0
|
228 |
case EBADMSG:
|
sl@0
|
229 |
error = "Bad message";
|
sl@0
|
230 |
break;
|
sl@0
|
231 |
case ELIBACC:
|
sl@0
|
232 |
error = "Cannot access a needed shared library";
|
sl@0
|
233 |
break;
|
sl@0
|
234 |
case ELIBBAD:
|
sl@0
|
235 |
error = "Accessing a corrupted shared library";
|
sl@0
|
236 |
break;
|
sl@0
|
237 |
case ELIBSCN:
|
sl@0
|
238 |
error = ".lib section in a.out corrupted";
|
sl@0
|
239 |
break;
|
sl@0
|
240 |
case ELIBMAX:
|
sl@0
|
241 |
error = "Attempting to link in more shared libraries than system limit";
|
sl@0
|
242 |
break;
|
sl@0
|
243 |
case ELIBEXEC:
|
sl@0
|
244 |
error = "Cannot exec a shared library directly";
|
sl@0
|
245 |
break;
|
sl@0
|
246 |
case ENOSYS:
|
sl@0
|
247 |
error = "Function not implemented";
|
sl@0
|
248 |
break;
|
sl@0
|
249 |
case ENMFILE:
|
sl@0
|
250 |
error = "No more files";
|
sl@0
|
251 |
break;
|
sl@0
|
252 |
case ENOTEMPTY:
|
sl@0
|
253 |
error = "Directory not empty";
|
sl@0
|
254 |
break;
|
sl@0
|
255 |
case ENAMETOOLONG:
|
sl@0
|
256 |
error = "File or path name too long";
|
sl@0
|
257 |
break;
|
sl@0
|
258 |
case EILSEQ:
|
sl@0
|
259 |
error = "invalid wide-character encoding";
|
sl@0
|
260 |
break;
|
sl@0
|
261 |
default:
|
sl@0
|
262 |
error = "";
|
sl@0
|
263 |
break;
|
sl@0
|
264 |
}
|
sl@0
|
265 |
|
sl@0
|
266 |
return error;
|
sl@0
|
267 |
}
|