CURLOPT_NETRC_FILE.md (1530B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_NETRC_FILE 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_NETRC (3) 9 - CURLOPT_PASSWORD (3) 10 - CURLOPT_USERNAME (3) 11 Protocol: 12 - All 13 Added-in: 7.11.0 14 --- 15 16 # NAME 17 18 CURLOPT_NETRC_FILE - filename to read .netrc info from 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NETRC_FILE, char *file); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a char pointer as parameter, pointing to a null-terminated string 31 containing the full path name to the *file* you want libcurl to use as .netrc 32 file. If this option is omitted, and CURLOPT_NETRC(3) is set, libcurl checks 33 for a .netrc file in the current user's home directory. 34 35 The application does not have to keep the string around after setting this 36 option. 37 38 Using this option multiple times makes the last set string override the 39 previous ones. Set it to NULL to disable its use again. 40 41 # DEFAULT 42 43 NULL 44 45 # %PROTOCOLS% 46 47 # EXAMPLE 48 49 ~~~c 50 int main(void) 51 { 52 CURL *curl = curl_easy_init(); 53 if(curl) { 54 CURLcode ret; 55 curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/"); 56 curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); 57 curl_easy_setopt(curl, CURLOPT_NETRC_FILE, "/tmp/magic-netrc"); 58 ret = curl_easy_perform(curl); 59 } 60 } 61 ~~~ 62 63 # %AVAILABILITY% 64 65 # RETURN VALUE 66 67 curl_easy_setopt(3) returns a CURLcode indicating success or error. 68 69 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 70 libcurl-errors(3).