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

Functions

bool xbps_remove_pkgname_from_array (xbps_array_t array, const char *pkgname)
 
bool xbps_remove_string_from_array (xbps_array_t array, const char *str)
 
int xbps_mkpath (const char *path, mode_t mode)
 
char * xbps_xasprintf (const char *fmt,...) __attribute__((format(printf
 
char bool xbps_mmap_file (const char *file, void **mmf, size_t *mmflen, size_t *filelen)
 
bool xbps_file_sha256 (char *dst, size_t len, const char *file)
 
bool xbps_file_sha256_raw (unsigned char *dst, size_t len, const char *file)
 
int xbps_file_sha256_check (const char *file, const char *sha256)
 
bool xbps_verify_signature (struct xbps_repo *repo, const char *sigfile, unsigned char *digest)
 
bool xbps_verify_file_signature (struct xbps_repo *repo, const char *fname)
 
int xbps_pkg_is_installed (struct xbps_handle *xhp, const char *pkg)
 
bool xbps_pkg_is_ignored (struct xbps_handle *xhp, const char *pkg)
 
bool xbps_binpkg_exists (struct xbps_handle *xhp, xbps_dictionary_t pkgd)
 
bool xbps_remote_binpkg_exists (struct xbps_handle *xhp, xbps_dictionary_t pkgd)
 
bool xbps_repository_is_remote (const char *uri)
 
char * xbps_repository_pkg_path (struct xbps_handle *xhp, xbps_dictionary_t pkgd)
 
ssize_t xbps_pkg_path (struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd)
 
ssize_t xbps_pkg_url (struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd)
 
ssize_t xbps_pkg_path_or_url (struct xbps_handle *xhp, char *dst, size_t dstsz, xbps_dictionary_t pkgd)
 
bool xbps_pkg_name (char *dst, size_t len, const char *pkg)
 
bool xbps_pkgpattern_name (char *dst, size_t len, const char *pattern)
 
const char * xbps_pkg_version (const char *pkg)
 
char * xbps_binpkg_pkgver (const char *pkg)
 
char * xbps_binpkg_arch (const char *pkg)
 
const char * xbps_pkgpattern_version (const char *pattern)
 
int xbps_pkgpattern_match (const char *pkgver, const char *pattern)
 
const char * xbps_pkg_revision (const char *pkg)
 
bool xbps_pkg_arch_match (struct xbps_handle *xhp, const char *orig, const char *target)
 
int xbps_humanize_number (char *buf, int64_t bytes)
 
size_t xbps_strlcat (char *dst, const char *src, size_t dstsize)
 
size_t xbps_strlcpy (char *dst, const char *src, size_t dstsize)
 
bool xbps_pkg_reverts (xbps_dictionary_t pkg, const char *pkgver)
 
int xbps_cmpver (const char *pkg1, const char *pkg2)
 
char * xbps_pubkey2fp (xbps_data_t pubkey)
 
char * xbps_sanitize_path (const char *src)
 
ssize_t xbps_path_clean (char *path)
 
ssize_t xbps_path_rel (char *dst, size_t len, const char *from, const char *to)
 
ssize_t xbps_path_join (char *dst, size_t len,...)
 
ssize_t xbps_path_append (char *dst, size_t len, const char *suffix)
 
ssize_t xbps_path_prepend (char *dst, size_t len, const char *prefix)
 
char * xbps_symlink_target (struct xbps_handle *xhp, const char *path, const char *target)
 
bool xbps_patterns_match (xbps_array_t patterns, const char *path)
 
xbps_array_t xbps_plist_array_from_file (const char *path)
 
xbps_dictionary_t xbps_plist_dictionary_from_file (const char *path)
 

Detailed Description

Function Documentation

◆ xbps_remove_pkgname_from_array()

bool xbps_remove_pkgname_from_array ( xbps_array_t  array,
const char *  pkgname 
)

Removes a string object matching pkgname in the array array of strings.

Parameters
[in]arrayProplib array of strings.
[in]pkgnamepkgname string object to remove.
Returns
true on success, false otherwise.

Definition at line 112 of file plist_remove.c.

◆ xbps_remove_string_from_array()

bool xbps_remove_string_from_array ( xbps_array_t  array,
const char *  str 
)

Removes a string object matching str in the array array of strings.

Parameters
[in]arrayProplib array of strings.
[in]strstring object to remove.
Returns
true on success, false otherwise.

Definition at line 106 of file plist_remove.c.

Referenced by xbps_alternatives_set(), xbps_alternatives_unregister(), and xbps_repo_remove().

Here is the caller graph for this function:

◆ xbps_mkpath()

int xbps_mkpath ( const char *  path,
mode_t  mode 
)

Creates a directory (and required components if necessary).

Parameters
[in]pathPath for final directory.
[in]modeMode for final directory (0755 if not specified).
Returns
0 on success, -1 on error and errno set appropiately.

Definition at line 42 of file mkpath.c.

Referenced by xbps_pkgdb_lock(), xbps_repo_key_import(), and xbps_transaction_commit().

Here is the caller graph for this function:

◆ xbps_xasprintf()

char * xbps_xasprintf ( const char *  fmt,
  ... 
)

Returns a string by concatenating its variable argument list as specified by the format string fmt.

Parameters
[in]fmtFormat string, see printf(3).
Returns
A pointer to a malloc(3)ed string, NULL otherwise and errno is set appropiately. The pointer should be free(3)d when it's no longer needed.

Referenced by xbps_fetch_file_dest_sha256(), xbps_pkg_exec_buffer(), xbps_pkgdb_lock(), xbps_repo_key_import(), xbps_repo_lock(), xbps_repo_path_with_name(), xbps_repository_pkg_path(), xbps_symlink_target(), and xbps_verify_signature().

Here is the caller graph for this function:

◆ xbps_mmap_file()

char bool xbps_mmap_file ( const char *  file,
void **  mmf,
size_t *  mmflen,
size_t *  filelen 
)

Creates a memory mapped object from file file into mmf with size mmflen, and file size to filelen;

Parameters
[in]filePath to a file.
[out]mmfMemory mapped object.
[out]mmflenLength of memory mapped object.
[out]filelenFile size length.
Returns
True on success, false otherwise and errno is set appropiately. The mmaped object should be munmap()ed when it's not longer needed.

Definition at line 65 of file util_hash.c.

Referenced by xbps_verify_signature().

Here is the caller graph for this function:

◆ xbps_file_sha256()

bool xbps_file_sha256 ( char *  dst,
size_t  len,
const char *  file 
)

Computes a sha256 hex digest into dst of size len from file file.

Parameters
[out]dstDestination buffer.
[in]lenSize of dst must be at least XBPS_SHA256_LENGTH.
[in]fileThe file to read.
Returns
true on success, false otherwise.

Definition at line 148 of file util_hash.c.

References xbps_file_sha256_raw().

Here is the call graph for this function:

◆ xbps_file_sha256_raw()

bool xbps_file_sha256_raw ( unsigned char *  dst,
size_t  len,
const char *  file 
)

Computes a sha256 binary digest into dst of size len from file file.

Parameters
[out]dstDestination buffer.
[in]lenSize of dst must be at least XBPS_SHA256_DIGEST_SIZE_LENGTH.
[in]fileThe file to read.
Returns
true on success, false otherwise.

Definition at line 116 of file util_hash.c.

Referenced by xbps_file_sha256(), xbps_file_sha256_check(), and xbps_verify_file_signature().

Here is the caller graph for this function:

◆ xbps_file_sha256_check()

int xbps_file_sha256_check ( const char *  file,
const char *  sha256 
)

Compares the sha256 hash of the file file with the sha256 string specified by sha256.

Parameters
[in]filePath to a file.
[in]sha256SHA256 hash to compare.
Returns
0 if file and sha256 have the same hash, ERANGE if it differs, or any other errno value on error.

Definition at line 201 of file util_hash.c.

References xbps_file_sha256_raw().

Here is the call graph for this function:

◆ xbps_verify_signature()

bool xbps_verify_signature ( struct xbps_repo repo,
const char *  sigfile,
unsigned char *  digest 
)

Verifies the RSA signature sigfile against digest with the RSA public-key associated in repo.

Parameters
[in]repoRepository to use with the RSA public key associated.
[in]sigfileThe signature file name used to verify digest.
[in]digestThe digest to verify.
Returns
True if the signature is valid, false otherwise.

Definition at line 75 of file verifysig.c.

References xbps_repo::idxmeta, xbps_handle::metadir, xbps_repo::uri, xbps_mmap_file(), xbps_plist_dictionary_from_file(), xbps_pubkey2fp(), xbps_xasprintf(), and xbps_repo::xhp.

Referenced by xbps_verify_file_signature().

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

◆ xbps_verify_file_signature()

bool xbps_verify_file_signature ( struct xbps_repo repo,
const char *  fname 
)

Verifies the RSA signature of fname with the RSA public-key associated in repo.

Parameters
[in]repoRepository to use with the RSA public key associated.
[in]fnameThe filename to verify, the signature file must have a .sig2 extension, i.e <fname>.sig2.
Returns
True if the signature is valid, false otherwise.

Definition at line 136 of file verifysig.c.

References xbps_file_sha256_raw(), and xbps_verify_signature().

Here is the call graph for this function:

◆ xbps_pkg_is_installed()

int xbps_pkg_is_installed ( struct xbps_handle xhp,
const char *  pkg 
)

Checks if a package is currently installed in pkgdb by matching pkg. To be installed, the pkg must be in "installed" or "unpacked" state.

Parameters
[in]xhpThe pointer to an xbps_handle struct.
[in]pkgPackage name, version pattern or exact pkg to match.
Returns
-1 on error (errno set appropiately), 0 if pkg didn't match installed package, 1 if pkg pattern fully matched installed package.

Definition at line 79 of file util.c.

References xbps_pkg_state_dictionary(), xbps_pkgdb_get_pkg(), and xbps_pkgdb_get_virtualpkg().

Here is the call graph for this function:

◆ xbps_pkg_is_ignored()

bool xbps_pkg_is_ignored ( struct xbps_handle xhp,
const char *  pkg 
)

Checks if a package is currently ignored by matching pkg. To be ignored, the pkg must be ignored by the users configuration.

Parameters
[in]xhpThe pointer to an xbps_handle struct.
[in]pkgPackage name, version pattern or exact pkg to match.
Returns
True if the package is ignored, false otherwise.

Definition at line 103 of file util.c.

References xbps_match_string_in_array(), xbps_pkg_name(), and xbps_pkgpattern_name().

Here is the call graph for this function:

◆ xbps_binpkg_exists()

bool xbps_binpkg_exists ( struct xbps_handle xhp,
xbps_dictionary_t  pkgd 
)

Returns true if binary package exists in cachedir or in a local repository, false otherwise.

Parameters
[in]xhpThe pointer to an xbps_handle struct.
[in]pkgdPackage dictionary returned by rpool.
Returns
true if exists, false otherwise.

Definition at line 429 of file util.c.

References xbps_handle::cachedir, and xbps_repository_is_remote().

Here is the call graph for this function:

◆ xbps_remote_binpkg_exists()

bool xbps_remote_binpkg_exists ( struct xbps_handle xhp,
xbps_dictionary_t  pkgd 
)

Returns true if binary package and signature exists in cachedir, false otherwise.

Parameters
[in]xhpThe pointer to an xbps_handle struct.
[in]pkgdPackage dictionary returned by rpool.
Returns
true if exists, false otherwise.

Definition at line 455 of file util.c.

References xbps_handle::cachedir.

◆ xbps_repository_is_remote()

bool xbps_repository_is_remote ( const char *  uri)

Checks if the URI specified by uri is remote or local.

Parameters
[in]uriURI string.
Returns
true if URI is remote, false if local.

Definition at line 66 of file util.c.

Referenced by xbps_binpkg_exists(), xbps_pkg_path(), xbps_repo_store(), and xbps_repository_pkg_path().

Here is the caller graph for this function:

◆ xbps_repository_pkg_path()

char * xbps_repository_pkg_path ( struct xbps_handle xhp,
xbps_dictionary_t  pkgd 
)

Returns an allocated string with the full path to the binary package matching pkgd.

The pkgd dictionary must contain the following objects:

  • architecture (string)
  • pkgver (string)
  • repository (string)
Parameters
[in]xhpThe pointer to an xbps_handle struct.
[in]pkgdThe package dictionary to match.
Returns
A malloc(3)ed buffer with the full path, NULL otherwise. The buffer should be free(3)d when it's no longer needed.

Definition at line 393 of file util.c.

References xbps_handle::cachedir, xbps_repository_is_remote(), and xbps_xasprintf().

Here is the call graph for this function:

◆ xbps_pkg_path()

ssize_t xbps_pkg_path ( struct xbps_handle xhp,
char *  dst,
size_t  dstsz,
xbps_dictionary_t  pkgd 
)

Put the path to the binary package pkgd into dst.

The pkgd dictionary must contain the following objects:

  • architecture (string)
  • pkgver (string)
  • repository (string)
Parameters
[in]xhpPointer to an xbps_handle struct.
[in]dstDestination buffer.
[in]dstszDestination buffer size.
[in]pkgdPackage dictionary.
Returns
The length of the path or a negative errno on error.
Return values
-EINVALMissing required dictionary entry.
-ENOBUFSThe path would exceed the supplied dst buffer.

Definition at line 325 of file util.c.

References xbps_handle::cachedir, and xbps_repository_is_remote().

Here is the call graph for this function:

◆ xbps_pkg_url()

ssize_t xbps_pkg_url ( struct xbps_handle xhp,
char *  dst,
size_t  dstsz,
xbps_dictionary_t  pkgd 
)

Put the url to the binary package pkgd into dst.

The pkgd dictionary must contain the following objects:

  • architecture (string)
  • pkgver (string)
  • repository (string)
Parameters
[in]xhpThe pointer to an xbps_handle struct.
[in]pkgdThe package dictionary to match.
Returns
The length of the path or a negative errno on error.
Return values
-EINVALMissing required dictionary entry.
-ENOBUFSThe path would exceed the supplied dst buffer.

◆ xbps_pkg_path_or_url()

ssize_t xbps_pkg_path_or_url ( struct xbps_handle xhp,
char *  dst,
size_t  dstsz,
xbps_dictionary_t  pkgd 
)

Put the url or path (if cached) to the binary package pkgd into dst.

The pkgd dictionary must contain the following objects:

  • architecture (string)
  • pkgver (string)
  • repository (string)
Parameters
[in]xhpThe pointer to an xbps_handle struct.
[in]pkgdThe package dictionary to match.
Returns
The length of the path or a negative errno on error.
Return values
-EINVALMissing required dictionary entry.
-ENOBUFSThe path would exceed the supplied dst buffer.

◆ xbps_pkg_name()

bool xbps_pkg_name ( char *  dst,
size_t  len,
const char *  pkg 
)

Gets the name of a package string. Package strings are composed by a <pkgname>/<version> pair and separated by the minus sign, i.e foo-2.0.

Parameters
[out]dstDestination buffer to store result.
[in]lenLength of dst.
[in]pkgPackage version string.
Returns
true on success, false otherwise.

Definition at line 253 of file util.c.

Referenced by xbps_configure_pkg(), xbps_pkg_exec_buffer(), xbps_pkg_is_ignored(), xbps_pkgdb_get_pkg_files(), xbps_pkgdb_get_pkg_revdeps(), xbps_repo_get_pkg(), xbps_repo_get_pkg_revdeps(), xbps_repo_get_virtualpkg(), xbps_set_pkg_state_installed(), xbps_transaction_install_pkg(), xbps_transaction_update_packages(), and xbps_transaction_update_pkg().

Here is the caller graph for this function:

◆ xbps_pkgpattern_name()

bool xbps_pkgpattern_name ( char *  dst,
size_t  len,
const char *  pattern 
)

Gets a the package name of a package pattern string specified by the pattern argument.

Package patterns are composed of the package name and either a equals (foo=2.0) constraint or a greater than (foo>2.0) or greater equals (foo>=2.0) or lower than (foo<2.0) or lower equals (foo<=2.0) or a combination of both (foo>=1.0<2.0).

Parameters
[out]dstDestination buffer to store result.
[in]lenLength of dst.
[in]patternA package pattern.
Returns
true on success, false otherwise.

Definition at line 289 of file util.c.

Referenced by xbps_pkg_is_ignored().

Here is the caller graph for this function:

◆ xbps_pkg_version()

const char * xbps_pkg_version ( const char *  pkg)

Gets the package version in a package string, i.e foo-2.0.

Parameters
[in]pkgPackage string.
Returns
A string with the version string, NULL if it couldn't find the version component.

Definition at line 124 of file util.c.

Referenced by xbps_binpkg_pkgver(), xbps_match_virtual_pkg_in_array(), xbps_pkg_exec_buffer(), and xbps_pkg_reverts().

Here is the caller graph for this function:

◆ xbps_binpkg_pkgver()

char * xbps_binpkg_pkgver ( const char *  pkg)

Gets the pkgname/version componentn of a binary package string, i.e foo-2.0_1.<arch>.xbps.

Parameters
[in]pkgPackage string.
Returns
A pointer to a malloc(ed) string with the pkgver component, NULL if it couldn't find the version component. The pointer should be free(3)d when it's no longer needed.

Definition at line 150 of file util.c.

References xbps_pkg_version().

Here is the call graph for this function:

◆ xbps_binpkg_arch()

char * xbps_binpkg_arch ( const char *  pkg)

Gets the architecture component of a binary package string, i.e <pkgver>.<arch>.xbps.

Parameters
[in]pkgPackage string.
Returns
A pointer to a malloc(ed) string with the architecture component, NULL if it couldn't find the version component. The pointer should be free(3)d when it's no longer needed.

Definition at line 192 of file util.c.

◆ xbps_pkgpattern_version()

const char * xbps_pkgpattern_version ( const char *  pattern)

Gets the package version of a package pattern string specified by the pattern argument.

Parameters
[in]patternA package pattern. The same rules in xbps_get_pkgpattern_name() apply here.
Returns
A string with the pattern version, NULL otherwise and errno is set appropiately.

Definition at line 317 of file util.c.

Referenced by xbps_match_virtual_pkg_in_array().

Here is the caller graph for this function:

◆ xbps_pkgpattern_match()

int xbps_pkgpattern_match ( const char *  pkgver,
const char *  pattern 
)

Package pattern matching.

There are 3 strategies for version matching:

  • simple compare: pattern equals to pkgver.
  • shell wildcards: see fnmatch(3).
  • relational dewey matching: '>' '<' '>=' '<='.
Parameters
[in]pkgverPackage name/version, i.e ‘foo-1.0’.
[in]patternPackage pattern to match against pkgver.
Returns
1 if pkgver is matched against pattern, 0 if no match.

Definition at line 530 of file util.c.

Referenced by xbps_match_any_virtualpkg_in_rundeps().

Here is the caller graph for this function:

◆ xbps_pkg_revision()

const char * xbps_pkg_revision ( const char *  pkg)

Gets the package version revision in a package string.

Parameters
[in]pkgPackage string, i.e foo-2.0_1.
Returns
A string with the revision number, NULL if it couldn't find the revision component.

Definition at line 227 of file util.c.

◆ xbps_pkg_arch_match()

bool xbps_pkg_arch_match ( struct xbps_handle xhp,
const char *  orig,
const char *  target 
)

Returns true if provided string is valid for target architecture.

Parameters
[in]xhpThe pointer to an xbps_handle struct.
[in]origArchitecture to match.
[in]targetIf not NULL, orig will be matched against it rather than returned value of uname(2).
Returns
True on match, false otherwise.

Definition at line 484 of file util.c.

References xbps_handle::native_arch, and xbps_handle::target_arch.

◆ xbps_humanize_number()

int xbps_humanize_number ( char *  buf,
int64_t  bytes 
)

Converts the 64 bits signed number specified in bytes to a human parsable string buffer pointed to buf.

Parameters
[out]bufBuffer to store the resulting string. At least it should have space for 6 chars.
[in]bytes64 bits signed number to convert.
Returns
A negative number is returned on error, 0 otherwise.

Definition at line 557 of file util.c.

◆ xbps_strlcat()

size_t xbps_strlcat ( char *  dst,
const char *  src,
size_t  dstsize 
)

Append the string src to the end of dst.

Parameters
[out]dstBuffer to store the resulting string.
[in]srcSource string.
[in]dstsizeSize of the dst buffer.
Returns
The total length of the created string, if the return value is >= dstsize, the output string has been truncated.

Definition at line 566 of file util.c.

Referenced by xbps_fetch_file_dest_sha256(), and xbps_path_append().

Here is the caller graph for this function:

◆ xbps_strlcpy()

size_t xbps_strlcpy ( char *  dst,
const char *  src,
size_t  dstsize 
)

Copy up to dstsize - 1 from the string src to dest, NUL-terminating the result if dstsize is not 0.

Parameters
[out]dstBuffer to store the resulting string.
[in]srcSource string.
[in]dstsizeSize of the dst buffer.
Returns
The total length of the created string, if the return value is >= dstsize, the output string has been truncated.

Definition at line 575 of file util.c.

Referenced by xbps_fetch_file_dest_sha256(), xbps_init(), xbps_path_append(), xbps_path_clean(), xbps_path_prepend(), and xbps_path_rel().

Here is the caller graph for this function:

◆ xbps_pkg_reverts()

bool xbps_pkg_reverts ( xbps_dictionary_t  pkg,
const char *  pkgver 
)

Tests if pkgver is reverted by pkg

The package version is defined by: ${NAME}-{${VERSION}_${REVISION}.

the name part is ignored.

Parameters
[in]pkga package which is a candidate to revert pkgver.
[in]pkgvera package version string
Returns
true if pkg reverts pkgver, false otherwise.

Definition at line 587 of file util.c.

References xbps_pkg_version().

Here is the call graph for this function:

◆ xbps_cmpver()

int xbps_cmpver ( const char *  pkg1,
const char *  pkg2 
)

Compares package version strings.

The package version is defined by: ${VERSION}[_${REVISION}].

Parameters
[in]pkg1a package version string.
[in]pkg2a package version string.
Returns
-1, 0 or 1 depending if pkg1 is less than, equal to or greater than pkg2.

Definition at line 273 of file dewey.c.

◆ xbps_pubkey2fp()

char * xbps_pubkey2fp ( xbps_data_t  pubkey)

Converts a RSA public key in PEM format to a hex fingerprint.

Parameters
[in]pubkeyThe public-key in PEM format as xbps_data_t.
Returns
The OpenSSH fingerprint in hexadecimal. The returned buffer must be free(3)d when necessary.

Definition at line 66 of file pubkey2fp.c.

Referenced by xbps_repo_key_import(), and xbps_verify_signature().

Here is the caller graph for this function:

◆ xbps_sanitize_path()

char * xbps_sanitize_path ( const char *  src)

Returns a buffer with a sanitized path from src. This removes multiple slashes.

Parameters
[in]srcpath component.
Returns
The sanitized path in a buffer. The returned buffer must be free(3)d when it's no longer necessary.

Definition at line 611 of file util.c.

Referenced by xbps_symlink_target().

Here is the caller graph for this function:

◆ xbps_path_clean()

ssize_t xbps_path_clean ( char *  path)

Turns the path in path into the shortest path equivalent to path by purely lexical processing.

Parameters
[in,out]pathThe path to clean.
Returns
The length of the path or -1 on error.

Definition at line 67 of file util_path.c.

References xbps_strlcpy().

Referenced by xbps_init(), and xbps_path_rel().

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

◆ xbps_path_rel()

ssize_t xbps_path_rel ( char *  dst,
size_t  len,
const char *  from,
const char *  to 
)

Returns the relative path from from to to.

Parameters
[out]dstDestination buffer to store result.
[in]lenLength of dst.
[in]fromThe base path.
[in]toThe path that becomes relative to from.
Returns
The length of the path or -1 on error.

Definition at line 131 of file util_path.c.

References xbps_path_clean(), and xbps_strlcpy().

Here is the call graph for this function:

◆ xbps_path_join()

ssize_t xbps_path_join ( char *  dst,
size_t  len,
  ... 
)

Joins multiple path components into the dst buffer.

The last argument has to be (char *)NULL.

Parameters
[out]dstDestination buffer to store result.
[in]lenLength of dst.
Returns
The length of the path or -1 on error.

Definition at line 208 of file util_path.c.

Referenced by xbps_init().

Here is the caller graph for this function:

◆ xbps_path_append()

ssize_t xbps_path_append ( char *  dst,
size_t  len,
const char *  suffix 
)

Adds rootdir and path to the dst buffer.

Parameters
[out]dstDestination buffer to store result.
[in]lenLength of dst.
[in]suffixSuffix to append.
Returns
The length of the path or -1 on error.

Definition at line 219 of file util_path.c.

References xbps_strlcat(), and xbps_strlcpy().

Here is the call graph for this function:

◆ xbps_path_prepend()

ssize_t xbps_path_prepend ( char *  dst,
size_t  len,
const char *  prefix 
)

Adds rootdir and path to the dst buffer.

Parameters
[out]dstDestination buffer to store result.
[in]lenLength of dst.
[in]prefixPrefix to prepend.
Returns
The length of the path or -1 on error.

Definition at line 249 of file util_path.c.

References xbps_strlcpy().

Referenced by xbps_init().

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

◆ xbps_symlink_target()

char * xbps_symlink_target ( struct xbps_handle xhp,
const char *  path,
const char *  target 
)

Returns a sanitized target file of path without the rootdir component.

Parameters
[in]xhpThe pointer to an xbps_handle struct.
[in]pathpath component.
[in]targetThe stored target file of a symlink.
Returns
The sanitized path in a buffer. The returned buffer must be free(3)d when it's no longer necessary.

Definition at line 638 of file util.c.

References xbps_handle::rootdir, xbps_sanitize_path(), and xbps_xasprintf().

Here is the call graph for this function:

◆ xbps_patterns_match()

bool xbps_patterns_match ( xbps_array_t  patterns,
const char *  path 
)

Returns true if any of the fnmatch patterns in patterns matches and is not negated by a later match.

Parameters
[in]patternsThe patterns to match against.
[in]pathThe path that is matched against the patterns.
Returns
true if any pattern matches, false otherwise. The returned buffer must be free(3)d when it's no longer necessary.

Definition at line 728 of file util.c.

◆ xbps_plist_array_from_file()

xbps_array_t xbps_plist_array_from_file ( const char *  path)

Internalizes a plist file declared in path and returns a proplib array.

Parameters
[in]pathThe file path.
Returns
The internalized proplib array, NULL otherwise.

Definition at line 937 of file proplib_wrapper.c.

◆ xbps_plist_dictionary_from_file()

xbps_dictionary_t xbps_plist_dictionary_from_file ( const char *  path)

Internalizes a plist file declared in path and returns a proplib dictionary.

Parameters
[in]pathThe file path.
Returns
The internalized proplib array, NULL otherwise.

Definition at line 950 of file proplib_wrapper.c.

Referenced by xbps_pkgdb_get_pkg_files(), xbps_repo_key_import(), and xbps_verify_signature().

Here is the caller graph for this function: