summaryrefslogtreecommitdiffstats
path: root/Source/cmCurl.cxx
diff options
context:
space:
mode:
authorShane Parris <shane.lee.parris@gmail.com>2017-10-18 14:26:55 (GMT)
committerBrad King <brad.king@kitware.com>2017-10-18 19:21:42 (GMT)
commit5d67e9025d1c7f1259477450831135667b6f1eeb (patch)
tree4fff01226f207564e5aef218acec11fec5c9092b /Source/cmCurl.cxx
parentcb8f26f199e18be231f40f523bfe64375e749e35 (diff)
downloadCMake-5d67e9025d1c7f1259477450831135667b6f1eeb.zip
CMake-5d67e9025d1c7f1259477450831135667b6f1eeb.tar.gz
CMake-5d67e9025d1c7f1259477450831135667b6f1eeb.tar.bz2
file(DOWNLOAD|UPLOAD): Add 'NETRC' and 'NETRC_FILE' suboption
Diffstat (limited to 'Source/cmCurl.cxx')
-rw-r--r--Source/cmCurl.cxx38
1 files changed, 38 insertions, 0 deletions
diff --git a/Source/cmCurl.cxx b/Source/cmCurl.cxx
index 341b8c0..8ef8bff 100644
--- a/Source/cmCurl.cxx
+++ b/Source/cmCurl.cxx
@@ -56,3 +56,41 @@ std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile)
#endif
return e;
}
+
+std::string cmCurlSetNETRCOption(::CURL* curl, const std::string& netrc_level,
+ const std::string& netrc_file)
+{
+ std::string e;
+ CURL_NETRC_OPTION curl_netrc_level = CURL_NETRC_LAST;
+ ::CURLcode res;
+
+ if (!netrc_level.empty()) {
+ if (netrc_level == "OPTIONAL") {
+ curl_netrc_level = CURL_NETRC_OPTIONAL;
+ } else if (netrc_level == "REQUIRED") {
+ curl_netrc_level = CURL_NETRC_REQUIRED;
+ } else if (netrc_level == "IGNORED") {
+ curl_netrc_level = CURL_NETRC_IGNORED;
+ } else {
+ e = "NETRC accepts OPTIONAL, IGNORED or REQUIRED but got: ";
+ e += netrc_level;
+ return e;
+ }
+ }
+
+ if (curl_netrc_level != CURL_NETRC_LAST &&
+ curl_netrc_level != CURL_NETRC_IGNORED) {
+ res = ::curl_easy_setopt(curl, CURLOPT_NETRC, curl_netrc_level);
+ check_curl_result(res, "Unable to set netrc level: ");
+ if (!e.empty()) {
+ return e;
+ }
+
+ // check to see if a .netrc file has been specified
+ if (!netrc_file.empty()) {
+ res = ::curl_easy_setopt(curl, CURLOPT_NETRC_FILE, netrc_file.c_str());
+ check_curl_result(res, "Unable to set .netrc file path : ");
+ }
+ }
+ return e;
+}