index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2011-06-30 10:37:08 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-06-30 10:37:08 -0500 |
commit | ad577b3cb46dcaf1b143c55324a6eecf9f0ad7f1 (patch) | |
tree | d79aa34734791bb069eab172b8ea3e0ee12bedc6 /lib/libalpm/db.c | |
parent | 0f4aaeee42135d06dd18eb585eab3bae0e5fbf34 (diff) | |
parent | fed3e09c94d204b4655656c703a178e6fa2144b3 (diff) |
-rw-r--r-- | lib/libalpm/db.c | 110 |
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 9f37f80b..f6f810c0 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -45,7 +45,7 @@ */ /** Register a sync database of packages. */ -pmdb_t SYMEXPORT *alpm_db_register_sync(pmhandle_t *handle, const char *treename, +alpm_db_t SYMEXPORT *alpm_db_register_sync(alpm_handle_t *handle, const char *treename, pgp_verify_t check_sig) { /* Sanity checks */ @@ -59,7 +59,7 @@ pmdb_t SYMEXPORT *alpm_db_register_sync(pmhandle_t *handle, const char *treename } /* Helper function for alpm_db_unregister{_all} */ -void _alpm_db_unregister(pmdb_t *db) +void _alpm_db_unregister(alpm_db_t *db) { if(db == NULL) { return; @@ -70,10 +70,10 @@ void _alpm_db_unregister(pmdb_t *db) } /** Unregister all package databases. */ -int SYMEXPORT alpm_db_unregister_all(pmhandle_t *handle) +int SYMEXPORT alpm_db_unregister_all(alpm_handle_t *handle) { alpm_list_t *i; - pmdb_t *db; + alpm_db_t *db; /* Sanity checks */ CHECK_HANDLE(handle, return -1); @@ -91,10 +91,10 @@ int SYMEXPORT alpm_db_unregister_all(pmhandle_t *handle) } /** Unregister a package database. */ -int SYMEXPORT alpm_db_unregister(pmdb_t *db) +int SYMEXPORT alpm_db_unregister(alpm_db_t *db) { int found = 0; - pmhandle_t *handle; + alpm_handle_t *handle; /* Sanity checks */ ASSERT(db != NULL, return -1); @@ -128,14 +128,14 @@ int SYMEXPORT alpm_db_unregister(pmdb_t *db) } /** Get the serverlist of a database. */ -alpm_list_t SYMEXPORT *alpm_db_get_servers(const pmdb_t *db) +alpm_list_t SYMEXPORT *alpm_db_get_servers(const alpm_db_t *db) { ASSERT(db != NULL, return NULL); return db->servers; } /** Set the serverlist of a database. */ -int SYMEXPORT alpm_db_set_servers(pmdb_t *db, alpm_list_t *servers) +int SYMEXPORT alpm_db_set_servers(alpm_db_t *db, alpm_list_t *servers) { ASSERT(db != NULL, return -1); if(db->servers) FREELIST(db->servers); @@ -161,7 +161,7 @@ static char *sanitize_url(const char *url) * @param url url of the server * @return 0 on success, -1 on error (pm_errno is set accordingly) */ -int SYMEXPORT alpm_db_add_server(pmdb_t *db, const char *url) +int SYMEXPORT alpm_db_add_server(alpm_db_t *db, const char *url) { char *newurl; @@ -187,7 +187,7 @@ int SYMEXPORT alpm_db_add_server(pmdb_t *db, const char *url) * @return 0 on success, 1 on server not present, * -1 on error (pm_errno is set accordingly) */ -int SYMEXPORT alpm_db_remove_server(pmdb_t *db, const char *url) +int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url) { char *newurl, *vdata = NULL; @@ -213,14 +213,14 @@ int SYMEXPORT alpm_db_remove_server(pmdb_t *db, const char *url) } /** Get the name of a package database. */ -const char SYMEXPORT *alpm_db_get_name(const pmdb_t *db) +const char SYMEXPORT *alpm_db_get_name(const alpm_db_t *db) { ASSERT(db != NULL, return NULL); return db->treename; } /** Get a package entry from a package database. */ -pmpkg_t SYMEXPORT *alpm_db_get_pkg(pmdb_t *db, const char *name) +alpm_pkg_t SYMEXPORT *alpm_db_get_pkg(alpm_db_t *db, const char *name) { ASSERT(db != NULL, return NULL); db->handle->pm_errno = 0; @@ -231,7 +231,7 @@ pmpkg_t SYMEXPORT *alpm_db_get_pkg(pmdb_t *db, const char *name) } /** Get the package cache of a package database. */ -alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db) +alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(alpm_db_t *db) { ASSERT(db != NULL, return NULL); db->handle->pm_errno = 0; @@ -239,27 +239,27 @@ alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(pmdb_t *db) } /** Get a group entry from a package database. */ -pmgrp_t SYMEXPORT *alpm_db_readgrp(pmdb_t *db, const char *name) +alpm_group_t SYMEXPORT *alpm_db_readgroup(alpm_db_t *db, const char *name) { ASSERT(db != NULL, return NULL); db->handle->pm_errno = 0; ASSERT(name != NULL && strlen(name) != 0, RET_ERR(db->handle, PM_ERR_WRONG_ARGS, NULL)); - return _alpm_db_get_grpfromcache(db, name); + return _alpm_db_get_groupfromcache(db, name); } /** Get the group cache of a package database. */ -alpm_list_t SYMEXPORT *alpm_db_get_grpcache(pmdb_t *db) +alpm_list_t SYMEXPORT *alpm_db_get_groupcache(alpm_db_t *db) { ASSERT(db != NULL, return NULL); db->handle->pm_errno = 0; - return _alpm_db_get_grpcache(db); + return _alpm_db_get_groupcache(db); } /** Searches a database. */ -alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles) +alpm_list_t SYMEXPORT *alpm_db_search(alpm_db_t *db, const alpm_list_t* needles) { ASSERT(db != NULL, return NULL); db->handle->pm_errno = 0; @@ -268,14 +268,14 @@ alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles) } /** Set install reason for a package in db. */ -int SYMEXPORT alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t reason) +int SYMEXPORT alpm_db_set_pkgreason(alpm_db_t *db, const char *name, alpm_pkgreason_t reason) { ASSERT(db != NULL, return -1); db->handle->pm_errno = 0; /* TODO assert db == db_local ? shouldn't need a db param at all here... */ ASSERT(name != NULL, RET_ERR(db->handle, PM_ERR_WRONG_ARGS, -1)); - pmpkg_t *pkg = _alpm_db_get_pkgfromcache(db, name); + alpm_pkg_t *pkg = _alpm_db_get_pkgfromcache(db, name); if(pkg == NULL) { RET_ERR(db->handle, PM_ERR_PKG_NOT_FOUND, -1); } @@ -297,11 +297,11 @@ int SYMEXPORT alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t /** @} */ -pmdb_t *_alpm_db_new(const char *treename, int is_local) +alpm_db_t *_alpm_db_new(const char *treename, int is_local) { - pmdb_t *db; + alpm_db_t *db; - CALLOC(db, 1, sizeof(pmdb_t), return NULL); + CALLOC(db, 1, sizeof(alpm_db_t), return NULL); STRDUP(db->treename, treename, return NULL); db->is_local = is_local; db->pgp_verify = PM_PGP_VERIFY_UNKNOWN; @@ -309,7 +309,7 @@ pmdb_t *_alpm_db_new(const char *treename, int is_local) return db; } -void _alpm_db_free(pmdb_t *db) +void _alpm_db_free(alpm_db_t *db) { /* cleanup pkgcache */ _alpm_db_free_pkgcache(db); @@ -322,7 +322,7 @@ void _alpm_db_free(pmdb_t *db) return; } -const char *_alpm_db_path(pmdb_t *db) +const char *_alpm_db_path(alpm_db_t *db) { if(!db) { return NULL; @@ -353,7 +353,7 @@ const char *_alpm_db_path(pmdb_t *db) return db->_path; } -char *_alpm_db_sig_path(pmdb_t *db) +char *_alpm_db_sig_path(alpm_db_t *db) { char *sigpath; size_t len; @@ -369,12 +369,12 @@ char *_alpm_db_sig_path(pmdb_t *db) int _alpm_db_cmp(const void *d1, const void *d2) { - pmdb_t *db1 = (pmdb_t *)d1; - pmdb_t *db2 = (pmdb_t *)d2; + alpm_db_t *db1 = (alpm_db_t *)d1; + alpm_db_t *db2 = (alpm_db_t *)d2; return strcmp(db1->treename, db2->treename); } -alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles) +alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles) { const alpm_list_t *i, *j, *k; alpm_list_t *ret = NULL; @@ -397,7 +397,7 @@ alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles) } for(j = list; j; j = j->next) { - pmpkg_t *pkg = j->data; + alpm_pkg_t *pkg = j->data; const char *matched = NULL; const char *name = alpm_pkg_get_name(pkg); const char *desc = alpm_pkg_get_desc(pkg); @@ -451,7 +451,7 @@ alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles) /* Returns a new package cache from db. * It frees the cache if it already exists. */ -static int load_pkgcache(pmdb_t *db) +static int load_pkgcache(alpm_db_t *db) { _alpm_db_free_pkgcache(db); @@ -467,7 +467,7 @@ static int load_pkgcache(pmdb_t *db) return 0; } -void _alpm_db_free_pkgcache(pmdb_t *db) +void _alpm_db_free_pkgcache(alpm_db_t *db) { if(db == NULL || !(db->status & DB_STATUS_PKGCACHE)) { return; @@ -481,10 +481,10 @@ void _alpm_db_free_pkgcache(pmdb_t *db) _alpm_pkghash_free(db->pkgcache); db->status &= ~DB_STATUS_PKGCACHE; - _alpm_db_free_grpcache(db); + _alpm_db_free_groupcache(db); } -pmpkghash_t *_alpm_db_get_pkgcache_hash(pmdb_t *db) +alpm_pkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db) { if(db == NULL) { return NULL; @@ -501,9 +501,9 @@ pmpkghash_t *_alpm_db_get_pkgcache_hash(pmdb_t *db) return db->pkgcache; } -alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db) +alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db) { - pmpkghash_t *hash = _alpm_db_get_pkgcache_hash(db); + alpm_pkghash_t *hash = _alpm_db_get_pkgcache_hash(db); if(hash == NULL) { return NULL; @@ -513,9 +513,9 @@ alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db) } /* "duplicate" pkg then add it to pkgcache */ -int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg) +int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg) { - pmpkg_t *newpkg; + alpm_pkg_t *newpkg; if(db == NULL || pkg == NULL || !(db->status & DB_STATUS_PKGCACHE)) { return -1; @@ -530,14 +530,14 @@ int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg) alpm_pkg_get_name(newpkg), db->treename); db->pkgcache = _alpm_pkghash_add_sorted(db->pkgcache, newpkg); - _alpm_db_free_grpcache(db); + _alpm_db_free_groupcache(db); return 0; } -int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg) +int _alpm_db_remove_pkgfromcache(alpm_db_t *db, alpm_pkg_t *pkg) { - pmpkg_t *data = NULL; + alpm_pkg_t *data = NULL; if(db == NULL || pkg == NULL || !(db->status & DB_STATUS_PKGCACHE)) { return -1; @@ -556,18 +556,18 @@ int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg) _alpm_pkg_free(data); - _alpm_db_free_grpcache(db); + _alpm_db_free_groupcache(db); return 0; } -pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, const char *target) +alpm_pkg_t *_alpm_db_get_pkgfromcache(alpm_db_t *db, const char *target) { if(db == NULL) { return NULL; } - pmpkghash_t *pkgcache = _alpm_db_get_pkgcache_hash(db); + alpm_pkghash_t *pkgcache = _alpm_db_get_pkgcache_hash(db); if(!pkgcache) { return NULL; } @@ -577,7 +577,7 @@ pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, const char *target) /* Returns a new group cache from db. */ -static int load_grpcache(pmdb_t *db) +static int load_grpcache(alpm_db_t *db) { alpm_list_t *lp; @@ -590,12 +590,12 @@ static int load_grpcache(pmdb_t *db) for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) { const alpm_list_t *i; - pmpkg_t *pkg = lp->data; + alpm_pkg_t *pkg = lp->data; for(i = alpm_pkg_get_groups(pkg); i; i = i->next) { const char *grpname = i->data; alpm_list_t *j; - pmgrp_t *grp = NULL; + alpm_group_t *grp = NULL; int found = 0; /* first look through the group cache for a group with this name */ @@ -613,9 +613,9 @@ static int load_grpcache(pmdb_t *db) continue; } /* we didn't find the group, so create a new one with this name */ - grp = _alpm_grp_new(grpname); + grp = _alpm_group_new(grpname); if(!grp) { - _alpm_db_free_grpcache(db); + _alpm_db_free_groupcache(db); return -1; } grp->packages = alpm_list_add(grp->packages, pkg); @@ -627,7 +627,7 @@ static int load_grpcache(pmdb_t *db) return 0; } -void _alpm_db_free_grpcache(pmdb_t *db) +void _alpm_db_free_groupcache(alpm_db_t *db) { alpm_list_t *lg; @@ -639,14 +639,14 @@ void _alpm_db_free_grpcache(pmdb_t *db) "freeing group cache for repository '%s'\n", db->treename); for(lg = db->grpcache; lg; lg = lg->next) { - _alpm_grp_free(lg->data); + _alpm_group_free(lg->data); lg->data = NULL; } FREELIST(db->grpcache); db->status &= ~DB_STATUS_GRPCACHE; } -alpm_list_t *_alpm_db_get_grpcache(pmdb_t *db) +alpm_list_t *_alpm_db_get_groupcache(alpm_db_t *db) { if(db == NULL) { return NULL; @@ -663,7 +663,7 @@ alpm_list_t *_alpm_db_get_grpcache(pmdb_t *db) return db->grpcache; } -pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, const char *target) +alpm_group_t *_alpm_db_get_groupfromcache(alpm_db_t *db, const char *target) { alpm_list_t *i; @@ -671,8 +671,8 @@ pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, const char *target) return NULL; } - for(i = _alpm_db_get_grpcache(db); i; i = i->next) { - pmgrp_t *info = i->data; + for(i = _alpm_db_get_groupcache(db); i; i = i->next) { + alpm_group_t *info = i->data; if(strcmp(info->name, target) == 0) { return info; |