PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
win32.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#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)
 

Macro Definition Documentation

#define ECONNRESET   WSAECONNRESET

Definition at line 23 of file win32.h.

#define EINPROGRESS   WSAEINPROGRESS

Definition at line 26 of file win32.h.

#define EINTR   WSAEINTR

Definition at line 18 of file win32.h.

#define EWOULDBLOCK   WSAEWOULDBLOCK

Definition at line 20 of file win32.h.

Function Documentation

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

Definition at line 281 of file win32.c.

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

282 {
283  unsigned long flags;
284  int offs,
285  i;
286  int success = LookupWSErrorMessage(err, strerrbuf);
287 
288  for (i = 0; !success && i < DLLS_SIZE; i++)
289  {
290 
291  if (!dlls[i].loaded)
292  {
293  dlls[i].loaded = 1; /* Only load once */
294  dlls[i].handle = (void *) LoadLibraryEx(
295  dlls[i].dll_name,
296  0,
297  LOAD_LIBRARY_AS_DATAFILE);
298  }
299 
300  if (dlls[i].dll_name && !dlls[i].handle)
301  continue; /* Didn't load */
302 
303  flags = FORMAT_MESSAGE_FROM_SYSTEM
304  | FORMAT_MESSAGE_IGNORE_INSERTS
305  | (dlls[i].handle ? FORMAT_MESSAGE_FROM_HMODULE : 0);
306 
307  success = 0 != FormatMessage(
308  flags,
309  dlls[i].handle, err,
310  MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
311  strerrbuf, buflen - 64,
312  0
313  );
314  }
315 
316  if (!success)
317  sprintf(strerrbuf, libpq_gettext("unrecognized socket error: 0x%08X/%d"), err, err);
318  else
319  {
320  strerrbuf[buflen - 1] = '\0';
321  offs = strlen(strerrbuf);
322  if (offs > (int) buflen - 64)
323  offs = buflen - 64;
324  sprintf(strerrbuf + offs, " (0x%08X/%d)", err, err);
325  }
326  return strerrbuf;
327 }
#define libpq_gettext(x)
Definition: win32.c:39
struct MessageDLL dlls[]
static bool success
Definition: pg_basebackup.c:96
static int LookupWSErrorMessage(DWORD err, char *dest)
Definition: win32.c:218
#define DLLS_SIZE
Definition: win32.c:268
int loaded
Definition: win32.c:238
void * handle
Definition: win32.c:237
int i