Back to index

nagios-plugins  1.4.16
Defines | Functions
w32sock.h File Reference
#include <errno.h>
#include <fcntl.h>
#include <io.h>

Go to the source code of this file.

Defines

#define FD_TO_SOCKET(fd)   ((SOCKET) _get_osfhandle ((fd)))
#define SOCKET_TO_FD(fh)   (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY))

Functions

static void set_winsock_errno (void)

Define Documentation

#define FD_TO_SOCKET (   fd)    ((SOCKET) _get_osfhandle ((fd)))

Definition at line 28 of file w32sock.h.

#define SOCKET_TO_FD (   fh)    (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY))

Definition at line 29 of file w32sock.h.


Function Documentation

static void set_winsock_errno ( void  ) [inline, static]

Definition at line 32 of file w32sock.h.

{
  int err = WSAGetLastError ();

  /* Map some WSAE* errors to the runtime library's error codes.  */
  switch (err)
    {
    case WSA_INVALID_HANDLE:
      errno = EBADF;
      break;
    case WSA_NOT_ENOUGH_MEMORY:
      errno = ENOMEM;
      break;
    case WSA_INVALID_PARAMETER:
      errno = EINVAL;
      break;
    case WSAEWOULDBLOCK:
      errno = EWOULDBLOCK;
      break;
    case WSAENAMETOOLONG:
      errno = ENAMETOOLONG;
      break;
    case WSAENOTEMPTY:
      errno = ENOTEMPTY;
      break;
    default:
      errno = (err > 10000 && err < 10025) ? err - 10000 : err;
      break;
    }
}