1curl_global_init(3)             libcurl Manual             curl_global_init(3)
2
3
4

NAME

6       curl_global_init - Global libcurl initialization
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_global_init(long flags);
12

DESCRIPTION

14       This function sets up the program environment that libcurl needs. Think
15       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.  Do  not  use  any other value unless you are familiar
27       with it and mean to control internal operations of libcurl.
28
29       This  function  is  thread-safe  since  libcurl  7.84.0  if   curl_ver‐
30       sion_info(3)  has  the  CURL_VERSION_THREADSAFE  feature  bit set (most
31       platforms).
32
33       If this is not thread-safe, you must not call this  function  when  any
34       other  thread in the program (i.e. a thread sharing the same memory) is
35       running.  This does not  just  mean  no  other  thread  that  is  using
36       libcurl. Because curl_global_init(3) calls functions of other libraries
37       that are similarly thread unsafe, it  could  conflict  with  any  other
38       thread that uses these other libraries.
39
40       If  you are initializing libcurl from a Windows DLL you should not ini‐
41       tialize it from DllMain or a static initializer because  Windows  holds
42       the loader lock during that time and it could cause a deadlock.
43
44       See  the  description  in libcurl(3) of global environment requirements
45       for details of how to use this function.
46

FLAGS

48       CURL_GLOBAL_ALL
49              Initialize everything possible. This sets all known bits  except
50              CURL_GLOBAL_ACK_EINTR.
51
52
53       CURL_GLOBAL_SSL
54              (This flag's presence or absence serves no meaning since 7.57.0.
55              The description below is for older libcurl versions.)
56
57              Initialize SSL.
58
59              The implication here is that if this bit is not  set,  the  ini‐
60              tialization of the SSL layer needs to be done by the application
61              or at least outside of libcurl. The exact procedure  how  to  do
62              SSL initialization depends on the TLS backend libcurl uses.
63
64              Doing  TLS based transfers without having the TLS layer initial‐
65              ized may lead to unexpected behaviors.
66
67       CURL_GLOBAL_WIN32
68              Initialize the Win32 socket libraries.
69
70              The implication here is that if this bit is not  set,  the  ini‐
71              tialization  of winsock has to be done by the application or you
72              risk getting undefined behaviors. This option  exists  for  when
73              the  initialization  is handled outside of libcurl so there's no
74              need for libcurl to do it again.
75
76       CURL_GLOBAL_NOTHING
77              Initialize nothing extra. This sets no bit.
78
79       CURL_GLOBAL_DEFAULT
80              A sensible default. It will init both SSL and Win32. Right  now,
81              this equals the functionality of the CURL_GLOBAL_ALL mask.
82
83       CURL_GLOBAL_ACK_EINTR
84              This  bit  has no point since 7.69.0 but its behavior is instead
85              the default.
86
87              Before 7.69.0: when this flag  is  set,  curl  will  acknowledge
88              EINTR condition when connecting or when waiting for data. Other‐
89              wise, curl waits until full timeout elapses. (Added in 7.30.0)
90

EXAMPLE

92        curl_global_init(CURL_GLOBAL_DEFAULT);
93
94        /* use libcurl, then before exiting... */
95
96        curl_global_cleanup();
97

AVAILABILITY

99       Added in 7.8
100

RETURN VALUE

102       If this function returns non-zero, something went wrong and you  cannot
103       use the other curl functions.
104

SEE ALSO

106       curl_global_init_mem(3), curl_global_cleanup(3), curl_global_sslset(3),
107       curl_easy_init(3) libcurl(3)
108
109
110
111libcurl 8.0.1                  January 02, 2023            curl_global_init(3)
Impressum