2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
24 #ifndef WIN32_LEAN_AND_MEAN
25 # define WIN32_LEAN_AND_MEAN
28 #if defined(HAVE_WINSOCK2_H) && HAVE_WINSOCK2_H
29 # include <winsock2.h>
32 #if defined(HAVE_WS2TCPIP_H) && HAVE_WS2TCPIP_H
33 # include <ws2tcpip.h>
36 #if defined(HAVE_IO_H) && HAVE_IO_H
45 static inline int translate_windows_error() {
46 int local_errno = WSAGetLastError();
48 switch (local_errno) {
50 local_errno = EINPROGRESS;
58 local_errno = ECONNREFUSED;
62 local_errno = ENETUNREACH;
66 local_errno = ETIMEDOUT;
70 local_errno = ECONNRESET;
74 local_errno = EADDRINUSE;
78 local_errno = EOPNOTSUPP;
82 local_errno = ENOPROTOOPT;
92 static inline char *basename(const char *filename) {
93 static char base[MAX_PATH * 2], ext[MAX_PATH], *ptr;
94 (void) _splitpath_s(filename, NULL, 0, NULL, 0, base, MAX_PATH, ext, MAX_PATH);
95 strcat_s(base, MAX_PATH * 2 - 1, ext);
99 static inline char *realpath(const char *path, char real[MAX_PATH]) {
100 return _fullpath(real, path, MAX_PATH);