]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ftp wildcard: a new option CURLOPT_FNMATCH_DATA
authorKamil Dudka <kdudka@redhat.com>
Sun, 16 May 2010 00:49:08 +0000 (02:49 +0200)
committerKamil Dudka <kdudka@redhat.com>
Sun, 16 May 2010 00:52:33 +0000 (02:52 +0200)
CHANGES
RELEASE-NOTES
docs/libcurl/curl_easy_setopt.3
docs/libcurl/symbols-in-versions
include/curl/curl.h
lib/curl_fnmatch.c
lib/curl_fnmatch.h
lib/ftplistparser.c
lib/url.c
lib/urldata.h
tests/libtest/lib577.c

diff --git a/CHANGES b/CHANGES
index d895ebeb6905e3fa76b7ef8846f0a3262658c5a0..115e33cf880765c916a0796f560eeab7da481c44 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,10 @@
 
                                   Changelog
 
+Kamil Dudka (16 May 2010)
+- Pavel Raiskup introduced a new option CURLOPT_FNMATCH_DATA in order to pass
+  a custom data pointer to the callback specified by CURLOPT_FNMATCH_FUNCTION.
+
 Daniel Stenberg (14 May 2010)
 - John-Mark Bell filed bug #3000052 that identified a problem (with an
   associated patch) with the OpenSSL handshake state machine when the multi
index 37348f91f8ddc892d14aa79f36083771cfb144e6..b73997900a6eb2c8fcd5b1ffac68f283baff5e4f 100644 (file)
@@ -2,7 +2,7 @@ Curl and libcurl 7.21.0
 
  Public curl releases:         116
  Command line options:         138
- curl_easy_setopt() options:   179
+ curl_easy_setopt() options:   180
  Public functions in libcurl:  58
  Known libcurl bindings:       39
  Contributors:                 794
index 7fa4f7271dd394ba796c479355fdc0caa565012b..a26898f1e9a1c1fa395a9cf5c2cc3f83b541f70b 100644 (file)
@@ -507,13 +507,16 @@ Pass a pointer that will be untouched by libcurl and passed as the ptr
 argument to the \fICURL_CHUNK_BGN_FUNTION\fP and \fICURL_CHUNK_END_FUNTION\fP.
 (This was added in 7.21.0)
 .IP CURLOPT_FNMATCH_FUNCTION
-Function pointer that should match \fBint function(const char *pattern, const
-char *string)\fP prototype (see \fIcurl/curl.h\fP). It is used internally for
-the wildcard matching feature.
+Function pointer that should match \fBint function(void *ptr, const char
+*pattern, const char *string)\fP prototype (see \fIcurl/curl.h\fP). It is used
+internally for the wildcard matching feature.
 
 Return \fICURL_FNMATCHFUNC_MATCH\fP if pattern matches the string,
 \fICURL_FNMATCHFUNC_NOMATCH\fP if not or \fICURL_FNMATCHFUNC_FAIL\fP if an
 error occurred.  (This was added in 7.21.0)
+.IP CURLOPT_FNMATCH_DATA
+Pass a pointer that will be untouched by libcurl and passed as the ptr argument
+to the \fICURL_FNMATCH_FUNCTION\fP. (This was added in 7.21.0)
 .SH ERROR OPTIONS
 .IP CURLOPT_ERRORBUFFER
 Pass a char * to a buffer that the libcurl may store human readable error
index a9bebe22966c8d69c18c3c0400f5efc8e6423db4..b33619ee0d6f4e1f5cc214cf9c3b42e9d0347e8c 100644 (file)
@@ -220,6 +220,7 @@ CURLOPT_FAILONERROR             7.1
 CURLOPT_FILE                    7.1           7.9.7
 CURLOPT_FILETIME                7.5
 CURLOPT_FLAGS                   7.1           -           7.9.2
+CURLOPT_FNMATCH_DATA            7.21.0
 CURLOPT_FNMATCH_FUNCTION        7.21.0
 CURLOPT_FOLLOWLOCATION          7.1
 CURLOPT_FORBID_REUSE            7.7
index a2e26bad0fe2395624933a87d40758a8bbb4d568..83ba078cbe9801e9a6ca11b19393def5265d660d 100644 (file)
@@ -285,7 +285,8 @@ typedef long (*curl_chunk_end_callback)(void *ptr);
 
 /* callback type for wildcard downloading pattern matching. If the
    string matches the pattern, return CURL_FNMATCHFUNC_MATCH value, etc. */
