summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/add.c34
-rw-r--r--lib/libalpm/alpm.c24
-rw-r--r--lib/libalpm/alpm.h1
-rw-r--r--lib/libalpm/alpm_list.c87
-rw-r--r--lib/libalpm/backup.c14
-rw-r--r--lib/libalpm/be_local.c70
-rw-r--r--lib/libalpm/be_package.c26
-rw-r--r--lib/libalpm/be_sync.c20
-rw-r--r--lib/libalpm/conflict.c62
-rw-r--r--lib/libalpm/db.c120
-rw-r--r--lib/libalpm/delta.c36
-rw-r--r--lib/libalpm/deps.c88
-rw-r--r--lib/libalpm/diskspace.c22
-rw-r--r--lib/libalpm/dload.c350
-rw-r--r--lib/libalpm/dload.h2
-rw-r--r--lib/libalpm/error.c19
-rw-r--r--lib/libalpm/graph.h2
-rw-r--r--lib/libalpm/group.c6
-rw-r--r--lib/libalpm/handle.c50
-rw-r--r--lib/libalpm/handle.h10
-rw-r--r--lib/libalpm/log.c4
-rw-r--r--lib/libalpm/package.c32
-rw-r--r--lib/libalpm/pkghash.c34
-rw-r--r--lib/libalpm/remove.c16
-rw-r--r--lib/libalpm/sync.c28
-rw-r--r--lib/libalpm/trans.c62
-rw-r--r--lib/libalpm/util.c88
-rw-r--r--lib/libalpm/util.h2
-rw-r--r--lib/libalpm/version.c14
29 files changed, 643 insertions, 680 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 702b12e9..0a5cb539 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -91,7 +91,7 @@ int SYMEXPORT alpm_add_pkg(pmpkg_t *pkg)
/* with the NEEDED flag, packages up to date are not reinstalled */
_alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- skipping\n"),
localpkgname, localpkgver);
- return(0);
+ return 0;
} else {
_alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- reinstalling\n"),
localpkgname, localpkgver);
@@ -109,7 +109,7 @@ int SYMEXPORT alpm_add_pkg(pmpkg_t *pkg)
pkgname, pkgver);
trans->add = alpm_list_add(trans->add, pkg);
- return(0);
+ return 0;
}
static int perform_extraction(struct archive *archive,
@@ -132,9 +132,9 @@ static int perform_extraction(struct archive *archive,
origname, archive_error_string(archive));
alpm_logaction("error: could not extract %s (%s)\n",
origname, archive_error_string(archive));
- return(1);
+ return 1;
}
- return(0);
+ return 0;
}
static int extract_single_file(struct archive *archive,
@@ -169,7 +169,7 @@ static int extract_single_file(struct archive *archive,
* already been handled (for future possibilities) */
_alpm_log(PM_LOG_DEBUG, "skipping extraction of '%s'\n", entryname);
archive_read_data_skip(archive);
- return(0);
+ return 0;
} else {
/* build the new entryname relative to handle->root */
snprintf(filename, PATH_MAX, "%s%s", handle->root, entryname);
@@ -182,7 +182,7 @@ static int extract_single_file(struct archive *archive,
alpm_logaction("note: %s is in NoExtract, skipping extraction\n",
entryname);
archive_read_data_skip(archive);
- return(0);
+ return 0;
}
/* Check for file existence. This is one of the more crucial parts
@@ -226,13 +226,13 @@ static int extract_single_file(struct archive *archive,
_alpm_log(PM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
entryname);
archive_read_data_skip(archive);
- return(0);
+ return 0;
} else {
/* case 10/11: trying to overwrite dir with file/symlink, don't allow it */
_alpm_log(PM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"),
entryname);
archive_read_data_skip(archive);
- return(1);
+ return 1;
}
} else if(S_ISLNK(lsbuf.st_mode) && S_ISDIR(entrymode)) {
/* case 9: existing symlink, dir in package */
@@ -241,13 +241,13 @@ static int extract_single_file(struct archive *archive,
_alpm_log(PM_LOG_DEBUG, "extract: skipping symlink overwrite of %s\n",
entryname);
archive_read_data_skip(archive);
- return(0);
+ return 0;
} else {
/* this is BAD. symlink was not to a directory */
_alpm_log(PM_LOG_ERROR, _("extract: symlink %s does not point to dir\n"),
entryname);
archive_read_data_skip(archive);
- return(1);
+ return 1;
}
} else if(S_ISREG(lsbuf.st_mode) && S_ISDIR(entrymode)) {
/* case 6: trying to overwrite file with dir */
@@ -299,7 +299,7 @@ static int extract_single_file(struct archive *archive,
/* error */
FREE(hash_orig);
FREE(entryname_orig);
- return(1);
+ return 1;
}
hash_local = alpm_compute_md5sum(filename);
@@ -442,7 +442,7 @@ static int extract_single_file(struct archive *archive,
if(ret == 1) {
/* error */
FREE(entryname_orig);
- return(1);
+ return 1;
}
/* calculate an hash if this is in newpkg's backup */
@@ -469,7 +469,7 @@ static int extract_single_file(struct archive *archive,
}
}
FREE(entryname_orig);
- return(errors);
+ return errors;
}
static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current,
@@ -705,7 +705,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current,
cleanup:
_alpm_pkg_free(oldpkg);
- return(ret);
+ return ret;
}
int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db)
@@ -720,7 +720,7 @@ int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db)
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
if(trans->add == NULL) {
- return(0);
+ return 0;
}
pkg_count = alpm_list_count(trans->add);
@@ -729,7 +729,7 @@ int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db)
/* loop through our package list adding/upgrading one at a time */
for(targ = trans->add; targ; targ = targ->next) {
if(handle->trans->state == STATE_INTERRUPTED) {
- return(ret);
+ return ret;
}
pmpkg_t *newpkg = (pmpkg_t *)targ->data;
@@ -750,7 +750,7 @@ int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db)
_alpm_ldconfig(handle->root);
}
- return(ret);
+ return ret;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 4f95832d..4d40d675 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -23,9 +23,8 @@
#include "config.h"
-/* connection caching setup */
-#ifdef HAVE_LIBFETCH
-#include <fetch.h>
+#ifdef HAVE_LIBCURL
+#include <curl/curl.h>
#endif
/* libalpm */
@@ -58,18 +57,19 @@ int SYMEXPORT alpm_initialize(void)
/* error code should be set */
_alpm_handle_free(handle);
handle = NULL;
- return(-1);
+ return -1;
}
#ifdef ENABLE_NLS
bindtextdomain("libalpm", LOCALEDIR);
#endif
-#ifdef HAVE_LIBFETCH
- fetchConnectionCacheInit(5, 1);
+#ifdef HAVE_LIBCURL
+ curl_global_init(CURL_GLOBAL_SSL);
+ handle->curl = curl_easy_init();
#endif
- return(0);
+ return 0;
}
/** Release the library. This should be the last alpm call you make.
@@ -82,17 +82,17 @@ int SYMEXPORT alpm_release(void)
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
if(alpm_db_unregister_all() == -1) {
- return(-1);
+ return -1;
}
_alpm_handle_free(handle);
handle = NULL;
-#ifdef HAVE_LIBFETCH
- fetchConnectionCacheClose();
+#ifdef HAVE_LIBCURL
+ curl_global_cleanup();
#endif
- return(0);
+ return 0;
}
/** @} */
@@ -103,7 +103,7 @@ int SYMEXPORT alpm_release(void)
/* Get the version of library */
const char SYMEXPORT *alpm_version(void) {
- return(LIB_VERSION);
+ return LIB_VERSION;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 0f3b7166..0b80506f 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -535,6 +535,7 @@ enum _pmerrno_t {
/* External library errors */
PM_ERR_LIBARCHIVE,
PM_ERR_LIBFETCH,
+ PM_ERR_LIBCURL,
PM_ERR_EXTERNAL_DOWNLOAD
};
diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index f0619bcd..0a3f6502 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -92,7 +92,7 @@ alpm_list_t SYMEXPORT *alpm_list_add(alpm_list_t *list, void *data)
ptr = calloc(1, sizeof(alpm_list_t));
if(ptr == NULL) {
- return(list);
+ return list;
}
ptr->data = data;
@@ -101,7 +101,7 @@ alpm_list_t SYMEXPORT *alpm_list_add(alpm_list_t *list, void *data)
/* Special case: the input list is empty */
if(list == NULL) {
ptr->prev = ptr;
- return(ptr);
+ return ptr;
}
lp = alpm_list_last(list);
@@ -109,7 +109,7 @@ alpm_list_t SYMEXPORT *alpm_list_add(alpm_list_t *list, void *data)
ptr->prev = lp;
list->prev = ptr;
- return(list);
+ return list;
}
/**
@@ -124,13 +124,13 @@ alpm_list_t SYMEXPORT *alpm_list_add(alpm_list_t *list, void *data)
alpm_list_t SYMEXPORT *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cmp fn)
{
if(!fn || !list) {
- return(alpm_list_add(list, data));
+ return alpm_list_add(list, data);
} else {
alpm_list_t *add = NULL, *prev = NULL, *next = list;
add = calloc(1, sizeof(alpm_list_t));
if(add == NULL) {
- return(list);
+ return list;
}
add->data = data;
@@ -146,19 +146,19 @@ alpm_list_t SYMEXPORT *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_
add->prev = list->prev; /* list != NULL */
add->next = list;
list->prev = add;
- return(add);
+ return add;
} else if(next == NULL) { /* another special case: add last element */
add->prev = prev;
add->next = NULL;
prev->next = add;
list->prev = add;
- return(list);
+ return list;
} else {
add->prev = prev;
add->next = next;
next->prev = add;
prev->next = add;
- return(list);
+ return list;
}
}
}
@@ -179,10 +179,10 @@ alpm_list_t SYMEXPORT *alpm_list_join(alpm_list_t *first, alpm_list_t *second)
alpm_list_t *tmp;
if (first == NULL) {
- return(second);
+ return second;
}
if (second == NULL) {
- return(first);
+ return first;
}
/* tmp is the last element of the first list */
tmp = first->prev;
@@ -193,7 +193,7 @@ alpm_list_t SYMEXPORT *alpm_list_join(alpm_list_t *first, alpm_list_t *second)
/* set the back reference to the tail */
second->prev = tmp;
- return(first);
+ return first;
}
/**
@@ -257,7 +257,7 @@ alpm_list_t SYMEXPORT *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, a
}
newlist->prev = lp;
- return(newlist);
+ return newlist;
}
/**
@@ -282,7 +282,7 @@ alpm_list_t SYMEXPORT *alpm_list_msort(alpm_list_t *list, size_t n, alpm_list_fn
right = alpm_list_msort(right, n - (n/2), fn);
list = alpm_list_mmerge(left, right, fn);
}
- return(list);
+ return list;
}
/**
@@ -298,7 +298,7 @@ alpm_list_t SYMEXPORT *alpm_list_remove_item(alpm_list_t *haystack,
alpm_list_t *item)
{
if(haystack == NULL || item == NULL) {
- return(haystack);
+ return haystack;
}
if(item == haystack) {
@@ -328,7 +328,7 @@ alpm_list_t SYMEXPORT *alpm_list_remove_item(alpm_list_t *haystack,
}
}
- return(haystack);
+ return haystack;
}
@@ -352,7 +352,7 @@ alpm_list_t SYMEXPORT *alpm_list_remove(alpm_list_t *haystack,
}
if(needle == NULL) {
- return(haystack);
+ return haystack;
}
while(i) {
@@ -373,7 +373,7 @@ alpm_list_t SYMEXPORT *alpm_list_remove(alpm_list_t *haystack,
}
}
- return(haystack);
+ return haystack;
}
/**
@@ -388,8 +388,8 @@ alpm_list_t SYMEXPORT *alpm_list_remove(alpm_list_t *haystack,
alpm_list_t SYMEXPORT *alpm_list_remove_str(alpm_list_t *haystack,
const char *needle, char **data)
{
- return(alpm_list_remove(haystack, (const void *)needle,
- (alpm_list_fn_cmp)strcmp, (void **)data));
+ return alpm_list_remove(haystack, (const void *)needle,
+ (alpm_list_fn_cmp)strcmp, (void **)data);
}
/**
@@ -411,7 +411,7 @@ alpm_list_t SYMEXPORT *alpm_list_remove_dupes(const alpm_list_t *list)
}
lp = lp->next;
}
- return(newlist);
+ return newlist;
}
/**
@@ -429,7 +429,7 @@ alpm_list_t SYMEXPORT *alpm_list_strdup(const alpm_list_t *list)
newlist = alpm_list_add(newlist, strdup(lp->data));
lp = lp->next;
}
- return(newlist);
+ return newlist;
}
/**
@@ -447,7 +447,7 @@ alpm_list_t SYMEXPORT *alpm_list_copy(const alpm_list_t *list)
newlist = alpm_list_add(newlist, lp->data);
lp = lp->next;
}
- return(newlist);
+ return newlist;
}
/**
@@ -473,7 +473,7 @@ alpm_list_t SYMEXPORT *alpm_list_copy_data(const alpm_list_t *list,
lp = lp->next;
}
}
- return(newlist);
+ return newlist;
}
/**
@@ -489,7 +489,7 @@ alpm_list_t SYMEXPORT *alpm_list_reverse(alpm_list_t *list)
alpm_list_t *newlist = NULL, *backup;
if(list == NULL) {
- return(NULL);
+ return NULL;
}
lp = alpm_list_last(list);
@@ -502,7 +502,7 @@ alpm_list_t SYMEXPORT *alpm_list_reverse(alpm_list_t *list)
lp = lp->prev;
}
list->prev = backup; /* restore tail pointer */
- return(newlist);
+ return newlist;
}
/* Accessors */
@@ -517,9 +517,9 @@ alpm_list_t SYMEXPORT *alpm_list_reverse(alpm_list_t *list)
inline alpm_list_t SYMEXPORT *alpm_list_first(const alpm_list_t *list)
{
if(list) {
- return((alpm_list_t*)list);
+ return (alpm_list_t *)list;
} else {
- return(NULL);
+ return NULL;
}
}
@@ -537,7 +537,7 @@ alpm_list_t SYMEXPORT *alpm_list_nth(const alpm_list_t *list, size_t n)
while(n--) {
i = i->next;
}
- return((alpm_list_t*)i);
+ return (alpm_list_t *)i;
}
/**
@@ -550,9 +550,9 @@ alpm_list_t SYMEXPORT *alpm_list_nth(const alpm_list_t *list, size_t n)
inline alpm_list_t SYMEXPORT *alpm_list_next(const alpm_list_t *node)
{
if(node) {
- return(node->next);
+ return node->next;
} else {
- return(NULL);
+ return NULL;
}
}
@@ -566,9 +566,9 @@ inline alpm_list_t SYMEXPORT *alpm_list_next(const alpm_list_t *node)
alpm_list_t SYMEXPORT *alpm_list_last(const alpm_list_t *list)
{
if(list) {
- return(list->prev);
+ return list->prev;
} else {
- return(NULL);
+ return NULL;
}
}
@@ -581,8 +581,8 @@ alpm_list_t SYMEXPORT *alpm_list_last(const alpm_list_t *list)
*/
void SYMEXPORT *alpm_list_getdata(const alpm_list_t *node)
{
- if(node == NULL) return(NULL);
- return(node->data);
+ if(node == NULL) return NULL;
+ return node->data;
}
/* Misc */
@@ -602,7 +602,7 @@ size_t SYMEXPORT alpm_list_count(const alpm_list_t *list)
++i;
lp = lp->next;
}
- return(i);
+ return i;
}
/**
@@ -620,17 +620,17 @@ void SYMEXPORT *alpm_list_find(const alpm_list_t *haystack, const void *needle,
const alpm_list_t *lp = haystack;
while(lp) {
if(lp->data && fn(lp->data, needle) == 0) {
- return(lp->data);
+ return lp->data;
}
lp = lp->next;
}
- return(NULL);
+ return NULL;
}
/* trivial helper function for alpm_list_find_ptr */
static int ptr_cmp(const void *p, const void *q)
{
- return(p != q);
+ return (p != q);
}
/**
@@ -643,9 +643,10 @@ static int ptr_cmp(const void *p, const void *q)
*
* @return `needle` if found, NULL otherwise
*/
-void SYMEXPORT *alpm_list_find_ptr(const alpm_list_t *haystack, const void *needle)
+void SYMEXPORT *alpm_list_find_ptr(const alpm_list_t *haystack,
+ const void *needle)
{
- return(alpm_list_find(haystack, needle, ptr_cmp));
+ return alpm_list_find(haystack, needle, ptr_cmp);
}
/**
@@ -659,8 +660,8 @@ void SYMEXPORT *alpm_list_find_ptr(const alpm_list_t *haystack, const void *need
char SYMEXPORT *alpm_list_find_str(const alpm_list_t *haystack,
const char *needle)
{
- return((char *)alpm_list_find(haystack, (const void*)needle,
- (alpm_list_fn_cmp)strcmp));
+ return (char *)alpm_list_find(haystack, (const void *)needle,
+ (alpm_list_fn_cmp)strcmp);
}
/**
@@ -745,7 +746,7 @@ alpm_list_t SYMEXPORT *alpm_list_diff(const alpm_list_t *lhs,
alpm_list_free(left);
alpm_list_free(right);
- return(ret);
+ return ret;
}
/** @} */
diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c
index ca955ca4..7df97471 100644
--- a/lib/libalpm/backup.c
+++ b/lib/libalpm/backup.c
@@ -47,7 +47,7 @@ static int backup_split(const char *string, char **file, char **hash)
/* don't need our dup as the fname wasn't requested, so free it */
FREE(str);
}
- return(0);
+ return 0;
}
*ptr = '\0';
ptr++;
@@ -59,21 +59,21 @@ static int backup_split(const char *string, char **file, char **hash)
*hash = strdup(ptr);
}
FREE(str);
- return(1);
+ return 1;
}
char *_alpm_backup_file(const char *string)
{
char *file = NULL;
backup_split(string, &file, NULL);
- return(file);
+ return file;
}
char *_alpm_backup_hash(const char *string)
{
char *hash = NULL;
backup_split(string, NULL, &hash);
- return(hash);
+ return hash;
}
/* Look for a filename in a pmpkg_t.backup list. If we find it,
@@ -86,7 +86,7 @@ char *_alpm_needbackup(const char *file, const alpm_list_t *backup)
ALPM_LOG_FUNC;
if(file == NULL || backup == NULL) {
- return(NULL);
+ return NULL;
}
/* run through the backup list and parse out the hash for our file */
@@ -101,13 +101,13 @@ char *_alpm_needbackup(const char *file, const alpm_list_t *backup)
}
if(strcmp(file, filename) == 0) {
FREE(filename);
- return(hash);
+ return hash;
}
FREE(filename);
FREE(hash);
}
- return(NULL);
+ return NULL;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index c13dffb4..82c1d591 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -51,8 +51,8 @@
#define LAZY_LOAD(info, errret) \
do { \
ALPM_LOG_FUNC; \
- ASSERT(handle != NULL, return(errret)); \
- ASSERT(pkg != NULL, return(errret)); \
+ ASSERT(handle != NULL, return (errret)); \
+ ASSERT(pkg != NULL, return (errret)); \
if(pkg->origin != PKG_FROM_FILE && !(pkg->infolevel & info)) { \
_alpm_local_db_read(pkg->origin_data.db, pkg, info); \
} \
@@ -73,13 +73,13 @@ static const char *_cache_get_filename(pmpkg_t *pkg)
static const char *_cache_get_name(pmpkg_t *pkg)
{
- ASSERT(pkg != NULL, return(NULL));
+ ASSERT(pkg != NULL, return NULL);
return pkg->name;
}
static const char *_cache_get_version(pmpkg_t *pkg)
{
- ASSERT(pkg != NULL, return(NULL));
+ ASSERT(pkg != NULL, return NULL);
return pkg->version;
}
@@ -160,8 +160,8 @@ static int _cache_has_scriptlet(pmpkg_t *pkg)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(-1));
- ASSERT(pkg != NULL, return(-1));
+ ASSERT(handle != NULL, return -1);
+ ASSERT(pkg != NULL, return -1);
if(!(pkg->infolevel & INFRQ_SCRIPTLET)) {
_alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_SCRIPTLET);
@@ -210,8 +210,8 @@ static alpm_list_t *_cache_get_files(pmpkg_t *pkg)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(pkg != NULL, return NULL);
if(pkg->origin == PKG_FROM_LOCALDB
&& !(pkg->infolevel & INFRQ_FILES)) {
@@ -225,8 +225,8 @@ static alpm_list_t *_cache_get_backup(pmpkg_t *pkg)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(pkg != NULL, return NULL);
if(pkg->origin == PKG_FROM_LOCALDB
&& !(pkg->infolevel & INFRQ_FILES)) {
@@ -246,8 +246,8 @@ static void *_cache_changelog_open(pmpkg_t *pkg)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(pkg != NULL, return NULL);
char clfile[PATH_MAX];
snprintf(clfile, PATH_MAX, "%s/%s/%s-%s/changelog",
@@ -270,13 +270,13 @@ static void *_cache_changelog_open(pmpkg_t *pkg)
static size_t _cache_changelog_read(void *ptr, size_t size,
const pmpkg_t *pkg, const void *fp)
{
- return ( fread(ptr, 1, size, (FILE*)fp) );
+ return fread(ptr, 1, size, (FILE *)fp);
}
/*
static int _cache_changelog_feof(const pmpkg_t *pkg, void *fp)
{
- return( feof((FILE*)fp) );
+ return feof((FILE*)fp);
}
*/
@@ -289,7 +289,7 @@ static int _cache_changelog_feof(const pmpkg_t *pkg, void *fp)
*/
static int _cache_changelog_close(const pmpkg_t *pkg, void *fp)
{
- return( fclose((FILE*)fp) );
+ return fclose((FILE *)fp);
}
@@ -345,14 +345,14 @@ static int checkdbdir(pmdb_t *db)
RET_ERR(PM_ERR_SYSTEM, -1);
}
}
- return(0);
+ return 0;
}
static int is_dir(const char *path, struct dirent *entry)
{
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
if(entry->d_type != DT_UNKNOWN) {
- return(entry->d_type == DT_DIR);
+ return (entry->d_type == DT_DIR);
}
#endif
{
@@ -362,11 +362,11 @@ static int is_dir(const char *path, struct dirent *entry)
snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);
if (!stat(buffer, &sbuf)) {
- return(S_ISDIR(sbuf.st_mode));
+ return S_ISDIR(sbuf.st_mode);
}
}
- return(0);
+ return 0;
}
static int local_db_populate(pmdb_t *db)
@@ -390,7 +390,7 @@ static int local_db_populate(pmdb_t *db)
if(dbdir == NULL) {
if(errno == ENOENT) {
/* no database existing yet is not an error */
- return(0);
+ return 0;
}
RET_ERR(PM_ERR_DB_OPEN, -1);
}
@@ -476,7 +476,7 @@ static int local_db_populate(pmdb_t *db)
if(count > 0) {
db->pkgcache->list = alpm_list_msort(db->pkgcache->list, (size_t)count, _alpm_pkg_cmp);
}
- return(count);
+ return count;
}
/* Note: the return value must be freed by the caller */
@@ -490,7 +490,7 @@ static char *get_pkgpath(pmdb_t *db, pmpkg_t *info)
len = strlen(dbpath) + strlen(info->name) + strlen(info->version) + 3;
MALLOC(pkgpath, len, RET_ERR(PM_ERR_MEMORY, NULL));
sprintf(pkgpath, "%s%s-%s/", dbpath, info->name, info->version);
- return(pkgpath);
+ return pkgpath;
}
@@ -509,14 +509,14 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
if(info == NULL || info->name == NULL || info->version == NULL) {
_alpm_log(PM_LOG_DEBUG, "invalid package entry provided to _alpm_local_db_read, skipping\n");
- return(-1);
+ return -1;
}
if(info->origin != PKG_FROM_LOCALDB) {
_alpm_log(PM_LOG_DEBUG,
"request to read info for a non-local package '%s', skipping...\n",
info->name);
- return(-1);
+ return -1;
}
/* bitmask logic here:
@@ -526,7 +526,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
* == to inforeq? nope, we need to load more info. */
if((info->infolevel & inforeq) == inforeq) {
/* already loaded all of this info, do nothing */
- return(0);
+ return 0;
}
_alpm_log(PM_LOG_FUNCTION, "loading package data for %s : level=0x%x\n",
info->name, inforeq);
@@ -706,14 +706,14 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
info->infolevel |= inforeq;
free(pkgpath);
- return(0);
+ return 0;
error:
free(pkgpath);
if(fp) {
fclose(fp);
}
- return(-1);
+ return -1;
}
int _alpm_local_db_prepare(pmdb_t *db, pmpkg_t *info)
@@ -723,7 +723,7 @@ int _alpm_local_db_prepare(pmdb_t *db, pmpkg_t *info)
char *pkgpath = NULL;
if(checkdbdir(db) != 0) {
- return(-1);
+ return -1;
}
oldmask = umask(0000);
@@ -737,7 +737,7 @@ int _alpm_local_db_prepare(pmdb_t *db, pmpkg_t *info)
free(pkgpath);
umask(oldmask);
- return(retval);
+ return retval;
}
int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
@@ -752,7 +752,7 @@ int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
ALPM_LOG_FUNC;
if(db == NULL || info == NULL) {
- return(-1);
+ return -1;
}
pkgpath = get_pkgpath(db, info);
@@ -761,7 +761,7 @@ int _alpm_local_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
oldmask = umask(0022);
if(strcmp(db->treename, "local") != 0) {
- return(-1);
+ return -1;
}
/* DESC */
@@ -904,7 +904,7 @@ cleanup:
fclose(fp);
}
- return(retval);
+ return retval;
}
int _alpm_local_db_remove(pmdb_t *db, pmpkg_t *info)
@@ -925,7 +925,7 @@ int _alpm_local_db_remove(pmdb_t *db, pmpkg_t *info)
if(ret != 0) {
ret = -1;
}
- return(ret);
+ return ret;
}
static int local_db_version(pmdb_t *db)
@@ -977,7 +977,7 @@ done:
}
_alpm_log(PM_LOG_DEBUG, "local database version %d\n", version);
- return(version);
+ return version;
}
struct db_operations local_db_ops = {
@@ -1001,7 +1001,7 @@ pmdb_t *_alpm_db_register_local(void)
db->ops = &local_db_ops;
handle->db_local = db;
- return(db);
+ return db;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index f4837890..fbd2c0c7 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -47,7 +47,7 @@ static void *_package_changelog_open(pmpkg_t *pkg)
{
ALPM_LOG_FUNC;
- ASSERT(pkg != NULL, return(NULL));
+ ASSERT(pkg != NULL, return NULL);
struct archive *archive = NULL;
struct archive_entry *entry;
@@ -69,14 +69,14 @@ static void *_package_changelog_open(pmpkg_t *pkg)
const char *entry_name = archive_entry_pathname(entry);
if(strcmp(entry_name, ".CHANGELOG") == 0) {
- return(archive);
+ return archive;
}
}
/* we didn't find a changelog */
archive_read_finish(archive);
errno = ENOENT;
- return(NULL);
+ return NULL;
}
/**
@@ -95,9 +95,9 @@ static size_t _package_changelog_read(void *ptr, size_t size,
/* Report error (negative values) */
if(sret < 0) {
pm_errno = PM_ERR_LIBARCHIVE;
- return(0);
+ return 0;
} else {
- return((size_t)sret);
+ return (size_t)sret;
}
}
@@ -105,7 +105,7 @@ static size_t _package_changelog_read(void *ptr, size_t size,
static int _package_changelog_feof(const pmpkg_t *pkg, void *fp)
{
// note: this doesn't quite work, no feof in libarchive
- return( archive_read_data((struct archive*)fp, NULL, 0) );
+ return archive_read_data((struct archive*)fp, NULL, 0);
}
*/
@@ -118,7 +118,7 @@ static int _package_changelog_feof(const pmpkg_t *pkg, void *fp)
*/
static int _package_changelog_close(const pmpkg_t *pkg, void *fp)
{
- return( archive_read_finish((struct archive *)fp) );
+ return archive_read_finish((struct archive *)fp);
}
/** Package file operations struct accessor. We implement this as a method
@@ -137,7 +137,7 @@ static struct pkg_operations *get_file_pkg_ops(void)
file_pkg_ops.changelog_close = _package_changelog_close;
file_pkg_ops_initialized = 1;
}
- return(&file_pkg_ops);
+ return &file_pkg_ops;
}
/**
@@ -226,7 +226,7 @@ static int parse_descfile(struct archive *a, pmpkg_t *newpkg)
line[0] = '\0';
}
- return(0);
+ return 0;
}
/**
@@ -356,7 +356,7 @@ static pmpkg_t *pkg_load(const char *pkgfile, int full)
newpkg->infolevel = INFRQ_BASE | INFRQ_DESC;
}
- return(newpkg);
+ return newpkg;
pkg_invalid:
pm_errno = PM_ERR_PKG_INVALID;
@@ -364,7 +364,7 @@ error:
_alpm_pkg_free(newpkg);
archive_read_finish(archive);
- return(NULL);
+ return NULL;
}
/** Create a package from a file.
@@ -389,10 +389,10 @@ int SYMEXPORT alpm_pkg_load(const char *filename, int full, pmpkg_t **pkg)
*pkg = pkg_load(filename, full);
if(*pkg == NULL) {
/* pm_errno is set by pkg_load */
- return(-1);
+ return -1;
}
- return(0);
+ return 0;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 98516fd8..4966ce6f 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -133,17 +133,17 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
if(ret == 1) {
/* files match, do nothing */
pm_errno = 0;
- return(1);
+ return 1;
} else if(ret == -1) {
/* pm_errno was set by the download code */
_alpm_log(PM_LOG_DEBUG, "failed to sync db: %s\n", alpm_strerrorlast());
- return(-1);
+ return -1;
}
/* Cache needs to be rebuilt */
_alpm_db_free_pkgcache(db);
- return(0);
+ return 0;
}
/* Forward decl so I don't reorganize the whole file right now */
@@ -204,7 +204,7 @@ static size_t estimate_package_count(struct stat *st, struct archive *archive)
/* assume it is at least somewhat compressed */
per_package = 200;
}
- return((size_t)(st->st_size / per_package) + 1);
+ return (size_t)((st->st_size / per_package) + 1);
}
static int sync_db_populate(pmdb_t *db)
@@ -294,7 +294,7 @@ static int sync_db_populate(pmdb_t *db)
}
archive_read_finish(archive);
- return(count);
+ return count;
}
#define READ_NEXT(s) do { \
@@ -334,7 +334,7 @@ static int sync_db_read(pmdb_t *db, struct archive *archive,
}
if(entryname == NULL) {
_alpm_log(PM_LOG_DEBUG, "invalid archive entry provided to _alpm_sync_db_read, skipping\n");
- return(-1);
+ return -1;
}
_alpm_log(PM_LOG_FUNCTION, "loading package data from archive entry %s\n",
@@ -365,7 +365,7 @@ static int sync_db_read(pmdb_t *db, struct archive *archive,
if(pkg == NULL) {
_alpm_log(PM_LOG_DEBUG, "package %s not found in %s sync database",
pkgname, db->treename);
- return(-1);
+ return -1;
}
if(strcmp(filename, "desc") == 0 || strcmp(filename, "depends") == 0
@@ -452,12 +452,12 @@ static int sync_db_read(pmdb_t *db, struct archive *archive,
error:
FREE(pkgname);
/* TODO: return 0 always? */
- return(0);
+ return 0;
}
static int sync_db_version(pmdb_t *db)
{
- return(2);
+ return 2;
}
struct db_operations sync_db_ops = {
@@ -490,7 +490,7 @@ pmdb_t *_alpm_db_register_sync(const char *treename)
db->ops = &sync_db_ops;
handle->dbs_sync = alpm_list_add(handle->dbs_sync, db);
- return(db);
+ return db;
}
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 6faced16..b4ecd659 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -53,7 +53,7 @@ pmconflict_t *_alpm_conflict_new(const char *package1, const char *package2,
STRDUP(conflict->package2, package2, RET_ERR(PM_ERR_MEMORY, NULL));
STRDUP(conflict->reason, reason, RET_ERR(PM_ERR_MEMORY, NULL));
- return(conflict);
+ return conflict;
}
void _alpm_conflict_free(pmconflict_t *conflict)
@@ -73,7 +73,7 @@ pmconflict_t *_alpm_conflict_dup(const pmconflict_t *conflict)
STRDUP(newconflict->package2, conflict->package2, RET_ERR(PM_ERR_MEMORY, NULL));
STRDUP(newconflict->reason, conflict->reason, RET_ERR(PM_ERR_MEMORY, NULL));
- return(newconflict);
+ return newconflict;
}
static int conflict_isin(pmconflict_t *needle, alpm_list_t *haystack)
@@ -90,11 +90,11 @@ static int conflict_isin(pmconflict_t *needle, alpm_list_t *haystack)
const char *cpkg2 = conflict->package2;
if((strcmp(cpkg1, npkg1) == 0 && strcmp(cpkg2, npkg2) == 0)
|| (strcmp(cpkg1, npkg2) == 0 && strcmp(cpkg2, npkg1) == 0)) {
- return(1);
+ return 1;
}
}
- return(0);
+ return 0;
}
/** Adds the pkg1/pkg2 conflict to the baddeps list
@@ -173,7 +173,7 @@ alpm_list_t *_alpm_innerconflicts(alpm_list_t *packages)
_alpm_log(PM_LOG_DEBUG, "check targets vs targets\n");
check_conflict(packages, packages, &baddeps, 0);
- return(baddeps);
+ return baddeps;
}
/* Check for target vs (db - target) conflicts
@@ -187,7 +187,7 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)
ALPM_LOG_FUNC;
if(db == NULL) {
- return(NULL);
+ return NULL;
}
alpm_list_t *dblist = alpm_list_diff(_alpm_db_get_pkgcache(db),
@@ -200,7 +200,7 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)
check_conflict(dblist, packages, &baddeps, -1);
alpm_list_free(dblist);
- return(baddeps);
+ return baddeps;
}
/** Check the package conflicts in a database
@@ -209,7 +209,7 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)
* @return an alpm_list_t of pmconflict_t
*/
alpm_list_t SYMEXPORT *alpm_checkconflicts(alpm_list_t *pkglist) {
- return(_alpm_innerconflicts(pkglist));
+ return _alpm_innerconflicts(pkglist);
}
/* Returns a alpm_list_t* of file conflicts.
@@ -246,7 +246,7 @@ static alpm_list_t *chk_fileconflicts(alpm_list_t *filesA, alpm_list_t *filesB)
}
}
- return(ret);
+ return ret;
}
/* Returns a alpm_list_t* of files that are in filesA but *NOT* in filesB
@@ -293,7 +293,7 @@ static alpm_list_t *chk_filedifference(alpm_list_t *filesA, alpm_list_t *filesB)
pA = pA->next;
}
- return(ret);
+ return ret;
}
/* Adds pmfileconflict_t to a conflicts list. Pass the conflicts list, type (either
@@ -321,7 +321,7 @@ static alpm_list_t *add_fileconflict(alpm_list_t *conflicts,
_alpm_log(PM_LOG_DEBUG, "found file conflict %s, packages %s and %s\n",
filestr, name1, name2 ? name2 : "(filesystem)");
- return(conflicts);
+ return conflicts;
}
void _alpm_fileconflict_free(pmfileconflict_t *conflict)
@@ -345,7 +345,7 @@ static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg)
snprintf(abspath, PATH_MAX, "%s%s", handle->root, dirpath);
dir = opendir(abspath);
if(dir == NULL) {
- return(1);
+ return 1;
}
while((ent = readdir(dir)) != NULL) {
const char *name = ent->d_name;
@@ -363,19 +363,19 @@ static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg)
continue;
} else {
closedir(dir);
- return(0);
+ return 0;
}
} else {
if(alpm_list_find_str(alpm_pkg_get_files(pkg), path)) {
continue;
} else {
closedir(dir);
- return(0);
+ return 0;
}
}
}
closedir(dir);
- return(1);
+ return 1;
}
/* Find file conflicts that may occur during the transaction with two checks:
@@ -391,7 +391,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans,
ALPM_LOG_FUNC;
if(db == NULL || upgrade == NULL || trans == NULL) {
- return(NULL);
+ return NULL;
}
/* TODO this whole function needs a huge change, which hopefully will
@@ -540,7 +540,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans,
PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", 100,
numtargs, current);
- return(conflicts);
+ return conflicts;
}
const char SYMEXPORT *alpm_conflict_get_package1(pmconflict_t *conflict)
@@ -548,8 +548,8 @@ const char SYMEXPORT *alpm_conflict_get_package1(pmconflict_t *conflict)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(conflict != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(conflict != NULL, return NULL);
return conflict->package1;
}
@@ -559,8 +559,8 @@ const char SYMEXPORT *alpm_conflict_get_package2(pmconflict_t *conflict)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(conflict != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(conflict != NULL, return NULL);
return conflict->package2;
}
@@ -570,8 +570,8 @@ const char SYMEXPORT *alpm_conflict_get_reason(pmconflict_t *conflict)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(conflict != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(conflict != NULL, return NULL);
return conflict->reason;
}
@@ -581,8 +581,8 @@ const char SYMEXPORT *alpm_fileconflict_get_target(pmfileconflict_t *conflict)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(conflict != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(conflict != NULL, return NULL);
return conflict->target;
}
@@ -592,8 +592,8 @@ pmfileconflicttype_t SYMEXPORT alpm_fileconflict_get_type(pmfileconflict_t *conf
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(-1));
- ASSERT(conflict != NULL, return(-1));
+ ASSERT(handle != NULL, return -1);
+ ASSERT(conflict != NULL, return -1);
return conflict->type;
}
@@ -603,8 +603,8 @@ const char SYMEXPORT *alpm_fileconflict_get_file(pmfileconflict_t *conflict)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(conflict != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(conflict != NULL, return NULL);
return conflict->file;
}
@@ -614,8 +614,8 @@ const char SYMEXPORT *alpm_fileconflict_get_ctarget(pmfileconflict_t *conflict)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(conflict != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(conflict != NULL, return NULL);
return conflict->ctarget;
}
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index fb64faed..20e1999b 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -61,7 +61,7 @@ pmdb_t SYMEXPORT *alpm_db_register_sync(const char *treename)
/* Do not register a database if a transaction is on-going */
ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL));
- return(_alpm_db_register_sync(treename));
+ return _alpm_db_register_sync(treename);
}
/* Helper function for alpm_db_unregister{_all} */
@@ -104,7 +104,7 @@ int SYMEXPORT alpm_db_unregister_all(void)
i->data = NULL;
}
FREELIST(handle->dbs_sync);
- return(0);
+ return 0;
}
/** Unregister a package database
@@ -144,7 +144,7 @@ int SYMEXPORT alpm_db_unregister(pmdb_t *db)
}
db->ops->unregister(db);
- return(0);
+ return 0;
}
/** Set the serverlist of a database.
@@ -191,7 +191,7 @@ int SYMEXPORT alpm_db_setserver(pmdb_t *db, const char *url)
_alpm_log(PM_LOG_DEBUG, "serverlist flushed for '%s'\n", db->treename);
}
- return(0);
+ return 0;
}
/** Get the name of a package database
@@ -203,8 +203,8 @@ const char SYMEXPORT *alpm_db_get_name(const pmdb_t *db)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(db != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(db != NULL, return NULL);
return db->treename;
}
@@ -220,13 +220,13 @@ const char SYMEXPORT *alpm_db_get_url(const pmdb_t *db)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(db != NULL, return(NULL));
- ASSERT(db->servers != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(db != NULL, return NULL);
+ ASSERT(db->servers != NULL, return NULL);
url = (char*)db->servers->data;
- return(url);
+ return url;
}
@@ -240,11 +240,11 @@ pmpkg_t SYMEXPORT *alpm_db_get_pkg(pmdb_t *db, const char *name)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(db != NULL, return(NULL));
- ASSERT(name != NULL && strlen(name) != 0, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(db != NULL, return NULL);
+ ASSERT(name != NULL && strlen(name) != 0, return NULL);
- return(_alpm_db_get_pkgfromcache(db, name));
+ return _alpm_db_get_pkgfromcache(db, name);
}
/** Get the package cache of a package database
@@ -256,10 +256,10 @@ alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(db != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(db != NULL, return NULL);
- return(_alpm_db_get_pkgcache(db));
+ return _alpm_db_get_pkgcache(db);
}
/** Get a group entry from a package database
@@ -272,11 +272,11 @@ pmgrp_t SYMEXPORT *alpm_db_readgrp(pmdb_t *db, const char *name)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(db != NULL, return(NULL));
- ASSERT(name != NULL && strlen(name) != 0, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(db != NULL, return NULL);
+ ASSERT(name != NULL && strlen(name) != 0, return NULL);
- return(_alpm_db_get_grpfromcache(db, name));
+ return _alpm_db_get_grpfromcache(db, name);
}
/** Get the group cache of a package database
@@ -288,10 +288,10 @@ alpm_list_t SYMEXPORT *alpm_db_get_grpcache(pmdb_t *db)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(db != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(db != NULL, return NULL);
- return(_alpm_db_get_grpcache(db));
+ return _alpm_db_get_grpcache(db);
}
/** Searches a database
@@ -304,10 +304,10 @@ alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(db != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(db != NULL, return NULL);
- return(_alpm_db_search(db, needles));
+ return _alpm_db_search(db, needles);
}
/** Set install reason for a package in db
@@ -332,16 +332,16 @@ int SYMEXPORT alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t
_alpm_log(PM_LOG_DEBUG, "setting install reason %u for %s/%s\n", reason, db->treename, name);
if(alpm_pkg_get_reason(pkg) == reason) {
/* we are done */
- return(0);
+ return 0;
}
/* set reason (in pkgcache) */
pkg->reason = reason;
/* write DESC */
if(_alpm_local_db_write(db, pkg, INFRQ_DESC)) {
- return(-1);
+ return -1;
}
- return(0);
+ return 0;
}
/** @} */
@@ -356,7 +356,7 @@ pmdb_t *_alpm_db_new(const char *treename, int is_local)
STRDUP(db->treename, treename, RET_ERR(PM_ERR_MEMORY, NULL));
db->is_local = is_local;
- return(db);
+ return db;
}
void _alpm_db_free(pmdb_t *db)
@@ -377,7 +377,7 @@ void _alpm_db_free(pmdb_t *db)
const char *_alpm_db_path(pmdb_t *db)
{
if(!db) {
- return(NULL);
+ return NULL;
}
if(!db->_path) {
const char *dbpath;
@@ -402,22 +402,22 @@ const char *_alpm_db_path(pmdb_t *db)
_alpm_log(PM_LOG_DEBUG, "database path for tree %s set to %s\n",
db->treename, db->_path);
}
- return(db->_path);
+ return db->_path;
}
int _alpm_db_version(pmdb_t *db)
{
if(!db) {
- return(-1);
+ return -1;
}
- return(db->ops->version(db));
+ return db->ops->version(db);
}
int _alpm_db_cmp(const void *d1, const void *d2)
{
pmdb_t *db1 = (pmdb_t *)d1;
pmdb_t *db2 = (pmdb_t *)d2;
- return(strcmp(db1->treename, db2->treename));
+ return strcmp(db1->treename, db2->treename);
}
alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles)
@@ -493,7 +493,7 @@ alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles)
regfree(&reg);
}
- return(ret);
+ return ret;
}
/* Returns a new package cache from db.
@@ -504,7 +504,7 @@ int _alpm_db_load_pkgcache(pmdb_t *db)
ALPM_LOG_FUNC;
if(db == NULL) {
- return(-1);
+ return -1;
}
_alpm_db_free_pkgcache(db);
@@ -513,11 +513,11 @@ int _alpm_db_load_pkgcache(pmdb_t *db)
if(db->ops->populate(db) == -1) {
_alpm_log(PM_LOG_DEBUG,
"failed to load package cache for repository '%s'\n", db->treename);
- return(-1);
+ return -1;
}
db->pkgcache_loaded = 1;
- return(0);
+ return 0;
}
void _alpm_db_free_pkgcache(pmdb_t *db)
@@ -544,7 +544,7 @@ pmpkghash_t *_alpm_db_get_pkgcache_hash(pmdb_t *db)
ALPM_LOG_FUNC;
if(db == NULL) {
- return(NULL);
+ return NULL;
}
if(!db->pkgcache_loaded) {
@@ -556,7 +556,7 @@ pmpkghash_t *_alpm_db_get_pkgcache_hash(pmdb_t *db)
_alpm_log(PM_LOG_DEBUG, "warning: pkgcache is NULL for db '%s'\n", db->treename);
}
- return(db->pkgcache);
+ return db->pkgcache;
}
alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db)
@@ -566,10 +566,10 @@ alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db)
pmpkghash_t *hash = _alpm_db_get_pkgcache_hash(db);
if(hash == NULL) {
- return(NULL);
+ return NULL;
}
- return(hash->list);
+ return hash->list;
}
/* "duplicate" pkg then add it to pkgcache */
@@ -580,12 +580,12 @@ int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
ALPM_LOG_FUNC;
if(db == NULL || !db->pkgcache_loaded || pkg == NULL) {
- return(-1);
+ return -1;
}
newpkg = _alpm_pkg_dup(pkg);
if(newpkg == NULL) {
- return(-1);
+ return -1;
}
_alpm_log(PM_LOG_DEBUG, "adding entry '%s' in '%s' cache\n",
@@ -594,7 +594,7 @@ int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
_alpm_db_free_grpcache(db);
- return(0);
+ return 0;
}
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
@@ -604,7 +604,7 @@ int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
ALPM_LOG_FUNC;
if(db == NULL || !db->pkgcache_loaded || pkg == NULL) {
- return(-1);
+ return -1;
}
_alpm_log(PM_LOG_DEBUG, "removing entry '%s' from '%s' cache\n",
@@ -615,14 +615,14 @@ int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
/* package not found */
_alpm_log(PM_LOG_DEBUG, "cannot remove entry '%s' from '%s' cache: not found\n",
alpm_pkg_get_name(pkg), db->treename);
- return(-1);
+ return -1;
}
_alpm_pkg_free(data);
_alpm_db_free_grpcache(db);
- return(0);
+ return 0;
}
pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, const char *target)
@@ -630,17 +630,17 @@ pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, const char *target)
ALPM_LOG_FUNC;
if(db == NULL) {
- return(NULL);
+ return NULL;
}
pmpkghash_t *pkgcache = _alpm_db_get_pkgcache_hash(db);
if(!pkgcache) {
_alpm_log(PM_LOG_DEBUG, "warning: failed to get '%s' from NULL pkgcache\n",
target);
- return(NULL);
+ return NULL;
}
- return(_alpm_pkghash_find(pkgcache, target));
+ return _alpm_pkghash_find(pkgcache, target);
}
/* Returns a new group cache from db.
@@ -652,7 +652,7 @@ int _alpm_db_load_grpcache(pmdb_t *db)
ALPM_LOG_FUNC;
if(db == NULL) {
- return(-1);
+ return -1;
}
_alpm_log(PM_LOG_DEBUG, "loading group cache for repository '%s'\n",
@@ -690,7 +690,7 @@ int _alpm_db_load_grpcache(pmdb_t *db)
}
db->grpcache_loaded = 1;
- return(0);
+ return 0;
}
void _alpm_db_free_grpcache(pmdb_t *db)
@@ -719,14 +719,14 @@ alpm_list_t *_alpm_db_get_grpcache(pmdb_t *db)
ALPM_LOG_FUNC;
if(db == NULL) {
- return(NULL);
+ return NULL;
}
if(!db->grpcache_loaded) {
_alpm_db_load_grpcache(db);
}
- return(db->grpcache);
+ return db->grpcache;
}
pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, const char *target)
@@ -736,18 +736,18 @@ pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, const char *target)
ALPM_LOG_FUNC;
if(db == NULL || target == NULL || strlen(target) == 0) {
- return(NULL);
+ return NULL;
}
for(i = _alpm_db_get_grpcache(db); i; i = i->next) {
pmgrp_t *info = i->data;
if(strcmp(info->name, target) == 0) {
- return(info);
+ return info;
}
}
- return(NULL);
+ return NULL;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index 10c982f2..d3213fd1 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -41,32 +41,32 @@
const char SYMEXPORT *alpm_delta_get_from(pmdelta_t *delta)
{
- ASSERT(delta != NULL, return(NULL));
- return(delta->from);
+ ASSERT(delta != NULL, return NULL);
+ return delta->from;
}
const char SYMEXPORT *alpm_delta_get_to(pmdelta_t *delta)
{
- ASSERT(delta != NULL, return(NULL));
- return(delta->to);
+ ASSERT(delta != NULL, return NULL);
+ return delta->to;
}
const char SYMEXPORT *alpm_delta_get_filename(pmdelta_t *delta)
{
- ASSERT(delta != NULL, return(NULL));
- return(delta->delta);
+ ASSERT(delta != NULL, return NULL);
+ return delta->delta;
}
const char SYMEXPORT *alpm_delta_get_md5sum(pmdelta_t *delta)
{
- ASSERT(delta != NULL, return(NULL));
- return(delta->delta_md5);
+ ASSERT(delta != NULL, return NULL);
+ return delta->delta_md5;
}
off_t SYMEXPORT alpm_delta_get_size(pmdelta_t *delta)
{
- ASSERT(delta != NULL, return(-1));
- return(delta->delta_size);
+ ASSERT(delta != NULL, return -1);
+ return delta->delta_size;
}
/** @} */
@@ -108,7 +108,7 @@ static alpm_list_t *graph_init(alpm_list_t *deltas, int reverse)
}
v_i->childptr = v_i->children;
}
- return(vertices);
+ return vertices;
}
static void graph_init_size(alpm_list_t *vertices)
@@ -205,7 +205,7 @@ static off_t shortest_path(alpm_list_t *vertices, const char *to, alpm_list_t **
*path = alpm_list_reverse(rpath);
alpm_list_free(rpath);
- return(bestsize);
+ return bestsize;
}
/** Calculates the shortest path from one version to another.
@@ -229,7 +229,7 @@ off_t _alpm_shortest_delta_path(alpm_list_t *deltas,
if(deltas == NULL) {
*path = NULL;
- return(bestsize);
+ return bestsize;
}
_alpm_log(PM_LOG_DEBUG, "started delta shortest-path search for '%s'\n", to);
@@ -245,7 +245,7 @@ off_t _alpm_shortest_delta_path(alpm_list_t *deltas,
alpm_list_free(vertices);
*path = bestpath;
- return(bestsize);
+ return bestsize;
}
static alpm_list_t *find_unused(alpm_list_t *deltas, const char *to, off_t quota)
@@ -273,7 +273,7 @@ static alpm_list_t *find_unused(alpm_list_t *deltas, const char *to, off_t quota
}
alpm_list_free_inner(vertices, _alpm_graph_free);
alpm_list_free(vertices);
- return(unused);
+ return unused;
}
alpm_list_t SYMEXPORT *alpm_pkg_unused_deltas(pmpkg_t *pkg)
@@ -283,7 +283,7 @@ alpm_list_t SYMEXPORT *alpm_pkg_unused_deltas(pmpkg_t *pkg)
alpm_pkg_get_deltas(pkg),
alpm_pkg_get_filename(pkg),
pkgsize * MAX_DELTA_RATIO);
- return(unused);
+ return unused;
}
@@ -308,7 +308,7 @@ pmdelta_t *_alpm_delta_parse(char *line)
if(regexec(&reg, line, 0, 0, 0) != 0) {
/* delta line is invalid, return NULL */
regfree(&reg);
- return(NULL);
+ return NULL;
}
regfree(&reg);
@@ -339,7 +339,7 @@ pmdelta_t *_alpm_delta_parse(char *line)
_alpm_log(PM_LOG_DEBUG, "delta : %s %s '%jd'\n", delta->from, delta->to, (intmax_t)delta->delta_size);
- return(delta);
+ return delta;
}
void _alpm_delta_free(pmdelta_t *delta)
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index ea579cda..7bb15d08 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -56,7 +56,7 @@ pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdepend_t *dep,
miss->depend = _alpm_dep_dup(dep);
STRDUP(miss->causingpkg, causingpkg, RET_ERR(PM_ERR_MEMORY, NULL));
- return(miss);
+ return miss;
}
void _alpm_depmiss_free(pmdepmissing_t *miss)
@@ -98,7 +98,7 @@ static alpm_list_t *dep_graph_init(alpm_list_t *targets)
}
vertex_i->childptr = vertex_i->children;
}
- return(vertices);
+ return vertices;
}
/* Re-order a list of target packages with respect to their dependencies.
@@ -125,7 +125,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse)
ALPM_LOG_FUNC;
if(targets == NULL) {
- return(NULL);
+ return NULL;
}
_alpm_log(PM_LOG_DEBUG, "started sorting dependencies\n");
@@ -189,7 +189,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse)
alpm_list_free_inner(vertices, _alpm_graph_free);
alpm_list_free(vertices);
- return(newtargs);
+ return newtargs;
}
pmpkg_t *_alpm_find_dep_satisfier(alpm_list_t *pkgs, pmdepend_t *dep)
@@ -199,10 +199,10 @@ pmpkg_t *_alpm_find_dep_satisfier(alpm_list_t *pkgs, pmdepend_t *dep)
for(i = pkgs; i; i = alpm_list_next(i)) {
pmpkg_t *pkg = i->data;
if(_alpm_depcmp_tolerant(pkg, dep)) {
- return(pkg);
+ return pkg;
}
}
- return(NULL);
+ return NULL;
}
/** Find a package satisfying a specified dependency.
@@ -216,7 +216,7 @@ pmpkg_t SYMEXPORT *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstring)
pmdepend_t *dep = _alpm_splitdep(depstring);
pmpkg_t *pkg = _alpm_find_dep_satisfier(pkgs, dep);
_alpm_dep_free(dep);
- return(pkg);
+ return pkg;
}
/** Checks dependencies and returns missing ones in a list.
@@ -300,7 +300,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
alpm_list_free(modified);
alpm_list_free(dblist);
- return(baddeps);
+ return baddeps;
}
static int dep_vercmp(const char *version1, pmdepmod_t mod,
@@ -321,7 +321,7 @@ static int dep_vercmp(const char *version1, pmdepmod_t mod,
default: equal = 1; break;
}
}
- return(equal);
+ return equal;
}
/* nodepversion: skip version checking */
@@ -345,7 +345,7 @@ static int _depcmp(pmpkg_t *pkg, pmdepend_t *dep, int nodepversion)
satisfy = (strcmp(pkg->name, dep->name) == 0
&& dep_vercmp(pkg->version, depmod, dep->version));
if(satisfy) {
- return(satisfy);
+ return satisfy;
}
}
@@ -371,7 +371,7 @@ static int _depcmp(pmpkg_t *pkg, pmdepend_t *dep, int nodepversion)
}
}
- return(satisfy);
+ return satisfy;
}
/* tolerant : respects NODEPVERSION flag */
@@ -384,13 +384,13 @@ int _alpm_depcmp_tolerant(pmpkg_t *pkg, pmdepend_t *dep)
nodepversion = flags & PM_TRANS_FLAG_NODEPVERSION;
}
- return(_depcmp(pkg, dep, nodepversion));
+ return _depcmp(pkg, dep, nodepversion);
}
/* strict : ignores NODEPVERSION flag */
int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep)
{
- return(_depcmp(pkg, dep, 0));
+ return _depcmp(pkg, dep, 0);
}
pmdepend_t *_alpm_splitdep(const char *depstring)
@@ -399,7 +399,7 @@ pmdepend_t *_alpm_splitdep(const char *depstring)
const char *ptr, *version = NULL;
if(depstring == NULL) {
- return(NULL);
+ return NULL;
}
CALLOC(depend, 1, sizeof(pmdepend_t), RET_ERR(PM_ERR_MEMORY, NULL));
@@ -435,7 +435,7 @@ pmdepend_t *_alpm_splitdep(const char *depstring)
STRDUP(depend->version, version, RET_ERR(PM_ERR_MEMORY, NULL));
}
- return(depend);
+ return depend;
}
pmdepend_t *_alpm_dep_dup(const pmdepend_t *dep)
@@ -448,7 +448,7 @@ pmdepend_t *_alpm_dep_dup(const pmdepend_t *dep)
STRDUP(newdep->version, dep->version, RET_ERR(PM_ERR_MEMORY, NULL));
newdep->mod = dep->mod;
- return(newdep);
+ return newdep;
}
/* These parameters are messy. We check if this package, given a list of
@@ -461,7 +461,7 @@ static int can_remove_package(pmdb_t *db, pmpkg_t *pkg, alpm_list_t *targets,
alpm_list_t *i;
if(_alpm_pkg_find(targets, alpm_pkg_get_name(pkg))) {
- return(0);
+ return 0;
}
if(!include_explicit) {
@@ -469,7 +469,7 @@ static int can_remove_package(pmdb_t *db, pmpkg_t *pkg, alpm_list_t *targets,
if(alpm_pkg_get_reason(pkg) == PM_PKG_REASON_EXPLICIT) {
_alpm_log(PM_LOG_DEBUG, "excluding %s -- explicitly installed\n",
alpm_pkg_get_name(pkg));
- return(0);
+ return 0;
}
}
@@ -483,12 +483,12 @@ static int can_remove_package(pmdb_t *db, pmpkg_t *pkg, alpm_list_t *targets,
for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
pmpkg_t *lpkg = i->data;
if(_alpm_dep_edge(lpkg, pkg) && !_alpm_pkg_find(targets, lpkg->name)) {
- return(0);
+ return 0;
}
}
/* it's ok to remove */
- return(1);
+ return 1;
}
/**
@@ -539,13 +539,13 @@ pmpkg_t SYMEXPORT *alpm_find_dbs_satisfier(alpm_list_t *dbs, const char *depstri
pmdepend_t *dep;
pmpkg_t *pkg;
- ASSERT(dbs, return(NULL));
+ ASSERT(dbs, return NULL);
dep = _alpm_splitdep(depstring);
- ASSERT(dep, return(NULL));
+ ASSERT(dep, return NULL);
pkg = _alpm_resolvedep(dep, dbs, NULL, 1);
_alpm_dep_free(dep);
- return(pkg);
+ return pkg;
}
/**
@@ -586,7 +586,7 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs,
continue;
}
}
- return(pkg);
+ return pkg;
}
}
/* 2. satisfiers (skip literals here) */
@@ -621,7 +621,7 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs,
pmpkg_t *pkg = i->data;
if (_alpm_pkghash_find(_alpm_db_get_pkgcache_hash(handle->db_local), pkg->name)) {
alpm_list_free(providers);
- return(pkg);
+ return pkg;
}
}
count = alpm_list_count(providers);
@@ -636,7 +636,7 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs,
if(index >= 0 && index < count) {
pmpkg_t *pkg = alpm_list_getdata(alpm_list_nth(providers, index));
alpm_list_free(providers);
- return(pkg);
+ return pkg;
}
alpm_list_free(providers);
providers = NULL;
@@ -647,7 +647,7 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs,
} else {
pm_errno = PM_ERR_PKG_NOT_FOUND;
}
- return(NULL);
+ return NULL;
}
/* Computes resolvable dependencies for a given package and adds that package
@@ -682,7 +682,7 @@ int _alpm_resolvedeps(alpm_list_t *localpkgs, alpm_list_t *dbs_sync, pmpkg_t *pk
ALPM_LOG_FUNC;
if(_alpm_pkg_find(*packages, pkg->name) != NULL) {
- return(0);
+ return 0;
}
/* Create a copy of the packages list, so that it can be restored
@@ -743,7 +743,7 @@ int _alpm_resolvedeps(alpm_list_t *localpkgs, alpm_list_t *dbs_sync, pmpkg_t *pk
alpm_list_free(packages_copy);
}
_alpm_log(PM_LOG_DEBUG, "finished resolving dependencies\n");
- return(ret);
+ return ret;
}
/* Does pkg1 depend on pkg2, ie. does pkg2 satisfy a dependency of pkg1? */
@@ -752,10 +752,10 @@ int _alpm_dep_edge(pmpkg_t *pkg1, pmpkg_t *pkg2)
alpm_list_t *i;
for(i = alpm_pkg_get_depends(pkg1); i; i = i->next) {
if(_alpm_depcmp_tolerant(pkg2, i->data)) {
- return(1);
+ return 1;
}
}
- return(0);
+ return 0;
}
const char SYMEXPORT *alpm_miss_get_target(const pmdepmissing_t *miss)
@@ -763,9 +763,9 @@ const char SYMEXPORT *alpm_miss_get_target(const pmdepmissing_t *miss)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(miss != NULL, return(NULL));
+ ASSERT(miss != NULL, return NULL);
- return(miss->target);
+ return miss->target;
}
const char SYMEXPORT *alpm_miss_get_causingpkg(const pmdepmissing_t *miss)
@@ -773,7 +773,7 @@ const char SYMEXPORT *alpm_miss_get_causingpkg(const pmdepmissing_t *miss)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(miss != NULL, return(NULL));
+ ASSERT(miss != NULL, return NULL);
return miss->causingpkg;
}
@@ -783,9 +783,9 @@ pmdepend_t SYMEXPORT *alpm_miss_get_dep(pmdepmissing_t *miss)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(miss != NULL, return(NULL));
+ ASSERT(miss != NULL, return NULL);
- return(miss->depend);
+ return miss->depend;
}
pmdepmod_t SYMEXPORT alpm_dep_get_mod(const pmdepend_t *dep)
@@ -793,9 +793,9 @@ pmdepmod_t SYMEXPORT alpm_dep_get_mod(const pmdepend_t *dep)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(dep != NULL, return(-1));
+ ASSERT(dep != NULL, return -1);
- return(dep->mod);
+ return dep->mod;
}
const char SYMEXPORT *alpm_dep_get_name(const pmdepend_t *dep)
@@ -803,9 +803,9 @@ const char SYMEXPORT *alpm_dep_get_name(const pmdepend_t *dep)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(dep != NULL, return(NULL));
+ ASSERT(dep != NULL, return NULL);
- return(dep->name);
+ return dep->name;
}
const char SYMEXPORT *alpm_dep_get_version(const pmdepend_t *dep)
@@ -813,9 +813,9 @@ const char SYMEXPORT *alpm_dep_get_version(const pmdepend_t *dep)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(dep != NULL, return(NULL));
+ ASSERT(dep != NULL, return NULL);
- return(dep->version);
+ return dep->version;
}
/** Reverse of splitdep; make a dep string from a pmdepend_t struct.
@@ -831,7 +831,7 @@ char SYMEXPORT *alpm_dep_compute_string(const pmdepend_t *dep)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(dep != NULL, return(NULL));
+ ASSERT(dep != NULL, return NULL);
if(dep->name) {
name = dep->name;
@@ -876,6 +876,6 @@ char SYMEXPORT *alpm_dep_compute_string(const pmdepend_t *dep)
MALLOC(str, len, RET_ERR(PM_ERR_MEMORY, NULL));
snprintf(str, len, "%s%s%s", name, opr, ver);
- return(str);
+ return str;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index 281173a2..983a3ac2 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -56,7 +56,7 @@ static int mount_point_cmp(const void *p1, const void *p2)
const alpm_mountpoint_t *mp1 = p1;
const alpm_mountpoint_t *mp2 = p2;
/* the negation will sort all mountpoints before their parent */
- return(-strcmp(mp1->mount_dir, mp2->mount_dir));
+ return -strcmp(mp1->mount_dir, mp2->mount_dir);
}
static alpm_list_t *mount_point_list(void)
@@ -72,7 +72,7 @@ static alpm_list_t *mount_point_list(void)
fp = setmntent(MOUNTED, "r");
if (fp == NULL) {
- return(NULL);
+ return NULL;
}
while((mnt = getmntent(fp))) {
@@ -104,7 +104,7 @@ static alpm_list_t *mount_point_list(void)
entries = getmntinfo(&fsp, MNT_NOWAIT);
if (entries < 0) {
- return(NULL);
+ return NULL;
}
for(; entries-- > 0; fsp++) {
@@ -128,7 +128,7 @@ static alpm_list_t *mount_point_list(void)
mp = ptr->data;
_alpm_log(PM_LOG_DEBUG, "mountpoint: %s\n", mp->mount_dir);
}
- return(mount_points);
+ return mount_points;
}
static alpm_mountpoint_t *match_mount_point(const alpm_list_t *mount_points,
@@ -140,12 +140,12 @@ static alpm_mountpoint_t *match_mount_point(const alpm_list_t *mount_points,
alpm_mountpoint_t *data = mp->data;
if(strncmp(data->mount_dir, real_path, data->mount_dir_len) == 0) {
- return(data);
+ return data;
}
}
/* should not get here... */
- return(NULL);
+ return NULL;
}
static int calculate_removed_size(const alpm_list_t *mount_points,
@@ -182,7 +182,7 @@ static int calculate_removed_size(const alpm_list_t *mount_points,
mp->used |= USED_REMOVE;
}
- return(0);
+ return 0;
}
static int calculate_installed_size(const alpm_list_t *mount_points,
@@ -254,7 +254,7 @@ static int calculate_installed_size(const alpm_list_t *mount_points,
archive_read_finish(archive);
cleanup:
- return(ret);
+ return ret;
}
int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local)
@@ -269,13 +269,13 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local)
mount_points = mount_point_list();
if(mount_points == NULL) {
_alpm_log(PM_LOG_ERROR, _("could not determine filesystem mount points\n"));
- return(-1);
+ return -1;
}
root_mp = match_mount_point(mount_points, handle->root);
if(root_mp == NULL) {
_alpm_log(PM_LOG_ERROR, _("could not determine root mount point %s\n"),
handle->root);
- return(-1);
+ return -1;
}
replaces = alpm_list_count(trans->remove);
@@ -352,7 +352,7 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local)
RET_ERR(PM_ERR_DISK_SPACE, -1);
}
- return(0);
+ return 0;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 7a98eb12..4347e5db 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -29,14 +29,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
-/* the following two are needed for FreeBSD's libfetch */
-#include <limits.h> /* PATH_MAX */
-#if defined(HAVE_SYS_PARAM_H)
-#include <sys/param.h> /* MAXHOSTNAMELEN */
-#endif
-#ifdef HAVE_LIBFETCH
-#include <fetch.h>
+#ifdef HAVE_LIBCURL
+#include <curl/curl.h>
#endif
/* libalpm */
@@ -47,43 +42,41 @@
#include "util.h"
#include "handle.h"
+static int prevprogress; /* last download amount */
+
static char *get_filename(const char *url) {
char *filename = strrchr(url, '/');
if(filename != NULL) {
filename++;
}
- return(filename);
+ return filename;
}
-#ifdef HAVE_LIBFETCH
-static char *get_destfile(const char *path, const char *filename) {
+#ifdef HAVE_LIBCURL
+static char *get_destfile(const char *path, const char *filename)
+{
char *destfile;
/* len = localpath len + filename len + null */
size_t len = strlen(path) + strlen(filename) + 1;
CALLOC(destfile, len, sizeof(char), RET_ERR(PM_ERR_MEMORY, NULL));
snprintf(destfile, len, "%s%s", path, filename);
- return(destfile);
+ return destfile;
}
-static char *get_tempfile(const char *path, const char *filename) {
+static char *get_tempfile(const char *path, const char *filename)
+{
char *tempfile;
/* len = localpath len + filename len + '.part' len + null */
size_t len = strlen(path) + strlen(filename) + 6;
CALLOC(tempfile, len, sizeof(char), RET_ERR(PM_ERR_MEMORY, NULL));
snprintf(tempfile, len, "%s%s.part", path, filename);
- return(tempfile);
+ return tempfile;
}
-static const char *gethost(struct url *fileurl)
-{
- const char *host = _("disk");
- if(strcmp(SCHEME_FILE, fileurl->scheme) != 0) {
- host = fileurl->host;
- }
- return(host);
-}
+#define check_stop() if(dload_interrupted) { ret = -1; goto cleanup; }
+enum sighandlers { OLD = 0, NEW = 1 };
int dload_interrupted;
static void inthandler(int signum)
@@ -91,59 +84,114 @@ static void inthandler(int signum)
dload_interrupted = 1;
}
-#define check_stop() if(dload_interrupted) { ret = -1; goto cleanup; }
-enum sighandlers { OLD = 0, NEW = 1 };
+static int curl_progress(void *filename, double dltotal, double dlnow,
+ double ultotal, double ulnow)
+{
-static int download_internal(const char *url, const char *localpath,
- int force) {
- FILE *localf = NULL;
- struct stat st;
- int ret = 0;
- off_t dl_thisfile = 0;
- ssize_t nread = 0;
- char *tempfile, *destfile, *filename;
- struct sigaction sig_pipe[2], sig_int[2];
+ /* unused parameters */
+ (void)ultotal;
+ (void)ulnow;
- off_t local_size = 0;
- time_t local_time = 0;
+ if(dltotal == 0 || prevprogress == dltotal) {
+ return 0;
+ }
- struct url *fileurl;
- struct url_stat ust;
- fetchIO *dlf = NULL;
+ if(dload_interrupted) {
+ return 1;
+ }
- char buffer[PM_DLBUF_LEN];
+ if(handle->dlcb) {
+ handle->dlcb((const char*)filename, (long)dlnow, (long)dltotal);
+ }
- filename = get_filename(url);
- if(!filename) {
- _alpm_log(PM_LOG_ERROR, _("url '%s' is invalid\n"), url);
- RET_ERR(PM_ERR_SERVER_BAD_URL, -1);
+ prevprogress = dlnow;
+
+ return 0;
+}
+
+static int curl_gethost(const char *url, char *buffer)
+{
+ int hostlen;
+ char *p;
+
+ if(strncmp(url, "file://", 7) == 0) {
+ strcpy(buffer, _("disk"));
+ } else {
+ p = strstr(url, "//");
+ if(!p) {
+ return 1;
+ }
+ p += 2; /* jump over the found // */
+ hostlen = strcspn(p, "/");
+ if(hostlen > 255) {
+ /* buffer overflow imminent */
+ _alpm_log(PM_LOG_ERROR, _("buffer overflow detected"));
+ return 1;
+ }
+ snprintf(buffer, hostlen + 1, "%s", p);
}
- fileurl = fetchParseURL(url);
- if(!fileurl) {
+ return 0;
+}
+
+static int curl_download_internal(const char *url, const char *localpath,
+ int force)
+{
+ int ret = -1;
+ FILE *localf = NULL;
+ char *destfile, *filename, *tempfile;
+ char hostname[256]; /* RFC1123 states applications should support this length */
+ struct stat st;
+ long httpresp, timecond, remote_time, local_time;
+ double remote_size, bytes_dl;
+ struct sigaction sig_pipe[2], sig_int[2];
+
+ filename = get_filename(url);
+ if(!filename || curl_gethost(url, hostname) != 0) {
_alpm_log(PM_LOG_ERROR, _("url '%s' is invalid\n"), url);
- RET_ERR(PM_ERR_LIBFETCH, -1);
+ RET_ERR(PM_ERR_SERVER_BAD_URL, -1);
}
destfile = get_destfile(localpath, filename);
- tempfile = get_tempfile(localpath, filename);
-
- if(stat(tempfile, &st) == 0 && S_ISREG(st.st_mode) && st.st_size > 0) {
- _alpm_log(PM_LOG_DEBUG, "tempfile found, attempting continuation\n");
- local_time = fileurl->last_modified = st.st_mtime;
- local_size = fileurl->offset = (off_t)st.st_size;
- dl_thisfile = st.st_size;
+ tempfile = get_tempfile(localpath, filename);
+
+ /* the curl_easy handle is initialized with the alpm handle, so we only need
+ * to reset the curl handle set parameters for each time it's used. */
+ curl_easy_reset(handle->curl);
+ curl_easy_setopt(handle->curl, CURLOPT_URL, url);
+ curl_easy_setopt(handle->curl, CURLOPT_FAILONERROR, 1L);
+ curl_easy_setopt(handle->curl, CURLOPT_ENCODING, "deflate, gzip");
+ curl_easy_setopt(handle->curl, CURLOPT_CONNECTTIMEOUT, 10L);
+ curl_easy_setopt(handle->curl, CURLOPT_FILETIME, 1L);
+ curl_easy_setopt(handle->curl, CURLOPT_NOPROGRESS, 0L);
+ curl_easy_setopt(handle->curl, CURLOPT_FOLLOWLOCATION, 1L);
+ curl_easy_setopt(handle->curl, CURLOPT_PROGRESSFUNCTION, curl_progress);
+ curl_easy_setopt(handle->curl, CURLOPT_PROGRESSDATA, filename);
+
+ if(!force && stat(destfile, &st) == 0) {
+ /* assume its a sync, so we're starting from scratch. but, only download
+ * our local is out of date. */
+ local_time = (long)st.st_mtime;
+ curl_easy_setopt(handle->curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
+ curl_easy_setopt(handle->curl, CURLOPT_TIMEVALUE, local_time);
+ } else if(stat(tempfile, &st) == 0 && st.st_size > 0) {
+ /* assume its a partial package download. we do not support resuming of
+ * transfers on partially downloaded sync DBs. */
localf = fopen(tempfile, "ab");
- } else if(!force && stat(destfile, &st) == 0 && S_ISREG(st.st_mode) && st.st_size > 0) {
- _alpm_log(PM_LOG_DEBUG, "destfile found, using mtime only\n");
- local_time = fileurl->last_modified = st.st_mtime;
- local_size = /* no fu->off here */ (off_t)st.st_size;
- } else {
- _alpm_log(PM_LOG_DEBUG, "no file found matching criteria, starting from scratch\n");
+ curl_easy_setopt(handle->curl, CURLOPT_RESUME_FROM, (long)st.st_size);
+ _alpm_log(PM_LOG_DEBUG, "tempfile found, attempting continuation");
}
- /* pass the raw filename for passing to the callback function */
- _alpm_log(PM_LOG_DEBUG, "using '%s' for download progress\n", filename);
+ /* no destfile and no tempfile. start from scratch */
+ if(localf == NULL) {
+ localf = fopen(tempfile, "wb");
+ if(localf == NULL) {
+ goto cleanup;
+ }
+ }
+
+ /* this has to be set _after_ figuring out which file we're opening */
+ curl_easy_setopt(handle->curl, CURLOPT_WRITEDATA, localf);
/* print proxy info for debug purposes */
_alpm_log(PM_LOG_DEBUG, "HTTP_PROXY: %s\n", getenv("HTTP_PROXY"));
@@ -151,9 +199,6 @@ static int download_internal(const char *url, const char *localpath,
_alpm_log(PM_LOG_DEBUG, "FTP_PROXY: %s\n", getenv("FTP_PROXY"));
_alpm_log(PM_LOG_DEBUG, "ftp_proxy: %s\n", getenv("ftp_proxy"));
- /* 10s timeout */
- fetchTimeout = 10;
-
/* ignore any SIGPIPE signals- these may occur if our FTP socket dies or
* something along those lines. Store the old signal handler first. */
sig_pipe[NEW].sa_handler = SIG_IGN;
@@ -169,146 +214,59 @@ static int download_internal(const char *url, const char *localpath,
sigaction(SIGINT, NULL, &sig_int[OLD]);
sigaction(SIGINT, &sig_int[NEW], NULL);
- /* NOTE: libfetch does not reset the error code, be sure to do it before
- * calls into the library */
-
- /* TODO: if we call fetchStat() and get a redirect (disabling automagic
- * redirect following), we should repeat the file locator stuff and get a new
- * filename rather than only base if off the first URL, and then verify
- * get_filename() didn't return ''. Of course, libfetch might not even allow
- * us to even get that URL...FS#22645. This would allow us to download things
- * without totally puking like
- * http://www.archlinux.org/packages/community/x86_64/exim/download/ */
-
- /* find out the remote size *and* mtime in one go. there is a lot of
- * trouble in trying to do both size and "if-modified-since" logic in a
- * non-stat request, so avoid it. */
- fetchLastErrCode = 0;
- if(fetchStat(fileurl, &ust, "") == -1) {
- pm_errno = PM_ERR_LIBFETCH;
- _alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
- filename, gethost(fileurl), fetchLastErrString);
- ret = -1;
- goto cleanup;
- }
- check_stop();
-
- _alpm_log(PM_LOG_DEBUG, "ust.mtime: %ld local_time: %ld compare: %ld\n",
- ust.mtime, local_time, local_time - ust.mtime);
- _alpm_log(PM_LOG_DEBUG, "ust.size: %jd local_size: %jd compare: %jd\n",
- (intmax_t)ust.size, (intmax_t)local_size, (intmax_t)(local_size - ust.size));
- if(!force && ust.mtime && ust.mtime == local_time
- && ust.size && ust.size == local_size) {
- /* the remote time and size values agreed with what we have, so move on
- * because there is nothing more to do. */
- _alpm_log(PM_LOG_DEBUG, "files are identical, skipping %s\n", filename);
- ret = 1;
- goto cleanup;
- }
- if(!ust.mtime || ust.mtime != local_time) {
- _alpm_log(PM_LOG_DEBUG, "mtimes were different or unavailable, downloading %s from beginning\n", filename);
- fileurl->offset = 0;
- }
-
- fetchLastErrCode = 0;
- dlf = fetchGet(fileurl, "");
- check_stop();
-
- if(fetchLastErrCode != 0 || dlf == NULL) {
- pm_errno = PM_ERR_LIBFETCH;
- _alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
- filename, gethost(fileurl), fetchLastErrString);
- ret = -1;
- goto cleanup;
- } else {
- _alpm_log(PM_LOG_DEBUG, "connected to %s successfully\n", fileurl->host);
- }
-
- if(localf && fileurl->offset == 0) {
- _alpm_log(PM_LOG_WARNING, _("resuming download of %s not possible; starting over\n"), filename);
- fclose(localf);
- localf = NULL;
- } else if(fileurl->offset) {
- _alpm_log(PM_LOG_DEBUG, "resuming download at position %jd\n", (intmax_t)fileurl->offset);
- }
-
+ /* set initial value of prevprogress to -1 which causes curl_progress() to
+ * initialize the progress bar with 0% once. */
+ prevprogress = -1;
- if(localf == NULL) {
- _alpm_rmrf(tempfile);
- fileurl->offset = (off_t)0;
- dl_thisfile = 0;
- localf = fopen(tempfile, "wb");
- if(localf == NULL) { /* still null? */
- pm_errno = PM_ERR_RETRIEVE;
- _alpm_log(PM_LOG_ERROR, _("error writing to file '%s': %s\n"),
- tempfile, strerror(errno));
- ret = -1;
- goto cleanup;
- }
- }
+ /* perform transfer */
+ handle->curlerr = curl_easy_perform(handle->curl);
- /* Progress 0 - initialize */
- if(handle->dlcb) {
- handle->dlcb(filename, 0, ust.size);
- }
-
- while((nread = fetchIO_read(dlf, buffer, PM_DLBUF_LEN)) > 0) {
- check_stop();
- size_t nwritten = 0;
- nwritten = fwrite(buffer, 1, (size_t)nread, localf);
- if((nwritten != (size_t)nread) || ferror(localf)) {
- pm_errno = PM_ERR_RETRIEVE;
- _alpm_log(PM_LOG_ERROR, _("error writing to file '%s': %s\n"),
- tempfile, strerror(errno));
- ret = -1;
- goto cleanup;
- }
- dl_thisfile += nread;
+ /* retrieve info about the state of the transfer */
+ curl_easy_getinfo(handle->curl, CURLINFO_HTTP_CODE, &httpresp);
+ curl_easy_getinfo(handle->curl, CURLINFO_FILETIME, &remote_time);
+ curl_easy_getinfo(handle->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &remote_size);
+ curl_easy_getinfo(handle->curl, CURLINFO_SIZE_DOWNLOAD, &bytes_dl);
+ curl_easy_getinfo(handle->curl, CURLINFO_CONDITION_UNMET, &timecond);
- if(handle->dlcb) {
- handle->dlcb(filename, dl_thisfile, ust.size);
- }
+ /* time condition was met and we didn't download anything. we need to
+ * clean up the 0 byte .part file that's left behind. */
+ if(bytes_dl == 0 && timecond == 1) {
+ ret = 1;
+ unlink(tempfile);
+ goto cleanup;
}
- /* did the transfer complete normally? */
- if (nread == -1) {
- /* not PM_ERR_LIBFETCH here because libfetch error string might be empty */
- pm_errno = PM_ERR_RETRIEVE;
- _alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s\n"),
- filename, gethost(fileurl));
- ret = -1;
+ if(handle->curlerr == CURLE_ABORTED_BY_CALLBACK) {
+ goto cleanup;
+ } else if(handle->curlerr != CURLE_OK) {
+ pm_errno = PM_ERR_LIBCURL;
+ _alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
+ filename, hostname, curl_easy_strerror(handle->curlerr));
+ unlink(tempfile);
goto cleanup;
}
- if (ust.size != -1 && dl_thisfile < ust.size) {
+ /* remote_size isn't necessarily the full size of the file, just what the
+ * server reported as remaining to download. compare it to what curl reported
+ * as actually being transferred during curl_easy_perform() */
+ if((remote_size != -1 && bytes_dl != -1) && bytes_dl != remote_size) {
pm_errno = PM_ERR_RETRIEVE;
_alpm_log(PM_LOG_ERROR, _("%s appears to be truncated: %jd/%jd bytes\n"),
- filename, (intmax_t)dl_thisfile, (intmax_t)ust.size);
- ret = -1;
+ filename, (intmax_t)bytes_dl, (intmax_t)remote_size);
goto cleanup;
}
- /* probably safer to close the file descriptors now before renaming the file,
- * for example to make sure the buffers are flushed.
- */
fclose(localf);
localf = NULL;
- fetchIO_close(dlf);
- dlf = NULL;
/* set the times on the file to the same as that of the remote file */
- if(ust.mtime) {
+ if(remote_time != -1) {
struct timeval tv[2];
memset(&tv, 0, sizeof(tv));
- tv[0].tv_sec = ust.atime;
- tv[1].tv_sec = ust.mtime;
+ tv[0].tv_sec = tv[1].tv_sec = remote_time;
utimes(tempfile, tv);
}
- if(rename(tempfile, destfile)) {
- _alpm_log(PM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
- tempfile, destfile, strerror(errno));
- ret = -1;
- }
+ rename(tempfile, destfile);
ret = 0;
cleanup:
@@ -318,19 +276,14 @@ cleanup:
/* if we still had a local file open, we got interrupted. set the mtimes on
* the file accordingly. */
fflush(localf);
- if(ust.mtime) {
+ if(remote_time != -1) {
struct timeval tv[2];
memset(&tv, 0, sizeof(tv));
- tv[0].tv_sec = ust.atime;
- tv[1].tv_sec = ust.mtime;
+ tv[0].tv_sec = tv[1].tv_sec = remote_time;
futimes(fileno(localf), tv);
}
fclose(localf);
}
- if(dlf != NULL) {
- fetchIO_close(dlf);
- }
- fetchFreeURL(fileurl);
/* restore the old signal handlers */
sigaction(SIGINT, &sig_int[OLD], NULL);
@@ -340,15 +293,16 @@ cleanup:
raise(SIGINT);
}
- return(ret);
+ return ret;
}
#endif
static int download(const char *url, const char *localpath,
- int force) {
+ int force)
+{
if(handle->fetchcb == NULL) {
-#ifdef HAVE_LIBFETCH
- return(download_internal(url, localpath, force));
+#ifdef HAVE_LIBCURL
+ return curl_download_internal(url, localpath, force);
#else
RET_ERR(PM_ERR_EXTERNAL_DOWNLOAD, -1);
#endif
@@ -357,7 +311,7 @@ static int download(const char *url, const char *localpath,
if(ret == -1) {
RET_ERR(PM_ERR_EXTERNAL_DOWNLOAD, -1);
}
- return(ret);
+ return ret;
}
}
@@ -395,7 +349,7 @@ int _alpm_download_single_file(const char *filename,
}
}
- return(ret);
+ return ret;
}
int _alpm_download_files(alpm_list_t *files,
@@ -412,7 +366,7 @@ int _alpm_download_files(alpm_list_t *files,
}
}
- return(ret);
+ return ret;
}
/** Fetch a remote pkg.
@@ -437,13 +391,13 @@ char SYMEXPORT *alpm_fetch_pkgurl(const char *url)
ret = download(url, cachedir, 0);
if(ret == -1) {
_alpm_log(PM_LOG_WARNING, _("failed to download %s\n"), url);
- return(NULL);
+ return NULL;
}
_alpm_log(PM_LOG_DEBUG, "successfully downloaded %s\n", url);
/* we should be able to find the file the second time around */
filepath = _alpm_filecache_find(filename);
- return(filepath);
+ return filepath;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h
index 63266491..e8d99b23 100644
--- a/lib/libalpm/dload.h
+++ b/lib/libalpm/dload.h
@@ -25,8 +25,6 @@
#include <time.h>
-#define PM_DLBUF_LEN (1024 * 16)
-
int _alpm_download_single_file(const char *filename,
alpm_list_t *servers, const char *localpath,
int force);
diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c
index 21fbb48f..dcf26074 100644
--- a/lib/libalpm/error.c
+++ b/lib/libalpm/error.c
@@ -20,21 +20,14 @@
#include "config.h"
-/* TODO: needed for the libfetch stuff, unfortunately- we should kill it */
-#include <stdio.h>
-/* the following two are needed for FreeBSD's libfetch */
-#include <limits.h> /* PATH_MAX */
-#if defined(HAVE_SYS_PARAM_H)
-#include <sys/param.h> /* MAXHOSTNAMELEN */
-#endif
-
-#ifdef HAVE_LIBFETCH
-#include <fetch.h> /* fetchLastErrString */
+#ifdef HAVE_LIBCURL
+#include <curl/curl.h>
#endif
/* libalpm */
#include "util.h"
#include "alpm.h"
+#include "handle.h"
const char SYMEXPORT *alpm_strerrorlast(void)
{
@@ -147,9 +140,9 @@ const char SYMEXPORT *alpm_strerror(int err)
* requires the archive struct, so we can't. Just use a generic
* error string instead. */
return _("libarchive error");
- case PM_ERR_LIBFETCH:
-#ifdef HAVE_LIBFETCH
- return fetchLastErrString;
+ case PM_ERR_LIBCURL:
+#ifdef HAVE_LIBCURL
+ return curl_easy_strerror(handle->curlerr);
#else
/* obviously shouldn't get here... */
return _("download library error");
diff --git a/lib/libalpm/graph.h b/lib/libalpm/graph.h
index 07986f66..ce195145 100644
--- a/lib/libalpm/graph.h
+++ b/lib/libalpm/graph.h
@@ -38,7 +38,7 @@ static pmgraph_t *_alpm_graph_new(void)
pmgraph_t *graph = NULL;
CALLOC(graph, 1, sizeof(pmgraph_t), RET_ERR(PM_ERR_MEMORY, NULL));
- return(graph);
+ return graph;
}
static void _alpm_graph_free(void *data)
diff --git a/lib/libalpm/group.c b/lib/libalpm/group.c
index 398c2588..b13908c1 100644
--- a/lib/libalpm/group.c
+++ b/lib/libalpm/group.c
@@ -40,7 +40,7 @@ pmgrp_t *_alpm_grp_new(const char *name)
CALLOC(grp, 1, sizeof(pmgrp_t), RET_ERR(PM_ERR_MEMORY, NULL));
STRDUP(grp->name, name, RET_ERR(PM_ERR_MEMORY, NULL));
- return(grp);
+ return grp;
}
void _alpm_grp_free(pmgrp_t *grp)
@@ -62,7 +62,7 @@ const char SYMEXPORT *alpm_grp_get_name(const pmgrp_t *grp)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(grp != NULL, return(NULL));
+ ASSERT(grp != NULL, return NULL);
return grp->name;
}
@@ -72,7 +72,7 @@ alpm_list_t SYMEXPORT *alpm_grp_get_pkgs(const pmgrp_t *grp)
ALPM_LOG_FUNC;
/* Sanity checks */
- ASSERT(grp != NULL, return(NULL));
+ ASSERT(grp != NULL, return NULL);
return grp->packages;
}
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index d4ebe82a..442e99df 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -50,7 +50,7 @@ pmhandle_t *_alpm_handle_new()
CALLOC(handle, 1, sizeof(pmhandle_t), RET_ERR(PM_ERR_MEMORY, NULL));
- return(handle);
+ return handle;
}
void _alpm_handle_free(pmhandle_t *handle)
@@ -71,6 +71,11 @@ void _alpm_handle_free(pmhandle_t *handle)
closelog();
}
+#ifdef HAVE_LIBCURL
+ /* release curl handle */
+ curl_easy_cleanup(handle->curl);
+#endif
+
/* free memory */
_alpm_trans_free(handle->trans);
FREE(handle->root);
@@ -85,6 +90,7 @@ void _alpm_handle_free(pmhandle_t *handle)
FREELIST(handle->ignorepkg);
FREELIST(handle->ignoregrp);
FREE(handle);
+
}
alpm_cb_log SYMEXPORT alpm_option_get_logcb()
@@ -304,18 +310,18 @@ int SYMEXPORT alpm_option_set_root(const char *root)
if(!root) {
pm_errno = PM_ERR_WRONG_ARGS;
- return(-1);
+ return -1;
}
if(stat(root, &st) == -1 || !S_ISDIR(st.st_mode)) {
pm_errno = PM_ERR_NOT_A_DIR;
- return(-1);
+ return -1;
}
realroot = calloc(PATH_MAX+1, sizeof(char));
if(!realpath(root, realroot)) {
FREE(realroot);
pm_errno = PM_ERR_NOT_A_DIR;
- return(-1);
+ return -1;
}
/* verify root ends in a '/' */
@@ -331,7 +337,7 @@ int SYMEXPORT alpm_option_set_root(const char *root)
handle->root[rootlen-1] = '/';
FREE(realroot);
_alpm_log(PM_LOG_DEBUG, "option 'root' = %s\n", handle->root);
- return(0);
+ return 0;
}
int SYMEXPORT alpm_option_set_dbpath(const char *dbpath)
@@ -344,11 +350,11 @@ int SYMEXPORT alpm_option_set_dbpath(const char *dbpath)
if(!dbpath) {
pm_errno = PM_ERR_WRONG_ARGS;
- return(-1);
+ return -1;
}
if(stat(dbpath, &st) == -1 || !S_ISDIR(st.st_mode)) {
pm_errno = PM_ERR_NOT_A_DIR;
- return(-1);
+ return -1;
}
/* verify dbpath ends in a '/' */
dbpathlen = strlen(dbpath);
@@ -370,7 +376,7 @@ int SYMEXPORT alpm_option_set_dbpath(const char *dbpath)
handle->lockfile = calloc(lockfilelen, sizeof(char));
snprintf(handle->lockfile, lockfilelen, "%s%s", handle->dbpath, lf);
_alpm_log(PM_LOG_DEBUG, "option 'lockfile' = %s\n", handle->lockfile);
- return(0);
+ return 0;
}
int SYMEXPORT alpm_option_add_cachedir(const char *cachedir)
@@ -382,7 +388,7 @@ int SYMEXPORT alpm_option_add_cachedir(const char *cachedir)
if(!cachedir) {
pm_errno = PM_ERR_WRONG_ARGS;
- return(-1);
+ return -1;
}
/* don't stat the cachedir yet, as it may not even be needed. we can
* fail later if it is needed and the path is invalid. */
@@ -397,7 +403,7 @@ int SYMEXPORT alpm_option_add_cachedir(const char *cachedir)
newcachedir[cachedirlen-1] = '/';
handle->cachedirs = alpm_list_add(handle->cachedirs, newcachedir);
_alpm_log(PM_LOG_DEBUG, "option 'cachedir' = %s\n", newcachedir);
- return(0);
+ return 0;
}
void SYMEXPORT alpm_option_set_cachedirs(alpm_list_t *cachedirs)
@@ -423,9 +429,9 @@ int SYMEXPORT alpm_option_remove_cachedir(const char *cachedir)
FREE(newcachedir);
if(vdata != NULL) {
FREE(vdata);
- return(1);
+ return 1;
}
- return(0);
+ return 0;
}
int SYMEXPORT alpm_option_set_logfile(const char *logfile)
@@ -436,7 +442,7 @@ int SYMEXPORT alpm_option_set_logfile(const char *logfile)
if(!logfile) {
pm_errno = PM_ERR_WRONG_ARGS;
- return(-1);
+ return -1;
}
handle->logfile = strdup(logfile);
@@ -451,7 +457,7 @@ int SYMEXPORT alpm_option_set_logfile(const char *logfile)
handle->logstream = NULL;
}
_alpm_log(PM_LOG_DEBUG, "option 'logfile' = %s\n", handle->logfile);
- return(0);
+ return 0;
}
void SYMEXPORT alpm_option_set_usesyslog(int usesyslog)
@@ -476,9 +482,9 @@ int SYMEXPORT alpm_option_remove_noupgrade(const char *pkg)
handle->noupgrade = alpm_list_remove_str(handle->noupgrade, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
- return(1);
+ return 1;
}
- return(0);
+ return 0;
}
void SYMEXPORT alpm_option_add_noextract(const char *pkg)
@@ -498,9 +504,9 @@ int SYMEXPORT alpm_option_remove_noextract(const char *pkg)
handle->noextract = alpm_list_remove_str(handle->noextract, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
- return(1);
+ return 1;
}
- return(0);
+ return 0;
}
void SYMEXPORT alpm_option_add_ignorepkg(const char *pkg)
@@ -520,9 +526,9 @@ int SYMEXPORT alpm_option_remove_ignorepkg(const char *pkg)
handle->ignorepkg = alpm_list_remove_str(handle->ignorepkg, pkg, &vdata);
if(vdata != NULL) {
FREE(vdata);
- return(1);
+ return 1;
}
- return(0);
+ return 0;
}
void SYMEXPORT alpm_option_add_ignoregrp(const char *grp)
@@ -542,9 +548,9 @@ int SYMEXPORT alpm_option_remove_ignoregrp(const char *grp)
handle->ignoregrp = alpm_list_remove_str(handle->ignoregrp, grp, &vdata);
if(vdata != NULL) {
FREE(vdata);
- return(1);
+ return 1;
}
- return(0);
+ return 0;
}
void SYMEXPORT alpm_option_set_arch(const char *arch)
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index 2d962fe6..de2dfa1a 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -29,6 +29,10 @@
#include "alpm.h"
#include "trans.h"
+#ifdef HAVE_LIBCURL
+#include <curl/curl.h>
+#endif
+
typedef struct _pmhandle_t {
/* internal usage */
pmdb_t *db_local; /* local db pointer */
@@ -37,6 +41,12 @@ typedef struct _pmhandle_t {
FILE *lckstream; /* lock file stream pointer if one exists */
pmtrans_t *trans;
+#ifdef HAVE_LIBCURL
+ /* libcurl handle */
+ CURL *curl; /* reusable curl_easy handle */
+ CURLcode curlerr; /* last error produced by curl */
+#endif
+
/* callback functions */
alpm_cb_log logcb; /* Log callback function */
alpm_cb_download dlcb; /* Download callback function */
diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c
index 09c6fb84..0d936e22 100644
--- a/lib/libalpm/log.c
+++ b/lib/libalpm/log.c
@@ -64,7 +64,7 @@ int SYMEXPORT alpm_logaction(const char *fmt, ...)
} else {
pm_errno = PM_ERR_SYSTEM;
}
- return(-1);
+ return -1;
}
}
@@ -83,7 +83,7 @@ int SYMEXPORT alpm_logaction(const char *fmt, ...)
* kpacman: "KPACMAN"
* This would allow us to share the log file between several frontends
* and know who does what */
- return(ret);
+ return ret;
}
/** @} */
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 18d77d65..445653ec 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -61,7 +61,7 @@ int SYMEXPORT alpm_pkg_free(pmpkg_t *pkg)
_alpm_pkg_free(pkg);
}
- return(0);
+ return 0;
}
/** Check the integrity (with md5) of a package from the sync cache.
@@ -84,13 +84,13 @@ int SYMEXPORT alpm_pkg_checkmd5sum(pmpkg_t *pkg)
retval = _alpm_test_md5sum(fpath, alpm_pkg_get_md5sum(pkg));
if(retval == 0) {
- return(0);
+ return 0;
} else if (retval == 1) {
pm_errno = PM_ERR_PKG_INVALID;
retval = -1;
}
- return(retval);
+ return retval;
}
/* Default package accessor functions. These will get overridden by any
@@ -274,10 +274,10 @@ alpm_list_t SYMEXPORT *alpm_pkg_get_backup(pmpkg_t *pkg)
pmdb_t SYMEXPORT *alpm_pkg_get_db(pmpkg_t *pkg)
{
/* Sanity checks */
- ASSERT(pkg != NULL, return(NULL));
- ASSERT(pkg->origin != PKG_FROM_FILE, return(NULL));
+ ASSERT(pkg != NULL, return NULL);
+ ASSERT(pkg->origin != PKG_FROM_FILE, return NULL);
- return(pkg->origin_data.db);
+ return pkg->origin_data.db;
}
/**
@@ -381,7 +381,7 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
}
}
}
- return(reqs);
+ return reqs;
}
/** @} */
@@ -394,7 +394,7 @@ pmpkg_t *_alpm_pkg_new(void)
CALLOC(pkg, 1, sizeof(pmpkg_t), RET_ERR(PM_ERR_MEMORY, NULL));
- return(pkg);
+ return pkg;
}
pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg)
@@ -445,7 +445,7 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg)
}
newpkg->infolevel = pkg->infolevel;
- return(newpkg);
+ return newpkg;
}
void _alpm_pkg_free(pmpkg_t *pkg)
@@ -522,7 +522,7 @@ int _alpm_pkg_cmp(const void *p1, const void *p2)
{
pmpkg_t *pkg1 = (pmpkg_t *)p1;
pmpkg_t *pkg2 = (pmpkg_t *)p2;
- return(strcoll(pkg1->name, pkg2->name));
+ return strcoll(pkg1->name, pkg2->name);
}
/* Test for existence of a package in a alpm_list_t*
@@ -536,7 +536,7 @@ pmpkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle)
ALPM_LOG_FUNC;
if(needle == NULL || haystack == NULL) {
- return(NULL);
+ return NULL;
}
needle_hash = _alpm_hash_sdbm(needle);
@@ -552,11 +552,11 @@ pmpkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle)
/* finally: we had hash match, verify string match */
if(strcmp(info->name, needle) == 0) {
- return(info);
+ return info;
}
}
}
- return(NULL);
+ return NULL;
}
/** Test if a package should be ignored.
@@ -574,18 +574,18 @@ int _alpm_pkg_should_ignore(pmpkg_t *pkg)
/* first see if the package is ignored */
if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(pkg))) {
- return(1);
+ return 1;
}
/* next see if the package is in a group that is ignored */
for(groups = handle->ignoregrp; groups; groups = alpm_list_next(groups)) {
char *grp = (char *)alpm_list_getdata(groups);
if(alpm_list_find_str(alpm_pkg_get_groups(pkg), grp)) {
- return(1);
+ return 1;
}
}
- return(0);
+ return 0;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/pkghash.c b/lib/libalpm/pkghash.c
index db98f94b..761ca72d 100644
--- a/lib/libalpm/pkghash.c
+++ b/lib/libalpm/pkghash.c
@@ -72,13 +72,13 @@ pmpkghash_t *_alpm_pkghash_create(size_t size)
if(hash->buckets < size) {
_alpm_log(PM_LOG_ERROR, _("database larger than maximum size\n"));
free(hash);
- return(NULL);
+ return NULL;
}
CALLOC(hash->hash_table, hash->buckets, sizeof(alpm_list_t*), \
free(hash); RET_ERR(PM_ERR_MEMORY, NULL));
- return(hash);
+ return hash;
}
static size_t get_hash_position(unsigned long name_hash, pmpkghash_t *hash)
@@ -93,7 +93,7 @@ static size_t get_hash_position(unsigned long name_hash, pmpkghash_t *hash)
position = (position + 1) % hash->buckets;
}
- return(position);
+ return position;
}
/* Expand the hash table size to the next increment and rebin the entries */
@@ -124,7 +124,7 @@ static pmpkghash_t *rehash(pmpkghash_t *oldhash)
newhash = _alpm_pkghash_create(newsize);
if(newhash == NULL) {
/* creation of newhash failed, stick with old one... */
- return(oldhash);
+ return oldhash;
}
newhash->list = oldhash->list;
@@ -145,7 +145,7 @@ static pmpkghash_t *rehash(pmpkghash_t *oldhash)
_alpm_pkghash_free(oldhash);
- return(newhash);
+ return newhash;
}
static pmpkghash_t *pkghash_add_pkg(pmpkghash_t *hash, pmpkg_t *pkg, int sorted)
@@ -154,7 +154,7 @@ static pmpkghash_t *pkghash_add_pkg(pmpkghash_t *hash, pmpkg_t *pkg, int sorted)
size_t position;
if(pkg == NULL || hash == NULL) {
- return(hash);
+ return hash;
}
if((hash->entries + 1) / MAX_HASH_LOAD > hash->buckets) {
@@ -165,7 +165,7 @@ static pmpkghash_t *pkghash_add_pkg(pmpkghash_t *hash, pmpkg_t *pkg, int sorted)
ptr = calloc(1, sizeof(alpm_list_t));
if(ptr == NULL) {
- return(hash);
+ return hash;
}
ptr->data = pkg;
@@ -180,17 +180,17 @@ static pmpkghash_t *pkghash_add_pkg(pmpkghash_t *hash, pmpkg_t *pkg, int sorted)
}
hash->entries += 1;
- return(hash);
+ return hash;
}
pmpkghash_t *_alpm_pkghash_add(pmpkghash_t *hash, pmpkg_t *pkg)
{
- return(pkghash_add_pkg(hash, pkg, 0));
+ return pkghash_add_pkg(hash, pkg, 0);
}
pmpkghash_t *_alpm_pkghash_add_sorted(pmpkghash_t *hash, pmpkg_t *pkg)
{
- return(pkghash_add_pkg(hash, pkg, 1));
+ return pkghash_add_pkg(hash, pkg, 1);
}
static size_t move_one_entry(pmpkghash_t *hash, size_t start, size_t end)
@@ -218,7 +218,7 @@ static size_t move_one_entry(pmpkghash_t *hash, size_t start, size_t end)
* e.g. (47 + 0 - 1) % 47 == 46 */
end = (hash->buckets + end - 1) % hash->buckets;
}
- return(end);
+ return end;
}
/**
@@ -241,7 +241,7 @@ pmpkghash_t *_alpm_pkghash_remove(pmpkghash_t *hash, pmpkg_t *pkg,
}
if(pkg == NULL || hash == NULL) {
- return(hash);
+ return hash;
}
position = pkg->name_hash % hash->buckets;
@@ -278,13 +278,13 @@ pmpkghash_t *_alpm_pkghash_remove(pmpkghash_t *hash, pmpkg_t *pkg,
position = prev;
}
- return(hash);
+ return hash;
}
position = (position + 1) % hash->buckets;
}
- return(hash);
+ return hash;
}
void _alpm_pkghash_free(pmpkghash_t *hash)
@@ -308,7 +308,7 @@ pmpkg_t *_alpm_pkghash_find(pmpkghash_t *hash, const char *name)
ALPM_LOG_FUNC;
if(name == NULL || hash == NULL) {
- return(NULL);
+ return NULL;
}
name_hash = _alpm_hash_sdbm(name);
@@ -319,13 +319,13 @@ pmpkg_t *_alpm_pkghash_find(pmpkghash_t *hash, const char *name)
pmpkg_t *info = lp->data;
if(info->name_hash == name_hash && strcmp(info->name, name) == 0) {
- return(info);
+ return info;
}
position = (position + 1) % hash->buckets;
}
- return(NULL);
+ return NULL;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 5def92a6..a01349ed 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -69,7 +69,7 @@ int SYMEXPORT alpm_remove_pkg(pmpkg_t *pkg)
_alpm_log(PM_LOG_DEBUG, "adding %s in the target list\n", pkgname);
trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(pkg));
- return(0);
+ return 0;
}
static void remove_prepare_cascade(pmtrans_t *trans, pmdb_t *db,
@@ -185,7 +185,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);
}
- return(0);
+ return 0;
}
static int can_remove_file(const char *path, alpm_list_t *skip)
@@ -196,7 +196,7 @@ static int can_remove_file(const char *path, alpm_list_t *skip)
if(alpm_list_find_str(skip, file)) {
/* return success because we will never actually remove this file */
- return(1);
+ return 1;
}
/* If we fail write permissions due to a read-only filesystem, abort.
* Assume all other possible failures are covered somewhere else */
@@ -206,11 +206,11 @@ static int can_remove_file(const char *path, alpm_list_t *skip)
* it - ignore "chmod -w" simple permission failures */
_alpm_log(PM_LOG_ERROR, _("cannot remove file '%s': %s\n"),
file, strerror(errno));
- return(0);
+ return 0;
}
}
- return(1);
+ return 1;
}
/* Helper function for iterating through a package's file and deleting them
@@ -351,7 +351,7 @@ db:
pkgname);
}
- return(0);
+ return 0;
}
int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db)
@@ -375,7 +375,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db)
size_t targcount = alpm_list_count(targ);
if(handle->trans->state == STATE_INTERRUPTED) {
- return(0);
+ return 0;
}
/* get the name now so we can use it after package is removed */
@@ -457,7 +457,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db)
/* run ldconfig if it exists */
_alpm_ldconfig(handle->root);
- return(0);
+ return 0;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 29197807..ebf8474d 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -56,7 +56,7 @@
*/
pmpkg_t SYMEXPORT *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync)
{
- ASSERT(pkg != NULL, return(NULL));
+ ASSERT(pkg != NULL, return NULL);
alpm_list_t *i;
pmpkg_t *spkg = NULL;
@@ -68,7 +68,7 @@ pmpkg_t SYMEXPORT *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync)
if(spkg == NULL) {
_alpm_log(PM_LOG_DEBUG, "'%s' not found in sync db => no upgrade\n",
alpm_pkg_get_name(pkg));
- return(NULL);
+ return NULL;
}
/* compare versions and see if spkg is an upgrade */
@@ -76,10 +76,10 @@ pmpkg_t SYMEXPORT *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync)
_alpm_log(PM_LOG_DEBUG, "new version of '%s' found (%s => %s)\n",
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg),
alpm_pkg_get_version(spkg));
- return(spkg);
+ return spkg;
}
/* spkg is not an upgrade */
- return(NULL);
+ return NULL;
}
/** Search for packages to upgrade and add them to the transaction.
@@ -199,7 +199,7 @@ int SYMEXPORT alpm_sync_sysupgrade(int enable_downgrade)
}
}
- return(0);
+ return 0;
}
/** Find group members across a list of databases.
@@ -241,7 +241,7 @@ alpm_list_t SYMEXPORT *alpm_find_grp_pkgs(alpm_list_t *dbs,
}
}
alpm_list_free(ignorelist);
- return(pkgs);
+ return pkgs;
}
/** Compute the size of the files that will be downloaded to install a
@@ -257,7 +257,7 @@ static int compute_download_size(pmpkg_t *newpkg)
if(newpkg->origin != PKG_FROM_SYNCDB) {
newpkg->infolevel |= INFRQ_DSIZE;
newpkg->download_size = 0;
- return(0);
+ return 0;
}
fname = alpm_pkg_get_filename(newpkg);
@@ -294,7 +294,7 @@ static int compute_download_size(pmpkg_t *newpkg)
newpkg->infolevel |= INFRQ_DSIZE;
newpkg->download_size = size;
- return(0);
+ return 0;
}
int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data)
@@ -544,7 +544,7 @@ cleanup:
alpm_list_free(unresolvable);
alpm_list_free(remove);
- return(ret);
+ return ret;
}
/** Returns the size of the files that will be downloaded to install a
@@ -557,13 +557,13 @@ off_t SYMEXPORT alpm_pkg_download_size(pmpkg_t *newpkg)
if(!(newpkg->infolevel & INFRQ_DSIZE)) {
compute_download_size(newpkg);
}
- return(newpkg->download_size);
+ return newpkg->download_size;
}
static int endswith(const char *filename, const char *extension)
{
const char *s = filename + strlen(filename) - strlen(extension);
- return(strcmp(s, extension) == 0);
+ return strcmp(s, extension) == 0;
}
/** Applies delta files to create an upgraded package file.
@@ -649,7 +649,7 @@ static int apply_deltas(pmtrans_t *trans)
}
}
- return(ret);
+ return ret;
}
/** Compares the md5sum of a file to the expected value.
@@ -684,7 +684,7 @@ static int test_md5sum(pmtrans_t *trans, const char *filename,
FREE(filepath);
- return(ret);
+ return ret;
}
int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
@@ -928,7 +928,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
error:
FREELIST(files);
alpm_list_free(deltas);
- return(ret);
+ return ret;
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 4b29f9a8..81254198 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -66,7 +66,7 @@ static int make_lock(pmhandle_t *handle)
}
if(_alpm_makepath(dir)) {
FREE(dir);
- return(-1);
+ return -1;
}
FREE(dir);
@@ -79,9 +79,9 @@ static int make_lock(pmhandle_t *handle)
fflush(f);
fsync(fd);
handle->lckstream = f;
- return(0);
+ return 0;
}
- return(-1);
+ return -1;
}
/* Remove a lock file */
@@ -92,9 +92,9 @@ static int remove_lock(pmhandle_t *handle)
handle->lckstream = NULL;
}
if(unlink(handle->lockfile) == -1 && errno != ENOENT) {
- return(-1);
+ return -1;
}
- return(0);
+ return 0;
}
/** Initialize the transaction.
@@ -148,7 +148,7 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags,
handle->trans = trans;
- return(0);
+ return 0;
}
static alpm_list_t *check_arch(alpm_list_t *pkgs)
@@ -158,7 +158,7 @@ static alpm_list_t *check_arch(alpm_list_t *pkgs)
const char *arch = alpm_option_get_arch();
if(!arch) {
- return(NULL);
+ return NULL;
}
for(i = pkgs; i; i = i->next) {
pmpkg_t *pkg = i->data;
@@ -173,7 +173,7 @@ static alpm_list_t *check_arch(alpm_list_t *pkgs)
invalid = alpm_list_add(invalid, string);
}
}
- return(invalid);
+ return invalid;
}
/** Prepare a transaction.
@@ -198,7 +198,7 @@ int SYMEXPORT alpm_trans_prepare(alpm_list_t **data)
/* If there's nothing to do, return without complaining */
if(trans->add == NULL && trans->remove == NULL) {
- return(0);
+ return 0;
}
alpm_list_t *invalid = check_arch(trans->add);
@@ -212,18 +212,18 @@ int SYMEXPORT alpm_trans_prepare(alpm_list_t **data)
if(trans->add == NULL) {
if(_alpm_remove_prepare(trans, handle->db_local, data) == -1) {
/* pm_errno is set by _alpm_remove_prepare() */
- return(-1);
+ return -1;
}
} else {
if(_alpm_sync_prepare(trans, handle->db_local, handle->dbs_sync, data) == -1) {
/* pm_errno is set by _alpm_sync_prepare() */
- return(-1);
+ return -1;
}
}
trans->state = STATE_PREPARED;
- return(0);
+ return 0;
}
/** Commit a transaction.
@@ -249,7 +249,7 @@ int SYMEXPORT alpm_trans_commit(alpm_list_t **data)
/* If there's nothing to do, return without complaining */
if(trans->add == NULL && trans->remove == NULL) {
- return(0);
+ return 0;
}
trans->state = STATE_COMMITING;
@@ -257,18 +257,18 @@ int SYMEXPORT alpm_trans_commit(alpm_list_t **data)
if(trans->add == NULL) {
if(_alpm_remove_packages(trans, handle->db_local) == -1) {
/* pm_errno is set by _alpm_remove_commit() */
- return(-1);
+ return -1;
}
} else {
if(_alpm_sync_commit(trans, handle->db_local, data) == -1) {
/* pm_errno is set by _alpm_sync_commit() */
- return(-1);
+ return -1;
}
}
trans->state = STATE_COMMITED;
- return(0);
+ return 0;
}
/** Interrupt a transaction.
@@ -290,7 +290,7 @@ int SYMEXPORT alpm_trans_interrupt(void)
trans->state = STATE_INTERRUPTED;
- return(0);
+ return 0;
}
/** Release a transaction.
@@ -324,7 +324,7 @@ int SYMEXPORT alpm_trans_release(void)
}
}
- return(0);
+ return 0;
}
/** @} */
@@ -338,7 +338,7 @@ pmtrans_t *_alpm_trans_new(void)
CALLOC(trans, 1, sizeof(pmtrans_t), RET_ERR(PM_ERR_MEMORY, NULL));
trans->state = STATE_IDLE;
- return(trans);
+ return trans;
}
void _alpm_trans_free(pmtrans_t *trans)
@@ -367,7 +367,7 @@ static int grep(const char *fn, const char *needle)
FILE *fp;
if((fp = fopen(fn, "r")) == NULL) {
- return(0);
+ return 0;
}
while(!feof(fp)) {
char line[1024];
@@ -378,11 +378,11 @@ static int grep(const char *fn, const char *needle)
* ends up being split across line reads */
if(strstr(line, needle)) {
fclose(fp);
- return(1);
+ return 1;
}
}
fclose(fp);
- return(0);
+ return 0;
}
int _alpm_runscriptlet(const char *root, const char *installfn,
@@ -402,7 +402,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
if(access(installfn, R_OK)) {
/* not found */
_alpm_log(PM_LOG_DEBUG, "scriptlet '%s' not found\n", installfn);
- return(0);
+ return 0;
}
/* creates a directory in $root/tmp/ for copying/extracting the scriptlet */
@@ -413,7 +413,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
snprintf(tmpdir, PATH_MAX, "%stmp/alpm_XXXXXX", root);
if(mkdtemp(tmpdir) == NULL) {
_alpm_log(PM_LOG_ERROR, _("could not create temp directory\n"));
- return(1);
+ return 1;
} else {
clean_tmpdir = 1;
}
@@ -459,14 +459,14 @@ cleanup:
_alpm_log(PM_LOG_WARNING, _("could not remove tmpdir %s\n"), tmpdir);
}
- return(retval);
+ return retval;
}
int SYMEXPORT alpm_trans_get_flags()
{
/* Sanity checks */
- ASSERT(handle != NULL, return(-1));
- ASSERT(handle->trans != NULL, return(-1));
+ ASSERT(handle != NULL, return -1);
+ ASSERT(handle->trans != NULL, return -1);
return handle->trans->flags;
}
@@ -474,8 +474,8 @@ int SYMEXPORT alpm_trans_get_flags()
alpm_list_t SYMEXPORT * alpm_trans_get_add()
{
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(handle->trans != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(handle->trans != NULL, return NULL);
return handle->trans->add;
}
@@ -483,8 +483,8 @@ alpm_list_t SYMEXPORT * alpm_trans_get_add()
alpm_list_t SYMEXPORT * alpm_trans_get_remove()
{
/* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(handle->trans != NULL, return(NULL));
+ ASSERT(handle != NULL, return NULL);
+ ASSERT(handle->trans != NULL, return NULL);
return handle->trans->remove;
}
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 74e14058..5332f001 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -86,7 +86,7 @@ char* strsep(char** str, const char* delims)
int _alpm_makepath(const char *path)
{
- return(_alpm_makepath_mode(path, 0755));
+ return _alpm_makepath_mode(path, 0755);
}
/* does the same thing as 'mkdir -p' */
@@ -122,7 +122,7 @@ int _alpm_makepath_mode(const char *path, mode_t mode)
free(orig);
free(incr);
umask(oldmask);
- return(ret);
+ return ret;
}
#define CPBUFSIZE 8 * 1024
@@ -136,12 +136,12 @@ int _alpm_copyfile(const char *src, const char *dest)
in = fopen(src, "rb");
if(in == NULL) {
- return(1);
+ return 1;
}
out = fopen(dest, "wb");
if(out == NULL) {
fclose(in);
- return(1);
+ return 1;
}
CALLOC(buf, (size_t)CPBUFSIZE, (size_t)1, ret = 1; goto cleanup;);
@@ -174,7 +174,7 @@ cleanup:
fclose(in);
fclose(out);
FREE(buf);
- return(ret);
+ return ret;
}
/* Trim whitespace and newlines from a string
@@ -185,7 +185,7 @@ char *_alpm_strtrim(char *str)
if(*str == '\0') {
/* string is empty, so we're done. */
- return(str);
+ return str;
}
while(isspace((unsigned char)*pch)) {
@@ -197,7 +197,7 @@ char *_alpm_strtrim(char *str)
/* check if there wasn't anything but whitespace in the string. */
if(*str == '\0') {
- return(str);
+ return str;
}
pch = (str + (strlen(str) - 1));
@@ -206,7 +206,7 @@ char *_alpm_strtrim(char *str)
}
*++pch = '\0';
- return(str);
+ return str;
}
/* Compression functions */
@@ -224,12 +224,12 @@ int _alpm_unpack_single(const char *archive, const char *prefix, const char *fn)
alpm_list_t *list = NULL;
int ret = 0;
if(fn == NULL) {
- return(1);
+ return 1;
}
list = alpm_list_add(list, (void *)fn);
ret = _alpm_unpack(archive, prefix, list, 1);
alpm_list_free(list);
- return(ret);
+ return ret;
}
/**
@@ -340,7 +340,7 @@ cleanup:
if(restore_cwd && chdir(cwd) != 0) {
_alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), cwd, strerror(errno));
}
- return(ret);
+ return ret;
}
/* does the same thing as 'rm -rf' */
@@ -355,18 +355,18 @@ int _alpm_rmrf(const char *path)
if(_alpm_lstat(path, &st) == 0) {
if(!S_ISDIR(st.st_mode)) {
if(!unlink(path)) {
- return(0);
+ return 0;
} else {
if(errno == ENOENT) {
- return(0);
+ return 0;
} else {
- return(1);
+ return 1;
}
}
} else {
dirp = opendir(path);
if(!dirp) {
- return(1);
+ return 1;
}
for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
if(dp->d_ino) {
@@ -381,9 +381,9 @@ int _alpm_rmrf(const char *path)
errflag++;
}
}
- return(errflag);
+ return errflag;
}
- return(0);
+ return 0;
}
int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args)
@@ -414,7 +414,7 @@ int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args)
fflush(f);
}
- return(ret);
+ return ret;
}
int _alpm_run_chroot(const char *root, const char *path, char *const argv[])
@@ -531,7 +531,7 @@ cleanup:
_alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), cwd, strerror(errno));
}
- return(retval);
+ return retval;
}
int _alpm_ldconfig(const char *root)
@@ -549,14 +549,14 @@ int _alpm_ldconfig(const char *root)
}
}
- return(0);
+ return 0;
}
/* Helper function for comparing strings using the
* alpm "compare func" signature */
int _alpm_str_cmp(const void *s1, const void *s2)
{
- return(strcmp(s1, s2));
+ return strcmp(s1, s2);
}
/** Find a filename in a registered alpm cachedir.
@@ -577,7 +577,7 @@ char *_alpm_filecache_find(const char* filename)
if(stat(path, &buf) == 0 && S_ISREG(buf.st_mode)) {
retpath = strdup(path);
_alpm_log(PM_LOG_DEBUG, "found cached pkg: %s\n", retpath);
- return(retpath);
+ return retpath;
}
}
/* package wasn't found in any cachedir */
@@ -603,11 +603,11 @@ const char *_alpm_filecache_setup(void)
cachedir);
if(_alpm_makepath(cachedir) == 0) {
_alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", cachedir);
- return(cachedir);
+ return cachedir;
}
} else if(S_ISDIR(buf.st_mode) && (buf.st_mode & S_IWUSR)) {
_alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", cachedir);
- return(cachedir);
+ return cachedir;
}
}
@@ -616,7 +616,7 @@ const char *_alpm_filecache_setup(void)
alpm_option_set_cachedirs(tmp);
_alpm_log(PM_LOG_DEBUG, "using cachedir: %s", "/tmp/\n");
_alpm_log(PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n"));
- return(alpm_list_getdata(tmp));
+ return alpm_list_getdata(tmp);
}
/** lstat wrapper that treats /path/dirsymlink/ the same as /path/dirsymlink.
@@ -640,7 +640,7 @@ int _alpm_lstat(const char *path, struct stat *buf)
ret = lstat(newpath, buf);
FREE(newpath);
- return(ret);
+ return ret;
}
#ifdef HAVE_LIBSSL
@@ -651,11 +651,11 @@ static int md5_file(const char *path, unsigned char output[16])
MD5_CTX ctx;
unsigned char *buf;
- CALLOC(buf, 8192, sizeof(unsigned char), return(1));
+ CALLOC(buf, 8192, sizeof(unsigned char), RET_ERR(PM_ERR_MEMORY, 1));
if((f = fopen(path, "rb")) == NULL) {
free(buf);
- return(1);
+ return 1;
}
MD5_Init(&ctx);
@@ -671,11 +671,11 @@ static int md5_file(const char *path, unsigned char output[16])
if(ferror(f) != 0) {
fclose(f);
- return(2);
+ return 2;
}
fclose(f);
- return(0);
+ return 0;
}
#endif
@@ -692,7 +692,7 @@ char SYMEXPORT *alpm_compute_md5sum(const char *filename)
ALPM_LOG_FUNC;
- ASSERT(filename != NULL, return(NULL));
+ ASSERT(filename != NULL, return NULL);
/* allocate 32 chars plus 1 for null */
md5sum = calloc(33, sizeof(char));
@@ -711,7 +711,7 @@ char SYMEXPORT *alpm_compute_md5sum(const char *filename)
md5sum[32] = '\0';
_alpm_log(PM_LOG_DEBUG, "md5(%s) = %s\n", filename, md5sum);
- return(md5sum);
+ return md5sum;
}
int _alpm_test_md5sum(const char *filepath, const char *md5sum)
@@ -730,7 +730,7 @@ int _alpm_test_md5sum(const char *filepath, const char *md5sum)
}
FREE(md5sum2);
- return(ret);
+ return ret;
}
/* Note: does NOT handle sparse files on purpose for speed. */
@@ -800,7 +800,7 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b)
b->line_offset[len] = '\0';
b->block_offset = ++i;
/* this is the main return point; from here you can read b->line */
- return(ARCHIVE_OK);
+ return ARCHIVE_OK;
} else {
/* we've looked through the whole block but no newline, copy it */
size_t len = (size_t)(b->block + b->block_size - b->block_offset);
@@ -815,7 +815,7 @@ cleanup:
int ret = b->ret;
FREE(b->line);
memset(b, 0, sizeof(b));
- return(ret);
+ return ret;
}
}
@@ -829,7 +829,7 @@ int _alpm_splitname(const char *target, pmpkg_t *pkg)
const char *version, *end;
if(target == NULL || pkg == NULL) {
- return(-1);
+ return -1;
}
end = target + strlen(target);
@@ -843,7 +843,7 @@ int _alpm_splitname(const char *target, pmpkg_t *pkg)
for(version = end - 1; *version && *version != '-'; version--);
for(version = version - 1; *version && *version != '-'; version--);
if(*version != '-' || version == target) {
- return(-1);
+ return -1;
}
/* copy into fields and return */
@@ -861,7 +861,7 @@ int _alpm_splitname(const char *target, pmpkg_t *pkg)
STRNDUP(pkg->name, target, version - target, RET_ERR(PM_ERR_MEMORY, -1));
pkg->name_hash = _alpm_hash_sdbm(pkg->name);
- return(0);
+ return 0;
}
/**
@@ -876,13 +876,13 @@ unsigned long _alpm_hash_sdbm(const char *str)
int c;
if(!str) {
- return(hash);
+ return hash;
}
while((c = *str++)) {
hash = c + (hash << 6) + (hash << 16) - hash;
}
- return(hash);
+ return hash;
}
long _alpm_parsedate(const char *line)
@@ -893,9 +893,9 @@ long _alpm_parsedate(const char *line)
setlocale(LC_TIME, "C");
strptime(line, "%a %b %e %H:%M:%S %Y", &tmp_tm);
setlocale(LC_TIME, "");
- return(mktime(&tmp_tm));
+ return mktime(&tmp_tm);
}
- return(atol(line));
+ return atol(line);
}
#ifndef HAVE_STRNDUP
@@ -904,7 +904,7 @@ static size_t strnlen(const char *s, size_t max)
{
register const char *p;
for(p = s; *p && max--; ++p);
- return(p - s);
+ return (p - s);
}
char *strndup(const char *s, size_t n)
@@ -916,7 +916,7 @@ char *strndup(const char *s, size_t n)
return NULL;
new[len] = '\0';
- return (char *) memcpy(new, s, len);
+ return (char *)memcpy(new, s, len);
}
#endif
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 3232f004..9f0344fe 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -59,7 +59,7 @@
#define RET_ERR(err, ret) do { pm_errno = (err); \
_alpm_log(PM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerrorlast()); \
- return(ret); } while(0)
+ return (ret); } while(0)
/**
* Used as a buffer/state holder for _alpm_archive_fgets().
diff --git a/lib/libalpm/version.c b/lib/libalpm/version.c
index eba66210..9f3a9b71 100644
--- a/lib/libalpm/version.c
+++ b/lib/libalpm/version.c
@@ -93,7 +93,7 @@ static int rpmvercmp(const char *a, const char *b)
int ret = 0;
/* easy comparison to see if versions are identical */
- if(strcmp(a, b) == 0) return(0);
+ if(strcmp(a, b) == 0) return 0;
str1 = strdup(a);
str2 = strdup(b);
@@ -209,7 +209,7 @@ static int rpmvercmp(const char *a, const char *b)
cleanup:
free(str1);
free(str2);
- return(ret);
+ return ret;
}
/** Compare two version strings and determine which one is 'newer'.
@@ -235,15 +235,15 @@ int SYMEXPORT alpm_pkg_vercmp(const char *a, const char *b)
/* ensure our strings are not null */
if(!a && !b) {
- return(0);
+ return 0;
} else if(!a) {
- return(-1);
+ return -1;
} else if(!b) {
- return(1);
+ return 1;
}
/* another quick shortcut- if full version specs are equal */
if(strcmp(a, b) == 0) {
- return(0);
+ return 0;
}
/* Parse both versions into [epoch:]version[-release] triplets. We probably
@@ -266,7 +266,7 @@ int SYMEXPORT alpm_pkg_vercmp(const char *a, const char *b)
free(full1);
free(full2);
- return(ret);
+ return ret;
}
/* vim: set ts=2 sw=2 noet: */