From 7131b7ac87b9793c06d7b7e59df103658dd76ec7 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Fri, 20 Oct 2006 06:26:55 +0000 Subject: 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 --- lib/libalpm/add.c | 16 ++++----- lib/libalpm/add.h | 2 +- lib/libalpm/alpm.c | 94 ++++++++++++-------------------------------------- lib/libalpm/alpm.h | 2 +- lib/libalpm/backup.c | 4 +-- lib/libalpm/backup.h | 2 +- lib/libalpm/be_files.c | 4 +-- lib/libalpm/cache.c | 14 ++++---- lib/libalpm/cache.h | 4 +-- lib/libalpm/conflict.c | 28 +++++++-------- lib/libalpm/conflict.h | 4 +-- lib/libalpm/db.c | 69 +++++++++++++++++++++++++++++++++--- lib/libalpm/db.h | 10 +++--- lib/libalpm/deps.c | 46 ++++++++++++------------ lib/libalpm/deps.h | 12 +++---- lib/libalpm/group.h | 2 +- lib/libalpm/handle.h | 12 +++---- lib/libalpm/list.c | 58 +++++++++++++++---------------- lib/libalpm/list.h | 26 +++++++------- lib/libalpm/package.c | 6 ++-- lib/libalpm/package.h | 24 ++++++------- lib/libalpm/provide.c | 8 ++--- lib/libalpm/provide.h | 2 +- lib/libalpm/remove.c | 12 +++---- lib/libalpm/remove.h | 2 +- lib/libalpm/server.c | 16 ++++----- lib/libalpm/server.h | 6 ++-- lib/libalpm/sync.c | 50 +++++++++++++-------------- lib/libalpm/sync.h | 8 ++--- lib/libalpm/trans.c | 6 ++-- lib/libalpm/trans.h | 10 +++--- lib/libalpm/util.c | 4 +-- lib/libalpm/util.h | 2 +- 33 files changed, 288 insertions(+), 277 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index bb704ae2..bbf9d532 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -112,7 +112,7 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) pmpkg_t *info = NULL; pmpkg_t *dummy; char pkgname[PKG_NAME_LEN], pkgver[PKG_VERSION_LEN]; - PMList *i; + pmlist_t *i; struct stat buf; ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); @@ -208,10 +208,10 @@ error: 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 *rmlist = NULL; + pmlist_t *lp; + pmlist_t *rmlist = NULL; char rm_fname[PATH_MAX]; pmpkg_t *info = NULL; @@ -273,7 +273,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) /* Check for file conflicts */ if(!(trans->flags & PM_TRANS_FLAG_FORCE)) { - PMList *skiplist = NULL; + pmlist_t *skiplist = 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; unsigned char cb_state; time_t t; - PMList *targ, *lp; + pmlist_t *targ, *lp; ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_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 */ for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) { pmpkg_t *tmpp = lp->data; - PMList *tmppm = NULL; + pmlist_t *tmppm = NULL; if(tmpp == NULL) { continue; } @@ -782,7 +782,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) depinfo = _alpm_db_get_pkgfromcache(db, depend.name); if(depinfo == NULL) { /* look for a provides package */ - PMList *provides = _alpm_db_whatprovides(db, depend.name); + pmlist_t *provides = _alpm_db_whatprovides(db, depend.name); if(provides) { /* TODO: should check _all_ packages listed in provides, not just * the first one. diff --git a/lib/libalpm/add.h b/lib/libalpm/add.h index 2b945b22..9b77a2ca 100644 --- a/lib/libalpm/add.h +++ b/lib/libalpm/add.h @@ -26,7 +26,7 @@ #include "trans.h" 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); #endif /* _ALPM_ADD_H */ diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 95264831..9702ad95 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -100,7 +100,7 @@ int alpm_initialize(char *root) */ int alpm_release() { - PMList *i; + pmlist_t *i; 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 * @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) */ -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 */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, 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 */ ASSERT(handle->trans == NULL, RET_ERR(PM_ERR_TRANS_NOT_NULL, NULL)); - 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 *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); + return(_alpm_db_register(treename, NULL)); } /** Unregister a package database @@ -324,7 +272,7 @@ int alpm_db_setserver(pmdb_t *db, char *url) found = 1; } } else { - PMList *i; + pmlist_t *i; for(i = handle->dbs_sync; i && !found; i = i->next) { pmdb_t *sdb = i->data; 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) { - PMList *lp; + pmlist_t *lp; char path[PATH_MAX]; - PMList *files = NULL; + pmlist_t *files = NULL; char newmtime[16] = ""; char lastupdate[16] = ""; 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 * @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 */ ASSERT(handle != NULL, return(NULL)); @@ -470,7 +418,7 @@ PMList *alpm_db_getpkgcache(pmdb_t *db) * @param name name of the package * @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 */ 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 * @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 */ 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) { + _alpm_log(PM_LOG_FUNCTION, "enter alpm_pkg_load"); + /* Sanity checks */ ASSERT(filename != NULL && strlen(filename) != 0, 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) { + _alpm_log(PM_LOG_FUNCTION, "enter alpm_pkg_free"); + ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1)); /* 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 * @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 */ 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) * @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 */ 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) * @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 */ ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1)); @@ -1122,7 +1074,7 @@ int alpm_logaction(char *fmt, ...) * @param list the list * @return the first element */ -PMList *alpm_list_first(PMList *list) +pmlist_t *alpm_list_first(pmlist_t *list) { return(list); } @@ -1131,7 +1083,7 @@ PMList *alpm_list_first(PMList *list) * @param entry the list entry * @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)); @@ -1142,7 +1094,7 @@ PMList *alpm_list_next(PMList *entry) * @param entry the list entry * @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)); @@ -1153,7 +1105,7 @@ void *alpm_list_getdata(PMList *entry) * @param entry list to free * @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)); @@ -1166,7 +1118,7 @@ int alpm_list_free(PMList *entry) * @param list the list to count * @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)); @@ -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) { 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)) { @@ -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); } if(strcmp(section, "options")) { - db = alpm_db_register(section, callback); + db = _alpm_db_register(section, callback); if(db == NULL) { /* pm_errno is set by alpm_db_register */ return(-1); diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 3807b11e..638bb57b 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -134,7 +134,7 @@ enum { /* Database registration callback */ 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); void *alpm_db_getinfo(PM_DB *db, unsigned char parm); diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c index 9c79a141..1c969835 100644 --- a/lib/libalpm/backup.c +++ b/lib/libalpm/backup.c @@ -31,9 +31,9 @@ /* 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) */ -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) { return(NULL); diff --git a/lib/libalpm/backup.h b/lib/libalpm/backup.h index 90125319..b1aa434c 100644 --- a/lib/libalpm/backup.h +++ b/lib/libalpm/backup.h @@ -23,7 +23,7 @@ #include "list.h" -char *_alpm_needbackup(char *file, PMList *backup); +char *_alpm_needbackup(char *file, pmlist_t *backup); #endif /* _ALPM_BACKUP_H */ diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index 7f273821..128ba77d 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -165,7 +165,7 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info) char path[PATH_MAX]; char line[512]; char *lang_tmp; - PMList *tmplist; + pmlist_t *tmplist; char *foo; 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; char path[PATH_MAX]; mode_t oldmask; - PMList *lp = NULL; + pmlist_t *lp = NULL; int retval = 0; int local = 0; diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c index 3c844b49..1115d111 100644 --- a/lib/libalpm/cache.c +++ b/lib/libalpm/cache.c @@ -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) { 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) { - PMList *lp; + pmlist_t *lp; if(db == NULL) { 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); for(lp = db->pkgcache; lp; lp = lp->next) { - PMList *i; + pmlist_t *i; pmpkg_t *pkg = lp->data; 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); db->grpcache = _alpm_list_add_sorted(db->grpcache, grp, _alpm_grp_cmp); } else { - PMList *j; + pmlist_t *j; for(j = db->grpcache; j; j = j->next) { 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) { - PMList *lg; + pmlist_t *lg; if(db == NULL || db->grpcache == NULL) { return; @@ -213,7 +213,7 @@ void _alpm_db_free_grpcache(pmdb_t *db) FREELIST(db->grpcache); } -PMList *_alpm_db_get_grpcache(pmdb_t *db) +pmlist_t *_alpm_db_get_grpcache(pmdb_t *db) { if(db == 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) { - PMList *i; + pmlist_t *i; if(db == NULL || target == NULL || strlen(target) == 0) { return(NULL); diff --git a/lib/libalpm/cache.h b/lib/libalpm/cache.h index c1ab844e..e6572970 100644 --- a/lib/libalpm/cache.h +++ b/lib/libalpm/cache.h @@ -31,12 +31,12 @@ int _alpm_db_load_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_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); /* groups */ int _alpm_db_load_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); #endif /* _ALPM_CACHE_H */ diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index 9b6e3124..6e7f0126 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -42,15 +42,15 @@ #include "deps.h" #include "conflict.h" -/* Returns a PMList* of pmdepmissing_t pointers. +/* Returns a pmlist_t* of pmdepmissing_t pointers. * * 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; - PMList *i, *j, *k; - PMList *baddeps = NULL; + pmlist_t *i, *j, *k; + pmlist_t *baddeps = NULL; pmdepmissing_t *miss = NULL; if(db == NULL) { @@ -88,7 +88,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) } } else { /* see if dp provides something in tp's conflict list */ - PMList *m; + pmlist_t *m; for(m = dp->provides; m; m = m->next) { if(!strcmp(m->data, j->data)) { /* confict */ @@ -124,7 +124,7 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) } } else { /* see if otp provides something in tp's conflict list */ - PMList *m; + pmlist_t *m; for(m = otp->provides; m; m = m->next) { if(!strcmp(m->data, j->data)) { _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 */ _alpm_log(PM_LOG_DEBUG, _("checkconflicts: db vs targ '%s'"), tp->name); for(k = _alpm_db_get_pkgcache(db); k; k = k->next) { - PMList *conflicts = NULL; + pmlist_t *conflicts = NULL; int usenewconflicts = 0; 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 */ 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) */ for(j = packages; j; j = j->next) { @@ -178,9 +178,9 @@ PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages) } } else { /* see if the db package conflicts with something we provide */ - PMList *m; + pmlist_t *m; for(m = conflicts; m; m = m->next) { - PMList *n; + pmlist_t *n; for(n = tp->provides; n; n = n->next) { if(!strcmp(m->data, n->data)) { _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); } -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 path[PATH_MAX+1]; struct stat buf, buf2; - PMList *conflicts = NULL; - PMList *targets = trans->packages; + pmlist_t *conflicts = NULL; + pmlist_t *targets = trans->packages; double percent; if(db == NULL || targets == NULL || root == NULL) { diff --git a/lib/libalpm/conflict.h b/lib/libalpm/conflict.h index 5c40af27..a47a585e 100644 --- a/lib/libalpm/conflict.h +++ b/lib/libalpm/conflict.h @@ -32,8 +32,8 @@ typedef struct __pmconflict_t { char ctarget[PKG_NAME_LEN]; } pmconflict_t; -PMList *_alpm_checkconflicts(pmdb_t *db, PMList *packages); -PMList *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, PMList **skip_list); +pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages); +pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmlist_t **skip_list); #endif /* _ALPM_CONFLICT_H */ diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 668628b4..2bbc4a4b 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -59,14 +59,14 @@ pmdb_t *_alpm_db_new(char *root, char* dbpath, char *treename) db = (pmdb_t *)malloc(sizeof(pmdb_t)); if(db == NULL) { _alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"), - sizeof(pmdb_t)); + sizeof(pmdb_t)); RET_ERR(PM_ERR_MEMORY, NULL); } db->path = (char *)malloc(strlen(root)+strlen(dbpath)+strlen(treename)+2); if(db->path == NULL) { _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); 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)); } -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) { char *targ; @@ -109,6 +109,7 @@ PMList *_alpm_db_search(pmdb_t *db, PMList *needles) continue; } 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) { pmpkg_t *pkg = j->data; @@ -123,7 +124,9 @@ PMList *_alpm_db_search(pmdb_t *db, PMList *needles) FREE(haystack); return(NULL); } else if(retval) { + _alpm_log(PM_LOG_DEBUG, " search target '%s' matched '%s'", targ, haystack); match = 1; + } else { } FREE(haystack); @@ -167,4 +170,60 @@ PMList *_alpm_db_search(pmdb_t *db, PMList *needles) 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: */ diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h index a374e096..571bf2ee 100644 --- a/lib/libalpm/db.h +++ b/lib/libalpm/db.h @@ -25,6 +25,7 @@ #include #include "package.h" +#include "alpm.h" /* Database entries */ #define INFRQ_NONE 0x00 @@ -41,15 +42,15 @@ typedef struct __pmdb_t { char *path; char treename[PATH_MAX]; void *handle; - PMList *pkgcache; - PMList *grpcache; - PMList *servers; + pmlist_t *pkgcache; + pmlist_t *grpcache; + pmlist_t *servers; } 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); -PMList *_alpm_db_search(pmdb_t *db, PMList *needles); +pmlist_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles); /* Prototypes for backends functions */ int _alpm_db_open(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_getlastupdate(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 */ diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index f709096d..8249c651 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -68,9 +68,9 @@ pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsign 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) { 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 * 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 *i, *j, *k, *l; + pmlist_t *newtargs = NULL; + pmlist_t *i, *j, *k, *l; int change = 1; int numscans = 0; int numtargs = 0; @@ -117,7 +117,7 @@ PMList *_alpm_sortbydeps(PMList *targets, int mode) _alpm_log(PM_LOG_DEBUG, _("started sorting dependencies")); while(change) { - PMList *tmptargs = NULL; + pmlist_t *tmptargs = NULL; change = 0; if(numscans > sqrt(numtargs)) { _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) { /* 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 */ FREELISTPTR(newtargs); newtargs = tmptargs; @@ -176,18 +176,18 @@ PMList *_alpm_sortbydeps(PMList *targets, int mode) return(newtargs); } -/* Returns a PMList* of missing_t pointers. +/* Returns a pmlist_t* of missing_t pointers. * * 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; - PMList *i, *j, *k; + pmlist_t *i, *j, *k; int cmp; int found = 0; - PMList *baddeps = NULL; + pmlist_t *baddeps = NULL; pmdepmissing_t *miss = NULL; if(db == NULL) { @@ -229,7 +229,7 @@ PMList *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, PMList * } if(found == 0) { /* 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) { /* not found */ continue; @@ -462,15 +462,15 @@ int _alpm_splitdep(char *depstr, pmdepend_t *depend) 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, * I mean dependencies that are *only* required for packages in the target * 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 *newtargs = targs; + pmlist_t *i, *j, *k; + pmlist_t *newtargs = targs; if(db == NULL) { return(newtargs); @@ -542,12 +542,12 @@ PMList *_alpm_removedeps(pmdb_t *db, PMList *targs) * * make sure *list and *trail are already initialized */ -int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, - PMList *trail, pmtrans_t *trans, PMList **data) +int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlist_t *list, + pmlist_t *trail, pmtrans_t *trans, pmlist_t **data) { - PMList *i, *j; - PMList *targ; - PMList *deps = NULL; + pmlist_t *i, *j; + pmlist_t *targ; + pmlist_t *deps = NULL; if(local == NULL || dbs_sync == NULL || syncpkg == NULL) { return(-1); @@ -586,7 +586,7 @@ int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList } /* check provides */ for(j = dbs_sync; !sync && j; j = j->next) { - PMList *provides; + pmlist_t *provides; provides = _alpm_db_whatprovides(j->data, miss->depend.name); if(provides) { sync = provides->data; diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h index ffd848ea..030020a9 100644 --- a/lib/libalpm/deps.h +++ b/lib/libalpm/deps.h @@ -40,13 +40,13 @@ typedef struct __pmdepmissing_t { pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsigned char depmod, const char *depname, const char *depversion); -int _alpm_depmiss_isin(pmdepmissing_t *needle, PMList *haystack); -PMList *_alpm_sortbydeps(PMList *targets, int mode); -PMList *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, PMList *packages); +int _alpm_depmiss_isin(pmdepmissing_t *needle, pmlist_t *haystack); +pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode); +pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist_t *packages); int _alpm_splitdep(char *depstr, pmdepend_t *depend); -PMList *_alpm_removedeps(pmdb_t *db, PMList *targs); -int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, - PMList *trail, pmtrans_t *trans, PMList **data); +pmlist_t *_alpm_removedeps(pmdb_t *db, pmlist_t *targs); +int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlist_t *list, + pmlist_t *trail, pmtrans_t *trans, pmlist_t **data); #endif /* _ALPM_DEPS_H */ diff --git a/lib/libalpm/group.h b/lib/libalpm/group.h index e36d3603..bb3de2a5 100644 --- a/lib/libalpm/group.h +++ b/lib/libalpm/group.h @@ -28,7 +28,7 @@ /* Groups structure */ typedef struct __pmgrp_t { char name[GRP_NAME_LEN]; - PMList *packages; /* List of strings */ + pmlist_t *packages; /* List of strings */ } pmgrp_t; #define FREEGRP(p) do { if(p) { _alpm_grp_free(p); p = NULL; } } while(0) diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h index b50e5800..0bd37afd 100644 --- a/lib/libalpm/handle.h +++ b/lib/libalpm/handle.h @@ -35,7 +35,7 @@ typedef struct __pmhandle_t { pmaccess_t access; uid_t uid; pmdb_t *db_local; - PMList *dbs_sync; /* List of (pmdb_t *) */ + pmlist_t *dbs_sync; /* List of (pmdb_t *) */ FILE *logfd; int lckfd; pmtrans_t *trans; @@ -44,10 +44,10 @@ typedef struct __pmhandle_t { char *dbpath; char *cachedir; char *logfile; - PMList *noupgrade; /* List of strings */ - PMList *noextract; /* List of strings */ - PMList *ignorepkg; /* List of strings */ - PMList *holdpkg; /* List of strings */ + pmlist_t *noupgrade; /* List of strings */ + pmlist_t *noextract; /* List of strings */ + pmlist_t *ignorepkg; /* List of strings */ + pmlist_t *holdpkg; /* List of strings */ unsigned char usesyslog; time_t upgradedelay; /* servers */ @@ -56,7 +56,7 @@ typedef struct __pmhandle_t { char *xfercommand; unsigned short nopassiveftp; unsigned short chomp; /* if eye-candy features should be enabled or not */ - PMList *needles; /* for searching */ + pmlist_t *needles; /* for searching */ } pmhandle_t; #define FREEHANDLE(p) do { if (p) { _alpm_handle_free(p); p = NULL; } } while (0) diff --git a/lib/libalpm/list.c b/lib/libalpm/list.c index 0e1c9426..be41a462 100644 --- a/lib/libalpm/list.c +++ b/lib/libalpm/list.c @@ -27,11 +27,11 @@ /* pacman */ #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) { return(NULL); } @@ -42,9 +42,9 @@ PMList *_alpm_list_new() 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) { 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; 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 * 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 *prev = NULL; - PMList *iter = list; + pmlist_t *add; + pmlist_t *prev = NULL; + pmlist_t *iter = list; add = _alpm_list_new(); 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. * 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) { *data = NULL; @@ -186,19 +186,19 @@ PMList *_alpm_list_remove(PMList *haystack, void *needle, _alpm_fn_cmp fn, void return(haystack); } -int _alpm_list_count(PMList *list) +int _alpm_list_count(pmlist_t *list) { int i; - PMList *lp; + pmlist_t *lp; for(lp = list, i = 0; lp; lp = lp->next, 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) { if(lp->data == needle) { @@ -208,11 +208,11 @@ int _alpm_list_is_in(void *needle, PMList *haystack) 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) { if(lp->data && !strcmp(lp->data, needle)) { @@ -222,7 +222,7 @@ int _alpm_list_is_strin(char *needle, PMList *haystack) return(0); } -PMList *_alpm_list_last(PMList *list) +pmlist_t *_alpm_list_last(pmlist_t *list) { if(list == 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. * */ -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) { 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 */ -PMList *_alpm_list_reverse(PMList *list) +pmlist_t *_alpm_list_reverse(pmlist_t *list) { /* simple but functional -- we just build a new list, starting * with the old list's tail */ - PMList *newlist = NULL; - PMList *lp; + pmlist_t *newlist = NULL; + pmlist_t *lp; for(lp = list->last; lp; lp = lp->prev) { newlist = _alpm_list_add(newlist, lp->data); @@ -270,10 +270,10 @@ PMList *_alpm_list_reverse(PMList *list) return(newlist); } -PMList *_alpm_list_strdup(PMList *list) +pmlist_t *_alpm_list_strdup(pmlist_t *list) { - PMList *newlist = NULL; - PMList *lp; + pmlist_t *newlist = NULL; + pmlist_t *lp; for(lp = list; lp; lp = lp->next) { newlist = _alpm_list_add(newlist, strdup(lp->data)); diff --git a/lib/libalpm/list.h b/lib/libalpm/list.h index 74da9a00..abff7819 100644 --- a/lib/libalpm/list.h +++ b/lib/libalpm/list.h @@ -29,8 +29,6 @@ typedef struct __pmlist_t { struct __pmlist_t *last; /* Quick access to last item in list */ } 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) _FREELIST(p, free) #define FREELISTPTR(p) _FREELIST(p, NULL) @@ -39,18 +37,18 @@ typedef void (*_alpm_fn_free)(void *); /* Sort comparison callback function declaration */ typedef int (*_alpm_fn_cmp)(const void *, const void *); -PMList *_alpm_list_new(void); -void _alpm_list_free(PMList *list, _alpm_fn_free fn); -PMList *_alpm_list_add(PMList *list, void *data); -PMList *_alpm_list_add_sorted(PMList *list, void *data, _alpm_fn_cmp fn); -PMList *_alpm_list_remove(PMList *haystack, void *needle, _alpm_fn_cmp fn, void **data); -int _alpm_list_count(PMList *list); -int _alpm_list_is_in(void *needle, PMList *haystack); -int _alpm_list_is_strin(char *needle, PMList *haystack); -PMList *_alpm_list_last(PMList *list); -PMList *_alpm_list_remove_dupes(PMList *list); -PMList *_alpm_list_reverse(PMList *list); -PMList *_alpm_list_strdup(PMList *list); +pmlist_t *_alpm_list_new(void); +void _alpm_list_free(pmlist_t *list, _alpm_fn_free fn); +pmlist_t *_alpm_list_add(pmlist_t *list, void *data); +pmlist_t *_alpm_list_add_sorted(pmlist_t *list, void *data, _alpm_fn_cmp fn); +pmlist_t *_alpm_list_remove(pmlist_t *haystack, void *needle, _alpm_fn_cmp fn, void **data); +int _alpm_list_count(pmlist_t *list); +int _alpm_list_is_in(void *needle, pmlist_t *haystack); +int _alpm_list_is_strin(char *needle, pmlist_t *haystack); +pmlist_t *_alpm_list_last(pmlist_t *list); +pmlist_t *_alpm_list_remove_dupes(pmlist_t *list); +pmlist_t *_alpm_list_reverse(pmlist_t *list); +pmlist_t *_alpm_list_strdup(pmlist_t *list); #endif /* _ALPM_LIST_H */ diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 77f85ab8..aa035769 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -414,12 +414,12 @@ error: return(NULL); } -/* Test for existence of a package in a PMList* +/* Test for existence of a package in a pmlist_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) { return(NULL); diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index 31c217e0..62ad7e4a 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -65,17 +65,17 @@ typedef struct __pmpkg_t { unsigned char force; time_t date; unsigned char reason; - PMList *desc_localized; - PMList *license; - PMList *replaces; - PMList *groups; - PMList *files; - PMList *backup; - PMList *depends; - PMList *removes; - PMList *requiredby; - PMList *conflicts; - PMList *provides; + pmlist_t *desc_localized; + pmlist_t *license; + pmlist_t *replaces; + pmlist_t *groups; + pmlist_t *files; + pmlist_t *backup; + pmlist_t *depends; + pmlist_t *removes; + pmlist_t *requiredby; + pmlist_t *conflicts; + pmlist_t *provides; /* internal */ unsigned char origin; void *data; @@ -97,7 +97,7 @@ 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); +pmpkg_t *_alpm_pkg_isin(char *needle, pmlist_t *haystack); int _alpm_pkg_splitname(char *target, char *name, char *version); #endif /* _ALPM_PACKAGE_H */ diff --git a/lib/libalpm/provide.c b/lib/libalpm/provide.c index bca6b7da..cd5db3e0 100644 --- a/lib/libalpm/provide.c +++ b/lib/libalpm/provide.c @@ -28,12 +28,12 @@ #include "db.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 *lp; + pmlist_t *pkgs = NULL; + pmlist_t *lp; if(db == NULL || package == NULL || strlen(package) == 0) { return(NULL); diff --git a/lib/libalpm/provide.h b/lib/libalpm/provide.h index 4313f581..7b132200 100644 --- a/lib/libalpm/provide.h +++ b/lib/libalpm/provide.h @@ -26,7 +26,7 @@ #include "list.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 */ diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index d67807a7..75d01f63 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -92,9 +92,9 @@ int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) 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(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(trans->flags & PM_TRANS_FLAG_CASCADE) { while(lp) { - PMList *i; + pmlist_t *i; for(i = lp; i; i = i->next) { pmdepmissing_t *miss = (pmdepmissing_t *)i->data; 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; struct stat buf; - PMList *targ, *lp; + pmlist_t *targ, *lp; char line[PATH_MAX+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 * explanation. */ int skipit = 0; - PMList *j; + pmlist_t *j; for(j = trans->skiplist; j; j = j->next) { if(!strcmp(file, (char*)j->data)) { skipit = 1; @@ -310,7 +310,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db) depinfo = _alpm_db_get_pkgfromcache(db, depend.name); if(depinfo == NULL) { /* look for a provides package */ - PMList *provides = _alpm_db_whatprovides(db, depend.name); + pmlist_t *provides = _alpm_db_whatprovides(db, depend.name); if(provides) { /* TODO: should check _all_ packages listed in provides, not just * the first one. diff --git a/lib/libalpm/remove.h b/lib/libalpm/remove.h index 217f23be..ac6ff1bf 100644 --- a/lib/libalpm/remove.h +++ b/lib/libalpm/remove.h @@ -26,7 +26,7 @@ #include "trans.h" 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); #endif /* _ALPM_REMOVE_H */ diff --git a/lib/libalpm/server.c b/lib/libalpm/server.c index 86271b57..7b2f037c 100644 --- a/lib/libalpm/server.c +++ b/lib/libalpm/server.c @@ -133,7 +133,7 @@ void _alpm_server_free(void *data) * * 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)); } @@ -151,15 +151,15 @@ int _alpm_downloadfiles(PMList *servers, const char *localpath, PMList *files) * -1 if the mtimes are identical * 1 on error */ -int _alpm_downloadfiles_forreal(PMList *servers, const char *localpath, - PMList *files, const char *mtime1, char *mtime2) +int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath, + pmlist_t *files, const char *mtime1, char *mtime2) { int fsz; netbuf *control = NULL; - PMList *lp; + pmlist_t *lp; int done = 0; - PMList *complete = NULL; - PMList *i; + pmlist_t *complete = NULL; + pmlist_t *i; if(files == NULL) { 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); } else { pmserver_t *server; - PMList *servers = NULL; - PMList *files; + pmlist_t *servers = NULL; + pmlist_t *files; if((server = (pmserver_t *)malloc(sizeof(pmserver_t))) == NULL) { _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmserver_t)); diff --git a/lib/libalpm/server.h b/lib/libalpm/server.h index c5c57a44..85d390d6 100644 --- a/lib/libalpm/server.h +++ b/lib/libalpm/server.h @@ -42,9 +42,9 @@ typedef struct __pmserver_t { pmserver_t *_alpm_server_new(char *url); void _alpm_server_free(void *data); -int _alpm_downloadfiles(PMList *servers, const char *localpath, PMList *files); -int _alpm_downloadfiles_forreal(PMList *servers, const char *localpath, - PMList *files, const char *mtime1, char *mtime2); +int _alpm_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t *files); +int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath, + pmlist_t *files, const char *mtime1, char *mtime2); char *_alpm_fetch_pkgurl(char *target); diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 27bb380e..ffc69bf8 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -89,12 +89,12 @@ void _alpm_sync_free(void *data) 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* */ -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; int found = 0; @@ -120,9 +120,9 @@ static int istoonew(pmpkg_t *pkg) 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 */ _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) { pmpkg_t *spkg = j->data; 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) { pmpkg_t *lpkg = m->data; if(!strcmp(k->data, lpkg->name)) { @@ -256,11 +256,11 @@ error: 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 *targ; - PMList *j; + pmlist_t *j; pmpkg_t *local; pmpkg_t *spkg = NULL; 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); if(spkg == NULL) { /* Search provides */ - PMList *p; + pmlist_t *p; _alpm_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ); p = _alpm_db_whatprovides(dbs, targ); 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); for(j = dbs_sync; j && !spkg; j = j->next) { pmdb_t *dbs = j->data; - PMList *p = _alpm_db_whatprovides(dbs, targ); + pmlist_t *p = _alpm_db_whatprovides(dbs, targ); if(p) { _alpm_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), p->data, targ); 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)); } -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 *list = NULL; /* list allowing checkdeps usage with data from trans->packages */ - PMList *trail = NULL; /* breadcrum list to avoid running into circles */ - PMList *asked = NULL; - PMList *i, *j, *k, *l; + pmlist_t *deps = NULL; + pmlist_t *list = NULL; /* list allowing checkdeps usage with data from trans->packages */ + pmlist_t *trail = NULL; /* breadcrum list to avoid running into circles */ + pmlist_t *asked = NULL; + pmlist_t *i, *j, *k, *l; int ret = 0; 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; if(!find_pkginsync(miss->depend.name, trans->packages)) { int pfound = 0; - PMList *k; + pmlist_t *k; /* If miss->depend.name depends on something that miss->target and a * package in final both provide, then it's okay... */ 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 * to a provisio from the package we want to remove */ for(k = conflictp->depends; k && !pfound; k = k->next) { - PMList *m; + pmlist_t *m; for(m = leavingp->provides; m && !pfound; m = m->next) { if(!strcmp(k->data, m->data)) { /* Found a match -- now look through final for a package that * provides the same thing. If none are found, then it truly * is an unresolvable conflict. */ - PMList *n, *o; + pmlist_t *n, *o; for(n = trans->packages; n && !pfound; n = n->next) { pmsyncpkg_t *sp = n->data; for(o = sp->pkg->provides; o && !pfound; o = o->next) { @@ -754,9 +754,9 @@ cleanup: 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; int replaces = 0, retval = 0; 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) { pmsyncpkg_t *sync = i->data; if(sync->type == PM_SYNC_TYPE_REPLACE) { - PMList *j; + pmlist_t *j; for(j = sync->data; j; j = j->next) { pmpkg_t *pkg = j->data; 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) { pmsyncpkg_t *sync = i->data; if(sync->type == PM_SYNC_TYPE_REPLACE) { - PMList *j; + pmlist_t *j; pmpkg_t *new = _alpm_db_get_pkgfromcache(db_local, sync->pkg->name); for(j = sync->data; j; j = j->next) { - PMList *k; + pmlist_t *k; pmpkg_t *old = j->data; /* merge lists */ for(k = old->requiredby; k; k = k->next) { if(!_alpm_list_is_strin(k->data, new->requiredby)) { /* 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); if(depender == NULL) { /* If the depending package no longer exists in the local db, diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h index ffcfb6f6..d23dc6d8 100644 --- a/lib/libalpm/sync.h +++ b/lib/libalpm/sync.h @@ -38,10 +38,10 @@ typedef struct __pmsyncpkg_t { pmsyncpkg_t *_alpm_sync_new(int type, pmpkg_t *spkg, 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_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, char *name); -int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **data); -int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data); +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_t *dbs_sync, char *name); +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_t **data); #endif /* _ALPM_SYNC_H */ diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 69fc69bb..2e34f570 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -73,7 +73,7 @@ void _alpm_trans_free(void *data) FREELIST(trans->targets); if(trans->type == PM_TRANS_TYPE_SYNC) { - PMList *i; + pmlist_t *i; for(i = trans->packages; i; i = i->next) { FREESYNC(i->data); } @@ -147,7 +147,7 @@ int _alpm_trans_addtarget(pmtrans_t *trans, char *target) return(0); } -int _alpm_trans_prepare(pmtrans_t *trans, PMList **data) +int _alpm_trans_prepare(pmtrans_t *trans, pmlist_t **data) { *data = NULL; @@ -186,7 +186,7 @@ int _alpm_trans_prepare(pmtrans_t *trans, PMList **data) return(0); } -int _alpm_trans_commit(pmtrans_t *trans, PMList **data) +int _alpm_trans_commit(pmtrans_t *trans, pmlist_t **data) { if(data!=NULL) *data = NULL; diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h index a0b72127..95e672b6 100644 --- a/lib/libalpm/trans.h +++ b/lib/libalpm/trans.h @@ -40,9 +40,9 @@ typedef struct __pmtrans_t { unsigned char type; unsigned int flags; unsigned char state; - PMList *targets; /* PMList of (char *) */ - PMList *packages; /* PMList of (pmpkg_t *) or (pmsyncpkg_t *) */ - PMList *skiplist; /* PMList of (char *) */ + pmlist_t *targets; /* pmlist_t of (char *) */ + pmlist_t *packages; /* pmlist_t of (pmpkg_t *) or (pmsyncpkg_t *) */ + pmlist_t *skiplist; /* pmlist_t of (char *) */ alpm_trans_cb_event cb_event; alpm_trans_cb_conv cb_conv; 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_sysupgrade(pmtrans_t *trans); int _alpm_trans_addtarget(pmtrans_t *trans, char *target); -int _alpm_trans_prepare(pmtrans_t *trans, PMList **data); -int _alpm_trans_commit(pmtrans_t *trans, PMList **data); +int _alpm_trans_prepare(pmtrans_t *trans, pmlist_t **data); +int _alpm_trans_commit(pmtrans_t *trans, pmlist_t **data); #endif /* _ALPM_TRANS_H */ diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index c5ad162b..1b7065ec 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -557,9 +557,9 @@ static long long get_freespace() 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; for(i = trans->packages; i; i = i->next) { diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index 205facae..63ba00c1 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -67,7 +67,7 @@ int _alpm_ldconfig(char *root); #ifdef _ALPM_TRANS_H int _alpm_runscriptlet(char *util, char *installfn, char *script, char *ver, char *oldver, pmtrans_t *trans); #ifndef __sun__ -int _alpm_check_freespace(pmtrans_t *trans, PMList **data); +int _alpm_check_freespace(pmtrans_t *trans, pmlist_t **data); #endif #endif int _alpm_reg_match(char *string, char *pattern); -- cgit v1.2.3-70-g09d2