1curl_global_init(3) libcurl Manual curl_global_init(3)
2
3
4
6 curl_global_init - Global libcurl initialisation
7
9 #include <curl/curl.h>
10
11 CURLcode curl_global_init(long flags);
12
14 This function sets up the program environment that libcurl needs.
15 Think of it as an extension of the library loader.
16
17 This function must be called at least once within a program (a program
18 is all the code that shares a memory space) before the program calls
19 any other function in libcurl. The environment it sets up is constant
20 for the life of the program and is the same for every program, so mul‐
21 tiple calls have the same effect as one call.
22
23 The flags option is a bit pattern that tells libcurl exactly what fea‐
24 tures to init, as described below. Set the desired bits by ORing the
25 values together. In normal operation, you must specify
26 CURL_GLOBAL_ALL. Don't use any other value unless you are familiar
27 with it and mean to control internal operations of libcurl.
28
29 This function is not thread safe. You must not call it when any other
30 thread in the program (i.e. a thread sharing the same memory) is run‐
31 ning. This doesn't just mean no other thread that is using libcurl.
32 Because curl_global_init(3) calls functions of other libraries that are
33 similarly thread unsafe, it could conflict with any other thread that
34 uses these other libraries.
35
36 If you are initializing libcurl from a Windows DLL you should not ini‐
37 tialize it from DllMain or a static initializer because Windows holds
38 the loader lock during that time and it could cause a deadlock.
39
40 See the description in libcurl(3) of global environment requirements
41 for details of how to use this function.
42
44 CURL_GLOBAL_ALL
45 Initialize everything possible. This sets all known bits except
46 CURL_GLOBAL_ACK_EINTR.
47
48
49 CURL_GLOBAL_SSL
50 (This flag's presence or absence serves no meaning since 7.57.0.
51 The description below is for older libcurl versions.)
52
53 Initialize SSL.
54
55 The implication here is that if this bit is not set, the ini‐
56 tialization of the SSL layer needs to be done by the application
57 or at least outside of libcurl. The exact procedure how to do
58 SSL initialization depends on the TLS backend libcurl uses.
59
60 Doing TLS based transfers without having the TLS layer initial‐
61 ized may lead to unexpected behaviors.
62
63 CURL_GLOBAL_WIN32
64 Initialize the Win32 socket libraries.
65
66 The implication here is that if this bit is not set, the ini‐
67 tialization of winsock has to be done by the application or you
68 risk getting undefined behaviors. This option exists for when
69 the initialization is handled outside of libcurl so there's no
70 need for libcurl to do it again.
71
72 CURL_GLOBAL_NOTHING
73 Initialise nothing extra. This sets no bit.
74
75 CURL_GLOBAL_DEFAULT
76 A sensible default. It will init both SSL and Win32. Right now,
77 this equals the functionality of the CURL_GLOBAL_ALL mask.
78
79 CURL_GLOBAL_ACK_EINTR
80 When this flag is set, curl will acknowledge EINTR condition
81 when connecting or when waiting for data. Otherwise, curl waits
82 until full timeout elapses. (Added in 7.30.0)
83
85 If this function returns non-zero, something went wrong and you cannot
86 use the other curl functions.
87
89 curl_global_init_mem(3), curl_global_cleanup(3), curl_global_sslset(3),
90 curl_easy_init(3) libcurl(3)
91
92
93
94libcurl 7.64.0 April 17, 2018 curl_global_init(3)