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