-typedef int (*curl_fnmatch_callback)(const char *pattern,
+typedef int (*curl_fnmatch_callback)(void *ptr,
+                                     const char *pattern,
                                      const char *string);
 
 /* These are the return codes for the seek callbacks */
@@ -1431,6 +1432,9 @@ typedef enum {
   /* Let the application define custom chunk data pointer */
   CINIT(CHUNK_DATA, OBJECTPOINT, 201),
 
+  /* FNMATCH_FUNCTION user pointer */
+  CINIT(FNMATCH_DATA, OBJECTPOINT, 202),
+
   CURLOPT_LASTENTRY /* the last unused */
 } CURLoption;
 
index 9628844ada5c529cd83fbe2adb4a514e336159be..91485a52ddf53546b8d4cd0e2104fe3c46ea9e67 100644 (file)
@@ -401,8 +401,10 @@ static int loop(const unsigned char *pattern, const unsigned char *string)
   }
 }
 
-int Curl_fnmatch(const char *pattern, const char *string)
+int Curl_fnmatch(void *ptr, const char *pattern, const char *string)
 {
+  (void)ptr; /* the argument is specified by the curl_fnmatch_callback
+                prototype, but not used by Curl_fnmatch() */
   if(!pattern || !string) {
     return CURL_FNMATCH_FAIL;
   }
index 3ffbc45759654a8746f3d92f3eb6708edf3b045f..6335d0312313a26f3483bb1ab8631e860618f8e2 100644 (file)
@@ -39,6 +39,6 @@
  * keywords: alnum, digit, xdigit, alpha, print, blank, lower, graph, space
  *           and upper (use as "[[:alnum:]]")
  */
-int Curl_fnmatch(const char *pattern, const char *string);
+int Curl_fnmatch(void *ptr, const char *pattern, const char *string);
 
 #endif /* HEADER_CURL_FNMATCH_H */
index faf314fe2fa67d1fb51e6f6bfdbfd1dbc2adca0f..ff7045b1e671e04ec340894cc10f232f887737e6 100644 (file)
@@ -330,7 +330,7 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn,
     compare = Curl_fnmatch;
 
   /* filter pattern-corresponding filenames */
-  if(compare(wc->pattern, finfo->filename) == 0) {
+  if(compare(conn->data->set.fnmatch_data, wc->pattern, finfo->filename) == 0) {
     /* discard symlink which is containing multiple " -> " */
     if((finfo->filetype == CURLFILETYPE_SYMLINK) &&
        (strstr(finfo->strings.target, " -> "))) {
index cc73750e0dace896af2d32faa8cd3d858797346f..31976300c644ade875094e55f00b50a23e037162 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -2478,7 +2478,9 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
   case CURLOPT_CHUNK_DATA:
     data->wildcard.customptr = va_arg(param, void *);
     break;
-
+  case CURLOPT_FNMATCH_DATA:
+    data->set.fnmatch_data = va_arg(param, void *);
+    break;
   default:
     /* unknown tag and its companion, just ignore: */
     result = CURLE_FAILED_INIT; /* correct this */
index 2c1b2fc4a3fd8980eb35d8d80e0654950afeef42..9db06405e14ee1ada4aae90975fa5c05e90849a0 100644 (file)
@@ -1424,6 +1424,7 @@ struct UserDefined {
                                         stopped */
   curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds
                                     to pattern (e.g. if WILDCARDMATCH is on) */
+  void *fnmatch_data;
 };
 
 struct Names {
index ac995c3fc81256ee21a47c4f78925fa101680bbb..fdab361e2a8a5f2daa38e5e89626dc29b439da99 100644 (file)
@@ -231,7 +231,7 @@ int test(char *URL)
 
   printf("===========================\n");
   for(i = 0; i < testnum; i++) {
-    rc = Curl_fnmatch(tests[i].pattern, tests[i].string);
+    rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string);
     if(rc != tests[i].result) {
       printf("Curl_fnmatch(\"%s\", \"%s\") should return %d (returns %d)\n",
              tests[i].pattern, tests[i].string, tests[i].result, rc);