New upstream version 21.0.2+dfsg1

This commit is contained in:
Sebastian Ramacher 2018-02-19 20:54:37 +01:00
parent 1f1bbb3518
commit baafb6325b
706 changed files with 49633 additions and 5044 deletions

View file

@ -117,6 +117,7 @@ static bool do_http_request(struct update_info *info, const char *url,
curl_easy_setopt(info->curl, CURLOPT_WRITEFUNCTION, http_write);
curl_easy_setopt(info->curl, CURLOPT_WRITEDATA, info);
curl_easy_setopt(info->curl, CURLOPT_FAILONERROR, true);
curl_easy_setopt(info->curl, CURLOPT_NOSIGNAL, 1);
if (!info->remote_url) {
// We only care about headers from the main package file
@ -523,3 +524,53 @@ update_info_t *update_info_create(
return info;
}
static void *single_file_thread(void *data)
{
struct update_info *info = data;
struct file_download_data download_data;
long response_code;
info->curl = curl_easy_init();
if (!info->curl) {
warn("Could not initialize Curl");
return NULL;
}
if (!do_http_request(info, info->url, &response_code))
return NULL;
if (!info->file_data.array || !info->file_data.array[0])
return NULL;
download_data.name = info->url;
download_data.version = 0;
download_data.buffer.da = info->file_data.da;
info->callback(info->param, &download_data);
info->file_data.da = download_data.buffer.da;
return NULL;
}
update_info_t *update_info_create_single(
const char *log_prefix,
const char *user_agent,
const char *file_url,
confirm_file_callback_t confirm_callback,
void *param)
{
struct update_info *info;
if (!log_prefix)
log_prefix = "";
info = bzalloc(sizeof(*info));
info->log_prefix = bstrdup(log_prefix);
info->user_agent = bstrdup(user_agent);
info->url = bstrdup(file_url);
info->callback = confirm_callback;
info->param = param;
if (pthread_create(&info->thread, NULL, single_file_thread, info) == 0)
info->thread_created = true;
return info;
}

View file

@ -1,5 +1,7 @@
#pragma once
#include <util/darray.h>
struct update_info;
typedef struct update_info update_info_t;
@ -21,4 +23,10 @@ update_info_t *update_info_create(
const char *cache_dir,
confirm_file_callback_t confirm_callback,
void *param);
update_info_t *update_info_create_single(
const char *log_prefix,
const char *user_agent,
const char *file_url,
confirm_file_callback_t confirm_callback,
void *param);
void update_info_destroy(update_info_t *info);