107 signed char retVal = 0;
108 struct FtpFile ftpfile = {destPath, 0, destBuf};
115 struct MyProgressData pd;
119 curl_easy_setopt(session, CURLOPT_URL, sourceURL);
121 SWBuf credentials =
u +
":" +
p;
122 curl_easy_setopt(session, CURLOPT_USERPWD, credentials.
c_str());
123 curl_easy_setopt(session, CURLOPT_WRITEFUNCTION,
my_fwrite);
125 curl_easy_setopt(session, CURLOPT_FTPPORT,
"-");
126 curl_easy_setopt(session, CURLOPT_NOPROGRESS, 0);
127 curl_easy_setopt(session, CURLOPT_PROGRESSDATA, &pd);
128 curl_easy_setopt(session, CURLOPT_PROGRESSFUNCTION,
my_fprogress);
129 curl_easy_setopt(session, CURLOPT_DEBUGFUNCTION,
my_trace);
131 curl_easy_setopt(session, CURLOPT_FILE, &ftpfile);
134 curl_easy_setopt(session, CURLOPT_VERBOSE,
true);
135 curl_easy_setopt(session, CURLOPT_CONNECTTIMEOUT, 45);
139 #if (LIBCURL_VERSION_MAJOR > 7) || \
140 ((LIBCURL_VERSION_MAJOR == 7) && (LIBCURL_VERSION_MINOR > 10)) || \
141 ((LIBCURL_VERSION_MAJOR == 7) && (LIBCURL_VERSION_MINOR == 10) && (LIBCURL_VERSION_PATCH >= 5))
142 # define EPRT_AVAILABLE 1
145 #ifdef EPRT_AVAILABLE
146 curl_easy_setopt(session, CURLOPT_FTP_USE_EPRT, 0);
147 SWLOGD(
"***** using CURLOPT_FTP_USE_EPRT\n");
151 SWLOGD(
"***** About to perform curl easy action. \n");
152 SWLOGD(
"***** destPath: %s \n", destPath);
153 SWLOGD(
"***** sourceURL: %s \n", sourceURL);
154 res = curl_easy_perform(session);
155 SWLOGD(
"***** Finished performing curl easy action. \n");
158 curl_easy_setopt(session, CURLOPT_PROGRESSDATA, (
void*)
NULL);
160 if(CURLE_OK != res) {
167 fclose(ftpfile.stream);
static int my_trace(CURL *handle, curl_infotype type, unsigned char *data, size_t size, void *userp)
static int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
static int my_fprogress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
const char * c_str() const
StatusReporter * statusReporter