@@ -81,6 +81,7 @@ int lcurl_easy_create(lua_State *L, int error_mode){
8181 p -> pr .cb_ref = p -> pr .ud_ref = LUA_NOREF ;
8282 p -> seek .cb_ref = p -> seek .ud_ref = LUA_NOREF ;
8383 p -> debug .cb_ref = p -> debug .ud_ref = LUA_NOREF ;
84+ p -> match .cb_ref = p -> match .ud_ref = LUA_NOREF ;
8485 p -> rbuffer .ref = LUA_NOREF ;
8586 for (i = 0 ; i < LCURL_LIST_COUNT ; ++ i ){
8687 p -> lists [i ] = LUA_NOREF ;
@@ -146,6 +147,8 @@ static int lcurl_easy_cleanup(lua_State *L){
146147 luaL_unref (L , LCURL_LUA_REGISTRY , p -> seek .ud_ref );
147148 luaL_unref (L , LCURL_LUA_REGISTRY , p -> debug .cb_ref );
148149 luaL_unref (L , LCURL_LUA_REGISTRY , p -> debug .ud_ref );
150+ luaL_unref (L , LCURL_LUA_REGISTRY , p -> match .cb_ref );
151+ luaL_unref (L , LCURL_LUA_REGISTRY , p -> match .ud_ref );
149152 luaL_unref (L , LCURL_LUA_REGISTRY , p -> hd .cb_ref );
150153 luaL_unref (L , LCURL_LUA_REGISTRY , p -> hd .ud_ref );
151154 luaL_unref (L , LCURL_LUA_REGISTRY , p -> rbuffer .ref );
@@ -156,6 +159,7 @@ static int lcurl_easy_cleanup(lua_State *L){
156159 p -> pr .cb_ref = p -> pr .ud_ref = LUA_NOREF ;
157160 p -> seek .cb_ref = p -> seek .ud_ref = LUA_NOREF ;
158161 p -> debug .cb_ref = p -> debug .ud_ref = LUA_NOREF ;
162+ p -> match .cb_ref = p -> match .ud_ref = LUA_NOREF ;
159163 p -> rbuffer .ref = LUA_NOREF ;
160164
161165 for (i = 0 ; i < LCURL_LIST_COUNT ; ++ i ){
@@ -647,6 +651,23 @@ static int lcurl_easy_unset_DEBUGFUNCTION(lua_State *L){
647651 return 1 ;
648652}
649653
654+ #if LCURL_CURL_VER_GE (7 ,21 ,0 )
655+
656+ static int lcurl_easy_unset_FNMATCH_FUNCTION (lua_State * L ){
657+ lcurl_easy_t * p = lcurl_geteasy (L );
658+
659+ CURLcode code = curl_easy_setopt (p -> curl , CURLOPT_FNMATCH_FUNCTION , NULL );
660+ if (code != CURLE_OK ){
661+ return lcurl_fail_ex (L , p -> err_mode , LCURL_ERROR_EASY , code );
662+ }
663+ curl_easy_setopt (p -> curl , CURLOPT_FNMATCH_DATA , NULL );
664+
665+ lua_settop (L , 1 );
666+ return 1 ;
667+ }
668+
669+ #endif
670+
650671#if LCURL_CURL_VER_GE (7 ,46 ,0 )
651672
652673static int lcurl_easy_unset_STREAM_DEPENDS (lua_State * L ){
@@ -1123,6 +1144,56 @@ static int lcurl_easy_set_DEBUGFUNCTION(lua_State *L){
11231144
11241145//}
11251146
1147+ //{ Match
1148+
1149+ #if LCURL_CURL_VER_GE (7 ,21 ,0 )
1150+
1151+ static int lcurl_match_callback (void * arg , const char * pattern , const char * string ) {
1152+ lcurl_easy_t * p = arg ;
1153+ lua_State * L = p -> L ;
1154+ int ret = CURL_FNMATCHFUNC_MATCH ;
1155+ int top = lua_gettop (L );
1156+ int n = lcurl_util_push_cb (L , & p -> match );
1157+
1158+ assert (NULL != p -> L );
1159+
1160+ lua_pushstring (L , pattern );
1161+ lua_pushstring (L , string );
1162+
1163+ if (lua_pcall (L , n + 1 , LUA_MULTRET , 0 )) {
1164+ assert (lua_gettop (L ) >= top );
1165+ lua_pushlightuserdata (L , (void * )LCURL_ERROR_TAG );
1166+ lua_insert (L , top + 1 );
1167+ return CURL_FNMATCHFUNC_FAIL ;
1168+ }
1169+
1170+ if (lua_gettop (L ) > top ){
1171+ if (lua_isnil (L , top + 1 ) && (!lua_isnoneornil (L , top + 2 ))){
1172+ lua_settop (L , top + 2 );
1173+ lua_remove (L , top + 1 );
1174+ lua_pushlightuserdata (L , (void * )LCURL_ERROR_TAG );
1175+ lua_insert (L , top + 1 );
1176+ return CURL_FNMATCHFUNC_FAIL ;
1177+ }
1178+ ret = lua_toboolean (L , top + 1 ) ? CURL_FNMATCHFUNC_MATCH : CURL_FNMATCHFUNC_NOMATCH ;
1179+ }
1180+
1181+ lua_settop (L , top );
1182+ return ret ;
1183+ }
1184+
1185+ static int lcurl_easy_set_FNMATCH_FUNCTION (lua_State * L ){
1186+ lcurl_easy_t * p = lcurl_geteasy (L );
1187+ return lcurl_easy_set_callback (L , p , & p -> match ,
1188+ CURLOPT_FNMATCH_FUNCTION , CURLOPT_FNMATCH_DATA ,
1189+ "match" , lcurl_match_callback
1190+ );
1191+ }
1192+
1193+ #endif
1194+
1195+ //}
1196+
11261197//}
11271198
11281199static int lcurl_easy_setopt (lua_State * L ){
@@ -1152,6 +1223,9 @@ static int lcurl_easy_setopt(lua_State *L){
11521223 OPT_ENTRY (progressfunction , PROGRESSFUNCTION , TTT , 0 , 0 )
11531224 OPT_ENTRY (seekfunction , SEEKFUNCTION , TTT , 0 , 0 )
11541225 OPT_ENTRY (debugfunction , DEBUGFUNCTION , TTT , 0 , 0 )
1226+ #if LCURL_CURL_VER_GE (7 ,21 ,0 )
1227+ OPT_ENTRY (fnmatch_function , FNMATCH_FUNCTION , TTT , 0 , 0 )
1228+ #endif
11551229#if LCURL_CURL_VER_GE (7 ,46 ,0 )
11561230 OPT_ENTRY (stream_depends , STREAM_DEPENDS , TTT , 0 , 0 )
11571231 OPT_ENTRY (stream_depends_e , STREAM_DEPENDS_E , TTT , 0 , 0 )
@@ -1181,6 +1255,9 @@ static int lcurl_easy_unsetopt(lua_State *L){
11811255 OPT_ENTRY (progressfunction , PROGRESSFUNCTION , TTT , 0 , 0 )
11821256 OPT_ENTRY (seekfunction , SEEKFUNCTION , TTT , 0 , 0 )
11831257 OPT_ENTRY (debugfunction , DEBUGFUNCTION , TTT , 0 , 0 )
1258+ #if LCURL_CURL_VER_GE (7 ,21 ,0 )
1259+ OPT_ENTRY (fnmatch_function , FNMATCH_FUNCTION , TTT , 0 , 0 )
1260+ #endif
11841261#if LCURL_CURL_VER_GE (7 ,46 ,0 )
11851262 OPT_ENTRY (stream_depends , STREAM_DEPENDS , TTT , 0 , 0 )
11861263 OPT_ENTRY (stream_depends_e , STREAM_DEPENDS_E , TTT , 0 , 0 )
@@ -1254,6 +1331,9 @@ static const struct luaL_Reg lcurl_easy_methods[] = {
12541331 OPT_ENTRY (progressfunction , PROGRESSFUNCTION , TTT , 0 , 0 )
12551332 OPT_ENTRY (seekfunction , SEEKFUNCTION , TTT , 0 , 0 )
12561333 OPT_ENTRY (debugfunction , DEBUGFUNCTION , TTT , 0 , 0 )
1334+ #if LCURL_CURL_VER_GE (7 ,21 ,0 )
1335+ OPT_ENTRY (fnmatch_function , FNMATCH_FUNCTION , TTT , 0 , 0 )
1336+ #endif
12571337#if LCURL_CURL_VER_GE (7 ,46 ,0 )
12581338 OPT_ENTRY (stream_depends , STREAM_DEPENDS , TTT , 0 , 0 )
12591339 OPT_ENTRY (stream_depends_e , STREAM_DEPENDS_E , TTT , 0 , 0 )
@@ -1271,6 +1351,9 @@ static const struct luaL_Reg lcurl_easy_methods[] = {
12711351 OPT_ENTRY (progressfunction , PROGRESSFUNCTION , TTT , 0 , 0 )
12721352 OPT_ENTRY (seekfunction , SEEKFUNCTION , TTT , 0 , 0 )
12731353 OPT_ENTRY (debugfunction , DEBUGFUNCTION , TTT , 0 , 0 )
1354+ #if LCURL_CURL_VER_GE (7 ,21 ,0 )
1355+ OPT_ENTRY (fnmatch_function , FNMATCH_FUNCTION , TTT , 0 , 0 )
1356+ #endif
12741357#if LCURL_CURL_VER_GE (7 ,46 ,0 )
12751358 OPT_ENTRY (stream_depends , STREAM_DEPENDS , TTT , 0 , 0 )
12761359 OPT_ENTRY (stream_depends_e , STREAM_DEPENDS_E , TTT , 0 , 0 )
@@ -1313,6 +1396,9 @@ static const lcurl_const_t lcurl_easy_opt[] = {
13131396 OPT_ENTRY (progressfunction , PROGRESSFUNCTION , TTT , 0 , 0 )
13141397 OPT_ENTRY (seekfunction , SEEKFUNCTION , TTT , 0 , 0 )
13151398 OPT_ENTRY (debugfunction , DEBUGFUNCTION , TTT , 0 , 0 )
1399+ #if LCURL_CURL_VER_GE (7 ,21 ,0 )
1400+ OPT_ENTRY (fnmatch_function , FNMATCH_FUNCTION , TTT , 0 , 0 )
1401+ #endif
13161402#if LCURL_CURL_VER_GE (7 ,46 ,0 )
13171403 OPT_ENTRY (stream_depends , STREAM_DEPENDS , TTT , 0 , 0 )
13181404 OPT_ENTRY (stream_depends_e , STREAM_DEPENDS_E , TTT , 0 , 0 )
0 commit comments