diff options
Diffstat (limited to 'src/common/curl.c')
-rw-r--r-- | src/common/curl.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/common/curl.c b/src/common/curl.c index 573180f..2cf7f3a 100644 --- a/src/common/curl.c +++ b/src/common/curl.c @@ -2,7 +2,7 @@ /* Chrysalide - Outil d'analyse de fichiers binaires * curl.c - encapsulation des fonctionnalités de cURL * - * Copyright (C) 2022 Cyrille Bagard + * Copyright (C) 2022-2024 Cyrille Bagard * * This file is part of Chrysalide. * @@ -30,7 +30,7 @@ /* Mémorise les données reçues en réponse à une requête. */ -static size_t receive_data_from_internet(void *, size_t, size_t, curl_net_data_t *); +static size_t receive_data_from_internet(void *, size_t, size_t, sized_binary_t *); @@ -49,19 +49,19 @@ static size_t receive_data_from_internet(void *, size_t, size_t, curl_net_data_t * * ******************************************************************************/ -static size_t receive_data_from_internet(void *contents, size_t size, size_t nmemb, curl_net_data_t *data) +static size_t receive_data_from_internet(void *contents, size_t size, size_t nmemb, sized_binary_t *data) { size_t realsize; /* Taille brute en octets */ realsize = size * nmemb; - data->memory = realloc(data->memory, data->size + realsize + 1); + data->data = realloc(data->data, data->size + realsize + 1); - memcpy(&(data->memory[data->size]), contents, realsize); + memcpy(&(data->data[data->size]), contents, realsize); data->size += realsize; - data->memory[data->size] = 0; + data->data[data->size] = 0; return realsize; @@ -85,7 +85,7 @@ static size_t receive_data_from_internet(void *contents, size_t size, size_t nme * * ******************************************************************************/ -bool send_http_get_request(const char *url, char * const headers[], size_t hcount, const char *cookies, setup_extra_curl_cb ecb, curl_net_data_t *resp) +bool send_http_get_request(const char *url, char * const headers[], size_t hcount, const char *cookies, setup_extra_curl_cb ecb, sized_binary_t *resp) { bool result; /* Bilan d'opération à renvoyer*/ CURL *req; /* Requête HTTP */ @@ -95,8 +95,7 @@ bool send_http_get_request(const char *url, char * const headers[], size_t hcoun result = false; - resp->memory = NULL; - resp->size = 0; + init_sized_binary(resp); req = curl_easy_init(); if (req == NULL) goto exit; @@ -165,7 +164,7 @@ bool send_http_get_request(const char *url, char * const headers[], size_t hcoun * * ******************************************************************************/ -bool send_http_post_request(const char *url, char * const headers[], size_t hcount, const char *cookies, const curl_net_data_t *payload, setup_extra_curl_cb ecb, curl_net_data_t *resp) +bool send_http_post_request(const char *url, char * const headers[], size_t hcount, const char *cookies, const sized_binary_t *payload, setup_extra_curl_cb ecb, sized_binary_t *resp) { bool result; /* Bilan d'opération à renvoyer*/ CURL *req; /* Requête HTTP */ @@ -175,8 +174,7 @@ bool send_http_post_request(const char *url, char * const headers[], size_t hcou result = false; - resp->memory = NULL; - resp->size = 0; + init_sized_binary(resp); req = curl_easy_init(); if (req == NULL) goto exit; @@ -205,7 +203,7 @@ bool send_http_post_request(const char *url, char * const headers[], size_t hcou curl_easy_setopt(req, CURLOPT_POST, 1); - curl_easy_setopt(req, CURLOPT_POSTFIELDS, payload->memory); + curl_easy_setopt(req, CURLOPT_POSTFIELDS, payload->data); curl_easy_setopt(req, CURLOPT_POSTFIELDSIZE, payload->size); /* Emission de la requête */ |