27 static char *win32_socket_strerror(
int errnum,
char *
buf,
size_t buflen);
39 return pg_strerror_r(errnum, errorstr_buf,
sizeof(errorstr_buf));
53 if (errnum >= 10000 && errnum <= 11999)
54 return win32_socket_strerror(errnum,
buf, buflen);
67 if (
str == NULL || *
str ==
'\0' || *
str ==
'?')
72 snprintf(
buf, buflen,
_(
"operating system error %d"), errnum);
87 #ifdef HAVE_STRERROR_R
124 return "EADDRNOTAVAIL";
126 return "EAFNOSUPPORT";
146 return "ECONNABORTED";
148 return "ECONNREFUSED";
164 return "EHOSTUNREACH";
168 return "EINPROGRESS";
190 return "ENAMETOOLONG";
196 return "ENETUNREACH";
229 #if defined(EOPNOTSUPP) && (!defined(ENOTSUP) || (EOPNOTSUPP != ENOTSUP))
242 return "EPROTONOSUPPORT";
257 #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
259 return "EWOULDBLOCK";
275 win32_socket_strerror(
int errnum,
char *
buf,
size_t buflen)
277 static HANDLE handleDLL = INVALID_HANDLE_VALUE;
279 if (handleDLL == INVALID_HANDLE_VALUE)
281 handleDLL = LoadLibraryEx(
"netmsg.dll", NULL,
282 DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
283 if (handleDLL == NULL)
286 "winsock error %d (could not load netmsg.dll to translate: error code %lu)",
287 errnum, GetLastError());
292 ZeroMemory(
buf, buflen);
293 if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
294 FORMAT_MESSAGE_FROM_SYSTEM |
295 FORMAT_MESSAGE_FROM_HMODULE,
298 MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
304 snprintf(
buf, buflen,
"unrecognized winsock error %d", errnum);
#define PG_STRERROR_R_BUFLEN
size_t strlcpy(char *dst, const char *src, size_t siz)
static char * get_errno_symbol(int errnum)
char * pg_strerror_r(int errnum, char *buf, size_t buflen)
static char * gnuish_strerror_r(int errnum, char *buf, size_t buflen)
char * pg_strerror(int errnum)