// CurlExample.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include "stdafx.h"
#include <Curl/curl.h> // Access curl library from its location
#include <iostream>

std::string serverName = "https://insertwebsitename.com"; // CHANGE


bool curlPostFile(FILE &log) {
	CURL *curl = curl_easy_init();
	if (curl) {

		//connecting to the server
		curl_easy_setopt(curl, CURLOPT_URL, serverName.c_str());
		curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
		curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);

		curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
		curl_easy_setopt(curl, CURLOPT_STDERR, log);
		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L);
		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);

		curl_easy_setopt(curl, CURLOPT_PORT, 443L);
		CURLcode curlReturn = curl_easy_perform(curl);

		std::cout << "Curl Return: " << curlReturn << std::endl;
		
		// always cleanup		
		curl_easy_cleanup(curl);
		return true;
	}
	return false;
}

int main(int argc, char *argv[]) {
	FILE * logfile;
	fopen_s(&logfile, "log.txt", "wb");
	curlPostFile(*logfile);
	fclose(logfile);
	return 0;
}

