Skip to content

Commit

Permalink
Merge pull request #130 from sanchit-saini/ubuntu-libcurl-1
Browse files Browse the repository at this point in the history
Add checks for remaining MACROS to handle older libcurl
  • Loading branch information
lawremi authored Aug 23, 2024
2 parents c9b53de + d11cdd7 commit 32cd3c2
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/ucsc/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ time_t header_get_last_modified(CURL *curl) {
curl_off_t last_modified;

#if LIBCURL_VERSION_NUM >= 0x073b00
#define FILETIME CURLINFO_FILETIME_T
#define CI_FILETIME CURLINFO_FILETIME_T
#else
#define FILETIME CURLINFO_FILETIME
#define CI_FILETIME CURLINFO_FILETIME
#endif

CURLcode status = curl_easy_getinfo(curl, FILETIME, &last_modified);
CURLcode status = curl_easy_getinfo(curl, CI_FILETIME, &last_modified);

if ((CURLE_OK == status) && (last_modified >= 0)) {
struct tm *utc_tm_info = gmtime(&last_modified);
Expand All @@ -37,8 +37,14 @@ time_t header_get_last_modified(CURL *curl) {

long long header_get_content_length(CURL *curl) {
curl_off_t content_length;
CURLcode status = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T,
&content_length);

#if LIBCURL_VERSION_NUM >= 0x073700
#define CI_CONTENT_LENGTH CURLINFO_CONTENT_LENGTH_DOWNLOAD_T
#else
#define CI_CONTENT_LENGTH CURLINFO_CONTENT_LENGTH_DOWNLOAD
#endif

CURLcode status = curl_easy_getinfo(curl, CI_CONTENT_LENGTH, &content_length);

// could not retrieve length
if (content_length == -1)
Expand Down Expand Up @@ -160,7 +166,14 @@ int netUrlOpenSockets(char *url, int *retCtrlSocket) {
} else if (startsWith("ftp://", url)) {
curl_socket_t ctrlSocket;
CURLcode status = wrapped_curl_request(curl, GET);
curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &ctrlSocket);

#if LIBCURL_VERSION_NUM >= 0x072d00
#define CI_SOCKET CURLINFO_ACTIVESOCKET
#else
#define CI_SOCKET CURLINFO_LASTSOCKET
#endif

curl_easy_getinfo(curl, CI_SOCKET, &ctrlSocket);

if (retCtrlSocket != NULL)
*retCtrlSocket = ctrlSocket;
Expand Down

0 comments on commit 32cd3c2

Please sign in to comment.