Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions examples/lcurl/crul_info.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
local curl = require "lcurl"

local function keys(t)
local s = {}
for k in pairs(t) do
s[#s + 1] = k
end
table.sort(s)
return s
end

local function printf(...)
return print(string.format(...))
end

local exclude = {protocols = 1, features = 1, version = 1, version_num = 1}

local info = curl.version_info()

print(curl.version())

for _, key in ipairs(keys(info)) do if not exclude[key] then
printf("%15s: %s", key, info[key])
end end

print('Protocols:')
for _, protocol in ipairs(keys(info.protocols))do
local on = info.protocols[protocol]
printf(' [%s] %s', on and '+' or '-', protocol)
end

print('Features:')
for _, feature in ipairs(keys(info.features))do
local on = info.features[feature]
printf(' [%s] %s', on and '+' or '-', feature)
end
4 changes: 2 additions & 2 deletions msvc/lcurl.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="$(CPPLIB_DIR)\curl\7.56.0\include;$(LUA_DIR)\include"
AdditionalIncludeDirectories="$(CPPLIB_DIR)\curl\7.59.0\include;$(LUA_DIR)\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LCURL_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
Expand All @@ -63,7 +63,7 @@
Name="VCLinkerTool"
AdditionalDependencies="lua5.1.lib libcurl.lib ws2_32.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(CPPLIB_DIR)\curl\7.56.0\lib&quot;;&quot;$(LUA_DIR)\lib&quot;"
AdditionalLibraryDirectories="&quot;$(CPPLIB_DIR)\curl\7.59.0\lib&quot;;&quot;$(LUA_DIR)\lib&quot;"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
Expand Down
45 changes: 45 additions & 0 deletions src/lceasy.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,25 @@ static int lcurl_opt_set_long_(lua_State *L, int opt){
return 1;
}

#if LCURL_CURL_VER_GE(7,59,0)

static int lcurl_opt_set_off_(lua_State *L, int opt){
lcurl_easy_t *p = lcurl_geteasy(L);
curl_off_t val; CURLcode code;

luaL_argcheck(L, lua_type(L, 2) == LUA_TNUMBER, 2, "number expected");
val = lutil_checkint64(L, 2);

code = curl_easy_setopt(p->curl, opt, val);
if(code != CURLE_OK){
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code);
}
lua_settop(L, 1);
return 1;
}

#endif

