mbgtools-lx  4.2.8
mbgerror.c
Go to the documentation of this file.
1 
2 /**************************************************************************
3  *
4  * $Id: mbgerror.c 1.7 2019/04/03 12:53:55 martin TRASH $
5  *
6  * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
7  *
8  * Description:
9  * Meinberg Library to communicate with USB devices from user space
10  *
11  * -----------------------------------------------------------------------
12  * $Log: mbgerror.c $
13  * Revision 1.7 2019/04/03 12:53:55 martin
14  * Use new code MBG_ERR_BAD_ADDR.
15  * Revision 1.6 2018/11/22 14:47:15 martin
16  * Support QNX target.
17  * New function mbg_win32_ntstatus_to_mbg().
18  * Added and renamed static code conversion tables.
19  * Added and updated doxygen comments.
20  * Revision 1.5 2018/09/21 09:44:38 martin
21  * Renamed mbg_win32_last_err_to_mbg() to
22  * mbg_win32_sys_err_to_mbg().
23  * Translate win32 error codes ERROR_BUFFER_OVERFLOW
24  * and ERROR_INSUFFICIENT_BUFFER.
25  * Updated some comments.
26  * Revision 1.4 2018/06/25 14:21:09Z martin
27  * Cleaned up definition and usage of control macros.
28  * Distinguish between kernel mode and user mode on Windows.
29  * Support some new error codes.
30  * Revision 1.3 2017/07/05 09:20:07 martin
31  * Fixed a bug where POSIX error ENODEV wasn't mapped at all, but
32  * EXDEV was instead translated erraneously to MBG_ERR_NO_DEV.
33  * Mapped POSIX error ENOSPC to MBG_ERR_NO_SPACE, and EFAULT
34  * to MBG_ERR_INV_PARM.
35  * Mapped Windows WSA error codes WSAEFAULT and WSAEINVAL
36  * to MBG_ERR_INV_PARM.
37  * Renamed mbg_ioctl_err() to mbg_cond_err_msg().
38  * New function mbg_cond_err_msg_info() which takes an optional
39  * info string which is printed if the error code to be checked
40  * is MBG_ERR_NOT_SUPP_BY_DEV.
41  * Fixed build in Windows kernel mode.
42  * Fixed syntax error in CVI-specific code.
43  * Quieted some compiler warnings.
44  * Revision 1.2 2016/08/05 12:25:44Z martin
45  * Added some functions.
46  * Revision 1.1 2014/03/07 12:08:14 martin
47  * Initial revision.
48  *
49  **************************************************************************/
50 
51 #define _MBGERROR
52  #include <mbgerror.h>
53 #undef _MBGERROR
54 
55 #include <mbg_tgt.h>
56 
57 #if defined( MBG_TGT_WIN32 )
58 
59  #if !defined( MBG_TGT_KERNEL )
60  #include <errno.h>
61  #include <stdio.h>
62 
63  #define _MBG_TGT_HAS_POSIX_ERRNO 1
64  #define _MBG_TGT_HAS_WIN32_ERR_API 1
65  #else
66  #include <mbgddmsg.h>
67 
68  #define _MBG_TGT_OMIT_LAST_ERROR 1
69  #define _MBG_TGT_OMIT_ERR_MSG 1 // Not (yet) supported in Windows kernel mode
70  #endif
71 
72 #elif defined( MBG_TGT_CVI )
73 
74  // Nothing to do here.
75 
76 #elif defined( MBG_TGT_LINUX )
77 
78  #if !defined( MBG_TGT_KERNEL )
79  #include <errno.h>
80  #include <stdio.h>
81  #include <string.h>
82  #include <netdb.h>
83 
84  #define _MBG_TGT_HAS_POSIX_ERRNO 1
85  #define _MBG_TGT_HAS_POSIX_H_ERRNO 1
86  #else
87  #include <asm/errno.h>
88 
89  #define _MBG_TGT_HAS_POSIX_ERRNO 1
90  #define _MBG_TGT_OMIT_LAST_ERROR 1
91  #define _MBG_TGT_OMIT_ERR_MSG 1
92  #endif
93 
94 #elif defined( MBG_TGT_BSD )
95 
96  #if !defined( MBG_TGT_KERNEL )
97  #include <errno.h>
98  #include <stdio.h>
99  #include <string.h>
100  #include <netdb.h>
101 
102  #define _MBG_TGT_HAS_POSIX_ERRNO 1
103  #define _MBG_TGT_HAS_POSIX_H_ERRNO 1
104  #else
105  #include <sys/errno.h>
106  #if defined( MBG_TGT_FREEBSD )
107  #include <sys/stddef.h> // NULL
108  #elif defined( MBG_TGT_NETBSD )
109  #include <sys/null.h> // NULL
110  #endif
111 
112  #define _MBG_TGT_HAS_POSIX_ERRNO 1
113  #define _MBG_TGT_OMIT_LAST_ERROR 1
114  #define _MBG_TGT_OMIT_ERR_MSG 1
115  #endif
116 
117 #elif defined( MBG_TGT_QNX_NTO ) // QNX 6.x only, but not QNX 4.x
118 
119  #include <stdio.h>
120  #include <errno.h>
121  #include <string.h>
122  #include <netdb.h>
123 
124  #define _MBG_TGT_HAS_POSIX_ERRNO 1
125  #define _MBG_TGT_HAS_POSIX_H_ERRNO 1
126 
127 #elif defined( MBG_TGT_DOS )
128 
129  #include <stdio.h>
130  #include <stdlib.h>
131  #include <stddef.h>
132  #include <errno.h>
133 
134  #define _MBG_TGT_HAS_POSIX_ERRNO 1
135  #define _MBG_TGT_OMIT_SOCKET_ERRORS 1 // No network socket support by OS
136 
137 #endif
138 
139 #if defined( USE_MBG_ZLIB )
140  #include <zlib.h>
141 #endif
142 
143 #if !defined( DEBUG )
144  // FIXME This should be done globally across projects.
145  #define DEBUG 0
146 #endif
147 
148 
149 typedef struct
150 {
151  int srch_errno;
152  int mapped_errno;
153 
155 
156 
157 
158 #if defined( _MBG_TGT_HAS_POSIX_ERRNO )
159 
174 {
175  { EPERM, MBG_ERR_PERM }, // 1, Operation not permitted (e.g. when trying to set time without sufficient permissions).
176  { ENOENT, MBG_ERR_NO_ENTITY }, // 2, No such file or directory.
177  // { ESRCH, }, // 3, No such process.
178  { EINTR, MBG_ERR_INTR }, // 4, Interrupted function call.
179  { EIO, MBG_ERR_IO }, // 5, Input/output error (from physical device).
180  { ENXIO, MBG_ERR_NOT_FOUND }, // 6, No such device or address (refering to a device that doesn't exist, or request beyond its capabilities) of the device.
181  // { E2BIG, }, // 7, Argument list too long (or lack of space in an output buffer, or argument exceeds system-imposed maximum.
182  // { ENOEXEC, }, // 8, Exec format error (executable file format error).
183  // { EBADF, }, // 9, Bad file number/descriptor (or a read (write) tried on a file only open for writing (reading)).
184  // { ECHILD, }, // 10, No child processes (when waiting for child process).
185  { EAGAIN, MBG_ERR_AGAIN }, // 11, Try again, resource temporarily unavailable (later calls may complete normally, maybe same as EWOULDBLOCK).
186  { ENOMEM, MBG_ERR_NO_MEM }, // 12, Out of memory (can't allocate memory).
187  { EACCES, MBG_ERR_ACCESS }, // 13, Permission denied (e.g. when trying to access a device without sufficient permissions).
188  { EFAULT, MBG_ERR_BAD_ADDRESS }, // 14, Bad address (e.g. invalid address in a function argument).
189  // { ENOTBLK, }, // 15, Block device required (eventually no POSIX error, but supported in Linux and *BSD).
190  { EBUSY, MBG_ERR_BUSY }, // 16, Device or resource busy.
191  { EEXIST, MBG_ERR_EXIST }, // 17, File exists.
192  // { EXDEV, }, // 18, Cross-device link.
193  { ENODEV, MBG_ERR_NO_DEV }, // 19, ### No such device (operation not supported by device).
194  // { ENOTDIR, }, // 20, Not a directory (when a directory was expected for the operation).
195  // { EISDIR, }, // 21, Is a directory (when a directory was *not* expected for the operation).
196  { EINVAL, MBG_ERR_INV_PARM }, // 22, Invalid argument (was supplied to a function).
197  // { ENFILE, }, // 23, Too many files open in system (file table overflow).
198  // { EMFILE, }, // 24, Too many open files (or file descriptor value too large).
199  { ENOTTY, MBG_ERR_NOT_SUPP_BY_DEV }, // 25, ### Not a typewriter (actually means "inappropriate I/O control for device").
200  // { ETXTBSY, }, // 26, Text file busy ("text" actually means "binary program file").
201  // { EFBIG, }, // 27, File too large.
202  { ENOSPC, MBG_ERR_NO_SPACE }, // 28, No space left on device (when writing a file or extending directory).
203  { ESPIPE, MBG_ERR_PIPE }, // 29, Illegal seek (when attempting to access the file offset associated with a pipe or FIFO).
204  // { EROFS, }, // 30, Read-only file system.
205  // { EMLINK, }, // 31, Too many links (link count of a single file exceed).
206  // { EPIPE, }, // 32, Broken pipe (writing to a socket, pipe, or FIFO which has no process to read the data).
207  // { EDOM, }, // 33, Math argument out of domain of function.
208  { ERANGE, MBG_ERR_RANGE }, // 34, Math result too large or too small (not representable).
209 #if defined( ETIME )
210  { ETIME, MBG_ERR_TIMER }, // 62, Timer expired (e.g. stream timeout on USB disconnect).
211 #endif
212 #if defined( EOVERFLOW )
213  { EOVERFLOW, MBG_ERR_OVERFLOW }, // 75, Value too large for defined data type (can't be stored).
214 #endif
215 #if defined( ENOTSOCK )
216  { ENOTSOCK, MBG_ERR_NOT_A_SOCKET }, // 88, Socket operation on non-socket (file descriptor is not a socket).
217 #endif
218 #if defined( ECONNRESET )
219  { ECONNRESET, MBG_ERR_CONN_RESET }, // 104, Connection reset by peer
220 #endif
221 #if defined( ETIMEDOUT )
222  { ETIMEDOUT, MBG_ERR_TIMEOUT }, // 110, Connection timed out
223 #endif
224  { 0, 0 } // end-of-table identifier
225 
226 }; // posix_errno_table
227 
228 #endif // defined( _MBG_TGT_HAS_POSIX_ERRNO )
229 
230 
231 
232 #if defined( _MBG_TGT_HAS_POSIX_H_ERRNO )
233 
235 {
236  // POSIX codes taken from Linux netdb.h
237  { HOST_NOT_FOUND, MBG_ERR_HOST_NOT_FOUND }, // The specified host is unknown
238  // { NO_ADDRESS, }, // Usually same numeric value as NO_DATA
239  // { NO_DATA, }, // The requested name is valid but does not have an IP address
240  // { NO_RECOVERY, }, // A nonrecoverable name server error occurred
241  // { TRY_AGAIN, }, // A temporary error occurred on an authoritative name server. Try again later.
242  { 0, 0 } // end-of-table identifier
243 
244 }; // posix_h_errno_table
245 
246 #endif // defined( _MBG_TGT_HAS_POSIX_H_ERRNO )
247 
248 
249 
250 #if defined( MBG_TGT_CVI )
251 
252 static ERRNO_CNV_ENTRY cvi_rs232_error_table[] =
253 {
254  // { kRS_UnknownSysError, }, // Unknown system error.
255  // { kRS_InvalidPortNum, }, // In valid port number.
256  // { kRS_PortNotOpen, }, // Port is not open.
257  // { kRS_UnknownIOError, }, // Unknown I/O error.
258  // { kRS_InternalError, }, // Unexpected internal error.
259  // { kRS_NoPortFound, }, // No serial port found.
260  // { kRS_CanNotOpenPort, }, // Cannot open port.
261  // { kRS_NullPointerPassed, }, // A NULL pointer was passed when a non-NULL pointer was expected.
262  // { kRS_OutOfMemory, }, // Out of memory.
263  // { kRS_OutOfSystemResources, }, // Unable to allocate system resources.
264  // { kRS_InvalidParameter, }, // Invalid parameter.
265  // { kRS_InvalidBaudRate, }, // Invalid baud rate.
266  // { kRS_InvalidParity, }, // Invalid parity.
267  // { kRS_InvalidDataBits, }, // Invalid number of data bits.
268  // { kRS_InvalidStopBits, }, // Invalid number of stop bits.
269  // { kRS_BadFileHandle, }, // Bad file handle.
270  // { kRS_FileIOError, }, // File I/O error.
271  // { kRS_InvalidCount, }, // Invalid count; must be greater than or equal to 0.
272  // { kRS_InvalidIntLevel, }, // Invalid interrupt level.
273  // { kRS_IOTimeOut, }, // I/O operation timed out.
274  // { kRS_InvalidBreakTime, }, // Break time must be a positive value.
275  // { kRS_InvalidInQSize, }, // Requested input queue size must be 0 or greater.
276  // { kRS_InvalidOutQSize, }, // Requested output queue size must be 0 or greater.
277  // { kRS_GeneralIOFailure, }, // General I/O error.
278  // { kRS_InvalidBufferPointer, }, // Buffer parameter is NULL.
279  // { kRS_VISALibrariesMissing, }, // A necessary run-time library could not be found or loaded.
280  // { kRS_NoAckReceived, }, // Packet was sent, but no acknowledgment was received.
281  // { kRS_MaxRetriesBeforeSend, }, // Packet was not sent within retry limit.
282  // { kRS_MaxRetriesBeforeReceived, }, // Packet was not received within retry limit.
283  // { kRS_UnexpectedEOT, }, // End of transmission character encountered when start of data character expected.
284  // { kRS_CanNotReadPackNum, }, // Unable to read packet number.
285  // { kRS_InconsistentPackNum, }, // Inconsistent packet number.
286  // { kRS_CanNotReadPackData, }, // Unable to read packet data.
287  // { kRS_CanNotReadCheckSum, }, // Unable to read checksum.
288  // { kRS_CheckSumError, }, // Checksum received did not match computed checksum.
289  // { kRS_PackSizeGTInQ, }, // Packet size exceeds input queue size.
290  // { kRS_OpenFileError, }, // Error opening file.
291  // { kRS_ReadFileError, }, // Error reading file.
292  // { kRS_NoInitNegAck, }, // Did not receive initial negative acknowledgment character.
293  // { kRS_NoAckAfterEOT, }, // Did not receive acknowledgment after end of transmission character was sent.
294  // { kRS_WriteFileError, }, // Error writing to file.
295  // { kRS_NoSOHorEOT, }, // Did not receive either a start of data or end of transmission character when expected.
296  // { kRS_TransferCancelled, }, // Transfer was canceled because CAN ASCII character was received.
297  // { kRS_InvalidStartDelay, }, // Invalid start delay.
298  // { kRS_InvalidMaxTries, }, // Invalid maximum number of retries.
299  // { kRS_InvalidWaitPeriod, }, // Invalid wait period.
300  // { kRS_InvalidPacketSize, }, // Invalid packet size.
301  // { kRS_CanNotReadCRC, }, // Unable to read Cyclical Redundancy Check.
302  // { kRS_CRCError, }, // Cyclical Redundancy Check error.
303  { 0, 0 } // end-of-table identifier
304 
305 }; // cvi_rs232_error_table
306 
307 #endif // defined( MBG_TGT_CVI )
308 
309 
310 
311 #if defined( MBG_TGT_WIN32 )
312 
313 #if defined( MBG_TGT_KERNEL )
314 
333 static ERRNO_CNV_ENTRY win32_kernel_status_table[] =
334 {
335  { STATUS_INVALID_PARAMETER, MBG_ERR_INV_PARM, }, // 0xC000000DL, An invalid parameter was passed to a service or function.
336  { STATUS_INVALID_DEVICE_REQUEST, MBG_ERR_INV_DEV_REQUEST }, // 0xC0000010L, The specified request is not a valid operation for the target device.
337  { STATUS_DEVICE_BUSY, MBG_ERR_IRQ_UNSAFE }, // 0x80000011L, The device is currently busy.
338  { STATUS_NO_MEMORY, MBG_ERR_NO_MEM }, // 0xC0000017L, Not enough memory available to complete the specified operation.
339  { STATUS_NO_DATA_DETECTED, MBG_ERR_NOT_SUPP_BY_DEV }, // 0x80000022L, (normally used with tape access, but mis-used here)
340  { STATUS_ACCESS_DENIED, MBG_ERR_PERM }, // 0xC0000022L, A process has requested access to an object, but has not been granted those access rights.
341  { STATUS_IO_DEVICE_ERROR, MBG_ERR_IO }, // 0xC0000185L, The I/O device reported an I/O error.
342 
343  { STATUS_BUFFER_TOO_SMALL, MBG_ERR_BUFFER_TOO_SMALL }, // 0xC0000023L, The buffer is too small to contain the entry. No information has been written to the buffer.
344  // { STATUS_CANCELLED, }, // 0xC0000120L, The I/O request was canceled.
345  // { STATUS_DELETE_PENDING, }, // 0xC0000056L, A non close operation has been requested of a file object with a delete pending.
346  // { STATUS_DEVICE_CONFIGURATION_ERROR, }, // 0xC0000182L, The I/O device is configured incorrectly or the configuration parameters to the driver are incorrect.
347  { STATUS_DEVICE_NOT_READY, MBG_ERR_NOT_READY }, // 0xC00000A3L, The device (drive) is not ready for use.
348  // { STATUS_INSUFFICIENT_RESOURCES, }, // 0xC000009AL, Insufficient system resources exist to complete the API.
349  // { STATUS_MORE_PROCESSING_REQUIRED, }, // 0xC0000016L, The specified IRP cannot be disposed of because the I/O operation is not complete.
350  // { STATUS_NOT_IMPLEMENTED, }, // 0xC0000002L, The requested operation is not implemented.
351  // { STATUS_NOT_SUPPORTED, }, // 0xC00000BBL, The network request is not supported.
352  // { STATUS_NO_SUCH_DEVICE, }, // 0xC000000EL, A device which does not exist was specified.
353  // { STATUS_OBJECT_NAME_NOT_FOUND, }, // 0xC0000034L, Object Name not found.
354  // { STATUS_PENDING, }, // 0x00000103L, The operation that was requested is pending completion.
355  { STATUS_TIMEOUT, MBG_ERR_TIMEOUT }, // 0x00000102L, STATUS_TIMEOUT
356  // { STATUS_UNSUCCESSFUL, }, // 0xC0000001L, The requested operation was unsuccessful.
357  { 0, 0 } // end-of-table identifier
358 
359 }; // win32_kernel_status_table
360 
361 
362 
363 #if !_USE_WIN32_PRIVATE_STATUS_CODES
364 
421 static ERRNO_CNV_ENTRY mbg_ioctl_to_ntstatus_table[] =
422 {
423  { MBG_ERR_INV_PARM, STATUS_INVALID_PARAMETER }, // ERROR_INVALID_PARAMETER
424  { MBG_ERR_INV_DEV_REQUEST, STATUS_INVALID_DEVICE_REQUEST }, // ERROR_BAD_COMMAND
425  { MBG_ERR_IRQ_UNSAFE, STATUS_DEVICE_BUSY }, // ERROR_BUSY
426  { MBG_ERR_NO_MEM, STATUS_NO_MEMORY }, // ERROR_NOT_ENOUGH_MEMORY
427  { MBG_ERR_NOT_SUPP_BY_DEV, STATUS_NO_DATA_DETECTED }, // ERROR_NO_DATA_DETECTED (mis-used here)
428  { MBG_ERR_PERM, STATUS_ACCESS_DENIED }, // ERROR_ACCESS_DENIED
429  { MBG_ERR_IO, STATUS_IO_DEVICE_ERROR }, // ERROR_IO_DEVICE
430  { 0, 0 } // end-of-table identifier
431 
432 }; // mbg_ioctl_to_ntstatus_table
433 
434 #endif // !_USE_WIN32_PRIVATE_STATUS_CODES
435 
436 
437 #else // Windows user space
438 
461 static ERRNO_CNV_ENTRY win32_sys_err_table[] =
462 {
463  // Mappings for some Windows error codes defined in WinError.h
464  { ERROR_PATH_NOT_FOUND, MBG_ERR_NO_ENTITY }, // 3L: The system cannot find the path specified.
465  { ERROR_ACCESS_DENIED, MBG_ERR_ACCESS }, // 5L: Access is denied.
466  { ERROR_INVALID_HANDLE, MBG_ERR_INV_HANDLE }, // 6L: The handle is invalid.
467  { ERROR_NOT_ENOUGH_MEMORY, MBG_ERR_NO_MEM }, // 8L: Not enough storage is available to process this command.
468  { ERROR_OUTOFMEMORY, MBG_ERR_NO_MEM }, // 14L: Not enough storage is available to complete this operation.
469  // { ERROR_WRITE_PROTECT, }, // 19L: The media is write protected.
470  // { ERROR_BAD_UNIT, }, // 20L: The system cannot find the device specified.
471  { ERROR_NOT_READY, MBG_ERR_NOT_READY }, // 21L: The device is not ready.
472  { ERROR_WRITE_FAULT, MBG_ERR_IO }, // 29L: The system cannot write to the specified device.
473  { ERROR_READ_FAULT, MBG_ERR_IO }, // 30L: The system cannot read from the specified device.
474  { ERROR_GEN_FAILURE, MBG_ERR_UNSPEC }, // 31L: A device attached to the system is not functioning.
475  // { ERROR_SHARING_VIOLATION, }, // 32L: The process cannot access the file because it is being used by another process.
476  // { ERROR_LOCK_VIOLATION, }, // 33L: The process cannot access the file because another process has locked a portion of the file.
477  // { ERROR_NOT_SUPPORTED, }, // 50L: The request is not supported.
478  // { ERROR_DUP_NAME, }, // 52L: A duplicate name exists on the network.
479  // { ERROR_BAD_DEV_TYPE, }, // 66L: The network resource type is not correct.
480  { ERROR_INVALID_PARAMETER, MBG_ERR_INV_PARM }, // 87L: The parameter is incorrect.
481  { ERROR_BUFFER_OVERFLOW, MBG_ERR_OVERFLOW }, // 111L: The file name is too long.
482  { ERROR_INSUFFICIENT_BUFFER, MBG_ERR_BUFFER_TOO_SMALL }, // 122L: The data area passed to a system call is too small.
483  { ERROR_BUSY, MBG_ERR_BUSY }, // 170L: The requested resource is in use.
484  // { ERROR_NOACCESS, }, // 998L: Invalid access to memory location.
485  { ERROR_NO_DATA_DETECTED, MBG_ERR_NOT_SUPP_BY_DEV }, // 1104L: No more data is on the tape. (mis-used here)
486  { ERROR_IO_DEVICE, MBG_ERR_IO }, // 1117L: The request could not be performed because of an I/O device error.
487  { ERROR_PRIVILEGE_NOT_HELD, MBG_ERR_PERM }, // 1314L: A required privilege is not held by the client.
488  { 0, 0 } // end-of-table identifier
489 
490 }; // win32_sys_err_table
491 
492 
493 
516 static ERRNO_CNV_ENTRY win32_wsa_err_table[] =
517 {
518  { WSAEINTR, MBG_ERR_INTR }, // 10004L A blocking operation was interrupted by a call to WSACancelBlockingCall.
519  // { WSAEBADF // 10009L The file handle supplied is not valid.
520  // { WSAEACCES // 10013L An attempt was made to access a socket in a way forbidden by its access permissions.
521  { WSAEFAULT, MBG_ERR_BAD_ADDRESS }, // 10014L The system detected an invalid pointer address in attempting to use a pointer argument in a call.
522  { WSAEINVAL, MBG_ERR_INV_PARM }, // 10022L An invalid argument was supplied.
523  // { WSAEMFILE // 10024L Too many open sockets.
524  { WSAEWOULDBLOCK, MBG_ERR_AGAIN }, // 10035L A non-blocking socket operation could not be completed immediately.
525  // { WSAEINPROGRESS // 10036L A blocking operation is currently executing.
526  // { WSAEALREADY // 10037L An operation was attempted on a non-blocking socket that already had an operation in progress.
527  { WSAENOTSOCK, MBG_ERR_NOT_A_SOCKET }, // 10038L An operation was attempted on something that is not a socket.
528  // { WSAEDESTADDRREQ // 10039L A required address was omitted from an operation on a socket.
529  // { WSAEMSGSIZE // 10040L A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself.
530  // { WSAEPROTOTYPE // 10041L A protocol was specified in the socket function call that does not support the semantics of the socket type requested.
531  // { WSAENOPROTOOPT // 10042L An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call.
532  // { WSAEPROTONOSUPPORT // 10043L The requested protocol has not been configured into the system, or no implementation for it exists.
533  // { WSAESOCKTNOSUPPORT // 10044L The support for the specified socket type does not exist in this address family.
534  // { WSAEOPNOTSUPP // 10045L The attempted operation is not supported for the type of object referenced.
535  // { WSAEPFNOSUPPORT // 10046L The protocol family has not been configured into the system or no implementation for it exists.
536  // { WSAEAFNOSUPPORT // 10047L An address incompatible with the requested protocol was used.
537  // { WSAEADDRINUSE // 10048L Only one usage of each socket address (protocol/network address/port) is normally permitted.
538  // { WSAEADDRNOTAVAIL // 10049L The requested address is not valid in its context.
539  // { WSAENETDOWN // 10050L A socket operation encountered a dead network.
540  // { WSAENETUNREACH // 10051L A socket operation was attempted to an unreachable network.
541  // { WSAENETRESET // 10052L The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.
542  // { WSAECONNABORTED // 10053L An established connection was aborted by the software in your host machine.
543  { WSAECONNRESET, MBG_ERR_CONN_RESET }, // 10054L An existing connection was forcibly closed by the remote host.
544  // { WSAENOBUFS // 10055L An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.
545  // { WSAEISCONN // 10056L A connect request was made on an already connected socket.
546  // { WSAENOTCONN // 10057L A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.
547  // { WSAESHUTDOWN // 10058L A request to send or receive data was disallowed because the socket had already been shut down in that direction with a previous shutdown call.
548  // { WSAETOOMANYREFS // 10059L Too many references to some kernel object.
549  // { WSAETIMEDOUT // 10060L A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
550  // { WSAECONNREFUSED // 10061L No connection could be made because the target machine actively refused it.
551  // { WSAELOOP // 10062L Cannot translate name.
552  // { WSAENAMETOOLONG // 10063L Name component or name was too long.
553  // { WSAEHOSTDOWN // 10064L A socket operation failed because the destination host was down.
554  // { WSAEHOSTUNREACH // 10065L A socket operation was attempted to an unreachable host.
555  // { WSAENOTEMPTY // 10066L Cannot remove a directory that is not empty.
556  // { WSAEPROCLIM // 10067L A Windows Sockets implementation may have a limit on the number of applications that may use it simultaneously.
557  // { WSAEUSERS // 10068L Ran out of quota.
558  // { WSAEDQUOT // 10069L Ran out of disk quota.
559  // { WSAESTALE // 10070L File handle reference is no longer available.
560  // { WSAEREMOTE // 10071L Item is not available locally.
561  // { WSASYSNOTREADY // 10091L WSAStartup cannot function at this time because the underlying system it uses to provide network services is currently unavailable.
562  // { WSAVERNOTSUPPORTED // 10092L The Windows Sockets version requested is not supported.
563  { WSANOTINITIALISED, MBG_ERR_SOCK_INIT }, // 10093L Either the application has not called WSAStartup, or WSAStartup failed.
564  // { WSAEDISCON // 10101L Returned by WSARecv or WSARecvFrom to indicate the remote party has initiated a graceful shutdown sequence.
565  // { WSAENOMORE // 10102L No more results can be returned by WSALookupServiceNext.
566  // { WSAECANCELLED // 10103L A call to WSALookupServiceEnd was made while this call was still processing. The call has been canceled.
567  // { WSAEINVALIDPROCTABLE // 10104L The procedure call table is invalid.
568  // { WSAEINVALIDPROVIDER // 10105L The requested service provider is invalid.
569  // { WSAEPROVIDERFAILEDINIT // 10106L The requested service provider could not be loaded or initialized.
570  // { WSASYSCALLFAILURE // 10107L A system call that should never fail has failed.
571  // { WSASERVICE_NOT_FOUND // 10108L No such service is known. The service cannot be found in the specified name space.
572  // { WSATYPE_NOT_FOUND // 10109L The specified class was not found.
573  // { WSA_E_NO_MORE // 10110L No more results can be returned by WSALookupServiceNext.
574  // { WSA_E_CANCELLED // 10111L A call to WSALookupServiceEnd was made while this call was still processing. The call has been canceled.
575  // { WSAEREFUSED // 10112L A database query failed because it was actively refused.
576  { WSAHOST_NOT_FOUND, MBG_ERR_HOST_NOT_FOUND }, // 11001L No such host is known.
577  // { WSATRY_AGAIN // 11002L This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server.
578  // { WSANO_RECOVERY // 11003L A non-recoverable error occurred during a database lookup.
579  // { WSANO_DATA // 11004L The requested name is valid, but no data of the requested type was found.
580  { 0, 0 } // end-of-table identifier
581 
582 }; // win32_wsa_err_table
583 
584 #endif // Windows user space
585 
586 #endif // defined( MBG_TGT_WIN32 )
587 
588 
589 
590 static /*HDR*/
601 int lookup_tbl_errno( int srch_errno, const ERRNO_CNV_ENTRY tbl[], int dflt_val )
602 {
603  const ERRNO_CNV_ENTRY *p;
604 
605  for ( p = tbl; p->srch_errno || p->mapped_errno; p++ )
606  if ( p->srch_errno == srch_errno )
607  return p->mapped_errno;
608 
609  return dflt_val;
610 
611 } // lookup_tbl_errno
612 
613 
614 #if !_USE_WIN32_PRIVATE_STATUS_CODES
615 
616 /*HDR*/
626 int mbg_errno_to_os( int err_no )
627 {
628  #if defined( MBG_TGT_KERNEL )
629 
630  #if defined( MBG_TGT_WIN32 )
631 
632  if ( err_no == MBG_SUCCESS )
633  return STATUS_SUCCESS;
634 
635  return lookup_tbl_errno( err_no, mbg_ioctl_to_ntstatus_table, STATUS_UNSUCCESSFUL );
636 
637  #elif defined( MBG_TGT_LINUX )
638 
639  #elif defined( MBG_TGT_FREEBSD )
640 
641  #elif defined( MBG_TGT_NETBSD )
642 
643  #else
644 
645  #error this needs to be implemented
646 
647  #endif
648 
649  #else // user space
650 
651  #if 0
652  #if defined( MBG_TGT_WIN32 ) // FIXME TODO
653  // Windows uses specially encoded numbers
654  return ( -err_no | 0xE0000000L );
655 
656  #elif defined( MBG_TGT_BSD )
657 
658  return -err_no;
659 
660  #else
661 
662  return err_no;
663 
664  #endif
665  #endif // 0
666 
667  #endif
668 
669  return err_no;
670 
671 } // mbg_errno_to_os
672 
673 #endif // _USE_WIN32_PRIVATE_STATUS_CODES
674 
675 
676 
677 /*HDR*/
685 const char *mbg_strerror( int mbg_errno )
686 {
688 
689  const MBG_CODE_NAME_TABLE_ENTRY *p;
690 
691  for ( p = tbl; p->name; p++ )
692  {
693  if ( mbg_errno == p->code )
694  return p->name;
695  }
696 
697  return "Unknown error";
698 
699 } // mbg_strerror
700 
701 
702 
703 #if !defined( _MBG_TGT_OMIT_ERR_MSG )
704 
705 /*HDR*/
714 bool mbg_cond_err_msg( int rc, const char *what )
715 {
716  return mbg_cond_err_msg_info( rc, what, NULL );
717 
718 } // mbg_cond_err_msg
719 
720 
721 
722 /*HDR*/
742 bool mbg_cond_err_msg_info( int rc, const char *what, const char *info )
743 {
744  if ( mbg_rc_is_error( rc ) )
745  {
746  if ( info && ( rc == MBG_ERR_NOT_SUPP_BY_DEV ) )
747  fprintf( stderr, "This device does not %s.\n", info );
748  else
749  fprintf( stderr, "** %s failed: %s (rc: %i)\n", what, mbg_strerror( rc ), rc );
750 
751  return true;
752  }
753 
754  return false;
755 
756 } // mbg_cond_err_msg_info
757 
758 #endif // !defined( _MBG_TGT_OMIT_ERR_MSG )
759 
760 
761 
762 #if defined( MBG_TGT_CVI )
763 
764 /*HDR*/
775 int mbg_cvi_rs232_error_to_mbg( int cvi_rc, const char *info )
776 {
777  #if DEBUG
778  if ( info )
779  fprintf( stderr, "%s, CVI RS-232 rc: %i\n", info, cvi_rc );
780  #else
781  (void) info; // avoid compiler warning
782  #endif
783 
784  return ( cvi_rc < 0 ) ? lookup_tbl_errno( cvi_rc, cvi_rs232_error_table, MBG_ERR_UNKNOWN ) : MBG_SUCCESS;
785 
786 } // mbg_cvi_rs232_error_to_mbg
787 
788 #endif
789 
790 
791 
792 #if defined( MBG_TGT_WIN32 )
793 
794 #if defined( MBG_TGT_KERNEL )
795 
796 /*HDR*/
805 int mbg_win32_ntstatus_to_mbg( NTSTATUS st, const char *info )
806 {
807  #if DEBUG
808  if ( info )
809  _mbgddmsg_2( DEBUG, MBG_LOG_INFO, "%s, ntstatus: 0x%08lX\n", info, (long) st );
810  #else
811  (void) info; // avoid compiler warning
812  #endif
813 
814  return lookup_tbl_errno( st, win32_kernel_status_table, MBG_ERR_UNKNOWN );
815 
816 } // mbg_win32_ntstatus_to_mbg
817 
818 
819 #else // Windows user space
820 
821 /*HDR*/
830 int mbg_win32_sys_err_to_mbg( DWORD win32_sys_rc, const char *info )
831 {
832  int rc = MBG_SUCCESS;
833 
834  if ( win32_sys_rc == ERROR_SUCCESS )
835  goto out;
836 
837  if ( win32_sys_rc & STATUS_CUSTOM_FLAG_MASK )
838  {
839  // This is a user-defined error code or message ID, e.g. returned by an IOCTL
840  // call. The lower 16 bits contain the (positive) error code while the upper
841  // 16 bits contain flags as specified for the Windows API in winerror.h.
842  // So we assume the error code is just the absolute value of one of the
843  // @ref MBG_ERROR_CODES, and we return the negated value.
844  rc = - (int) ( win32_sys_rc & 0xFFFF );
845  goto out;
846  }
847 
848 #if 0 // TODO FIXME
849  rc = (int) win32_sys_rc;
850 
851  if ( rc < 0 )
852  {
853  // If the error code is negative then this is a user-defined
854  // error code e.g. returned by an IOCTL call. In this case we
855  // assume it's one of the
856  goto out;
857  }
858 #endif
859 
860  rc = lookup_tbl_errno( win32_sys_rc, win32_sys_err_table, MBG_ERR_UNKNOWN );
861 
862 out:
863  #if DEBUG
864  if ( info )
865  fprintf( stderr, "%s, win32_sys_rc: 0x%08lX (%i) --> %i (%s)\n",
866  info, (long) win32_sys_rc, (int) win32_sys_rc,
867  rc, mbg_strerror( rc ) );
868  #else
869  (void) info; // avoid compiler warning
870  #endif
871 
872  return rc;
873 
874 } // mbg_win32_sys_err_to_mbg
875 
876 
877 
878 /*HDR*/
887 int mbg_win32_wsa_err_to_mbg( int wsa_err, const char *info )
888 {
889  #if DEBUG
890  if ( info )
891  fprintf( stderr, "%s, wsa_err: %i\n", info, wsa_err );
892  #else
893  (void) info; // avoid compiler warning
894  #endif
895 
896  // The WSA error code is only retrieved after an error has occurred, so
897  // we don't need care for the success case here.
898  return lookup_tbl_errno( wsa_err, win32_wsa_err_table, MBG_ERR_UNKNOWN );
899 
900 } // mbg_win32_wsa_err_to_mbg
901 
902 #endif // Windows user space
903 
904 #endif // defined( MBG_TGT_WIN32 )
905 
906 
907 
908 
909 #if defined( _MBG_TGT_HAS_POSIX_ERRNO )
910 
911 /*HDR*/
920 int mbg_posix_errno_to_mbg( int posix_errno, const char *info )
921 {
922  #if DEBUG && !defined( MBG_TGT_KERNEL )
923  if ( info )
924  fprintf( stderr, "%s: %s (errno: %i)\n", info,
925  strerror( posix_errno ), posix_errno );
926  #else
927  (void) info; // avoid compiler warning
928  #endif
929 
930  return lookup_tbl_errno( posix_errno, posix_errno_table, MBG_ERR_UNKNOWN );
931 
932 } // mbg_posix_errno_to_mbg
933 
934 #endif // defined( _MBG_TGT_HAS_POSIX_ERRNO )
935 
936 
937 
938 #if defined( _MBG_TGT_HAS_POSIX_H_ERRNO )
939 
940 /*HDR*/
956 int mbg_posix_h_errno_to_mbg( int posix_h_errno, const char *info )
957 {
958  #if DEBUG && !defined( MBG_TGT_KERNEL )
959  if ( info )
960  fprintf( stderr, "%s: %s (h_errno: %i)\n", info,
961  hstrerror( posix_h_errno ), posix_h_errno );
962  #else
963  (void) info; // avoid compiler warning
964  #endif
965 
966  return lookup_tbl_errno( posix_h_errno, posix_h_errno_table, MBG_ERR_UNKNOWN );
967 
968 } // mbg_posix_h_errno_to_mbg
969 
970 #endif // defined( _MBG_TGT_HAS_POSIX_H_ERRNO )
971 
972 
973 
974 #if !defined( _MBG_TGT_OMIT_LAST_ERROR )
975 
976 /*HDR*/
993 int mbg_get_last_error( const char *info )
994 {
995  #if defined( MBG_TGT_WIN32 )
996 
997  // Under Windows the "last error" code after a non-socket function
998  // ("Windows System Errors") has to be retrieved by calling GetLastError(),
999  // whereas the "last error" code from POSIX-like socket functions
1000  // ("Windows Sockets Error Codes") has to be retrieved by calling
1001  // WSAGetLastError().
1002  return mbg_win32_sys_err_to_mbg( GetLastError(), info );
1003 
1004  #elif defined( MBG_TGT_POSIX )
1005 
1006  // On POSIX systems the "last error" code is always stored in errno.
1007  return mbg_posix_errno_to_mbg( errno, info );
1008 
1009  #else
1010 
1011  // ### TODO #error This function is not supported for this target.
1012  return mbg_posix_errno_to_mbg( errno, info );
1013 
1014  #endif
1015 
1016 } // mbg_get_last_error
1017 
1018 
1019 
1020 #if !defined( _MBG_TGT_OMIT_SOCKET_ERRORS )
1021 
1022 /*HDR*/
1038 int mbg_get_last_socket_error( const char *info )
1039 {
1040  #if defined( MBG_TGT_CVI )
1041 
1042  #warning This needs to be implemented for CVI
1043  return MBG_ERR_UNKNOWN;
1044 
1045  #elif defined( MBG_TGT_WIN32 )
1046 
1047  #if !defined( MBG_TGT_KERNEL )
1048  // Under Windows the "last error" code after a POSIX-like socket
1049  // function ("Windows Sockets Error Code") has to be retrieved
1050  // by calling WSAGetLastError(), whereas the "last error" code
1051  // after a non-socket function ("Windows System Errors") has
1052  // to be retrieved by calling GetLastError().
1053  return mbg_win32_wsa_err_to_mbg( WSAGetLastError(), info );
1054  #else
1055  return MBG_ERR_GENERIC; // TODO should we only work with NTSTATUS codes in kernel mode?
1056  #endif
1057 
1058  #elif defined( MBG_TGT_POSIX )
1059 
1060  // On POSIX systems the "last error" code is always stored in errno.
1061  return mbg_posix_errno_to_mbg( errno, info );
1062 
1063  #else
1064 
1065  #error This function is not supported for this target.
1066 
1067  #endif
1068 
1069 } // mbg_get_last_socket_error
1070 
1071 
1072 
1073 /*HDR*/
1090 int mbg_get_gethostbyname_error( const char *info )
1091 {
1092  #if defined( MBG_TGT_CVI )
1093 
1094  #warning This needs to be implemented for CVI
1095  return MBG_ERR_UNKNOWN;
1096 
1097  #elif defined( MBG_TGT_WIN32 )
1098 
1099  #if !defined( MBG_TGT_KERNEL )
1100  return mbg_win32_wsa_err_to_mbg( WSAGetLastError(), info );
1101  #else
1102  return MBG_ERR_GENERIC;
1103  #endif
1104 
1105  #elif defined( MBG_TGT_POSIX )
1106 
1107  return mbg_posix_h_errno_to_mbg( h_errno, info );
1108 
1109  #else
1110 
1111  #error This function is not supported for this target.
1112 
1113  #endif
1114 
1115 } // mbg_get_gethostbyname_error
1116 
1117 #endif // !defined( _MBG_TGT_OMIT_SOCKET_ERRORS )
1118 
1119 #endif // !defined( _MBG_TGT_OMIT_LAST_ERROR )
1120 
1121 
1122 
1123 #if 0 // not yet finished
1124 // error handler for getaddressinfo()
1125 /*
1126  * Handle specific error returned by getaddressinfo()
1127  */
1128  /*HDR*/
1129 int mbg_gai_error( int rc, const char *info )
1130 {
1131  #if defined( MBG_TGT_CVI )
1132 
1133  #warning This needs to be implemented for CVI
1134  return MBG_ERR_UNKNOWN;
1135 
1136  #elif defined( MBG_TGT_WIN32 )
1137 
1138  return mbg_win32_wsa_err_to_mbg( WSAGetLastError(), info );
1139 
1140  #elif defined( MBG_TGT_POSIX )
1141 
1142  return mbg_posix_h_errno_to_mbg( h_errno, info );
1143 
1144  #else
1145 
1146  return MBG_ERR_UNKNOWN;
1147 
1148  #endif
1149 
1150 } // mbg_get_gai_error
1151 
1152 #endif
1153 
1154 
1155 
1156 #if defined( USE_MBG_ZLIB )
1157 
1158 /*HDR*/
1169 int mbg_zlib_error_to_mbg( int zlib_error, const char *info, const char *msg )
1170 {
1171  #if DEBUG
1172  if ( info && msg )
1173  fprintf( stderr, "%s: %s (zlib_error: %d)\n", info,
1174  msg, zlib_error );
1175  #endif
1176 
1177  switch ( zlib_error )
1178  {
1179  case Z_ERRNO: return mbg_get_last_error( info );
1180  case Z_MEM_ERROR: return MBG_ERR_NO_MEM;
1181  /*
1182  * All other zlib error codes are not specified any further.
1183  * So, it's hard to guess what they mean and we return MBG_UNSPEC so far.
1184  */
1185  default:
1186  return MBG_ERR_UNKNOWN;
1187  }
1188 
1189 } // mbg_zlib_error_to_mbg
1190 
1191 #endif // defined( USE_MBG_ZLIB )
1192 
1193 
#define MBG_ERR_HOST_NOT_FOUND
host not found
Definition: mbgerror.h:357
int mbg_win32_ntstatus_to_mbg(NTSTATUS st, const char *info)
Translate a Windows NTSTATUS code to one of the MBG_ERROR_CODES.
#define MBG_ERR_BAD_ADDRESS
Bad Address (like POSIX EFAULT)
Definition: mbgerror.h:388
#define MBG_ERR_INTR
interrupted function call
Definition: mbgerror.h:335
#define MBG_ERR_NO_DEV
No such device, or attempted an inappropriate function.
Definition: mbgerror.h:330
#define MBG_ERR_UNKNOWN
Unknown error code from external API.
Definition: mbgerror.h:366
#define MBG_ERR_INV_PARM
Invalid parameter.
Definition: mbgerror.h:329
bool mbg_cond_err_msg(int rc, const char *what)
Check if a value is an error code and print an associated error message.
Definition: mbgerror.c:714
int mapped_errno
Definition: mbgerror.c:152
#define MBG_ERR_EXIST
File exists.
Definition: mbgerror.h:353
int mbg_get_gethostbyname_error(const char *info)
Retrieve and convert last error after gethostbyname()
Definition: mbgerror.c:1090
A table entry which can be used to map codes to names.
Definition: words.h:532
#define MBG_ERR_GENERIC
Generic error.
Definition: mbgerror.h:269
#define MBG_ERR_RANGE
input parameter was out of range
Definition: mbgerror.h:347
static int lookup_tbl_errno(int srch_errno, const ERRNO_CNV_ENTRY tbl[], int dflt_val)
Lookup some error code in a conversion table.
Definition: mbgerror.c:601
#define MBG_ERR_NOT_A_SOCKET
Socket descriptor is not a socket.
Definition: mbgerror.h:324
#define MBG_ERR_NOT_READY
Bus-level device is temp. unable to respond e.g. during init. after RESET.
Definition: mbgerror.h:277
#define MBG_ERR_TIMER
Timer expired (e.g. stream timeout on USB disconnect)
Definition: mbgerror.h:369
int mbg_posix_h_errno_to_mbg(int posix_h_errno, const char *info)
Translate a POSIX h_errno error code to one of the MBG_ERROR_CODES.
Definition: mbgerror.c:956
Definition: mbgerror.c:149
#define MBG_ERR_BUFFER_TOO_SMALL
Buffer is too small.
Definition: mbgerror.h:383
int mbg_win32_wsa_err_to_mbg(int wsa_err, const char *info)
Translate a Windows socket API error code to one of the MBG_ERROR_CODES.
int mbg_posix_errno_to_mbg(int posix_errno, const char *info)
Translate a POSIX errno error code to one of the MBG_ERROR_CODES.
Definition: mbgerror.c:920
#define MBG_ERR_IRQ_UNSAFE
Enabled IRQ of bus-level device is unsafe with this firmware/ASIC version.
Definition: mbgerror.h:293
#define MBG_ERR_INV_HANDLE
invalid file/device handle specified
Definition: mbgerror.h:339
#define MBG_ERR_TIMEOUT
Timeout accessing the device.
Definition: mbgerror.h:270
#define MBG_ERR_NO_ENTITY
no such file or directory
Definition: mbgerror.h:355
#define MBG_ERR_NO_SPACE
insufficient disk space left on the device
Definition: mbgerror.h:361
static ERRNO_CNV_ENTRY posix_h_errno_table[]
Definition: mbgerror.c:234
#define MBG_ERR_IO
Input/output error.
Definition: mbgerror.h:328
#define MBG_ERR_UNSPEC
Unspecified error.
Definition: mbgerror.h:312
#define MBG_ERR_CONN_RESET
connection reset by peer
Definition: mbgerror.h:358
bool mbg_cond_err_msg_info(int rc, const char *what, const char *info)
Check if a value is an general or a "not supported" error code and print an associated message...
Definition: mbgerror.c:742
#define MBG_ERR_INV_DEV_REQUEST
IOCTL call not supported by driver.
Definition: mbgerror.h:285
int * NTSTATUS
Definition: mbgerror.h:230
#define MBG_ERR_NOT_FOUND
Specified item not found.
Definition: mbgerror.h:331
#define MBG_ERR_NO_MEM
Failed to allocate memory.
Definition: mbgerror.h:282
#define MBG_ERR_ACCESS
Access denied, e.g. when trying to access a file or device without sufficient permissions.
Definition: mbgerror.h:336
long code
Definition: words.h:534
int mbg_zlib_error_to_mbg(int zlib_error, const char *info, const char *msg)
Retrieve and convert last zlib internal error code.
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
Definition: mbgerror.h:259
#define _mbgddmsg_2(_f, _lvl, _fmt, _p1, _p2)
Definition: mbgddmsg.h:324
uint32_t DWORD
Definition: mbgerror.h:222
int mbg_win32_sys_err_to_mbg(DWORD win32_sys_rc, const char *info)
Translate a Windows non-socket API return code to one of the MBG_RETURN_CODES.
#define MBG_ERR_BUSY
Device or resource busy, can&#39;t be used.
Definition: mbgerror.h:338
#define MBG_ERR_PIPE
pipe error
Definition: mbgerror.h:334
#define MBG_ERR_PERM
Operation not permitted, e.g. when trying to set the system time without sufficient permissions...
Definition: mbgerror.h:337
int mbg_errno_to_os(int err_no)
Convert one of the MBG_ERROR_CODES to an OS-specific format.
Definition: mbgerror.c:626
#define MBG_ERR_STR_TABLE_ENG
Strings associated with MBG_RETURN_CODES.
Definition: mbgerror.h:550
const char * name
Definition: words.h:535
static ERRNO_CNV_ENTRY posix_errno_table[]
Mappings between Meinberg error codes and POSIX error codes.
Definition: mbgerror.c:173
#define MBG_ERR_NOT_SUPP_BY_DEV
Command or feature not supported by device.
Definition: mbgerror.h:286
#define MBG_ERR_OVERFLOW
range or buffer overflow
Definition: mbgerror.h:333
int mbg_get_last_socket_error(const char *info)
Get and translate last error after socket function call.
Definition: mbgerror.c:1038
#define mbg_rc_is_error(_rc)
Definition: mbgerror.h:617
const char * mbg_strerror(int mbg_errno)
Return an error string associated with the MBG_ERROR_CODES.
Definition: mbgerror.c:685
#define MBG_ERR_AGAIN
on a non-blocking socket.
Definition: mbgerror.h:371
int mbg_cvi_rs232_error_to_mbg(int cvi_rc, const char *info)
Translate an error code from the Labwindows/CVI RS-232 library to one of the MBG_ERROR_CODES.
int mbg_get_last_error(const char *info)
Get and translate last error after non-socket function call.
Definition: mbgerror.c:993
int srch_errno
Definition: mbgerror.c:151
#define MBG_ERR_SOCK_INIT
Socket interface not initialized, or failed to initialize.
Definition: mbgerror.h:322