]>
jfr.im git - irc/evilnet/x3.git/blob - src/compat.c
8 #ifdef HAVE_SYS_TIMEB_H
9 # include <sys/timeb.h>
15 #if !defined(HAVE_GETTIMEOFDAY) && defined(HAVE_FTIME)
16 extern gettimeofday(struct timeval
* tv
, struct timezone
* tz
);
26 ftime(&tb
); /* FIXME: some versions are void return others int */
29 tv
->tv_usec
= ((long)tb
.millitm
)*1000;
32 tz
->tz_minuteswest
= 0;
41 extern void * memcpy(void * dest
, void const * src
, unsigned long n
)
47 /* very slow, your fault for not having memcpy()*/
48 unsigned char * td
=dest
;
49 unsigned char * ts
=src
;
63 /* very slow, deal with it */
64 extern void * memset(void * dest
, int c
, unsigned long n
)
66 unsigned char * temp
=dest
;
73 temp
[i
] = (unsigned char)c
;
79 extern char * strdup(char const * str
)
85 if (!(out
= malloc(strlen(str
)+1)))
93 extern char const * strerror(int errornum
)
99 return "Operation not permitted";
102 if (errornum
==ENOENT
)
103 return "No such file or directory";
107 return "No such process";
111 return "Interrupted system call";
119 return "No such device or address";
123 return "Bad file number";
126 if (errornum
==EAGAIN
)
130 if (errornum
==ENOMEM
)
131 return "Out of memory";
134 if (errornum
==EACCES
)
135 return "Permission denied";
138 if (errornum
==EFAULT
)
139 return "Bad address";
143 return "Device or resource busy";
146 if (errornum
==EEXIST
)
147 return "File exists";
151 return "Cross-device link";
155 return "Resource deadlock would occur";
158 if (errornum
==EDEADLOCK
)
159 return "Resource deadlock would occur";
162 if (errornum
==ENODEV
)
163 return "No such device";
166 if (errornum
==ENOTDIR
)
167 return "Not a directory";
170 if (errornum
==EISDIR
)
171 return "Is a directory";
174 if (errornum
==EINVAL
)
175 return "Invalid argument";
178 if (errornum
==ENFILE
)
179 return "Too many open files in system";
182 if (errornum
==EMFILE
)
183 return "Too many open files";
186 if (errornum
==ENOTTY
)
187 return "Not a typewriter";
190 if (errornum
==ETXTBSY
)
191 return "Text file busy";
195 return "File too large";
198 if (errornum
==ENOSPC
)
199 return "No space left on device";
202 if (errornum
==ESPIPE
)
203 return "Illegal seek";
207 return "Read-only file system";
210 if (errornum
==EMLINK
)
211 return "Too many links";
215 return "Broken pipe";
219 return "Math argument out of domain of func";
222 if (errornum
==ERANGE
)
223 return "Math result not representable";
226 if (errornum
==ENAMETOOLONG
)
227 return "File name too long";
230 if (errornum
==ENOLCK
)
231 return "No record locks avaliable";
234 if (errornum
==ENOSYS
)
235 return "Function not implemented";
238 if (errornum
==ENOTEMPTY
)
239 return "Directory not empty";
243 return "Too many symbolic links encountered";
246 if (errornum
==EHOSTDOWN
)
247 return "Host is down";
250 if (errornum
==EHOSTUNREACH
)
251 return "No route to host";
254 if (errornum
==EALREADY
)
255 return "Operation already in progress";
258 if (errornum
==EINPROGRESS
)
259 return "Operation now in progress";
262 if (errornum
==ESTALE
)
263 return "Stale NFS filehandle";
266 if (errornum
==EDQUOT
)
267 return "Quota exceeded";
270 if (errornum
==EWOULDBLOCK
)
271 return "Operation would block";
275 return "Communication error on send";
278 if (errornum
==EPROTO
)
279 return "Protocol error";
281 #ifdef EPROTONOSUPPORT
282 if (errornum
==EPROTONOSUPPORT
)
283 return "Protocol not supported";
285 #ifdef ESOCKTNOSUPPORT
286 if (errornum
==ESOCKTNOSUPPORT
)
287 return "Socket type not supported";
289 #ifdef ESOCKTNOSUPPORT
290 if (errornum
==EOPNOTSUPP
)
291 return "Operation not supported";
294 if (errornum
==EPFNOSUPPORT
)
295 return "Protocol family not supported";
298 if (errornum
==EAFNOSUPPORT
)
299 return "Address family not supported by protocol family";
302 if (errornum
==EADDRINUSE
)
303 return "Address already in use";
306 if (errornum
==EADDRNOTAVAIL
)
307 return "Cannot assign requested address";
310 if (errornum
==ENETDOWN
)
311 return "Network is down";
314 if (errornum
==ENETUNREACH
)
315 return "Network is unreachable";
318 if (errornum
==ENETRESET
)
319 return "Network dropped connection on reset";
322 if (errornum
==ECONNABORTED
)
323 return "Software caused connection abort";
326 if (errornum
==ECONNRESET
)
327 return " Connection reset by peer";
330 if (errornum
==ENOBUFS
)
331 return "No buffer space available";
334 if (errornum
==EISCONN
)
335 return "Socket is already connected";
338 if (errornum
==ENOTCONN
)
339 return "Socket is not connected";
342 if (errornum
==ESHUTDOWN
)
343 return " Cannot send after socket shutdown";
346 if (errornum
==ETIMEDOUT
)
347 return "Connection timed out";
350 if (errornum
==ECONNREFUSED
)
351 return "Connection refused";
353 return "Unknown error";