1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_FNMATCH_DATA
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_FNMATCH_FUNCTION (3)
9  - CURLOPT_WILDCARDMATCH (3)
10Protocol:
11  - FTP
12Added-in: 7.21.0
13---
14
15# NAME
16
17CURLOPT_FNMATCH_DATA - pointer passed to the fnmatch callback
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FNMATCH_DATA,
25                          void *pointer);
26~~~
27
28# DESCRIPTION
29
30Pass a pointer that is untouched by libcurl and passed as the ptr argument to
31the CURLOPT_FNMATCH_FUNCTION(3).
32
33# DEFAULT
34
35NULL
36
37# %PROTOCOLS%
38
39# EXAMPLE
40
41~~~c
42extern int string_match(const char *s1, const char *s2);
43
44struct local_stuff {
45  void *custom;
46};
47
48static int my_fnmatch(void *clientp,
49                      const char *pattern, const char *string)
50{
51  struct local_stuff *my = clientp;
52  printf("my ptr: %p\n", my->custom);
53
54  if(string_match(pattern, string))
55    return CURL_FNMATCHFUNC_MATCH;
56  else
57    return CURL_FNMATCHFUNC_NOMATCH;
58}
59
60int main(void)
61{
62  struct local_stuff local_data;
63  CURL *curl = curl_easy_init();
64  if(curl) {
65    curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*");
66    curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
67    curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch);
68    curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data);
69
70    curl_easy_perform(curl);
71  }
72}
73~~~
74
75# %AVAILABILITY%
76
77# RETURN VALUE
78
79Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
80