1CURLOPT_NETRC(3)           curl_easy_setopt options           CURLOPT_NETRC(3)
2
3
4

NAME

6       CURLOPT_NETRC - request that .netrc is used
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NETRC, long level);
12

DESCRIPTION

14       This  parameter  controls the preference level of libcurl between using
15       user names and passwords from your  ~/.netrc  file,  relative  to  user
16       names  and  passwords  in the URL supplied with CURLOPT_URL(3). On Win‐
17       dows, libcurl will use the file as %HOME%/_netrc, but you can also tell
18       libcurl a different file name to use with CURLOPT_NETRC_FILE(3).
19
20       libcurl  uses  a user name (and supplied or prompted password) supplied
21       with CURLOPT_USERPWD(3) or CURLOPT_USERNAME(3) in preference to any  of
22       the options controlled by this parameter.
23
24       Only  machine name, user name and password are taken into account (init
25       macros and similar things aren't supported).
26
27       libcurl does not verify that the file has the  correct  properties  set
28       (as  the  standard Unix ftp client does). It should only be readable by
29       user.
30
31       level should be set to one of the values described below.
32
33
34       CURL_NETRC_OPTIONAL
35              The use of your ~/.netrc file is optional,  and  information  in
36              the  URL  is  to be preferred.  The file will be scanned for the
37              host and user name (to find the password only) or for  the  host
38              only,  to  find  the  first  user  name  and password after that
39              machine, which ever information is not specified in the URL.
40
41              Undefined values of the option will have this effect.
42
43       CURL_NETRC_IGNORED
44              The library will ignore the file and use only the information in
45              the URL.
46
47              This is the default.
48
49       CURL_NETRC_REQUIRED
50              This  value  tells the library that use of the file is required,
51              to ignore the information in the URL, and to search the file for
52              the host only.
53

DEFAULT

55       CURL_NETRC_IGNORED
56

PROTOCOLS

58       Most
59

EXAMPLE

61       CURL *curl = curl_easy_init();
62       if(curl) {
63         CURLcode ret;
64         curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/");
65         curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
66         ret = curl_easy_perform(curl);
67       }
68

AVAILABILITY

70       Always
71

RETURN VALUE

73       Returns CURLE_OK
74

SEE ALSO

76       CURLOPT_USERPWD(3), CURLOPT_USERNAME(3), CURLOPT_NETRC_FILE(3),
77
78
79
80libcurl 7.61.1                   May 02, 2018                 CURLOPT_NETRC(3)
Impressum