GNURLOPT_FNMATCH_FUNCTION(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLOPT_F...CH_FUNCTION(3) πŸ’…

okay so this page is from the curl_easy_setopt options manual, and it's all about the wildcard matching function callback, bestie. no cap, it's giving very-specific-but-iconic.


✨ NAME ✨

  • CURLOPT_FNMATCH_FUNCTION β€” wildcard matching function callback. that's the whole name, periodt.

πŸŽ€ SYNOPSIS πŸŽ€

#include <gnurl/curl.h>

int fnmatch_callback(void *ptr,
                     const char *pattern,
                     const char *string);

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FNMATCH_FUNCTION,
                          fnmatch_callback);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so you pass a pointer to your callback function, and it should match the prototype shown above exactly. like, character-for-character match the vibe.

This callback is used for wildcard matching. yes bestie, wildcard matching is the main character here.

Your callback returns CURL_FNMATCHFUNC_MATCH if pattern matches the string, CURL_FNMATCHFUNC_NOMATCH if not, or CURL_FNMATCHFUNC_FAIL if an error occurred. those are the three constants, and you gotta use them exactly.

🌸 DEFAULT 🌸

NULL == an internal function for wildcard matching.

so if you don't set this, the default is NULL, and that means an internal function for wildcard matching handles it. lowkey convenient.

πŸ’œ PROTOCOLS πŸ’œ

FTP β€” that's it. this one is FTP-coded, fr fr.

πŸ“ EXAMPLE πŸ“

here's the exact example, no edits, no cap:

static int my_fnmatch(void *clientp,
                      const char *pattern, const char *string)
{
  struct local_stuff *data = (struct local_stuff *)clientp;
  if(string_match(pattern, string))
    return CURL_FNMATCHFUNC_MATCH;
  else
    return CURL_FNMATCHFUNC_NOMATCH;
}

{
  struct local_stuff local_data;
  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);
}

🌈 AVAILABILITY 🌈

Added in 7.21.0 β€” she's been around, bestie.

πŸ”₯ RETURN VALUE πŸ”₯

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. that's the return value tea.

πŸ‘‘ SEE ALSO πŸ‘‘

go read CURLOPT_FNMATCH_DATA(3), CURLOPT_DEBUGFUNCTION(3), too, okay? those are the references, comma and all.


okay bye bestie πŸ’– this was GNURLOPT_F...CH_FUNCTION(3) from libcurl 7.37.0, dated 19 Jun 2014 β€” slay, periodt. 🫢

πŸ“¦ where this page comes from