Task
Connect to a server, change directory, list its contents and download a file as binary using the FTP protocol. Use passive mode if available.




OPTION PARSE FALSE
 
PRAGMA INCLUDE <curl/curl.h>
PRAGMA LDFLAGS -lcurl
 
DECLARE easyhandle TYPE CURL*
 
OPEN "data.txt" FOR WRITING AS download
 
easyhandle = curl_easy_init()
curl_easy_setopt(easyhandle, CURLOPT_URL, "ftp://localhost/pub/data.txt")
curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, download)
curl_easy_setopt(easyhandle, CURLOPT_USERPWD, "anonymous")
success = curl_easy_perform(easyhandle)
curl_easy_cleanup(easyhandle)
 
CLOSE FILE download