#include <iostream>
#include <string>

#include <curl/curl.h>

#include "easy_curl.h"

void test(const std::string& url, const std::string file)
{
	easy_curl curl;

	// Upload file
	if(curl.upload(file, url + "/__delme.txt") != CURLE_OK)
		std::cout << "Error during ftp upload " << curl.get_err_no() << std::endl;

	// Remove file
	if(curl.ftp_cmd(url + "/", "DELE __delme.txt") != CURLE_OK)
		std::cout << "Error during ftp delete " << curl.get_err_no() << std::endl;
}

int main(int argc, char* argv[])
{
	// Sanity check
	if(argc < 3)
	{
		std::cout << "Usage: " << argv[0] << " ftp://user:pass@server.com/path file_to_upload" << std::endl;
		return 1;
	}

	// Initializes curl
	curl_global_init(CURL_GLOBAL_ALL);

	// Do the test :)
	test(argv[1], argv[2]);
	
	// Closes curl
	curl_global_cleanup();

	return 0;
}
