1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-02-28 17:31:52 -05:00

A handful of minor changes:

* Removed the PMList typedef, in favor of the same naming scheme other
      structs use 'pmlist_t'
    * Added a time stamp on debug output, to make it more informational
    * Moved alpm_db_register to _alpm_db_register, making the public function
      not take a callback parameter
This commit is contained in:
Aaron Griffin 2006-10-20 06:26:55 +00:00
parent e7f886aac3
commit 7131b7ac87
35 changed files with 299 additions and 279 deletions

View File

@ -112,7 +112,7 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
pmpkg_t *info = NULL; pmpkg_t *info = NULL;
pmpkg_t *dummy; pmpkg_t *dummy;
char pkgname[PKG_NAME_LEN], pkgver[PKG_VERSION_LEN]; char pkgname[PKG_NAME_LEN], pkgver[PKG_VERSION_LEN];
PMList *i; pmlist_t *i;
struct stat buf; struct stat buf;
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
@ -208,10 +208,10 @@ error:
return(-1); return(-1);
} }
int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data)
{ {
PMList *lp; pmlist_t *lp;
PMList *rmlist = NULL; pmlist_t *rmlist = NULL;
char rm_fname[PATH_MAX]; char rm_fname[PATH_MAX];
pmpkg_t *info = NULL; pmpkg_t *info = NULL;
@ -273,7 +273,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
/* Check for file conflicts /* Check for file conflicts
*/ */
if(!(trans->flags & PM_TRANS_FLAG_FORCE)) { if(!(trans->flags & PM_TRANS_FLAG_FORCE)) {
PMList *skiplist = NULL; pmlist_t *skiplist = NULL;
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL); EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
@ -314,7 +314,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
char expath[PATH_MAX], cwd[PATH_MAX] = "", *what; char expath[PATH_MAX], cwd[PATH_MAX] = "", *what;
unsigned char cb_state; unsigned char cb_state;
time_t t; time_t t;
PMList *targ, *lp; pmlist_t *targ, *lp;
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
@ -736,7 +736,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
* looking for packages depending on the package to add */ * looking for packages depending on the package to add */
for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) { for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) {
pmpkg_t *tmpp = lp->data; pmpkg_t *tmpp = lp->data;
PMList *tmppm = NULL; pmlist_t *tmppm = NULL;
if(tmpp == NULL) { if(tmpp == NULL) {
continue; continue;
} }
@ -782,7 +782,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
depinfo = _alpm_db_get_pkgfromcache(db, depend.name); depinfo = _alpm_db_get_pkgfromcache(db, depend.name);
if(depinfo == NULL) { if(depinfo == NULL) {
/* look for a provides package */ /* look for a provides package */
PMList *provides = _alpm_db_whatprovides(db, depend.name); pmlist_t *provides = _alpm_db_whatprovides(db, depend.name);
if(provides) { if(provides) {
/* TODO: should check _all_ packages listed in provides, not just /* TODO: should check _all_ packages listed in provides, not just
* the first one. * the first one.

View File

@ -26,7 +26,7 @@
#include "trans.h" #include "trans.h"
int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name); int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name);
int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data); int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data);
int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db); int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db);
#endif /* _ALPM_ADD_H */ #endif /* _ALPM_ADD_H */

View File

@ -100,7 +100,7 @@ int alpm_initialize(char *root)
*/ */
int alpm_release() int alpm_release()
{ {
PMList *i; pmlist_t *i;
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
@ -166,69 +166,17 @@ int alpm_get_option(unsigned char parm, long *data)
/** Register a package database /** Register a package database
* @param treename the name of the repository * @param treename the name of the repository
* @param callback a function to be called upon new database creation
* @return 0 on success, -1 on error (pm_errno is set accordingly) * @return 0 on success, -1 on error (pm_errno is set accordingly)
*/ */
pmdb_t *alpm_db_register(char *treename, alpm_cb_db_register callback) pmdb_t *alpm_db_register(char *treename)
{ {
struct stat buf;
pmdb_t *db;
char path[PATH_MAX];
/* Sanity checks */ /* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, NULL)); ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, NULL));
ASSERT(treename != NULL && strlen(treename) != 0, RET_ERR(PM_ERR_WRONG_ARGS, NULL)); ASSERT(treename != NULL && strlen(treename) != 0, RET_ERR(PM_ERR_WRONG_ARGS, NULL));
/* Do not register a database if a transaction is on-going */ /* Do not register a database if a transaction is on-going */
ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL)); ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL));
if(strcmp(treename, "local") == 0) { return(_alpm_db_register(treename, NULL));
if(handle->db_local != NULL) {
_alpm_log(PM_LOG_WARNING, _("attempt to re-register the 'local' DB\n"));
RET_ERR(PM_ERR_DB_NOT_NULL, NULL);
}
} else {
PMList *i;
for(i = handle->dbs_sync; i; i = i->next) {
pmdb_t *sdb = i->data;
if(strcmp(treename, sdb->treename) == 0) {
_alpm_log(PM_LOG_DEBUG, _("attempt to re-register the '%s' databse, using existing\n"), sdb->treename);
return sdb;
}
}
}
_alpm_log(PM_LOG_FLOW1, _("registering database '%s'"), treename);
/* make sure the database directory exists */
snprintf(path, PATH_MAX, "%s%s/%s", handle->root, handle->dbpath, treename);
if(stat(path, &buf) != 0 || !S_ISDIR(buf.st_mode)) {
_alpm_log(PM_LOG_FLOW1, _("database directory '%s' does not exist -- try creating it"), path);
if(_alpm_makepath(path) != 0) {
RET_ERR(PM_ERR_SYSTEM, NULL);
}
}
db = _alpm_db_new(handle->root, handle->dbpath, treename);
if(db == NULL) {
RET_ERR(PM_ERR_DB_CREATE, NULL);
}
_alpm_log(PM_LOG_DEBUG, _("opening database '%s'"), db->treename);
if(_alpm_db_open(db) == -1) {
_alpm_db_free(db);
RET_ERR(PM_ERR_DB_OPEN, NULL);
}
/* Only call callback on NEW registration. */
if(callback) callback(treename, db);
if(strcmp(treename, "local") == 0) {
handle->db_local = db;
} else {
handle->dbs_sync = _alpm_list_add(handle->dbs_sync, db);
}
return(db);
} }
/** Unregister a package database /** Unregister a package database
@ -324,7 +272,7 @@ int alpm_db_setserver(pmdb_t *db, char *url)
found = 1; found = 1;
} }
} else { } else {
PMList *i; pmlist_t *i;
for(i = handle->dbs_sync; i && !found; i = i->next) { for(i = handle->dbs_sync; i && !found; i = i->next) {
pmdb_t *sdb = i->data; pmdb_t *sdb = i->data;
if(strcmp(db->treename, sdb->treename) == 0) { if(strcmp(db->treename, sdb->treename) == 0) {
@ -361,9 +309,9 @@ int alpm_db_setserver(pmdb_t *db, char *url)
*/ */
int alpm_db_update(int force, PM_DB *db) int alpm_db_update(int force, PM_DB *db)
{ {
PMList *lp; pmlist_t *lp;
char path[PATH_MAX]; char path[PATH_MAX];
PMList *files = NULL; pmlist_t *files = NULL;
char newmtime[16] = ""; char newmtime[16] = "";
char lastupdate[16] = ""; char lastupdate[16] = "";
int ret; int ret;
@ -456,7 +404,7 @@ pmpkg_t *alpm_db_readpkg(pmdb_t *db, char *name)
* @param db pointer to the package database to get the package from * @param db pointer to the package database to get the package from
* @return the list of packages on success, NULL on error * @return the list of packages on success, NULL on error
*/ */
PMList *alpm_db_getpkgcache(pmdb_t *db) pmlist_t *alpm_db_getpkgcache(pmdb_t *db)
{ {
/* Sanity checks */ /* Sanity checks */
ASSERT(handle != NULL, return(NULL)); ASSERT(handle != NULL, return(NULL));
@ -470,7 +418,7 @@ PMList *alpm_db_getpkgcache(pmdb_t *db)
* @param name name of the package * @param name name of the package
* @return the list of packages on success, NULL on error * @return the list of packages on success, NULL on error
*/ */
PMList *alpm_db_whatprovides(pmdb_t *db, char *name) pmlist_t *alpm_db_whatprovides(pmdb_t *db, char *name)
{ {
/* Sanity checks */ /* Sanity checks */
ASSERT(handle != NULL, return(NULL)); ASSERT(handle != NULL, return(NULL));
@ -499,7 +447,7 @@ pmgrp_t *alpm_db_readgrp(pmdb_t *db, char *name)
* @param db pointer to the package database to get the group from * @param db pointer to the package database to get the group from
* @return the list of groups on success, NULL on error * @return the list of groups on success, NULL on error
*/ */
PMList *alpm_db_getgrpcache(pmdb_t *db) pmlist_t *alpm_db_getgrpcache(pmdb_t *db)
{ {
/* Sanity checks */ /* Sanity checks */
ASSERT(handle != NULL, return(NULL)); ASSERT(handle != NULL, return(NULL));
@ -624,6 +572,8 @@ void *alpm_pkg_getinfo(pmpkg_t *pkg, unsigned char parm)
*/ */
int alpm_pkg_load(char *filename, pmpkg_t **pkg) int alpm_pkg_load(char *filename, pmpkg_t **pkg)
{ {
_alpm_log(PM_LOG_FUNCTION, "enter alpm_pkg_load");
/* Sanity checks */ /* Sanity checks */
ASSERT(filename != NULL && strlen(filename) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1)); ASSERT(filename != NULL && strlen(filename) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1));
ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
@ -643,6 +593,8 @@ int alpm_pkg_load(char *filename, pmpkg_t **pkg)
*/ */
int alpm_pkg_free(pmpkg_t *pkg) int alpm_pkg_free(pmpkg_t *pkg)
{ {
_alpm_log(PM_LOG_FUNCTION, "enter alpm_pkg_free");
ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
/* Only free packages loaded in user space */ /* Only free packages loaded in user space */
@ -822,7 +774,7 @@ void *alpm_sync_getinfo(pmsyncpkg_t *sync, unsigned char parm)
* @param db pointer to the package database to search in * @param db pointer to the package database to search in
* @return the list of packages on success, NULL on error * @return the list of packages on success, NULL on error
*/ */
PMList *alpm_db_search(pmdb_t *db) pmlist_t *alpm_db_search(pmdb_t *db)
{ {
/* Sanity checks */ /* Sanity checks */
ASSERT(handle != NULL, return(NULL)); ASSERT(handle != NULL, return(NULL));
@ -940,7 +892,7 @@ int alpm_trans_addtarget(char *target)
* of an error can be dumped (ie. list of conflicting files) * of an error can be dumped (ie. list of conflicting files)
* @return 0 on success, -1 on error (pm_errno is set accordingly) * @return 0 on success, -1 on error (pm_errno is set accordingly)
*/ */
int alpm_trans_prepare(PMList **data) int alpm_trans_prepare(pmlist_t **data)
{ {
/* Sanity checks */ /* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
@ -957,7 +909,7 @@ int alpm_trans_prepare(PMList **data)
* of an error can be dumped (ie. list of conflicting files) * of an error can be dumped (ie. list of conflicting files)
* @return 0 on success, -1 on error (pm_errno is set accordingly) * @return 0 on success, -1 on error (pm_errno is set accordingly)
*/ */
int alpm_trans_commit(PMList **data) int alpm_trans_commit(pmlist_t **data)
{ {
/* Sanity checks */ /* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
@ -1122,7 +1074,7 @@ int alpm_logaction(char *fmt, ...)
* @param list the list * @param list the list
* @return the first element * @return the first element
*/ */
PMList *alpm_list_first(PMList *list) pmlist_t *alpm_list_first(pmlist_t *list)
{ {
return(list); return(list);
} }
@ -1131,7 +1083,7 @@ PMList *alpm_list_first(PMList *list)
* @param entry the list entry * @param entry the list entry
* @return the next element on success, NULL on error * @return the next element on success, NULL on error
*/ */
PMList *alpm_list_next(PMList *entry) pmlist_t *alpm_list_next(pmlist_t *entry)
{ {
ASSERT(entry != NULL, return(NULL)); ASSERT(entry != NULL, return(NULL));
@ -1142,7 +1094,7 @@ PMList *alpm_list_next(PMList *entry)
* @param entry the list entry * @param entry the list entry
* @return the data on success, NULL on error * @return the data on success, NULL on error
*/ */
void *alpm_list_getdata(PMList *entry) void *alpm_list_getdata(pmlist_t *entry)
{ {
ASSERT(entry != NULL, return(NULL)); ASSERT(entry != NULL, return(NULL));
@ -1153,7 +1105,7 @@ void *alpm_list_getdata(PMList *entry)
* @param entry list to free * @param entry list to free
* @return 0 on success, -1 on error * @return 0 on success, -1 on error
*/ */
int alpm_list_free(PMList *entry) int alpm_list_free(pmlist_t *entry)
{ {
ASSERT(entry != NULL, return(-1)); ASSERT(entry != NULL, return(-1));
@ -1166,7 +1118,7 @@ int alpm_list_free(PMList *entry)
* @param list the list to count * @param list the list to count
* @return number of entries on success, NULL on error * @return number of entries on success, NULL on error
*/ */
int alpm_list_count(PMList *list) int alpm_list_count(pmlist_t *list)
{ {
ASSERT(list != NULL, return(-1)); ASSERT(list != NULL, return(-1));
@ -1235,7 +1187,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
if(this_section != NULL && strlen(this_section) > 0) { if(this_section != NULL && strlen(this_section) > 0) {
strncpy(section, this_section, min(255, strlen(this_section))); strncpy(section, this_section, min(255, strlen(this_section)));
db = alpm_db_register(section, callback); db = _alpm_db_register(section, callback);
} }
while(fgets(line, PATH_MAX, fp)) { while(fgets(line, PATH_MAX, fp)) {
@ -1258,7 +1210,7 @@ int alpm_parse_config(char *file, alpm_cb_db_register callback, const char *this
RET_ERR(PM_ERR_CONF_LOCAL, -1); RET_ERR(PM_ERR_CONF_LOCAL, -1);
} }
if(strcmp(section, "options")) { if(strcmp(section, "options")) {
db = alpm_db_register(section, callback); db = _alpm_db_register(section, callback);
if(db == NULL) { if(db == NULL) {
/* pm_errno is set by alpm_db_register */ /* pm_errno is set by alpm_db_register */
return(-1); return(-1);

View File

@ -134,7 +134,7 @@ enum {
/* Database registration callback */ /* Database registration callback */
typedef void (*alpm_cb_db_register)(char *, PM_DB *); typedef void (*alpm_cb_db_register)(char *, PM_DB *);
PM_DB *alpm_db_register(char *treename, alpm_cb_db_register); PM_DB *alpm_db_register(char *treename);
int alpm_db_unregister(PM_DB *db); int alpm_db_unregister(PM_DB *db);
void *alpm_db_getinfo(PM_DB *db, unsigned char parm); void *alpm_db_getinfo(PM_DB *db, unsigned char parm);

View File

@ -31,9 +31,9 @@
/* Look for a filename in a pmpkg_t.backup list. If we find it, /* Look for a filename in a pmpkg_t.backup list. If we find it,
* then we return the md5 or sha1 hash (parsed from the same line) * then we return the md5 or sha1 hash (parsed from the same line)
*/ */
char *_alpm_needbackup(char *file, PMList *backup) char *_alpm_needbackup(char *file, pmlist_t *backup)
{ {
PMList *lp; pmlist_t *lp;
if(file == NULL || backup == NULL) { if(file == NULL || backup == NULL) {
return(NULL); return(NULL);

View File

@ -23,7 +23,7 @@
#include "list.h" #include "list.h"
char *_alpm_needbackup(char *file, PMList *backup); char *_alpm_needbackup(char *file, pmlist_t *backup);
#endif /* _ALPM_BACKUP_H */ #endif /* _ALPM_BACKUP_H */

View File

@ -165,7 +165,7 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
char path[PATH_MAX]; char path[PATH_MAX];
char line[512]; char line[512];
char *lang_tmp; char *lang_tmp;
PMList *tmplist; pmlist_t *tmplist;
char *foo; char *foo;
if(db == NULL || info == NULL || info->name[0] == 0 || info->version[0] == 0) { if(db == NULL || info == NULL || info->name[0] == 0 || info->version[0] == 0) {
@ -410,7 +410,7 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq)
FILE *fp = NULL; FILE *fp = NULL;
char path[PATH_MAX]; char path[PATH_MAX];
mode_t oldmask; mode_t oldmask;
PMList *lp = NULL; pmlist_t *lp = NULL;
int retval = 0; int retval = 0;
int local = 0; int local = 0;

View File

@ -82,7 +82,7 @@ void _alpm_db_free_pkgcache(pmdb_t *db)
} }
} }
PMList *_alpm_db_get_pkgcache(pmdb_t *db) pmlist_t *_alpm_db_get_pkgcache(pmdb_t *db)
{ {
if(db == NULL) { if(db == NULL) {
return(NULL); return(NULL);
@ -150,7 +150,7 @@ pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target)
*/ */
int _alpm_db_load_grpcache(pmdb_t *db) int _alpm_db_load_grpcache(pmdb_t *db)
{ {
PMList *lp; pmlist_t *lp;
if(db == NULL) { if(db == NULL) {
return(-1); return(-1);
@ -163,7 +163,7 @@ int _alpm_db_load_grpcache(pmdb_t *db)
_alpm_log(PM_LOG_DEBUG, _("loading group cache for repository '%s'"), db->treename); _alpm_log(PM_LOG_DEBUG, _("loading group cache for repository '%s'"), db->treename);
for(lp = db->pkgcache; lp; lp = lp->next) { for(lp = db->pkgcache; lp; lp = lp->next) {
PMList *i; pmlist_t *i;
pmpkg_t *pkg = lp->data; pmpkg_t *pkg = lp->data;
if(!(pkg->infolevel & INFRQ_DESC)) { if(!(pkg->infolevel & INFRQ_DESC)) {
@ -178,7 +178,7 @@ int _alpm_db_load_grpcache(pmdb_t *db)
grp->packages = _alpm_list_add_sorted(grp->packages, pkg->name, _alpm_grp_cmp); grp->packages = _alpm_list_add_sorted(grp->packages, pkg->name, _alpm_grp_cmp);
db->grpcache = _alpm_list_add_sorted(db->grpcache, grp, _alpm_grp_cmp); db->grpcache = _alpm_list_add_sorted(db->grpcache, grp, _alpm_grp_cmp);
} else { } else {
PMList *j; pmlist_t *j;
for(j = db->grpcache; j; j = j->next) { for(j = db->grpcache; j; j = j->next) {
pmgrp_t *grp = j->data; pmgrp_t *grp = j->data;
@ -198,7 +198,7 @@ int _alpm_db_load_grpcache(pmdb_t *db)
void _alpm_db_free_grpcache(pmdb_t *db) void _alpm_db_free_grpcache(pmdb_t *db)
{ {
PMList *lg; pmlist_t *lg;
if(db == NULL || db->grpcache == NULL) { if(db == NULL || db->grpcache == NULL) {
return; return;
@ -213,7 +213,7 @@ void _alpm_db_free_grpcache(pmdb_t *db)
FREELIST(db->grpcache); FREELIST(db->grpcache);
} }
PMList *_alpm_db_get_grpcache(pmdb_t *db) pmlist_t *_alpm_db_get_grpcache(pmdb_t *db)
{ {
if(db == NULL) { if(db == NULL) {
return(NULL); return(NULL);
@ -228,7 +228,7 @@ PMList *_alpm_db_get_grpcache(pmdb_t *db)
pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, char *target) pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, char *target)
{ {
PMList *i; pmlist_t *i;
if(db == NULL || target == NULL || strlen(target) == 0) { if(db == NULL || target == NULL || strlen(target) == 0) {
return(NULL); return(NULL);

View File

@ -31,12 +31,12 @@ int _alpm_db_load_pkgcache(pmdb_t *db);
void _alpm_db_free_pkgcache(pmdb_t *db); void _alpm_db_free_pkgcache(pmdb_t *db);
int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg); int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg);
int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg); int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg);
PMList *_alpm_db_get_pkgcache(pmdb_t *db); pmlist_t *_alpm_db_get_pkgcache(pmdb_t *db);
pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target); pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target);
/* groups */ /* groups */
int _alpm_db_load_grpcache(pmdb_t *db); int _alpm_db_load_grpcache(pmdb_t *db);
void _alpm_db_free_grpcache(pmdb_t *db); void _alpm_db_free_grpcache(pmdb_t *db);
PMList *_alpm_db_get_grpcache(pmdb_t *db); pmlist_t *_alpm_db_get_grpcache(pmdb_t *db);
pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, char *target); pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, char *target);
#endif /* _ALPM_CACHE_H */ #endif /* _ALPM_CACHE_H */

View File

@ -42,15 +42,15 @@
#include "deps.h" #include "deps.h"
#include "conflict.h" #include "conflict.h"
/* Returns a PMList* of pmdepmissing_t pointers. /* Returns a pmlist_t* of pmdepmissing_t pointers.
* *
* conflicts are always name only * conflicts are always name only
*/ */
PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages)
{ {
pmpkg_t *info = NULL; pmpkg_t *info = NULL;
PMList *i, *j, *k; pmlist_t *i, *j, *k;
PMList *baddeps = NULL; pmlist_t *baddeps = NULL;
pmdepmissing_t *miss = NULL; pmdepmissing_t *miss = NULL;
if(db == NULL) { if(db == NULL) {
@ -88,7 +88,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages)
} }
} else { } else {
/* see if dp provides something in tp's conflict list */ /* see if dp provides something in tp's conflict list */
PMList *m; pmlist_t *m;
for(m = dp->provides; m; m = m->next) { for(m = dp->provides; m; m = m->next) {
if(!strcmp(m->data, j->data)) { if(!strcmp(m->data, j->data)) {
/* confict */ /* confict */
@ -124,7 +124,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages)
} }
} else { } else {
/* see if otp provides something in tp's conflict list */ /* see if otp provides something in tp's conflict list */
PMList *m; pmlist_t *m;
for(m = otp->provides; m; m = m->next) { for(m = otp->provides; m; m = m->next) {
if(!strcmp(m->data, j->data)) { if(!strcmp(m->data, j->data)) {
_alpm_log(PM_LOG_DEBUG, _("targs vs targs: found %s as a conflict for %s"), _alpm_log(PM_LOG_DEBUG, _("targs vs targs: found %s as a conflict for %s"),
@ -143,7 +143,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages)
/* CHECK 3: check database against targets */ /* CHECK 3: check database against targets */
_alpm_log(PM_LOG_DEBUG, _("checkconflicts: db vs targ '%s'"), tp->name); _alpm_log(PM_LOG_DEBUG, _("checkconflicts: db vs targ '%s'"), tp->name);
for(k = _alpm_db_get_pkgcache(db); k; k = k->next) { for(k = _alpm_db_get_pkgcache(db); k; k = k->next) {
PMList *conflicts = NULL; pmlist_t *conflicts = NULL;
int usenewconflicts = 0; int usenewconflicts = 0;
info = k->data; info = k->data;
@ -151,7 +151,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages)
/* a package cannot conflict with itself -- that's just not nice */ /* a package cannot conflict with itself -- that's just not nice */
continue; continue;
} }
/* If this package (*info) is also in our packages PMList, use the /* If this package (*info) is also in our packages pmlist_t, use the
* conflicts list from the new package, not the old one (*info) * conflicts list from the new package, not the old one (*info)
*/ */
for(j = packages; j; j = j->next) { for(j = packages; j; j = j->next) {
@ -178,9 +178,9 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages)
} }
} else { } else {
/* see if the db package conflicts with something we provide */ /* see if the db package conflicts with something we provide */
PMList *m; pmlist_t *m;
for(m = conflicts; m; m = m->next) { for(m = conflicts; m; m = m->next) {
PMList *n; pmlist_t *n;
for(n = tp->provides; n; n = n->next) { for(n = tp->provides; n; n = n->next) {
if(!strcmp(m->data, n->data)) { if(!strcmp(m->data, n->data)) {
_alpm_log(PM_LOG_DEBUG, _("db vs targs: found %s as a conflict for %s"), _alpm_log(PM_LOG_DEBUG, _("db vs targs: found %s as a conflict for %s"),
@ -202,14 +202,14 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages)
return(baddeps); return(baddeps);
} }
PMList *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, PMList **skip_list) pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmlist_t **skip_list)
{ {
PMList *i, *j, *k; pmlist_t *i, *j, *k;
char *filestr = NULL; char *filestr = NULL;
char path[PATH_MAX+1]; char path[PATH_MAX+1];
struct stat buf, buf2; struct stat buf, buf2;
PMList *conflicts = NULL; pmlist_t *conflicts = NULL;
PMList *targets = trans->packages; pmlist_t *targets = trans->packages;
double percent; double percent;
if(db == NULL || targets == NULL || root == NULL) { if(db == NULL || targets == NULL || root == NULL) {

View File

@ -32,8 +32,8 @@ typedef struct __pmconflict_t {
char ctarget[PKG_NAME_LEN]; char ctarget[PKG_NAME_LEN];
} pmconflict_t; } pmconflict_t;
PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages); pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages);
PMList *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, PMList **skip_list); pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmlist_t **skip_list);
#endif /* _ALPM_CONFLICT_H */ #endif /* _ALPM_CONFLICT_H */

View File

@ -59,14 +59,14 @@ pmdb_t *_alpm_db_new(char *root, char* dbpath, char *treename)
db = (pmdb_t *)malloc(sizeof(pmdb_t)); db = (pmdb_t *)malloc(sizeof(pmdb_t));
if(db == NULL) { if(db == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"), _alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"),
sizeof(pmdb_t)); sizeof(pmdb_t));
RET_ERR(PM_ERR_MEMORY, NULL); RET_ERR(PM_ERR_MEMORY, NULL);
} }
db->path = (char *)malloc(strlen(root)+strlen(dbpath)+strlen(treename)+2); db->path = (char *)malloc(strlen(root)+strlen(dbpath)+strlen(treename)+2);
if(db->path == NULL) { if(db->path == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"), _alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"),
strlen(root)+strlen(dbpath)+strlen(treename)+2); strlen(root)+strlen(dbpath)+strlen(treename)+2);
FREE(db); FREE(db);
RET_ERR(PM_ERR_MEMORY, NULL); RET_ERR(PM_ERR_MEMORY, NULL);
} }
@ -97,9 +97,9 @@ int _alpm_db_cmp(const void *db1, const void *db2)
return(strcmp(((pmdb_t *)db1)->treename, ((pmdb_t *)db2)->treename)); return(strcmp(((pmdb_t *)db1)->treename, ((pmdb_t *)db2)->treename));
} }
PMList *_alpm_db_search(pmdb_t *db, PMList *needles) pmlist_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles)
{ {
PMList *i, *j, *k, *ret = NULL; pmlist_t *i, *j, *k, *ret = NULL;
for(i = needles; i; i = i->next) { for(i = needles; i; i = i->next) {
char *targ; char *targ;
@ -109,6 +109,7 @@ PMList *_alpm_db_search(pmdb_t *db, PMList *needles)
continue; continue;
} }
targ = strdup(i->data); targ = strdup(i->data);
_alpm_log(PM_LOG_DEBUG, "searching for target '%s'\n", targ);
for(j = _alpm_db_get_pkgcache(db); j; j = j->next) { for(j = _alpm_db_get_pkgcache(db); j; j = j->next) {
pmpkg_t *pkg = j->data; pmpkg_t *pkg = j->data;
@ -123,7 +124,9 @@ PMList *_alpm_db_search(pmdb_t *db, PMList *needles)
FREE(haystack); FREE(haystack);
return(NULL); return(NULL);
} else if(retval) { } else if(retval) {
_alpm_log(PM_LOG_DEBUG, " search target '%s' matched '%s'", targ, haystack);
match = 1; match = 1;
} else {
} }
FREE(haystack); FREE(haystack);
@ -167,4 +170,60 @@ PMList *_alpm_db_search(pmdb_t *db, PMList *needles)
return(ret); return(ret);
} }
/* vim: set ts=2 sw=2 noet: */
pmdb_t *_alpm_db_register(char *treename, alpm_cb_db_register callback)
{
struct stat buf;
pmdb_t *db;
char path[PATH_MAX];
if(strcmp(treename, "local") == 0) {
if(handle->db_local != NULL) {
_alpm_log(PM_LOG_WARNING, _("attempt to re-register the 'local' DB\n"));
RET_ERR(PM_ERR_DB_NOT_NULL, NULL);
}
} else {
pmlist_t *i;
for(i = handle->dbs_sync; i; i = i->next) {
pmdb_t *sdb = i->data;
if(strcmp(treename, sdb->treename) == 0) {
_alpm_log(PM_LOG_DEBUG, _("attempt to re-register the '%s' databse, using existing\n"), sdb->treename);
return sdb;
}
}
}
_alpm_log(PM_LOG_FLOW1, _("registering database '%s'"), treename);
/* make sure the database directory exists */
snprintf(path, PATH_MAX, "%s%s/%s", handle->root, handle->dbpath, treename);
if(stat(path, &buf) != 0 || !S_ISDIR(buf.st_mode)) {
_alpm_log(PM_LOG_FLOW1, _("database directory '%s' does not exist -- try creating it"), path);
if(_alpm_makepath(path) != 0) {
RET_ERR(PM_ERR_SYSTEM, NULL);
}
}
db = _alpm_db_new(handle->root, handle->dbpath, treename);
if(db == NULL) {
RET_ERR(PM_ERR_DB_CREATE, NULL);
}
_alpm_log(PM_LOG_DEBUG, _("opening database '%s'"), db->treename);
if(_alpm_db_open(db) == -1) {
_alpm_db_free(db);
RET_ERR(PM_ERR_DB_OPEN, NULL);
}
/* Only call callback on NEW registration. */
if(callback) callback(treename, db);
if(strcmp(treename, "local") == 0) {
handle->db_local = db;
} else {
handle->dbs_sync = _alpm_list_add(handle->dbs_sync, db);
}
return(db);
}
/* vim: set noet: */

View File

@ -25,6 +25,7 @@
#include <limits.h> #include <limits.h>
#include "package.h" #include "package.h"
#include "alpm.h"
/* Database entries */ /* Database entries */
#define INFRQ_NONE 0x00 #define INFRQ_NONE 0x00
@ -41,15 +42,15 @@ typedef struct __pmdb_t {
char *path; char *path;
char treename[PATH_MAX]; char treename[PATH_MAX];
void *handle; void *handle;
PMList *pkgcache; pmlist_t *pkgcache;
PMList *grpcache; pmlist_t *grpcache;
PMList *servers; pmlist_t *servers;
} pmdb_t; } pmdb_t;
pmdb_t *_alpm_db_new(char *root, char *dbpath, char *treename); pmdb_t *_alpm_db_new(char *root, char *dbpath, char *treename);
void _alpm_db_free(void *data); void _alpm_db_free(void *data);
int _alpm_db_cmp(const void *db1, const void *db2); int _alpm_db_cmp(const void *db1, const void *db2);
PMList *_alpm_db_search(pmdb_t *db, PMList *needles); pmlist_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles);
/* Prototypes for backends functions */ /* Prototypes for backends functions */
int _alpm_db_open(pmdb_t *db); int _alpm_db_open(pmdb_t *db);
void _alpm_db_close(pmdb_t *db); void _alpm_db_close(pmdb_t *db);
@ -60,6 +61,7 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq);
int _alpm_db_remove(pmdb_t *db, pmpkg_t *info); int _alpm_db_remove(pmdb_t *db, pmpkg_t *info);
int _alpm_db_getlastupdate(pmdb_t *db, char *ts); int _alpm_db_getlastupdate(pmdb_t *db, char *ts);
int _alpm_db_setlastupdate(pmdb_t *db, char *ts); int _alpm_db_setlastupdate(pmdb_t *db, char *ts);
pmdb_t *_alpm_db_register(char *treename, alpm_cb_db_register callback);
#endif /* _ALPM_DB_H */ #endif /* _ALPM_DB_H */

View File

@ -68,9 +68,9 @@ pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsign
return(miss); return(miss);
} }
int _alpm_depmiss_isin(pmdepmissing_t *needle, PMList *haystack) int _alpm_depmiss_isin(pmdepmissing_t *needle, pmlist_t *haystack)
{ {
PMList *i; pmlist_t *i;
for(i = haystack; i; i = i->next) { for(i = haystack; i; i = i->next) {
pmdepmissing_t *miss = i->data; pmdepmissing_t *miss = i->data;
@ -95,13 +95,13 @@ int _alpm_depmiss_isin(pmdepmissing_t *needle, PMList *haystack)
* mode should be either PM_TRANS_TYPE_ADD or PM_TRANS_TYPE_REMOVE. This * mode should be either PM_TRANS_TYPE_ADD or PM_TRANS_TYPE_REMOVE. This
* affects the dependency order sortbydeps() will use. * affects the dependency order sortbydeps() will use.
* *
* This function returns the new PMList* target list. * This function returns the new pmlist_t* target list.
* *
*/ */
PMList *_alpm_sortbydeps(PMList *targets, int mode) pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode)
{ {
PMList *newtargs = NULL; pmlist_t *newtargs = NULL;
PMList *i, *j, *k, *l; pmlist_t *i, *j, *k, *l;
int change = 1; int change = 1;
int numscans = 0; int numscans = 0;
int numtargs = 0; int numtargs = 0;
@ -117,7 +117,7 @@ PMList *_alpm_sortbydeps(PMList *targets, int mode)
_alpm_log(PM_LOG_DEBUG, _("started sorting dependencies")); _alpm_log(PM_LOG_DEBUG, _("started sorting dependencies"));
while(change) { while(change) {
PMList *tmptargs = NULL; pmlist_t *tmptargs = NULL;
change = 0; change = 0;
if(numscans > sqrt(numtargs)) { if(numscans > sqrt(numtargs)) {
_alpm_log(PM_LOG_DEBUG, _("possible dependency cycle detected")); _alpm_log(PM_LOG_DEBUG, _("possible dependency cycle detected"));
@ -167,7 +167,7 @@ PMList *_alpm_sortbydeps(PMList *targets, int mode)
if(mode == PM_TRANS_TYPE_REMOVE) { if(mode == PM_TRANS_TYPE_REMOVE) {
/* we're removing packages, so reverse the order */ /* we're removing packages, so reverse the order */
PMList *tmptargs = _alpm_list_reverse(newtargs); pmlist_t *tmptargs = _alpm_list_reverse(newtargs);
/* free the old one */ /* free the old one */
FREELISTPTR(newtargs); FREELISTPTR(newtargs);
newtargs = tmptargs; newtargs = tmptargs;
@ -176,18 +176,18 @@ PMList *_alpm_sortbydeps(PMList *targets, int mode)
return(newtargs); return(newtargs);
} }
/* Returns a PMList* of missing_t pointers. /* Returns a pmlist_t* of missing_t pointers.
* *
* dependencies can include versions with depmod operators. * dependencies can include versions with depmod operators.
* *
*/ */
PMList *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, PMList *packages) pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist_t *packages)
{ {
pmdepend_t depend; pmdepend_t depend;
PMList *i, *j, *k; pmlist_t *i, *j, *k;
int cmp; int cmp;
int found = 0; int found = 0;
PMList *baddeps = NULL; pmlist_t *baddeps = NULL;
pmdepmissing_t *miss = NULL; pmdepmissing_t *miss = NULL;
if(db == NULL) { if(db == NULL) {
@ -229,7 +229,7 @@ PMList *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, PMList *
} }
if(found == 0) { if(found == 0) {
/* look for packages that list depend.name as a "provide" */ /* look for packages that list depend.name as a "provide" */
PMList *provides = _alpm_db_whatprovides(db, depend.name); pmlist_t *provides = _alpm_db_whatprovides(db, depend.name);
if(provides == NULL) { if(provides == NULL) {
/* not found */ /* not found */
continue; continue;
@ -462,15 +462,15 @@ int _alpm_splitdep(char *depstr, pmdepend_t *depend)
return(0); return(0);
} }
/* return a new PMList target list containing all packages in the original /* return a new pmlist_t target list containing all packages in the original
* target list, as well as all their un-needed dependencies. By un-needed, * target list, as well as all their un-needed dependencies. By un-needed,
* I mean dependencies that are *only* required for packages in the target * I mean dependencies that are *only* required for packages in the target
* list, so they can be safely removed. This function is recursive. * list, so they can be safely removed. This function is recursive.
*/ */
PMList *_alpm_removedeps(pmdb_t *db, PMList *targs) pmlist_t *_alpm_removedeps(pmdb_t *db, pmlist_t *targs)
{ {
PMList *i, *j, *k; pmlist_t *i, *j, *k;
PMList *newtargs = targs; pmlist_t *newtargs = targs;
if(db == NULL) { if(db == NULL) {
return(newtargs); return(newtargs);
@ -542,12 +542,12 @@ PMList *_alpm_removedeps(pmdb_t *db, PMList *targs)
* *
* make sure *list and *trail are already initialized * make sure *list and *trail are already initialized
*/ */
int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlist_t *list,
PMList *trail, pmtrans_t *trans, PMList **data) pmlist_t *trail, pmtrans_t *trans, pmlist_t **data)
{ {
PMList *i, *j; pmlist_t *i, *j;
PMList *targ; pmlist_t *targ;
PMList *deps = NULL; pmlist_t *deps = NULL;
if(local == NULL || dbs_sync == NULL || syncpkg == NULL) { if(local == NULL || dbs_sync == NULL || syncpkg == NULL) {
return(-1); return(-1);
@ -586,7 +586,7 @@ int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList
} }
/* check provides */ /* check provides */
for(j = dbs_sync; !sync && j; j = j->next) { for(j = dbs_sync; !sync && j; j = j->next) {
PMList *provides; pmlist_t *provides;
provides = _alpm_db_whatprovides(j->data, miss->depend.name); provides = _alpm_db_whatprovides(j->data, miss->depend.name);
if(provides) { if(provides) {
sync = provides->data; sync = provides->data;

View File

@ -40,13 +40,13 @@ typedef struct __pmdepmissing_t {
pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsigned char depmod, pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsigned char depmod,
const char *depname, const char *depversion); const char *depname, const char *depversion);
int _alpm_depmiss_isin(pmdepmissing_t *needle, PMList *haystack); int _alpm_depmiss_isin(pmdepmissing_t *needle, pmlist_t *haystack);
PMList *_alpm_sortbydeps(PMList *targets, int mode); pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode);
PMList *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, PMList *packages); pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist_t *packages);
int _alpm_splitdep(char *depstr, pmdepend_t *depend); int _alpm_splitdep(char *depstr, pmdepend_t *depend);
PMList *_alpm_removedeps(pmdb_t *db, PMList *targs); pmlist_t *_alpm_removedeps(pmdb_t *db, pmlist_t *targs);
int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlist_t *list,
PMList *trail, pmtrans_t *trans, PMList **data); pmlist_t *trail, pmtrans_t *trans, pmlist_t **data);
#endif /* _ALPM_DEPS_H */ #endif /* _ALPM_DEPS_H */

View File

@ -28,7 +28,7 @@
/* Groups structure */ /* Groups structure */
typedef struct __pmgrp_t { typedef struct __pmgrp_t {
char name[GRP_NAME_LEN]; char name[GRP_NAME_LEN];
PMList *packages; /* List of strings */ pmlist_t *packages; /* List of strings */
} pmgrp_t; } pmgrp_t;
#define FREEGRP(p) do { if(p) { _alpm_grp_free(p); p = NULL; } } while(0) #define FREEGRP(p) do { if(p) { _alpm_grp_free(p); p = NULL; } } while(0)

View File

@ -35,7 +35,7 @@ typedef struct __pmhandle_t {
pmaccess_t access; pmaccess_t access;
uid_t uid; uid_t uid;
pmdb_t *db_local; pmdb_t *db_local;
PMList *dbs_sync; /* List of (pmdb_t *) */ pmlist_t *dbs_sync; /* List of (pmdb_t *) */
FILE *logfd; FILE *logfd;
int lckfd; int lckfd;
pmtrans_t *trans; pmtrans_t *trans;
@ -44,10 +44,10 @@ typedef struct __pmhandle_t {
char *dbpath; char *dbpath;
char *cachedir; char *cachedir;
char *logfile; char *logfile;
PMList *noupgrade; /* List of strings */ pmlist_t *noupgrade; /* List of strings */
PMList *noextract; /* List of strings */ pmlist_t *noextract; /* List of strings */
PMList *ignorepkg; /* List of strings */ pmlist_t *ignorepkg; /* List of strings */
PMList *holdpkg; /* List of strings */ pmlist_t *holdpkg; /* List of strings */
unsigned char usesyslog; unsigned char usesyslog;
time_t upgradedelay; time_t upgradedelay;
/* servers */ /* servers */
@ -56,7 +56,7 @@ typedef struct __pmhandle_t {
char *xfercommand; char *xfercommand;
unsigned short nopassiveftp; unsigned short nopassiveftp;
unsigned short chomp; /* if eye-candy features should be enabled or not */ unsigned short chomp; /* if eye-candy features should be enabled or not */
PMList *needles; /* for searching */ pmlist_t *needles; /* for searching */
} pmhandle_t; } pmhandle_t;
#define FREEHANDLE(p) do { if (p) { _alpm_handle_free(p); p = NULL; } } while (0) #define FREEHANDLE(p) do { if (p) { _alpm_handle_free(p); p = NULL; } } while (0)

View File

@ -27,11 +27,11 @@
/* pacman */ /* pacman */
#include "list.h" #include "list.h"
PMList *_alpm_list_new() pmlist_t *_alpm_list_new()
{ {
PMList *list = NULL; pmlist_t *list = NULL;
list = (PMList *)malloc(sizeof(PMList)); list = (pmlist_t *)malloc(sizeof(pmlist_t));
if(list == NULL) { if(list == NULL) {
return(NULL); return(NULL);
} }
@ -42,9 +42,9 @@ PMList *_alpm_list_new()
return(list); return(list);
} }
void _alpm_list_free(PMList *list, _alpm_fn_free fn) void _alpm_list_free(pmlist_t *list, _alpm_fn_free fn)
{ {
PMList *ptr, *it = list; pmlist_t *ptr, *it = list;
while(it) { while(it) {
ptr = it->next; ptr = it->next;
@ -56,9 +56,9 @@ void _alpm_list_free(PMList *list, _alpm_fn_free fn)
} }
} }
PMList *_alpm_list_add(PMList *list, void *data) pmlist_t *_alpm_list_add(pmlist_t *list, void *data)
{ {
PMList *ptr, *lp; pmlist_t *ptr, *lp;
ptr = list; ptr = list;
if(ptr == NULL) { if(ptr == NULL) {
@ -90,11 +90,11 @@ PMList *_alpm_list_add(PMList *list, void *data)
/* Add items to a list in sorted order. Use the given comparision func to /* Add items to a list in sorted order. Use the given comparision func to
* determine order. * determine order.
*/ */
PMList *_alpm_list_add_sorted(PMList *list, void *data, _alpm_fn_cmp fn) pmlist_t *_alpm_list_add_sorted(pmlist_t *list, void *data, _alpm_fn_cmp fn)
{ {
PMList *add; pmlist_t *add;
PMList *prev = NULL; pmlist_t *prev = NULL;
PMList *iter = list; pmlist_t *iter = list;
add = _alpm_list_new(); add = _alpm_list_new();
add->data = data; add->data = data;
@ -139,9 +139,9 @@ PMList *_alpm_list_add_sorted(PMList *list, void *data, _alpm_fn_cmp fn)
* Otherwise, it is set to NULL. * Otherwise, it is set to NULL.
* Return the new list (without the removed element). * Return the new list (without the removed element).
*/ */
PMList *_alpm_list_remove(PMList *haystack, void *needle, _alpm_fn_cmp fn, void **data) pmlist_t *_alpm_list_remove(pmlist_t *haystack, void *needle, _alpm_fn_cmp fn, void **data)
{ {
PMList *i = haystack; pmlist_t *i = haystack;
if(data) { if(data) {
*data = NULL; *data = NULL;
@ -186,19 +186,19 @@ PMList *_alpm_list_remove(PMList *haystack, void *needle, _alpm_fn_cmp fn, void
return(haystack); return(haystack);
} }
int _alpm_list_count(PMList *list) int _alpm_list_count(pmlist_t *list)
{ {
int i; int i;
PMList *lp; pmlist_t *lp;
for(lp = list, i = 0; lp; lp = lp->next, i++); for(lp = list, i = 0; lp; lp = lp->next, i++);
return(i); return(i);
} }
int _alpm_list_is_in(void *needle, PMList *haystack) int _alpm_list_is_in(void *needle, pmlist_t *haystack)
{ {
PMList *lp; pmlist_t *lp;
for(lp = haystack; lp; lp = lp->next) { for(lp = haystack; lp; lp = lp->next) {
if(lp->data == needle) { if(lp->data == needle) {
@ -208,11 +208,11 @@ int _alpm_list_is_in(void *needle, PMList *haystack)
return(0); return(0);
} }
/* Test for existence of a string in a PMList /* Test for existence of a string in a pmlist_t
*/ */
int _alpm_list_is_strin(char *needle, PMList *haystack) int _alpm_list_is_strin(char *needle, pmlist_t *haystack)
{ {
PMList *lp; pmlist_t *lp;
for(lp = haystack; lp; lp = lp->next) { for(lp = haystack; lp; lp = lp->next) {
if(lp->data && !strcmp(lp->data, needle)) { if(lp->data && !strcmp(lp->data, needle)) {
@ -222,7 +222,7 @@ int _alpm_list_is_strin(char *needle, PMList *haystack)
return(0); return(0);
} }
PMList *_alpm_list_last(PMList *list) pmlist_t *_alpm_list_last(pmlist_t *list)
{ {
if(list == NULL) { if(list == NULL) {
return(NULL); return(NULL);
@ -239,9 +239,9 @@ PMList *_alpm_list_last(PMList *list)
* a new list, using is_in() to check for dupes at each iteration. * a new list, using is_in() to check for dupes at each iteration.
* *
*/ */
PMList *_alpm_list_remove_dupes(PMList *list) pmlist_t *_alpm_list_remove_dupes(pmlist_t *list)
{ {
PMList *i, *newlist = NULL; pmlist_t *i, *newlist = NULL;
for(i = list; i; i = i->next) { for(i = list; i; i = i->next) {
if(!_alpm_list_is_strin(i->data, newlist)) { if(!_alpm_list_is_strin(i->data, newlist)) {
@ -255,13 +255,13 @@ PMList *_alpm_list_remove_dupes(PMList *list)
* *
* The caller is responsible for freeing the old list * The caller is responsible for freeing the old list
*/ */
PMList *_alpm_list_reverse(PMList *list) pmlist_t *_alpm_list_reverse(pmlist_t *list)
{ {
/* simple but functional -- we just build a new list, starting /* simple but functional -- we just build a new list, starting
* with the old list's tail * with the old list's tail
*/ */
PMList *newlist = NULL; pmlist_t *newlist = NULL;
PMList *lp; pmlist_t *lp;
for(lp = list->last; lp; lp = lp->prev) { for(lp = list->last; lp; lp = lp->prev) {
newlist = _alpm_list_add(newlist, lp->data); newlist = _alpm_list_add(newlist, lp->data);
@ -270,10 +270,10 @@ PMList *_alpm_list_reverse(PMList *list)
return(newlist); return(newlist);
} }
PMList *_alpm_list_strdup(PMList *list) pmlist_t *_alpm_list_strdup(pmlist_t *list)
{ {
PMList *newlist = NULL; pmlist_t *newlist = NULL;
PMList *lp; pmlist_t *lp;
for(lp = list; lp; lp = lp->next) { for(lp = list; lp; lp = lp->next) {
newlist = _alpm_list_add(newlist, strdup(lp->data)); newlist = _alpm_list_add(newlist, strdup(lp->data));

View File

@ -29,8 +29,6 @@ typedef struct __pmlist_t {
struct __pmlist_t *last; /* Quick access to last item in list */ struct __pmlist_t *last; /* Quick access to last item in list */
} pmlist_t; } pmlist_t;
typedef struct __pmlist_t PMList;
#define _FREELIST(p, f) do { if(p) { _alpm_list_free(p, f); p = NULL; } } while(0) #define _FREELIST(p, f) do { if(p) { _alpm_list_free(p, f); p = NULL; } } while(0)
#define FREELIST(p) _FREELIST(p, free) #define FREELIST(p) _FREELIST(p, free)
#define FREELISTPTR(p) _FREELIST(p, NULL) #define FREELISTPTR(p) _FREELIST(p, NULL)
@ -39,18 +37,18 @@ typedef void (*_alpm_fn_free)(void *);
/* Sort comparison callback function declaration */ /* Sort comparison callback function declaration */
typedef int (*_alpm_fn_cmp)(const void *, const void *); typedef int (*_alpm_fn_cmp)(const void *, const void *);
PMList *_alpm_list_new(void); pmlist_t *_alpm_list_new(void);
void _alpm_list_free(PMList *list, _alpm_fn_free fn); void _alpm_list_free(pmlist_t *list, _alpm_fn_free fn);
PMList *_alpm_list_add(PMList *list, void *data); pmlist_t *_alpm_list_add(pmlist_t *list, void *data);
PMList *_alpm_list_add_sorted(PMList *list, void *data, _alpm_fn_cmp fn); pmlist_t *_alpm_list_add_sorted(pmlist_t *list, void *data, _alpm_fn_cmp fn);
PMList *_alpm_list_remove(PMList *haystack, void *needle, _alpm_fn_cmp fn, void **data); pmlist_t *_alpm_list_remove(pmlist_t *haystack, void *needle, _alpm_fn_cmp fn, void **data);
int _alpm_list_count(PMList *list); int _alpm_list_count(pmlist_t *list);
int _alpm_list_is_in(void *needle, PMList *haystack); int _alpm_list_is_in(void *needle, pmlist_t *haystack);
int _alpm_list_is_strin(char *needle, PMList *haystack); int _alpm_list_is_strin(char *needle, pmlist_t *haystack);
PMList *_alpm_list_last(PMList *list); pmlist_t *_alpm_list_last(pmlist_t *list);
PMList *_alpm_list_remove_dupes(PMList *list); pmlist_t *_alpm_list_remove_dupes(pmlist_t *list);
PMList *_alpm_list_reverse(PMList *list); pmlist_t *_alpm_list_reverse(pmlist_t *list);
PMList *_alpm_list_strdup(PMList *list); pmlist_t *_alpm_list_strdup(pmlist_t *list);
#endif /* _ALPM_LIST_H */ #endif /* _ALPM_LIST_H */

View File

@ -414,12 +414,12 @@ error:
return(NULL); return(NULL);
} }
/* Test for existence of a package in a PMList* /* Test for existence of a package in a pmlist_t*
* of pmpkg_t* * of pmpkg_t*
*/ */
pmpkg_t *_alpm_pkg_isin(char *needle, PMList *haystack) pmpkg_t *_alpm_pkg_isin(char *needle, pmlist_t *haystack)
{ {
PMList *lp; pmlist_t *lp;
if(needle == NULL || haystack == NULL) { if(needle == NULL || haystack == NULL) {
return(NULL); return(NULL);

View File

@ -65,17 +65,17 @@ typedef struct __pmpkg_t {
unsigned char force; unsigned char force;
time_t date; time_t date;
unsigned char reason; unsigned char reason;
PMList *desc_localized; pmlist_t *desc_localized;
PMList *license; pmlist_t *license;
PMList *replaces; pmlist_t *replaces;
PMList *groups; pmlist_t *groups;
PMList *files; pmlist_t *files;
PMList *backup; pmlist_t *backup;
PMList *depends; pmlist_t *depends;
PMList *removes; pmlist_t *removes;
PMList *requiredby; pmlist_t *requiredby;
PMList *conflicts; pmlist_t *conflicts;
PMList *provides; pmlist_t *provides;
/* internal */ /* internal */
unsigned char origin; unsigned char origin;
void *data; void *data;
@ -97,7 +97,7 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg);
void _alpm_pkg_free(void *data); void _alpm_pkg_free(void *data);
int _alpm_pkg_cmp(const void *p1, const void *p2); int _alpm_pkg_cmp(const void *p1, const void *p2);
pmpkg_t *_alpm_pkg_load(char *pkgfile); pmpkg_t *_alpm_pkg_load(char *pkgfile);
pmpkg_t *_alpm_pkg_isin(char *needle, PMList *haystack); pmpkg_t *_alpm_pkg_isin(char *needle, pmlist_t *haystack);
int _alpm_pkg_splitname(char *target, char *name, char *version); int _alpm_pkg_splitname(char *target, char *name, char *version);
#endif /* _ALPM_PACKAGE_H */ #endif /* _ALPM_PACKAGE_H */

View File

@ -28,12 +28,12 @@
#include "db.h" #include "db.h"
#include "provide.h" #include "provide.h"
/* return a PMList of packages in "db" that provide "package" /* return a pmlist_t of packages in "db" that provide "package"
*/ */
PMList *_alpm_db_whatprovides(pmdb_t *db, char *package) pmlist_t *_alpm_db_whatprovides(pmdb_t *db, char *package)
{ {
PMList *pkgs = NULL; pmlist_t *pkgs = NULL;
PMList *lp; pmlist_t *lp;
if(db == NULL || package == NULL || strlen(package) == 0) { if(db == NULL || package == NULL || strlen(package) == 0) {
return(NULL); return(NULL);

View File

@ -26,7 +26,7 @@
#include "list.h" #include "list.h"
#include "db.h" #include "db.h"
PMList *_alpm_db_whatprovides(pmdb_t *db, char *package); pmlist_t *_alpm_db_whatprovides(pmdb_t *db, char *package);
#endif /* _ALPM_PROVIDE_H */ #endif /* _ALPM_PROVIDE_H */

View File

@ -92,9 +92,9 @@ int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
return(0); return(0);
} }
int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data)
{ {
PMList *lp; pmlist_t *lp;
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
@ -107,7 +107,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
if(lp != NULL) { if(lp != NULL) {
if(trans->flags & PM_TRANS_FLAG_CASCADE) { if(trans->flags & PM_TRANS_FLAG_CASCADE) {
while(lp) { while(lp) {
PMList *i; pmlist_t *i;
for(i = lp; i; i = i->next) { for(i = lp; i; i = i->next) {
pmdepmissing_t *miss = (pmdepmissing_t *)i->data; pmdepmissing_t *miss = (pmdepmissing_t *)i->data;
pmpkg_t *info = _alpm_db_scan(db, miss->depend.name, INFRQ_ALL); pmpkg_t *info = _alpm_db_scan(db, miss->depend.name, INFRQ_ALL);
@ -161,7 +161,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
{ {
pmpkg_t *info; pmpkg_t *info;
struct stat buf; struct stat buf;
PMList *targ, *lp; pmlist_t *targ, *lp;
char line[PATH_MAX+1]; char line[PATH_MAX+1];
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
@ -230,7 +230,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
* see the big comment block in db_find_conflicts() for an * see the big comment block in db_find_conflicts() for an
* explanation. */ * explanation. */
int skipit = 0; int skipit = 0;
PMList *j; pmlist_t *j;
for(j = trans->skiplist; j; j = j->next) { for(j = trans->skiplist; j; j = j->next) {
if(!strcmp(file, (char*)j->data)) { if(!strcmp(file, (char*)j->data)) {
skipit = 1; skipit = 1;
@ -310,7 +310,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
depinfo = _alpm_db_get_pkgfromcache(db, depend.name); depinfo = _alpm_db_get_pkgfromcache(db, depend.name);
if(depinfo == NULL) { if(depinfo == NULL) {
/* look for a provides package */ /* look for a provides package */
PMList *provides = _alpm_db_whatprovides(db, depend.name); pmlist_t *provides = _alpm_db_whatprovides(db, depend.name);
if(provides) { if(provides) {
/* TODO: should check _all_ packages listed in provides, not just /* TODO: should check _all_ packages listed in provides, not just
* the first one. * the first one.

View File

@ -26,7 +26,7 @@
#include "trans.h" #include "trans.h"
int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name); int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name);
int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data); int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data);
int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db); int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db);
#endif /* _ALPM_REMOVE_H */ #endif /* _ALPM_REMOVE_H */

View File

@ -133,7 +133,7 @@ void _alpm_server_free(void *data)
* *
* RETURN: 0 for successful download, 1 on error * RETURN: 0 for successful download, 1 on error
*/ */
int _alpm_downloadfiles(PMList *servers, const char *localpath, PMList *files) int _alpm_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t *files)
{ {
return(!!_alpm_downloadfiles_forreal(servers, localpath, files, NULL, NULL)); return(!!_alpm_downloadfiles_forreal(servers, localpath, files, NULL, NULL));
} }
@ -151,15 +151,15 @@ int _alpm_downloadfiles(PMList *servers, const char *localpath, PMList *files)
* -1 if the mtimes are identical * -1 if the mtimes are identical
* 1 on error * 1 on error
*/ */
int _alpm_downloadfiles_forreal(PMList *servers, const char *localpath, int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
PMList *files, const char *mtime1, char *mtime2) pmlist_t *files, const char *mtime1, char *mtime2)
{ {
int fsz; int fsz;
netbuf *control = NULL; netbuf *control = NULL;
PMList *lp; pmlist_t *lp;
int done = 0; int done = 0;
PMList *complete = NULL; pmlist_t *complete = NULL;
PMList *i; pmlist_t *i;
if(files == NULL) { if(files == NULL) {
return(0); return(0);
@ -545,8 +545,8 @@ char *_alpm_fetch_pkgurl(char *target)
_alpm_log(PM_LOG_DEBUG, _(" %s is already in the current directory\n"), fn); _alpm_log(PM_LOG_DEBUG, _(" %s is already in the current directory\n"), fn);
} else { } else {
pmserver_t *server; pmserver_t *server;
PMList *servers = NULL; pmlist_t *servers = NULL;
PMList *files; pmlist_t *files;
if((server = (pmserver_t *)malloc(sizeof(pmserver_t))) == NULL) { if((server = (pmserver_t *)malloc(sizeof(pmserver_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmserver_t)); _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmserver_t));

View File

@ -42,9 +42,9 @@ typedef struct __pmserver_t {
pmserver_t *_alpm_server_new(char *url); pmserver_t *_alpm_server_new(char *url);
void _alpm_server_free(void *data); void _alpm_server_free(void *data);
int _alpm_downloadfiles(PMList *servers, const char *localpath, PMList *files); int _alpm_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t *files);
int _alpm_downloadfiles_forreal(PMList *servers, const char *localpath, int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
PMList *files, const char *mtime1, char *mtime2); pmlist_t *files, const char *mtime1, char *mtime2);
char *_alpm_fetch_pkgurl(char *target); char *_alpm_fetch_pkgurl(char *target);

View File

@ -89,12 +89,12 @@ void _alpm_sync_free(void *data)
free(sync); free(sync);
} }
/* Test for existence of a package in a PMList* of pmsyncpkg_t* /* Test for existence of a package in a pmlist_t* of pmsyncpkg_t*
* If found, return a pointer to the respective pmsyncpkg_t* * If found, return a pointer to the respective pmsyncpkg_t*
*/ */
static pmsyncpkg_t *find_pkginsync(char *needle, PMList *haystack) static pmsyncpkg_t *find_pkginsync(char *needle, pmlist_t *haystack)
{ {
PMList *i; pmlist_t *i;
pmsyncpkg_t *sync = NULL; pmsyncpkg_t *sync = NULL;
int found = 0; int found = 0;
@ -120,9 +120,9 @@ static int istoonew(pmpkg_t *pkg)
return((pkg->date + handle->upgradedelay) > t); return((pkg->date + handle->upgradedelay) > t);
} }
int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync) int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync)
{ {
PMList *i, *j, *k; pmlist_t *i, *j, *k;
/* check for "recommended" package replacements */ /* check for "recommended" package replacements */
_alpm_log(PM_LOG_FLOW1, _("checking for package replacements")); _alpm_log(PM_LOG_FLOW1, _("checking for package replacements"));
@ -130,7 +130,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync)
for(j = _alpm_db_get_pkgcache(i->data); j; j = j->next) { for(j = _alpm_db_get_pkgcache(i->data); j; j = j->next) {
pmpkg_t *spkg = j->data; pmpkg_t *spkg = j->data;
for(k = spkg->replaces; k; k = k->next) { for(k = spkg->replaces; k; k = k->next) {
PMList *m; pmlist_t *m;
for(m = _alpm_db_get_pkgcache(db_local); m; m = m->next) { for(m = _alpm_db_get_pkgcache(db_local); m; m = m->next) {
pmpkg_t *lpkg = m->data; pmpkg_t *lpkg = m->data;
if(!strcmp(k->data, lpkg->name)) { if(!strcmp(k->data, lpkg->name)) {
@ -256,11 +256,11 @@ error:
return(-1); return(-1);
} }
int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, char *name) int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, char *name)
{ {
char targline[PKG_FULLNAME_LEN]; char targline[PKG_FULLNAME_LEN];
char *targ; char *targ;
PMList *j; pmlist_t *j;
pmpkg_t *local; pmpkg_t *local;
pmpkg_t *spkg = NULL; pmpkg_t *spkg = NULL;
pmsyncpkg_t *sync; pmsyncpkg_t *sync;
@ -281,7 +281,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, c
spkg = _alpm_db_get_pkgfromcache(dbs, targ); spkg = _alpm_db_get_pkgfromcache(dbs, targ);
if(spkg == NULL) { if(spkg == NULL) {
/* Search provides */ /* Search provides */
PMList *p; pmlist_t *p;
_alpm_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ); _alpm_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ);
p = _alpm_db_whatprovides(dbs, targ); p = _alpm_db_whatprovides(dbs, targ);
if(p == NULL) { if(p == NULL) {
@ -304,7 +304,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, c
_alpm_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ); _alpm_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ);
for(j = dbs_sync; j && !spkg; j = j->next) { for(j = dbs_sync; j && !spkg; j = j->next) {
pmdb_t *dbs = j->data; pmdb_t *dbs = j->data;
PMList *p = _alpm_db_whatprovides(dbs, targ); pmlist_t *p = _alpm_db_whatprovides(dbs, targ);
if(p) { if(p) {
_alpm_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), p->data, targ); _alpm_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), p->data, targ);
spkg = _alpm_db_get_pkgfromcache(dbs, p->data); spkg = _alpm_db_get_pkgfromcache(dbs, p->data);
@ -372,13 +372,13 @@ static int pkg_cmp(const void *p1, const void *p2)
return(strcmp(((pmpkg_t *)p1)->name, ((pmsyncpkg_t *)p2)->pkg->name)); return(strcmp(((pmpkg_t *)p1)->name, ((pmsyncpkg_t *)p2)->pkg->name));
} }
int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **data) int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, pmlist_t **data)
{ {
PMList *deps = NULL; pmlist_t *deps = NULL;
PMList *list = NULL; /* list allowing checkdeps usage with data from trans->packages */ pmlist_t *list = NULL; /* list allowing checkdeps usage with data from trans->packages */
PMList *trail = NULL; /* breadcrum list to avoid running into circles */ pmlist_t *trail = NULL; /* breadcrum list to avoid running into circles */
PMList *asked = NULL; pmlist_t *asked = NULL;
PMList *i, *j, *k, *l; pmlist_t *i, *j, *k, *l;
int ret = 0; int ret = 0;
ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
@ -672,7 +672,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML
pmdepmissing_t *miss = i->data; pmdepmissing_t *miss = i->data;
if(!find_pkginsync(miss->depend.name, trans->packages)) { if(!find_pkginsync(miss->depend.name, trans->packages)) {
int pfound = 0; int pfound = 0;
PMList *k; pmlist_t *k;
/* If miss->depend.name depends on something that miss->target and a /* If miss->depend.name depends on something that miss->target and a
* package in final both provide, then it's okay... */ * package in final both provide, then it's okay... */
pmpkg_t *leavingp = _alpm_db_get_pkgfromcache(db_local, miss->target); pmpkg_t *leavingp = _alpm_db_get_pkgfromcache(db_local, miss->target);
@ -685,13 +685,13 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML
/* Look through the upset package's dependencies and try to match one up /* Look through the upset package's dependencies and try to match one up
* to a provisio from the package we want to remove */ * to a provisio from the package we want to remove */
for(k = conflictp->depends; k && !pfound; k = k->next) { for(k = conflictp->depends; k && !pfound; k = k->next) {
PMList *m; pmlist_t *m;
for(m = leavingp->provides; m && !pfound; m = m->next) { for(m = leavingp->provides; m && !pfound; m = m->next) {
if(!strcmp(k->data, m->data)) { if(!strcmp(k->data, m->data)) {
/* Found a match -- now look through final for a package that /* Found a match -- now look through final for a package that
* provides the same thing. If none are found, then it truly * provides the same thing. If none are found, then it truly
* is an unresolvable conflict. */ * is an unresolvable conflict. */
PMList *n, *o; pmlist_t *n, *o;
for(n = trans->packages; n && !pfound; n = n->next) { for(n = trans->packages; n && !pfound; n = n->next) {
pmsyncpkg_t *sp = n->data; pmsyncpkg_t *sp = n->data;
for(o = sp->pkg->provides; o && !pfound; o = o->next) { for(o = sp->pkg->provides; o && !pfound; o = o->next) {
@ -754,9 +754,9 @@ cleanup:
return(ret); return(ret);
} }
int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data) int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data)
{ {
PMList *i, *j, *files = NULL; pmlist_t *i, *j, *files = NULL;
pmtrans_t *tr = NULL; pmtrans_t *tr = NULL;
int replaces = 0, retval = 0; int replaces = 0, retval = 0;
char ldir[PATH_MAX]; char ldir[PATH_MAX];
@ -916,7 +916,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data)
for(i = trans->packages; i; i = i->next) { for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data; pmsyncpkg_t *sync = i->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) { if(sync->type == PM_SYNC_TYPE_REPLACE) {
PMList *j; pmlist_t *j;
for(j = sync->data; j; j = j->next) { for(j = sync->data; j; j = j->next) {
pmpkg_t *pkg = j->data; pmpkg_t *pkg = j->data;
if(!_alpm_pkg_isin(pkg->name, tr->packages)) { if(!_alpm_pkg_isin(pkg->name, tr->packages)) {
@ -987,16 +987,16 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data)
for(i = trans->packages; i; i = i->next) { for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data; pmsyncpkg_t *sync = i->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) { if(sync->type == PM_SYNC_TYPE_REPLACE) {
PMList *j; pmlist_t *j;
pmpkg_t *new = _alpm_db_get_pkgfromcache(db_local, sync->pkg->name); pmpkg_t *new = _alpm_db_get_pkgfromcache(db_local, sync->pkg->name);
for(j = sync->data; j; j = j->next) { for(j = sync->data; j; j = j->next) {
PMList *k; pmlist_t *k;
pmpkg_t *old = j->data; pmpkg_t *old = j->data;
/* merge lists */ /* merge lists */
for(k = old->requiredby; k; k = k->next) { for(k = old->requiredby; k; k = k->next) {
if(!_alpm_list_is_strin(k->data, new->requiredby)) { if(!_alpm_list_is_strin(k->data, new->requiredby)) {
/* replace old's name with new's name in the requiredby's dependency list */ /* replace old's name with new's name in the requiredby's dependency list */
PMList *m; pmlist_t *m;
pmpkg_t *depender = _alpm_db_get_pkgfromcache(db_local, k->data); pmpkg_t *depender = _alpm_db_get_pkgfromcache(db_local, k->data);
if(depender == NULL) { if(depender == NULL) {
/* If the depending package no longer exists in the local db, /* If the depending package no longer exists in the local db,

View File

@ -38,10 +38,10 @@ typedef struct __pmsyncpkg_t {
pmsyncpkg_t *_alpm_sync_new(int type, pmpkg_t *spkg, void *data); pmsyncpkg_t *_alpm_sync_new(int type, pmpkg_t *spkg, void *data);
void _alpm_sync_free(void *data); void _alpm_sync_free(void *data);
int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync); int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync);
int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, char *name); int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, char *name);
int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **data); int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, pmlist_t **data);
int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data); int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data);
#endif /* _ALPM_SYNC_H */ #endif /* _ALPM_SYNC_H */

View File

@ -73,7 +73,7 @@ void _alpm_trans_free(void *data)
FREELIST(trans->targets); FREELIST(trans->targets);
if(trans->type == PM_TRANS_TYPE_SYNC) { if(trans->type == PM_TRANS_TYPE_SYNC) {
PMList *i; pmlist_t *i;
for(i = trans->packages; i; i = i->next) { for(i = trans->packages; i; i = i->next) {
FREESYNC(i->data); FREESYNC(i->data);
} }
@ -147,7 +147,7 @@ int _alpm_trans_addtarget(pmtrans_t *trans, char *target)
return(0); return(0);
} }
int _alpm_trans_prepare(pmtrans_t *trans, PMList **data) int _alpm_trans_prepare(pmtrans_t *trans, pmlist_t **data)
{ {
*data = NULL; *data = NULL;
@ -186,7 +186,7 @@ int _alpm_trans_prepare(pmtrans_t *trans, PMList **data)
return(0); return(0);
} }
int _alpm_trans_commit(pmtrans_t *trans, PMList **data) int _alpm_trans_commit(pmtrans_t *trans, pmlist_t **data)
{ {
if(data!=NULL) if(data!=NULL)
*data = NULL; *data = NULL;

View File

@ -40,9 +40,9 @@ typedef struct __pmtrans_t {
unsigned char type; unsigned char type;
unsigned int flags; unsigned int flags;
unsigned char state; unsigned char state;
PMList *targets; /* PMList of (char *) */ pmlist_t *targets; /* pmlist_t of (char *) */
PMList *packages; /* PMList of (pmpkg_t *) or (pmsyncpkg_t *) */ pmlist_t *packages; /* pmlist_t of (pmpkg_t *) or (pmsyncpkg_t *) */
PMList *skiplist; /* PMList of (char *) */ pmlist_t *skiplist; /* pmlist_t of (char *) */
alpm_trans_cb_event cb_event; alpm_trans_cb_event cb_event;
alpm_trans_cb_conv cb_conv; alpm_trans_cb_conv cb_conv;
alpm_trans_cb_progress cb_progress; alpm_trans_cb_progress cb_progress;
@ -79,8 +79,8 @@ void _alpm_trans_free(void *data);
int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress); int _alpm_trans_init(pmtrans_t *trans, unsigned char type, unsigned int flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress);
int _alpm_trans_sysupgrade(pmtrans_t *trans); int _alpm_trans_sysupgrade(pmtrans_t *trans);
int _alpm_trans_addtarget(pmtrans_t *trans, char *target); int _alpm_trans_addtarget(pmtrans_t *trans, char *target);
int _alpm_trans_prepare(pmtrans_t *trans, PMList **data); int _alpm_trans_prepare(pmtrans_t *trans, pmlist_t **data);
int _alpm_trans_commit(pmtrans_t *trans, PMList **data); int _alpm_trans_commit(pmtrans_t *trans, pmlist_t **data);
#endif /* _ALPM_TRANS_H */ #endif /* _ALPM_TRANS_H */

View File

@ -557,9 +557,9 @@ static long long get_freespace()
return(ret); return(ret);
} }
int _alpm_check_freespace(pmtrans_t *trans, PMList **data) int _alpm_check_freespace(pmtrans_t *trans, pmlist_t **data)
{ {
PMList *i; pmlist_t *i;
long long pkgsize=0, freespace; long long pkgsize=0, freespace;
for(i = trans->packages; i; i = i->next) { for(i = trans->packages; i; i = i->next) {

View File

@ -67,7 +67,7 @@ int _alpm_ldconfig(char *root);
#ifdef _ALPM_TRANS_H #ifdef _ALPM_TRANS_H
int _alpm_runscriptlet(char *util, char *installfn, char *script, char *ver, char *oldver, pmtrans_t *trans); int _alpm_runscriptlet(char *util, char *installfn, char *script, char *ver, char *oldver, pmtrans_t *trans);
#ifndef __sun__ #ifndef __sun__
int _alpm_check_freespace(pmtrans_t *trans, PMList **data); int _alpm_check_freespace(pmtrans_t *trans, pmlist_t **data);
#endif #endif
#endif #endif
int _alpm_reg_match(char *string, char *pattern); int _alpm_reg_match(char *string, char *pattern);

View File

@ -74,7 +74,16 @@ void cb_log(unsigned short level, char *msg)
break; break;
} }
MSG(NL, "%s: %s\n", str, msg); time_t t;
struct tm *tmp;
char timestr[10] = {0};
t = time(NULL);
tmp = localtime(&t);
strftime(timestr, 9, "%H:%M:%S", tmp);
timestr[8] = '\0';
MSG(NL, "[%s] %s: %s\n", timestr, str, msg);
} }
/* Wrapper to fprintf() that allows to choose if we want the output /* Wrapper to fprintf() that allows to choose if we want the output

View File

@ -588,7 +588,7 @@ int main(int argc, char *argv[])
} }
/* Opening local database */ /* Opening local database */
db_local = alpm_db_register("local", NULL); db_local = alpm_db_register("local");
if(db_local == NULL) { if(db_local == NULL) {
ERR(NL, _("could not register 'local' database (%s)\n"), alpm_strerror(pm_errno)); ERR(NL, _("could not register 'local' database (%s)\n"), alpm_strerror(pm_errno));
cleanup(1); cleanup(1);