#include <stdio.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
int main(void)
{
CURL *curl;
CURLcode res;
char source_url[] = "ftp://remotehost.com/path/to/source";
char target_url[] = "ftp://aotherserver.com/path/to/dest";
char sourceUserPass[] = "user:pass";
char targetUserPass[] = "user:pass";
char url[100];
struct curl_slist *source_pre_cmd = NULL;
struct curl_slist *target_pre_cmd = NULL;
struct curl_slist *source_post_cmd = NULL;
struct curl_slist *target_post_cmd = NULL;
char cmd[] = "PWD";
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, target_url);
curl_easy_setopt(curl, CURLOPT_SOURCE_URL, source_url);
curl_easy_setopt(curl, CURLOPT_USERPWD, targetUserPass);
curl_easy_setopt(curl, CURLOPT_SOURCE_USERPWD, sourceUserPass);
#if 0
curl_easy_setopt(curl, CURLOPT_FTPPORT, "");
#endif
source_pre_cmd = curl_slist_append(source_pre_cmd, cmd);
curl_easy_setopt(curl, CURLOPT_SOURCE_PREQUOTE, source_pre_cmd);
target_pre_cmd = curl_slist_append(target_pre_cmd, cmd);
curl_easy_setopt(curl, CURLOPT_PREQUOTE, target_pre_cmd);
source_post_cmd = curl_slist_append(source_post_cmd, cmd);
curl_easy_setopt(curl, CURLOPT_SOURCE_POSTQUOTE, source_post_cmd);
target_post_cmd = curl_slist_append(target_post_cmd, cmd);
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, target_post_cmd);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
res = curl_easy_perform(curl);
curl_slist_free_all(source_pre_cmd);
curl_slist_free_all(target_pre_cmd);
curl_slist_free_all(source_post_cmd);
curl_slist_free_all(target_post_cmd);
curl_easy_cleanup(curl);
if(CURLE_OK != res) {
fprintf(stderr, "curl told us %d\n", res);
}
}
curl_global_cleanup();
return 0;
}