summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2006-03-08 18:07:58 +0000
committerAurelien Foret <aurelien@archlinux.org>2006-03-08 18:07:58 +0000
commit4f42a0accb04936acb6eeb640e5bc09a556eac57 (patch)
treebaf6422b479604fa12da47e8243edfcbfdb691a1 /lib/libalpm
parent230d9d7ae3c3ebc64e922611567841b6fe692f3f (diff)
downloadpacman-4f42a0accb04936acb6eeb640e5bc09a556eac57.tar.xz
all _alpm_XXX_cmp functions are now public
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/alpm.c14
-rw-r--r--lib/libalpm/cache.c13
-rw-r--r--lib/libalpm/db.c5
-rw-r--r--lib/libalpm/db.h1
-rw-r--r--lib/libalpm/package.c7
-rw-r--r--lib/libalpm/package.h1
6 files changed, 18 insertions, 23 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 55c4e274..18021fba 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -217,18 +217,6 @@ pmdb_t *alpm_db_register(char *treename)
return(db);
}
-/** Helper function for comparing databases
- * @param db1 first database
- * @param db2 second database
- * @return an integer less than, equal to, or greater than zero if the name of
- * db1 is found, respectively, to be less than, to match, or be greater than
- * the name of db2.
- */
-static int db_cmp(const void *db1, const void *db2)
-{
- return(strcmp(((pmdb_t *)db1)->treename, ((pmdb_t *)db2)->treename));
-}
-
/** Unregister a package database
* @param db pointer to the package database to unregister
* @return 0 on success, -1 on error (pm_errno is set accordingly)
@@ -248,7 +236,7 @@ int alpm_db_unregister(pmdb_t *db)
found = 1;
} else {
pmdb_t *data;
- handle->dbs_sync = _alpm_list_remove(handle->dbs_sync, db, db_cmp, (void **)&data);
+ handle->dbs_sync = _alpm_list_remove(handle->dbs_sync, db, _alpm_db_cmp, (void **)&data);
if(data) {
found = 1;
}
diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c
index 2c03f961..2a98d886 100644
--- a/lib/libalpm/cache.c
+++ b/lib/libalpm/cache.c
@@ -36,13 +36,6 @@
#include "db.h"
#include "cache.h"
-/* Helper function for comparing packages
- */
-static int pkg_cmp(const void *p1, const void *p2)
-{
- return(strcmp(((pmpkg_t *)p1)->name, ((pmpkg_t *)p2)->name));
-}
-
/* Returns a new package cache from db.
* It frees the cache if it already exists.
*/
@@ -66,7 +59,7 @@ int _alpm_db_load_pkgcache(pmdb_t *db)
info->origin = PKG_FROM_CACHE;
info->data = db;
/* add to the collective */
- db->pkgcache = _alpm_list_add_sorted(db->pkgcache, info, pkg_cmp);
+ db->pkgcache = _alpm_list_add_sorted(db->pkgcache, info, _alpm_pkg_cmp);
}
return(0);
@@ -114,7 +107,7 @@ int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
return(-1);
}
_alpm_log(PM_LOG_DEBUG, "adding entry '%s' in '%s' cache", newpkg->name, db->treename);
- db->pkgcache = _alpm_list_add_sorted(db->pkgcache, newpkg, pkg_cmp);
+ db->pkgcache = _alpm_list_add_sorted(db->pkgcache, newpkg, _alpm_pkg_cmp);
_alpm_db_free_grpcache(db);
@@ -129,7 +122,7 @@ int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
return(-1);
}
- db->pkgcache = _alpm_list_remove(db->pkgcache, pkg, pkg_cmp, (void **)&data);
+ db->pkgcache = _alpm_list_remove(db->pkgcache, pkg, _alpm_pkg_cmp, (void **)&data);
if(data == NULL) {
/* package not found */
return(-1);
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 6b1ceffe..01265917 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -77,4 +77,9 @@ void _alpm_db_free(void *data)
free(db);
}
+int _alpm_db_cmp(const void *db1, const void *db2)
+{
+ return(strcmp(((pmdb_t *)db1)->treename, ((pmdb_t *)db2)->treename));
+}
+
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 8e15a1a4..b1a88103 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -46,6 +46,7 @@ typedef struct __pmdb_t {
pmdb_t *_alpm_db_new(char *root, char *dbpath, char *treename);
void _alpm_db_free(void *data);
+int _alpm_db_cmp(const void *db1, const void *db2);
/* Prototypes for backends functions */
int _alpm_db_open(pmdb_t *db, int mode);
void _alpm_db_close(pmdb_t *db);
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 8150dd7c..1b006cc4 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -148,6 +148,13 @@ void _alpm_pkg_free(void *data)
return;
}
+/* Helper function for comparing packages
+ */
+int _alpm_pkg_cmp(const void *p1, const void *p2)
+{
+ return(strcmp(((pmpkg_t *)p1)->name, ((pmpkg_t *)p2)->name));
+}
+
/* Parses the package description file for the current package
*
* Returns: 0 on success, 1 on error
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 2fe60dd7..ae286bce 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -80,6 +80,7 @@ do { \
pmpkg_t* _alpm_pkg_new(const char *name, const char *version);
pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg);
void _alpm_pkg_free(void *data);
+int _alpm_pkg_cmp(const void *p1, const void *p2);
pmpkg_t *_alpm_pkg_load(char *pkgfile);
pmpkg_t *_alpm_pkg_isin(char *needle, PMList *haystack);
int _alpm_pkg_splitname(char *target, char *name, char *version);