最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

Cocos2d-x中libcurl库的使用(1)查看库的版本信息

来源:动视网 责编:小采 时间:2020-11-09 08:32:21
文档

Cocos2d-x中libcurl库的使用(1)查看库的版本信息

Cocos2d-x中libcurl库的使用(1)查看库的版本信息:使用如下代码,可检测Cocos2d-x中使用的libcurl库的版本信息 #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)#include ../cocos2d/external/curl/include/ios/curl/curl.h#endif#if (CC_TARGET_PLATFORM ==
推荐度:
导读Cocos2d-x中libcurl库的使用(1)查看库的版本信息:使用如下代码,可检测Cocos2d-x中使用的libcurl库的版本信息 #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)#include ../cocos2d/external/curl/include/ios/curl/curl.h#endif#if (CC_TARGET_PLATFORM ==


使用如下代码,可检测Cocos2d-x中使用的libcurl库的版本信息 #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/

使用如下代码,可检测Cocos2d-x中使用的libcurl库的版本信息

#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"
#endif

int 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、curl_global_init的参数flag

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)

2、curl_version_info_data结构体
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初始化libcurl,CURL_GLOBAL_ALL会使libcurl初始化所有的子模块和一些默认的选项,这个一个比较好的默认值

4、curl_global_cleanup,释放资源,curl_global_init和curl_global_cleanup只能被调用一次。


文档

Cocos2d-x中libcurl库的使用(1)查看库的版本信息

Cocos2d-x中libcurl库的使用(1)查看库的版本信息:使用如下代码,可检测Cocos2d-x中使用的libcurl库的版本信息 #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)#include ../cocos2d/external/curl/include/ios/curl/curl.h#endif#if (CC_TARGET_PLATFORM ==
推荐度:
标签: 信息 查看 使用
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top