Lely core libraries  2.2.5
errnum.h
Go to the documentation of this file.
1 
56 #ifndef LELY_UTIL_ERRNUM_H_
57 #define LELY_UTIL_ERRNUM_H_
58 
59 #include <lely/features.h>
60 
61 #include <errno.h>
62 
63 #if _WIN32
64 #include <winerror.h>
65 #elif _POSIX_C_SOURCE >= 200112L && !defined(__NEWLIB__)
66 #include <netdb.h>
67 #endif
68 
69 #ifndef LELY_UTIL_ERRNUM_INLINE
70 #define LELY_UTIL_ERRNUM_INLINE static inline
71 #endif
72 
74 enum errnum {
111  // ERRNUM_DQUOT,
144  // ERRNUM_MULTIHOP,
167  // ERRNUM_NOLINK,
222  // ERRNUM_STALE,
257 };
258 
260 #ifdef __cplusplus
261 typedef int errnum_t;
262 #else
263 typedef enum errnum errnum_t;
264 #endif
265 
266 #ifdef __cplusplus
267 extern "C" {
268 #endif
269 
277 int errno2c(int errnum);
278 
285 
293 int errc2no(int errc);
294 
300 errnum_t errc2num(int errc);
301 
308 
315 
325 int get_errc(void);
326 
334 void set_errc(int errc);
335 
343 LELY_UTIL_ERRNUM_INLINE errnum_t get_errnum(void);
344 
351 LELY_UTIL_ERRNUM_INLINE void set_errnum(errnum_t errnum);
352 
357 const char *errno2str(int errnum);
358 
360 const char *errc2str(int errc);
361 
366 LELY_UTIL_ERRNUM_INLINE const char *errnum2str(errnum_t errnum);
367 
368 inline errnum_t
370 {
371  return errc2num(get_errc());
372 }
373 
374 inline void
376 {
378 }
379 
380 inline const char *
382 {
383  return errc2str(errnum2c(errnum));
384 }
385 
386 #ifdef __cplusplus
387 }
388 #endif
389 
390 #endif // !LELY_UTIL_ERRNUM_H_
errnum_t errno2num(int errnum)
Transforms a standard C error number to a platform-independent error number.
Definition: errnum.c:53
errnum_t errc2num(int errc)
Transforms a native error code to a platform-independent error number.
Definition: errnum.c:310
int errnum2c(errnum_t errnum)
Transforms a platform-independent error number to a native error code.
Definition: errnum.c:825
const char * errnum2str(errnum_t errnum)
Returns a string describing a platform-independent error number.
Definition: errnum.h:381
errnum
The platform-independent error numbers.
Definition: errnum.h:74
@ ERRNUM_NOSPC
No space left on device.
Definition: errnum.h:175
@ ERRNUM_AI_MEMORY
There was a memory allocation failure.
Definition: errnum.h:248
@ ERRNUM_NOSYS
Function not supported.
Definition: errnum.h:181
@ ERRNUM_WOULDBLOCK
Operation would block.
Definition: errnum.h:230
@ ERRNUM_OWNERDEAD
Previous owner died.
Definition: errnum.h:203
@ ERRNUM_PROTO
Protocol error.
Definition: errnum.h:209
@ ERRNUM_BADMSG
Bad message.
Definition: errnum.h:92
@ ERRNUM_AFNOSUPPORT
Address family not supported.
Definition: errnum.h:84
@ ERRNUM_NOTCONN
The socket is not connected.
Definition: errnum.h:183
@ ERRNUM_NXIO
No such device or address.
Definition: errnum.h:197
@ ERRNUM_IDRM
Identifier removed.
Definition: errnum.h:121
@ ERRNUM_AI_BADFLAGS
The flags had an invalid value.
Definition: errnum.h:239
@ ERRNUM_RANGE
Result too large.
Definition: errnum.h:215
@ ERRNUM_MSGSIZE
Message too large.
Definition: errnum.h:143
@ ERRNUM_INTR
Interrupted function.
Definition: errnum.h:127
@ ERRNUM_SPIPE
Invalid seek.
Definition: errnum.h:219
@ ERRNUM_ALREADY
Connection already in progress.
Definition: errnum.h:88
@ ERRNUM_NOPROTOOPT
Protocol not available.
Definition: errnum.h:173
@ ERRNUM_BUSY
Device or resource busy.
Definition: errnum.h:94
@ ERRNUM_ISCONN
Socket is connected.
Definition: errnum.h:133
@ ERRNUM_NETDOWN
Network is down.
Definition: errnum.h:148
@ ERRNUM_SRCH
No such process.
Definition: errnum.h:221
@ ERRNUM_MLINK
Too many links.
Definition: errnum.h:141
@ ERRNUM_IO
I/O error.
Definition: errnum.h:131
@ ERRNUM_TIMEDOUT
Connection timed out.
Definition: errnum.h:226
@ ERRNUM_NOENT
No such file or directory.
Definition: errnum.h:162
@ ERRNUM_NFILE
Too many files open in system.
Definition: errnum.h:154
@ ERRNUM_AI_SOCKTYPE
The intended socket type was not recognized.
Definition: errnum.h:256
@ ERRNUM_BADF
Bad file descriptor.
Definition: errnum.h:90
@ ERRNUM_OPNOTSUPP
Operation not supported on socket.
Definition: errnum.h:199
@ ERRNUM_NOTTY
Inappropriate I/O control operation.
Definition: errnum.h:195
@ ERRNUM_PERM
Operation not permitted.
Definition: errnum.h:205
@ ERRNUM_PROTONOSUPPORT
Protocol not supported.
Definition: errnum.h:211
@ ERRNUM_NOMEM
Not enough space.
Definition: errnum.h:169
@ ERRNUM_TIME
Stream ioctl() timeout.
Definition: errnum.h:224
@ ERRNUM_FBIG
File too large.
Definition: errnum.h:117
@ ERRNUM_2BIG
Argument list too long.
Definition: errnum.h:76
@ ERRNUM_NOEXEC
Executable file format error.
Definition: errnum.h:164
@ ERRNUM_NOTSUP
Not supported.
Definition: errnum.h:193
@ ERRNUM_CHILD
No child process.
Definition: errnum.h:98
@ ERRNUM_NOTSOCK
Not a socket.
Definition: errnum.h:191
@ ERRNUM_NOTDIR
Not a directory or a symbolic link to a directory.
Definition: errnum.h:185
@ ERRNUM_MFILE
File descriptor value too large.
Definition: errnum.h:139
@ ERRNUM_ACCES
Permission denied.
Definition: errnum.h:78
@ ERRNUM_ADDRNOTAVAIL
Address not available.
Definition: errnum.h:82
@ ERRNUM_INVAL
Invalid argument.
Definition: errnum.h:129
@ ERRNUM_AI_AGAIN
The name could not be resolved at this time.
Definition: errnum.h:237
@ ERRNUM_CONNABORTED
Connection aborted.
Definition: errnum.h:100
@ ERRNUM_NOTEMPTY
Directory not empty.
Definition: errnum.h:187
@ ERRNUM_AI_FAIL
A non-recoverable error occurred.
Definition: errnum.h:241
@ ERRNUM_PROTOTYPE
Protocol wrong type for socket.
Definition: errnum.h:213
@ ERRNUM_ADDRINUSE
Address in use.
Definition: errnum.h:80
@ ERRNUM_NOMSG
No message of the desired type.
Definition: errnum.h:171
@ ERRNUM_AGAIN
Resource unavailable, try again.
Definition: errnum.h:86
@ ERRNUM_ROFS
Read-only file system.
Definition: errnum.h:217
@ ERRNUM_NOBUFS
No buffer space available.
Definition: errnum.h:156
@ ERRNUM_CONNREFUSED
Connection refused.
Definition: errnum.h:102
@ ERRNUM_DOM
Mathematics argument out of domain of function.
Definition: errnum.h:110
@ ERRNUM_NETRESET
Connection aborted by network.
Definition: errnum.h:150
@ ERRNUM_HOSTUNREACH
Host is unreachable.
Definition: errnum.h:119
@ ERRNUM_DEADLK
Resource deadlock would occur.
Definition: errnum.h:106
@ ERRNUM_EXIST
File exists.
Definition: errnum.h:113
@ ERRNUM_NODATA
No message is available on the STREAM head read queue.
Definition: errnum.h:158
@ ERRNUM_ISDIR
Is a directory.
Definition: errnum.h:135
@ ERRNUM_OVERFLOW
Value too large to be stored in data type.
Definition: errnum.h:201
@ ERRNUM_AI_OVERFLOW
An argument buffer overflowed.
Definition: errnum.h:252
@ ERRNUM_PIPE
Broken pipe.
Definition: errnum.h:207
@ ERRNUM_TXTBSY
Text file busy.
Definition: errnum.h:228
@ ERRNUM_AI_FAMILY
The address family was not recognized or the address length was invalid for the specified family.
Definition: errnum.h:246
@ ERRNUM_NOSR
No STREAM resources.
Definition: errnum.h:177
@ ERRNUM_NOSTR
Not a STREAM.
Definition: errnum.h:179
@ ERRNUM_ILSEQ
Illegal byte sequence.
Definition: errnum.h:123
@ ERRNUM_CONNRESET
Connection reset.
Definition: errnum.h:104
@ ERRNUM_INPROGRESS
Operation in progress.
Definition: errnum.h:125
@ ERRNUM_AI_SERVICE
The service passed was not recognized for the specified socket type.
Definition: errnum.h:254
@ ERRNUM_NODEV
No such device.
Definition: errnum.h:160
@ ERRNUM_FAULT
Bad address.
Definition: errnum.h:115
@ ERRNUM_LOOP
Too many levels of symbolic links.
Definition: errnum.h:137
@ ERRNUM_NETUNREACH
Network unreachable.
Definition: errnum.h:152
@ ERRNUM_AI_NONAME
The name does not resolve for the supplied parameters.
Definition: errnum.h:250
@ ERRNUM_XDEV
Cross-device link.
Definition: errnum.h:232
@ ERRNUM_DESTADDRREQ
Destination address required.
Definition: errnum.h:108
@ ERRNUM_NAMETOOLONG
Filename too long.
Definition: errnum.h:146
@ ERRNUM_CANCELED
Operation canceled.
Definition: errnum.h:96
@ ERRNUM_NOTRECOVERABLE
State not recoverable.
Definition: errnum.h:189
@ ERRNUM_NOLCK
No locks available.
Definition: errnum.h:166
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
Definition: errnum.c:947
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
Definition: errnum.c:957
int errc2no(int errc)
Transforms a native error code to a standard C error number.
Definition: errnum.c:300
enum errnum errnum_t
The platform-independent error number type.
Definition: errnum.h:263
int errnum2no(errnum_t errnum)
Transforms a platform-independent error number to a standard C error number.
Definition: errnum.c:574
const char * errno2str(int errnum)
Returns a string describing a standard C error number.
Definition: errnum.c:967
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
Definition: errnum.c:43
errnum_t get_errnum(void)
Returns the last (thread-specific) platform-independent error number set by a system call or library ...
Definition: errnum.h:369
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
Definition: errnum.h:375
const char * errc2str(int errc)
Returns a string describing a native error code.
Definition: errnum.c:973
This header file is part of the Lely libraries; it contains the compiler feature definitions.