GNURLOPT_FNMATCH_FUNCTION(3)
π 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
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms