libalpm
Arch Linux Package Manager Library
|
#include "alpm_list.h"
#include "alpm.h"
#include "package.h"
#include "handle.h"
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <math.h>
#include <float.h>
#include <fcntl.h>
#include <archive.h>
Go to the source code of this file.
Data Structures | |
struct | archive_read_buffer |
Used as a buffer/state holder for _alpm_archive_fgets(). More... | |
Defines | |
#define | _(s) s |
#define | ALLOC_FAIL(s) do { fprintf(stderr, "alloc failure: could not allocate %zd bytes\n", s); } while(0) |
#define | MALLOC(p, s, action) do { p = malloc(s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0) |
#define | CALLOC(p, l, s, action) do { p = calloc(l, s); if(p == NULL) { ALLOC_FAIL(l * s); action; } } while(0) |
#define | STRDUP(r, s, action) do { if(s != NULL) { r = strdup(s); if(r == NULL) { ALLOC_FAIL(strlen(s)); action; } } else { r = NULL; } } while(0) |
#define | STRNDUP(r, s, l, action) do { if(s != NULL) { r = strndup(s, l); if(r == NULL) { ALLOC_FAIL(strlen(s)); action; } } else { r = NULL; } } while(0) |
#define | FREE(p) do { free(p); p = NULL; } while(0) |
#define | ASSERT(cond, action) do { if(!(cond)) { action; } } while(0) |
#define | RET_ERR_VOID(handle, err) |
#define | RET_ERR(handle, err, ret) |
#define | DOUBLE_EQ(x, y) (fabs((x) - (y)) < DBL_EPSILON) |
#define | CHECK_HANDLE(handle, action) do { if(!(handle)) { action; } (handle)->pm_errno = 0; } while(0) |
#define | ALPM_BUFFER_SIZE 8192 |
Standard buffer size used throughout the library. | |
#define | OPEN(fd, path, flags) do { fd = open(path, flags | O_BINARY); } while(fd == -1 && errno == EINTR) |
#define | CLOSE(fd) do { int ret; do { ret = close(fd); } while(ret == -1 && errno == EINTR); } while(0) |
#define | SYMEXPORT __attribute__((visibility("default"))) |
#define | SYMHIDDEN __attribute__((visibility("internal"))) |
#define | UNUSED __attribute__((unused)) |
Enumerations | |
enum | _alpm_csum { ALPM_CSUM_MD5, ALPM_CSUM_SHA256 } |
Functions | |
int | _alpm_makepath (const char *path) |
int | _alpm_makepath_mode (const char *path, mode_t mode) |
Creates a directory, including parents if needed, similar to 'mkdir -p'. | |
int | _alpm_copyfile (const char *src, const char *dest) |
Copies a file. | |
size_t | _alpm_strip_newline (char *str) |
Trim trailing newlines from a string (if any exist). | |
int | _alpm_open_archive (alpm_handle_t *handle, const char *path, struct stat *buf, struct archive **archive, alpm_errno_t error) |
Open an archive for reading and perform the necessary boilerplate. | |
int | _alpm_unpack_single (alpm_handle_t *handle, const char *archive, const char *prefix, const char *filename) |
Unpack a specific file in an archive. | |
int | _alpm_unpack (alpm_handle_t *handle, const char *archive, const char *prefix, alpm_list_t *list, int breakfirst) |
Unpack a list of files in an archive. | |
int | _alpm_rmrf (const char *path) |
Recursively removes a path similar to 'rm -rf'. | |
ssize_t | _alpm_files_in_directory (alpm_handle_t *handle, const char *path, int full_count) |
Determine if there are files in a directory. | |
int | _alpm_logaction (alpm_handle_t *handle, const char *fmt, va_list args) |
Write formatted message to log. | |
int | _alpm_run_chroot (alpm_handle_t *handle, const char *cmd, char *const argv[]) |
Execute a command with arguments in a chroot. | |
int | _alpm_ldconfig (alpm_handle_t *handle) |
Run ldconfig in a chroot. | |
int | _alpm_str_cmp (const void *s1, const void *s2) |
Helper function for comparing strings using the alpm "compare func" signature. | |
char * | _alpm_filecache_find (alpm_handle_t *handle, const char *filename) |
Find a filename in a registered alpm cachedir. | |
const char * | _alpm_filecache_setup (alpm_handle_t *handle) |
Check the alpm cachedirs for existance and find a writable one. | |
int | _alpm_lstat (const char *path, struct stat *buf) |
lstat wrapper that treats /path/dirsymlink/ the same as /path/dirsymlink. | |
int | _alpm_test_checksum (const char *filepath, const char *expected, enum _alpm_csum type) |
Calculates a file's MD5 or SHA2 digest and compares it to an expected value. | |
int | _alpm_archive_fgets (struct archive *a, struct archive_read_buffer *b) |
TODO. | |
int | _alpm_splitname (const char *target, char **name, char **version, unsigned long *name_hash) |
Parse a full package specifier. | |
unsigned long | _alpm_hash_sdbm (const char *str) |
Hash the given string to an unsigned long value. | |
off_t | _alpm_strtoofft (const char *line) |
Convert a string to a file offset. | |
alpm_time_t | _alpm_parsedate (const char *line) |
Parses a date into an alpm_time_t struct. | |
int | _alpm_raw_cmp (const char *first, const char *second) |
int | _alpm_raw_ncmp (const char *first, const char *second, size_t max) |
int | _alpm_access (alpm_handle_t *handle, const char *dir, const char *file, int amode) |
Wrapper around access() which takes a dir and file argument separately and generates an appropriate error message. | |
int | _alpm_fnmatch (const void *pattern, const void *string) |
Checks whether a string matches a shell wildcard pattern. | |
char * | strsep (char **, const char *) |
Extracts tokens from a string. | |
char * | strndup (const char *s, size_t n) |
Copies a string. |
#define _ | ( | s | ) | s |
Definition at line 49 of file lib/libalpm/util.h.
Referenced by _alpm_check_diskspace(), _alpm_check_downloadspace(), _alpm_db_path(), _alpm_filecache_setup(), _alpm_gpgme_checksig(), _alpm_local_db_prepare(), _alpm_local_db_write(), _alpm_open_archive(), _alpm_pkg_dup(), _alpm_pkg_load_internal(), _alpm_process_siglist(), _alpm_remove_single_package(), _alpm_resolvedeps(), _alpm_run_chroot(), _alpm_runscriptlet(), _alpm_sortbydeps(), _alpm_sync_commit(), _alpm_sync_prepare(), _alpm_unpack(), alpm_add_pkg(), alpm_db_update(), alpm_fetch_pkgurl(), alpm_strerror(), alpm_trans_release(), cb_dl_progress(), cb_event(), cb_progress(), cb_question(), check_syncdbs(), config_new(), display_new_optdepends(), display_optdepends(), dump_pkg_backups(), dump_pkg_changelog(), dump_pkg_full(), list_display(), list_display_linebreak(), main(), multiselect_question(), pacman_database(), pacman_query(), pacman_remove(), pacman_sync(), pacman_upgrade(), pm_asprintf(), pm_vasprintf(), pm_vfprintf(), select_question(), signature_display(), string_display(), sync_prepare_execute(), table_display(), trans_init_error(), and trans_release().
#define ALLOC_FAIL | ( | s | ) | do { fprintf(stderr, "alloc failure: could not allocate %zd bytes\n", s); } while(0) |
Definition at line 52 of file lib/libalpm/util.h.
Referenced by _alpm_pkg_load_internal().
#define ALPM_BUFFER_SIZE 8192 |
Standard buffer size used throughout the library.
Definition at line 82 of file lib/libalpm/util.h.
Referenced by _alpm_copyfile(), and _alpm_open_archive().
#define ASSERT | ( | cond, | |
action | |||
) | do { if(!(cond)) { action; } } while(0) |
Definition at line 62 of file lib/libalpm/util.h.
Referenced by _alpm_dload_payload_reset(), _alpm_handle_lock(), _alpm_handle_unlock(), alpm_add_pkg(), alpm_compute_md5sum(), alpm_compute_sha256sum(), alpm_db_add_server(), alpm_db_check_pgp_signature(), alpm_db_get_groupcache(), alpm_db_get_name(), alpm_db_get_pkg(), alpm_db_get_pkgcache(), alpm_db_get_servers(), alpm_db_get_siglevel(), alpm_db_get_valid(), alpm_db_readgroup(), alpm_db_register_sync(), alpm_db_remove_server(), alpm_db_search(), alpm_db_set_pkgreason(), alpm_db_set_servers(), alpm_db_unregister(), alpm_db_unregister_all(), alpm_db_update(), alpm_dep_compute_string(), alpm_fetch_pkgurl(), alpm_find_dbs_satisfier(), alpm_logaction(), alpm_option_add_cachedir(), alpm_option_remove_cachedir(), alpm_pkg_changelog_close(), alpm_pkg_changelog_open(), alpm_pkg_changelog_read(), alpm_pkg_check_pgp_signature(), alpm_pkg_checkmd5sum(), alpm_pkg_compute_requiredby(), alpm_pkg_free(), alpm_pkg_get_arch(), alpm_pkg_get_backup(), alpm_pkg_get_base64_sig(), alpm_pkg_get_builddate(), alpm_pkg_get_conflicts(), alpm_pkg_get_db(), alpm_pkg_get_deltas(), alpm_pkg_get_depends(), alpm_pkg_get_desc(), alpm_pkg_get_filename(), alpm_pkg_get_files(), alpm_pkg_get_groups(), alpm_pkg_get_installdate(), alpm_pkg_get_isize(), alpm_pkg_get_licenses(), alpm_pkg_get_md5sum(), alpm_pkg_get_name(), alpm_pkg_get_optdepends(), alpm_pkg_get_origin(), alpm_pkg_get_packager(), alpm_pkg_get_provides(), alpm_pkg_get_reason(), alpm_pkg_get_replaces(), alpm_pkg_get_sha256sum(), alpm_pkg_get_size(), alpm_pkg_get_url(), alpm_pkg_get_version(), alpm_pkg_has_scriptlet(), alpm_pkg_load(), alpm_pkg_unused_deltas(), alpm_remove_pkg(), alpm_siglist_cleanup(), alpm_sync_newversion(), alpm_sync_sysupgrade(), alpm_trans_commit(), alpm_trans_get_add(), alpm_trans_get_flags(), alpm_trans_get_remove(), alpm_trans_init(), alpm_trans_interrupt(), alpm_trans_prepare(), and alpm_trans_release().
#define CALLOC | ( | p, | |
l, | |||
s, | |||
action | |||
) | do { p = calloc(l, s); if(p == NULL) { ALLOC_FAIL(l * s); action; } } while(0) |
Definition at line 55 of file lib/libalpm/util.h.
Referenced by _alpm_access(), _alpm_archive_fgets(), _alpm_backup_dup(), _alpm_check_pgp_helper(), _alpm_conflict_dup(), _alpm_db_new(), _alpm_db_path(), _alpm_delta_dup(), _alpm_delta_parse(), _alpm_dep_dup(), _alpm_gpgme_checksig(), _alpm_graph_new(), _alpm_group_new(), _alpm_handle_new(), _alpm_pkg_dup(), _alpm_pkg_new(), _alpm_pkghash_create(), _alpm_set_directory_option(), _alpm_sigpath(), and alpm_trans_init().
#define CHECK_HANDLE | ( | handle, | |
action | |||
) | do { if(!(handle)) { action; } (handle)->pm_errno = 0; } while(0) |
Definition at line 76 of file lib/libalpm/util.h.
Referenced by alpm_add_pkg(), alpm_checkconflicts(), alpm_checkdeps(), alpm_db_register_sync(), alpm_db_set_pkgreason(), alpm_db_unregister_all(), alpm_fetch_pkgurl(), alpm_find_dbs_satisfier(), alpm_option_add_cachedir(), alpm_option_add_ignoregroup(), alpm_option_add_ignorepkg(), alpm_option_add_noextract(), alpm_option_add_noupgrade(), alpm_option_get_arch(), alpm_option_get_cachedirs(), alpm_option_get_checkspace(), alpm_option_get_dbpath(), alpm_option_get_default_siglevel(), alpm_option_get_dlcb(), alpm_option_get_eventcb(), alpm_option_get_fetchcb(), alpm_option_get_gpgdir(), alpm_option_get_ignoregroups(), alpm_option_get_ignorepkgs(), alpm_option_get_localdb(), alpm_option_get_lockfile(), alpm_option_get_logcb(), alpm_option_get_logfile(), alpm_option_get_noextracts(), alpm_option_get_noupgrades(), alpm_option_get_progresscb(), alpm_option_get_questioncb(), alpm_option_get_root(), alpm_option_get_syncdbs(), alpm_option_get_totaldlcb(), alpm_option_get_usedelta(), alpm_option_get_usesyslog(), alpm_option_remove_cachedir(), alpm_option_remove_ignoregroup(), alpm_option_remove_ignorepkg(), alpm_option_remove_noextract(), alpm_option_remove_noupgrade(), alpm_option_set_arch(), alpm_option_set_cachedirs(), alpm_option_set_checkspace(), alpm_option_set_default_siglevel(), alpm_option_set_dlcb(), alpm_option_set_eventcb(), alpm_option_set_fetchcb(), alpm_option_set_gpgdir(), alpm_option_set_ignoregroups(), alpm_option_set_ignorepkgs(), alpm_option_set_logcb(), alpm_option_set_logfile(), alpm_option_set_noextracts(), alpm_option_set_noupgrades(), alpm_option_set_progresscb(), alpm_option_set_questioncb(), alpm_option_set_totaldlcb(), alpm_option_set_usedelta(), alpm_option_set_usesyslog(), alpm_pkg_load(), alpm_release(), alpm_remove_pkg(), alpm_sync_sysupgrade(), alpm_trans_commit(), alpm_trans_get_add(), alpm_trans_get_flags(), alpm_trans_get_remove(), alpm_trans_init(), alpm_trans_interrupt(), alpm_trans_prepare(), and alpm_trans_release().
#define CLOSE | ( | fd | ) | do { int ret; do { ret = close(fd); } while(ret == -1 && errno == EINTR); } while(0) |
Definition at line 90 of file lib/libalpm/util.h.
Referenced by _alpm_copyfile(), _alpm_open_archive(), _alpm_pkg_load_internal(), _alpm_run_chroot(), and _alpm_unpack().
#define DOUBLE_EQ | ( | x, | |
y | |||
) | (fabs((x) - (y)) < DBL_EPSILON) |
Definition at line 74 of file lib/libalpm/util.h.
#define FREE | ( | p | ) | do { free(p); p = NULL; } while(0) |
Definition at line 60 of file lib/libalpm/util.h.
Referenced by _alpm_archive_fgets(), _alpm_conflict_free(), _alpm_db_free(), _alpm_delta_free(), _alpm_dep_free(), _alpm_depmiss_free(), _alpm_dload_payload_reset(), _alpm_fileconflict_free(), _alpm_gpgme_checksig(), _alpm_group_free(), _alpm_handle_free(), _alpm_handle_lock(), _alpm_pkg_free(), _alpm_set_directory_option(), _alpm_split_backup(), _alpm_splitname(), _alpm_test_checksum(), _alpm_trans_free(), alpm_fetch_pkgurl(), alpm_option_remove_cachedir(), alpm_option_remove_ignoregroup(), alpm_option_remove_ignorepkg(), alpm_option_remove_noextract(), alpm_option_remove_noupgrade(), alpm_option_set_arch(), alpm_option_set_gpgdir(), and alpm_option_set_logfile().
#define MALLOC | ( | p, | |
s, | |||
action | |||
) | do { p = malloc(s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0) |
Definition at line 54 of file lib/libalpm/util.h.
Referenced by _alpm_copyfile(), _alpm_local_db_pkgpath(), _alpm_pkg_dup(), _alpm_runscriptlet(), _alpm_splitdep(), alpm_db_update(), alpm_dep_compute_string(), and alpm_fetch_pkgurl().
#define OPEN | ( | fd, | |
path, | |||
flags | |||
) | do { fd = open(path, flags | O_BINARY); } while(fd == -1 && errno == EINTR) |
Definition at line 89 of file lib/libalpm/util.h.
Referenced by _alpm_copyfile(), _alpm_open_archive(), _alpm_run_chroot(), and _alpm_unpack().
do { \ _alpm_log(handle, ALPM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \ (handle)->pm_errno = (err); \ return (ret); } while(0)
Definition at line 69 of file lib/libalpm/util.h.
Referenced by _alpm_access(), _alpm_check_diskspace(), _alpm_check_downloadspace(), _alpm_check_pgp_helper(), _alpm_db_get_groupcache(), _alpm_db_get_pkgcache_hash(), _alpm_db_path(), _alpm_db_register_sync(), _alpm_db_search(), _alpm_download(), _alpm_gpgme_checksig(), _alpm_local_db_pkgpath(), _alpm_open_archive(), _alpm_pkg_dup(), _alpm_pkg_load_internal(), _alpm_pkg_validate_internal(), _alpm_remove_prepare(), _alpm_runscriptlet(), _alpm_sigpath(), _alpm_sync_commit(), _alpm_sync_prepare(), alpm_add_pkg(), alpm_db_add_server(), alpm_db_check_pgp_signature(), alpm_db_get_pkg(), alpm_db_readgroup(), alpm_db_register_sync(), alpm_db_remove_server(), alpm_db_set_pkgreason(), alpm_db_unregister(), alpm_db_unregister_all(), alpm_db_update(), alpm_fetch_pkgurl(), alpm_find_dbs_satisfier(), alpm_option_add_cachedir(), alpm_option_remove_cachedir(), alpm_option_set_default_siglevel(), alpm_pkg_check_pgp_signature(), alpm_pkg_checkmd5sum(), alpm_pkg_load(), alpm_remove_pkg(), alpm_sync_sysupgrade(), alpm_trans_commit(), alpm_trans_get_add(), alpm_trans_get_flags(), alpm_trans_get_remove(), alpm_trans_init(), alpm_trans_interrupt(), alpm_trans_prepare(), and alpm_trans_release().
#define RET_ERR_VOID | ( | handle, | |
err | |||
) |
do { \ _alpm_log(handle, ALPM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \ (handle)->pm_errno = (err); \ return; } while(0)
Definition at line 64 of file lib/libalpm/util.h.
#define STRDUP | ( | r, | |
s, | |||
action | |||
) | do { if(s != NULL) { r = strdup(s); if(r == NULL) { ALLOC_FAIL(strlen(s)); action; } } else { r = NULL; } } while(0) |
Definition at line 57 of file lib/libalpm/util.h.
Referenced by _alpm_backup_dup(), _alpm_conflict_dup(), _alpm_db_new(), _alpm_delta_dup(), _alpm_dep_dup(), _alpm_file_copy(), _alpm_gpgme_checksig(), _alpm_group_new(), _alpm_pkg_dup(), _alpm_pkg_load_internal(), _alpm_split_backup(), _alpm_splitdep(), and alpm_fetch_pkgurl().
#define STRNDUP | ( | r, | |
s, | |||
l, | |||
action | |||
) | do { if(s != NULL) { r = strndup(s, l); if(r == NULL) { ALLOC_FAIL(strlen(s)); action; } } else { r = NULL; } } while(0) |
Definition at line 58 of file lib/libalpm/util.h.
Referenced by _alpm_delta_parse(), _alpm_splitdep(), and _alpm_splitname().
#define SYMEXPORT __attribute__((visibility("default"))) |
Definition at line 154 of file lib/libalpm/util.h.
#define SYMHIDDEN __attribute__((visibility("internal"))) |
Definition at line 155 of file lib/libalpm/util.h.
#define UNUSED __attribute__((unused)) |
Definition at line 157 of file lib/libalpm/util.h.
enum _alpm_csum |
Definition at line 108 of file lib/libalpm/util.h.
int _alpm_access | ( | alpm_handle_t * | handle, |
const char * | dir, | ||
const char * | file, | ||
int | amode | ||
) |
Wrapper around access() which takes a dir and file argument separately and generates an appropriate error message.
If dir is NULL file will be treated as the whole path.
handle | an alpm handle |
dir | directory path ending with and slash |
file | filename |
amode | access mode as described in access() |
Definition at line 1235 of file lib/libalpm/util.c.
References _alpm_log(), ALPM_ERR_MEMORY, ALPM_LOG_DEBUG, CALLOC, and RET_ERR.
Referenced by _alpm_gpgme_checksig(), _alpm_pkg_validate_internal(), _alpm_process_siglist(), and _alpm_runscriptlet().
int _alpm_archive_fgets | ( | struct archive * | a, |
struct archive_read_buffer * | b | ||
) |
TODO.
Does not handle sparse files on purpose for speed.
a | |
b |
Definition at line 984 of file lib/libalpm/util.c.
References archive_read_buffer::block, archive_read_buffer::block_offset, archive_read_buffer::block_size, CALLOC, FREE, archive_read_buffer::line, archive_read_buffer::line_offset, archive_read_buffer::line_size, archive_read_buffer::max_line_size, and archive_read_buffer::ret.
int _alpm_copyfile | ( | const char * | src, |
const char * | dest | ||
) |
Copies a file.
src | file path to copy from |
dest | file path to copy to |
Definition at line 142 of file lib/libalpm/util.c.
References ALPM_BUFFER_SIZE, CLOSE, MALLOC, and OPEN.
Referenced by _alpm_runscriptlet().
char* _alpm_filecache_find | ( | alpm_handle_t * | handle, |
const char * | filename | ||
) |
Find a filename in a registered alpm cachedir.
handle | the context handle |
filename | name of file to find |
Definition at line 689 of file lib/libalpm/util.c.
References _alpm_log(), ALPM_LOG_DEBUG, __alpm_handle_t::cachedirs, __alpm_list_t::data, and __alpm_list_t::next.
Referenced by alpm_fetch_pkgurl(), and alpm_pkg_checkmd5sum().
const char* _alpm_filecache_setup | ( | alpm_handle_t * | handle | ) |
Check the alpm cachedirs for existance and find a writable one.
If no valid cache directory can be found, use /tmp.
handle | the context handle |
Definition at line 715 of file lib/libalpm/util.c.
References _, _alpm_log(), _alpm_makepath(), ALPM_LOG_DEBUG, ALPM_LOG_WARNING, alpm_option_add_cachedir(), __alpm_handle_t::cachedirs, __alpm_list_t::data, __alpm_list_t::next, and __alpm_list_t::prev.
Referenced by alpm_fetch_pkgurl().
ssize_t _alpm_files_in_directory | ( | alpm_handle_t * | handle, |
const char * | path, | ||
int | full_count | ||
) |
Determine if there are files in a directory.
handle | the context handle |
path | the full absolute directory path |
full_count | whether to return an exact count of files |
Definition at line 453 of file lib/libalpm/util.c.
References _alpm_log(), and ALPM_LOG_DEBUG.
int _alpm_fnmatch | ( | const void * | pattern, |
const void * | string | ||
) |
Checks whether a string matches a shell wildcard pattern.
Wrapper around fnmatch.
pattern | pattern to match aganist |
string | string to check against pattern |
Definition at line 1282 of file lib/libalpm/util.c.
Referenced by _alpm_pkg_should_ignore().
unsigned long _alpm_hash_sdbm | ( | const char * | str | ) |
Hash the given string to an unsigned long value.
This is the standard sdbm hashing algorithm.
str | string to hash |
Definition at line 1144 of file lib/libalpm/util.c.
Referenced by _alpm_pkg_find(), _alpm_pkghash_find(), _alpm_splitdep(), and _alpm_splitname().
int _alpm_ldconfig | ( | alpm_handle_t * | handle | ) |
Run ldconfig in a chroot.
handle | the context handle |
Definition at line 654 of file lib/libalpm/util.c.
References _alpm_log(), _alpm_run_chroot(), ALPM_LOG_DEBUG, and __alpm_handle_t::root.
Referenced by _alpm_remove_packages(), and _alpm_upgrade_packages().
int _alpm_logaction | ( | alpm_handle_t * | handle, |
const char * | fmt, | ||
va_list | args | ||
) |
Write formatted message to log.
handle | the context handle |
format | formatted string to write out |
args | formatting arguments |
Definition at line 494 of file lib/libalpm/util.c.
References __alpm_handle_t::logstream, and __alpm_handle_t::usesyslog.
Referenced by alpm_logaction().
int _alpm_lstat | ( | const char * | path, |
struct stat * | buf | ||
) |
lstat wrapper that treats /path/dirsymlink/ the same as /path/dirsymlink.
Linux lstat follows POSIX semantics and still performs a dereference on the first, and for uses of lstat in libalpm this is not what we want.
path | path to file to lstat |
buf | structure to fill with stat information |
Definition at line 768 of file lib/libalpm/util.c.
Referenced by _alpm_db_find_fileconflicts(), and _alpm_rmrf().
int _alpm_makepath | ( | const char * | path | ) |
Definition at line 92 of file lib/libalpm/util.c.
References _alpm_makepath_mode().
Referenced by _alpm_filecache_setup(), and _alpm_handle_lock().
int _alpm_makepath_mode | ( | const char * | path, |
mode_t | mode | ||
) |
Creates a directory, including parents if needed, similar to 'mkdir -p'.
path | directory path to create |
mode | permission mode for created directories |
Definition at line 102 of file lib/libalpm/util.c.
References strsep().
Referenced by _alpm_makepath(), and _alpm_runscriptlet().
int _alpm_open_archive | ( | alpm_handle_t * | handle, |
const char * | path, | ||
struct stat * | buf, | ||
struct archive ** | archive, | ||
alpm_errno_t | error | ||
) |
Open an archive for reading and perform the necessary boilerplate.
This takes care of creating the libarchive 'archive' struct, setting up compression and format options, opening a file descriptor, setting up the buffer size, and performing a stat on the path once opened. On error, no file descriptor is opened, and the archive pointer returned will be set to NULL.
handle | the context handle |
path | the path of the archive to open |
buf | space for a stat buffer for the given path |
archive | pointer to place the created archive object |
error | error code to set on failure to open archive |
Definition at line 225 of file lib/libalpm/util.c.
References _, _alpm_log(), ALPM_BUFFER_SIZE, ALPM_ERR_LIBARCHIVE, ALPM_LOG_DEBUG, ALPM_LOG_ERROR, CLOSE, OPEN, and RET_ERR.
Referenced by _alpm_pkg_load_internal(), and _alpm_unpack().
alpm_time_t _alpm_parsedate | ( | const char * | line | ) |
Parses a date into an alpm_time_t struct.
line | date to parse |
Definition at line 1193 of file lib/libalpm/util.c.
int _alpm_raw_cmp | ( | const char * | first, |
const char * | second | ||
) |
int _alpm_raw_ncmp | ( | const char * | first, |
const char * | second, | ||
size_t | max | ||
) |
int _alpm_rmrf | ( | const char * | path | ) |
Recursively removes a path similar to 'rm -rf'.
path | path to remove |
Definition at line 404 of file lib/libalpm/util.c.
References _alpm_lstat(), and _alpm_rmrf().
Referenced by _alpm_local_db_remove(), and _alpm_rmrf().
int _alpm_run_chroot | ( | alpm_handle_t * | handle, |
const char * | cmd, | ||
char *const | argv[] | ||
) |
Execute a command with arguments in a chroot.
handle | the context handle |
cmd | command to execute |
argv | arguments to pass to cmd |
Definition at line 531 of file lib/libalpm/util.c.
References _, _alpm_log(), ALPM_EVENT_SCRIPTLET_INFO, ALPM_LOG_DEBUG, ALPM_LOG_ERROR, alpm_logaction(), CLOSE, EVENT, OPEN, and __alpm_handle_t::root.
Referenced by _alpm_ldconfig(), and _alpm_runscriptlet().
int _alpm_splitname | ( | const char * | target, |
char ** | name, | ||
char ** | version, | ||
unsigned long * | name_hash | ||
) |
Parse a full package specifier.
target | package specifier to parse, such as: "pacman-4.0.1-2", "pacman-4.01-2/", or "pacman-4.0.1-2/desc" |
name | to hold package name |
version | to hold package version |
name_hash | to hold package name hash |
Definition at line 1087 of file lib/libalpm/util.c.
References _alpm_hash_sdbm(), FREE, and STRNDUP.
int _alpm_str_cmp | ( | const void * | s1, |
const void * | s2 | ||
) |
Helper function for comparing strings using the alpm "compare func" signature.
s1 | first string to be compared |
s2 | second string to be compared |
Definition at line 679 of file lib/libalpm/util.c.
Referenced by alpm_pkg_compute_requiredby().
size_t _alpm_strip_newline | ( | char * | str | ) |
Trim trailing newlines from a string (if any exist).
str | a single line of text |
Definition at line 195 of file lib/libalpm/util.c.
off_t _alpm_strtoofft | ( | const char * | line | ) |
Convert a string to a file offset.
This parses bare positive integers only.
line | string to convert |
Definition at line 1164 of file lib/libalpm/util.c.
Referenced by _alpm_delta_parse().
int _alpm_test_checksum | ( | const char * | filepath, |
const char * | expected, | ||
enum _alpm_csum | type | ||
) |
Calculates a file's MD5 or SHA2 digest and compares it to an expected value.
filepath | path of the file to check |
expected | hash value to compare against |
type | digest type to use |
Definition at line 951 of file lib/libalpm/util.c.
References alpm_compute_md5sum(), alpm_compute_sha256sum(), ALPM_CSUM_MD5, ALPM_CSUM_SHA256, and FREE.
Referenced by _alpm_pkg_validate_internal(), and alpm_pkg_checkmd5sum().
int _alpm_unpack | ( | alpm_handle_t * | handle, |
const char * | path, | ||
const char * | prefix, | ||
alpm_list_t * | list, | ||
int | breakfirst | ||
) |
Unpack a list of files in an archive.
handle | the context handle |
path | the archive to unpack |
prefix | where to extract the files |
list | a list of files within the archive to unpack or NULL for all |
breakfirst | break after the first entry found |
Definition at line 303 of file lib/libalpm/util.c.
References _, _alpm_log(), _alpm_open_archive(), ALPM_ERR_PKG_OPEN, alpm_list_find_str(), ALPM_LOG_DEBUG, ALPM_LOG_ERROR, ALPM_LOG_WARNING, CLOSE, and OPEN.
Referenced by _alpm_unpack_single().
int _alpm_unpack_single | ( | alpm_handle_t * | handle, |
const char * | archive, | ||
const char * | prefix, | ||
const char * | filename | ||
) |
Unpack a specific file in an archive.
handle | the context handle |
archive | the archive to unpack |
prefix | where to extract the files |
filename | a file within the archive to unpack |
Definition at line 281 of file lib/libalpm/util.c.
References _alpm_unpack(), alpm_list_add(), and alpm_list_free().
Referenced by _alpm_runscriptlet().
char* strndup | ( | const char * | s, |
size_t | n | ||
) |
Copies a string.
Returned string needs to be freed
s | string to be copied |
n | maximum number of characters to copy |
Definition at line 1307 of file lib/libalpm/util.c.
char* strsep | ( | char ** | str, |
const char * | delims | ||
) |
Extracts tokens from a string.
Replaces strset which is not portable (missing on Solaris). Copyright (c) 2001 by François Gouget <fgouget_at_codeweavers.com> Modifies str to point to the first character after the token if one is found, or NULL if one is not.
str | string containing delimited tokens to parse |
delim | character delimiting tokens in str |
Definition at line 68 of file lib/libalpm/util.c.
Referenced by _alpm_makepath_mode().