CURLOPT_NETRC.3 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .\"
  23. .TH CURLOPT_NETRC 3 "17 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options"
  24. .SH NAME
  25. CURLOPT_NETRC \- enable use of .netrc
  26. .SH SYNOPSIS
  27. .nf
  28. #include <curl/curl.h>
  29. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NETRC, long level);
  30. .fi
  31. .SH DESCRIPTION
  32. This parameter controls the preference \fIlevel\fP of libcurl between using
  33. user names and passwords from your \fI~/.netrc\fP file, relative to user names
  34. and passwords in the URL supplied with \fICURLOPT_URL(3)\fP. On Windows,
  35. libcurl will use the file as \fI%HOME%/_netrc\fP, but you can also tell
  36. libcurl a different file name to use with \fICURLOPT_NETRC_FILE(3)\fP.
  37. libcurl uses a user name (and supplied or prompted password) supplied with
  38. \fICURLOPT_USERPWD(3)\fP or \fICURLOPT_USERNAME(3)\fP in preference to any of
  39. the options controlled by this parameter.
  40. Only machine name, user name and password are taken into account (init macros
  41. and similar things are not supported).
  42. libcurl does not verify that the file has the correct properties set (as the
  43. standard Unix ftp client does). It should only be readable by user.
  44. \fIlevel\fP is a long that should be set to one of the values described below.
  45. .IP "CURL_NETRC_IGNORED (0)"
  46. The library will ignore the \fI.netrc\fP file. This is the default.
  47. .IP "CURL_NETRC_OPTIONAL (1)"
  48. The use of the \fI.netrc\fP file is optional, and information in the URL is to
  49. be preferred. The file will be scanned for the host and user name (to find
  50. the password only) or for the host only, to find the first user name and
  51. password after that \fImachine\fP, which ever information is not specified.
  52. .IP "CURL_NETRC_REQUIRED (2)"
  53. The use of the \fI.netrc\fP file is required, and any credential information
  54. present in the URL is ignored. The file will be scanned for the host and user
  55. name (to find the password only) or for the host only, to find the first user
  56. name and password after that \fImachine\fP, which ever information is not
  57. specified.
  58. .SH DEFAULT
  59. CURL_NETRC_IGNORED
  60. .SH PROTOCOLS
  61. Most
  62. .SH EXAMPLE
  63. .nf
  64. CURL *curl = curl_easy_init();
  65. if(curl) {
  66. CURLcode ret;
  67. curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/");
  68. curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
  69. ret = curl_easy_perform(curl);
  70. }
  71. .fi
  72. .SH AVAILABILITY
  73. Always
  74. .SH RETURN VALUE
  75. Returns CURLE_OK
  76. .SH "SEE ALSO"
  77. .BR CURLOPT_USERPWD "(3), " CURLOPT_USERNAME "(3), " CURLOPT_NETRC_FILE "(3), "