Header And Logo

PostgreSQL
| The world's most advanced open source database.

Defines | Functions

win32.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define close(a)   _close(a)
#define read(a, b, c)   _read(a,b,c)
#define write(a, b, c)   _write(a,b,c)
#define EINTR   WSAEINTR
#define EWOULDBLOCK   WSAEWOULDBLOCK
#define ECONNRESET   WSAECONNRESET
#define EINPROGRESS   WSAEINPROGRESS

Functions

const char * winsock_strerror (int err, char *strerrbuf, size_t buflen)

Define Documentation

#define close (   a  )     _close(a)
#define ECONNRESET   WSAECONNRESET

Definition at line 29 of file win32.h.

#define EINPROGRESS   WSAEINPROGRESS

Definition at line 32 of file win32.h.

#define EINTR   WSAEINTR

Definition at line 24 of file win32.h.

#define EWOULDBLOCK   WSAEWOULDBLOCK

Definition at line 26 of file win32.h.

#define read (   a,
  b,
  c 
)    _read(a,b,c)
#define write (   a,
  b,
  c 
)    _write(a,b,c)

Function Documentation

const char* winsock_strerror ( int  err,
char *  strerrbuf,
size_t  buflen 
)

Definition at line 286 of file win32.c.

References dlls, MessageDLL::handle, i, libpq_gettext, MessageDLL::loaded, and LookupWSErrorMessage().

{
    unsigned long flags;
    int         offs,
                i;
    int         success = LookupWSErrorMessage(err, strerrbuf);

    for (i = 0; !success && i < DLLS_SIZE; i++)
    {

        if (!dlls[i].loaded)
        {
            dlls[i].loaded = 1; /* Only load once */
            dlls[i].handle = (void *) LoadLibraryEx(
                                                    dlls[i].dll_name,
                                                    0,
                                                    LOAD_LIBRARY_AS_DATAFILE);
        }

        if (dlls[i].dll_name && !dlls[i].handle)
            continue;           /* Didn't load */

        flags = FORMAT_MESSAGE_FROM_SYSTEM
            | FORMAT_MESSAGE_IGNORE_INSERTS
            | (dlls[i].handle ? FORMAT_MESSAGE_FROM_HMODULE : 0);

        success = 0 != FormatMessage(
                                     flags,
                                     dlls[i].handle, err,
                                   MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
                                     strerrbuf, buflen - 64,
                                     0
            );
    }

    if (!success)
        sprintf(strerrbuf, libpq_gettext("unrecognized socket error: 0x%08X/%d"), err, err);
    else
    {
        strerrbuf[buflen - 1] = '\0';
        offs = strlen(strerrbuf);
        if (offs > (int) buflen - 64)
            offs = buflen - 64;
        sprintf(strerrbuf + offs, " (0x%08X/%d)", err, err);
    }
    return strerrbuf;
}