1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

all _alpm_XXX_cmp functions are now public

This commit is contained in:
Aurelien Foret 2006-03-08 18:07:58 +00:00
parent 230d9d7ae3
commit 4f42a0accb
6 changed files with 18 additions and 23 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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: */

View File

@ -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);

View File

@ -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

View File

@ -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);