c - How to get and compare libcurl version? -


i using libcurl setting oauth 2.0 access token. since libcurl 7.33 curlcode curl_easy_setopt(curl *handle, curlopt_xoauth2_bearer, char *token); option added. need libcurl version , compare 7.33. in case version 7.33 or higher use curlopt_xoauth2_bearer otherwise else. know should somehow use curl_version_info_data *curl_version_info( curlversion type ); have no idea, how data in struct , how compare them 7.33 version. can me?

if want detect version @ run-time, can use curl_version_info() in style this:

curl_version_info_data *d = curl_version_info(curlversion_now);  /* compare 24 bit hex number in 8 bit fields */ if(d->version_num >= 0x072100) {   /* libcurl 7.33.0 or later */   printf("succcess\n"); } else {   printf("a old version\n"); } 

if prefer detection build-time, can use preprocessor #if expression this:

#include <curl/curl.h> #if libcurl_version_num >= 0x072100  /* 7.33.0 or later */ #else  /* work-around older libcurls */ #endif 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -