GNURLOPT_READDATA(3)

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

πŸŽ€ GNURLOPT_READDATA(3) πŸŽ€

okay so bestie, this is the GNURLOPT_READDATA(3) page from the curl_easy_setopt options manual, and it's all about a custom pointer that gets passed to the read callback. iykyk πŸ’…

🌸 NAME 🌸

CURLOPT_READDATA β€” custom pointer passed to the read callback. literally that's the whole vibe 🫢

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

Data pointer to pass to the file read function. if you use the CURLOPT_READFUNCTION(3) option, this is the pointer you'll get as input in the 4th argument to the callback. no cap.

If you don't specify a read callback but instead rely on the default internal read function, this data must be a valid readable FILE * (cast to 'void *'). yes, that's the assignment 😌

⚠️ win32 DLL bestie alert: if you're using libcurl as a win32 DLL, you MUST use a CURLOPT_READFUNCTION(3) if you set this option β€” or you will experience crashes 😭. not a drill, fr fr.

πŸ“ DEFAULT πŸ“

By default, this is a FILE * to stdin. iconic default behavior, honestly.

🌈 PROTOCOLS 🌈

This is used for all protocols when sending data. all of them. periodt.

πŸ’œ EXAMPLE πŸ’œ

here's the little code moment, bestie:

CURL *curl = curl_easy_init();
struct MyData this;
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");

  /* pass pointer that gets passed in to the
     CURLOPT_READFUNCTION callback */
  curl_easy_setopt(curl, CURLOPT_READDATA, &this);

  curl_easy_perform(curl);
}

🧚 AVAILABILITY 🧚

This option was once known by the older name CURLOPT_INFILE; the name CURLOPT_READDATA(3) was introduced in 7.9.7. glow-up era πŸ’«

πŸ‘‘ RETURN VALUE πŸ‘‘

This will return CURLE_OK. short, sweet, slay.

πŸ”₯ SEE ALSO πŸ”₯

CURLOPT_READFUNCTION(3), CURLOPT_WRITEDATA(3), β€” yep, that trailing comma is in the original, periodt πŸ’…


okay that's the whole page, bestie β€” GNURLOPT_READDATA(3) from libcurl 7.37.0, dated 16 Jun 2014. mwah πŸ’–βœ¨

πŸ“¦ where this page comes from