使用如下代码,可检测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#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_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只能被调用一次。