ftp wildcard: a new option CURLOPT_FNMATCH_DATA
This commit is contained in:
parent
027ceb37a1
commit
2ffe834bff
4
CHANGES
4
CHANGES
@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
Changelog
|
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)
|
Daniel Stenberg (14 May 2010)
|
||||||
- John-Mark Bell filed bug #3000052 that identified a problem (with an
|
- John-Mark Bell filed bug #3000052 that identified a problem (with an
|
||||||
associated patch) with the OpenSSL handshake state machine when the multi
|
associated patch) with the OpenSSL handshake state machine when the multi
|
||||||
|
@ -2,7 +2,7 @@ Curl and libcurl 7.21.0
|
|||||||
|
|
||||||
Public curl releases: 116
|
Public curl releases: 116
|
||||||
Command line options: 138
|
Command line options: 138
|
||||||
curl_easy_setopt() options: 179
|
curl_easy_setopt() options: 180
|
||||||
Public functions in libcurl: 58
|
Public functions in libcurl: 58
|
||||||
Known libcurl bindings: 39
|
Known libcurl bindings: 39
|
||||||
Contributors: 794
|
Contributors: 794
|
||||||
|
@ -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.
|
argument to the \fICURL_CHUNK_BGN_FUNTION\fP and \fICURL_CHUNK_END_FUNTION\fP.
|
||||||
(This was added in 7.21.0)
|
(This was added in 7.21.0)
|
||||||
.IP CURLOPT_FNMATCH_FUNCTION
|
.IP CURLOPT_FNMATCH_FUNCTION
|
||||||
Function pointer that should match \fBint function(const char *pattern, const
|
Function pointer that should match \fBint function(void *ptr, const char
|
||||||
char *string)\fP prototype (see \fIcurl/curl.h\fP). It is used internally for
|
*pattern, const char *string)\fP prototype (see \fIcurl/curl.h\fP). It is used
|
||||||
the wildcard matching feature.
|
internally for the wildcard matching feature.
|
||||||
|
|
||||||
Return \fICURL_FNMATCHFUNC_MATCH\fP if pattern matches the string,
|
Return \fICURL_FNMATCHFUNC_MATCH\fP if pattern matches the string,
|
||||||
\fICURL_FNMATCHFUNC_NOMATCH\fP if not or \fICURL_FNMATCHFUNC_FAIL\fP if an
|
\fICURL_FNMATCHFUNC_NOMATCH\fP if not or \fICURL_FNMATCHFUNC_FAIL\fP if an
|
||||||
error occurred. (This was added in 7.21.0)
|
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
|
.SH ERROR OPTIONS
|
||||||
.IP CURLOPT_ERRORBUFFER
|
.IP CURLOPT_ERRORBUFFER
|
||||||
Pass a char * to a buffer that the libcurl may store human readable error
|
Pass a char * to a buffer that the libcurl may store human readable error
|
||||||
|
@ -220,6 +220,7 @@ CURLOPT_FAILONERROR 7.1
|
|||||||
CURLOPT_FILE 7.1 7.9.7
|
CURLOPT_FILE 7.1 7.9.7
|
||||||
CURLOPT_FILETIME 7.5
|
CURLOPT_FILETIME 7.5
|
||||||
CURLOPT_FLAGS 7.1 - 7.9.2
|
CURLOPT_FLAGS 7.1 - 7.9.2
|
||||||
|
CURLOPT_FNMATCH_DATA 7.21.0
|
||||||
CURLOPT_FNMATCH_FUNCTION 7.21.0
|
CURLOPT_FNMATCH_FUNCTION 7.21.0
|
||||||
CURLOPT_FOLLOWLOCATION 7.1
|
CURLOPT_FOLLOWLOCATION 7.1
|
||||||
CURLOPT_FORBID_REUSE 7.7
|
CURLOPT_FORBID_REUSE 7.7
|
||||||
|
@ -285,7 +285,8 @@ typedef long (*curl_chunk_end_callback)(void *ptr);
|
|||||||
|
|
||||||
/* callback type for wildcard downloading pattern matching. If the
|
/* callback type for wildcard downloading pattern matching. If the
|
||||||
string matches the pattern, return CURL_FNMATCHFUNC_MATCH value, etc. */
|
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);
|
const char *string);
|
||||||
|
|
||||||
/* These are the return codes for the seek callbacks */
|
/* These are the return codes for the seek callbacks */
|
||||||
@ -1431,6 +1432,9 @@ typedef enum {
|
|||||||
/* Let the application define custom chunk data pointer */
|
/* Let the application define custom chunk data pointer */
|
||||||
CINIT(CHUNK_DATA, OBJECTPOINT, 201),
|
CINIT(CHUNK_DATA, OBJECTPOINT, 201),
|
||||||
|
|
||||||
|
/* FNMATCH_FUNCTION user pointer */
|
||||||
|
CINIT(FNMATCH_DATA, OBJECTPOINT, 202),
|
||||||
|
|
||||||
CURLOPT_LASTENTRY /* the last unused */
|
CURLOPT_LASTENTRY /* the last unused */
|
||||||
} CURLoption;
|
} CURLoption;
|
||||||
|
|
||||||
|
@ -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) {
|
if(!pattern || !string) {
|
||||||
return CURL_FNMATCH_FAIL;
|
return CURL_FNMATCH_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,6 @@
|
|||||||
* keywords: alnum, digit, xdigit, alpha, print, blank, lower, graph, space
|
* keywords: alnum, digit, xdigit, alpha, print, blank, lower, graph, space
|
||||||
* and upper (use as "[[:alnum:]]")
|
* 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 */
|
#endif /* HEADER_CURL_FNMATCH_H */
|
||||||
|
@ -330,7 +330,7 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn,
|
|||||||
compare = Curl_fnmatch;
|
compare = Curl_fnmatch;
|
||||||
|
|
||||||
/* filter pattern-corresponding filenames */
|
/* 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 " -> " */
|
/* discard symlink which is containing multiple " -> " */
|
||||||
if((finfo->filetype == CURLFILETYPE_SYMLINK) &&
|
if((finfo->filetype == CURLFILETYPE_SYMLINK) &&
|
||||||
(strstr(finfo->strings.target, " -> "))) {
|
(strstr(finfo->strings.target, " -> "))) {
|
||||||
|
@ -2478,7 +2478,9 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
|||||||
case CURLOPT_CHUNK_DATA:
|
case CURLOPT_CHUNK_DATA:
|
||||||
data->wildcard.customptr = va_arg(param, void *);
|
data->wildcard.customptr = va_arg(param, void *);
|
||||||
break;
|
break;
|
||||||
|
case CURLOPT_FNMATCH_DATA:
|
||||||
|
data->set.fnmatch_data = va_arg(param, void *);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
/* unknown tag and its companion, just ignore: */
|
/* unknown tag and its companion, just ignore: */
|
||||||
result = CURLE_FAILED_INIT; /* correct this */
|
result = CURLE_FAILED_INIT; /* correct this */
|
||||||
|
@ -1424,6 +1424,7 @@ struct UserDefined {
|
|||||||
stopped */
|
stopped */
|
||||||
curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds
|
curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds
|
||||||
to pattern (e.g. if WILDCARDMATCH is on) */
|
to pattern (e.g. if WILDCARDMATCH is on) */
|
||||||
|
void *fnmatch_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Names {
|
struct Names {
|
||||||
|
@ -231,7 +231,7 @@ int test(char *URL)
|
|||||||
|
|
||||||
printf("===========================\n");
|
printf("===========================\n");
|
||||||
for(i = 0; i < testnum; i++) {
|
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) {
|
if(rc != tests[i].result) {
|
||||||
printf("Curl_fnmatch(\"%s\", \"%s\") should return %d (returns %d)\n",
|
printf("Curl_fnmatch(\"%s\", \"%s\") should return %d (returns %d)\n",
|
||||||
tests[i].pattern, tests[i].string, tests[i].result, rc);
|
tests[i].pattern, tests[i].string, tests[i].result, rc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user