CURLOPT_FTP_USE_PRET(3)

πŸ’… CURLOPT_FTP_USE_PRET πŸ’…

okay bestie, so this is a page from the Library Functions Manual and honestly? it's a niche little gem but it slaps once you get it. let's get into it 🫢


✨ NAME ✨

CURLOPT_FTP_USE_PRET β€” the "use PRET for FTP" option, literally what it says on the tin πŸŽ€


🌸 SYNOPSIS 🌸

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_USE_PRET, long enable);

so you're passing a long in there, bestie. keep that in mind πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so, you pass a long. that's it, that's the whole vibe at first glance.

if the value is 1, it tells curl to send a PRET command before PASV (and EPSV). yeah, PRET is that extra little pre-command. certain FTP servers β€” mainly drftpd, hi drftpd ily πŸ‘‘ β€” require this non-standard command for directory listings as well as up and downloads in PASV mode. so if you're hitting one of those servers and it's being weird about things, this is your girl.

heads up though: this has no effect when you're using the active FTP transfers mode. like, none at all. it's a passive-mode-only situation, no cap πŸ’€

πŸŽ€ DEFAULT πŸŽ€

0

like, off by default. as it should be, honestly. icon behavior ⭐


🌈 PROTOCOLS 🌈

this functionality affects ftp only. that's it. just ftp. periodt πŸ’…


πŸ”₯ EXAMPLE πŸ”₯

here's the whole thing in action, bestie β€” every line, nothing skipped:

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL,
                     "ftp://example.com/old-server/file.txt");

    /* a drftpd server, do it */
    curl_easy_setopt(curl, CURLOPT_FTP_USE_PRET, 1L);

    result = curl_easy_perform(curl);

    curl_easy_cleanup(curl);
  }
}

see how it just drops that 1L in there before performing? yeah. that's the whole move. slay ✨


πŸ’œ AVAILABILITY πŸ’œ

added in curl 7.20.0, so she's been around a minute 🧚


πŸ’– RETURN VALUE πŸ’–

curl_easy_setopt(3) returns a CURLcode indicating success or error.

  • CURLE_OK (0) means everything was OK πŸŽ‰
  • non-zero means an error occurred 😭 β€” see libcurl-errors(3) for the whole lore

🌟 SEE ALSO 🌟

like, her sister options. go read 'em, iykyk πŸ¦‹


vibe check recap: PRET before PASV/EPSV, default 0, ftp only, no effect in active mode, added in 7.20.0. that's the tea β˜•

and that's the page, bestie πŸ’– mwah. brought to you by the Library Functions Manual, from libcurl, dated 2026-10-12 β€” go forth and set your options responsibly πŸŽ€πŸ‘‘

πŸ“¦ where this page comes from