mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
ch: move curl_data and curl_callback definitions
Move the definitions of curl_data and curl_callback to be used within virCHMonitorPutNoContent. Signed-off-by: Praveen K Paladugu <praveenkpaladugu@gmail.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
72a9a91e3b
commit
db4e837598
@ -671,6 +671,28 @@ virCHMonitorCurlPerform(CURL *handle)
|
|||||||
return responseCode;
|
return responseCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct curl_data {
|
||||||
|
char *content;
|
||||||
|
size_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
curl_callback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||||
|
{
|
||||||
|
size_t content_size = size * nmemb;
|
||||||
|
struct curl_data *data = userp;
|
||||||
|
|
||||||
|
if (content_size == 0)
|
||||||
|
return content_size;
|
||||||
|
|
||||||
|
data->content = g_realloc(data->content, data->size + content_size);
|
||||||
|
|
||||||
|
memcpy(&(data->content[data->size]), contents, content_size);
|
||||||
|
data->size += content_size;
|
||||||
|
|
||||||
|
return content_size;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint)
|
virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint)
|
||||||
{
|
{
|
||||||
@ -698,28 +720,6 @@ virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct curl_data {
|
|
||||||
char *content;
|
|
||||||
size_t size;
|
|
||||||
};
|
|
||||||
|
|
||||||
static size_t
|
|
||||||
curl_callback(void *contents, size_t size, size_t nmemb, void *userp)
|
|
||||||
{
|
|
||||||
size_t content_size = size * nmemb;
|
|
||||||
struct curl_data *data = userp;
|
|
||||||
|
|
||||||
if (content_size == 0)
|
|
||||||
return content_size;
|
|
||||||
|
|
||||||
data->content = g_realloc(data->content, data->size + content_size);
|
|
||||||
|
|
||||||
memcpy(&(data->content[data->size]), contents, content_size);
|
|
||||||
data->size += content_size;
|
|
||||||
|
|
||||||
return content_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virCHMonitorGet(virCHMonitor *mon, const char *endpoint, virJSONValue **response)
|
virCHMonitorGet(virCHMonitor *mon, const char *endpoint, virJSONValue **response)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user