Skip to content

Commit 8042bb7

Browse files
committed
Add. Support offset type for easy getinfo function.
1 parent 1475e5c commit 8042bb7

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/lceasy.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,23 @@ static int lcurl_info_get_double_(lua_State *L, int opt){
813813
return 1;
814814
}
815815

816+
#if LCURL_CURL_VER_GE(7,55,0)
817+
818+
static int lcurl_info_get_offset_(lua_State *L, int opt){
819+
lcurl_easy_t *p = lcurl_geteasy(L);
820+
curl_off_t val; CURLcode code;
821+
822+
code = curl_easy_getinfo(p->curl, opt, &val);
823+
if(code != CURLE_OK){
824+
return lcurl_fail_ex(L, p->err_mode, LCURL_ERROR_EASY, code);
825+
}
826+
827+
lutil_pushint64(L, val);
828+
return 1;
829+
}
830+
831+
#endif
832+
816833
static int lcurl_info_get_string_(lua_State *L, int opt){
817834
lcurl_easy_t *p = lcurl_geteasy(L);
818835
char *val; CURLcode code;
@@ -890,6 +907,10 @@ static int lcurl_info_get_certinfo_(lua_State *L, int opt){
890907
return lcurl_info_get_double_(L, CURLINFO_##N);\
891908
}
892909

910+
#define LCURL_OFF_INFO(N, S) static int lcurl_easy_get_##N(lua_State *L){\
911+
return lcurl_info_get_offset_(L, CURLINFO_##N);\
912+
}
913+
893914
#define LCURL_CERTINFO_INFO(N, S) static int lcurl_easy_get_##N(lua_State *L){\
894915
return lcurl_info_get_certinfo_(L, CURLINFO_##N);\
895916
}

src/lcinfoeasy.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ OPT_ENTRY( protocol, PROTOCOL, LNG, 0)
5454
OPT_ENTRY( scheme, SCHEME, STR, 0)
5555
#endif
5656

57+
#if LCURL_CURL_VER_GE(7,55,0)
58+
OPT_ENTRY( content_length_download_t, CONTENT_LENGTH_DOWNLOAD_T, OFF, 0)
59+
OPT_ENTRY( content_length_upload_t, CONTENT_LENGTH_UPLOAD_T, OFF, 0)
60+
OPT_ENTRY( size_download_t, SIZE_DOWNLOAD_T, OFF, 0)
61+
OPT_ENTRY( size_upload_t, SIZE_UPLOAD_T, OFF, 0)
62+
OPT_ENTRY( speed_download_t, SPEED_DOWNLOAD_T, OFF, 0)
63+
OPT_ENTRY( speed_upload_t, SPEED_UPLOAD_T, OFF, 0)
64+
#endif
65+
5766
// OPT_ENTRY( PRIVATE, void )
5867
// OPT_ENTRY( TLS_SSL_PTR, struct curl_tlssessioninfo **
5968
// OPT_ENTRY( TLS_SESSION, struct curl_tlssessioninfo *

0 commit comments

Comments
 (0)