Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=52b8a03411726037f19b108dd28d22e04c99e195
commit 52b8a03411726037f19b108dd28d22e04c99e195 Author: Michel Hermier <[email protected]> Date: Tue Aug 19 09:57:45 2014 +0200 libpacman: Rename pmlist::data to m_data to enforce usage of f_ptrlistitem_data. diff --git a/lib/libpacman/cache.cpp b/lib/libpacman/cache.cpp index 832229b..31ee7a4 100644 --- a/lib/libpacman/cache.cpp +++ b/lib/libpacman/cache.cpp @@ -145,7 +145,7 @@ int _pacman_db_remove_pkgfromcache(Database *db, Package *pkg) } static -Group *_pacman_db_get_grpfromlist(pmlist_t *list, const char *target) +Group *_pacman_db_get_grpfromlist(FPtrList *list, const char *target) { pmlist_t *i; @@ -154,7 +154,7 @@ Group *_pacman_db_get_grpfromlist(pmlist_t *list, const char *target) } for(i = list; i; i = i->next) { - Group *info = i->data; + Group *info = f_ptrlistitem_data(i); if(strcmp(info->name, target) == 0) { return(info); @@ -178,17 +178,19 @@ int _pacman_db_load_grpcache(Database *db) for(; lp; lp = lp->next) { pmlist_t *i; - Package *pkg = lp->data; + Package *pkg = f_ptrlistitem_data(lp); if(!(pkg->flags & INFRQ_DESC)) { pkg->read(INFRQ_DESC); } for(i = pkg->groups(); i; i = i->next) { - Group *grp = _pacman_db_get_grpfromlist(db->grpcache, f_stringlistitem_to_str(i)); + const char *grp_name = f_stringlistitem_to_str(i); + + Group *grp = _pacman_db_get_grpfromlist(db->grpcache, grp_name); if(grp == NULL) { - grp = new Group((char *)i->data); + grp = new Group(grp_name); db->grpcache = f_ptrlist_add_sorted(db->grpcache, grp, _pacman_grp_cmp); } if(!_pacman_list_is_strin(pkg->name(), grp->packages)) { diff --git a/lib/libpacman/conflict.cpp b/lib/libpacman/conflict.cpp index 0fd8449..0077b6b 100644 --- a/lib/libpacman/conflict.cpp +++ b/lib/libpacman/conflict.cpp @@ -66,7 +66,7 @@ pmlist_t *_pacman_checkconflicts(pmtrans_t *trans, pmlist_t *packages) howmany = f_ptrlist_count(packages); for(i = packages; i; i = i->next) { - Package *tp = i->data; + Package *tp = (Package *)f_ptrlistitem_data(i); if(tp == NULL) { continue; } @@ -88,7 +88,7 @@ pmlist_t *_pacman_checkconflicts(pmtrans_t *trans, pmlist_t *packages) /* CHECK 1: check targets against database */ _pacman_log(PM_LOG_DEBUG, _("checkconflicts: targ '%s' vs db"), tp->name()); for(k = _pacman_db_get_pkgcache(db_local); k; k = k->next) { - Package *dp = (Package *)k->data; + Package *dp = (Package *)f_ptrlistitem_data(k); if(!strcmp(dp->name(), tp->name())) { /* a package cannot conflict with itself -- that's just not nice */ continue; @@ -116,7 +116,7 @@ pmlist_t *_pacman_checkconflicts(pmtrans_t *trans, pmlist_t *packages) /* CHECK 2: check targets against targets */ _pacman_log(PM_LOG_DEBUG, _("checkconflicts: targ '%s' vs targs"), tp->name()); for(k = packages; k; k = k->next) { - Package *otp = (Package *)k->data; + Package *otp = (Package *)f_ptrlistitem_data(k); if(!strcmp(otp->name(), tp->name())) { /* a package cannot conflict with itself -- that's just not nice */ continue; @@ -147,7 +147,7 @@ pmlist_t *_pacman_checkconflicts(pmtrans_t *trans, pmlist_t *packages) pmlist_t *conflicts = NULL; int usenewconflicts = 0; - info = k->data; + info = (Package *)f_ptrlistitem_data(k); if(!strcmp(info->name(), tp->name())) { /* a package cannot conflict with itself -- that's just not nice */ continue; @@ -156,7 +156,7 @@ pmlist_t *_pacman_checkconflicts(pmtrans_t *trans, pmlist_t *packages) * conflicts list from the new package, not the old one (*info) */ for(j = packages; j; j = j->next) { - Package *pkg = j->data; + Package *pkg = (Package *)f_ptrlistitem_data(j); if(!strcmp(pkg->name(), info->name())) { /* Use the new, to-be-installed package's conflicts */ conflicts = pkg->conflicts(); @@ -253,12 +253,12 @@ pmlist_t *_pacman_db_find_conflicts(pmtrans_t *trans) /* CHECK 1: check every target against every target */ for(i = targets; i; i = i->next) { - Package *p1 = (Package*)i->data; + Package *p1 = (Package*)f_ptrlistitem_data(i); remain = f_ptrlist_count(i); percent = (double)(howmany - remain + 1) / howmany; PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", (percent * 100), howmany, howmany - remain + 1); for(j = i; j; j = j->next) { - Package *p2 = (Package*)j->data; + Package *p2 = (Package*)f_ptrlistitem_data(j); if(strcmp(p1->name(), p2->name())) { pmlist_t *ret = chk_fileconflicts(p1->files(), p2->files()); for(k = ret; k; k = k->next) { @@ -277,7 +277,7 @@ pmlist_t *_pacman_db_find_conflicts(pmtrans_t *trans) } /* CHECK 2: check every target against the filesystem */ - p = (Package*)i->data; + p = (Package*)f_ptrlistitem_data(i); dbpkg = NULL; for(j = p->files(); j; j = j->next) { filestr = f_stringlistitem_to_str(j); @@ -308,7 +308,7 @@ pmlist_t *_pacman_db_find_conflicts(pmtrans_t *trans) if(!ok) { /* Look at all the targets */ for(k = targets; k && !ok; k = k->next) { - Package *p2 = (Package *)k->data; + Package *p2 = (Package *)f_ptrlistitem_data(k); /* As long as they're not the current package */ if(strcmp(p2->name(), p->name())) { Package *dbpkg2 = NULL; diff --git a/lib/libpacman/db.cpp b/lib/libpacman/db.cpp index dc9e6af..6dcb7dd 100644 --- a/lib/libpacman/db.cpp +++ b/lib/libpacman/db.cpp @@ -89,7 +89,7 @@ pmlist_t *Database::filter(const PackageMatcher &packagematcher) pmlist_t *i, *ret = NULL; for(i = _pacman_db_get_pkgcache(this); i; i = i->next) { - Package *pkg = i->data; + Package *pkg = (Package *)f_ptrlistitem_data(i); if(packagematcher.match(pkg)) { ret = f_ptrlist_append(ret, pkg); @@ -118,7 +118,7 @@ FPtrList *Database::filter(const FStringList *needles, int packagestrmatcher_fla PackageMatcher packagematcher(pattern, packagestrmatcher_flags, strmatcher_flags); for(j = _pacman_db_get_pkgcache(this); j; j = j->next) { - Package *pkg = j->data; + Package *pkg = (Package *)f_ptrlistitem_data(j); if(packagematcher.match(pkg)) { ret = f_ptrlist_append(ret, pkg); @@ -142,7 +142,7 @@ Package *Database::find(const PackageMatcher &packagematcher) pmlist_t *i; for(i = _pacman_db_get_pkgcache(this); i; i = i->next) { - Package *pkg = i->data; + Package *pkg = (Package *)f_ptrlistitem_data(i); if(packagematcher.match(pkg)) { if(packagematcher.match(pkg, ~PM_PACKAGE_FLAG_PROVIDES)) { diff --git a/lib/libpacman/db/localdb.cpp b/lib/libpacman/db/localdb.cpp index 67682f7..7f50668 100644 --- a/lib/libpacman/db/localdb.cpp +++ b/lib/libpacman/db/localdb.cpp @@ -429,7 +429,7 @@ void _pacman_localdb_write_stringlist(const char *entry, const pmlist_t *values, if(values != NULL) { fprintf(stream, "%%%s%%\n", entry); for(lp = values; lp; lp = lp->next) { - fprintf(stream, "%s\n", (char *)lp->data); + fprintf(stream, "%s\n", f_stringlistitem_to_str(lp)); } fputc('\n', stream); } @@ -546,15 +546,13 @@ pmlist_t *LocalDatabase::getowners(const char *filename) } for(lp = _pacman_db_get_pkgcache(this); lp; lp = lp->next) { - Package *info; + Package *info = (Package *)f_ptrlistitem_data(lp); pmlist_t *i; - info = lp->data; - for(i = info->files(); i; i = i->next) { char path[PATH_MAX]; - snprintf(path, PATH_MAX, "%s%s", m_handle->root, (char *)i->data); + snprintf(path, PATH_MAX, "%s%s", m_handle->root, f_stringlistitem_to_str(i)); if(!strcmp(path, rpath)) { ret = f_ptrlist_add(ret, info); if(rpath[strlen(rpath)-1] != '/') { diff --git a/lib/libpacman/db/localdb_files.cpp b/lib/libpacman/db/localdb_files.cpp index d43838a..e8aff6e 100644 --- a/lib/libpacman/db/localdb_files.cpp +++ b/lib/libpacman/db/localdb_files.cpp @@ -75,7 +75,7 @@ int _pacman_localdb_desc_fread(Package *info, FILE *fp) f_strtrim(line); if(!strcmp(line, "%DESC%")) { _pacman_db_read_lines(&info->desc_localized, line, sline, fp); - STRNCPY(info->m_description, (char*)info->desc_localized->data, sizeof(info->m_description)); + STRNCPY(info->m_description, f_stringlistitem_to_str(info->desc_localized), sizeof(info->m_description)); for (i = info->desc_localized; i; i = i->next) { const char *desc = f_stringlistitem_to_str(i); const size_t language_len = strlen(handle->language); diff --git a/lib/libpacman/deps.cpp b/lib/libpacman/deps.cpp index c75d1ff..d8a9ae7 100644 --- a/lib/libpacman/deps.cpp +++ b/lib/libpacman/deps.cpp @@ -80,7 +80,7 @@ int _pacman_depmiss_isin(pmdepmissing_t *needle, pmlist_t *haystack) pmlist_t *i; for(i = haystack; i; i = i->next) { - pmdepmissing_t *miss = i->data; + pmdepmissing_t *miss = f_ptrlistitem_data(i); if(!memcmp(needle, miss, sizeof(pmdepmissing_t)) && !memcmp(&needle->depend, &miss->depend, sizeof(pmdepend_t))) { return(1); @@ -132,22 +132,22 @@ pmlist_t *_pacman_sortbydeps(pmlist_t *targets, int mode) /* We create the vertices */ for(i = targets; i; i = i->next) { pmgraph_t *v = _pacman_graph_new(); - v->data = (void *)i->data; + v->data = f_ptrlistitem_data(i); vertices = f_ptrlist_add(vertices, v); } /* We compute the edges */ for(i = vertices; i; i = i->next) { - pmgraph_t *vertex_i = i->data; + pmgraph_t *vertex_i = f_ptrlistitem_data(i); Package *p_i = vertex_i->data; /* TODO this should be somehow combined with _pacman_checkdeps */ for(j = vertices; j; j = j->next) { - pmgraph_t *vertex_j = j->data; + pmgraph_t *vertex_j = f_ptrlistitem_data(j); Package *p_j = vertex_j->data; int child = 0; for(k = p_i->depends(); k && !child; k = k->next) { pmdepend_t depend; - _pacman_splitdep(k->data, &depend); + _pacman_splitdep(f_ptrlistitem_data(k), &depend); child = _pacman_depcmp(p_j, &depend); } if(child) { @@ -158,13 +158,13 @@ pmlist_t *_pacman_sortbydeps(pmlist_t *targets, int mode) } vptr = vertices; - vertex = vertices->data; + vertex = f_ptrlistitem_data(vertices); while(vptr) { /* mark that we touched the vertex */ vertex->state = -1; found = 0; while(vertex->childptr && !found) { - pmgraph_t *nextchild = (vertex->childptr)->data; + pmgraph_t *nextchild = f_ptrlistitem_data(vertex->childptr); vertex->childptr = (vertex->childptr)->next; if (nextchild->state == 0) { found = 1; @@ -182,7 +182,7 @@ pmlist_t *_pacman_sortbydeps(pmlist_t *targets, int mode) if(!vertex) { vptr = vptr->next; while(vptr) { - vertex = vptr->data; + vertex = f_ptrlistitem_data(vptr); if (vertex->state == 0) break; vptr = vptr->next; } @@ -224,7 +224,7 @@ pmlist_t *_pacman_checkdeps(pmtrans_t *trans, unsigned char op, pmlist_t *packag } for(i = packages; i; i = i->next) { - Package *tp = i->data; + Package *tp = f_ptrlistitem_data(i); Package *pkg_local; if(tp == NULL) { @@ -274,14 +274,14 @@ pmlist_t *_pacman_checkdeps(pmtrans_t *trans, unsigned char op, pmlist_t *packag if(!_pacman_pkg_isin(requiredby_name, packages)) { /* check if a package in trans->packages provides this package */ for(k=trans->packages; !found && k; k=k->next) { - Package *spkg = k->data; + Package *spkg = f_ptrlistitem_data(k); if(spkg && spkg->provides(pkg_local->name())) { found=1; } } for(k=trans->syncpkgs; !found && k; k=k->next) { - pmsyncpkg_t *ps = k->data; + pmsyncpkg_t *ps = f_ptrlistitem_data(k); if(ps->pkg_new->provides(pkg_local->name())) { found=1; @@ -306,7 +306,7 @@ pmlist_t *_pacman_checkdeps(pmtrans_t *trans, unsigned char op, pmlist_t *packag found = 0; /* check database for literal packages */ for(k = _pacman_db_get_pkgcache(db_local); k && !found; k = k->next) { - Package *p = (Package *)k->data; + Package *p = (Package *)f_ptrlistitem_data(k); if(!strcmp(p->name(), depend.name)) { if(depend.mod == PM_DEP_MOD_ANY) { /* accept any version */ @@ -342,11 +342,11 @@ pmlist_t *_pacman_checkdeps(pmtrans_t *trans, unsigned char op, pmlist_t *packag * to install. this way, if we match against a to-be-installed * package, we'll defer to the NEW one, not the one already * installed. */ - Package *p = m->data; + Package *p = f_ptrlistitem_data(m); pmlist_t *n; int skip = 0; for(n = packages; n && !skip; n = n->next) { - Package *ptp = n->data; + Package *ptp = f_ptrlistitem_data(n); if(!strcmp(ptp->name(), p->name())) { skip = 1; } @@ -383,7 +383,7 @@ pmlist_t *_pacman_checkdeps(pmtrans_t *trans, unsigned char op, pmlist_t *packag } /* check other targets */ for(k = packages; k && !found; k = k->next) { - Package *p = (Package *)k->data; + Package *p = (Package *)f_ptrlistitem_data(k); /* see if the package names match OR if p provides depend.name */ if(!strcmp(p->name(), depend.name) || p->provides(depend.name)) { if(depend.mod == PM_DEP_MOD_ANY || @@ -489,12 +489,12 @@ pmlist_t *_pacman_removedeps(Database *db, pmlist_t *targs) } for(i = targs; i; i = i->next) { - for(j = ((Package *)i->data)->depends(); j; j = j->next) { + for(j = ((Package *)f_ptrlistitem_data(i))->depends(); j; j = j->next) { pmdepend_t depend; Package *dep; int needed = 0; - if(_pacman_splitdep(j->data, &depend)) { + if(_pacman_splitdep(f_stringlistitem_to_str(j), &depend)) { continue; } @@ -506,7 +506,7 @@ pmlist_t *_pacman_removedeps(Database *db, pmlist_t *targs) _pacman_log(PM_LOG_WARNING, _("cannot find package \"%s\" or anything that provides it!"), depend.name); continue; } - dep = db->find(((Package *)k->data)->name()); + dep = db->find(((Package *)f_ptrlistitem_data(k))->name()); if(dep == NULL) { _pacman_log(PM_LOG_ERROR, _("dep is NULL!")); /* wtf */ @@ -577,12 +577,12 @@ int _pacman_resolvedeps(pmtrans_t *trans, Package *syncpkg, pmlist_t *list, for(i = deps; i; i = i->next) { int found = 0; - pmdepmissing_t *miss = i->data; + pmdepmissing_t *miss = f_ptrlistitem_data(i); Package *ps = NULL; /* check if one of the packages in *list already provides this dependency */ for(j = list; j && !found; j = j->next) { - Package *sp = (Package *)j->data; + Package *sp = (Package *)f_ptrlistitem_data(j); if(sp->provides(miss->depend.name)) { _pacman_log(PM_LOG_DEBUG, _("%s provides dependency %s -- skipping"), sp->name(), miss->depend.name); @@ -596,14 +596,14 @@ int _pacman_resolvedeps(pmtrans_t *trans, Package *syncpkg, pmlist_t *list, /* find the package in one of the repositories */ /* check literals */ for(j = dbs_sync; !ps && j; j = j->next) { - ps = ((Database *)j->data)->find(miss->depend.name); + ps = ((Database *)f_ptrlistitem_data(j))->find(miss->depend.name); } /* check provides */ for(j = dbs_sync; !ps && j; j = j->next) { pmlist_t *provides; - provides = ((Database *)j->data)->whatPackagesProvide(miss->depend.name); + provides = ((Database *)f_ptrlistitem_data(j))->whatPackagesProvide(miss->depend.name); if(provides) { - ps = provides->data; + ps = f_ptrlistitem_data(provides); } FREELISTPTR(provides); } @@ -615,7 +615,7 @@ int _pacman_resolvedeps(pmtrans_t *trans, Package *syncpkg, pmlist_t *list, FREELIST(*data); goto error; } - *miss = *(pmdepmissing_t *)i->data; + *miss = *(pmdepmissing_t *)f_ptrlistitem_data(i); *data = f_ptrlist_add(*data, miss); } pm_errno = PM_ERR_UNSATISFIED_DEPS; @@ -653,7 +653,7 @@ int _pacman_resolvedeps(pmtrans_t *trans, Package *syncpkg, pmlist_t *list, FREELIST(*data); goto error; } - *miss = *(pmdepmissing_t *)i->data; + *miss = *(pmdepmissing_t *)f_ptrlistitem_data(i); *data = f_ptrlist_add(*data, miss); } pm_errno = PM_ERR_UNSATISFIED_DEPS; @@ -731,7 +731,7 @@ int inList(pmlist_t *lst, char *lItem) { pmlist_t *ll; ll = lst; while(ll) { - if(!strcmp(lItem, (char *)ll->data)) { + if(!strcmp(lItem, (char *)f_ptrlistitem_data(ll))) { return 1; } ll = ll->next; @@ -748,7 +748,7 @@ int pacman_output_generate(pmlist_t *targets, pmlist_t *dblist) { int foundMatch = 0; unsigned int inforeq = INFRQ_DEPENDS; for(j = dblist; j; j = j->next) { - Database *db = j->data; + Database *db = f_ptrlistitem_data(j); do { foundMatch = 0; pkg = db->readpkg(inforeq); @@ -758,7 +758,7 @@ int pacman_output_generate(pmlist_t *targets, pmlist_t *dblist) { if(match) { foundMatch = 1; for(k = pkg->depends(); k; k = k->next) { - char *fullDep = (char *)k->data; + char *fullDep = f_stringlistitem_to_str(k); pmdepend_t depend; if(_pacman_splitdep(fullDep, &depend)) { continue; diff --git a/lib/libpacman/handle.cpp b/lib/libpacman/handle.cpp index 2a2add5..7fd115b 100644 --- a/lib/libpacman/handle.cpp +++ b/lib/libpacman/handle.cpp @@ -176,7 +176,7 @@ Database *Handle::getDatabase(const char *treename) } for(i = dbs_sync; i; i = i->next) { - Database *sdb = (Database *)i->data; + Database *sdb = (Database *)f_ptrlistitem_data(i); if(strcmp(treename, sdb->treename) == 0) { return sdb; } diff --git a/lib/libpacman/package.cpp b/lib/libpacman/package.cpp index 4effcff..31ef7c3 100644 --- a/lib/libpacman/package.cpp +++ b/lib/libpacman/package.cpp @@ -168,10 +168,10 @@ Package *_pacman_pkg_isin(const char *needle, pmlist_t *haystack) } for(lp = haystack; lp; lp = lp->next) { - Package *info = lp->data; + Package *info = f_ptrlistitem_data(lp); if(info && !strcmp(info->name(), needle)) { - return(lp->data); + return info; } } return(NULL); diff --git a/lib/libpacman/package/packagecache.cpp b/lib/libpacman/package/packagecache.cpp index f4438f4..b553745 100644 --- a/lib/libpacman/package/packagecache.cpp +++ b/lib/libpacman/package/packagecache.cpp @@ -60,7 +60,7 @@ int _pacman_packagecache_clean(int level) closedir(dir); for(i = cache; i; i = i->next) { - char *str = i->data; + char *str = f_stringlistitem_to_str(i); char name[PKG_NAME_LEN], version[PKG_VERSION_LEN]; if(strstr(str, PM_EXT_PKG) == NULL) { @@ -76,7 +76,7 @@ int _pacman_packagecache_clean(int level) continue; } for(j = i->next; j; j = j->next) { - char *s = j->data; + char *s = f_stringlistitem_to_str(j); char n[PKG_NAME_LEN], v[PKG_VERSION_LEN]; if(strstr(s, PM_EXT_PKG) == NULL) { @@ -101,7 +101,7 @@ int _pacman_packagecache_clean(int level) for(i = clean; i; i = i->next) { char path[PATH_MAX]; - snprintf(path, PATH_MAX, "%s/%s", dirpath, (char *)i->data); + snprintf(path, PATH_MAX, "%s/%s", dirpath, f_stringlistitem_to_str(i)); unlink(path); } FREELIST(clean); diff --git a/lib/libpacman/pacman.cpp b/lib/libpacman/pacman.cpp index 839f41c..c806c47 100644 --- a/lib/libpacman/pacman.cpp +++ b/lib/libpacman/pacman.cpp @@ -119,7 +119,7 @@ int pacman_release(void) /* and also sync ones */ while(handle->dbs_sync) { /* db_unregister() will also update the handle->dbs_sync list */ - pacman_db_unregister(handle->dbs_sync->data); + pacman_db_unregister(f_ptrlistitem_data(handle->dbs_sync)); } if(handle->unlock() != 0) { @@ -474,7 +474,7 @@ void *pacman_db_getinfo(pmdb_t *_db, unsigned char parm) switch(parm) { case PM_DB_TREENAME: data = db->treename; break; case PM_DB_FIRSTSERVER: - server = (pmserver_t*)db->servers->data; + server = (pmserver_t*)f_ptrlistitem_data(db->servers); if(!strcmp(server->protocol, "file")) { snprintf(path, PATH_MAX, "%s://%s", server->protocol, server->path); } else { @@ -511,7 +511,7 @@ int pacman_db_setserver(pmdb_t *_db, char *url) } else { pmlist_t *i; for(i = handle->dbs_sync; i && !found; i = i->next) { - Database *sdb = i->data; + Database *sdb = f_ptrlistitem_data(i); if(strcmp(db->treename, sdb->treename) == 0) { found = 1; } @@ -1025,7 +1025,7 @@ pmlist_t *pacman_db_search(pmdb_t *_db) /* Sanity checks */ ASSERT(handle != NULL, return(NULL)); ASSERT(handle->needles != NULL, return(NULL)); - ASSERT(handle->needles->data != NULL, return(NULL)); + ASSERT(f_ptrlistitem_data(handle->needles) != NULL, return(NULL)); ASSERT(db != NULL, return(NULL)); ret = db->filter(handle->needles, @@ -1370,7 +1370,7 @@ void *pacman_list_iterator_getdata(pmlist_iterator_t *iterator) { ASSERT(iterator != NULL, return NULL); - return cxx_cast(iterator)->data; + return f_ptrlistitem_data(cxx_cast(iterator)); } /** @} */ diff --git a/lib/libpacman/server.cpp b/lib/libpacman/server.cpp index 291da7b..5131714 100644 --- a/lib/libpacman/server.cpp +++ b/lib/libpacman/server.cpp @@ -401,11 +401,11 @@ int _pacman_downloadfiles_forreal(Handle *handle, pmlist_t *servers, const char if (count < skip) continue; /* the caller requested skip of this server */ _pacman_log(PM_LOG_DEBUG, _("server check, done? %d\n"),done); - server = (pmserver_t*)i->data; + server = (pmserver_t*)f_ptrlistitem_data(i); /* get each file in the list */ for(lp = files; lp; lp = lp->next) { - char *fn = (char *)lp->data; + char *fn = f_stringlistitem_to_str(lp); if(_pacman_list_is_strin(fn, complete)) { continue; diff --git a/lib/libpacman/trans.cpp b/lib/libpacman/trans.cpp index 86c43c0..9238cb1 100644 --- a/lib/libpacman/trans.cpp +++ b/lib/libpacman/trans.cpp @@ -134,12 +134,12 @@ int _pacman_trans_compute_triggers(pmtrans_t *trans) /* NOTE: Not the most efficient way, but will do until we add some string hash. */ for(lp = trans->packages; lp; lp = lp->next) { - Package *pkg = lp->data; + Package *pkg = f_ptrlistitem_data(lp); trans->triggers = f_stringlist_append_stringlist(trans->triggers, pkg->triggers()); } for(lp = trans->syncpkgs; lp; lp = lp->next) { - Package *pkg = ((pmsyncpkg_t *)lp->data)->pkg_new; + Package *pkg = ((pmsyncpkg_t *)f_ptrlistitem_data(lp))->pkg_new; /* FIXME: might be incomplete */ trans->triggers = f_stringlist_append_stringlist(trans->triggers, pkg->triggers()); @@ -200,7 +200,7 @@ pmsyncpkg_t *__pmtrans_t::find(const char *pkgname) const pmlist_t *i; for(i = syncpkgs; i != NULL ; i = i->next) { - pmsyncpkg_t *ps = i->data; + pmsyncpkg_t *ps = f_ptrlistitem_data(i); if(ps && !strcmp(ps->pkg_name, pkgname)) { return ps; @@ -252,7 +252,7 @@ static int check_olddelay(Handle *handle) } for(i = handle->dbs_sync; i; i= i->next) { - Database *db = i->data; + Database *db = f_ptrlistitem_data(i); if(db->gettimestamp(&tm) == -1) { continue; } @@ -330,7 +330,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t type, int flags) *targ = '\0'; targ++; for(i = dbs_sync; i && !spkg; i = i->next) { - Database *dbs = i->data; + Database *dbs = f_ptrlistitem_data(i); if(strcmp(dbs->treename, targline) == 0) { spkg = dbs->find(targ); if(spkg == NULL) { @@ -350,14 +350,14 @@ int __pmtrans_t::add(const char *target, pmtranstype_t type, int flags) } else { targ = targline; for(i = dbs_sync; i && !spkg; i = i->next) { - Database *dbs = i->data; + Database *dbs = f_ptrlistitem_data(i); spkg = dbs->find(targ); } if(spkg == NULL) { /* Search provides */ _pacman_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ); for(i = dbs_sync; i && !spkg; i = i->next) { - Database *dbs = i->data; + Database *dbs = f_ptrlistitem_data(i); pmlist_t *p = dbs->whatPackagesProvide(targ); if(p != NULL) { spkg = f_ptrlistitem_data(p); @@ -442,7 +442,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t type, int flags) /* check if an older version of said package is already in transaction packages. * if so, replace it in the list */ for(i = packages; i; i = i->next) { - Package *pkg = i->data; + Package *pkg = f_ptrlistitem_data(i); if(strcmp(pkg->name(), pkg_new->name()) == 0) { pkg_queued = pkg; break; @@ -453,7 +453,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t type, int flags) if(_pacman_versioncmp(pkg_queued->version(), pkg_new->version()) < 0) { _pacman_log(PM_LOG_WARNING, _("replacing older version %s-%s by %s in target list"), pkg_queued->name(), pkg_queued->version(), pkg_new->version()); - f_ptrswap(&i->data, (void **)&pkg_new); + f_ptrswap(&i->m_data, (void **)&pkg_new); } else { _pacman_log(PM_LOG_WARNING, _("newer version %s-%s is in the target list -- skipping"), pkg_queued->name(), pkg_queued->version(), pkg_new->version()); @@ -521,7 +521,7 @@ int __pmtrans_t::prepare(pmlist_t **data) if(m_type == PM_TRANS_TYPE_SYNC) { for(i = syncpkgs; i; i = i->next) { - pmsyncpkg_t *ps = i->data; + pmsyncpkg_t *ps = f_ptrlistitem_data(i); list = f_ptrlist_add(list, ps->pkg_new); } @@ -532,7 +532,7 @@ int __pmtrans_t::prepare(pmlist_t **data) EVENT(this, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL); _pacman_log(PM_LOG_FLOW1, _("resolving targets dependencies")); for(i = syncpkgs; i; i = i->next) { - Package *spkg = ((pmsyncpkg_t *)i->data)->pkg_new; + Package *spkg = ((pmsyncpkg_t *)f_ptrlistitem_data(i))->pkg_new; if(_pacman_resolvedeps(this, spkg, list, trail, data) == -1) { /* pm_errno is set by resolvedeps */ ret = -1; @@ -542,7 +542,7 @@ int __pmtrans_t::prepare(pmlist_t **data) for(i = list; i; i = i->next) { /* add the dependencies found by resolvedeps to the transaction set */ - Package *spkg = i->data; + Package *spkg = f_ptrlistitem_data(i); if(!find(spkg->name())) { pmsyncpkg_t *ps = new __pmsyncpkg_t(PM_SYNC_TYPE_DEPEND, spkg, NULL); if(ps == NULL) { @@ -564,14 +564,14 @@ int __pmtrans_t::prepare(pmlist_t **data) /* re-order w.r.t. dependencies */ k = l = NULL; for(i=syncpkgs; i; i=i->next) { - pmsyncpkg_t *s = (pmsyncpkg_t*)i->data; + pmsyncpkg_t *s = (pmsyncpkg_t*)f_ptrlistitem_data(i); k = f_ptrlist_add(k, s->pkg_new); } m = _pacman_sortbydeps(k, PM_TRANS_TYPE_ADD); for(i=m; i; i=i->next) { for(j=syncpkgs; j; j=j->next) { - pmsyncpkg_t *s = (pmsyncpkg_t*)j->data; - if(s->pkg_new == i->data) { + pmsyncpkg_t *s = (pmsyncpkg_t*)f_ptrlistitem_data(j); + if(s->pkg_new == f_ptrlistitem_data(i)) { l = f_ptrlist_add(l, s); } } @@ -607,7 +607,7 @@ int __pmtrans_t::prepare(pmlist_t **data) int errorout = 0; for(i = deps; i && !errorout; i = i->next) { - pmdepmissing_t *miss = i->data; + pmdepmissing_t *miss = f_ptrlistitem_data(i); int found = 0; pmsyncpkg_t *ps; Package *local; @@ -619,7 +619,7 @@ int __pmtrans_t::prepare(pmlist_t **data) * if so, then just ignore it */ for(j = syncpkgs; j && !found; j = j->next) { - ps = j->data; + ps = f_ptrlistitem_data(j); if(ps->type == PM_SYNC_TYPE_REPLACE) { if(_pacman_pkg_isin(miss->depend.name, ps->data)) { found = 1; @@ -738,7 +738,7 @@ int __pmtrans_t::prepare(pmlist_t **data) ret = -1; goto cleanup; } - *miss = *(pmdepmissing_t *)i->data; + *miss = *(pmdepmissing_t *)f_ptrlistitem_data(i); *data = f_ptrlist_add(*data, miss); } } @@ -752,7 +752,7 @@ int __pmtrans_t::prepare(pmlist_t **data) ret = -1; goto cleanup; } - *miss = *(pmdepmissing_t *)i->data; + *miss = *(pmdepmissing_t *)f_ptrlistitem_data(i); *data = f_ptrlist_add(*data, miss); } } @@ -786,10 +786,10 @@ int __pmtrans_t::prepare(pmlist_t **data) */ /*EVENT(this, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);*/ for(i = syncpkgs; i; i = i->next) { - pmsyncpkg_t *ps = i->data; + pmsyncpkg_t *ps = f_ptrlistitem_data(i); if(ps->type == PM_SYNC_TYPE_REPLACE) { for(j = ps->data; j; j = j->next) { - list = f_ptrlist_add(list, j->data); + list = f_ptrlist_add(list, f_ptrlistitem_data(j)); } } } @@ -799,7 +799,7 @@ int __pmtrans_t::prepare(pmlist_t **data) if(deps) { int errorout = 0; for(i = deps; i; i = i->next) { - pmdepmissing_t *miss = i->data; + pmdepmissing_t *miss = f_ptrlistitem_data(i); if(!find(miss->depend.name)) { int pfound = 0; /* If miss->depend.name depends on something that miss->target and a @@ -822,12 +822,12 @@ int __pmtrans_t::prepare(pmlist_t **data) * is an unresolvable conflict. */ pmlist_t *n, *o; for(n = syncpkgs; n && !pfound; n = n->next) { - pmsyncpkg_t *sp = n->data; + pmsyncpkg_t *sp = f_ptrlistitem_data(n); for(o = sp->pkg_new->provides(); o && !pfound; o = o->next) { if(!strcmp(f_stringlistitem_to_str(m), f_stringlistitem_to_str(o))) { /* found matching provisio -- we're good to go */ _pacman_log(PM_LOG_FLOW2, _("found '%s' as a provision for '%s' -- conflict aborted"), - sp->pkg_name, (char *)o->data); + sp->pkg_name, f_stringlistitem_to_str(o)); pfound = 1; } } @@ -845,7 +845,7 @@ int __pmtrans_t::prepare(pmlist_t **data) ret = -1; goto cleanup; } - *miss = *(pmdepmissing_t *)i->data; + *miss = *(pmdepmissing_t *)f_ptrlistitem_data(i); *data = f_ptrlist_add(*data, miss); } } @@ -899,7 +899,7 @@ cleanup: while(lp) { pmlist_t *i; for(i = lp; i; i = i->next) { - pmdepmissing_t *miss = (pmdepmissing_t *)i->data; + pmdepmissing_t *miss = (pmdepmissing_t *)f_ptrlistitem_data(i); Package *pkg_local = db_local->scan(miss->depend.name, INFRQ_ALL); if(pkg_local) { _pacman_log(PM_LOG_FLOW2, _("pulling %s in the targets list"), pkg_local->name()); @@ -966,13 +966,13 @@ cleanup: EVENT(this, PM_TRANS_EVT_CLEANUP_START, NULL, NULL); _pacman_log(PM_LOG_FLOW1, _("cleaning up")); for (lp = packages; lp!=NULL; lp=lp->next) { - Package *pkg_new=(Package *)lp->data; + Package *pkg_new = (Package *)f_ptrlistitem_data(lp); pmlist_t *rmlist; for (rmlist=pkg_new->removes(); rmlist!=NULL; rmlist=rmlist->next) { char rm_fname[PATH_MAX]; - snprintf(rm_fname, PATH_MAX, "%s%s", m_handle->root, (char *)rmlist->data); + snprintf(rm_fname, PATH_MAX, "%s%s", m_handle->root, f_stringlistitem_to_str(rmlist)); remove(rm_fname); } } @@ -1142,7 +1142,7 @@ int _pacman_fpmpackage_install(Package *pkg, pmtranstype_t type, pmtrans_t *tran */ for(lp = pkg->backup(); lp; lp = lp->next) { char *fn; - char *file = lp->data; + char *file = f_stringlistitem_to_str(lp); if(!file) continue; if(!strcmp(file, pathname)) { @@ -1153,7 +1153,7 @@ int _pacman_fpmpackage_install(Package *pkg, pmtranstype_t type, pmtrans_t *tran } sprintf(fn, "%s\t%s", file, md5_pkg); FREE(file); - lp->data = fn; + lp->m_data = fn; } else { /* 41 for the hash, 1 for the terminating NULL, and 1 for the tab delimiter */ if((fn = (char *)malloc(strlen(file)+43)) == NULL) { @@ -1161,7 +1161,7 @@ int _pacman_fpmpackage_install(Package *pkg, pmtranstype_t type, pmtrans_t *tran } sprintf(fn, "%s\t%s", file, sha1_pkg); FREE(file); - lp->data = fn; + lp->m_data = fn; } } } @@ -1273,7 +1273,7 @@ int _pacman_fpmpackage_install(Package *pkg, pmtranstype_t type, pmtrans_t *tran for(lp = pkg->backup(); lp; lp = lp->next) { char *fn, *md5, *sha1; char path[PATH_MAX]; - char *file = lp->data; + char *file = f_stringlistitem_to_str(lp); if(!file) continue; if(!strcmp(file, pathname)) { @@ -1297,7 +1297,7 @@ int _pacman_fpmpackage_install(Package *pkg, pmtranstype_t type, pmtrans_t *tran FREE(sha1); } FREE(file); - lp->data = fn; + lp->m_data = fn; } } } @@ -1449,10 +1449,10 @@ int __pmtrans_t::commit(pmlist_t **data) int done = 1; for(i = m_handle->dbs_sync; i; i = i->next) { struct stat buf; - Database *current = i->data; + Database *current = f_ptrlistitem_data(i); for(j = syncpkgs; j; j = j->next) { - pmsyncpkg_t *ps = j->data; + pmsyncpkg_t *ps = f_ptrlistitem_data(j); Package *spkg = ps->pkg_new; Database *dbs = spkg->database(); @@ -1518,7 +1518,7 @@ int __pmtrans_t::commit(pmlist_t **data) EVENT(this, PM_TRANS_EVT_INTEGRITY_START, NULL, NULL); for(i = syncpkgs; i; i = i->next) { - pmsyncpkg_t *ps = i->data; + pmsyncpkg_t *ps = f_ptrlistitem_data(i); retval = _pacman_cachedpkg_check_integrity(ps->pkg_new, this, data); } @@ -1557,10 +1557,10 @@ int __pmtrans_t::commit(pmlist_t **data) tr->conv.connect(&conv); tr->progress.connect(&progress); for(i = syncpkgs; i; i = i->next) { - pmsyncpkg_t *ps = i->data; + pmsyncpkg_t *ps = f_ptrlistitem_data(i); if(ps->type == PM_SYNC_TYPE_REPLACE) { for(j = ps->data; j; j = j->next) { - Package *pkg = j->data; + Package *pkg = f_ptrlistitem_data(j); if(!_pacman_pkg_isin(pkg->name(), tr->packages)) { if(tr->add(pkg->name(), tr->m_type, tr->flags) == -1) { goto error; @@ -1596,7 +1596,7 @@ int __pmtrans_t::commit(pmlist_t **data) tr->conv.connect(&conv); tr->progress.connect(&progress); for(i = syncpkgs; i; i = i->next) { - pmsyncpkg_t *ps = i->data; + pmsyncpkg_t *ps = f_ptrlistitem_data(i); Package *spkg = ps->pkg_new; char str[PATH_MAX]; snprintf(str, PATH_MAX, "%s%s/%s-%s-%s" PM_EXT_PKG, m_handle->root, m_handle->cachedir, spkg->name(), spkg->version(), spkg->arch); @@ -1605,7 +1605,7 @@ int __pmtrans_t::commit(pmlist_t **data) } /* using f_ptrlist_last() is ok because addtarget() adds the new target at the * end of the tr->packages list */ - spkg = f_ptrlist_last(tr->packages)->data; + spkg = f_ptrlistitem_data(f_ptrlist_last(tr->packages)); if(ps->type == PM_SYNC_TYPE_DEPEND || flags & PM_TRANS_FLAG_ALLDEPS) { spkg->m_reason = PM_PKG_REASON_DEPEND; } else if(ps->type == PM_SYNC_TYPE_UPGRADE && !m_handle->sysupgrade) { @@ -1628,12 +1628,12 @@ int __pmtrans_t::commit(pmlist_t **data) if(replaces) { _pacman_log(PM_LOG_FLOW1, _("updating database for replaced packages' dependencies")); for(i = syncpkgs; i; i = i->next) { - pmsyncpkg_t *ps = i->data; + pmsyncpkg_t *ps = f_ptrlistitem_data(i); if(ps->type == PM_SYNC_TYPE_REPLACE) { Package *pkg_new = db_local->find(ps->pkg_name); for(j = ps->data; j; j = j->next) { pmlist_t *k; - Package *old = j->data; + Package *old = f_ptrlistitem_data(j); /* merge lists */ for(k = old->requiredby(); k; k = k->next) { if(!_pacman_list_is_strin(f_stringlistitem_to_str(k), pkg_new->requiredby())) { @@ -1649,8 +1649,8 @@ int __pmtrans_t::commit(pmlist_t **data) } for(m = depender->depends(); m; m = m->next) { if(!strcmp(f_stringlistitem_to_str(m), old->name())) { - FREE(m->data); - m->data = strdup(pkg_new->name()); + FREE(m->m_data); + m->m_data = strdup(pkg_new->name()); } } if(db_local->write(depender, INFRQ_DEPENDS) == -1) { @@ -1701,9 +1701,9 @@ int __pmtrans_t::commit(pmlist_t **data) } if(type & PM_TRANS_TYPE_ADD) { - pkg_new = (Package *)targ->data; + pkg_new = (Package *)f_ptrlistitem_data(targ); } else { - pkg_local = (Package *)targ->data; + pkg_local = (Package *)f_ptrlistitem_data(targ); } /* see if this is an upgrade. if so, remove the old package first */ @@ -1791,7 +1791,7 @@ int __pmtrans_t::commit(pmlist_t **data) Package *depinfo = NULL; pmdepend_t depend; char *data; - if(_pacman_splitdep((char*)lp->data, &depend)) { + if(_pacman_splitdep((char*)f_stringlistitem_to_str(lp), &depend)) { continue; } /* if this dependency is in the transaction targets, no need to update @@ -1810,7 +1810,7 @@ int __pmtrans_t::commit(pmlist_t **data) * the first one. */ /* use the first one */ - depinfo = db_local->find(((Package *)provides->data)->name()); + depinfo = db_local->find(((Package *)f_ptrlistitem_data(provides))->name()); FREELISTPTR(provides); } if(depinfo == NULL) { @@ -1851,17 +1851,17 @@ int __pmtrans_t::commit(pmlist_t **data) /* Update the requiredby field by scanning the whole database * looking for packages depending on the package to add */ for(lp = _pacman_db_get_pkgcache(db_local); lp; lp = lp->next) { - Package *tmpp = lp->data; + Package *tmpp = f_ptrlistitem_data(lp); pmlist_t *tmppm = NULL; if(tmpp == NULL) { continue; } for(tmppm = tmpp->depends(); tmppm; tmppm = tmppm->next) { pmdepend_t depend; - if(_pacman_splitdep(tmppm->data, &depend)) { + if(_pacman_splitdep(f_ptrlistitem_data(tmppm), &depend)) { continue; } - if(tmppm->data && (!strcmp(depend.name, pkg_new->name()) || pkg_new->provides(depend.name))) { + if(f_ptrlistitem_data(tmppm) && (!strcmp(depend.name, pkg_new->name()) || pkg_new->provides(depend.name))) { _pacman_log(PM_LOG_DEBUG, _("adding '%s' in requiredby field for '%s'"), tmpp->name(), pkg_new->name()); pkg_new->m_requiredby = _pacman_stringlist_append(pkg_new->m_requiredby, tmpp->name()); } @@ -1891,7 +1891,7 @@ int __pmtrans_t::commit(pmlist_t **data) for(lp = pkg_new->depends(); lp; lp = lp->next) { Package *depinfo; pmdepend_t depend; - if(_pacman_splitdep(lp->data, &depend)) { + if(_pacman_splitdep(f_stringlistitem_to_str(lp), &depend)) { continue; } depinfo = db_local->find(depend.name); @@ -1903,7 +1903,7 @@ int __pmtrans_t::commit(pmlist_t **data) * the first one. */ /* use the first one */ - depinfo = db_local->find(((Package *)provides->data)->name()); + depinfo = db_local->find(((Package *)f_ptrlistitem_data(provides))->name()); FREELISTPTR(provides); } if(depinfo == NULL) { diff --git a/lib/libpacman/trans_sysupgrade.cpp b/lib/libpacman/trans_sysupgrade.cpp index 9ff3429..5cab5e0 100644 --- a/lib/libpacman/trans_sysupgrade.cpp +++ b/lib/libpacman/trans_sysupgrade.cpp @@ -87,21 +87,21 @@ int _pacman_trans_sysupgrade(pmtrans_t *trans) /* check for "recommended" package replacements */ _pacman_log(PM_LOG_FLOW1, _("checking for package replacements")); for(i = dbs_sync; i; i = i->next) { - for(j = _pacman_db_get_pkgcache(i->data); j; j = j->next) { - Package *spkg = j->data; + for(j = _pacman_db_get_pkgcache(f_ptrlistitem_data(i)); j; j = j->next) { + Package *spkg = f_ptrlistitem_data(j); for(k = spkg->replaces(); k; k = k->next) { pmlist_t *m; for(m = _pacman_db_get_pkgcache(db_local); m; m = m->next) { - Package *lpkg = m->data; + Package *lpkg = f_ptrlistitem_data(m); if(!strcmp(f_stringlistitem_to_str(k), lpkg->name())) { - _pacman_log(PM_LOG_DEBUG, _("checking replacement '%s' for package '%s'"), k->data, spkg->name()); + _pacman_log(PM_LOG_DEBUG, _("checking replacement '%s' for package '%s'"), f_stringlistitem_to_str(k), spkg->name()); if(_pacman_list_is_strin(lpkg->name(), handle->ignorepkg)) { _pacman_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (to be replaced by %s-%s)"), lpkg->name(), lpkg->version(), spkg->name(), spkg->version()); } else { /* get confirmation for the replacement */ int doreplace = 0; - QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, ((Database *)i->data)->treename, &doreplace); + QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, ((Database *)f_ptrlistitem_data(i))->treename, &doreplace); if(doreplace) { /* if confirmed, add this to the 'final' list, designating 'lpkg' as @@ -141,12 +141,12 @@ int _pacman_trans_sysupgrade(pmtrans_t *trans) for(i = _pacman_db_get_pkgcache(db_local); i; i = i->next) { int cmp; int replace=0; - Package *local = i->data; + Package *local = f_ptrlistitem_data(i); Package *spkg = NULL; pmsyncpkg_t *ps; for(j = dbs_sync; !spkg && j; j = j->next) { - spkg = ((Database *)j->data)->find(local->name()); + spkg = ((Database *)f_ptrlistitem_data(j))->find(local->name()); } if(spkg == NULL) { _pacman_log(PM_LOG_DEBUG, _("'%s' not found in sync db -- skipping"), local->name()); @@ -155,7 +155,7 @@ int _pacman_trans_sysupgrade(pmtrans_t *trans) /* we don't care about a to-be-replaced package's newer version */ for(j = trans->syncpkgs; j && !replace; j=j->next) { - ps = j->data; + ps = f_ptrlistitem_data(j); if(ps->type == PM_SYNC_TYPE_REPLACE) { if(_pacman_pkg_isin(spkg->name(), ps->data)) { replace=1; diff --git a/lib/libpacman/util.cpp b/lib/libpacman/util.cpp index 6541a92..5e7dfb0 100644 --- a/lib/libpacman/util.cpp +++ b/lib/libpacman/util.cpp @@ -129,7 +129,7 @@ static int list_startswith(char *needle, pmlist_t *haystack) pmlist_t *i; for (i = haystack; i; i = i->next) { - cache_t *c = i->data; + cache_t *c = f_ptrlistitem_data(i); if (!strncmp(c->str, needle, strlen(c->str))) { c->hit = 1; return(1); @@ -199,7 +199,7 @@ int _pacman_unpack(const char *archive, const char *prefix, const char *fn) /* finally delete the old ones */ for (i = cache; i; i = i->next) { - cache_t *c = i->data; + cache_t *c = f_ptrlistitem_data(i); if (!c->hit) { snprintf(expath, PATH_MAX, "%s/%s", prefix, c->str); _pacman_rmrf(expath); @@ -485,11 +485,11 @@ int _pacman_check_freespace(pmtrans_t *trans, pmlist_t **data) long long pkgsize=0, freespace; for(i = trans->packages; i; i = i->next) { - Package *pkg = i->data; + Package *pkg = f_ptrlistitem_data(i); pkgsize += pkg->size; } for(i = trans->syncpkgs; i; i = i->next) { - pmsyncpkg_t *ps = i->data; + pmsyncpkg_t *ps = f_ptrlistitem_data(i); if(ps->type != PM_SYNC_TYPE_REPLACE) { Package *pkg = ps->pkg_new; diff --git a/lib/libpacman/util/fptrlist.c b/lib/libpacman/util/fptrlist.c index f8898ba..e1fdd1f 100644 --- a/lib/libpacman/util/fptrlist.c +++ b/lib/libpacman/util/fptrlist.c @@ -38,11 +38,11 @@ FPtrList *f_ptrlist_add_sorted(FPtrList *list, void *data, _pacman_fn_cmp fn) FPtrListItem *add, *end = f_ptrlist_end(list), *prev = NULL, *iter = f_ptrlist_first(list); add = f_ptrlist_new(); - add->data = data; + add->m_data = data; /* Find insertion point. */ while(iter != end) { - if(fn(add->data, iter->data) <= 0) break; + if(fn(f_ptrlistitem_data(add), f_ptrlistitem_data(iter)) <= 0) break; prev = iter; iter = iter->next; } @@ -79,10 +79,10 @@ FPtrList *_pacman_list_remove(FPtrList *haystack, void *needle, _pacman_fn_cmp f } while(i) { - if(i->data == NULL) { + if(i->m_data == NULL) { continue; } - if(fn(needle, i->data) == 0) { + if(fn(needle, i->m_data) == 0) { break; } i = i->next; @@ -102,9 +102,9 @@ FPtrList *_pacman_list_remove(FPtrList *haystack, void *needle, _pacman_fn_cmp f } if(data) { - *data = i->data; + *data = i->m_data; } - i->data = NULL; + i->m_data = NULL; free(i); } @@ -124,7 +124,7 @@ FPtrList *_pacman_list_reverse(FPtrList *list) FPtrListItem *it; for(it = f_ptrlist_last(list); it; it = f_ptrlistitem_previous(it)) { - newlist = f_ptrlist_add(newlist, it->data); + newlist = f_ptrlist_add(newlist, f_ptrlistitem_data(it)); } return(newlist); @@ -149,7 +149,7 @@ FPtrListItem *f_ptrlistitem_new(void *ptr) FPtrListItem *item = f_zalloc(sizeof(*item)); if(item != NULL) { - item->data = ptr; + item->m_data = ptr; } return item; } @@ -167,7 +167,7 @@ void *f_ptrlistitem_data(const FPtrListItem *self) { ASSERT(self != NULL, RET_ERR(PM_ERR_WRONG_ARGS, NULL)); - return self->data; + return self->m_data; } int f_ptrlistitem_insert_after(FPtrListItem *self, FPtrListItem *previous) @@ -203,7 +203,7 @@ FPtrListItem *f_ptrlistitem_previous(FPtrListItem *self) } int f_ptrlistitem_ptrcmp(const FPtrListItem *item, const void *ptr) { - return f_ptrcmp(item->data, ptr); + return f_ptrcmp(item->m_data, ptr); } FPtrList *f_ptrlist_new(void) @@ -247,7 +247,7 @@ FPtrList *f_ptrlist_append(FPtrList *list, void *data) } lp = f_ptrlist_last(ptr); - if(lp == ptr && lp->data == NULL) { + if(lp == ptr && lp->m_data == NULL) { /* nada */ } else { lp->next = f_ptrlist_new(); @@ -258,7 +258,7 @@ FPtrList *f_ptrlist_append(FPtrList *list, void *data) lp = lp->next; } - lp->data = data; + lp->m_data = data; return(ptr); } diff --git a/lib/libpacman/util/fptrlist.h b/lib/libpacman/util/fptrlist.h index f61ea4d..26b0371 100644 --- a/lib/libpacman/util/fptrlist.h +++ b/lib/libpacman/util/fptrlist.h @@ -37,7 +37,7 @@ extern "C" { struct __pmlist_t { struct __pmlist_t *prev; struct __pmlist_t *next; - void *data; + void *m_data; }; typedef struct __pmlist_t FPtrList; diff --git a/lib/libpacman/util/stringlist.c b/lib/libpacman/util/stringlist.c index 29d9ab0..9d635f8 100644 --- a/lib/libpacman/util/stringlist.c +++ b/lib/libpacman/util/stringlist.c @@ -37,7 +37,9 @@ int _pacman_list_is_strin(const char *needle, FStringList *haystack) FStringList *lp; for(lp = haystack; lp; lp = lp->next) { - if(lp->data && !strcmp(lp->data, needle)) { + const char *str = f_stringlistitem_to_str(lp); + + if(str && !strcmp(str, needle)) { return(1); } } @@ -55,8 +57,10 @@ FStringList *_pacman_list_remove_dupes(FStringList *list) FStringList *i, *newlist = NULL; for(i = list; i; i = i->next) { - if(!_pacman_list_is_strin(i->data, newlist)) { - newlist = _pacman_stringlist_append(newlist, i->data); + const char *str = f_stringlistitem_to_str(i); + + if(!_pacman_list_is_strin(str, newlist)) { + newlist = _pacman_stringlist_append(newlist, str); } } return newlist; @@ -68,7 +72,7 @@ FStringList *_pacman_list_strdup(FStringList *list) FStringList *lp; for(lp = list; lp; lp = lp->next) { - newlist = f_stringlist_append(newlist, lp->data); + newlist = f_stringlist_append(newlist, f_stringlistitem_to_str(lp)); } return(newlist); @@ -125,7 +129,7 @@ FStringList *f_stringlist_append_stringlist(FStringList *dest, const FStringList const FStringList *lp; for(lp = src; lp; lp = lp->next) { - dest = f_stringlist_append(dest, lp->data); + dest = f_stringlist_append(dest, f_stringlistitem_to_str(lp)); } return dest; } diff --git a/src/pacman-g2/deptest.c b/src/pacman-g2/deptest.c index 4b2b32e..ef3e9b8 100644 --- a/src/pacman-g2/deptest.c +++ b/src/pacman-g2/deptest.c @@ -79,9 +79,9 @@ int deptestpkg(list_t *targets) } strcpy(str, "name=dummy|version=1.0-1"); for(i = targets; i; i = i->next) { - str = (char *)realloc(str, strlen(str)+8+strlen(i->data)+1); + str = (char *)realloc(str, strlen(str)+8+strlen(list_data(i))+1); strcat(str, "|depend="); - strcat(str, i->data); + strcat(str, list_data(i)); } vprint(_("add target %s\n"), str); if(pacman_trans_addtarget(pacman_get_trans(), PM_TRANS_TYPE_ADD, str, 0) == -1) { diff --git a/src/pacman-g2/list.c b/src/pacman-g2/list.c index b9182b3..0b7925f 100644 --- a/src/pacman-g2/list.c +++ b/src/pacman-g2/list.c @@ -36,7 +36,7 @@ void list_free(list_t *list) while(it) { ptr = it->next; - free(it->data); + free(list_data(it)); free(it); it = ptr; } @@ -50,7 +50,9 @@ int list_is_strin(char *needle, list_t *haystack) list_t *lp; for(lp = haystack; lp; lp = lp->next) { - if(lp->data && !strcmp(lp->data, needle)) { + char *str = list_data(lp); + + if(str && !strcmp(str, needle)) { return(1); } } @@ -69,7 +71,7 @@ void list_display(const char *title, const FStringList *list) if(list) { for(lp = list, cols = len; lp; lp = lp->next) { - int s = strlen((char *)lp->data)+1; + int s = strlen((char *)list_data(lp))+1; if(s+cols >= maxcols) { int i; cols = len; @@ -78,7 +80,7 @@ void list_display(const char *title, const FStringList *list) printf(" "); } } - printf("%s ", (char *)lp->data); + printf("%s ", (char *)list_data(lp)); cols += s; } printf("\n"); diff --git a/src/pacman-g2/list.h b/src/pacman-g2/list.h index 002cbc9..a2db75e 100644 --- a/src/pacman-g2/list.h +++ b/src/pacman-g2/list.h @@ -32,6 +32,7 @@ typedef FPtrList list_t; void list_free(list_t *list); #define list_add f_ptrlist_add #define list_count f_ptrlist_count +#define list_data f_ptrlistitem_data int list_is_strin(char *needle, list_t *haystack); void list_display(const char *title, const FStringList *list); diff --git a/src/pacman-g2/pacman-g2.c b/src/pacman-g2/pacman-g2.c index 10aedf6..2d2ce14 100644 --- a/src/pacman-g2/pacman-g2.c +++ b/src/pacman-g2/pacman-g2.c @@ -587,7 +587,7 @@ int main(int argc, char *argv[]) pacman_get_option(PM_OPT_CACHEDIR, (long *)&config->cachedir); for(lp = config->op_s_ignore; lp; lp = lp->next) { - if(pacman_set_option(PM_OPT_IGNOREPKG, (long)lp->data) == -1) { + if(pacman_set_option(PM_OPT_IGNOREPKG, (long)list_data(lp)) == -1) { ERR(NL, _("failed to set option IGNOREPKG (%s)\n"), pacman_strerror(pm_errno)); cleanup(1); } diff --git a/src/pacman-g2/ps.c b/src/pacman-g2/ps.c index fb2e6d0..40cab4e 100644 --- a/src/pacman-g2/ps.c +++ b/src/pacman-g2/ps.c @@ -214,7 +214,7 @@ int pspkg(int countonly) list_t* ret = ps_parse(fpout); for (i = ret; i; i = i->next) { - ps_t *ps = i->data; + ps_t *ps = list_data(i); if (!ps) continue; if (!countonly) { diff --git a/src/pacman-g2/query.c b/src/pacman-g2/query.c index 4707960..b5fe792 100644 --- a/src/pacman-g2/query.c +++ b/src/pacman-g2/query.c @@ -52,7 +52,7 @@ int querypkg(list_t *targets) if(config->op_q_search) { for(i = targets; i; i = i->next) { - pacman_set_option(PM_OPT_NEEDLES, (long)i->data); + pacman_set_option(PM_OPT_NEEDLES, (long)list_data(i)); } ret = pacman_db_search(db_local); if(ret == NULL) { @@ -94,7 +94,7 @@ int querypkg(list_t *targets) if(targ->next == NULL) { done = 1; } - package = targ->data; + package = list_data(targ); } /* looking for groups */ @@ -202,7 +202,7 @@ int querypkg(list_t *targets) if(config->op_q_foreign) { int match = 0; for(i = pmc_syncs; i; i = i->next) { - PM_DB *db = i->data; + PM_DB *db = list_data(i); for(j = pacman_db_getpkgcache(db); j; j = pacman_list_next(j)) { PM_PKG *pkg = pacman_list_getdata(j); char *haystack; diff --git a/src/pacman-g2/sync.c b/src/pacman-g2/sync.c index 9f2b39d..0b1d74c 100644 --- a/src/pacman-g2/sync.c +++ b/src/pacman-g2/sync.c @@ -61,7 +61,7 @@ static int sync_synctree(int level, list_t *syncs) int success = 0, ret; for(i = syncs; i; i = i->next) { - PM_DB *db = i->data; + PM_DB *db = list_data(i); ret = pacman_db_update((level < 2 ? 0 : 1), db); if(ret == -1) { @@ -87,11 +87,11 @@ static int sync_search(list_t *syncs, list_t *targets) PM_PKG *ipkg; for(i = syncs; i; i = i->next) { - PM_DB *db = i->data; + PM_DB *db = list_data(i); PM_LIST *lp; for(j = targets; j; j = j->next) { - pacman_set_option(PM_OPT_NEEDLES, (long)j->data); + pacman_set_option(PM_OPT_NEEDLES, (long)list_data(j)); } ret = pacman_db_search(db); if(ret == NULL) { @@ -129,8 +129,8 @@ static int sync_group(int level, list_t *syncs, list_t *targets) for(i = targets; i; i = i->next) { int found = 0; for(j = syncs; j; j = j->next) { - PM_DB *db = j->data; - PM_GRP *grp = pacman_db_readgrp(db, i->data); + PM_DB *db = list_data(j); + PM_GRP *grp = pacman_db_readgrp(db, list_data(i)); if(grp) { MSG(NL, "%s\n", (char *)pacman_grp_getinfo(grp, PM_GRP_NAME)); @@ -139,13 +139,13 @@ static int sync_group(int level, list_t *syncs, list_t *targets) } } if (!found) { - ERR(NL, _("group \"%s\" was not found\n"), (char *)i->data); + ERR(NL, _("group \"%s\" was not found\n"), (char *)list_data(i)); ret = 1; } } } else { for(j = syncs; j; j = j->next) { - PM_DB *db = j->data; + PM_DB *db = list_data(j); PM_LIST *lp; for(lp = pacman_db_getgrpcache(db); lp; lp = pacman_list_next(lp)) { @@ -171,13 +171,13 @@ static int sync_info(list_t *syncs, list_t *targets) int found = 0; for(j = syncs; j && !found; j = j->next) { - PM_DB *db = j->data; + PM_DB *db = list_data(j); PM_LIST *lp; for(lp = pacman_db_getpkgcache(db); !found && lp; lp = pacman_list_next(lp)) { PM_PKG *pkg = pacman_list_getdata(lp); - if(!strcmp(pacman_pkg_getinfo(pkg, PM_PKG_NAME), i->data)) { + if(!strcmp(pacman_pkg_getinfo(pkg, PM_PKG_NAME), list_data(i))) { dump_pkg_sync(pkg, (char *)pacman_db_getinfo(db, PM_DB_TREENAME)); MSG(NL, "\n"); found = 1; @@ -185,13 +185,13 @@ static int sync_info(list_t *syncs, list_t *targets) } } if(!found) { - ERR(NL, _("package \"%s\" was not found.\n"), (char *)i->data); + ERR(NL, _("package \"%s\" was not found.\n"), (char *)list_data(i)); break; } } } else { for(j = syncs; j; j = j->next) { - PM_DB *db = j->data; + PM_DB *db = list_data(j); PM_LIST *lp; for(lp = pacman_db_getpkgcache(db); lp; lp = pacman_list_next(lp)) { @@ -215,15 +215,15 @@ static int sync_list(list_t *syncs, list_t *targets) PM_DB *db = NULL; for(j = syncs; j && !db; j = j->next) { - PM_DB *d = j->data; + PM_DB *d = list_data(j); - if(strcmp(i->data, (char *)pacman_db_getinfo(d, PM_DB_TREENAME)) == 0) { + if(strcmp(list_data(i), (char *)pacman_db_getinfo(d, PM_DB_TREENAME)) == 0) { db = d; } } if(db == NULL) { - ERR(NL, _("repository \"%s\" was not found.\n"), (char *)i->data); + ERR(NL, _("repository \"%s\" was not found.\n"), (char *)list_data(i)); FREELISTPTR(ls); return(1); } @@ -236,7 +236,7 @@ static int sync_list(list_t *syncs, list_t *targets) for(i = ls; i; i = i->next) { PM_LIST *lp; - PM_DB *db = i->data; + PM_DB *db = list_data(i); for(lp = pacman_db_getpkgcache(db); lp; lp = pacman_list_next(lp)) { PM_PKG *pkg = pacman_list_getdata(lp); @@ -373,7 +373,7 @@ int syncpkg(list_t *targets) } else { /* process targets */ for(i = targets; i; i = i->next) { - char *targ = i->data; + char *targ = list_data(i); if(pacman_trans_addtarget(pacman_get_trans(), PM_TRANS_TYPE_SYNC, targ, config->flags) == -1) { PM_GRP *grp = NULL; list_t *j; @@ -383,13 +383,13 @@ int syncpkg(list_t *targets) continue; } if(pm_errno != PM_ERR_PKG_NOT_FOUND) { - ERR(NL, _("could not add target '%s': %s\n"), (char *)i->data, pacman_strerror(pm_errno)); + ERR(NL, _("could not add target '%s': %s\n"), (char *)list_data(i), pacman_strerror(pm_errno)); retval = 1; goto cleanup; } /* target not found: check if it's a group */ for(j = pmc_syncs; j; j = j->next) { - PM_DB *db = j->data; + PM_DB *db = list_data(j); grp = pacman_db_readgrp(db, targ); if(grp) { PM_LIST *pmpkgs; @@ -403,11 +403,11 @@ int syncpkg(list_t *targets) list_display(" ", pkgs); if(yesno(_(":: Install whole content? [Y/n] "))) { for(k = pkgs; k; k = k->next) { - targets = list_add(targets, strdup(k->data)); + targets = list_add(targets, strdup(list_data(k))); } } else { for(k = pkgs; k; k = k->next) { - char *pkgname = k->data; + char *pkgname = list_data(k); if(yesno(_(":: Install %s from group %s? [Y/n] "), pkgname, targ)) { targets = list_add(targets, strdup(pkgname)); } @@ -419,7 +419,7 @@ int syncpkg(list_t *targets) /* targ is not a group, see if it's a regex */ if(!found && config->regex) { for(j = pmc_syncs; j; j = j->next) { - PM_DB *db = j->data; + PM_DB *db = list_data(j); PM_LIST *k; for(k = pacman_db_getpkgcache(db); k; k = pacman_list_next(k)) { PM_PKG *p = pacman_list_getdata(k); @@ -442,7 +442,7 @@ int syncpkg(list_t *targets) PM_PKG *pkg; char *pname; for(j = pmc_syncs; j && !k; j = j->next) { - PM_DB *db = j->data; + PM_DB *db = list_data(j); k = pacman_db_whatprovides(db, targ); pkg = (PM_PKG*)pacman_list_getdata(pacman_list_first(k)); pname = (char*)pacman_pkg_getinfo(pkg, PM_PKG_NAME); diff --git a/src/pacman-g2/trans.c b/src/pacman-g2/trans.c index 4b6698a..755f522 100644 --- a/src/pacman-g2/trans.c +++ b/src/pacman-g2/trans.c @@ -395,15 +395,15 @@ int trans_commit(pmtranstype_t transtype, list_t *targets) /* Check for URL targets and process them */ for(i = targets; i; i = i->next) { - if(strstr(i->data, "://")) { - char *str = pacman_fetch_pkgurl(i->data); + if(strstr(list_data(i), "://")) { + char *str = pacman_fetch_pkgurl(list_data(i)); if(str == NULL) { return(1); } else { finaltargs = list_add(finaltargs, str); } } else { - finaltargs = list_add(finaltargs, strdup(i->data)); + finaltargs = list_add(finaltargs, strdup(list_data(i))); } } break; @@ -414,7 +414,7 @@ int trans_commit(pmtranstype_t transtype, list_t *targets) for(i = targets; i; i = i->next) { PM_GRP *grp; - grp = pacman_db_readgrp(db_local, i->data); + grp = pacman_db_readgrp(db_local, list_data(i)); if(grp) { PM_LIST *lp, *pkgnames; int all; @@ -425,13 +425,13 @@ int trans_commit(pmtranstype_t transtype, list_t *targets) PM_LIST_display(" ", pkgnames); all = yesno(_(" Remove whole content? [Y/n] ")); for(lp = pacman_list_first(pkgnames); lp; lp = pacman_list_next(lp)) { - if(all || yesno(_(":: Remove %s from group %s? [Y/n] "), (char *)pacman_list_getdata(lp), i->data)) { + if(all || yesno(_(":: Remove %s from group %s? [Y/n] "), (char *)pacman_list_getdata(lp), list_data(i))) { finaltargs = list_add(finaltargs, strdup(pacman_list_getdata(lp))); } } } else { /* not a group, so add it to the final targets */ - finaltargs = list_add(finaltargs, strdup(i->data)); + finaltargs = list_add(finaltargs, strdup(list_data(i))); } } break; @@ -452,7 +452,7 @@ int trans_commit(pmtranstype_t transtype, list_t *targets) /* and add targets to it */ MSG(NL, _("loading package data... ")); for(i = finaltargs; i; i = i->next) { - if(pacman_trans_addtarget(pacman_get_trans(), transtype, i->data, config->flags) == -1) { + if(pacman_trans_addtarget(pacman_get_trans(), transtype, list_data(i), config->flags) == -1) { int match = 0; switch (transtype) { @@ -465,7 +465,7 @@ int trans_commit(pmtranstype_t transtype, list_t *targets) PM_PKG *p = pacman_list_getdata(k); char *pkgname = pacman_pkg_getinfo(p, PM_PKG_NAME); - match = pacman_reg_match(pkgname, i->data); + match = pacman_reg_match(pkgname, list_data(i)); if(match > 0 && pacman_trans_addtarget(pacman_get_trans(), transtype, pkgname, config->flags) == -1) { match = 0; @@ -475,7 +475,7 @@ int trans_commit(pmtranstype_t transtype, list_t *targets) break; } if (match > 0) continue; - ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)i->data, pacman_strerror(pm_errno)); + ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)list_data(i), pacman_strerror(pm_errno)); retval = 1; goto cleanup; } diff --git a/src/pacman-g2/util.c b/src/pacman-g2/util.c index a072987..a4c2129 100644 --- a/src/pacman-g2/util.c +++ b/src/pacman-g2/util.c @@ -95,7 +95,7 @@ char *buildstring(list_t *strlist) list_t *lp; for(lp = strlist; lp; lp = lp->next) { - size += strlen(lp->data) + 1; + size += strlen(list_data(lp)) + 1; } str = (char *)malloc(size); if(str == NULL) { @@ -103,7 +103,7 @@ char *buildstring(list_t *strlist) } str[0] = '\0'; for(lp = strlist; lp; lp = lp->next) { - strcat(str, lp->data); + strcat(str, list_data(lp)); strcat(str, " "); } /* shave off the last space */ diff --git a/src/pacman-g2/vercmp.c b/src/pacman-g2/vercmp.c index c0a61e6..6bea674 100644 --- a/src/pacman-g2/vercmp.c +++ b/src/pacman-g2/vercmp.c @@ -35,8 +35,8 @@ int vercmp(list_t *targets) { // FIXME: should count targets - if(targets != NULL && targets->data && targets->next && targets->next->data) { - int ret = pacman_pkg_vercmp(targets->data, targets->next->data); + if(targets != NULL && list_data(targets) && targets->next && list_data(targets->next)) { + int ret = pacman_pkg_vercmp(list_data(targets), list_data(targets->next)); printf("%d\n", ret); return(ret); } _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
