curl_easy_option_next(3)

πŸ’… curl_easy_option_next β€” like, the actual page

okay so real quick: this is from the Library Functions Manual, bestie. Buckle up, we're iterating πŸ¦‹

✨ NAME ✨

curl_easy_option_next β€” iterate over easy setopt options. yes, that's the whole name section, she's short and iconic πŸ’…

✨ SYNOPSIS ✨

#include <curl/curl.h>

const struct curl_easyoption *
curl_easy_option_next(const struct curl_easyoption *prev);

✨ DESCRIPTION ✨

so this function hands you back a pointer to either the first or the next curl_easyoption struct, which is genuinely giving you the ability to iterate over all the options known to curl_easy_setopt(3) in this particular instance of libcurl. obsessed. πŸ”₯

pass a NULL argument as prev and you get the first option returned β€” pass in the current option and you get the next one back. and if there's literally no more option to return? curl_easy_option_next(3) returns NULL. that's it, that's the vibe check 🌈

the options this function returns are the ones known to this libcurl, plus the info about what argument type they want. very helpful, no cap 🫢

and if the CURLOT_FLAG_ALIAS bit is set in the flags field, that means the name is provided for backwards compatibility as an alias. iykyk ⭐

✨ struct ✨

okay this part is code, so i'm not touching a single character of it β€” copy it exactly, bestie, fr fr:

typedef enum {
  CURLOT_LONG,    /* long (a range of values) */
  CURLOT_VALUES,  /*      (a defined set or bitmask) */
  CURLOT_OFF_T,   /* curl_off_t (a range of values) */
  CURLOT_OBJECT,  /* pointer (void *) */
  CURLOT_STRING,  /*         (char * to null-terminated buffer) */
  CURLOT_SLIST,   /*         (struct curl_slist *) */
  CURLOT_CBPTR,   /*         (void * passed as-is to a callback) */
  CURLOT_BLOB,    /* blob (struct curl_blob *) */
  CURLOT_FUNCTION /* function pointer */
} curl_easytype;

/* The CURLOPTTYPE_* id ranges can still be used to figure out what type/size
   to use for curl_easy_setopt() for the given id */
struct curl_easyoption {
  const char *name;
  CURLoption id;
  curl_easytype type;
  unsigned int flags;
};

✨ PROTOCOLS ✨

this functionality affects all supported protocols. all of them. every single one πŸ’œ

✨ EXAMPLE ✨

here's the moment you've been waiting for, a whole little main that iterates over all available options πŸ˜­πŸŽ€

int main(void)
{
  /* iterate over all available options */
  const struct curl_easyoption *opt;
  opt = curl_easy_option_next(NULL);
  while(opt) {
    printf("Name: %s\n", opt->name);
    opt = curl_easy_option_next(opt);
  }
}

✨ AVAILABILITY ✨

added in curl 7.73.0. she's not vintage, she's not brand new β€” she's just right 🌸

✨ RETURN VALUE ✨

a pointer to the curl_easyoption struct for the next option β€” or NULL if there are no more options. that's the whole deal πŸ“

✨ SEE ALSO ✨


bestie note: everything above is exactly what the page says, i just gave it main character energy. nothing invented, nothing skipped πŸ’–

k bye, this page was brought to you by libcurl, dated 2026-10-12 β€” slay, go iterate some options πŸ‘‘βœ¨

πŸ“¦ where this page comes from