XBPS Library API 20240111
The X Binary Package System
Functions
Download functions

Functions

int xbps_fetch_file (struct xbps_handle *xhp, const char *uri, const char *flags)
 
int xbps_fetch_file_sha256 (struct xbps_handle *xhp, const char *uri, const char *flags, unsigned char *digest, size_t digestlen)
 
int xbps_fetch_file_dest (struct xbps_handle *xhp, const char *uri, const char *filename, const char *flags)
 
int xbps_fetch_file_dest_sha256 (struct xbps_handle *xhp, const char *uri, const char *filename, const char *flags, unsigned char *digest, size_t digestlen)
 
const char * xbps_fetch_error_string (void)
 

Detailed Description

XBPS download related functions, frontend for NetBSD's libfetch.

Function Documentation

◆ xbps_fetch_file()

int xbps_fetch_file ( struct xbps_handle xhp,
const char *  uri,
const char *  flags 
)

Download a file from a remote URL to current working directory.

Parameters
[in]xhpPointer to an xbps_handle struct.
[in]uriRemote URI string.
[in]flagsFlags passed to libfetch's fetchXget().
Returns
-1 on error, 0 if not downloaded (because local/remote size/mtime do not match) and 1 if downloaded successfully.

Definition at line 362 of file download.c.

References xbps_fetch_file_sha256().

Here is the call graph for this function:

◆ xbps_fetch_file_sha256()

int xbps_fetch_file_sha256 ( struct xbps_handle xhp,
const char *  uri,
const char *  flags,
unsigned char *  digest,
size_t  digestlen 
)

Download and digest a file from a remote URL to current working directory.

Parameters
[in]xhpPointer to an xbps_handle struct.
[in]uriRemote URI string.
[in]flagsFlags passed to libfetch's fetchXget().
[out]digestSHA256 digest buffer for the downloaded file or NULL.
[in]digestlenSize of digest if specified; must be at least XBPS_SHA256_DIGEST_SIZE.
Returns
-1 on error, 0 if not downloaded (because local/remote size/mtime do not match) and 1 if downloaded successfully.

Definition at line 346 of file download.c.

References xbps_fetch_file_dest_sha256().

Referenced by xbps_fetch_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xbps_fetch_file_dest()

int xbps_fetch_file_dest ( struct xbps_handle xhp,
const char *  uri,
const char *  filename,
const char *  flags 
)

Download a file from a remote URL to current working directory, and writing file to filename.

Parameters
[in]xhpPointer to an xbps_handle struct.
[in]uriRemote URI string.
[in]filenameLocal filename to safe the file
[in]flagsFlags passed to libfetch's fetchXget().
Returns
-1 on error, 0 if not downloaded (because local/remote size/mtime do not match) and 1 if downloaded successfully.

Definition at line 339 of file download.c.

References xbps_fetch_file_dest_sha256().

Here is the call graph for this function:

◆ xbps_fetch_file_dest_sha256()

int xbps_fetch_file_dest_sha256 ( struct xbps_handle xhp,
const char *  uri,
const char *  filename,
const char *  flags,
unsigned char *  digest,
size_t  digestlen 
)

Download and digest a file from a remote URL to current working directory, and writing file to filename.

Parameters
[in]xhpPointer to an xbps_handle struct.
[in]uriRemote URI string.
[in]filenameLocal filename to safe the file
[in]flagsFlags passed to libfetch's fetchXget().
[out]digestSHA256 digest buffer of the downloaded file or NULL.
[in]digestlenSize of digest if specified; must be at least XBPS_SHA256_DIGEST_SIZE.
Returns
-1 on error, 0 if not downloaded (because local/remote size/mtime do not match) and 1 if downloaded successfully.

Definition at line 98 of file download.c.

References xbps_strlcat(), xbps_strlcpy(), and xbps_xasprintf().

Referenced by xbps_fetch_file_dest(), and xbps_fetch_file_sha256().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xbps_fetch_error_string()

const char * xbps_fetch_error_string ( void  )

Returns last error string reported by xbps_fetch_file().

Returns
A string with the appropiate error message.

Definition at line 89 of file download.c.