CURLOPT_FNMATCH_DATA(3)

πŸ’… CURLOPT_FNMATCH_DATA(3) β€” bestie edition ✨

okay so this page lives in the Library Functions Manual and it's literally all about CURLOPT_FNMATCH_DATA(3), no cap. it's short, it's sweet, it's giving "small but crucial" πŸŽ€


🌸 NAME 🌸

CURLOPT_FNMATCH_DATA β€” the pointer you pass along to your fnmatch callback. that's it. that's the whole vibe πŸ’–


✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FNMATCH_DATA,
                          void *pointer);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• β€” you hand libcurl a pointer, and libcurl is literally not going to touch it. like, zero touching. not even a little peek. instead it gets passed straight through as the ptr argument to whatever function you set with CURLOPT_FNMATCH_FUNCTION(3). 🫢

it's giving "you carry the bag, we do the wildcard matching" and honestly? iconic.


πŸŽ€ DEFAULT πŸŽ€

NULL

(yeah. nothing. empty. the void. very main-character-of-emptiness of it πŸ’€)


🌈 PROTOCOLS 🌈

this functionality affects ftp only. ftp girlies, this one's for you 🧚


⭐ EXAMPLE ⭐

here's the whole thing, verbatim, because we respect the source:

extern int string_match(const char *s1, const char *s2);

struct local_stuff {
  void *custom;
};

static int my_fnmatch(void *clientp,
                      const char *pattern, const char *string)
{
  struct local_stuff *my = clientp;
  printf("my ptr: %p\n", my->custom);

  if(string_match(pattern, string))
    return CURL_FNMATCHFUNC_MATCH;
  else
    return CURL_FNMATCHFUNC_NOMATCH;
}

int main(void)
{
  struct local_stuff local_data;
  CURL *curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*");
    curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
    curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch);
    curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data);

    curl_easy_perform(curl);
  }
}

see how &local_data slides right into CURLOPT_FNMATCH_DATA and then shows up as clientp in my_fnmatch? it's giving "the circle of life" πŸ¦‹βœ¨


πŸ‘‘ AVAILABILITY πŸ‘‘

added in curl 7.21.0. vintage, but still slaying πŸ’…


πŸ”₯ RETURN VALUE πŸ”₯

curl_easy_setopt(3) returns a CURLcode indicating success or error. very demure, very straightforward.

  • CURLE_OK (0) means everything was OK β€” slay βœ…
  • non-zero means an error occurred 😭 β€” see libcurl-errors(3) for the full drama

πŸ’œ SEE ALSO πŸ’œ

lowkey go read both of these next, they're the other two-thirds of the wildcard-matching trifecta 🫢

and that's the whole page bestie, hope it ate πŸ’– this one comes from libcurl, dated 2026-10-12, and it was originally titled CURLOPT_FNMATCH_DATA(3) in case the vibe check required receipts. mwah πŸ˜˜πŸŽ€

πŸ“¦ where this page comes from