GNURLOPT_QUOTE(3)

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

πŸ’… GNURLOPT_QUOTE(3) β€” bestie, it's giving pre-transfer glow-up πŸ’…

okay so this is from the gnurl manual, section 3, and it's literally about sending (S)FTP commands to the server before your actual transfer. no cap. it's the "get ready with me" of network requests. 🫢


✨ NAME ✨

CURLOPT_QUOTE β€” (S)FTP commands to run before transfer. it's giving prep work, and honestly? iconic.


🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_QUOTE, struct curl_slist *cmds);

so you're passing a pointer to a linked list of commands, bestie. simple as that (jk it's a little more, keep reading). πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so you pass a pointer to a linked list of FTP or SFTP commands to pass to the server prior to your request. this happens before any other commands are issued β€” even before the CWD command for FTP. the way that's literally the first thing that goes down. 😭

the linked list should be a fully valid list of 'struct curl_slist' structs properly filled in with text strings. use curl_slist_append(3) to append strings (commands) to the list, and clear the entire list afterwards with curl_slist_free_all(3). don't forget that part, bestie β€” clean up your slist, it's the respectful thing to do. 🧚

and if you want to disable this operation again, just set a NULL to this option. easy. πŸ™ˆ

when speaking to an FTP server, prefix the command with an asterisk (*) to make libcurl continue even if the command fails β€” because by default libcurl will stop at first failure. so like, if you're feeling risky and want it to keep going no matter what, use that * prefix. but be warned, default behavior is "first failure and we're done." periodt. πŸ’€

the set of valid FTP commands depends on the server (see RFC959 for a list of mandatory commands). iykyk.

the valid SFTP commands are:

  • chgrp group file β€” the chgrp command sets the group ID of the file named by the file operand to the group ID specified by the group operand. the group operand is a decimal integer group ID. slay. πŸ’…
  • chmod mode file β€” the chmod command modifies the file mode bits of the specified file. the mode operand is an octal integer mode number. iconic permission energy. πŸ”₯
  • chown user file β€” the chown command sets the owner of the file named by the file operand to the user ID specified by the user operand. the user operand is a decimal integer user ID. changing owners like a main character. πŸ‘‘
  • ln source_file target_file β€” the ln and symlink commands create a symbolic link at the target_file location pointing to the source_file location. link me up, bestie. πŸ”—
  • mkdir directory_name β€” the mkdir command creates the directory named by the directory_name operand. new folder, who dis? πŸŽ€
  • pwd β€” the pwd command returns the absolute pathname of the current working directory. just a little "where am i" moment. 🌈
  • rename source target β€” the rename command renames the file or directory named by the source operand to the destination path named by the target operand. glow-up via name change, we love to see it. ✨
  • rm file β€” the rm command removes the file specified by the file operand. bye bestie. πŸ‘‹
  • rmdir directory β€” the rmdir command removes the directory entry specified by the directory operand, provided it is empty. only if it's empty, no cap. πŸ—‘οΈ
  • statvfs file β€” the statvfs command returns statistics on the file system in which specified file resides. (Added in 7.49.0) β€” stats queen. πŸ“Š
  • symlink source_file target_file β€” See ln. same vibe, different name. πŸ¦‹

πŸŽ€ DEFAULT πŸŽ€

NULL β€” yep, nothing by default. no commands, no drama. just vibes. πŸ’–


🌈 PROTOCOLS 🌈

SFTP and FTP. that's the vibe check, and it passed. βœ…


πŸ’– EXAMPLE πŸ’–

struct curl_slist *cmdlist = NULL;
cmdlist = curl_slist_append(cmdlist, "RNFR source-name");
cmdlist = curl_slist_append(cmdlist, "RNTO new-name");

curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin");

  /* pass in the FTP commands to run before the transfer */
  curl_easy_setopt(curl, CURLOPT_QUOTE, cmdlist);

  ret = curl_easy_perform(curl);

  curl_easy_cleanup(curl);
}

look at that β€” it's giving rename glow-up. RNFR then RNTO, slay. πŸ”₯


⭐ AVAILABILITY ⭐

SFTP support added in 7.16.3. *-prefix for SFTP added in 7.24.0. so if you're on an ancient version, check yourself before you wreck yourself. 🫢


πŸ‘‘ RETURN VALUE πŸ‘‘

Returns CURLE_OK. that's it. that's the return value. πŸ’…


🫢 SEE ALSO 🫢

CURLOPT_POSTQUOTE(3), CURLOPT_PREQUOTE(3) β€” go check out these other besties too, they're part of the same quote-y friend group. 🌸


that's the whole page, bestie. this was written for libcurl 7.37.0 and dated 17 Jun 2014. now go run your pre-transfer commands and slay. πŸ’…βœ¨

πŸ“¦ where this page comes from