diff options
-rw-r--r-- | lib/libalpm/alpm.c | 2 | ||||
-rw-r--r-- | lib/libalpm/be_local.c | 20 | ||||
-rw-r--r-- | lib/libalpm/be_sync.c | 10 | ||||
-rw-r--r-- | lib/libalpm/db.c | 11 | ||||
-rw-r--r-- | lib/libalpm/db.h | 4 | ||||
-rw-r--r-- | lib/libalpm/package.c | 11 |
6 files changed, 17 insertions, 41 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 17fe5cd8..2da3432f 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -54,7 +54,7 @@ int SYMEXPORT alpm_initialize(void) if(handle == NULL) { RET_ERR(PM_ERR_MEMORY, -1); } - if(_alpm_db_register_local() == NULL) { + if(_alpm_db_register_local(handle) == NULL) { /* error code should be set */ _alpm_handle_free(handle); handle = NULL; diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 1f509d19..64af4b95 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -41,12 +41,8 @@ #include "package.h" #include "deps.h" -/* global handle variable */ -extern pmhandle_t *handle; - #define LAZY_LOAD(info, errret) \ do { \ - ASSERT(handle != NULL, return (errret)); \ if(pkg->origin != PKG_FROM_FILE && !(pkg->infolevel & info)) { \ _alpm_local_db_read(pkg->origin_data.db, pkg, info); \ } \ @@ -139,9 +135,6 @@ static alpm_list_t *_cache_get_groups(pmpkg_t *pkg) static int _cache_has_scriptlet(pmpkg_t *pkg) { - /* Sanity checks */ - ASSERT(handle != NULL, return -1); - if(!(pkg->infolevel & INFRQ_SCRIPTLET)) { _alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_SCRIPTLET); } @@ -186,9 +179,6 @@ static alpm_list_t *_cache_get_deltas(pmpkg_t UNUSED *pkg) static alpm_list_t *_cache_get_files(pmpkg_t *pkg) { - /* Sanity checks */ - ASSERT(handle != NULL, return NULL); - if(pkg->origin == PKG_FROM_LOCALDB && !(pkg->infolevel & INFRQ_FILES)) { _alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_FILES); @@ -198,9 +188,6 @@ static alpm_list_t *_cache_get_files(pmpkg_t *pkg) static alpm_list_t *_cache_get_backup(pmpkg_t *pkg) { - /* Sanity checks */ - ASSERT(handle != NULL, return NULL); - if(pkg->origin == PKG_FROM_LOCALDB && !(pkg->infolevel & INFRQ_FILES)) { _alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_FILES); @@ -216,9 +203,6 @@ static alpm_list_t *_cache_get_backup(pmpkg_t *pkg) */ static void *_cache_changelog_open(pmpkg_t *pkg) { - /* Sanity checks */ - ASSERT(handle != NULL, return NULL); - char clfile[PATH_MAX]; snprintf(clfile, PATH_MAX, "%s/%s/%s-%s/changelog", alpm_option_get_dbpath(), @@ -417,7 +401,7 @@ static int local_db_populate(pmdb_t *db) pkg->origin = PKG_FROM_LOCALDB; pkg->origin_data.db = db; pkg->ops = &local_pkg_ops; - pkg->handle = handle; + pkg->handle = db->handle; /* explicitly read with only 'BASE' data, accessors will handle the rest */ if(_alpm_local_db_read(db, pkg, INFRQ_BASE) == -1) { @@ -944,7 +928,7 @@ struct db_operations local_db_ops = { .version = local_db_version, }; -pmdb_t *_alpm_db_register_local(void) +pmdb_t *_alpm_db_register_local(pmhandle_t *handle) { pmdb_t *db; diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 2e472b3d..953e4dc1 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -37,9 +37,6 @@ #include "deps.h" #include "dload.h" -/* global handle variable */ -extern pmhandle_t *handle; - /** Update a package database * * An update of the package database \a db will be attempted. Unless @@ -91,8 +88,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) pgp_verify_t check_sig; /* Sanity checks */ - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); - ASSERT(db != NULL && db != handle->db_local, RET_ERR(PM_ERR_WRONG_ARGS, -1)); + ASSERT(db != NULL && db != db->handle->db_local, RET_ERR(PM_ERR_WRONG_ARGS, -1)); ASSERT(db->servers != NULL, RET_ERR(PM_ERR_SERVER_NONE, -1)); dbpath = alpm_option_get_dbpath(); @@ -311,7 +307,7 @@ static int sync_db_populate(pmdb_t *db) pkg->origin = PKG_FROM_SYNCDB; pkg->origin_data.db = db; pkg->ops = &default_pkg_ops; - pkg->handle = handle; + pkg->handle = db->handle; /* add to the collection */ _alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", @@ -506,7 +502,7 @@ struct db_operations sync_db_ops = { .version = sync_db_version, }; -pmdb_t *_alpm_db_register_sync(const char *treename) +pmdb_t *_alpm_db_register_sync(pmhandle_t *handle, const char *treename) { pmdb_t *db; diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index c297bc69..9b1f4fbb 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -56,7 +56,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(handle, treename); } /* Helper function for alpm_db_unregister{_all} */ @@ -97,13 +97,12 @@ int SYMEXPORT alpm_db_unregister(pmdb_t *db) int found = 0; /* Sanity checks */ - ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(db != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); /* Do not unregister a database if a transaction is on-going */ - ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, -1)); + ASSERT(db->handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, -1)); - if(db == handle->db_local) { - handle->db_local = NULL; + if(db == db->handle->db_local) { + db->handle->db_local = NULL; found = 1; } else { /* Warning : this function shouldn't be used to unregister all sync @@ -111,7 +110,7 @@ int SYMEXPORT alpm_db_unregister(pmdb_t *db) * alpm_option_get_syncdbs, because the db is removed from that list here. */ void *data; - handle->dbs_sync = alpm_list_remove(handle->dbs_sync, + db->handle->dbs_sync = alpm_list_remove(db->handle->dbs_sync, db, _alpm_db_cmp, &data); if(data) { found = 1; diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h index 8d92bd2d..3a7ab72f 100644 --- a/lib/libalpm/db.h +++ b/lib/libalpm/db.h @@ -77,8 +77,8 @@ const char *_alpm_db_path(pmdb_t *db); int _alpm_db_version(pmdb_t *db); int _alpm_db_cmp(const void *d1, const void *d2); alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles); -pmdb_t *_alpm_db_register_local(void); -pmdb_t *_alpm_db_register_sync(const char *treename); +pmdb_t *_alpm_db_register_local(pmhandle_t *handle); +pmdb_t *_alpm_db_register_sync(pmhandle_t *handle, const char *treename); void _alpm_db_unregister(pmdb_t *db); /* be_*.c, backend specific calls */ diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 10ec82f1..d6edca1f 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -37,9 +37,6 @@ #include "handle.h" #include "deps.h" -/* global handle variable */ -extern pmhandle_t *handle; - /** \addtogroup alpm_packages Package Functions * @brief Functions to manipulate libalpm packages * @{ @@ -353,7 +350,7 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg) if(db->is_local) { find_requiredby(pkg, db, &reqs); } else { - for(i = handle->dbs_sync; i; i = i->next) { + for(i = pkg->handle->dbs_sync; i; i = i->next) { db = i->data; find_requiredby(pkg, db, &reqs); } @@ -419,7 +416,7 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg) newpkg->origin_data.db = pkg->origin_data.db; } newpkg->ops = pkg->ops; - newpkg->handle = handle; + newpkg->handle = pkg->handle; return newpkg; } @@ -542,12 +539,12 @@ int _alpm_pkg_should_ignore(pmpkg_t *pkg) alpm_list_t *groups = NULL; /* first see if the package is ignored */ - if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(pkg))) { + if(alpm_list_find_str(pkg->handle->ignorepkg, alpm_pkg_get_name(pkg))) { return 1; } /* next see if the package is in a group that is ignored */ - for(groups = handle->ignoregrp; groups; groups = alpm_list_next(groups)) { + for(groups = pkg->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; |