mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
Fix undefined behavior + make some ifdefs more readable
This commit is contained in:
parent
d32eee7627
commit
d0c5c66bd6
1 changed files with 14 additions and 13 deletions
27
httplib.h
27
httplib.h
|
@ -5,38 +5,39 @@
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef _CPPHTTPLIB_HTTPLIB_H_
|
#ifndef CPPHTTPLIB_HTTPLIB_H
|
||||||
#define _CPPHTTPLIB_HTTPLIB_H_
|
#define CPPHTTPLIB_HTTPLIB_H
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
#endif
|
#endif //_CRT_SECURE_NO_WARNINGS
|
||||||
|
|
||||||
#ifndef _CRT_NONSTDC_NO_DEPRECATE
|
#ifndef _CRT_NONSTDC_NO_DEPRECATE
|
||||||
#define _CRT_NONSTDC_NO_DEPRECATE
|
#define _CRT_NONSTDC_NO_DEPRECATE
|
||||||
#endif
|
#endif //_CRT_NONSTDC_NO_DEPRECATE
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||||
#define snprintf _snprintf_s
|
#define snprintf _snprintf_s
|
||||||
#endif
|
#endif // _MSC_VER
|
||||||
|
|
||||||
#ifndef S_ISREG
|
#ifndef S_ISREG
|
||||||
#define S_ISREG(m) (((m)&S_IFREG)==S_IFREG)
|
#define S_ISREG(m) (((m)&S_IFREG)==S_IFREG)
|
||||||
#endif
|
#endif //S_ISREG
|
||||||
|
|
||||||
#ifndef S_ISDIR
|
#ifndef S_ISDIR
|
||||||
#define S_ISDIR(m) (((m)&S_IFDIR)==S_IFDIR)
|
#define S_ISDIR(m) (((m)&S_IFDIR)==S_IFDIR)
|
||||||
#endif
|
#endif //S_ISDIR
|
||||||
|
|
||||||
|
#define NOMINMAX
|
||||||
|
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
|
||||||
#undef min
|
|
||||||
#undef max
|
|
||||||
|
|
||||||
#ifndef strcasecmp
|
#ifndef strcasecmp
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#endif
|
#endif //strcasecmp
|
||||||
|
|
||||||
typedef SOCKET socket_t;
|
typedef SOCKET socket_t;
|
||||||
#else
|
#else
|
||||||
|
@ -52,7 +53,7 @@ typedef SOCKET socket_t;
|
||||||
|
|
||||||
typedef int socket_t;
|
typedef int socket_t;
|
||||||
#define INVALID_SOCKET (-1)
|
#define INVALID_SOCKET (-1)
|
||||||
#endif
|
#endif //_WIN32
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -2390,6 +2391,6 @@ inline bool SSLClient::read_and_close_socket(socket_t sock, Request& req, Respon
|
||||||
|
|
||||||
} // namespace httplib
|
} // namespace httplib
|
||||||
|
|
||||||
#endif
|
#endif //CPPHTTPLIB_HTTPLIB_H
|
||||||
|
|
||||||
// vim: et ts=4 sw=4 cin cino={1s ff=unix
|
// vim: et ts=4 sw=4 cin cino={1s ff=unix
|
||||||
|
|
Loading…
Reference in a new issue