#include "bom.hpp" #include "book.hpp" #include #include #include #include #include #include namespace bom { static size_t my_fwrite(void* buffer, size_t size, size_t nmemb, void* stream) { FILE* out = (FILE*)stream; if (!out) { out = tmpfile(); if (!out) { return -1; } } return fwrite(buffer, size, nmemb, out); } void updateBom(std::unordered_map& bs) { CURL* curl; CURLcode res; FILE* f{NULL}; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.bom.gov.au/anon/gen/fwo/IDN60920.xml"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &f); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); curl_easy_cleanup(curl); if (CURLE_OK != res) { fprintf(stderr, "Curl failed: %d\n", res); } } if (f) { fclose(f); } curl_global_cleanup(); } } // namespace bom