Use of libcurl library in Cocos2d-x (1) view library version information

Source: Internet
Author: User
Use the following code to check the libcurl library version information used in the Cocos2d-x # if (CC_TARGET_PLATFORMCC_PLATFORM_IOS) # include .. example. h # endif # if (CC_TARGET_PLATFORMCC_PLATFORM_ANDROID) # include .. cocos2dexternal

Use the following code to check the version information of the libcurl library used in the Cocos2d-x # if (CC_TARGET_PLATFORM = CC_PLATFORM_IOS) # include .. /cocos2d/external/curl/include/ios/curl. h # endif # if (CC_TARGET_PLATFORM = CC_PLATFORM_ANDROID) # include .. /cocos2d/external/

Use the following code to detect version information for libcurl libraries used in the Cocos2d-x

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)#include "../cocos2d/external/curl/include/ios/curl/curl.h"#endif#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)#include "../cocos2d/external/curl/include/android/curl/curl.h"#endifint getVersion(){    CURLcode  return_code;    return_code = curl_global_init(CURL_GLOBAL_ALL);        if(CURLE_OK != return_code)    {        log("init libcurl failed");        return -1;    }        log("curl_version=%s",curl_version());    curl_version_info_data *p = curl_version_info(CURLVERSION_NOW);    log("curl_version_info_data = %u",p->version_num);    curl_global_cleanup();    return 0;}

1. The parameter flag of curl_global_init

CURL_GLOBAL_ALL Initialize everything possible. This sets all known bits should t 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)

2. curl_version_info_data struct

typedef struct {  CURLversion age;          /* age of the returned struct */  const char *version;      /* LIBCURL_VERSION */  unsigned int version_num; /* LIBCURL_VERSION_NUM */  const char *host;         /* OS/host/cpu/machine when configured */  int features;             /* bitmask, see defines below */  const char *ssl_version;  /* human readable string */  long ssl_version_num;     /* not used anymore, always 0 */  const char *libz_version; /* human readable string */  /* protocols is terminated by an entry with a NULL protoname */  const char * const *protocols;  /* The fields below this were added in CURLVERSION_SECOND */  const char *ares;  int ares_num;  /* This field was added in CURLVERSION_THIRD */  const char *libidn;  /* These field were added in CURLVERSION_FOURTH */  /* Same as '_libiconv_version' if built with HAVE_ICONV */  int iconv_ver_num;  const char *libssh_version; /* human readable string */} curl_version_info_data;
3. curl_global_init initializes libcurl. CURL_GLOBAL_ALL will enable libcurl to initialize all sub-modules and some default options. This is a better default value.

4. curl_global_cleanup: release resources. curl_global_init and curl_global_cleanup can only be called once.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.