2
0

curl_global_init.3 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .TH curl_global_init 3 "11 May 2004" "libcurl" "libcurl"
  25. .SH NAME
  26. curl_global_init - Global libcurl initialization
  27. .SH SYNOPSIS
  28. .nf
  29. #include <curl/curl.h>
  30. CURLcode curl_global_init(long flags);
  31. .fi
  32. .SH DESCRIPTION
  33. This function sets up the program environment that libcurl needs. Think of it
  34. as an extension of the library loader.
  35. This function must be called at least once within a program (a program is all
  36. the code that shares a memory space) before the program calls any other
  37. function in libcurl. The environment it sets up is constant for the life of
  38. the program and is the same for every program, so multiple calls have the same
  39. effect as one call.
  40. The flags option is a bit pattern that tells libcurl exactly what features to
  41. init, as described below. Set the desired bits by ORing the values together.
  42. In normal operation, you must specify CURL_GLOBAL_ALL. Do not use any other
  43. value unless you are familiar with it and mean to control internal operations
  44. of libcurl.
  45. This function is thread-safe since libcurl 7.84.0 if
  46. \fIcurl_version_info(3)\fP has the CURL_VERSION_THREADSAFE feature bit set
  47. (most platforms).
  48. If this is not thread-safe, you must not call this function when any other
  49. thread in the program (i.e. a thread sharing the same memory) is running.
  50. This does not just mean no other thread that is using libcurl. Because
  51. \fIcurl_global_init(3)\fP calls functions of other libraries that are
  52. similarly thread unsafe, it could conflict with any other thread that uses
  53. these other libraries.
  54. If you are initializing libcurl from a Windows DLL you should not initialize
  55. it from \fIDllMain\fP or a static initializer because Windows holds the loader
  56. lock during that time and it could cause a deadlock.
  57. See the description in \fIlibcurl(3)\fP of global environment requirements for
  58. details of how to use this function.
  59. .SH FLAGS
  60. .IP CURL_GLOBAL_ALL
  61. Initialize everything possible. This sets all known bits except
  62. \fBCURL_GLOBAL_ACK_EINTR\fP.
  63. .IP CURL_GLOBAL_SSL
  64. (This flag's presence or absence serves no meaning since 7.57.0. The
  65. description below is for older libcurl versions.)
  66. Initialize SSL.
  67. The implication here is that if this bit is not set, the initialization of the
  68. SSL layer needs to be done by the application or at least outside of
  69. libcurl. The exact procedure how to do SSL initialization depends on the TLS
  70. backend libcurl uses.
  71. Doing TLS based transfers without having the TLS layer initialized may lead to
  72. unexpected behaviors.
  73. .IP CURL_GLOBAL_WIN32
  74. Initialize the Win32 socket libraries.
  75. The implication here is that if this bit is not set, the initialization of
  76. winsock has to be done by the application or you risk getting undefined
  77. behaviors. This option exists for when the initialization is handled outside
  78. of libcurl so there's no need for libcurl to do it again.
  79. .IP CURL_GLOBAL_NOTHING
  80. Initialize nothing extra. This sets no bit.
  81. .IP CURL_GLOBAL_DEFAULT
  82. A sensible default. It will init both SSL and Win32. Right now, this equals
  83. the functionality of the \fBCURL_GLOBAL_ALL\fP mask.
  84. .IP CURL_GLOBAL_ACK_EINTR
  85. This bit has no point since 7.69.0 but its behavior is instead the default.
  86. Before 7.69.0: when this flag is set, curl will acknowledge EINTR condition
  87. when connecting or when waiting for data. Otherwise, curl waits until full
  88. timeout elapses. (Added in 7.30.0)
  89. .SH EXAMPLE
  90. .nf
  91. curl_global_init(CURL_GLOBAL_DEFAULT);
  92. /* use libcurl, then before exiting... */
  93. curl_global_cleanup();
  94. .fi
  95. .SH AVAILABILITY
  96. Added in 7.8
  97. .SH RETURN VALUE
  98. If this function returns non-zero, something went wrong and you cannot use the
  99. other curl functions.
  100. .SH "SEE ALSO"
  101. .BR curl_global_init_mem "(3), "
  102. .BR curl_global_cleanup "(3), "
  103. .BR curl_global_sslset "(3), "
  104. .BR curl_easy_init "(3) "
  105. .BR libcurl "(3) "