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