PostgreSQL Source Code  git master
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)
 

Functions

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

Macro Definition Documentation

◆ close

#define close (   a)    _close(a)

Definition at line 12 of file win32.h.

◆ read

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

Definition at line 13 of file win32.h.

◆ write

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

Definition at line 14 of file win32.h.

Function Documentation

◆ winsock_strerror()

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

Definition at line 277 of file win32.c.

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

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