man curl_global_init(原創)


curl_global_init(3)             libcurl 手冊             curl_global_init(3)

 

名稱

curl_global_init - libcurl庫全局的初始化

 

概要

#include <curl/curl.h>

     CURLcode curl_global_init(long flags);

 

描述

在調應libcurl庫中其他函數之前,必須先調用這個函數對編程環境進行相應的初始化,使每個程序調用libcurl庫函數都具有相同的效果。

這個按位組合選擇的整形(int)變量可以精確告訴libcurl當下的需要的工作模式。詳細情況,如果你不是十分熟悉整體參數的初始化,您可以設置參數為CURL_GLOABL_ALL。對所有的需要用到的環境進行初始化,這個函數不是安全線程,在多線程應用中,需要在主線程中調用這個函數。這個函數設置libcurl所需的環境。通常情況,如果不顯式的調用它,第一次調用 curl_easy_init()時,curl_easy_init 會調用 curl_global_init,在單線程環境下,這不是問題。但是多線程下就不行了,因為curl_global_init不是線程安全的。在多個線 程中調用curl_easy_int,然后如果兩個線程同時發現curl_global_init還沒有被調用,同時調用 curl_global_init,悲劇就發生了。這種情況發生的概率很小,但可能性是存在的。

         看到libcurl的描述(3)的全局環境要求的細節如何使用這個函數。

標志

CURL_GLOBAL_ALL

初始化所有已知設置,除了后台傳輸服務。CURL_GLOBAL_ACK_EINTR.

CURL_GLOBAL_SSL

            初始化 SSL(安全套接層)

CURL_GLOBAL_WIN32

            初始化Win32 所以共享函數包.

 

CURL_GLOBAL_NOTHING

什么都不初始化This sets no bit.

CURL_GLOBAL_DEFAULT

一個合理的默認值。它將init SSL和Win32。現在,這個等於CURL_GLOBAL_ALL面具的功能。

CURL_GLOBAL_ACK_EINTR

這個標志被設置時,旋度承認當連接或在等待數據捕獲條件。否則,旋度等待超時白白的流逝了。在7.30.0(添加)

返回值

如果這個函數返回非零,出了意外,你不能使用其他旋度函數。

另請參閱

curl_global_init_mem(3),    curl_global_cleanup(3),   curl_easy_init(3),  libcurl(3)

 

libcurl 7.12                    11 May 2004                         curl_global_init(3)

 

 

curl_global_init(3)             libcurl Manual             curl_global_init(3)

NAME
       curl_global_init - Global libcurl initialisation

SYNOPSIS
       #include <curl/curl.h>

       CURLcode curl_global_init(long flags);

DESCRIPTION
       This  function  sets  up  the  program  environment that libcurl needs.
       Think of it as an extension of the library loader.

       This function must be called at least once within a program (a  program
       is  all  the  code that shares a memory space) before the program calls
       any other function in libcurl.  The environment it sets up is  constant
       for  the life of the program and is the same for every program, so mul‐
       tiple calls have the same effect as one call.

       The flags option is a bit pattern that tells libcurl exactly what  fea‐
       tures  to  init,  as described below. Set the desired bits by ORing the
       values   together.    In   normal   operation,   you    must    specify
       CURL_GLOBAL_ALL.   Don't  use  any  other value unless you are familiar
       with it and mean to control internal operations of libcurl.

       This function is not thread safe. You must not call it when  any  other
       thread  in  the program (i.e. a thread sharing the same memory) is run‐
       ning.  This doesn't just mean no other thread that  is  using  libcurl.
       Because curl_global_init(3) calls functions of other libraries that are
       similarly thread unsafe, it could conflict with any other  thread  that
       uses these other libraries.

       If  you are initializing libcurl from a Windows DLL you should not ini‐
       tialize it from DllMain or a static initializer because  Windows  holds
       the loader lock during that time and it could cause a deadlock.

       See  the  description  in libcurl(3) of global environment requirements
       for details of how to use this function.

FLAGS
       CURL_GLOBAL_ALL
            Initialize everything possible. This sets all  known  bits  except
            CURL_GLOBAL_ACK_EINTR.

       CURL_GLOBAL_SSL
            Initialize SSL

       CURL_GLOBAL_WIN32
            Initialize the Win32 socket libraries.

       CURL_GLOBAL_NOTHING
            Initialise nothing extra. This sets no bit.

       CURL_GLOBAL_DEFAULT
            A  sensible  default.  It will init both SSL and Win32. Right now,
            this equals the functionality of the CURL_GLOBAL_ALL mask.

       CURL_GLOBAL_ACK_EINTR
            When this flag is set, curl will acknowledge EINTR condition  when
            connecting  or when waiting for data.  Otherwise, curl waits until
            full timeout elapses. (Added in 7.30.0)

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

SEE ALSO
       curl_global_init_mem(3),    curl_global_cleanup(3),   curl_easy_init(3)
       libcurl(3)

libcurl 7.12                      11 May 2004              curl_global_init(3)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM