libalpm
Arch Linux Package Manager Library
dload.c File Reference
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <signal.h>
#include <dirent.h>
#include <pwd.h>
#include <curl/curl.h>
#include "dload.h"
#include "alpm_list.h"
#include "alpm.h"
#include "log.h"
#include "util.h"
#include "handle.h"
#include "sandbox.h"
Include dependency graph for dload.c:

Data Structures

struct  server_error_count
 

Macros

#define HOSTNAME_SIZE   256
 

Enumerations

enum  { ABORT_OVER_MAXFILESIZE = 1 }
 

Functions

static const char * get_filename (const char *url)
 
static mode_t _getumask (void)
 
static int finalize_download_file (const char *filename)
 
static FILE * create_tempfile (struct dload_payload *payload, const char *localpath)
 
static int curl_add_payload (alpm_handle_t *handle, CURLM *curlm, struct dload_payload *payload)
 
static int curl_gethost (const char *url, char *buffer, size_t buf_len)
 
static struct server_error_countfind_server_errors (alpm_handle_t *handle, const char *server)
 
static int should_skip_server (alpm_handle_t *handle, const char *server)
 
static int should_skip_cache_server (alpm_handle_t *handle, const char *server)
 
static void server_soft_error (alpm_handle_t *handle, const char *server)
 
static void server_hard_error (alpm_handle_t *handle, const char *server)
 
static const char * payload_next_server (struct dload_payload *payload)
 
static int dload_progress_cb (void *file, curl_off_t dltotal, curl_off_t dlnow, curl_off_t UNUSED ultotal, curl_off_t UNUSED ulnow)
 
static int utimes_long (const char *path, long seconds)
 
static size_t dload_parseheader_cb (void *ptr, size_t size, size_t nmemb, void *user)
 
static void curl_set_handle_opts (CURL *curl, struct dload_payload *payload)
 
static int curl_retry_next_server (CURLM *curlm, CURL *curl, struct dload_payload *payload)
 
static int curl_check_finished_download (alpm_handle_t *handle, CURLM *curlm, CURLMsg *msg, int *active_downloads_num)
 
static int compare_dload_payload_sizes (const void *left_ptr, const void *right_ptr)
 
static int curl_download_internal (alpm_handle_t *handle, alpm_list_t *payloads)
 
static int curl_download_internal_sandboxed (alpm_handle_t *handle, alpm_list_t *payloads, const char *localpath)
 
static int payload_download_fetchcb (struct dload_payload *payload, const char *server, const char *localpath)
 
static int move_file (const char *filepath, const char *directory)
 
static int finalize_download_locations (alpm_list_t *payloads, const char *localpath)
 
static void prepare_resumable_downloads (alpm_list_t *payloads, const char *localpath, const char *user)
 
static char * filecache_find_url (alpm_handle_t *handle, const char *url)
 
int alpm_fetch_pkgurl (alpm_handle_t *handle, const alpm_list_t *urls, alpm_list_t **fetched)
 Fetch a list of remote packages.
 

Variables

const int server_error_limit = 3
 
static int dload_interrupted
 

Data Structure Documentation

◆ server_error_count

struct server_error_count
Data Fields
int errors
char server[HOSTNAME_SIZE]

Macro Definition Documentation

◆ HOSTNAME_SIZE

#define HOSTNAME_SIZE   256

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ABORT_OVER_MAXFILESIZE 

Function Documentation

◆ _getumask()

static mode_t _getumask ( void )
static

◆ compare_dload_payload_sizes()

static int compare_dload_payload_sizes ( const void * left_ptr,
const void * right_ptr )
static

◆ create_tempfile()

static FILE * create_tempfile ( struct dload_payload * payload,
const char * localpath )
static

◆ curl_add_payload()

◆ curl_check_finished_download()

◆ curl_download_internal()

◆ curl_download_internal_sandboxed()

◆ curl_gethost()

static int curl_gethost ( const char * url,
char * buffer,
size_t buf_len )
static

◆ curl_retry_next_server()

◆ curl_set_handle_opts()

◆ dload_parseheader_cb()

static size_t dload_parseheader_cb ( void * ptr,
size_t size,
size_t nmemb,
void * user )
static

◆ dload_progress_cb()

◆ filecache_find_url()

static char * filecache_find_url ( alpm_handle_t * handle,
const char * url )
static

References dload_payload::handle.

Referenced by alpm_fetch_pkgurl().

◆ finalize_download_file()

static int finalize_download_file ( const char * filename)
static

References _getumask(), and ASSERT.

Referenced by move_file().

◆ finalize_download_locations()

◆ find_server_errors()

◆ get_filename()

static const char * get_filename ( const char * url)
static

◆ move_file()

static int move_file ( const char * filepath,
const char * directory )
static

◆ payload_download_fetchcb()

static int payload_download_fetchcb ( struct dload_payload * payload,
const char * server,
const char * localpath )
static

◆ payload_next_server()

◆ prepare_resumable_downloads()

static void prepare_resumable_downloads ( alpm_list_t * payloads,
const char * localpath,
const char * user )
static

◆ server_hard_error()

static void server_hard_error ( alpm_handle_t * handle,
const char * server )
static

◆ server_soft_error()

static void server_soft_error ( alpm_handle_t * handle,
const char * server )
static

◆ should_skip_cache_server()

static int should_skip_cache_server ( alpm_handle_t * handle,
const char * server )
static

◆ should_skip_server()

static int should_skip_server ( alpm_handle_t * handle,
const char * server )
static

◆ utimes_long()

static int utimes_long ( const char * path,
long seconds )
static

Variable Documentation

◆ dload_interrupted

int dload_interrupted
static

◆ server_error_limit

const int server_error_limit = 3