| 190 | } |
| 191 | |
| 192 | std::string cmCurlSetNETRCOption(::CURL* curl, std::string const& netrc_level, |
| 193 | std::string const& netrc_file) |
| 194 | { |
| 195 | std::string e; |
| 196 | long curl_netrc_level = CURL_NETRC_LAST; |
| 197 | ::CURLcode res; |
| 198 | |
| 199 | if (!netrc_level.empty()) { |
| 200 | if (netrc_level == "OPTIONAL") { |
| 201 | curl_netrc_level = CURL_NETRC_OPTIONAL; |
| 202 | } else if (netrc_level == "REQUIRED") { |
| 203 | curl_netrc_level = CURL_NETRC_REQUIRED; |
| 204 | } else if (netrc_level == "IGNORED") { |
| 205 | curl_netrc_level = CURL_NETRC_IGNORED; |
| 206 | } else { |
| 207 | e = cmStrCat("NETRC accepts OPTIONAL, IGNORED or REQUIRED but got: ", |
| 208 | netrc_level); |
| 209 | return e; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | if (curl_netrc_level != CURL_NETRC_LAST && |
| 214 | curl_netrc_level != CURL_NETRC_IGNORED) { |
| 215 | res = ::curl_easy_setopt(curl, CURLOPT_NETRC, curl_netrc_level); |
| 216 | check_curl_result(res, "Unable to set netrc level: "); |
| 217 | if (!e.empty()) { |
| 218 | return e; |
| 219 | } |
| 220 | |
| 221 | // check to see if a .netrc file has been specified |
| 222 | if (!netrc_file.empty()) { |
| 223 | res = ::curl_easy_setopt(curl, CURLOPT_NETRC_FILE, netrc_file.c_str()); |
| 224 | check_curl_result(res, "Unable to set .netrc file path : "); |
| 225 | } |
| 226 | } |
| 227 | return e; |
| 228 | } |
| 229 | |
| 230 | ::CURL* cm_curl_easy_init() |
| 231 | { |
no test coverage detected
searching dependent graphs…