@@ -81,6 +81,7 @@ int lcurl_easy_create(lua_State *L, int error_mode){
81
81
p -> pr .cb_ref = p -> pr .ud_ref = LUA_NOREF ;
82
82
p -> seek .cb_ref = p -> seek .ud_ref = LUA_NOREF ;
83
83
p -> debug .cb_ref = p -> debug .ud_ref = LUA_NOREF ;
84
+ p -> match .cb_ref = p -> match .ud_ref = LUA_NOREF ;
84
85
p -> rbuffer .ref = LUA_NOREF ;
85
86
for (i = 0 ; i < LCURL_LIST_COUNT ; ++ i ){
86
87
p -> lists [i ] = LUA_NOREF ;
@@ -146,6 +147,8 @@ static int lcurl_easy_cleanup(lua_State *L){
146
147
luaL_unref (L , LCURL_LUA_REGISTRY , p -> seek .ud_ref );
147
148
luaL_unref (L , LCURL_LUA_REGISTRY , p -> debug .cb_ref );
148
149
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 );
149
152
luaL_unref (L , LCURL_LUA_REGISTRY , p -> hd .cb_ref );
150
153
luaL_unref (L , LCURL_LUA_REGISTRY , p -> hd .ud_ref );
151
154
luaL_unref (L , LCURL_LUA_REGISTRY , p -> rbuffer .ref );
@@ -156,6 +159,7 @@ static int lcurl_easy_cleanup(lua_State *L){
156
159
p -> pr .cb_ref = p -> pr .ud_ref = LUA_NOREF ;
157
160
p -> seek .cb_ref = p -> seek .ud_ref = LUA_NOREF ;
158
161
p -> debug .cb_ref = p -> debug .ud_ref = LUA_NOREF ;
162
+ p -> match .cb_ref = p -> match .ud_ref = LUA_NOREF ;
159
163
p -> rbuffer .ref = LUA_NOREF ;
160
164
161
165
for (i = 0 ; i < LCURL_LIST_COUNT ; ++ i ){
@@ -647,6 +651,23 @@ static int lcurl_easy_unset_DEBUGFUNCTION(lua_State *L){
647
651
return 1 ;
648
652
}
649
653
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
+
650
671
#if LCURL_CURL_VER_GE (7 ,46 ,0 )
651
672
652
673
static int lcurl_easy_unset_STREAM_DEPENDS (lua_State * L ){
@@ -1123,6 +1144,56 @@ static int lcurl_easy_set_DEBUGFUNCTION(lua_State *L){
1123
1144
1124
1145
//}
1125
1146
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
+
1126
1197
//}
1127
1198
1128
1199
static int lcurl_easy_setopt (lua_State * L ){
@@ -1152,6 +1223,9 @@ static int lcurl_easy_setopt(lua_State *L){
1152
1223
OPT_ENTRY (progressfunction , PROGRESSFUNCTION , TTT , 0 , 0 )
1153
1224
OPT_ENTRY (seekfunction , SEEKFUNCTION , TTT , 0 , 0 )
1154
1225
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
1155
1229
#if LCURL_CURL_VER_GE (7 ,46 ,0 )
1156
1230
OPT_ENTRY (stream_depends , STREAM_DEPENDS , TTT , 0 , 0 )
1157
1231
OPT_ENTRY (stream_depends_e , STREAM_DEPENDS_E , TTT , 0 , 0 )
@@ -1181,6 +1255,9 @@ static int lcurl_easy_unsetopt(lua_State *L){
1181
1255
OPT_ENTRY (progressfunction , PROGRESSFUNCTION , TTT , 0 , 0 )
1182
1256
OPT_ENTRY (seekfunction , SEEKFUNCTION , TTT , 0 , 0 )
1183
1257
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
1184
1261
#if LCURL_CURL_VER_GE (7 ,46 ,0 )
1185
1262
OPT_ENTRY (stream_depends , STREAM_DEPENDS , TTT , 0 , 0 )
1186
1263
OPT_ENTRY (stream_depends_e , STREAM_DEPENDS_E , TTT , 0 , 0 )
@@ -1254,6 +1331,9 @@ static const struct luaL_Reg lcurl_easy_methods[] = {
1254
1331
OPT_ENTRY (progressfunction , PROGRESSFUNCTION , TTT , 0 , 0 )
1255
1332
OPT_ENTRY (seekfunction , SEEKFUNCTION , TTT , 0 , 0 )
1256
1333
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
1257
1337
#if LCURL_CURL_VER_GE (7 ,46 ,0 )
1258
1338
OPT_ENTRY (stream_depends , STREAM_DEPENDS , TTT , 0 , 0 )
1259
1339
OPT_ENTRY (stream_depends_e , STREAM_DEPENDS_E , TTT , 0 , 0 )
@@ -1271,6 +1351,9 @@ static const struct luaL_Reg lcurl_easy_methods[] = {
1271
1351
OPT_ENTRY (progressfunction , PROGRESSFUNCTION , TTT , 0 , 0 )
1272
1352
OPT_ENTRY (seekfunction , SEEKFUNCTION , TTT , 0 , 0 )
1273
1353
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
1274
1357
#if LCURL_CURL_VER_GE (7 ,46 ,0 )
1275
1358
OPT_ENTRY (stream_depends , STREAM_DEPENDS , TTT , 0 , 0 )
1276
1359
OPT_ENTRY (stream_depends_e , STREAM_DEPENDS_E , TTT , 0 , 0 )
@@ -1313,6 +1396,9 @@ static const lcurl_const_t lcurl_easy_opt[] = {
1313
1396
OPT_ENTRY (progressfunction , PROGRESSFUNCTION , TTT , 0 , 0 )
1314
1397
OPT_ENTRY (seekfunction , SEEKFUNCTION , TTT , 0 , 0 )
1315
1398
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
1316
1402
#if LCURL_CURL_VER_GE (7 ,46 ,0 )
1317
1403
OPT_ENTRY (stream_depends , STREAM_DEPENDS , TTT , 0 , 0 )
1318
1404
OPT_ENTRY (stream_depends_e , STREAM_DEPENDS_E , TTT , 0 , 0 )
0 commit comments