Commit 7ceb5698 authored by Curl Upstream's avatar Curl Upstream Committed by Brad King
Browse files

curl 2020-08-19 (9d954e49)

Code extracted from:

    https://github.com/curl/curl.git

at commit 9d954e49bce3706a9a2efb119ecd05767f0f2a9e (curl-7_72_0).
parent 4446fda8
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.haxx.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
###########################################################################
#[=======================================================================[.rst:
FindZstd
----------
Find the zstd library
Result Variables
^^^^^^^^^^^^^^^^
``Zstd_FOUND``
System has zstd
``Zstd_INCLUDE_DIRS``
The zstd include directories.
``Zstd_LIBRARIES``
The libraries needed to use zstd
#]=======================================================================]
if(UNIX)
find_package(PkgConfig QUIET)
pkg_search_module(PC_Zstd libzstd)
endif()
find_path(Zstd_INCLUDE_DIR zstd.h
HINTS
${PC_Zstd_INCLUDEDIR}
${PC_Zstd_INCLUDE_DIRS}
)
find_library(Zstd_LIBRARY NAMES zstd
HINTS
${PC_Zstd_LIBDIR}
${PC_Zstd_LIBRARY_DIRS}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Zstd
REQUIRED_VARS
Zstd_LIBRARY
Zstd_INCLUDE_DIR
)
if(Zstd_FOUND)
set(Zstd_LIBRARIES ${Zstd_LIBRARY})
set(Zstd_INCLUDE_DIRS ${Zstd_INCLUDE_DIR})
endif()
mark_as_advanced(Zstd_INCLUDE_DIRS Zstd_LIBRARIES)
......@@ -82,12 +82,15 @@ if(WIN32)
set(CURL_TARGET_WINDOWS_VERSION "" CACHE STRING "Minimum target Windows version as hex string")
if(CURL_TARGET_WINDOWS_VERSION)
add_definitions(-D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION})
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION}")
elseif(ENABLE_INET_PTON)
# _WIN32_WINNT_VISTA (0x0600)
add_definitions(-D_WIN32_WINNT=0x0600)
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0600")
else()
# _WIN32_WINNT_WINXP (0x0501)
add_definitions(-D_WIN32_WINNT=0x0501)
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0501")
endif()
endif()
option(CURL_LTO "Turn on compiler Link Time Optimizations" OFF)
......@@ -101,7 +104,7 @@ option(ENABLE_CURLDEBUG "Set to ON to build with TrackMemory feature enabled" OF
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
if(PICKY_COMPILER)
foreach(_CCOPT -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wno-sign-conversion -Wvla -Wdouble-promotion -Wno-system-headers -Wno-pedantic-ms-format)
foreach(_CCOPT -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion)
# surprisingly, CHECK_C_COMPILER_FLAG needs a new variable to store each new
# test result in.
string(MAKE_C_IDENTIFIER "OPT${_CCOPT}" _optvarname)
......@@ -110,6 +113,15 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT}")
endif()
endforeach()
foreach(_CCOPT long-long multichar format-nonliteral sign-conversion system-headers pedantic-ms-format)
# GCC only warns about unknown -Wno- options if there are also other diagnostic messages,
# so test for the positive form instead
string(MAKE_C_IDENTIFIER "OPT${_CCOPT}" _optvarname)
check_c_compiler_flag("-W${_CCOPT}" ${_optvarname})
if(${_optvarname})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-${_CCOPT}")
endif()
endforeach()
endif()
endif()
......@@ -213,7 +225,10 @@ if(ENABLE_IPV6 AND NOT WIN32)
endif()
endif()
curl_nroff_check()
if(USE_MANUAL)
#nroff is currently only used when USE_MANUAL is set, so we can prevent the warning of no *NROFF if USE_MANUAL is OFF (or not defined), by not even looking for NROFF..
curl_nroff_check()
endif()
find_package(Perl)
cmake_dependent_option(ENABLE_MANUAL "to provide the built-in manual"
......@@ -297,14 +312,17 @@ endif()
# check SSL libraries
# TODO support GnuTLS
if(CMAKE_USE_WINSSL)
message(FATAL_ERROR "The cmake option CMAKE_USE_WINSSL was renamed to CMAKE_USE_SCHANNEL.")
endif()
if(APPLE)
option(CMAKE_USE_SECTRANSP "enable Apple OS native SSL/TLS" OFF)
endif()
if(WIN32)
option(CMAKE_USE_WINSSL "enable Windows native SSL/TLS" OFF)
option(CMAKE_USE_SCHANNEL "enable Windows native SSL/TLS" OFF)
cmake_dependent_option(CURL_WINDOWS_SSPI "Use windows libraries to allow NTLM authentication without openssl" ON
CMAKE_USE_WINSSL OFF)
CMAKE_USE_SCHANNEL OFF)
endif()
option(CMAKE_USE_MBEDTLS "Enable mbedTLS for SSL/TLS" OFF)
option(CMAKE_USE_BEARSSL "Enable BearSSL for SSL/TLS" OFF)
......@@ -312,13 +330,13 @@ option(CMAKE_USE_NSS "Enable NSS for SSL/TLS" OFF)
option(CMAKE_USE_WOLFSSL "enable wolfSSL for SSL/TLS" OFF)
set(openssl_default ON)
if(WIN32 OR CMAKE_USE_SECTRANSP OR CMAKE_USE_WINSSL OR CMAKE_USE_MBEDTLS OR CMAKE_USE_NSS OR CMAKE_USE_WOLFSSL)
if(WIN32 OR CMAKE_USE_SECTRANSP OR CMAKE_USE_SCHANNEL OR CMAKE_USE_MBEDTLS OR CMAKE_USE_NSS OR CMAKE_USE_WOLFSSL)
set(openssl_default OFF)
endif()
option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ${openssl_default})
count_true(enabled_ssl_options_count
CMAKE_USE_WINSSL
CMAKE_USE_SCHANNEL
CMAKE_USE_SECTRANSP
CMAKE_USE_OPENSSL
CMAKE_USE_MBEDTLS
......@@ -330,10 +348,10 @@ if(enabled_ssl_options_count GREATER "1")
set(CURL_WITH_MULTI_SSL ON)
endif()
if(CMAKE_USE_WINSSL)
if(CMAKE_USE_SCHANNEL)
set(SSL_ENABLED ON)
set(USE_SCHANNEL ON) # Windows native SSL/TLS support
set(USE_WINDOWS_SSPI ON) # CMAKE_USE_WINSSL implies CURL_WINDOWS_SSPI
set(USE_WINDOWS_SSPI ON) # CMAKE_USE_SCHANNEL implies CURL_WINDOWS_SSPI
list(APPEND CURL_LIBS "crypt32")
endif()
if(CURL_WINDOWS_SSPI)
......@@ -638,6 +656,22 @@ if(CURL_BROTLI)
endif()
endif()
option(CURL_ZSTD "Set to ON to enable building curl with zstd support." OFF)
set(HAVE_ZSTD OFF)
if(CURL_ZSTD)
find_package(Zstd REQUIRED)
cmake_push_check_state()
set(CMAKE_REQUIRED_INCLUDES ${Zstd_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${Zstd_LIBRARIES})
check_symbol_exists(ZSTD_createDStream "zstd.h" HAVE_ZSTD_CREATEDSTREAM)
cmake_pop_check_state()
if(Zstd_FOUND AND HAVE_ZSTD_CREATEDSTREAM)
set(HAVE_ZSTD ON)
list(APPEND CURL_LIBS ${Zstd_LIBRARIES})
include_directories(${Zstd_INCLUDE_DIRS})
endif()
endif()
#libSSH2
option(CMAKE_USE_LIBSSH2 "Use libSSH2" ON)
mark_as_advanced(CMAKE_USE_LIBSSH2)
......@@ -1319,11 +1353,13 @@ _add_if("SSL" SSL_ENABLED)
_add_if("IPv6" ENABLE_IPV6)
_add_if("unix-sockets" USE_UNIX_SOCKETS)
_add_if("libz" HAVE_LIBZ)
_add_if("brotli" HAVE_BROTLI)
_add_if("zstd" HAVE_ZSTD)
_add_if("AsynchDNS" USE_ARES OR USE_THREADS_POSIX OR USE_THREADS_WIN32)
_add_if("IDN" HAVE_LIBIDN2)
_add_if("Largefile" (CURL_SIZEOF_CURL_OFF_T GREATER 4) AND
((SIZEOF_OFF_T GREATER 4) OR USE_WIN32_LARGE_FILES))
# TODO SSP1 (WinSSL) check is missing
# TODO SSP1 (Schannel) check is missing
_add_if("SSPI" USE_WINDOWS_SSPI)
_add_if("GSS-API" HAVE_GSSAPI)
_add_if("alt-svc" ENABLE_ALT_SVC)
......@@ -1385,7 +1421,7 @@ message(STATUS "Enabled protocols: ${SUPPORT_PROTOCOLS}")
# Clear list and collect SSL backends
set(_items)
_add_if("WinSSL" SSL_ENABLED AND USE_WINDOWS_SSPI)
_add_if("Schannel" SSL_ENABLED AND USE_WINDOWS_SSPI)
_add_if("OpenSSL" SSL_ENABLED AND USE_OPENSSL)
_add_if("Secure Transport" SSL_ENABLED AND USE_SECTRANSP)
_add_if("mbedTLS" SSL_ENABLED AND USE_MBEDTLS)
......
......@@ -2634,10 +2634,6 @@ typedef enum {
CURLINFO_PROXY_SSL_VERIFYRESULT = CURLINFO_LONG + 47,
CURLINFO_PROTOCOL = CURLINFO_LONG + 48,
CURLINFO_SCHEME = CURLINFO_STRING + 49,
/* Fill in new entries below here! */
/* Preferably these would be defined conditionally based on the
sizeof curl_off_t being 64-bits */
CURLINFO_TOTAL_TIME_T = CURLINFO_OFF_T + 50,
CURLINFO_NAMELOOKUP_TIME_T = CURLINFO_OFF_T + 51,
CURLINFO_CONNECT_TIME_T = CURLINFO_OFF_T + 52,
......@@ -2646,8 +2642,9 @@ typedef enum {
CURLINFO_REDIRECT_TIME_T = CURLINFO_OFF_T + 55,
CURLINFO_APPCONNECT_TIME_T = CURLINFO_OFF_T + 56,
CURLINFO_RETRY_AFTER = CURLINFO_OFF_T + 57,
CURLINFO_EFFECTIVE_METHOD = CURLINFO_STRING + 58,
CURLINFO_LASTONE = 57
CURLINFO_LASTONE = 58
} CURLINFO;
/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as
......@@ -2748,6 +2745,7 @@ typedef enum {
CURLVERSION_FIFTH,
CURLVERSION_SIXTH,
CURLVERSION_SEVENTH,
CURLVERSION_EIGHTH,
CURLVERSION_LAST /* never actually use this */
} CURLversion;
......@@ -2756,7 +2754,7 @@ typedef enum {
meant to be a built-in version number for what kind of struct the caller
expects. If the struct ever changes, we redefine the NOW to another enum
from above. */
#define CURLVERSION_NOW CURLVERSION_SEVENTH
#define CURLVERSION_NOW CURLVERSION_EIGHTH
struct curl_version_info_data {
CURLversion age; /* age of the returned struct */
......@@ -2802,6 +2800,11 @@ struct curl_version_info_data {
const char *capath; /* the built-in default CURLOPT_CAPATH, might
be NULL */
/* These fields were added in CURLVERSION_EIGHTH */
unsigned int zstd_ver_num; /* Numeric Zstd version
(MAJOR << 24) | (MINOR << 12) | PATCH */
const char *zstd_version; /* human readable string. */
};
typedef struct curl_version_info_data curl_version_info_data;
......@@ -2836,6 +2839,8 @@ typedef struct curl_version_info_data curl_version_info_data;
#define CURL_VERSION_BROTLI (1<<23) /* Brotli features are present. */
#define CURL_VERSION_ALTSVC (1<<24) /* Alt-Svc handling built-in */
#define CURL_VERSION_HTTP3 (1<<25) /* HTTP3 support built-in */
#define CURL_VERSION_ZSTD (1<<26) /* zstd features are present */
#define CURL_VERSION_UNICODE (1<<27) /* Unicode support on Windows */
/*
* NAME curl_version_info()
......
......@@ -30,13 +30,13 @@
/* This is the version number of the libcurl package from which this header
file origins: */
#define LIBCURL_VERSION "7.71.1-DEV"
#define LIBCURL_VERSION "7.72.0-DEV"
/* The numeric version number is also available "in parts" by using these
defines: */
#define LIBCURL_VERSION_MAJOR 7
#define LIBCURL_VERSION_MINOR 71
#define LIBCURL_VERSION_PATCH 1
#define LIBCURL_VERSION_MINOR 72
#define LIBCURL_VERSION_PATCH 0
/* This is the numeric version of the libcurl version number, meant for easier
parsing and comparisons by programs. The LIBCURL_VERSION_NUM define will
......@@ -57,7 +57,7 @@
CURL_VERSION_BITS() macro since curl's own configure script greps for it
and needs it to contain the full number.
*/
#define LIBCURL_VERSION_NUM 0x074701
#define LIBCURL_VERSION_NUM 0x074800
/*
* This is the date and time when the full source package was created. The
......
......@@ -427,12 +427,14 @@ CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
* Name: curl_push_callback
*
* Desc: This callback gets called when a new stream is being pushed by the
* server. It approves or denies the new stream.
* server. It approves or denies the new stream. It can also decide
* to completely fail the connection.
*
* Returns: CURL_PUSH_OK or CURL_PUSH_DENY.
* Returns: CURL_PUSH_OK, CURL_PUSH_DENY or CURL_PUSH_ERROROUT
*/
#define CURL_PUSH_OK 0
#define CURL_PUSH_DENY 1
#define CURL_PUSH_OK 0
#define CURL_PUSH_DENY 1
#define CURL_PUSH_ERROROUT 2 /* added in 7.72.0 */
struct curl_pushheaders; /* forward declaration only */
......
......@@ -60,7 +60,8 @@ LIB_CFILES = altsvc.c amigaos.c asyn-ares.c asyn-thread.c base64.c \
sendf.c setopt.c sha256.c share.c slist.c smb.c smtp.c socketpair.c socks.c \
socks_gssapi.c socks_sspi.c speedcheck.c splay.c strcase.c strdup.c \
strerror.c strtok.c strtoofft.c system_win32.c telnet.c tftp.c timeval.c \
transfer.c urlapi.c version.c warnless.c wildcard.c x509asn1.c dynbuf.c
transfer.c urlapi.c version.c warnless.c wildcard.c x509asn1.c dynbuf.c \
version_win32.c
LIB_HFILES = altsvc.h amigaos.h arpa_telnet.h asyn.h conncache.h connect.h \
content_encoding.h cookie.h curl_addrinfo.h curl_base64.h curl_ctype.h \
......@@ -79,7 +80,7 @@ LIB_HFILES = altsvc.h amigaos.h arpa_telnet.h asyn.h conncache.h connect.h \
smb.h smtp.h sockaddr.h socketpair.h socks.h speedcheck.h splay.h strcase.h \
strdup.h strerror.h strtok.h strtoofft.h system_win32.h telnet.h tftp.h \
timeval.h transfer.h urlapi-int.h urldata.h warnless.h wildcard.h \
x509asn1.h dynbuf.h
x509asn1.h dynbuf.h version_win32.h
LIB_RCFILES = libcurl.rc
......
......@@ -633,7 +633,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
*waitp = 0; /* default to synchronous response */
#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
#ifdef ENABLE_IPV6
switch(conn->ip_version) {
default:
#if ARES_VERSION >= 0x010601
......@@ -649,7 +649,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
family = PF_INET6;
break;
}
#endif /* CURLRES_IPV6 */
#endif /* ENABLE_IPV6 */
bufp = strdup(hostname);
if(bufp) {
......@@ -670,7 +670,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
/* initial status - failed */
res->last_status = ARES_ENOTFOUND;
#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
#ifdef ENABLE_IPV6
if(family == PF_UNSPEC) {
if(Curl_ipv6works(conn)) {
res->num_pending = 2;
......@@ -690,7 +690,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
}
}
else
#endif /* CURLRES_IPV6 */
#endif /* ENABLE_IPV6 */
{
res->num_pending = 1;
......
......@@ -164,7 +164,6 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
#define Curl_resolver_kill(x) Curl_nop_stmt
#define Curl_resolver_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST
#define Curl_resolver_wait_resolv(x,y) CURLE_COULDNT_RESOLVE_HOST
#define Curl_resolver_getsock(x,y,z) 0
#define Curl_resolver_duphandle(x,y,z) CURLE_OK
#define Curl_resolver_init(x,y) CURLE_OK
#define Curl_resolver_global_init() CURLE_OK
......
......@@ -74,7 +74,7 @@
#include "warnless.h"
#include "conncache.h"
#include "multihandle.h"
#include "system_win32.h"
#include "version_win32.h"
#include "quic.h"
#include "socks.h"
......@@ -934,10 +934,10 @@ CURLcode Curl_is_connected(struct connectdata *conn,
return CURLE_OK;
}
infof(data, "Connection failed\n");
}
else if(rc & CURL_CSELECT_ERR)
else if(rc & CURL_CSELECT_ERR) {
(void)verifyconnect(conn->tempsock[i], &error);
}
/*
* The connection failed here, we should attempt to connect to the "next
......@@ -1085,8 +1085,8 @@ void Curl_sndbufset(curl_socket_t sockfd)
static int detectOsState = DETECT_OS_NONE;
if(detectOsState == DETECT_OS_NONE) {
if(Curl_verify_windows_version(6, 0, PLATFORM_WINNT,
VERSION_GREATER_THAN_EQUAL))
if(curlx_verify_windows_version(6, 0, PLATFORM_WINNT,
VERSION_GREATER_THAN_EQUAL))
detectOsState = DETECT_OS_VISTA_OR_LATER;
else
detectOsState = DETECT_OS_PREVISTA;
......@@ -1363,15 +1363,15 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
}
struct connfind {
struct connectdata *tofind;
bool found;
long id_tofind;
struct connectdata *found;
};
static int conn_is_conn(struct connectdata *conn, void *param)
{
struct connfind *f = (struct connfind *)param;
if(conn == f->tofind) {
f->found = TRUE;
if(conn->connection_id == f->id_tofind) {
f->found = conn;
return 1;
}
return 0;
......@@ -1393,21 +1393,22 @@ curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
* - that is associated with a multi handle, and whose connection
* was detached with CURLOPT_CONNECT_ONLY
*/
if(data->state.lastconnect && (data->multi_easy || data->multi)) {
struct connectdata *c = data->state.lastconnect;
if((data->state.lastconnect_id != -1) && (data->multi_easy || data->multi)) {
struct connectdata *c;
struct connfind find;
find.tofind = data->state.lastconnect;
find.found = FALSE;
find.id_tofind = data->state.lastconnect_id;
find.found = NULL;
Curl_conncache_foreach(data, data->multi_easy?
&data->multi_easy->conn_cache:
&data->multi->conn_cache, &find, conn_is_conn);
if(!find.found) {
data->state.lastconnect = NULL;
data->state.lastconnect_id = -1;
return CURL_SOCKET_BAD;
}
c = find.found;
if(connp) {
/* only store this if the caller cares for it */
*connp = c;
......
......@@ -38,6 +38,10 @@
#include <brotli/decode.h>
#endif
#ifdef HAVE_ZSTD
#include <zstd.h>
#endif
#include "sendf.h"
#include "http.h"
#include "content_encoding.h"
......@@ -710,6 +714,95 @@ static const struct content_encoding brotli_encoding = {
#endif
#ifdef HAVE_ZSTD
/* Writer parameters. */
struct zstd_params {
ZSTD_DStream *zds; /* State structure for zstd. */
void *decomp;
};
static CURLcode zstd_init_writer(struct connectdata *conn,
struct contenc_writer *writer)
{
struct zstd_params *zp = (struct zstd_params *)&writer->params;
(void)conn;
if(!writer->downstream)
return CURLE_WRITE_ERROR;
zp->zds = ZSTD_createDStream();
zp->decomp = NULL;
return zp->zds ? CURLE_OK : CURLE_OUT_OF_MEMORY;
}
static CURLcode zstd_unencode_write(struct connectdata *conn,
struct contenc_writer *writer,
const char *buf, size_t nbytes)
{
CURLcode result = CURLE_OK;
struct zstd_params *zp = (struct zstd_params *)&writer->params;
ZSTD_inBuffer in;
ZSTD_outBuffer out;
size_t errorCode;
if(!zp->decomp) {
zp->decomp = malloc(DSIZ);
if(!zp->decomp)
return CURLE_OUT_OF_MEMORY;
}
in.pos = 0;
in.src = buf;
in.size = nbytes;
for(;;) {
out.pos = 0;
out.dst = zp->decomp;
out.size = DSIZ;
errorCode = ZSTD_decompressStream(zp->zds, &out, &in);
if(ZSTD_isError(errorCode)) {
return CURLE_BAD_CONTENT_ENCODING;
}
if(out.pos > 0) {
result = Curl_unencode_write(conn, writer->downstream,
zp->decomp, out.pos);
if(result)
break;
}
if((in.pos == nbytes) && (out.pos < out.size))
break;
}
return result;
}
static void zstd_close_writer(struct connectdata *conn,
struct contenc_writer *writer)
{
struct zstd_params *zp = (struct zstd_params *)&writer->params;
(void)conn;
if(zp->decomp) {
free(zp->decomp);
zp->decomp = NULL;
}
if(zp->zds) {
ZSTD_freeDStream(zp->zds);
zp->zds = NULL;
}
}
static const struct content_encoding zstd_encoding = {
"zstd",
NULL,
zstd_init_writer,
zstd_unencode_write,
zstd_close_writer,
sizeof(struct zstd_params)
};
#endif
/* Identity handler. */
static CURLcode identity_init_writer(struct connectdata *conn,
struct contenc_writer *writer)
......@@ -751,6 +844,9 @@ static const struct content_encoding * const encodings[] = {
#endif
#ifdef HAVE_BROTLI
&brotli_encoding,
#endif
#ifdef HAVE_ZSTD
&zstd_encoding,
#endif
NULL
};
......
......@@ -437,6 +437,9 @@
/* if brotli is available */
#cmakedefine HAVE_BROTLI 1
/* if zstd is available */
#cmakedefine HAVE_ZSTD 1
/* if your compiler supports LL */
#cmakedefine HAVE_LL 1
......
......@@ -641,7 +641,7 @@ int netware_init(void);
defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_SECTRANSP) || \
defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \
defined(USE_MBEDTLS) || \
(defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_SET_ODD_PARITY))
(defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT))
#define USE_NTLM
......
......@@ -28,6 +28,7 @@
#include "curl_sspi.h"
#include "curl_multibyte.h"
#include "system_win32.h"
#include "version_win32.h"
#include "warnless.h"
/* The last #include files should be: */
......@@ -82,7 +83,7 @@ CURLcode Curl_sspi_global_init(void)
* have both these DLLs (security.dll forwards calls to secur32.dll) */
/* Load SSPI dll into the address space of the calling process */
if(Curl_verify_windows_version(4, 0, PLATFORM_WINNT, VERSION_EQUAL))
if(curlx_verify_windows_version(4, 0, PLATFORM_WINNT, VERSION_EQUAL))
s_hSecDll = Curl_load_library(TEXT("security.dll"));
else
s_hSecDll = Curl_load_library(TEXT("secur32.dll"));
......
......@@ -63,6 +63,9 @@
curlx_unicodefree()
*/
#include "version_win32.h"
/* "version_win32.h" provides curlx_verify_windows_version() */
/* Now setup curlx_ * names for the functions that are to become curlx_ and
be removed from a future libcurl official API:
curlx_getenv
......
......@@ -858,7 +858,7 @@ doh2ai(const struct dohentry *de, const char *hostname, int port)
addr = (void *)ai->ai_addr; /* storage area for this info */