static int lcurl_opt_set_string_(lua_State *L, int opt, int store){
lcurl_easy_t *p = lcurl_geteasy(L);
CURLcode code;
Expand Down Expand Up @@ -378,6 +397,10 @@ static int lcurl_opt_set_slist_(lua_State *L, int opt, int list_no){
return lcurl_opt_set_long_(L, CURLOPT_##N);\
}

#define LCURL_OFF_OPT(N, S) static int lcurl_easy_set_##N(lua_State *L){\
return lcurl_opt_set_off_(L, CURLOPT_##N);\
}

#define OPT_ENTRY(L, N, T, S, D) LCURL_##T##_OPT(N, S)

#include "lcopteasy.h"
Expand Down Expand Up @@ -409,6 +432,7 @@ static int lcurl_easy_set_POSTFIELDS(lua_State *L){
#undef LCURL_STR_OPT
#undef LCURL_LST_OPT
#undef LCURL_LNG_OPT
#undef LCURL_OFF_OPT

static size_t lcurl_hpost_read_callback(char *buffer, size_t size, size_t nitems, void *arg);

Expand Down Expand Up @@ -508,6 +532,22 @@ static int lcurl_opt_unset_long_(lua_State *L, int opt, long val){
return 1;
}

#if LCURL_CURL_VER_GE(7,59,0)

static int lcurl_opt_unset_off_(lua_State *L, int opt, curl_off_t val){
lcurl_easy_t *p = lcurl_geteasy(L);
CURLcode code;

code = curl_easy_setopt(p->curl, opt, val);
if(code != CURLE_OK){
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code);
}
lua_settop(L, 1);
return 1;
}

#endif

static int lcurl_opt_unset_string_(lua_State *L, int opt, const char *val){
lcurl_easy_t *p = lcurl_geteasy(L);
CURLcode code;
Expand Down Expand Up @@ -556,6 +596,10 @@ static int lcurl_opt_unset_slist_(lua_State *L, int opt, int list_no){
return lcurl_opt_unset_long_(L, CURLOPT_##N, (D));\
}

#define LCURL_OFF_OPT(N, S, D) static int lcurl_easy_unset_##N(lua_State *L){\
return lcurl_opt_unset_off_(L, CURLOPT_##N, (D));\
}

#define OPT_ENTRY(L, N, T, S, D) LCURL_##T##_OPT(N, S, D)

#include "lcopteasy.h"
Expand All @@ -565,6 +609,7 @@ static int lcurl_opt_unset_slist_(lua_State *L, int opt, int list_no){
#undef LCURL_STR_OPT
#undef LCURL_LST_OPT
#undef LCURL_LNG_OPT
#undef LCURL_OFF_OPT

static int lcurl_easy_unset_HTTPPOST(lua_State *L){
lcurl_easy_t *p = lcurl_geteasy(L);
Expand Down
2 changes: 2 additions & 0 deletions src/lceasy.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define LCURL_LST_INDEX(N) LCURL_##N##_LIST,
#define LCURL_STR_INDEX(N)
#define LCURL_LNG_INDEX(N)
#define LCURL_OFF_INDEX(N)
#define OPT_ENTRY(L, N, T, S, D) LCURL_##T##_INDEX(N)

enum {
Expand All @@ -28,6 +29,7 @@ enum {
LCURL_LIST_COUNT,
};

#undef LCURL_OFF_INDEX
#undef LCURL_LST_INDEX
#undef LCURL_STR_INDEX
#undef LCURL_LNG_INDEX
Expand Down
3 changes: 3 additions & 0 deletions src/lcerr_easy.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,6 @@ ERR_ENTRY ( SSL_INVALIDCERTSTATUS )
#if LCURL_CURL_VER_GE(7,49,0)
ERR_ENTRY ( HTTP2_STREAM )
#endif
#if LCURL_CURL_VER_GE(7,59,0)
ERR_ENTRY ( RECURSIVE_API_CALL )
#endif
3 changes: 3 additions & 0 deletions src/lcerr_multi.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ ERR_ENTRY ( UNKNOWN_OPTION )
#if LCURL_CURL_VER_GE(7,32,1)
ERR_ENTRY ( ADDED_ALREADY )
#endif
#if LCURL_CURL_VER_GE(7,59,0)
ERR_ENTRY ( RECURSIVE_API_CALL )
#endif
3 changes: 3 additions & 0 deletions src/lcflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ FLG_ENTRY(SSH_AUTH_PASSWORD )
#ifdef CURLSSH_AUTH_HOST
FLG_ENTRY(SSH_AUTH_HOST )
#endif
#ifdef CURLSSH_AUTH_GSSAPI
FLG_ENTRY(SSH_AUTH_GSSAPI )
#endif
#ifdef CURLSSH_AUTH_KEYBOARD
FLG_ENTRY(SSH_AUTH_KEYBOARD )
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/lcinfoeasy.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ OPT_ENTRY( speed_download_t, SPEED_DOWNLOAD_T, OFF, 0)
OPT_ENTRY( speed_upload_t, SPEED_UPLOAD_T, OFF, 0)
#endif

#if LCURL_CURL_VER_GE(7,59,0)
OPT_ENTRY( filetime_t, FILETIME_T, OFF, 0)
#endif

// OPT_ENTRY( PRIVATE, void )
// OPT_ENTRY( TLS_SSL_PTR, struct curl_tlssessioninfo **
// OPT_ENTRY( TLS_SESSION, struct curl_tlssessioninfo *
5 changes: 5 additions & 0 deletions src/lcopteasy.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ OPT_ENTRY( socks5_auth, SOCKS5_AUTH, LNG, 0, LCURL_DEF
OPT_ENTRY( ssh_compression, SSH_COMPRESSION, LNG, 0, LCURL_DEFAULT_VALUE)
#endif

#if LCURL_CURL_VER_GE(7,59,0)
OPT_ENTRY( happy_eyeballs_timeout_ms,HAPPY_EYEBALLS_TIMEOUT_MS,LNG, 0, CURL_HET_DEFAULT)
OPT_ENTRY( timevalue_large, TIMEVALUE_LARGE ,OFF, 0, LCURL_DEFAULT_VALUE)
#endif

#ifdef LCURL__TCP_FASTOPEN
# define TCP_FASTOPEN LCURL__TCP_FASTOPEN
# undef LCURL__TCP_FASTOPEN
Expand Down
14 changes: 13 additions & 1 deletion src/lcurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ static int lcurl_version_info(lua_State *L){
#ifdef CURL_VERSION_MULTI_SSL
lua_pushliteral(L, "MULTI_SSL"); lua_pushboolean(L, data->features & CURL_VERSION_MULTI_SSL ); lua_rawset(L, -3);
#endif
#ifdef CURL_VERSION_BROTLI
lua_pushliteral(L, "BROTLI"); lua_pushboolean(L, data->features & CURL_VERSION_BROTLI ); lua_rawset(L, -3);
#endif

lua_setfield(L, -2, "features"); /* bitmask, see defines below */

Expand All @@ -140,10 +143,19 @@ static int lcurl_version_info(lua_State *L){
if(data->libidn){lua_pushstring(L, data->libidn); lua_setfield(L, -2, "libidn");}
}

if(data->age >= CURLVERSION_FOURTH){ /* added in 7.16.1 */
#if LCURL_CURL_VER_GE(7,16,1)
if(data->age >= CURLVERSION_FOURTH){
lua_pushnumber(L, data->iconv_ver_num); lua_setfield(L, -2, "iconv_ver_num");
if(data->libssh_version){lua_pushstring(L, data->libssh_version);lua_setfield(L, -2, "libssh_version");}
}
#endif

#if LCURL_CURL_VER_GE(7,57,0)
if(data->age >= CURLVERSION_FOURTH){
lua_pushnumber(L, data->brotli_ver_num); lua_setfield(L, -2, "brotli_ver_num");
if(data->brotli_version){lua_pushstring(L, data->brotli_version);lua_setfield(L, -2, "brotli_version");}
}
#endif

if(lua_isstring(L, 1)){
lua_pushvalue(L, 1); lua_rawget(L, -2);
Expand Down
20 changes: 12 additions & 8 deletions src/lua/cURL/impl/cURL.lua
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,18 @@ Easy.setopt_httpauth = wrap_setopt_flags("httpauth", {
["ONLY" ] = curl.AUTH_ONLY;
["ANY" ] = curl.AUTH_ANY;
["ANYSAFE" ] = curl.AUTH_ANYSAFE;
["SSH_ANY" ] = curl.SSH_AUTH_ANY;
["SSH_NONE" ] = curl.SSH_AUTH_NONE;
["SSH_PUBLICKEY" ] = curl.SSH_AUTH_PUBLICKEY;
["SSH_PASSWORD" ] = curl.SSH_AUTH_PASSWORD;
["SSH_HOST" ] = curl.SSH_AUTH_HOST;
["SSH_KEYBOARD" ] = curl.SSH_AUTH_KEYBOARD;
["SSH_AGENT" ] = curl.SSH_AUTH_AGENT;
["SSH_DEFAULT" ] = curl.SSH_AUTH_DEFAULT;
})

Easy.setopt_ssh_auth_types = wrap_setopt_flags("ssh_auth_types", {
["NONE" ] = curl.SSH_AUTH_NONE;
["ANY" ] = curl.SSH_AUTH_ANY;
["PUBLICKEY" ] = curl.SSH_AUTH_PUBLICKEY;
["PASSWORD" ] = curl.SSH_AUTH_PASSWORD;
["HOST" ] = curl.SSH_AUTH_HOST;
["GSSAPI" ] = curl.SSH_AUTH_GSSAPI;
["KEYBOARD" ] = curl.SSH_AUTH_KEYBOARD;
["AGENT" ] = curl.SSH_AUTH_AGENT;
["DEFAULT" ] = curl.SSH_AUTH_DEFAULT;
})

end
Expand Down