#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#ifdef HAVE_LIBCURL
#include <curl/curl.h>
#endif
#include "dload.h"
#include "alpm_list.h"
#include "alpm.h"
#include "log.h"
#include "util.h"
#include "handle.h"
#ifdef HAVE_LIBCURL
static const char *get_filename(const char *url)
{
char *filename = strrchr(url, '/');
if(filename != NULL) {
filename++;
}
return filename;
}
static char *get_fullpath(const char *path, const char *filename,
const char *suffix)
{
char *filepath;
size_t len = strlen(path) + strlen(filename) + strlen(suffix) + 1;
MALLOC(filepath, len, return NULL);
snprintf(filepath, len, "%s%s%s", path, filename, suffix);
return filepath;
}
static CURL *get_libcurl_handle(alpm_handle_t *handle)
{
if(!handle->curl) {
curl_global_init(CURL_GLOBAL_SSL);
handle->curl = curl_easy_init();
}
return handle->curl;
}
enum {
ABORT_SIGINT = 1,
ABORT_OVER_MAXFILESIZE
};
static int dload_interrupted;
static void inthandler(int UNUSED signum)
{
dload_interrupted = ABORT_SIGINT;
}
static int curl_progress(void *file, double dltotal, double dlnow,
double UNUSED ultotal,
|