#include <stdio.h>
#include <string.h>
#include <time.h>
#include <curl/curl.h>

clock_t begin;

size_t download(void *ptr, size_t size, size_t nmemb, void *stream) {
	fprintf(stream, "Recieved %zu bytes of data.\n", size * nmemb);
	fprintf(stream, "%f seconds have passed.\n", ((double)(clock() - begin) / CLOCKS_PER_SEC));
	return (nmemb*size);
}

int main(int argc, char **argv) {
	if(argc != 2) {
		fprintf(stderr, "usage: %s url\n", argv[0]);
		return 1;
	}

	begin = clock();
	curl_global_init(CURL_GLOBAL_ALL);
	CURL *curl = curl_easy_init();
	curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, *download);
	curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout);
	curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
	CURLcode res = curl_easy_perform(curl);
	return 0;
}