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

Cocos2d-x中libcurl库的使用(1)查看库的版本信息,第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 == CC_PLATFORM_ANDROID)#in

使用如下代码,可检测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"#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、curl_global_init的参数flag

CURL_GLOBAL_ALLInitialize everything possible. This sets all kNown bits exceptCURL_GLOBAL_ACK_EINTR.

CURL_GLOBAL_SSLInitialize SSL

CURL_GLOBAL_WIN32Initialize the Win32 socket librarIEs.

CURL_GLOBAL_nothingInitialise nothing extra. This sets no bit.

CURL_GLOBAL_DEFAulTA sensible default. It will init both SSL and Win32. Right Now,this equals the functionality of theCURL_GLOBAL_ALLmask.

CURL_GLOBAL_ACK_EINTRWhen 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)查看库的版本信息所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1021111.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-23
下一篇2022-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存