summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--bindings/alpm.i2
-rw-r--r--lib/libalpm/Makefile.am4
-rw-r--r--lib/libalpm/add.c44
-rw-r--r--lib/libalpm/add.h4
-rw-r--r--lib/libalpm/alpm.c103
-rw-r--r--lib/libalpm/alpm.h73
-rw-r--r--lib/libalpm/alpm_list.c429
-rw-r--r--lib/libalpm/alpm_list.h71
-rw-r--r--lib/libalpm/backup.c4
-rw-r--r--lib/libalpm/backup.h4
-rw-r--r--lib/libalpm/be_files.c26
-rw-r--r--lib/libalpm/cache.c36
-rw-r--r--lib/libalpm/cache.h6
-rw-r--r--lib/libalpm/conflict.c62
-rw-r--r--lib/libalpm/conflict.h4
-rw-r--r--lib/libalpm/db.c10
-rw-r--r--lib/libalpm/db.h8
-rw-r--r--lib/libalpm/deps.c86
-rw-r--r--lib/libalpm/deps.h12
-rw-r--r--lib/libalpm/group.c4
-rw-r--r--lib/libalpm/group.h2
-rw-r--r--lib/libalpm/handle.c36
-rw-r--r--lib/libalpm/handle.h14
-rw-r--r--lib/libalpm/list.c361
-rw-r--r--lib/libalpm/list.h60
-rw-r--r--lib/libalpm/package.c72
-rw-r--r--lib/libalpm/package.h24
-rw-r--r--lib/libalpm/provide.c14
-rw-r--r--lib/libalpm/provide.h4
-rw-r--r--lib/libalpm/remove.c36
-rw-r--r--lib/libalpm/remove.h4
-rw-r--r--lib/libalpm/server.c30
-rw-r--r--lib/libalpm/server.h8
-rw-r--r--lib/libalpm/sync.c128
-rw-r--r--lib/libalpm/sync.h8
-rw-r--r--lib/libalpm/trans.c16
-rw-r--r--lib/libalpm/trans.h10
-rw-r--r--lib/libalpm/util.c10
-rw-r--r--lib/libalpm/util.h2
-rw-r--r--lib/libalpm/versioncmp.c4
-rw-r--r--src/pacman/Makefile.am2
-rw-r--r--src/pacman/add.c29
-rw-r--r--src/pacman/add.h4
-rw-r--r--src/pacman/conf.c14
-rw-r--r--src/pacman/conf.h5
-rw-r--r--src/pacman/deptest.c41
-rw-r--r--src/pacman/deptest.h4
-rw-r--r--src/pacman/downloadprog.c1
-rw-r--r--src/pacman/list.c197
-rw-r--r--src/pacman/list.h53
-rw-r--r--src/pacman/log.c1
-rw-r--r--src/pacman/package.c34
-rw-r--r--src/pacman/package.h2
-rw-r--r--src/pacman/pacman.c27
-rw-r--r--src/pacman/query.c101
-rw-r--r--src/pacman/query.h4
-rw-r--r--src/pacman/remove.c57
-rw-r--r--src/pacman/remove.h4
-rw-r--r--src/pacman/sync.c286
-rw-r--r--src/pacman/sync.h8
-rw-r--r--src/pacman/trans.c1
-rw-r--r--src/pacman/upgrade.c4
-rw-r--r--src/pacman/upgrade.h4
-rw-r--r--src/pacman/util.c45
-rw-r--r--src/pacman/util.h10
66 files changed, 1252 insertions, 1522 deletions
diff --git a/AUTHORS b/AUTHORS
index c5d4c6bd..e01c9097 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -10,3 +10,4 @@ David Kimpe <DNAku@frugalware.org>
Dan McGee <dpmcgee@gmail.com>
James Rosten <seinfeld90@gmail.com>
+Roman Kyrylych <Roman.Kyrylych@gmail.com>
diff --git a/bindings/alpm.i b/bindings/alpm.i
index 661f1694..c2d04dd7 100644
--- a/bindings/alpm.i
+++ b/bindings/alpm.i
@@ -13,7 +13,7 @@
%pointer_cast(void *, long *, void_to_long);
%pointer_cast(void *, char *, void_to_char);
%pointer_cast(void *, unsigned long, void_to_unsigned_long);
-%pointer_cast(void *, pmlist_t *, void_to_pmlist);
+%pointer_cast(void *, alpm_list_t *, void_to_pmlist);
%pointer_cast(void *, pmpkg_t *, void_to_pmpkg);
%pointer_cast(void *, pmgrp_t *, void_to_pmgrp);
%pointer_cast(void *, pmsyncpkg_t *, void_to_pmsyncpkg);
diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am
index c5306d1f..77f092bb 100644
--- a/lib/libalpm/Makefile.am
+++ b/lib/libalpm/Makefile.am
@@ -12,7 +12,7 @@ TARGETS = md5driver.c \
md5.c \
sha1.c \
util.c \
- list.c \
+ alpm_list.c \
log.c \
error.c \
package.c \
@@ -35,7 +35,7 @@ TARGETS = md5driver.c \
lib_LTLIBRARIES = libalpm.la
-include_HEADERS = alpm.h
+include_HEADERS = alpm_list.h alpm.h
libalpm_la_SOURCES = $(TARGETS)
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 24fceba5..5f7c024c 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -39,7 +39,7 @@
#include <limits.h>
#include <libintl.h>
/* pacman */
-#include "list.h"
+#include "alpm_list.h"
#include "trans.h"
#include "util.h"
#include "error.h"
@@ -88,7 +88,7 @@ static int add_faketarget(pmtrans_t *trans, char *name)
} else if(strncmp("version", p, q-p) == 0) {
STRNCPY(dummy->version, q+1, PKG_VERSION_LEN);
} else if(strncmp("depend", p, q-p) == 0) {
- dummy->depends = _alpm_list_add(dummy->depends, strdup(q+1));
+ dummy->depends = alpm_list_add(dummy->depends, strdup(q+1));
} else {
_alpm_log(PM_LOG_ERROR, _("could not parse token %s"), p);
}
@@ -100,7 +100,7 @@ static int add_faketarget(pmtrans_t *trans, char *name)
}
/* add the package to the transaction */
- trans->packages = _alpm_list_add(trans->packages, dummy);
+ trans->packages = alpm_list_add(trans->packages, dummy);
return(0);
}
@@ -110,7 +110,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_t *i;
+ alpm_list_t *i;
struct stat buf;
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
@@ -201,7 +201,7 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
}
/* add the package to the transaction */
- trans->packages = _alpm_list_add(trans->packages, info);
+ trans->packages = alpm_list_add(trans->packages, info);
return(0);
@@ -216,10 +216,10 @@ static int name_cmp(const void *p1, const void *p2)
return(strcmp(((pmpkg_t *)p1)->name, (const char *)p2));
}
-int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data)
+int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
{
- pmlist_t *lp = NULL, *i = NULL;
- pmlist_t *rmlist = NULL;
+ alpm_list_t *lp = NULL, *i = NULL;
+ alpm_list_t *rmlist = NULL;
char rm_fname[PATH_MAX];
pmpkg_t *info = NULL;
@@ -254,7 +254,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data)
QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &skip_this);
if(skip_this) {
pmpkg_t **pkg = NULL;
- lp = _alpm_list_remove(lp, (void *)miss->depend.name, name_cmp, (void **)pkg);
+ lp = alpm_list_remove(lp, (void *)miss->depend.name, name_cmp, (void **)pkg);
FREEPKG(*pkg);
}
}
@@ -293,7 +293,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data)
/* Check for file conflicts
*/
if(!(trans->flags & PM_TRANS_FLAG_FORCE)) {
- pmlist_t *skiplist = NULL;
+ alpm_list_t *skiplist = NULL;
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
@@ -334,7 +334,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_t *targ, *lp;
+ alpm_list_t *targ, *lp;
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
@@ -375,7 +375,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
_alpm_log(PM_LOG_DEBUG, _("loading FILES info for '%s'"), local->name);
_alpm_db_read(db, INFRQ_FILES, local);
}
- oldpkg->backup = _alpm_list_strdup(local->backup);
+ oldpkg->backup = alpm_list_strdup(local->backup);
strncpy(oldpkg->name, local->name, PKG_NAME_LEN);
strncpy(oldpkg->version, local->version, PKG_VERSION_LEN);
}
@@ -408,7 +408,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
RET_ERR(PM_ERR_TRANS_ABORT, -1);
}
/* copy the skiplist over */
- tr->skiplist = _alpm_list_strdup(trans->skiplist);
+ tr->skiplist = alpm_list_strdup(trans->skiplist);
if(_alpm_remove_commit(tr, db) == -1) {
FREETRANS(tr);
RET_ERR(PM_ERR_TRANS_ABORT, -1);
@@ -475,7 +475,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
if (info->size != 0)
percent = (double)archive_position_uncompressed(archive) / info->size;
if (needdisp == 0) {
- PROGRESS(trans, cb_state, what, (int)(percent * 100), _alpm_list_count(trans->packages), (_alpm_list_count(trans->packages) - _alpm_list_count(targ) +1));
+ PROGRESS(trans, cb_state, what, (int)(percent * 100), alpm_list_count(trans->packages), (alpm_list_count(trans->packages) - alpm_list_count(targ) +1));
}
if(!strcmp(pathname, ".PKGINFO") || !strcmp(pathname, ".FILELIST")) {
@@ -507,7 +507,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
* eg, /home/httpd/html/index.html may be removed so index.php
* could be used.
*/
- if(_alpm_list_is_strin(pathname, handle->noextract)) {
+ if(alpm_list_is_strin(pathname, handle->noextract)) {
alpm_logaction(_("notice: %s is in NoExtract -- skipping extraction"), pathname);
archive_read_data_skip (archive);
continue;
@@ -516,7 +516,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
if(!stat(expath, &buf) && !S_ISDIR(buf.st_mode)) {
/* file already exists */
if(!pmo_upgrade || oldpkg == NULL) {
- nb = _alpm_list_is_strin(pathname, info->backup);
+ nb = alpm_list_is_strin(pathname, info->backup);
} else {
/* op == PM_TRANS_TYPE_UPGRADE */
md5_orig = _alpm_needbackup(pathname, oldpkg->backup);
@@ -525,7 +525,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
nb = 1;
}
}
- if(_alpm_list_is_strin(pathname, handle->noupgrade)) {
+ if(alpm_list_is_strin(pathname, handle->noupgrade)) {
notouch = 1;
nb = 0;
}
@@ -753,7 +753,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, INFRQ_DEPENDS); lp; lp = lp->next) {
pmpkg_t *tmpp = lp->data;
- pmlist_t *tmppm = NULL;
+ alpm_list_t *tmppm = NULL;
if(tmpp == NULL) {
continue;
}
@@ -764,7 +764,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
}
if(tmppm->data && !strcmp(depend.name, info->name)) {
_alpm_log(PM_LOG_DEBUG, _("adding '%s' in requiredby field for '%s'"), tmpp->name, info->name);
- info->requiredby = _alpm_list_add(info->requiredby, strdup(tmpp->name));
+ info->requiredby = alpm_list_add(info->requiredby, strdup(tmpp->name));
}
}
}
@@ -800,7 +800,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_t *provides = _alpm_db_whatprovides(db, depend.name);
+ alpm_list_t *provides = _alpm_db_whatprovides(db, depend.name);
if(provides) {
/* TODO: should check _all_ packages listed in provides, not just
* the first one.
@@ -820,14 +820,14 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
_alpm_db_read(db, INFRQ_DEPENDS, depinfo);
_alpm_log(PM_LOG_DEBUG, _("adding '%s' in requiredby field for '%s'"), info->name, depinfo->name);
- depinfo->requiredby = _alpm_list_add(depinfo->requiredby, strdup(info->name));
+ depinfo->requiredby = alpm_list_add(depinfo->requiredby, strdup(info->name));
if(_alpm_db_write(db, depinfo, INFRQ_DEPENDS)) {
_alpm_log(PM_LOG_ERROR, _("could not update 'requiredby' database entry %s-%s"),
depinfo->name, depinfo->version);
}
}
- PROGRESS(trans, cb_state, what, 100, _alpm_list_count(trans->packages), (_alpm_list_count(trans->packages) - _alpm_list_count(targ) +1));
+ PROGRESS(trans, cb_state, what, 100, alpm_list_count(trans->packages), (alpm_list_count(trans->packages) - alpm_list_count(targ) +1));
needdisp = 0;
EVENT(trans, PM_TRANS_EVT_EXTRACT_DONE, NULL, NULL);
FREE(what);
diff --git a/lib/libalpm/add.h b/lib/libalpm/add.h
index d39aa140..4cd2e445 100644
--- a/lib/libalpm/add.h
+++ b/lib/libalpm/add.h
@@ -22,11 +22,11 @@
#define _ALPM_ADD_H
#include "db.h"
-#include "list.h"
+#include "alpm_list.h"
#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_t **data);
+int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_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 ae5f6686..c604f4f5 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -42,7 +42,7 @@
#include "versioncmp.h"
#include "md5.h"
#include "sha1.h"
-#include "list.h"
+#include "alpm_list.h"
#include "package.h"
#include "group.h"
#include "util.h"
@@ -169,7 +169,7 @@ int alpm_db_unregister(pmdb_t *db)
found = 1;
} else {
void *data;
- handle->dbs_sync = _alpm_list_remove(handle->dbs_sync, db, _alpm_db_cmp, &data);
+ handle->dbs_sync = alpm_list_remove(handle->dbs_sync, db, _alpm_db_cmp, &data);
if(data) {
found = 1;
}
@@ -209,7 +209,7 @@ int alpm_db_setserver(pmdb_t *db, const char *url)
found = 1;
}
} else {
- pmlist_t *i;
+ alpm_list_t *i;
for(i = handle->dbs_sync; i && !found; i = i->next) {
pmdb_t *sdb = i->data;
if(strcmp(db->treename, sdb->treename) == 0) {
@@ -227,7 +227,7 @@ int alpm_db_setserver(pmdb_t *db, const char *url)
/* pm_errno is set by _alpm_server_new */
return(-1);
}
- db->servers = _alpm_list_add(db->servers, server);
+ db->servers = alpm_list_add(db->servers, server);
_alpm_log(PM_LOG_FLOW2, _("adding new server to database '%s': protocol '%s', server '%s', path '%s'"),
db->treename, server->s_url->scheme, server->s_url->host, server->s_url->doc);
} else {
@@ -247,9 +247,9 @@ int alpm_db_setserver(pmdb_t *db, const char *url)
*/
int alpm_db_update(int force, pmdb_t *db)
{
- pmlist_t *lp;
+ alpm_list_t *lp;
char path[PATH_MAX];
- pmlist_t *files = NULL;
+ alpm_list_t *files = NULL;
char newmtime[16] = "";
char lastupdate[16] = "";
int ret;
@@ -265,7 +265,7 @@ int alpm_db_update(int force, pmdb_t *db)
ASSERT(handle->trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1));
ASSERT(handle->trans->type == PM_TRANS_TYPE_SYNC, RET_ERR(PM_ERR_TRANS_TYPE, -1));
- if(!_alpm_list_is_in(db, handle->dbs_sync)) {
+ if(!alpm_list_is_in(db, handle->dbs_sync)) {
RET_ERR(PM_ERR_DB_NOT_FOUND, -1);
}
@@ -279,7 +279,7 @@ int alpm_db_update(int force, pmdb_t *db)
/* build a one-element list */
snprintf(path, PATH_MAX, "%s" PM_EXT_DB, db->treename);
- files = _alpm_list_add(files, strdup(path));
+ files = alpm_list_add(files, strdup(path));
snprintf(path, PATH_MAX, "%s%s", handle->root, handle->dbpath);
@@ -344,7 +344,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_t *alpm_db_getpkgcache(pmdb_t *db)
+alpm_list_t *alpm_db_getpkgcache(pmdb_t *db)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -358,7 +358,7 @@ pmlist_t *alpm_db_getpkgcache(pmdb_t *db)
* @param name name of the package
* @return the list of packages on success, NULL on error
*/
-pmlist_t *alpm_db_whatprovides(pmdb_t *db, char *name)
+alpm_list_t *alpm_db_whatprovides(pmdb_t *db, char *name)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -387,7 +387,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_t *alpm_db_getgrpcache(pmdb_t *db)
+alpm_list_t *alpm_db_getgrpcache(pmdb_t *db)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -596,7 +596,7 @@ char *alpm_pkg_name_hasarch(char *pkgname)
* @param db pointer to the package database to search in
* @return the list of packages on success, NULL on error
*/
-pmlist_t *alpm_db_search(pmdb_t *db)
+alpm_list_t *alpm_db_search(pmdb_t *db)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -687,7 +687,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_t **data)
+int alpm_trans_prepare(alpm_list_t **data)
{
/* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
@@ -704,7 +704,7 @@ int alpm_trans_prepare(pmlist_t **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_t **data)
+int alpm_trans_commit(alpm_list_t **data)
{
/* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
@@ -801,81 +801,6 @@ int alpm_logaction(char *fmt, ...)
}
/** @} */
-/** \addtogroup alpm_list List Functions
- * @brief Functions to manipulate libalpm linked lists
- * @{
- */
-
-/** Get the first element of a list.
- * @param list the list
- * @return the first element
- */
-pmlist_t *alpm_list_first(pmlist_t *list)
-{
- return(list);
-}
-
-/** Get the next element of a list.
- * @param entry the list entry
- * @return the next element on success, NULL on error
- */
-pmlist_t *alpm_list_next(pmlist_t *entry)
-{
- ASSERT(entry != NULL, return(NULL));
-
- return(entry->next);
-}
-
-/** Get the data of a list entry.
- * @param entry the list entry
- * @return the data on success, NULL on error
- */
-void *alpm_list_getdata(const pmlist_t *entry)
-{
- ASSERT(entry != NULL, return(NULL));
-
- return(entry->data);
-}
-
-/** Free a list.
- * @param entry list to free
- * @return 0 on success, -1 on error
- */
-int alpm_list_free(pmlist_t *entry)
-{
- ASSERT(entry != NULL, return(-1));
-
- FREELIST(entry);
-
- return(0);
-}
-
-/** Free the outer list, but not the contained data
- * @param entry list to free
- * @return 0 on success, -1 on error
- */
-int alpm_list_free_outer(pmlist_t *entry)
-{
- ASSERT(entry != NULL, return(-1));
-
- _FREELIST(entry, NULL);
-
- return(0);
-}
-
-/** Count the entries in a list.
- * @param list the list to count
- * @return number of entries on success, NULL on error
- */
-int alpm_list_count(const pmlist_t *list)
-{
- ASSERT(list != NULL, return(-1));
-
- return(_alpm_list_count(list));
-}
-
-/** @} */
-
/** \addtogroup alpm_misc Miscellaneous Functions
* @brief Various libalpm functions
* @{
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 143f3367..1a227224 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -47,7 +47,8 @@ extern "C" {
* Structures
*/
-typedef struct __pmlist_t pmlist_t;
+typedef struct __alpm_list_t alpm_list_t;
+
typedef struct __pmdb_t pmdb_t;
typedef struct __pmpkg_t pmpkg_t;
typedef struct __pmgrp_t pmgrp_t;
@@ -117,21 +118,21 @@ void alpm_option_set_logfile(const char *logfile);
unsigned char alpm_option_get_usesyslog();
void alpm_option_set_usesyslog(unsigned char usesyslog);
-pmlist_t *alpm_option_get_noupgrades();
+alpm_list_t *alpm_option_get_noupgrades();
void alpm_option_add_noupgrade(char *pkg);
-void alpm_option_set_noupgrades(pmlist_t *noupgrade);
+void alpm_option_set_noupgrades(alpm_list_t *noupgrade);
-pmlist_t *alpm_option_get_noextracts();
+alpm_list_t *alpm_option_get_noextracts();
void alpm_option_add_noextract(char *pkg);
-void alpm_option_set_noextracts(pmlist_t *noextract);
+void alpm_option_set_noextracts(alpm_list_t *noextract);
-pmlist_t *alpm_option_get_ignorepkgs();
+alpm_list_t *alpm_option_get_ignorepkgs();
void alpm_option_add_ignorepkg(char *pkg);
-void alpm_option_set_ignorepkgs(pmlist_t *ignorepkgs);
+void alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs);
-pmlist_t *alpm_option_get_holdpkgs();
+alpm_list_t *alpm_option_get_holdpkgs();
void alpm_option_add_holdpkg(char *pkg);
-void alpm_option_set_holdpkgs(pmlist_t *holdpkgs);
+void alpm_option_set_holdpkgs(alpm_list_t *holdpkgs);
time_t alpm_option_get_upgradedelay();
void alpm_option_set_upgradedelay(time_t delay);
@@ -145,13 +146,16 @@ void alpm_option_set_nopassiveftp(unsigned short nopasv);
unsigned short alpm_option_get_chomp();
void alpm_option_set_chomp(unsigned short chomp);
-pmlist_t *alpm_option_get_needles();
+alpm_list_t *alpm_option_get_needles();
void alpm_option_add_needle(char *needle);
-void alpm_option_set_needles(pmlist_t *needles);
+void alpm_option_set_needles(alpm_list_t *needles);
unsigned short alpm_option_get_usecolor();
void alpm_option_set_usecolor(unsigned short usecolor);
+pmdb_t *alpm_option_get_localdb();
+alpm_list_t *alpm_option_get_syncdbs();
+
/*
* Databases
*/
@@ -170,12 +174,12 @@ int alpm_db_setserver(pmdb_t *db, const char *url);
int alpm_db_update(int level, pmdb_t *db);
pmpkg_t *alpm_db_readpkg(pmdb_t *db, char *name);
-pmlist_t *alpm_db_getpkgcache(pmdb_t *db);
-pmlist_t *alpm_db_whatprovides(pmdb_t *db, char *name);
+alpm_list_t *alpm_db_getpkgcache(pmdb_t *db);
+alpm_list_t *alpm_db_whatprovides(pmdb_t *db, char *name);
pmgrp_t *alpm_db_readgrp(pmdb_t *db, char *name);
-pmlist_t *alpm_db_getgrpcache(pmdb_t *db);
-pmlist_t *alpm_db_search(pmdb_t *db);
+alpm_list_t *alpm_db_getgrpcache(pmdb_t *db);
+alpm_list_t *alpm_db_search(pmdb_t *db);
/*
* Packages
@@ -215,23 +219,23 @@ const char *alpm_pkg_get_arch(pmpkg_t *pkg);
unsigned long alpm_pkg_get_size(pmpkg_t *pkg);
unsigned long alpm_pkg_get_isize(pmpkg_t *pkg);
unsigned char alpm_pkg_get_reason(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_licenses(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_groups(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_depends(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_removes(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_requiredby(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_conflicts(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_provides(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_replaces(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_files(pmpkg_t *pkg);
-pmlist_t *alpm_pkg_get_backup(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_licenses(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_groups(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_depends(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_removes(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_requiredby(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_conflicts(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_provides(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_replaces(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_files(pmpkg_t *pkg);
+alpm_list_t *alpm_pkg_get_backup(pmpkg_t *pkg);
unsigned char alpm_pkg_has_scriptlet(pmpkg_t *pkg);
/*
* Groups
*/
const char *alpm_grp_get_name(pmgrp_t *grp);
-pmlist_t *alpm_grp_get_packages(pmgrp_t *grp);
+alpm_list_t *alpm_grp_get_packages(pmgrp_t *grp);
/*
* Sync
@@ -334,13 +338,13 @@ typedef void (*alpm_trans_cb_progress)(unsigned char, char *, int, int, int);
unsigned char alpm_trans_get_type();
unsigned int alpm_trans_get_flags();
-pmlist_t * alpm_trans_get_targets();
-pmlist_t * alpm_trans_get_packages();
+alpm_list_t * alpm_trans_get_targets();
+alpm_list_t * alpm_trans_get_packages();
int alpm_trans_init(unsigned char type, unsigned int flags, alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv, alpm_trans_cb_progress cb_progress);
int alpm_trans_sysupgrade(void);
int alpm_trans_addtarget(char *target);
-int alpm_trans_prepare(pmlist_t **data);
-int alpm_trans_commit(pmlist_t **data);
+int alpm_trans_prepare(alpm_list_t **data);
+int alpm_trans_commit(alpm_list_t **data);
int alpm_trans_release(void);
/*
@@ -382,15 +386,6 @@ const char *alpm_conflict_get_ctarget(pmconflict_t *conflict);
/*
* Helpers
*/
-
-/* pmlist_t */
-pmlist_t *alpm_list_first(pmlist_t *list);
-pmlist_t *alpm_list_next(pmlist_t *entry);
-#define alpm_list_data(type, list) (type)alpm_list_getdata((list))
-void *alpm_list_getdata(const pmlist_t *entry);
-int alpm_list_free(pmlist_t *entry);
-int alpm_list_free_outer(pmlist_t *entry);
-int alpm_list_count(const pmlist_t *list);
/* md5sums */
char *alpm_get_md5sum(char *name);
diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
new file mode 100644
index 00000000..beccc39c
--- /dev/null
+++ b/lib/libalpm/alpm_list.c
@@ -0,0 +1,429 @@
+/*
+ * alpm_list.c
+ *
+ * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+#include "config.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <assert.h>
+
+#include "alpm_list.h"
+#include "util.h"
+
+/** \defgroup alpm_list functions */
+/*\@{*/
+
+/* Allocation */
+
+/** Allocate a new alpm_list_t
+ * @return a new alpm_list_t item, or NULL on failure
+ */
+alpm_list_t *alpm_list_new()
+{
+ alpm_list_t *list = NULL;
+
+ list = (alpm_list_t *)malloc(sizeof(alpm_list_t));
+ if(list) {
+ list->data = NULL;
+ list->prev = NULL;
+ list->next = NULL;
+ }
+ return(list);
+}
+
+/** Free a list structure and possibly the internal data as well
+ * @param list the list to free
+ * @param fn a free function for the internal data, or NULL for none
+ */
+void alpm_list_free(alpm_list_t *list, alpm_list_fn_free fn)
+{
+ alpm_list_t *it = list;
+
+ while(it) {
+ alpm_list_t *ptr = it->next;
+ if(fn && it->data) {
+ fn(it->data);
+ }
+ FREE(it);
+ it = ptr;
+ }
+}
+
+/** Free the outer list, but not the contained data
+ * A minor simplification of alpm_list_free
+ * @param list the list to free
+ */
+void alpm_list_free_outer(alpm_list_t *list)
+{
+ alpm_list_free(list, NULL);
+}
+
+/* Mutators */
+
+/** Add a new item to the list
+ * @param list the list to add to
+ * @param data the new item to be added to the list
+ * @return the resultant list, or NULL on failure
+ */
+alpm_list_t *alpm_list_add(alpm_list_t *list, void *data)
+{
+ alpm_list_t *ptr, *lp;
+
+ ptr = list;
+ if(ptr == NULL) {
+ ptr = alpm_list_new();
+ if(ptr == NULL) {
+ return(NULL);
+ }
+ }
+
+ lp = alpm_list_last(ptr);
+ if(lp == ptr && lp->data == NULL) {
+ /* nada */
+ } else {
+ lp->next = alpm_list_new();
+ if(lp->next == NULL) {
+ return(NULL);
+ }
+ lp->next->prev = lp;
+ lp = lp->next;
+ }
+
+ lp->data = data;
+
+ return(ptr);
+}
+
+/** Add items to a list in sorted order.
+ * @param list the list to add to
+ * @param data the new item to be added to the list
+ * @param fn the comparison function to use to determine order
+ * @return the resultant list, or NULL on failure
+ */
+alpm_list_t *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cmp fn)
+{
+ if(!fn) {
+ return alpm_list_add(list, data);
+ } else {
+ alpm_list_t *add = NULL, *prev = NULL, *next = list;
+
+ add = alpm_list_new();
+ add->data = data;
+
+ /* Find insertion point. */
+ while(next) {
+ if(fn(add->data, next->data) <= 0) break;
+ prev = next;
+ next = next->next;
+ }
+
+ /* Insert node before insertion point. */
+ add->prev = prev;
+ add->next = next;
+
+ if(next != NULL) {
+ next->prev = add; /* Not at end. */
+ }
+
+ if(prev != NULL) {
+ prev->next = add; /* In middle. */
+ }
+
+ return(list);
+ }
+}
+
+/** Merge the two sorted sublists into one sorted list
+ * @param left the first list
+ * @param right the second list
+ * @param fn comparison function for determining merge order
+ */
+alpm_list_t *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn)
+{
+ alpm_list_t *newlist, *lp;
+
+ if (left == NULL)
+ return right;
+ if (right == NULL)
+ return left;
+
+ if (fn(left->data, right->data) <= 0) {
+ newlist = left;
+ left = left->next;
+ }
+ else {
+ newlist = right;
+ right = right->next;
+ }
+ newlist->prev = NULL;
+ newlist->next = NULL;
+ lp = newlist;
+
+ while ((left != NULL) && (right != NULL)) {
+ if (fn(left->data, right->data) <= 0) {
+ lp->next = left;
+ left->prev = lp;
+ left = left->next;
+ }
+ else {
+ lp->next = right;
+ right->prev = lp;
+ right = right->next;
+ }
+ lp = lp->next;
+ lp->next = NULL;
+ }
+ if (left != NULL) {
+ lp->next = left;
+ left->prev = lp;
+ }
+ else if (right != NULL) {
+ lp->next = right;
+ right->prev = lp;
+ }
+ return(newlist);
+}
+
+/** Sort a list of size `n` using mergesort algorithm
+ * @param list the list to sort
+ * @param n the size of the list
+ * @param fn the comparison function for determining order
+ */
+alpm_list_t* alpm_list_msort(alpm_list_t *list, int n, alpm_list_fn_cmp fn)
+{
+ if (n > 1) {
+ alpm_list_t *left = list;
+ alpm_list_t *lastleft = alpm_list_nth(list, n/2 - 1);
+ alpm_list_t *right = lastleft->next;
+ /* terminate first list */
+ lastleft->next = NULL;
+
+ left = alpm_list_msort(left, n/2, fn);
+ right = alpm_list_msort(right, n - (n/2), fn);
+ list = alpm_list_mmerge(left, right, fn);
+ }
+ return(list);
+}
+
+/** Remove an item from the list
+ * @param haystack the list to remove the item from
+ * @param needle the data member of the item we're removing
+ * @param fn the comparison function for searching
+ * @param data output parameter containing the data member of the item removed
+ * @return the resultant list, or NULL on failure
+ */
+alpm_list_t *alpm_list_remove(alpm_list_t *haystack, void *needle, alpm_list_fn_cmp fn, void **data)
+{ /* TODO I modified this to remove ALL matching items. Do we need a remove_first? */
+ alpm_list_t *i = haystack, *tmp = NULL;
+
+ if(data) {
+ *data = NULL;
+ }
+
+ while(i) {
+ if(i->data == NULL) {
+ continue;
+ }
+ tmp = i->next;
+ if(fn(needle, i->data) == 0) {
+ /* we found a matching item */
+ if(i->next) {
+ i->next->prev = i->prev;
+ }
+ if(i->prev) {
+ i->prev->next = i->next;
+ }
+
+ if(i == haystack) {
+ /* The item found is the first in the chain */
+ haystack = haystack->next;
+ }
+
+ if(data) {
+ *data = i->data;
+ }
+ i->data = NULL;
+ free(i);
+ }
+ i = tmp;
+ }
+
+ return(haystack);
+}
+
+/** Create a new list without any duplicates
+ * @note DOES NOT copy data members
+ * @param list the list to copy
+ * @return a NEW list containing non-duplicated items
+ */
+alpm_list_t *alpm_list_remove_dupes(alpm_list_t *list)
+{ /* TODO does removing the strdup here cause invalid free's anywhere? */
+ alpm_list_t *lp = list, *newlist = NULL;
+ while(lp) {
+ if(!alpm_list_is_in(lp->data, newlist)) {
+ newlist = alpm_list_add(newlist, lp->data);
+ }
+ lp = lp->next;
+ }
+ return(newlist);
+}
+
+/** Copy a string list, including data
+ * @note this is gross, assumes string data members
+ * @param list the list to copy
+ * @return a copy of the original list
+ */
+alpm_list_t *alpm_list_strdup(alpm_list_t *list)
+{
+ alpm_list_t *lp = list, *newlist = NULL;
+ while(lp) {
+ newlist = alpm_list_add(newlist, strdup(lp->data));
+ lp = lp->next;
+ }
+ return(newlist);
+}
+
+/** Create a new list in reverse order
+ * @param list the list to copy
+ * @return a NEW list in reverse order of the first
+ */
+alpm_list_t *alpm_list_reverse(alpm_list_t *list)
+{ /* TODO any invalid free's from NOT duplicating data here? */
+ alpm_list_t *lp, *newlist = NULL;
+
+ lp = alpm_list_last(list);
+ while(lp) {
+ newlist = alpm_list_add(newlist, lp->data);
+ lp = lp->prev;
+ }
+ return(newlist);
+}
+
+/* Accessors */
+
+/** Get the first element of a list.
+ * @param list the list
+ * @return the first element in the list
+ */
+alpm_list_t *alpm_list_first(alpm_list_t *list)
+{
+ return(list);
+}
+
+/** Return nth element from list (starting with 0)
+ * @param list the list to access
+ * @param n the index of the item to find
+ * @return an alpm_list_t node for index `n`
+ */
+alpm_list_t *alpm_list_nth(alpm_list_t *list, int n)
+{
+ alpm_list_t *i = list;
+ while(n--) {
+ i = i->next;
+ }
+ return(i);
+}
+
+/** Get the next element of a list.
+ * @param entry the list entry
+ * @return the next element, or NULL when no more elements exist
+ */
+alpm_list_t *alpm_list_next(alpm_list_t *entry)
+{
+ return(entry->next);
+}
+/** Get the last item in the list.
+ * @param list the list to operate on
+ * @return the last element in the list
+ */
+alpm_list_t *alpm_list_last(alpm_list_t *list)
+{
+ alpm_list_t *i = list;
+ while(i && i->next) {
+ i = i->next;
+ }
+ return(i);
+}
+
+/** Get the data member of a list entry.
+ * @param entry the list entry
+ * @return the contained data, or NULL if none
+ */
+void *alpm_list_getdata(const alpm_list_t *entry)
+{
+ return(entry->data);
+}
+
+/* Misc */
+
+/** Count the list items
+ * @param list the list to operate on
+ * @return the number of list items
+ */
+int alpm_list_count(const alpm_list_t *list)
+{
+ unsigned int i = 0;
+ const alpm_list_t *lp = list;
+ while(lp) {
+ ++i;
+ lp = lp->next;
+ }
+ return(i);
+}
+
+/** Is an item in the list
+ * @param needle the data to compare to (== comparison)
+ * @param haystack the list to search
+ * @return 1 if `needle` is found, 0 otherwise
+ */
+int alpm_list_is_in(const void *needle, alpm_list_t *haystack)
+{
+ alpm_list_t *lp = haystack;
+ while(lp) {
+ if(lp->data == needle) {
+ return(1);
+ }
+ lp = lp->next;
+ }
+ return(0);
+}
+
+/* Test for existence of a string in a alpm_list_t
+*/
+/** Is a _string_ in the list (optimization of alpm_list_is_in for strings)
+ * @param needle the string to compare
+ * @param haystack the list to search
+ * @return 1 if `needle` is found, 0 otherwise
+ */
+int alpm_list_is_strin(const char *needle, alpm_list_t *haystack)
+{
+ alpm_list_t *lp = haystack;
+ while(lp) {
+ if(lp->data && strcmp((const char *)lp->data, needle) == 0) {
+ return(1);
+ }
+ }
+ return(0);
+}
+
+/** @} */
+
+/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h
new file mode 100644
index 00000000..df19c9e9
--- /dev/null
+++ b/lib/libalpm/alpm_list.h
@@ -0,0 +1,71 @@
+/*
+ * alpm_alpm_list.h
+ *
+ * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+#ifndef _ALPM_LIST_H
+#define _ALPM_LIST_H
+
+#include "alpm.h"
+
+/* Chained list struct */
+struct __alpm_list_t {
+ void *data;
+ struct __alpm_list_t *prev;
+ struct __alpm_list_t *next;
+};
+
+/* TODO we should do away with these... they're messy */
+#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)
+
+typedef void (*alpm_list_fn_free)(void *); /* item deallocation callback */
+typedef int (*alpm_list_fn_cmp)(const void *, const void *); /* item comparison callback */
+
+/* allocation */
+alpm_list_t *alpm_list_new(void);
+void alpm_list_free(alpm_list_t *list, alpm_list_fn_free fn);
+void alpm_list_free_outer(alpm_list_t *list);
+
+/* item mutators */
+alpm_list_t *alpm_list_add(alpm_list_t *list, void *data);
+alpm_list_t *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cmp fn);
+alpm_list_t* alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn);
+alpm_list_t* alpm_list_msort(alpm_list_t *list, int n, alpm_list_fn_cmp fn);
+alpm_list_t *alpm_list_remove(alpm_list_t *haystack, void *needle, alpm_list_fn_cmp fn, void **data);
+alpm_list_t *alpm_list_remove_dupes(alpm_list_t *list);
+alpm_list_t *alpm_list_strdup(alpm_list_t *list);
+alpm_list_t *alpm_list_reverse(alpm_list_t *list);
+
+/* item accessors */
+alpm_list_t *alpm_list_first(alpm_list_t *list);
+alpm_list_t* alpm_list_nth(alpm_list_t *list, int n);
+alpm_list_t *alpm_list_next(alpm_list_t *list);
+alpm_list_t *alpm_list_last(alpm_list_t *list);
+void *alpm_list_getdata(const alpm_list_t *entry);
+#define alpm_list_data(type, list) (type)alpm_list_getdata((list))
+
+/* misc */
+int alpm_list_count(const alpm_list_t *list);
+int alpm_list_is_in(const void *needle, alpm_list_t *haystack);
+int alpm_list_is_strin(const char *needle, alpm_list_t *haystack);
+
+#endif /* _ALPM_LIST_H */
+
+/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c
index 4c438fe4..dbe6d625 100644
--- a/lib/libalpm/backup.c
+++ b/lib/libalpm/backup.c
@@ -32,9 +32,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_t *backup)
+char *_alpm_needbackup(char *file, alpm_list_t *backup)
{
- pmlist_t *lp;
+ alpm_list_t *lp;
if(file == NULL || backup == NULL) {
return(NULL);
diff --git a/lib/libalpm/backup.h b/lib/libalpm/backup.h
index b1aa434c..0498146b 100644
--- a/lib/libalpm/backup.h
+++ b/lib/libalpm/backup.h
@@ -21,9 +21,9 @@
#ifndef _ALPM_BACKUP_H
#define _ALPM_BACKUP_H
-#include "list.h"
+#include "alpm_list.h"
-char *_alpm_needbackup(char *file, pmlist_t *backup);
+char *_alpm_needbackup(char *file, alpm_list_t *backup);
#endif /* _ALPM_BACKUP_H */
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index e722f626..ba3e45a4 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -181,7 +181,7 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
struct stat buf;
char path[PATH_MAX+1];
char line[513];
- pmlist_t *tmplist;
+ alpm_list_t *tmplist;
char *locale;
if(db == NULL) {
@@ -238,7 +238,7 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
_alpm_strtrim(info->filename);
} else if(!strcmp(line, "%DESC%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->desc_localized = _alpm_list_add(info->desc_localized, strdup(line));
+ info->desc_localized = alpm_list_add(info->desc_localized, strdup(line));
}
if((locale = setlocale(LC_ALL, "")) == NULL) { /* To fix segfault when locale invalid */
@@ -263,7 +263,7 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
_alpm_strtrim(info->desc);
} else if(!strcmp(line, "%GROUPS%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->groups = _alpm_list_add(info->groups, strdup(line));
+ info->groups = alpm_list_add(info->groups, strdup(line));
}
} else if(!strcmp(line, "%URL%")) {
if(fgets(info->url, sizeof(info->url), fp) == NULL) {
@@ -272,7 +272,7 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
_alpm_strtrim(info->url);
} else if(!strcmp(line, "%LICENSE%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->license = _alpm_list_add(info->license, strdup(line));
+ info->license = alpm_list_add(info->license, strdup(line));
}
} else if(!strcmp(line, "%ARCH%")) {
if(fgets(info->arch, sizeof(info->arch), fp) == NULL) {
@@ -347,7 +347,7 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
/* the REPLACES tag is special -- it only appears in sync repositories,
* not the local one. */
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->replaces = _alpm_list_add(info->replaces, strdup(line));
+ info->replaces = alpm_list_add(info->replaces, strdup(line));
}
} else if(!strcmp(line, "%FORCE%")) {
/* FORCE tag only appears in sync repositories,
@@ -371,11 +371,11 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
_alpm_strtrim(line);
if(!strcmp(line, "%FILES%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->files = _alpm_list_add(info->files, strdup(line));
+ info->files = alpm_list_add(info->files, strdup(line));
}
} else if(!strcmp(line, "%BACKUP%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->backup = _alpm_list_add(info->backup, strdup(line));
+ info->backup = alpm_list_add(info->backup, strdup(line));
}
}
}
@@ -396,25 +396,25 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
_alpm_strtrim(line);
if(!strcmp(line, "%DEPENDS%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->depends = _alpm_list_add(info->depends, strdup(line));
+ info->depends = alpm_list_add(info->depends, strdup(line));
}
} else if(!strcmp(line, "%REQUIREDBY%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->requiredby = _alpm_list_add(info->requiredby, strdup(line));
+ info->requiredby = alpm_list_add(info->requiredby, strdup(line));
}
} else if(!strcmp(line, "%CONFLICTS%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->conflicts = _alpm_list_add(info->conflicts, strdup(line));
+ info->conflicts = alpm_list_add(info->conflicts, strdup(line));
}
} else if(!strcmp(line, "%PROVIDES%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->provides = _alpm_list_add(info->provides, strdup(line));
+ info->provides = alpm_list_add(info->provides, strdup(line));
}
} else if(!strcmp(line, "%REPLACES%")) {
/* the REPLACES tag is special -- it only appears in sync repositories,
* not the local one. */
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
- info->replaces = _alpm_list_add(info->replaces, strdup(line));
+ info->replaces = alpm_list_add(info->replaces, strdup(line));
}
} else if(!strcmp(line, "%FORCE%")) {
/* FORCE tag only appears in sync repositories,
@@ -451,7 +451,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_t *lp = NULL;
+ alpm_list_t *lp = NULL;
int retval = 0;
int local = 0;
diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c
index 6aa517cf..db04b465 100644
--- a/lib/libalpm/cache.c
+++ b/lib/libalpm/cache.c
@@ -30,7 +30,7 @@
/* pacman */
#include "log.h"
#include "alpm.h"
-#include "list.h"
+#include "alpm_list.h"
#include "util.h"
#include "error.h"
#include "package.h"
@@ -62,11 +62,11 @@ int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel)
info->origin = PKG_FROM_CACHE;
info->data = db;
/* add to the collection */
- db->pkgcache = _alpm_list_add(db->pkgcache, info);
+ db->pkgcache = alpm_list_add(db->pkgcache, info);
count++;
}
- db->pkgcache = _alpm_list_msort(db->pkgcache, count, _alpm_pkg_cmp);
+ db->pkgcache = alpm_list_msort(db->pkgcache, count, _alpm_pkg_cmp);
return(0);
}
@@ -86,7 +86,7 @@ void _alpm_db_free_pkgcache(pmdb_t *db)
}
}
-pmlist_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel)
+alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel)
{
if(db == NULL) {
return(NULL);
@@ -108,7 +108,7 @@ int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel)
* info is not already cached
*/
- pmlist_t *p;
+ alpm_list_t *p;
for(p = db->pkgcache; p; p = p->next) {
pmpkg_t *pkg = (pmpkg_t *)p->data;
if(infolevel != INFRQ_NONE && !(pkg->infolevel & infolevel)) {
@@ -136,7 +136,7 @@ int _alpm_db_add_pkgincache(pmdb_t *db, pmpkg_t *pkg)
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("adding entry '%s' in '%s' cache"), newpkg->name, db->treename);
- db->pkgcache = _alpm_list_add_sorted(db->pkgcache, newpkg, _alpm_pkg_cmp);
+ db->pkgcache = alpm_list_add_sorted(db->pkgcache, newpkg, _alpm_pkg_cmp);
_alpm_db_free_grpcache(db);
@@ -152,7 +152,7 @@ int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
return(-1);
}
- db->pkgcache = _alpm_list_remove(db->pkgcache, pkg, _alpm_pkg_cmp, &vdata);
+ db->pkgcache = alpm_list_remove(db->pkgcache, pkg, _alpm_pkg_cmp, &vdata);
data = vdata;
if(data == NULL) {
/* package not found */
@@ -180,7 +180,7 @@ pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target)
*/
int _alpm_db_load_grpcache(pmdb_t *db)
{
- pmlist_t *lp;
+ alpm_list_t *lp;
if(db == NULL) {
return(-1);
@@ -193,25 +193,25 @@ int _alpm_db_load_grpcache(pmdb_t *db)
_alpm_log(PM_LOG_DEBUG, _("loading group cache for repository '%s'"), db->treename);
for(lp = _alpm_db_get_pkgcache(db, INFRQ_DESC); lp; lp = lp->next) {
- pmlist_t *i;
+ alpm_list_t *i;
pmpkg_t *pkg = lp->data;
for(i = pkg->groups; i; i = i->next) {
- if(!_alpm_list_is_strin(i->data, db->grpcache)) {
+ if(!alpm_list_is_strin(i->data, db->grpcache)) {
pmgrp_t *grp = _alpm_grp_new();
STRNCPY(grp->name, (char *)i->data, GRP_NAME_LEN);
- 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);
+ 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_t *j;
+ alpm_list_t *j;
for(j = db->grpcache; j; j = j->next) {
pmgrp_t *grp = j->data;
if(strcmp(grp->name, i->data) == 0) {
- if(!_alpm_list_is_strin(pkg->name, grp->packages)) {
- grp->packages = _alpm_list_add_sorted(grp->packages, (char *)pkg->name, _alpm_grp_cmp);
+ if(!alpm_list_is_strin(pkg->name, grp->packages)) {
+ grp->packages = alpm_list_add_sorted(grp->packages, (char *)pkg->name, _alpm_grp_cmp);
}
}
}
@@ -224,7 +224,7 @@ int _alpm_db_load_grpcache(pmdb_t *db)
void _alpm_db_free_grpcache(pmdb_t *db)
{
- pmlist_t *lg;
+ alpm_list_t *lg;
if(db == NULL || db->grpcache == NULL) {
return;
@@ -239,7 +239,7 @@ void _alpm_db_free_grpcache(pmdb_t *db)
FREELIST(db->grpcache);
}
-pmlist_t *_alpm_db_get_grpcache(pmdb_t *db)
+alpm_list_t *_alpm_db_get_grpcache(pmdb_t *db)
{
if(db == NULL) {
return(NULL);
@@ -254,7 +254,7 @@ pmlist_t *_alpm_db_get_grpcache(pmdb_t *db)
pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, char *target)
{
- pmlist_t *i;
+ alpm_list_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 5b366bdf..c17b8268 100644
--- a/lib/libalpm/cache.h
+++ b/lib/libalpm/cache.h
@@ -22,7 +22,7 @@
#define _ALPM_CACHE_H
#include "db.h"
-#include "list.h"
+#include "alpm_list.h"
#include "group.h"
#include "package.h"
@@ -31,13 +31,13 @@ int _alpm_db_load_pkgcache(pmdb_t *db, unsigned char infolevel);
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_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel);
+alpm_list_t *_alpm_db_get_pkgcache(pmdb_t *db, unsigned char infolevel);
int _alpm_db_ensure_pkgcache(pmdb_t *db, unsigned char infolevel);
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_t *_alpm_db_get_grpcache(pmdb_t *db);
+alpm_list_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 570520f1..088320e6 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -37,7 +37,7 @@
#include <libintl.h>
/* pacman */
#include "handle.h"
-#include "list.h"
+#include "alpm_list.h"
#include "trans.h"
#include "util.h"
#include "error.h"
@@ -46,15 +46,15 @@
#include "deps.h"
#include "conflict.h"
-/* Returns a pmlist_t* of pmdepmissing_t pointers.
+/* Returns a alpm_list_t* of pmdepmissing_t pointers.
*
* conflicts are always name only
*/
-pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages)
+alpm_list_t *_alpm_checkconflicts(pmdb_t *db, alpm_list_t *packages)
{
pmpkg_t *info = NULL;
- pmlist_t *i, *j, *k;
- pmlist_t *baddeps = NULL;
+ alpm_list_t *i, *j, *k;
+ alpm_list_t *baddeps = NULL;
pmdepmissing_t *miss = NULL;
if(db == NULL) {
@@ -86,13 +86,13 @@ pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages)
dp->name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, dp->name, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
} else {
/* see if dp provides something in tp's conflict list */
- pmlist_t *m;
+ alpm_list_t *m;
for(m = dp->provides; m; m = m->next) {
if(!strcmp(m->data, j->data)) {
/* confict */
@@ -100,7 +100,7 @@ pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages)
dp->name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, dp->name, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
@@ -122,20 +122,20 @@ pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages)
otp->name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, otp->name, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
} else {
/* see if otp provides something in tp's conflict list */
- pmlist_t *m;
+ alpm_list_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"),
otp->name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, otp->name, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
@@ -147,7 +147,7 @@ pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *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, INFRQ_DEPENDS); k; k = k->next) {
- pmlist_t *conflicts = NULL;
+ alpm_list_t *conflicts = NULL;
int usenewconflicts = 0;
info = k->data;
@@ -155,7 +155,7 @@ pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages)
/* a package cannot conflict with itself -- that's just not nice */
continue;
}
- /* If this package (*info) is also in our packages pmlist_t, use the
+ /* If this package (*info) is also in our packages alpm_list_t, use the
* conflicts list from the new package, not the old one (*info)
*/
for(j = packages; j; j = j->next) {
@@ -176,22 +176,22 @@ pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages)
info->name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, info->name, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
} else {
/* see if the db package conflicts with something we provide */
- pmlist_t *m;
+ alpm_list_t *m;
for(m = conflicts; m; m = m->next) {
- pmlist_t *n;
+ alpm_list_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"),
info->name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, info->name, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
@@ -206,18 +206,18 @@ pmlist_t *_alpm_checkconflicts(pmdb_t *db, pmlist_t *packages)
return(baddeps);
}
-/* Returns a pmlist_t* of file conflicts.
+/* Returns a alpm_list_t* of file conflicts.
*
- * adds list of files to skip to pmlist_t** skip_list.
+ * adds list of files to skip to alpm_list_t** skip_list.
*/
-pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmlist_t **skip_list)
+alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, alpm_list_t **skip_list)
{
- pmlist_t *i, *j, *k;
+ alpm_list_t *i, *j, *k;
char *filestr = NULL;
char path[PATH_MAX+1];
struct stat buf, buf2;
- pmlist_t *conflicts = NULL;
- pmlist_t *targets = trans->packages;
+ alpm_list_t *conflicts = NULL;
+ alpm_list_t *targets = trans->packages;
double percent;
if(db == NULL || targets == NULL || root == NULL) {
@@ -226,8 +226,8 @@ pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmli
/* CHECK 1: check every target against every target */
for(i = targets; i; i = i->next) {
pmpkg_t *p1 = (pmpkg_t*)i->data;
- percent = (double)(_alpm_list_count(targets) - _alpm_list_count(i) + 1) / _alpm_list_count(targets);
- PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", (percent * 100), _alpm_list_count(targets), (_alpm_list_count(targets) - _alpm_list_count(i) +1));
+ percent = (double)(alpm_list_count(targets) - alpm_list_count(i) + 1) / alpm_list_count(targets);
+ PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", (percent * 100), alpm_list_count(targets), (alpm_list_count(targets) - alpm_list_count(i) +1));
for(j = i; j; j = j->next) {
pmpkg_t *p2 = (pmpkg_t*)j->data;
if(strcmp(p1->name, p2->name)) {
@@ -240,7 +240,7 @@ pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmli
if(strcmp(filestr, ".INSTALL") == 0) {
continue;
}
- if(_alpm_list_is_strin(filestr, p2->files)) {
+ if(alpm_list_is_strin(filestr, p2->files)) {
pmconflict_t *conflict = malloc(sizeof(pmconflict_t));
if(conflict == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"),
@@ -251,7 +251,7 @@ pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmli
STRNCPY(conflict->target, p1->name, PKG_NAME_LEN);
STRNCPY(conflict->file, filestr, CONFLICT_FILE_LEN);
STRNCPY(conflict->ctarget, p2->name, PKG_NAME_LEN);
- conflicts = _alpm_list_add(conflicts, conflict);
+ conflicts = alpm_list_add(conflicts, conflict);
}
}
}
@@ -284,7 +284,7 @@ pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmli
_alpm_log(PM_LOG_DEBUG, _("loading FILES info for '%s'"), dbpkg->name);
_alpm_db_read(db, INFRQ_FILES, dbpkg);
}
- if(dbpkg && _alpm_list_is_strin(j->data, dbpkg->files)) {
+ if(dbpkg && alpm_list_is_strin(j->data, dbpkg->files)) {
ok = 1;
}
/* Make sure that the supposedly-conflicting file is not actually just
@@ -315,7 +315,7 @@ pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmli
_alpm_db_read(db, INFRQ_FILES, dbpkg2);
}
/* If it used to exist in there, but doesn't anymore */
- if(dbpkg2 && !_alpm_list_is_strin(filestr, p1->files) && _alpm_list_is_strin(filestr, dbpkg2->files)) {
+ if(dbpkg2 && !alpm_list_is_strin(filestr, p1->files) && alpm_list_is_strin(filestr, dbpkg2->files)) {
ok = 1;
/* Add to the "skip list" of files that we shouldn't remove during an upgrade.
*
@@ -333,7 +333,7 @@ pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmli
* Our workaround is to scan through all "old" packages and all "new"
* ones, looking for files that jump to different packages.
*/
- *skip_list = _alpm_list_add(*skip_list, strdup(filestr));
+ *skip_list = alpm_list_add(*skip_list, strdup(filestr));
}
}
}
@@ -350,7 +350,7 @@ pmlist_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, pmli
STRNCPY(conflict->target, p->name, PKG_NAME_LEN);
STRNCPY(conflict->file, filestr, CONFLICT_FILE_LEN);
conflict->ctarget[0] = 0;
- conflicts = _alpm_list_add(conflicts, conflict);
+ conflicts = alpm_list_add(conflicts, conflict);
}
}
}
diff --git a/lib/libalpm/conflict.h b/lib/libalpm/conflict.h
index 7bf8744b..07225991 100644
--- a/lib/libalpm/conflict.h
+++ b/lib/libalpm/conflict.h
@@ -33,8 +33,8 @@ struct __pmconflict_t {
char ctarget[PKG_NAME_LEN];
};
-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);
+alpm_list_t *_alpm_checkconflicts(pmdb_t *db, alpm_list_t *packages);
+alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, alpm_list_t **skip_list);
#endif /* _ALPM_CONFLICT_H */
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 1cc603be..84c05ccc 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -96,9 +96,9 @@ int _alpm_db_cmp(const void *db1, const void *db2)
return(strcmp(((pmdb_t *)db1)->treename, ((pmdb_t *)db2)->treename));
}
-pmlist_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles)
+alpm_list_t *_alpm_db_search(pmdb_t *db, alpm_list_t *needles)
{
- pmlist_t *i, *j, *k, *ret = NULL;
+ alpm_list_t *i, *j, *k, *ret = NULL;
for(i = needles; i; i = i->next) {
char *targ;
@@ -139,7 +139,7 @@ pmlist_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles)
if(matched != NULL) {
_alpm_log(PM_LOG_DEBUG, " search target '%s' matched '%s'", targ, matched);
- ret = _alpm_list_add(ret, pkg);
+ ret = alpm_list_add(ret, pkg);
}
}
}
@@ -159,7 +159,7 @@ pmdb_t *_alpm_db_register(char *treename, alpm_cb_db_register callback)
RET_ERR(PM_ERR_DB_NOT_NULL, NULL);
}
} else {
- pmlist_t *i;
+ alpm_list_t *i;
for(i = handle->dbs_sync; i; i = i->next) {
pmdb_t *sdb = i->data;
if(strcmp(treename, sdb->treename) == 0) {
@@ -197,7 +197,7 @@ pmdb_t *_alpm_db_register(char *treename, alpm_cb_db_register callback)
if(strcmp(treename, "local") == 0) {
handle->db_local = db;
} else {
- handle->dbs_sync = _alpm_list_add(handle->dbs_sync, db);
+ handle->dbs_sync = alpm_list_add(handle->dbs_sync, db);
}
return(db);
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 9224d69a..6d9ddd2c 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -39,15 +39,15 @@ struct __pmdb_t {
char *path;
char treename[PATH_MAX];
void *handle;
- pmlist_t *pkgcache;
- pmlist_t *grpcache;
- pmlist_t *servers;
+ alpm_list_t *pkgcache;
+ alpm_list_t *grpcache;
+ alpm_list_t *servers;
};
/* db.c, database general calls */
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_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles);
+alpm_list_t *_alpm_db_search(pmdb_t *db, alpm_list_t *needles);
pmdb_t *_alpm_db_register(char *treename, alpm_cb_db_register callback);
/* be.c, backend specific calls */
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index cb53d41b..31aba2b4 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -33,7 +33,7 @@
#include "util.h"
#include "log.h"
#include "error.h"
-#include "list.h"
+#include "alpm_list.h"
#include "package.h"
#include "db.h"
#include "cache.h"
@@ -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_t *haystack)
+int _alpm_depmiss_isin(pmdepmissing_t *needle, alpm_list_t *haystack)
{
- pmlist_t *i;
+ alpm_list_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_t *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_t* target list.
+ * This function returns the new alpm_list_t* target list.
*
*/
-pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode)
+alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int mode)
{
- pmlist_t *newtargs = NULL;
- pmlist_t *i, *j, *k, *l;
+ alpm_list_t *newtargs = NULL;
+ alpm_list_t *i, *j, *k, *l;
int change = 1;
int numscans = 0;
int numtargs = 0;
@@ -111,13 +111,13 @@ pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode)
}
for(i = targets; i; i = i->next) {
- newtargs = _alpm_list_add(newtargs, i->data);
+ newtargs = alpm_list_add(newtargs, i->data);
numtargs++;
}
_alpm_log(PM_LOG_DEBUG, _("started sorting dependencies"));
while(change) {
- pmlist_t *tmptargs = NULL;
+ alpm_list_t *tmptargs = NULL;
change = 0;
/* TODO only use of a math.h function in entire libalpm,
* can we get rid of it? Former code line:
@@ -147,7 +147,7 @@ pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode)
if(!strcmp(dep.name, q->name)) {
if(!_alpm_pkg_isin(q->name, tmptargs)) {
change = 1;
- tmptargs = _alpm_list_add(tmptargs, q);
+ tmptargs = alpm_list_add(tmptargs, q);
}
break;
}
@@ -155,7 +155,7 @@ pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode)
if(!strcmp(dep.name, (char*)l->data)) {
if(!_alpm_pkg_isin((char*)l->data, tmptargs)) {
change = 1;
- tmptargs = _alpm_list_add(tmptargs, q);
+ tmptargs = alpm_list_add(tmptargs, q);
}
break;
}
@@ -163,7 +163,7 @@ pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode)
}
}
if(!_alpm_pkg_isin(p->name, tmptargs)) {
- tmptargs = _alpm_list_add(tmptargs, p);
+ tmptargs = alpm_list_add(tmptargs, p);
}
}
FREELISTPTR(newtargs);
@@ -173,7 +173,7 @@ pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode)
if(mode == PM_TRANS_TYPE_REMOVE) {
/* we're removing packages, so reverse the order */
- pmlist_t *tmptargs = _alpm_list_reverse(newtargs);
+ alpm_list_t *tmptargs = alpm_list_reverse(newtargs);
/* free the old one */
FREELISTPTR(newtargs);
newtargs = tmptargs;
@@ -182,17 +182,17 @@ pmlist_t *_alpm_sortbydeps(pmlist_t *targets, int mode)
return(newtargs);
}
-/* Returns a pmlist_t* of missing_t pointers.
+/* Returns a alpm_list_t* of missing_t pointers.
*
* dependencies can include versions with depmod operators.
*
*/
-pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist_t *packages)
+alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alpm_list_t *packages)
{
pmdepend_t depend;
- pmlist_t *i, *j, *k;
+ alpm_list_t *i, *j, *k;
int found = 0;
- pmlist_t *baddeps = NULL;
+ alpm_list_t *baddeps = NULL;
pmdepmissing_t *miss = NULL;
if(db == NULL) {
@@ -237,7 +237,7 @@ pmlist_t *_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_t *provides = _alpm_db_whatprovides(db, depend.name);
+ alpm_list_t *provides = _alpm_db_whatprovides(db, depend.name);
if(provides == NULL) {
/* not found */
continue;
@@ -249,7 +249,7 @@ pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"), depend.name, p->name);
miss = _alpm_depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod, depend.name, depend.version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
@@ -284,7 +284,7 @@ pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist
}
/* check database for provides matches */
if(!found) {
- pmlist_t *m;
+ alpm_list_t *m;
k = _alpm_db_whatprovides(db, depend.name);
for(m = k; m && !found; m = m->next) {
/* look for a match that isn't one of the packages we're trying
@@ -292,7 +292,7 @@ pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist
* package, we'll defer to the NEW one, not the one already
* installed. */
pmpkg_t *p = m->data;
- pmlist_t *n;
+ alpm_list_t *n;
int skip = 0;
for(n = packages; n && !skip; n = n->next) {
pmpkg_t *ptp = n->data;
@@ -319,7 +319,7 @@ pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist
depend.name, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod, depend.name, depend.version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
@@ -338,7 +338,7 @@ pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist
for(j = tp->requiredby; j; j = j->next) {
/* Search for 'reqname' in packages for removal */
char *reqname = j->data;
- pmlist_t *x = NULL;
+ alpm_list_t *x = NULL;
for(x = packages; x; x = x->next) {
pmpkg_t *xp = x->data;
if(strcmp(reqname, xp->name) == 0) {
@@ -357,7 +357,7 @@ pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist
spkg = k->data;
}
if(spkg) {
- if(_alpm_list_is_strin(tp->name, spkg->provides)) {
+ if(alpm_list_is_strin(tp->name, spkg->provides)) {
found = 1;
}
}
@@ -366,7 +366,7 @@ pmlist_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, pmlist
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"), reqname, tp->name);
miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_REQUIRED, PM_DEP_MOD_ANY, j->data, NULL);
if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = _alpm_list_add(baddeps, miss);
+ baddeps = alpm_list_add(baddeps, miss);
} else {
FREE(miss);
}
@@ -422,15 +422,15 @@ int _alpm_splitdep(char *depstr, pmdepend_t *depend)
return(0);
}
-/* return a new pmlist_t target list containing all packages in the original
+/* return a new alpm_list_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_t *_alpm_removedeps(pmdb_t *db, pmlist_t *targs)
+alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs)
{
- pmlist_t *i, *j, *k;
- pmlist_t *newtargs = targs;
+ alpm_list_t *i, *j, *k;
+ alpm_list_t *newtargs = targs;
if(db == NULL) {
return(newtargs);
@@ -497,7 +497,7 @@ pmlist_t *_alpm_removedeps(pmdb_t *db, pmlist_t *targs)
/* add it to the target list */
_alpm_log(PM_LOG_DEBUG, _("loading ALL info for '%s'"), pkg->name);
_alpm_db_read(db, INFRQ_ALL, pkg);
- newtargs = _alpm_list_add(newtargs, pkg);
+ newtargs = alpm_list_add(newtargs, pkg);
_alpm_log(PM_LOG_FLOW2, _("adding '%s' to the targets"), pkg->name);
newtargs = _alpm_removedeps(db, newtargs);
}
@@ -512,19 +512,19 @@ pmlist_t *_alpm_removedeps(pmdb_t *db, pmlist_t *targs)
*
* make sure *list and *trail are already initialized
*/
-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)
+int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, alpm_list_t *list,
+ alpm_list_t *trail, pmtrans_t *trans, alpm_list_t **data)
{
- pmlist_t *i, *j;
- pmlist_t *targ;
- pmlist_t *deps = NULL;
+ alpm_list_t *i, *j;
+ alpm_list_t *targ;
+ alpm_list_t *deps = NULL;
if(local == NULL || dbs_sync == NULL || syncpkg == NULL) {
return(-1);
}
_alpm_log(PM_LOG_DEBUG, _("started resolving dependencies"));
- targ = _alpm_list_add(NULL, syncpkg);
+ targ = alpm_list_add(NULL, syncpkg);
deps = _alpm_checkdeps(trans, local, PM_TRANS_TYPE_ADD, targ);
FREELISTPTR(targ);
@@ -540,7 +540,7 @@ int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlis
/* check if one of the packages in *list already provides this dependency */
for(j = list; j && !found; j = j->next) {
pmpkg_t *sp = (pmpkg_t *)j->data;
- if(_alpm_list_is_strin(miss->depend.name, sp->provides)) {
+ if(alpm_list_is_strin(miss->depend.name, sp->provides)) {
_alpm_log(PM_LOG_DEBUG, _("%s provides dependency %s -- skipping"),
sp->name, miss->depend.name);
found = 1;
@@ -558,7 +558,7 @@ int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlis
}
/* check provides */
for(j = dbs_sync; !sync && j; j = j->next) {
- pmlist_t *provides;
+ alpm_list_t *provides;
provides = _alpm_db_whatprovides(j->data, miss->depend.name);
if(provides) {
sync = provides->data;
@@ -576,7 +576,7 @@ int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlis
goto error;
}
*miss = *(pmdepmissing_t *)i->data;
- *data = _alpm_list_add(*data, miss);
+ *data = alpm_list_add(*data, miss);
}
pm_errno = PM_ERR_UNSATISFIED_DEPS;
goto error;
@@ -593,19 +593,19 @@ int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlis
* something we're not supposed to.
*/
int usedep = 1;
- if(_alpm_list_is_strin(sync->name, handle->ignorepkg)) {
+ if(alpm_list_is_strin(sync->name, handle->ignorepkg)) {
pmpkg_t *dummypkg = _alpm_pkg_new(miss->target, NULL);
QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep);
FREEPKG(dummypkg);
}
if(usedep) {
- trail = _alpm_list_add(trail, sync);
+ trail = alpm_list_add(trail, sync);
if(_alpm_resolvedeps(local, dbs_sync, sync, list, trail, trans, data)) {
goto error;
}
_alpm_log(PM_LOG_DEBUG, _("pulling dependency %s (needed by %s)"),
sync->name, syncpkg->name);
- list = _alpm_list_add(list, sync);
+ list = alpm_list_add(list, sync);
} else {
_alpm_log(PM_LOG_ERROR, _("cannot resolve dependencies for \"%s\""), miss->target);
if(data) {
@@ -616,7 +616,7 @@ int _alpm_resolvedeps(pmdb_t *local, pmlist_t *dbs_sync, pmpkg_t *syncpkg, pmlis
goto error;
}
*miss = *(pmdepmissing_t *)i->data;
- *data = _alpm_list_add(*data, miss);
+ *data = alpm_list_add(*data, miss);
}
pm_errno = PM_ERR_UNSATISFIED_DEPS;
goto error;
diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h
index 72425f56..d34d1eca 100644
--- a/lib/libalpm/deps.h
+++ b/lib/libalpm/deps.h
@@ -44,13 +44,13 @@ 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_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_depmiss_isin(pmdepmissing_t *needle, alpm_list_t *haystack);
+alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int mode);
+alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, unsigned char op, alpm_list_t *packages);
int _alpm_splitdep(char *depstr, pmdepend_t *depend);
-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);
+alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs);
+int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, alpm_list_t *list,
+ alpm_list_t *trail, pmtrans_t *trans, alpm_list_t **data);
#endif /* _ALPM_DEPS_H */
diff --git a/lib/libalpm/group.c b/lib/libalpm/group.c
index ecc608d8..e0294ccb 100644
--- a/lib/libalpm/group.c
+++ b/lib/libalpm/group.c
@@ -29,7 +29,7 @@
#include "error.h"
#include "log.h"
#include "group.h"
-#include "list.h"
+#include "alpm_list.h"
#include "alpm.h"
pmgrp_t *_alpm_grp_new()
@@ -81,7 +81,7 @@ const char *alpm_grp_get_name(pmgrp_t *grp)
return grp->name;
}
-pmlist_t *alpm_grp_get_packages(pmgrp_t *grp)
+alpm_list_t *alpm_grp_get_packages(pmgrp_t *grp)
{
/* Sanity checks */
ASSERT(grp != NULL, return(NULL));
diff --git a/lib/libalpm/group.h b/lib/libalpm/group.h
index 86562b10..c5366e64 100644
--- a/lib/libalpm/group.h
+++ b/lib/libalpm/group.h
@@ -28,7 +28,7 @@
struct __pmgrp_t {
char name[GRP_NAME_LEN];
- pmlist_t *packages; /* List of strings */
+ alpm_list_t *packages; /* List of strings */
};
#define FREEGRP(p) do { if(p) { _alpm_grp_free(p); p = NULL; } } while(0)
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index c6338d59..42490f6e 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -33,7 +33,7 @@
/* pacman */
#include "util.h"
#include "log.h"
-#include "list.h"
+#include "alpm_list.h"
#include "error.h"
#include "trans.h"
#include "alpm.h"
@@ -123,19 +123,19 @@ const char *alpm_option_get_dbpath() { return handle->dbpath; }
const char *alpm_option_get_cachedir() { return handle->cachedir; }
const char *alpm_option_get_logfile() { return handle->logfile; }
unsigned char alpm_option_get_usesyslog() { return handle->usesyslog; }
-pmlist_t *alpm_option_get_noupgrades() { return handle->noupgrade; }
-pmlist_t *alpm_option_get_noextracts() { return handle->noextract; }
-pmlist_t *alpm_option_get_ignorepkgs() { return handle->ignorepkg; }
-pmlist_t *alpm_option_get_holdpkgs() { return handle->holdpkg; }
+alpm_list_t *alpm_option_get_noupgrades() { return handle->noupgrade; }
+alpm_list_t *alpm_option_get_noextracts() { return handle->noextract; }
+alpm_list_t *alpm_option_get_ignorepkgs() { return handle->ignorepkg; }
+alpm_list_t *alpm_option_get_holdpkgs() { return handle->holdpkg; }
time_t alpm_option_get_upgradedelay() { return handle->upgradedelay; }
const char *alpm_option_get_xfercommand() { return handle->xfercommand; }
unsigned short alpm_option_get_nopassiveftp() { return handle->nopassiveftp; }
unsigned short alpm_option_get_chomp() { return handle->chomp; }
-pmlist_t *alpm_option_get_needles() { return handle->needles; }
+alpm_list_t *alpm_option_get_needles() { return handle->needles; }
unsigned short alpm_option_get_usecolor() { return handle->use_color; }
-pmdb_t *alpm_option_get_localdb(pmhandle_t *handle) { return handle->db_local; }
-pmlist_t *alpm_option_get_syncdbs(pmhandle_t *handle) { return handle->dbs_sync; }
+pmdb_t *alpm_option_get_localdb() { return handle->db_local; }
+alpm_list_t *alpm_option_get_syncdbs() { return handle->dbs_sync; }
void alpm_option_set_logcb(alpm_cb_log cb) { handle->logcb = cb; }
@@ -180,9 +180,9 @@ void alpm_option_set_usesyslog(unsigned char usesyslog) { handle->usesyslog = us
void alpm_option_add_noupgrade(char *pkg)
{
- handle->noupgrade = _alpm_list_add(handle->noupgrade, strdup(pkg));
+ handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(pkg));
}
-void alpm_option_set_noupgrades(pmlist_t *noupgrade)
+void alpm_option_set_noupgrades(alpm_list_t *noupgrade)
{
if(handle->noupgrade) FREELIST(handle->noupgrade);
if(noupgrade) handle->noupgrade = noupgrade;
@@ -190,9 +190,9 @@ void alpm_option_set_noupgrades(pmlist_t *noupgrade)
void alpm_option_add_noextract(char *pkg)
{
- handle->noextract = _alpm_list_add(handle->noextract, strdup(pkg));
+ handle->noextract = alpm_list_add(handle->noextract, strdup(pkg));
}
-void alpm_option_set_noextracts(pmlist_t *noextract)
+void alpm_option_set_noextracts(alpm_list_t *noextract)
{
if(handle->noextract) FREELIST(handle->noextract);
if(noextract) handle->noextract = noextract;
@@ -200,9 +200,9 @@ void alpm_option_set_noextracts(pmlist_t *noextract)
void alpm_option_add_ignorepkg(char *pkg)
{
- handle->ignorepkg = _alpm_list_add(handle->ignorepkg, strdup(pkg));
+ handle->ignorepkg = alpm_list_add(handle->ignorepkg, strdup(pkg));
}
-void alpm_option_set_ignorepkgs(pmlist_t *ignorepkgs)
+void alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs)
{
if(handle->ignorepkg) FREELIST(handle->ignorepkg);
if(ignorepkgs) handle->ignorepkg = ignorepkgs;
@@ -210,9 +210,9 @@ void alpm_option_set_ignorepkgs(pmlist_t *ignorepkgs)
void alpm_option_add_holdpkg(char *pkg)
{
- handle->holdpkg = _alpm_list_add(handle->holdpkg, strdup(pkg));
+ handle->holdpkg = alpm_list_add(handle->holdpkg, strdup(pkg));
}
-void alpm_option_set_holdpkgs(pmlist_t *holdpkgs)
+void alpm_option_set_holdpkgs(alpm_list_t *holdpkgs)
{
if(handle->holdpkg) FREELIST(handle->holdpkg);
if(holdpkgs) handle->holdpkg = holdpkgs;
@@ -232,9 +232,9 @@ void alpm_option_set_chomp(unsigned short chomp) { handle->chomp = chomp; }
void alpm_option_add_needle(char *needle)
{
- handle->needles = _alpm_list_add(handle->needles, strdup(needle));
+ handle->needles = alpm_list_add(handle->needles, strdup(needle));
}
-void alpm_option_set_needles(pmlist_t *needles)
+void alpm_option_set_needles(alpm_list_t *needles)
{
if(handle->needles) FREELIST(handle->needles);
if(needles) handle->needles = needles;
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index 41e8a5fe..eb5f734e 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -23,7 +23,7 @@
#include "db.h"
#include "log.h"
-#include "list.h"
+#include "alpm_list.h"
#include "alpm.h"
#include "trans.h"
@@ -37,7 +37,7 @@ typedef struct _pmhandle_t {
pmaccess_t access;
uid_t uid;
pmdb_t *db_local;
- pmlist_t *dbs_sync; /* List of (pmdb_t *) */
+ alpm_list_t *dbs_sync; /* List of (pmdb_t *) */
FILE *logfd;
int lckfd;
pmtrans_t *trans;
@@ -52,17 +52,17 @@ typedef struct _pmhandle_t {
char *logfile; /* Name of the file to log to */ /*TODO is this used?*/
unsigned char usesyslog; /* Use syslog instead of logfile? */
- pmlist_t *noupgrade; /* List of packages NOT to be upgraded */
- pmlist_t *noextract; /* List of packages NOT to extrace */ /*TODO is this used?*/
- pmlist_t *ignorepkg; /* List of packages to ignore */
- pmlist_t *holdpkg; /* List of packages which 'hold' pacman */
+ alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
+ alpm_list_t *noextract; /* List of packages NOT to extrace */ /*TODO is this used?*/
+ alpm_list_t *ignorepkg; /* List of packages to ignore */
+ alpm_list_t *holdpkg; /* List of packages which 'hold' pacman */
time_t upgradedelay; /* Amount of time to wait before upgrading a package*/
/* servers */
char *xfercommand; /* External download command */
unsigned short nopassiveftp; /* Don't use PASV ftp connections */
unsigned short chomp; /* I Love Candy! */
- pmlist_t *needles; /* needles for searching */ /* TODO why is this here? */
+ alpm_list_t *needles; /* needles for searching */ /* TODO why is this here? */
unsigned short use_color; /* enable colorful output */
} pmhandle_t;
diff --git a/lib/libalpm/list.c b/lib/libalpm/list.c
deleted file mode 100644
index b6797073..00000000
--- a/lib/libalpm/list.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * list.c
- *
- * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-/* pacman */
-#include "list.h"
-#include "util.h"
-
-pmlist_t *_alpm_list_new()
-{
- pmlist_t *list = NULL;
-
- list = (pmlist_t *)malloc(sizeof(pmlist_t));
- if(list == NULL) {
- return(NULL);
- }
- list->data = NULL;
- list->prev = NULL;
- list->next = NULL;
- list->last = list;
- return(list);
-}
-
-void _alpm_list_free(pmlist_t *list, _alpm_fn_free fn)
-{
- pmlist_t *ptr, *it = list;
-
- while(it) {
- ptr = it->next;
- if(fn && it->data) {
- fn(it->data);
- }
- FREE(it);
- it = ptr;
- }
-}
-
-pmlist_t *_alpm_list_add(pmlist_t *list, void *data)
-{
- pmlist_t *ptr, *lp;
-
- ptr = list;
- if(ptr == NULL) {
- ptr = _alpm_list_new();
- if(ptr == NULL) {
- return(NULL);
- }
- }
-
- lp = _alpm_list_last(ptr);
- if(lp == ptr && lp->data == NULL) {
- /* nada */
- } else {
- lp->next = _alpm_list_new();
- if(lp->next == NULL) {
- return(NULL);
- }
- lp->next->prev = lp;
- lp->last = NULL;
- lp = lp->next;
- }
-
- lp->data = data;
- ptr->last = lp;
-
- return(ptr);
-}
-
-/* Add items to a list in sorted order. Use the given comparision func to
- * determine order.
- */
-pmlist_t *_alpm_list_add_sorted(pmlist_t *list, void *data, _alpm_fn_cmp fn)
-{
- pmlist_t *add;
- pmlist_t *prev = NULL;
- pmlist_t *iter = list;
-
- add = _alpm_list_new();
- add->data = data;
-
- /* Find insertion point. */
- while(iter) {
- if(fn(add->data, iter->data) <= 0) break;
- prev = iter;
- iter = iter->next;
- }
-
- /* Insert node before insertion point. */
- add->prev = prev;
- add->next = iter;
-
- if(iter != NULL) {
- iter->prev = add; /* Not at end. */
- } else {
- if (list != NULL) {
- list->last = add; /* Added new to end, so update the link to last. */
- }
- }
-
- if(prev != NULL) {
- prev->next = add; /* In middle. */
- } else {
- if(list == NULL) {
- add->last = add;
- } else {
- add->last = list->last;
- list->last = NULL;
- }
- list = add; /* Start or empty, new list head. */
- }
-
- return(list);
-}
-
-/* return nth element from list (starting with 0) */
-pmlist_t* _alpm_list_nth(pmlist_t *list, int n) {
- while (n--)
- list = list->next;
- return list;
-}
-
-/* merge the two sorted sublists into one sorted list */
-pmlist_t* _alpm_list_mmerge(pmlist_t *left, pmlist_t *right, _alpm_fn_cmp fn) {
- pmlist_t *newlist;
- pmlist_t *lp;
-
- if (left == NULL)
- return right;
- if (right == NULL)
- return left;
-
- if (fn(left->data, right->data) <= 0) {
- newlist = left;
- left = left->next;
- }
- else {
- newlist = right;
- right = right->next;
- }
- newlist->prev = NULL;
- newlist->next = NULL;
- newlist->last = NULL;
- lp = newlist;
-
- while ((left != NULL) && (right != NULL)) {
- if (fn(left->data, right->data) <= 0) {
- lp->next = left;
- left->prev = lp;
- left = left->next;
- }
- else {
- lp->next = right;
- right->prev = lp;
- right = right->next;
- }
- lp = lp->next;
- lp->next = NULL;
- newlist->last = lp;
- }
- if (left != NULL) {
- lp->next = left;
- left->prev = lp;
- newlist->last = left->last;
- }
- else if (right != NULL) {
- lp->next = right;
- right->prev = lp;
- newlist->last = right->last;
- }
- return newlist;
-}
-
-/* sort an list of size n using mergesort algorithm */
-pmlist_t* _alpm_list_msort(pmlist_t *list, int len, _alpm_fn_cmp fn) {
- if (len > 1 ) {
- pmlist_t *left = list;
- pmlist_t *lastleft = _alpm_list_nth(list, len/2 - 1);
- pmlist_t *right = lastleft->next;
- /* update rights last element, to previous last element*/
- right->last = left->last;
- /* update lefts last element */
- left->last = lastleft;
- /* terminate first list */
- lastleft->next = NULL;
-
- left = _alpm_list_msort(left, len/2, fn);
- right = _alpm_list_msort(right, len - (len/2), fn);
- list = _alpm_list_mmerge(left, right, fn);
- }
- return list;
-}
-
-/* Remove an item in a list. Use the given comparaison function to find the
- * item.
- * If the item is found, 'data' is pointing to the removed element.
- * Otherwise, it is set to NULL.
- * Return the new list (without the removed element).
- */
-pmlist_t *_alpm_list_remove(pmlist_t *haystack, void *needle, _alpm_fn_cmp fn, void **data)
-{
- pmlist_t *i = haystack;
-
- if(data) {
- *data = NULL;
- }
-
- while(i) {
- if(i->data == NULL) {
- continue;
- }
- if(fn(needle, i->data) == 0) {
- break;
- }
- i = i->next;
- }
-
- if(i) {
- /* we found a matching item */
- if(i->next) {
- i->next->prev = i->prev;
- }
- if(i->prev) {
- i->prev->next = i->next;
- }
- if(i == haystack) {
- /* The item found is the first in the chain */
- if(haystack->next) {
- haystack->next->last = haystack->last;
- }
- haystack = haystack->next;
- } else if(i == haystack->last) {
- /* The item found is the last in the chain */
- haystack->last = i->prev;
- }
-
- if(data) {
- *data = i->data;
- }
- i->data = NULL;
- FREE(i);
- }
-
- return(haystack);
-}
-
-int _alpm_list_count(const pmlist_t *list)
-{
- int i;
- const pmlist_t *lp;
-
- for(lp = list, i = 0; lp; lp = lp->next, i++);
-
- return(i);
-}
-
-int _alpm_list_is_in(void *needle, pmlist_t *haystack)
-{
- pmlist_t *lp;
-
- for(lp = haystack; lp; lp = lp->next) {
- if(lp->data == needle) {
- return(1);
- }
- }
- return(0);
-}
-
-/* Test for existence of a string in a pmlist_t
-*/
-int _alpm_list_is_strin(char *needle, pmlist_t *haystack)
-{
- pmlist_t *lp;
-
- for(lp = haystack; lp; lp = lp->next) {
- if(lp->data && !strcmp(lp->data, needle)) {
- return(1);
- }
- }
- return(0);
-}
-
-pmlist_t *_alpm_list_last(pmlist_t *list)
-{
- if(list == NULL) {
- return(NULL);
- }
-
- return(list->last);
-}
-
-/* Filter out any duplicate strings in a list.
- *
- * Not the most efficient way, but simple to implement -- we assemble
- * a new list, using is_in() to check for dupes at each iteration.
- *
- */
-pmlist_t *_alpm_list_remove_dupes(pmlist_t *list)
-{
- pmlist_t *i, *newlist = NULL;
-
- for(i = list; i; i = i->next) {
- if(!_alpm_list_is_strin(i->data, newlist)) {
- newlist = _alpm_list_add(newlist, strdup(i->data));
- }
- }
- return newlist;
-}
-
-/* Reverse the order of a list
- *
- * The caller is responsible for freeing the old 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_t *newlist = NULL;
- pmlist_t *lp;
-
- for(lp = list->last; lp; lp = lp->prev) {
- newlist = _alpm_list_add(newlist, lp->data);
- }
-
- return(newlist);
-}
-
-pmlist_t *_alpm_list_strdup(pmlist_t *list)
-{
- pmlist_t *newlist = NULL;
- pmlist_t *lp;
-
- for(lp = list; lp; lp = lp->next) {
- newlist = _alpm_list_add(newlist, strdup(lp->data));
- }
-
- return(newlist);
-}
-
-/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/list.h b/lib/libalpm/list.h
deleted file mode 100644
index a065b01e..00000000
--- a/lib/libalpm/list.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * list.h
- *
- * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-#ifndef _ALPM_LIST_H
-#define _ALPM_LIST_H
-
-#include "alpm.h"
-
-/* Chained list struct */
-struct __pmlist_t {
- void *data;
- struct __pmlist_t *prev;
- struct __pmlist_t *next;
- struct __pmlist_t *last; /* Quick access to last item in list */
-};
-
-#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)
-
-typedef void (*_alpm_fn_free)(void *);
-/* Sort comparison callback function declaration */
-typedef int (*_alpm_fn_cmp)(const void *, const void *);
-
-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_mmerge(pmlist_t *left, pmlist_t *right, _alpm_fn_cmp fn);
-pmlist_t* _alpm_list_msort(pmlist_t *list, int len, _alpm_fn_cmp fn);
-pmlist_t* _alpm_list_nth(pmlist_t *list, int n);
-pmlist_t *_alpm_list_remove(pmlist_t *haystack, void *needle, _alpm_fn_cmp fn, void **data);
-int _alpm_list_count(const 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 */
-
-/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index aa72be40..23d11bfd 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -33,7 +33,7 @@
#include "log.h"
#include "util.h"
#include "error.h"
-#include "list.h"
+#include "alpm_list.h"
#include "package.h"
#include "db.h"
#include "handle.h"
@@ -118,17 +118,17 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg)
newpkg->force = pkg->force;
newpkg->scriptlet = pkg->scriptlet;
newpkg->reason = pkg->reason;
- newpkg->license = _alpm_list_strdup(pkg->license);
- newpkg->desc_localized = _alpm_list_strdup(pkg->desc_localized);
- newpkg->requiredby = _alpm_list_strdup(pkg->requiredby);
- newpkg->conflicts = _alpm_list_strdup(pkg->conflicts);
- newpkg->files = _alpm_list_strdup(pkg->files);
- newpkg->backup = _alpm_list_strdup(pkg->backup);
- newpkg->depends = _alpm_list_strdup(pkg->depends);
- newpkg->removes = _alpm_list_strdup(pkg->removes);
- newpkg->groups = _alpm_list_strdup(pkg->groups);
- newpkg->provides = _alpm_list_strdup(pkg->provides);
- newpkg->replaces = _alpm_list_strdup(pkg->replaces);
+ newpkg->license = alpm_list_strdup(pkg->license);
+ newpkg->desc_localized = alpm_list_strdup(pkg->desc_localized);
+ newpkg->requiredby = alpm_list_strdup(pkg->requiredby);
+ newpkg->conflicts = alpm_list_strdup(pkg->conflicts);
+ newpkg->files = alpm_list_strdup(pkg->files);
+ newpkg->backup = alpm_list_strdup(pkg->backup);
+ newpkg->depends = alpm_list_strdup(pkg->depends);
+ newpkg->removes = alpm_list_strdup(pkg->removes);
+ newpkg->groups = alpm_list_strdup(pkg->groups);
+ newpkg->provides = alpm_list_strdup(pkg->provides);
+ newpkg->replaces = alpm_list_strdup(pkg->replaces);
/* internal */
newpkg->origin = pkg->origin;
newpkg->data = (newpkg->origin == PKG_FROM_FILE) ? strdup(pkg->data) : pkg->data;
@@ -214,7 +214,7 @@ static int parse_descfile(char *descfile, pmpkg_t *info, int output)
STRNCPY(info->version, ptr, sizeof(info->version));
} else if(!strcmp(key, "PKGDESC")) {
char *lang_tmp;
- info->desc_localized = _alpm_list_add(info->desc_localized, strdup(ptr));
+ info->desc_localized = alpm_list_add(info->desc_localized, strdup(ptr));
if((lang_tmp = (char *)malloc(strlen(setlocale(LC_ALL, "")))) == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
}
@@ -226,11 +226,11 @@ static int parse_descfile(char *descfile, pmpkg_t *info, int output)
}
FREE(lang_tmp);
} else if(!strcmp(key, "GROUP")) {
- info->groups = _alpm_list_add(info->groups, strdup(ptr));
+ info->groups = alpm_list_add(info->groups, strdup(ptr));
} else if(!strcmp(key, "URL")) {
STRNCPY(info->url, ptr, sizeof(info->url));
} else if(!strcmp(key, "LICENSE")) {
- info->license = _alpm_list_add(info->license, strdup(ptr));
+ info->license = alpm_list_add(info->license, strdup(ptr));
} else if(!strcmp(key, "BUILDDATE")) {
STRNCPY(info->builddate, ptr, sizeof(info->builddate));
} else if(!strcmp(key, "BUILDTYPE")) {
@@ -250,17 +250,17 @@ static int parse_descfile(char *descfile, pmpkg_t *info, int output)
STRNCPY(tmp, ptr, sizeof(tmp));
info->isize = atol(ptr);
} else if(!strcmp(key, "DEPEND")) {
- info->depends = _alpm_list_add(info->depends, strdup(ptr));
+ info->depends = alpm_list_add(info->depends, strdup(ptr));
} else if(!strcmp(key, "REMOVE")) {
- info->removes = _alpm_list_add(info->removes, strdup(ptr));
+ info->removes = alpm_list_add(info->removes, strdup(ptr));
} else if(!strcmp(key, "CONFLICT")) {
- info->conflicts = _alpm_list_add(info->conflicts, strdup(ptr));
+ info->conflicts = alpm_list_add(info->conflicts, strdup(ptr));
} else if(!strcmp(key, "REPLACES")) {
- info->replaces = _alpm_list_add(info->replaces, strdup(ptr));
+ info->replaces = alpm_list_add(info->replaces, strdup(ptr));
} else if(!strcmp(key, "PROVIDES")) {
- info->provides = _alpm_list_add(info->provides, strdup(ptr));
+ info->provides = alpm_list_add(info->provides, strdup(ptr));
} else if(!strcmp(key, "BACKUP")) {
- info->backup = _alpm_list_add(info->backup, strdup(ptr));
+ info->backup = alpm_list_add(info->backup, strdup(ptr));
} else {
_alpm_log(PM_LOG_DEBUG, _("%s: syntax error in description file line %d"),
info->name[0] != '\0' ? info->name : "error", linenum);
@@ -369,7 +369,7 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile)
continue;
}
_alpm_strtrim(str);
- info->files = _alpm_list_add(info->files, strdup(str));
+ info->files = alpm_list_add(info->files, strdup(str));
}
FREE(str);
fclose(fp);
@@ -386,7 +386,7 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile)
/* no .FILELIST present in this package.. build the filelist the */
/* old-fashioned way, one at a time */
expath = strdup(archive_entry_pathname (entry));
- info->files = _alpm_list_add(info->files, expath);
+ info->files = alpm_list_add(info->files, expath);
}
}
@@ -417,12 +417,12 @@ error:
return(NULL);
}
-/* Test for existence of a package in a pmlist_t*
+/* Test for existence of a package in a alpm_list_t*
* of pmpkg_t*
*/
-pmpkg_t *_alpm_pkg_isin(char *needle, pmlist_t *haystack)
+pmpkg_t *_alpm_pkg_isin(char *needle, alpm_list_t *haystack)
{
- pmlist_t *lp;
+ alpm_list_t *lp;
if(needle == NULL || haystack == NULL) {
return(NULL);
@@ -668,7 +668,7 @@ unsigned char alpm_pkg_get_reason(pmpkg_t *pkg)
return pkg->reason;
}
-pmlist_t *alpm_pkg_get_licenses(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_licenses(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -680,7 +680,7 @@ pmlist_t *alpm_pkg_get_licenses(pmpkg_t *pkg)
return pkg->license;
}
-pmlist_t *alpm_pkg_get_groups(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_groups(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -693,7 +693,7 @@ pmlist_t *alpm_pkg_get_groups(pmpkg_t *pkg)
}
/* depends */
-pmlist_t *alpm_pkg_get_depends(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_depends(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -705,7 +705,7 @@ pmlist_t *alpm_pkg_get_depends(pmpkg_t *pkg)
return pkg->depends;
}
-pmlist_t *alpm_pkg_get_removes(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_removes(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -717,7 +717,7 @@ pmlist_t *alpm_pkg_get_removes(pmpkg_t *pkg)
return pkg->removes;
}
-pmlist_t *alpm_pkg_get_requiredby(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_requiredby(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -729,7 +729,7 @@ pmlist_t *alpm_pkg_get_requiredby(pmpkg_t *pkg)
return pkg->requiredby;
}
-pmlist_t *alpm_pkg_get_conflicts(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_conflicts(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -741,7 +741,7 @@ pmlist_t *alpm_pkg_get_conflicts(pmpkg_t *pkg)
return pkg->conflicts;
}
-pmlist_t *alpm_pkg_get_provides(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_provides(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -753,7 +753,7 @@ pmlist_t *alpm_pkg_get_provides(pmpkg_t *pkg)
return pkg->provides;
}
-pmlist_t *alpm_pkg_get_replaces(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_replaces(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -765,7 +765,7 @@ pmlist_t *alpm_pkg_get_replaces(pmpkg_t *pkg)
return pkg->replaces;
}
-pmlist_t *alpm_pkg_get_files(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_files(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -778,7 +778,7 @@ pmlist_t *alpm_pkg_get_files(pmpkg_t *pkg)
return pkg->files;
}
-pmlist_t *alpm_pkg_get_backup(pmpkg_t *pkg)
+alpm_list_t *alpm_pkg_get_backup(pmpkg_t *pkg)
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 0b11ae49..616131d5 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -69,17 +69,17 @@ struct __pmpkg_t {
unsigned char force;
time_t date;
unsigned char reason;
- 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;
+ alpm_list_t *desc_localized;
+ alpm_list_t *license;
+ alpm_list_t *replaces;
+ alpm_list_t *groups;
+ alpm_list_t *files;
+ alpm_list_t *backup;
+ alpm_list_t *depends;
+ alpm_list_t *removes;
+ alpm_list_t *requiredby;
+ alpm_list_t *conflicts;
+ alpm_list_t *provides;
/* internal */
unsigned char origin;
void *data;
@@ -94,7 +94,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_t *haystack);
+pmpkg_t *_alpm_pkg_isin(char *needle, alpm_list_t *haystack);
int _alpm_pkg_splitname(char *target, char *name, char *version, int witharch);
diff --git a/lib/libalpm/provide.c b/lib/libalpm/provide.c
index e2d58952..91f827fb 100644
--- a/lib/libalpm/provide.c
+++ b/lib/libalpm/provide.c
@@ -24,16 +24,16 @@
#include <string.h>
/* pacman */
#include "cache.h"
-#include "list.h"
+#include "alpm_list.h"
#include "db.h"
#include "provide.h"
-/* return a pmlist_t of packages in "db" that provide "package"
+/* return a alpm_list_t of packages in "db" that provide "package"
*/
-pmlist_t *_alpm_db_whatprovides(pmdb_t *db, char *package)
+alpm_list_t *_alpm_db_whatprovides(pmdb_t *db, char *package)
{
- pmlist_t *pkgs = NULL;
- pmlist_t *lp;
+ alpm_list_t *pkgs = NULL;
+ alpm_list_t *lp;
if(db == NULL || package == NULL || strlen(package) == 0) {
return(NULL);
@@ -42,8 +42,8 @@ pmlist_t *_alpm_db_whatprovides(pmdb_t *db, char *package)
for(lp = _alpm_db_get_pkgcache(db, INFRQ_DEPENDS); lp; lp = lp->next) {
pmpkg_t *info = lp->data;
- if(_alpm_list_is_strin(package, info->provides)) {
- pkgs = _alpm_list_add(pkgs, info);
+ if(alpm_list_is_strin(package, info->provides)) {
+ pkgs = alpm_list_add(pkgs, info);
}
}
diff --git a/lib/libalpm/provide.h b/lib/libalpm/provide.h
index eb587003..7f249fff 100644
--- a/lib/libalpm/provide.h
+++ b/lib/libalpm/provide.h
@@ -22,10 +22,10 @@
#define _ALPM_PROVIDE_H
#include "db.h"
-#include "list.h"
+#include "alpm_list.h"
#include "config.h"
-pmlist_t *_alpm_db_whatprovides(pmdb_t *db, char *package);
+alpm_list_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 2177a6da..e340dfc3 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -41,7 +41,7 @@
#include <errno.h>
#include <libintl.h>
/* pacman */
-#include "list.h"
+#include "alpm_list.h"
#include "trans.h"
#include "util.h"
#include "error.h"
@@ -78,7 +78,7 @@ int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
}
/* ignore holdpkgs on upgrade */
- if((trans == handle->trans) && _alpm_list_is_strin(info->name, handle->holdpkg)) {
+ if((trans == handle->trans) && alpm_list_is_strin(info->name, handle->holdpkg)) {
int resp = 0;
QUESTION(trans, PM_TRANS_CONV_REMOVE_HOLDPKG, info, NULL, NULL, &resp);
if(!resp) {
@@ -87,14 +87,14 @@ int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
}
_alpm_log(PM_LOG_FLOW2, _("adding %s in the targets list"), info->name);
- trans->packages = _alpm_list_add(trans->packages, info);
+ trans->packages = alpm_list_add(trans->packages, info);
return(0);
}
-int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data)
+int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
{
- pmlist_t *lp;
+ alpm_list_t *lp;
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
@@ -107,13 +107,13 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, pmlist_t **data)
if(lp != NULL) {
if(trans->flags & PM_TRANS_FLAG_CASCADE) {
while(lp) {
- pmlist_t *i;
+ alpm_list_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);
if(info) {
_alpm_log(PM_LOG_FLOW2, _("pulling %s in the targets list"), info->name);
- trans->packages = _alpm_list_add(trans->packages, info);
+ trans->packages = alpm_list_add(trans->packages, info);
} else {
_alpm_log(PM_LOG_ERROR, _("could not find %s in database -- skipping"),
miss->depend.name);
@@ -160,7 +160,7 @@ static int str_cmp(const void *s1, const void *s2)
/* Helper function for iterating through a package's file and deleting them
* Used by _alpm_remove_commit
*/
-static void unlink_file(pmpkg_t *info, pmlist_t *lp, pmlist_t *targ,
+static void unlink_file(pmpkg_t *info, alpm_list_t *lp, alpm_list_t *targ,
pmtrans_t *trans, int filenum, int *position)
{
struct stat buf;
@@ -177,7 +177,7 @@ static void unlink_file(pmpkg_t *info, pmlist_t *lp, pmlist_t *targ,
FREE(checksum);
} if ( !nb && trans->type == PM_TRANS_TYPE_UPGRADE ) {
/* check noupgrade */
- if ( _alpm_list_is_strin(file, handle->noupgrade) ) {
+ if ( alpm_list_is_strin(file, handle->noupgrade) ) {
nb = 1;
}
}
@@ -198,7 +198,7 @@ static void unlink_file(pmpkg_t *info, pmlist_t *lp, pmlist_t *targ,
* see the big comment block in db_find_conflicts() for an
* explanation. */
int skipit = 0;
- pmlist_t *j;
+ alpm_list_t *j;
for ( j = trans->skiplist; j; j = j->next ) {
if ( !strcmp(file, (char*)j->data) ) {
skipit = 1;
@@ -222,8 +222,8 @@ static void unlink_file(pmpkg_t *info, pmlist_t *lp, pmlist_t *targ,
}
} else {
_alpm_log(PM_LOG_FLOW2, _("unlinking %s"), line);
- int list_count = _alpm_list_count(trans->packages); /* this way we don't have to call _alpm_list_count twice during PROGRESS */
- PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, (double)(percent * 100), list_count, (list_count - _alpm_list_count(targ) + 1));
+ int list_count = alpm_list_count(trans->packages); /* this way we don't have to call alpm_list_count twice during PROGRESS */
+ PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, (double)(percent * 100), list_count, (list_count - alpm_list_count(targ) + 1));
++(*position);
}
if (unlink(line) == -1) {
@@ -236,7 +236,7 @@ static void unlink_file(pmpkg_t *info, pmlist_t *lp, pmlist_t *targ,
int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
{
pmpkg_t *info;
- pmlist_t *targ, *lp;
+ alpm_list_t *targ, *lp;
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
@@ -262,11 +262,11 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
}
if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) {
- int filenum = _alpm_list_count(info->files);
+ int filenum = alpm_list_count(info->files);
_alpm_log(PM_LOG_FLOW1, _("removing files"));
/* iterate through the list backwards, unlinking files */
- for(lp = _alpm_list_last(info->files); lp; lp = lp->prev) {
+ for(lp = alpm_list_last(info->files); lp; lp = lp->prev) {
unlink_file(info, lp, targ, trans, filenum, &position);
}
}
@@ -309,7 +309,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_t *provides = _alpm_db_whatprovides(db, depend.name);
+ alpm_list_t *provides = _alpm_db_whatprovides(db, depend.name);
if(provides) {
/* TODO: should check _all_ packages listed in provides, not just
* the first one.
@@ -327,7 +327,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
/* Ensure package has the appropriate data */
_alpm_db_read(db, INFRQ_DEPENDS, depinfo);
/* splice out this entry from requiredby */
- depinfo->requiredby = _alpm_list_remove(depinfo->requiredby, info->name, str_cmp, &vdata);
+ depinfo->requiredby = alpm_list_remove(depinfo->requiredby, info->name, str_cmp, &vdata);
data = vdata;
FREE(data);
_alpm_log(PM_LOG_DEBUG, _("updating 'requiredby' field for package '%s'"), depinfo->name);
@@ -337,7 +337,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
}
}
- PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, 100, _alpm_list_count(trans->packages), (_alpm_list_count(trans->packages) - _alpm_list_count(targ) +1));
+ PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, 100, alpm_list_count(trans->packages), (alpm_list_count(trans->packages) - alpm_list_count(targ) +1));
if(trans->type != PM_TRANS_TYPE_UPGRADE) {
EVENT(trans, PM_TRANS_EVT_REMOVE_DONE, info, NULL);
}
diff --git a/lib/libalpm/remove.h b/lib/libalpm/remove.h
index 524e5faa..5ceba3b2 100644
--- a/lib/libalpm/remove.h
+++ b/lib/libalpm/remove.h
@@ -22,11 +22,11 @@
#define _ALPM_REMOVE_H
#include "db.h"
-#include "list.h"
+#include "alpm_list.h"
#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_t **data);
+int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_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 c37d8a12..6a6658f1 100644
--- a/lib/libalpm/server.c
+++ b/lib/libalpm/server.c
@@ -94,7 +94,7 @@ void _alpm_server_free(void *data)
*
* RETURN: 0 for successful download, 1 on error
*/
-int _alpm_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t *files)
+int _alpm_downloadfiles(alpm_list_t *servers, const char *localpath, alpm_list_t *files)
{
return(_alpm_downloadfiles_forreal(servers, localpath, files, NULL, NULL));
}
@@ -112,14 +112,14 @@ int _alpm_downloadfiles(pmlist_t *servers, const char *localpath, pmlist_t *file
* 1 if the mtimes are identical
* -1 on error
*/
-int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
- pmlist_t *files, const char *mtime1, char *mtime2)
+int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
+ alpm_list_t *files, const char *mtime1, char *mtime2)
{
int dltotal_bytes = 0;
- pmlist_t *lp;
+ alpm_list_t *lp;
int done = 0;
- pmlist_t *complete = NULL;
- pmlist_t *i;
+ alpm_list_t *complete = NULL;
+ alpm_list_t *i;
if(files == NULL) {
return(0);
@@ -137,7 +137,7 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
snprintf(realfile, PATH_MAX, "%s/%s", localpath, fn);
snprintf(output, PATH_MAX, "%s/%s.part", localpath, fn);
- if(_alpm_list_is_strin(fn, complete)) {
+ if(alpm_list_is_strin(fn, complete)) {
continue;
}
@@ -196,7 +196,7 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
_alpm_time2string(ust.mtime, strtime);
if(strcmp(mtime1, strtime) == 0) {
_alpm_log(PM_LOG_DEBUG, _("mtimes are identical, skipping %s"), fn);
- complete = _alpm_list_add(complete, fn);
+ complete = alpm_list_add(complete, fn);
if(localf != NULL) {
fclose(localf);
}
@@ -246,7 +246,7 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
fclose(localf);
fclose(dlf);
rename(output, realfile);
- complete = _alpm_list_add(complete, fn);
+ complete = alpm_list_add(complete, fn);
} else {
int ret;
int usepart = 0;
@@ -298,7 +298,7 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
_alpm_log(PM_LOG_DEBUG, _("XferCommand command returned non-zero status code (%d)"), ret);
} else {
/* download was successful */
- complete = _alpm_list_add(complete, fn);
+ complete = alpm_list_add(complete, fn);
if(usepart) {
char fnpart[PATH_MAX];
/* rename "output.part" file to "output" file */
@@ -310,7 +310,7 @@ int _alpm_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
}
}
- if(_alpm_list_count(complete) == _alpm_list_count(files)) {
+ if(alpm_list_count(complete) == alpm_list_count(files)) {
done = 1;
}
}
@@ -344,8 +344,8 @@ char *_alpm_fetch_pkgurl(char *target)
_alpm_log(PM_LOG_DEBUG, _(" %s is already in the current directory"), s_url->doc);
} else {
pmserver_t *server;
- pmlist_t *servers = NULL;
- pmlist_t *files;
+ alpm_list_t *servers = NULL;
+ alpm_list_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));
@@ -357,9 +357,9 @@ char *_alpm_fetch_pkgurl(char *target)
server->s_url = s_url;
server->path = strdup(s_url->doc);
- servers = _alpm_list_add(servers, server);
+ servers = alpm_list_add(servers, server);
- files = _alpm_list_add(NULL, strdup(p));
+ files = alpm_list_add(NULL, strdup(p));
if(_alpm_downloadfiles(servers, ".", files)) {
_alpm_log(PM_LOG_WARNING, _("failed to download %s"), target);
return(NULL);
diff --git a/lib/libalpm/server.h b/lib/libalpm/server.h
index 80e9a7e1..63dd62ea 100644
--- a/lib/libalpm/server.h
+++ b/lib/libalpm/server.h
@@ -21,7 +21,7 @@
#ifndef _ALPM_SERVER_H
#define _ALPM_SERVER_H
-#include "list.h"
+#include "alpm_list.h"
#include "alpm.h"
#include <time.h>
@@ -40,9 +40,9 @@ struct __pmserver_t {
pmserver_t *_alpm_server_new(const char *url);
void _alpm_server_free(void *data);
-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);
+int _alpm_downloadfiles(alpm_list_t *servers, const char *localpath, alpm_list_t *files);
+int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
+ alpm_list_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 453347d7..a4f527ed 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -36,7 +36,7 @@
/* pacman */
#include "log.h"
#include "error.h"
-#include "list.h"
+#include "alpm_list.h"
#include "package.h"
#include "db.h"
#include "cache.h"
@@ -87,12 +87,12 @@ void _alpm_sync_free(void *data)
FREE(sync);
}
-/* Test for existence of a package in a pmlist_t* of pmsyncpkg_t*
+/* Test for existence of a package in a alpm_list_t* of pmsyncpkg_t*
* If found, return a pointer to the respective pmsyncpkg_t*
*/
-static pmsyncpkg_t *find_pkginsync(char *needle, pmlist_t *haystack)
+static pmsyncpkg_t *find_pkginsync(char *needle, alpm_list_t *haystack)
{
- pmlist_t *i;
+ alpm_list_t *i;
pmsyncpkg_t *sync = NULL;
int found = 0;
@@ -122,9 +122,9 @@ static int istoonew(pmpkg_t *pkg)
* (refactored from _alpm_sync_prepare)
*/
static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
- pmlist_t *dbs_sync)
+ alpm_list_t *dbs_sync)
{
- pmlist_t *i, *j, *k;
+ alpm_list_t *i, *j, *k;
/* check for "recommended" package replacements */
_alpm_log(PM_LOG_FLOW1, _("checking for package replacements"));
@@ -132,12 +132,12 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
for(j = _alpm_db_get_pkgcache(i->data, INFRQ_DESC); j; j = j->next) {
pmpkg_t *spkg = j->data;
for(k = spkg->replaces; k; k = k->next) {
- pmlist_t *m;
+ alpm_list_t *m;
for(m = _alpm_db_get_pkgcache(db_local, INFRQ_NONE); m; m = m->next) {
pmpkg_t *lpkg = m->data;
if(strcmp(k->data, lpkg->name) == 0) {
_alpm_log(PM_LOG_DEBUG, _("checking replacement '%s' for package '%s'"), k->data, spkg->name);
- if(_alpm_list_is_strin(lpkg->name, handle->ignorepkg)) {
+ if(alpm_list_is_strin(lpkg->name, handle->ignorepkg)) {
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (to be replaced by %s-%s)"),
lpkg->name, lpkg->version, spkg->name, spkg->version);
} else {
@@ -155,12 +155,12 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
pm_errno = PM_ERR_MEMORY;
goto error;
}
- dummy->requiredby = _alpm_list_strdup(lpkg->requiredby);
+ dummy->requiredby = alpm_list_strdup(lpkg->requiredby);
/* check if spkg->name is already in the packages list. */
sync = find_pkginsync(spkg->name, trans->packages);
if(sync) {
/* found it -- just append to the replaces list */
- sync->data = _alpm_list_add(sync->data, dummy);
+ sync->data = alpm_list_add(sync->data, dummy);
} else {
/* none found -- enter pkg into the final sync list */
sync = _alpm_sync_new(PM_SYNC_TYPE_REPLACE, spkg, NULL);
@@ -169,8 +169,8 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
pm_errno = PM_ERR_MEMORY;
goto error;
}
- sync->data = _alpm_list_add(NULL, dummy);
- trans->packages = _alpm_list_add(trans->packages, sync);
+ sync->data = alpm_list_add(NULL, dummy);
+ trans->packages = alpm_list_add(trans->packages, sync);
}
_alpm_log(PM_LOG_FLOW2, _("%s-%s elected for upgrade (to be replaced by %s-%s)"),
lpkg->name, lpkg->version, spkg->name, spkg->version);
@@ -187,9 +187,9 @@ error:
return(-1);
}
-int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync)
+int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync)
{
- pmlist_t *i, *j;
+ alpm_list_t *i, *j;
/* check for "recommended" package replacements */
_alpm_log(PM_LOG_FLOW1, _("checking for package replacements"));
@@ -235,7 +235,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync
local->name, local->version, db->treename, spkg->version);
} else if(cmp == 0) {
/* versions are identical */
- } else if(_alpm_list_is_strin(spkg->name, handle->ignorepkg)) {
+ } else if(alpm_list_is_strin(spkg->name, handle->ignorepkg)) {
/* package should be ignored (IgnorePkg) */
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"),
local->name, local->version, spkg->version);
@@ -257,7 +257,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync
FREEPKG(dummy);
goto error;
}
- trans->packages = _alpm_list_add(trans->packages, sync);
+ trans->packages = alpm_list_add(trans->packages, sync);
} else {
/* spkg->name is already in the packages list -- just ignore it */
}
@@ -271,11 +271,11 @@ error:
return(-1);
}
-int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, char *name)
+int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, char *name)
{
char targline[PKG_FULLNAME_LEN];
char *targ;
- pmlist_t *j;
+ alpm_list_t *j;
pmpkg_t *local;
pmpkg_t *spkg = NULL;
pmsyncpkg_t *sync;
@@ -298,7 +298,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync,
spkg = _alpm_db_get_pkgfromcache(dbs, targ);
if(spkg == NULL) {
/* Search provides */
- pmlist_t *p;
+ alpm_list_t *p;
_alpm_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ);
p = _alpm_db_whatprovides(dbs, targ);
if(p == NULL) {
@@ -325,7 +325,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync,
_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_t *p = _alpm_db_whatprovides(dbs, targ);
+ alpm_list_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);
@@ -375,13 +375,13 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync,
RET_ERR(PM_ERR_MEMORY, -1);
}
_alpm_log(PM_LOG_FLOW2, _("adding target '%s' to the transaction set"), spkg->name);
- trans->packages = _alpm_list_add(trans->packages, sync);
+ trans->packages = alpm_list_add(trans->packages, sync);
}
return(0);
}
-/* Helper functions for _alpm_list_remove
+/* Helper functions for alpm_list_remove
*/
/* removed - use pkg_cmp all of the time
static int ptr_cmp(const void *s1, const void *s2)
@@ -394,13 +394,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_t *dbs_sync, pmlist_t **data)
+int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data)
{
- pmlist_t *deps = NULL;
- pmlist_t *list = NULL; /* list allowing checkdeps usage with data from trans->packages */
- pmlist_t *trail = NULL; /* breadcrumb list to avoid running into circles */
- pmlist_t *asked = NULL;
- pmlist_t *i, *j, *k, *l;
+ alpm_list_t *deps = NULL;
+ alpm_list_t *list = NULL; /* list allowing checkdeps usage with data from trans->packages */
+ alpm_list_t *trail = NULL; /* breadcrumb list to avoid running into circles */
+ alpm_list_t *asked = NULL;
+ alpm_list_t *i, *j, *k, *l;
int ret = 0;
ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
@@ -412,11 +412,11 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
- list = _alpm_list_add(list, sync->pkg);
+ list = alpm_list_add(list, sync->pkg);
}
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
- trail = _alpm_list_new();
+ trail = alpm_list_new();
/* Resolve targets dependencies */
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
@@ -439,7 +439,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
ret = -1;
goto cleanup;
}
- trans->packages = _alpm_list_add(trans->packages, sync);
+ trans->packages = alpm_list_add(trans->packages, sync);
_alpm_log(PM_LOG_FLOW2, _("adding package %s-%s to the transaction targets"),
spkg->name, spkg->version);
} else {
@@ -447,7 +447,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
if((trans->flags & PM_TRANS_FLAG_DEPENDSONLY)) {
void *vp;
pmpkg_t *p;
- trans->packages = _alpm_list_remove(trans->packages, spkg, pkg_cmp, &vp);
+ trans->packages = alpm_list_remove(trans->packages, spkg, pkg_cmp, &vp);
p = vp;
FREEPKG(p);
}
@@ -458,14 +458,14 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
k = l = NULL;
for(i=trans->packages; i; i=i->next) {
pmsyncpkg_t *s = (pmsyncpkg_t*)i->data;
- k = _alpm_list_add(k, s->pkg);
+ k = alpm_list_add(k, s->pkg);
}
k = _alpm_sortbydeps(k, PM_TRANS_TYPE_ADD);
for(i=k; i; i=i->next) {
for(j=trans->packages; j; j=j->next) {
pmsyncpkg_t *s = (pmsyncpkg_t*)j->data;
if(s->pkg==i->data) {
- l = _alpm_list_add(l, s);
+ l = alpm_list_add(l, s);
}
}
}
@@ -535,7 +535,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
local = _alpm_db_get_pkgfromcache(db_local, miss->depend.name);
/* check if this package also "provides" the package it's conflicting with
*/
- if(_alpm_list_is_strin(miss->depend.name, sync->pkg->provides)) {
+ if(alpm_list_is_strin(miss->depend.name, sync->pkg->provides)) {
/* so just treat it like a "replaces" item so the REQUIREDBY
* fields are inherited properly.
*/
@@ -559,8 +559,8 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
/* figure out which one was requested in targets. If they both were,
* then it's still an unresolvable conflict. */
- target = _alpm_list_is_strin(miss->target, trans->targets);
- depend = _alpm_list_is_strin(miss->depend.name, trans->targets);
+ target = alpm_list_is_strin(miss->target, trans->targets);
+ depend = alpm_list_is_strin(miss->depend.name, trans->targets);
if(depend && !target) {
_alpm_log(PM_LOG_DEBUG, _("'%s' is in the target list -- keeping it"),
miss->depend.name);
@@ -580,7 +580,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
pmsyncpkg_t *rsync = find_pkginsync(rmpkg, trans->packages);
void *vpkg;
_alpm_log(PM_LOG_FLOW2, _("removing '%s' from target list"), rmpkg);
- trans->packages = _alpm_list_remove(trans->packages, rsync, pkg_cmp, &vpkg);
+ trans->packages = alpm_list_remove(trans->packages, rsync, pkg_cmp, &vpkg);
FREESYNC(vpkg);
continue;
}
@@ -591,9 +591,9 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
_alpm_log(PM_LOG_DEBUG, _("resolving package '%s' conflict"), miss->target);
if(local) {
int doremove = 0;
- if(!_alpm_list_is_strin(miss->depend.name, asked)) {
+ if(!alpm_list_is_strin(miss->depend.name, asked)) {
QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &doremove);
- asked = _alpm_list_add(asked, strdup(miss->depend.name));
+ asked = alpm_list_add(asked, strdup(miss->depend.name));
if(doremove) {
pmsyncpkg_t *rsync = find_pkginsync(miss->depend.name, trans->packages);
pmpkg_t *q = _alpm_pkg_new(miss->depend.name, NULL);
@@ -604,7 +604,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
ret = -1;
goto cleanup;
}
- q->requiredby = _alpm_list_strdup(local->requiredby);
+ q->requiredby = alpm_list_strdup(local->requiredby);
if(sync->type != PM_SYNC_TYPE_REPLACE) {
/* switch this sync type to REPLACE */
sync->type = PM_SYNC_TYPE_REPLACE;
@@ -612,12 +612,12 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
}
/* append to the replaces list */
_alpm_log(PM_LOG_FLOW2, _("electing '%s' for removal"), miss->depend.name);
- sync->data = _alpm_list_add(sync->data, q);
+ sync->data = alpm_list_add(sync->data, q);
if(rsync) {
/* remove it from the target list */
void *vpkg;
_alpm_log(PM_LOG_FLOW2, _("removing '%s' from target list"), miss->depend.name);
- trans->packages = _alpm_list_remove(trans->packages, rsync, pkg_cmp, &vpkg);
+ trans->packages = alpm_list_remove(trans->packages, rsync, pkg_cmp, &vpkg);
FREESYNC(vpkg);
}
} else {
@@ -633,7 +633,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
goto cleanup;
}
*miss = *(pmdepmissing_t *)i->data;
- *data = _alpm_list_add(*data, miss);
+ *data = alpm_list_add(*data, miss);
}
}
}
@@ -649,7 +649,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
goto cleanup;
}
*miss = *(pmdepmissing_t *)i->data;
- *data = _alpm_list_add(*data, miss);
+ *data = alpm_list_add(*data, miss);
}
}
}
@@ -685,7 +685,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
pmsyncpkg_t *sync = i->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) {
for(j = sync->data; j; j = j->next) {
- list = _alpm_list_add(list, j->data);
+ list = alpm_list_add(list, j->data);
}
}
}
@@ -698,7 +698,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
pmdepmissing_t *miss = i->data;
if(!find_pkginsync(miss->depend.name, trans->packages)) {
int pfound = 0;
- pmlist_t *k;
+ alpm_list_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);
@@ -711,13 +711,13 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
/* 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_t *m;
+ alpm_list_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_t *n, *o;
+ alpm_list_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) {
@@ -745,7 +745,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, p
goto cleanup;
}
*miss = *(pmdepmissing_t *)i->data;
- *data = _alpm_list_add(*data, miss);
+ *data = alpm_list_add(*data, miss);
}
}
}
@@ -780,9 +780,9 @@ cleanup:
return(ret);
}
-int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data)
+int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
{
- pmlist_t *i, *j, *files = NULL;
+ alpm_list_t *i, *j, *files = NULL;
pmtrans_t *tr = NULL;
int replaces = 0, retval = 0;
char ldir[PATH_MAX];
@@ -815,7 +815,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data)
snprintf(path, PATH_MAX, "%s/%s", ldir, fname);
if(stat(path, &buf)) {
/* file is not in the cache dir, so add it to the list */
- files = _alpm_list_add(files, strdup(fname));
+ files = alpm_list_add(files, strdup(fname));
} else {
_alpm_log(PM_LOG_DEBUG, _("%s is already in the cache\n"), fname);
}
@@ -872,7 +872,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data)
RET_ERR(PM_ERR_MEMORY, -1);
}
snprintf(ptr, 512, _("can't get md5 or sha1 checksum for package %s\n"), pkgname);
- *data = _alpm_list_add(*data, ptr);
+ *data = alpm_list_add(*data, ptr);
retval = 1;
continue;
}
@@ -884,7 +884,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data)
RET_ERR(PM_ERR_MEMORY, -1);
}
snprintf(ptr, 512, _("can't get md5 or sha1 checksum for package %s\n"), pkgname);
- *data = _alpm_list_add(*data, ptr);
+ *data = alpm_list_add(*data, ptr);
retval = 1;
continue;
}
@@ -906,7 +906,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data)
} else {
snprintf(ptr, 512, _("archive %s is corrupted (bad MD5 or SHA1 checksum)\n"), pkgname);
}
- *data = _alpm_list_add(*data, ptr);
+ *data = alpm_list_add(*data, ptr);
retval = 1;
}
FREE(md5sum2);
@@ -938,7 +938,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data)
for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) {
- pmlist_t *j;
+ alpm_list_t *j;
for(j = sync->data; j; j = j->next) {
pmpkg_t *pkg = j->data;
if(!_alpm_pkg_isin(pkg->name, tr->packages)) {
@@ -989,9 +989,9 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data)
if(_alpm_trans_addtarget(tr, str) == -1) {
goto error;
}
- /* using _alpm_list_last() is ok because addtarget() adds the new target at the
+ /* using alpm_list_last() is ok because addtarget() adds the new target at the
* end of the tr->packages list */
- spkg = _alpm_list_last(tr->packages)->data;
+ spkg = alpm_list_last(tr->packages)->data;
if(sync->type == PM_SYNC_TYPE_DEPEND) {
spkg->reason = PM_PKG_REASON_DEPEND;
}
@@ -1013,16 +1013,16 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data)
for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) {
- pmlist_t *j;
+ alpm_list_t *j;
pmpkg_t *new = _alpm_db_get_pkgfromcache(db_local, sync->pkg->name);
for(j = sync->data; j; j = j->next) {
- pmlist_t *k;
+ alpm_list_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)) {
+ if(!alpm_list_is_strin(k->data, new->requiredby)) {
/* replace old's name with new's name in the requiredby's dependency list */
- pmlist_t *m;
+ alpm_list_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,
@@ -1042,7 +1042,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, pmlist_t **data)
new->name, new->version);
}
/* add the new requiredby */
- new->requiredby = _alpm_list_add(new->requiredby, strdup(k->data));
+ new->requiredby = alpm_list_add(new->requiredby, strdup(k->data));
}
}
}
diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h
index f3d5ec02..c01afd64 100644
--- a/lib/libalpm/sync.h
+++ b/lib/libalpm/sync.h
@@ -37,10 +37,10 @@ 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_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);
+int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync);
+int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, char *name);
+int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data);
+int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data);
#endif /* _ALPM_SYNC_H */
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 8def650f..20425b63 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -32,7 +32,7 @@
#include "package.h"
#include "util.h"
#include "log.h"
-#include "list.h"
+#include "alpm_list.h"
#include "handle.h"
#include "add.h"
#include "remove.h"
@@ -71,7 +71,7 @@ void _alpm_trans_free(void *data)
FREELIST(trans->targets);
if(trans->type == PM_TRANS_TYPE_SYNC) {
- pmlist_t *i;
+ alpm_list_t *i;
for(i = trans->packages; i; i = i->next) {
FREESYNC(i->data);
}
@@ -114,7 +114,7 @@ int _alpm_trans_addtarget(pmtrans_t *trans, char *target)
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(target != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
- if(_alpm_list_is_strin(target, trans->targets)) {
+ if(alpm_list_is_strin(target, trans->targets)) {
RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1);
}
@@ -140,12 +140,12 @@ int _alpm_trans_addtarget(pmtrans_t *trans, char *target)
break;
}
- trans->targets = _alpm_list_add(trans->targets, strdup(target));
+ trans->targets = alpm_list_add(trans->targets, strdup(target));
return(0);
}
-int _alpm_trans_prepare(pmtrans_t *trans, pmlist_t **data)
+int _alpm_trans_prepare(pmtrans_t *trans, alpm_list_t **data)
{
*data = NULL;
@@ -184,7 +184,7 @@ int _alpm_trans_prepare(pmtrans_t *trans, pmlist_t **data)
return(0);
}
-int _alpm_trans_commit(pmtrans_t *trans, pmlist_t **data)
+int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data)
{
if(data!=NULL)
*data = NULL;
@@ -244,7 +244,7 @@ unsigned int alpm_trans_get_flags()
return handle->trans->flags;
}
-pmlist_t * alpm_trans_get_targets()
+alpm_list_t * alpm_trans_get_targets()
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -253,7 +253,7 @@ pmlist_t * alpm_trans_get_targets()
return handle->trans->targets;
}
-pmlist_t * alpm_trans_get_packages()
+alpm_list_t * alpm_trans_get_packages()
{
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h
index 49bcceb3..2fcec2ed 100644
--- a/lib/libalpm/trans.h
+++ b/lib/libalpm/trans.h
@@ -31,9 +31,9 @@ struct __pmtrans_t {
unsigned char type;
unsigned int flags;
unsigned char state;
- 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_list_t *targets; /* alpm_list_t of (char *) */
+ alpm_list_t *packages; /* alpm_list_t of (pmpkg_t *) or (pmsyncpkg_t *) */
+ alpm_list_t *skiplist; /* alpm_list_t of (char *) */
alpm_trans_cb_event cb_event;
alpm_trans_cb_conv cb_conv;
alpm_trans_cb_progress cb_progress;
@@ -80,8 +80,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_t **data);
-int _alpm_trans_commit(pmtrans_t *trans, pmlist_t **data);
+int _alpm_trans_prepare(pmtrans_t *trans, alpm_list_t **data);
+int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data);
#endif /* _ALPM_TRANS_H */
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 074d16f1..ad7bf8ee 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -55,8 +55,8 @@
#endif
/* pacman */
+#include "alpm_list.h"
#include "log.h"
-#include "list.h"
#include "trans.h"
#include "sync.h"
#include "util.h"
@@ -563,9 +563,9 @@ static long long get_freespace()
return(ret);
}
-int _alpm_check_freespace(pmtrans_t *trans, pmlist_t **data)
+int _alpm_check_freespace(pmtrans_t *trans, alpm_list_t **data)
{
- pmlist_t *i;
+ alpm_list_t *i;
long long pkgsize=0, freespace;
for(i = trans->packages; i; i = i->next) {
@@ -594,7 +594,7 @@ int _alpm_check_freespace(pmtrans_t *trans, pmlist_t **data)
return(-1);
}
*ptr = pkgsize;
- *data = _alpm_list_add(*data, ptr);
+ *data = alpm_list_add(*data, ptr);
if((ptr = (long long*)malloc(sizeof(long long)))==NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(long long));
FREELIST(*data);
@@ -602,7 +602,7 @@ int _alpm_check_freespace(pmtrans_t *trans, pmlist_t **data)
return(-1);
}
*ptr = freespace;
- *data = _alpm_list_add(*data, ptr);
+ *data = alpm_list_add(*data, ptr);
}
pm_errno = PM_ERR_DISK_FULL;
return(-1);
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 73e1c14e..378233d2 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_t **data);
+int _alpm_check_freespace(pmtrans_t *trans, alpm_list_t **data);
#endif
#endif
void _alpm_time2string(time_t t, char *buffer);
diff --git a/lib/libalpm/versioncmp.c b/lib/libalpm/versioncmp.c
index 4e31ca51..045f2a24 100644
--- a/lib/libalpm/versioncmp.c
+++ b/lib/libalpm/versioncmp.c
@@ -31,7 +31,7 @@
#include "alpm.h"
#include "log.h"
#include "util.h"
-#include "list.h"
+#include "alpm_list.h"
#include "versioncmp.h"
#ifndef HAVE_STRVERSCMP
@@ -247,7 +247,7 @@ int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep)
{
int equal = 0;
- if(strcmp(pkg->name, dep->name) == 0 || _alpm_list_is_strin(dep->name, pkg->provides)) {
+ if(strcmp(pkg->name, dep->name) == 0 || alpm_list_is_strin(dep->name, pkg->provides)) {
if(dep->mod == PM_DEP_MOD_ANY) {
equal = 1;
} else {
diff --git a/src/pacman/Makefile.am b/src/pacman/Makefile.am
index d637dc2d..0de2383e 100644
--- a/src/pacman/Makefile.am
+++ b/src/pacman/Makefile.am
@@ -11,7 +11,7 @@ DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
AM_CFLAGS = -D_GNU_SOURCE -I$(top_srcdir)/lib/libalpm $(CFLAGS)
-pacman_SOURCES = util.c log.c list.c package.c downloadprog.c trans.c add.c \
+pacman_SOURCES = util.c log.c package.c downloadprog.c trans.c add.c \
remove.c upgrade.c query.c sync.c conf.c deptest.c pacman.c
pacman_static_SOURCES = $(pacman_SOURCES)
diff --git a/src/pacman/add.c b/src/pacman/add.c
index 7a7cb80c..6a23531d 100644
--- a/src/pacman/add.c
+++ b/src/pacman/add.c
@@ -25,9 +25,9 @@
#include <libintl.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
#include "log.h"
-#include "list.h"
#include "downloadprog.h"
#include "trans.h"
#include "add.h"
@@ -36,10 +36,9 @@
extern config_t *config;
-int pacman_add(list_t *targets)
+int pacman_add(alpm_list_t *targets)
{
- pmlist_t *data;
- list_t *i;
+ alpm_list_t *i = targets, *data;
int retval = 0;
if(targets == NULL) {
@@ -48,7 +47,7 @@ int pacman_add(list_t *targets)
/* Check for URL targets and process them
*/
- for(i = targets; i; i = i->next) {
+ while(i) {
if(strstr(i->data, "://")) {
char *str = alpm_fetch_pkgurl(i->data);
if(str == NULL) {
@@ -58,6 +57,7 @@ int pacman_add(list_t *targets)
i->data = str;
}
}
+ i = i->next;
}
/* Step 1: create a new transaction
@@ -67,7 +67,7 @@ int pacman_add(list_t *targets)
ERR(NL, "%s\n", alpm_strerror(pm_errno));
if(pm_errno == PM_ERR_HANDLE_LOCK) {
MSG(NL, _(" if you're sure a package manager is not already running,\n"
- " you can remove %s%s\n"), config->root, PM_LOCK);
+ " you can remove %s%s\n"), config->root, PM_LOCK);
}
return(1);
}
@@ -87,12 +87,11 @@ int pacman_add(list_t *targets)
*/
if(alpm_trans_prepare(&data) == -1) {
long long *pkgsize, *freespace;
- pmlist_t *i;
ERR(NL, _("failed to prepare transaction (%s)\n"), alpm_strerror(pm_errno));
switch(pm_errno) {
case PM_ERR_UNSATISFIED_DEPS:
- for(i = alpm_list_first(data); i; i = alpm_list_next(i)) {
+ for(i = data; i; i = alpm_list_next(i)) {
pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, _(":: %s: requires %s"), alpm_dep_get_target(miss),
alpm_dep_get_name(miss));
@@ -105,14 +104,14 @@ int pacman_add(list_t *targets)
}
break;
case PM_ERR_CONFLICTING_DEPS:
- for(i = alpm_list_first(data); i; i = alpm_list_next(i)) {
+ for(i = data; i; i = alpm_list_next(i)) {
pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, _(":: %s: conflicts with %s"),
alpm_dep_get_target(miss), alpm_dep_get_name(miss));
}
break;
case PM_ERR_FILE_CONFLICTS:
- for(i = alpm_list_first(data); i; i = alpm_list_next(i)) {
+ for(i = data; i; i = alpm_list_next(i)) {
pmconflict_t *conflict = alpm_list_getdata(i);
switch(alpm_conflict_get_type(conflict)) {
case PM_CONFLICT_TYPE_TARGET:
@@ -132,13 +131,16 @@ int pacman_add(list_t *targets)
}
MSG(NL, _("\nerrors occurred, no packages were upgraded.\n"));
break;
+ /* TODO This is gross... we should not return these values in the same list we
+ * would get conflicts and such with... it's just silly
+ */
case PM_ERR_DISK_FULL:
- i = alpm_list_first(data);
+ i = data;
pkgsize = alpm_list_getdata(i);
i = alpm_list_next(i);
freespace = alpm_list_getdata(i);
MSG(NL, _(":: %.1f MB required, have %.1f MB"),
- (double)(*pkgsize / 1048576.0), (double)(*freespace / 1048576.0));
+ (double)(*pkgsize / (1024.0*1024.0)), (double)(*freespace / (1024.0*1024.0)));
break;
default:
break;
@@ -157,8 +159,7 @@ int pacman_add(list_t *targets)
cleanup:
if(data) {
- alpm_list_free(data);
- data = NULL;
+ alpm_list_free(data, NULL);
}
if(alpm_trans_release() == -1) {
ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno));
diff --git a/src/pacman/add.h b/src/pacman/add.h
index 4795ca7b..cdcadc0e 100644
--- a/src/pacman/add.h
+++ b/src/pacman/add.h
@@ -21,7 +21,9 @@
#ifndef _PM_ADD_H
#define _PM_ADD_H
-int pacman_add(list_t *targets);
+#include <alpm.h>
+
+int pacman_add(alpm_list_t *targets);
#endif /* _PM_ADD_H */
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index a429690e..185372e0 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -26,16 +26,14 @@
#include <libintl.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
#include "util.h"
#include "log.h"
-#include "list.h"
#include "sync.h"
#include "downloadprog.h"
#include "conf.h"
-extern list_t *pmc_syncs;
-
config_t *config_new()
{
config_t *config;
@@ -61,14 +59,4 @@ int config_free(config_t *config)
return(0);
}
-void cb_db_register(char *section, pmdb_t *db)
-{
- sync_t *sync;
-
- MALLOC(sync, sizeof(sync_t));
- sync->treename = strdup(section);
- sync->db = db;
- pmc_syncs = list_add(pmc_syncs, sync);
-}
-
/* vim: set ts=2 sw=2 noet: */
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index a4bac015..65e0f23e 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -21,6 +21,8 @@
#ifndef _PM_CONF_H
#define _PM_CONF_H
+#include <alpm.h>
+
typedef struct __config_t {
/* command line options */
char *root;
@@ -47,7 +49,7 @@ typedef struct __config_t {
unsigned short op_s_clean;
unsigned short op_s_dependsonly;
unsigned short op_s_downloadonly;
- list_t *op_s_ignore;
+ alpm_list_t *op_s_ignore;
unsigned short op_s_info;
unsigned short op_s_sync;
unsigned short op_s_search;
@@ -63,7 +65,6 @@ typedef struct __config_t {
config_t *config_new(void);
int config_free(config_t *config);
-void cb_db_register(char *section, pmdb_t *db);
#endif /* _PM_CONF_H */
diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c
index faa9ebda..e5306579 100644
--- a/src/pacman/deptest.c
+++ b/src/pacman/deptest.c
@@ -26,9 +26,9 @@
#include <string.h>
#include <libintl.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
#include "util.h"
-#include "list.h"
#include "conf.h"
#include "log.h"
#include "sync.h"
@@ -36,10 +36,12 @@
extern config_t *config;
-int pacman_deptest(list_t *targets)
+/* TODO this function is fairly messy, with the obscure return codes and the odd
+ * 'dummy' packages and all these messy FREELISTs of synctargs
+ */
+int pacman_deptest(alpm_list_t *targets)
{
- pmlist_t *data;
- list_t *i;
+ alpm_list_t *data, *i;
char *str;
int retval = 0;
@@ -48,8 +50,11 @@ int pacman_deptest(list_t *targets)
}
if(config->op_d_vertest) {
- if(targets->data && targets->next && targets->next->data) {
- int ret = alpm_pkg_vercmp(targets->data, targets->next->data);
+ const char *pkga, *pkgb;
+ pkga = alpm_list_getdata(targets);
+ i = alpm_list_next(targets);
+ if(pkga && i && (pkgb = alpm_list_getdata(i))) {
+ int ret = alpm_pkg_vercmp(pkga, pkgb);
printf("%d\n", ret);
return(ret);
}
@@ -79,10 +84,11 @@ int pacman_deptest(list_t *targets)
goto cleanup;
}
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);
+ for(i = targets; i; i = alpm_list_next(i)) {
+ const char *targ = alpm_list_getdata(i);
+ str = (char *)realloc(str, strlen(str)+8+strlen(targ)+1);
strcat(str, "|depend=");
- strcat(str, i->data);
+ strcat(str, targ);
}
vprint(_("add target %s\n"), str);
if(alpm_trans_addtarget(str) == -1) {
@@ -94,8 +100,7 @@ int pacman_deptest(list_t *targets)
FREE(str);
if(alpm_trans_prepare(&data) == -1) {
- pmlist_t *lp;
- list_t *synctargs = NULL;
+ alpm_list_t *synctargs = NULL;
retval = 126;
/* return 126 = deps were missing, but successfully resolved
* return 127 = deps were missing, and failed to resolve; OR
@@ -104,8 +109,8 @@ int pacman_deptest(list_t *targets)
*/
switch(pm_errno) {
case PM_ERR_UNSATISFIED_DEPS:
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmdepmissing_t *miss = alpm_list_getdata(lp);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmdepmissing_t *miss = alpm_list_getdata(i);
if(!config->op_d_resolve) {
MSG(NL, _("requires: %s"), alpm_dep_get_name(miss));
switch(alpm_dep_get_mod(miss)) {
@@ -115,18 +120,18 @@ int pacman_deptest(list_t *targets)
}
MSG(CL, "\n");
}
- synctargs = list_add(synctargs, strdup(alpm_dep_get_name(miss)));
+ synctargs = alpm_list_add(synctargs, strdup(alpm_dep_get_name(miss)));
}
- alpm_list_free(data);
+ alpm_list_free(data, NULL);
break;
case PM_ERR_CONFLICTING_DEPS:
/* we can't auto-resolve conflicts */
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmdepmissing_t *miss = alpm_list_getdata(lp);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, _("conflict: %s"), alpm_dep_get_name(miss));
}
retval = 127;
- alpm_list_free(data);
+ alpm_list_free(data, NULL);
break;
default:
retval = 127;
diff --git a/src/pacman/deptest.h b/src/pacman/deptest.h
index 5b2ff751..3a9ca3f5 100644
--- a/src/pacman/deptest.h
+++ b/src/pacman/deptest.h
@@ -21,7 +21,9 @@
#ifndef _PM_DEPTEST_H
#define _PM_DEPTEST_H
-int pacman_deptest(list_t *targets);
+#include <alpm.h>
+
+int pacman_deptest(alpm_list_t *targets);
#endif /* _PM_DEPTEST_H */
diff --git a/src/pacman/downloadprog.c b/src/pacman/downloadprog.c
index 29a98124..ae9f2005 100644
--- a/src/pacman/downloadprog.c
+++ b/src/pacman/downloadprog.c
@@ -34,7 +34,6 @@
/* pacman */
#include "util.h"
#include "log.h"
-#include "list.h"
#include "downloadprog.h"
#include "conf.h"
diff --git a/src/pacman/list.c b/src/pacman/list.c
deleted file mode 100644
index c95e8f3d..00000000
--- a/src/pacman/list.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * list.c
- *
- * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <libintl.h>
-/* pacman */
-#include "util.h"
-#include "list.h"
-
-static list_t *list_last(list_t *list);
-
-list_t *list_new()
-{
- list_t *list = NULL;
-
- list = (list_t *)malloc(sizeof(list_t));
- if(list == NULL) {
- return(NULL);
- }
- list->data = NULL;
- list->next = NULL;
- return(list);
-}
-
-void list_free(list_t *list)
-{
- list_t *ptr, *it = list;
-
- while(it) {
- ptr = it->next;
- free(it->data);
- free(it);
- it = ptr;
- }
- return;
-}
-
-list_t *list_add(list_t *list, void *data)
-{
- list_t *ptr, *lp;
-
- ptr = list;
- if(ptr == NULL) {
- ptr = list_new();
- }
-
- lp = list_last(ptr);
- if(lp == ptr && lp->data == NULL) {
- /* nada */
- } else {
- lp->next = list_new();
- if(lp->next == NULL) {
- return(NULL);
- }
- lp = lp->next;
- }
- lp->data = data;
- return(ptr);
-}
-
-int list_count(list_t *list)
-{
- int i;
- list_t *lp;
-
- for(lp = list, i = 0; lp; lp = lp->next, i++);
-
- return(i);
-}
-
-static list_t *list_last(list_t *list)
-{
- list_t *ptr;
-
- for(ptr = list; ptr && ptr->next; ptr = ptr->next);
- return(ptr);
-}
-
-/* Test for existence of a string in a list_t
- */
-int list_is_strin(const char *needle, list_t *haystack)
-{
- list_t *lp;
-
- for(lp = haystack; lp; lp = lp->next) {
- if(lp->data && !strcmp(lp->data, needle)) {
- return(1);
- }
- }
- return(0);
-}
-
-/* Display the content of a list_t struct of strings
- */
-
-void list_display(const char *title, list_t *list)
-{
- list_t *lp;
- int cols, len;
-
- len = strlen(title);
- printf("%s ", title);
-
- if(list) {
- for(lp = list, cols = len; lp; lp = lp->next) {
- int s = strlen((char *)lp->data)+1;
- unsigned int maxcols = getcols();
- if(s+cols >= maxcols) {
- int i;
- cols = len;
- printf("\n");
- for (i = 0; i < len+1; i++) {
- printf(" ");
- }
- }
- printf("%s ", (char *)lp->data);
- cols += s;
- }
- printf("\n");
- } else {
- printf(_("None\n"));
- }
-}
-
-void pmlist_display(const char *title, pmlist_t *list)
-{
- pmlist_t *lp;
- int cols, len;
-
- len = strlen(title);
- printf("%s ", title);
-
- if(list) {
- for(lp = list, cols = len; lp; lp = alpm_list_next(lp)) {
- int s = strlen(alpm_list_getdata(lp))+1;
- unsigned int maxcols = getcols();
- if(s+cols >= maxcols) {
- int i;
- cols = len;
- printf("\n");
- for (i = 0; i < len+1; i++) {
- printf(" ");
- }
- }
- printf("%s ", (char *)alpm_list_getdata(lp));
- cols += s;
- }
- printf("\n");
- } else {
- printf(_("None\n"));
- }
-}
-
-/* Filter out any duplicate strings in a pmlist_t
- *
- * Not the most efficient way, but simple to implement -- we assemble
- * a new list, using is_in() to check for dupes at each iteration.
- *
- * This function takes a pmlist_t* and returns a list_t*
- *
- */
-list_t *pmlist_remove_dupes(pmlist_t *list)
-{
- pmlist_t *i;
- list_t *newlist = NULL;
-
- for(i = alpm_list_first(list); i; i = alpm_list_next(i)) {
- char *data = alpm_list_getdata(i);
- if(!list_is_strin(data, newlist)) {
- newlist = list_add(newlist, strdup(data));
- }
- }
- return newlist;
-}
-
-/* vim: set ts=2 sw=2 noet: */
diff --git a/src/pacman/list.h b/src/pacman/list.h
deleted file mode 100644
index 30830aae..00000000
--- a/src/pacman/list.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * list.h
- *
- * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-#ifndef _LIST_H
-#define _LIST_H
-
-#include <alpm.h>
-
-/* Chained list struct */
-typedef struct __list_t {
- void *data;
- struct __list_t *next;
-} list_t;
-
-#define FREELIST(p) do { if(p) { list_free(p); p = NULL; } } while(0)
-#define FREELISTPTR(p) do { \
- list_t *i; \
- for(i = p; i; i = i->next) { \
- i->data = NULL; \
- } \
- FREELIST(p); \
-} while(0)
-
-list_t *list_new(void);
-void list_free(list_t *list);
-list_t *list_add(list_t *list, void *data);
-int list_count(list_t *list);
-int list_is_strin(const char *needle, list_t *haystack);
-void list_display(const char *title, list_t *list);
-
-void pmlist_display(const char *title, pmlist_t *list);
-list_t *pmlist_remove_dupes(pmlist_t *list);
-
-#endif /*_LIST_H*/
-
-/* vim: set ts=2 sw=2 noet: */
diff --git a/src/pacman/log.c b/src/pacman/log.c
index 928c8220..4685bd85 100644
--- a/src/pacman/log.c
+++ b/src/pacman/log.c
@@ -30,7 +30,6 @@
#include <alpm.h>
/* pacman */
#include "log.h"
-#include "list.h"
#include "conf.h"
#include "util.h"
diff --git a/src/pacman/package.c b/src/pacman/package.c
index b4874aaf..117cdf29 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -63,10 +63,10 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
/* actual output */
printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg));
printf(_("Version : %s\n"), (char *)alpm_pkg_get_version(pkg));
- pmlist_display(_("Groups :"), alpm_pkg_get_groups(pkg));
+ list_display(_("Groups :"), alpm_pkg_get_groups(pkg));
printf(_("Packager : %s\n"), (char *)alpm_pkg_get_packager(pkg));
printf(_("URL : %s\n"), (char *)alpm_pkg_get_url(pkg));
- pmlist_display(_("License :"), alpm_pkg_get_licenses(pkg));
+ list_display(_("License :"), alpm_pkg_get_licenses(pkg));
printf(_("Architecture : %s\n"), (char *)alpm_pkg_get_arch(pkg));
printf(_("Installed Size : %ld\n"), (long int)alpm_pkg_get_size(pkg));
printf(_("Build Date : %s %s\n"), bdate, strlen(bdate) ? "UTC" : "");
@@ -75,12 +75,12 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
printf(_("Install Date : %s %s\n"), idate, strlen(idate) ? "UTC" : "");
printf(_("Install Script : %s\n"), alpm_pkg_has_scriptlet(pkg) ? _("Yes") : _("No"));
printf(_("Reason : %s\n"), reason);
- pmlist_display(_("Provides :"), alpm_pkg_get_provides(pkg));
- pmlist_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
- pmlist_display(_("Removes :"), alpm_pkg_get_removes(pkg));
+ list_display(_("Provides :"), alpm_pkg_get_provides(pkg));
+ list_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
+ list_display(_("Removes :"), alpm_pkg_get_removes(pkg));
/* TODO only applicable if querying installed package, not a file */
- pmlist_display(_("Required By :"), alpm_pkg_get_requiredby(pkg));
- pmlist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
+ list_display(_("Required By :"), alpm_pkg_get_requiredby(pkg));
+ list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
printf(_("Description : "));
indentprint(alpm_pkg_get_desc(pkg), 17);
@@ -98,7 +98,7 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
/* Display the content of a sync package
*/
-void dump_pkg_sync(pmpkg_t *pkg, char *treename)
+void dump_pkg_sync(pmpkg_t *pkg, const char *treename)
{
char *md5sum, *sha1sum;
if(pkg == NULL) {
@@ -111,12 +111,12 @@ void dump_pkg_sync(pmpkg_t *pkg, char *treename)
printf(_("Repository : %s\n"), treename);
printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg));
printf(_("Version : %s\n"), (char *)alpm_pkg_get_version(pkg));
- pmlist_display(_("Groups :"), alpm_pkg_get_groups(pkg));
- pmlist_display(_("Provides :"), alpm_pkg_get_provides(pkg));
- pmlist_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
- pmlist_display(_("Removes :"), alpm_pkg_get_removes(pkg));
- pmlist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
- pmlist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
+ list_display(_("Groups :"), alpm_pkg_get_groups(pkg));
+ list_display(_("Provides :"), alpm_pkg_get_provides(pkg));
+ list_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
+ list_display(_("Removes :"), alpm_pkg_get_removes(pkg));
+ list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
+ list_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
printf(_("Download Size : %ld\n"), (long)alpm_pkg_get_size(pkg));
printf(_("Installed Size : %ld\n"), (long)alpm_pkg_get_isize(pkg));
@@ -137,10 +137,10 @@ void dump_pkg_sync(pmpkg_t *pkg, char *treename)
*/
void dump_pkg_backups(pmpkg_t *pkg)
{
- pmlist_t *i;
+ alpm_list_t *i;
const char *root = alpm_option_get_root();
printf("\nBackup Files :\n");
- for(i = alpm_list_first(alpm_pkg_get_backup(pkg)); i; i = alpm_list_next(i)) {
+ for(i = alpm_pkg_get_backup(pkg); i; i = alpm_list_next(i)) {
struct stat buf;
char path[PATH_MAX];
char *str = strdup(alpm_list_getdata(i));
@@ -190,7 +190,7 @@ void dump_pkg_backups(pmpkg_t *pkg)
void dump_pkg_files(pmpkg_t *pkg)
{
const char *pkgname;
- pmlist_t *i, *pkgfiles;
+ alpm_list_t *i, *pkgfiles;
pkgname = alpm_pkg_get_name(pkg);
pkgfiles = alpm_pkg_get_files(pkg);
diff --git a/src/pacman/package.h b/src/pacman/package.h
index 2b4d1728..f6aab756 100644
--- a/src/pacman/package.h
+++ b/src/pacman/package.h
@@ -22,7 +22,7 @@
#define _PM_PACKAGE_H
void dump_pkg_full(pmpkg_t *pkg, int level);
-void dump_pkg_sync(pmpkg_t *pkg, char *treename);
+void dump_pkg_sync(pmpkg_t *pkg, const char *treename);
void dump_pkg_backups(pmpkg_t *pkg);
void dump_pkg_files(pmpkg_t *pkg);
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 5498fab5..2c0fc4e6 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -43,8 +43,8 @@
#include <time.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
-#include "list.h"
#include "util.h"
#include "log.h"
#include "downloadprog.h"
@@ -75,10 +75,8 @@ enum {
config_t *config;
pmdb_t *db_local;
-/* list of (sync_t *) structs for sync locations */
-list_t *pmc_syncs;
/* list of targets specified on command line */
-static list_t *pm_targets;
+static alpm_list_t *pm_targets;
extern int neednl;
@@ -177,8 +175,6 @@ static void version()
static void cleanup(int signum)
{
- list_t *lp;
-
if(signum==SIGSEGV)
{
fprintf(stderr, "Internal pacman error: Segmentation fault\n"
@@ -198,11 +194,6 @@ static void cleanup(int signum)
}
/* free memory */
- for(lp = pmc_syncs; lp; lp = lp->next) {
- sync_t *sync = lp->data;
- FREE(sync->treename);
- }
- FREELIST(pmc_syncs);
FREELIST(pm_targets);
FREECONF(config);
@@ -294,7 +285,7 @@ static int parseargs(int argc, char *argv[])
config->configfile = strndup(optarg, PATH_MAX);
#endif
break;
- case 1002: config->op_s_ignore = list_add(config->op_s_ignore, strdup(optarg)); break;
+ case 1002: config->op_s_ignore = alpm_list_add(config->op_s_ignore, strdup(optarg)); break;
case 1003: config->debug = atoi(optarg); break;
case 1004: config->noprogressbar = 1; break;
case 1005: config->flags |= PM_TRANS_FLAG_NOSCRIPTLET; break;
@@ -392,7 +383,7 @@ static int parseargs(int argc, char *argv[])
while(optind < argc) {
/* add the target to our target array */
- pm_targets = list_add(pm_targets, strdup(argv[optind]));
+ pm_targets = alpm_list_add(pm_targets, strdup(argv[optind]));
optind++;
}
@@ -406,7 +397,6 @@ int main(int argc, char *argv[])
#ifndef CYGWIN
uid_t myuid;
#endif
- list_t *lp;
#if defined(PACMAN_DEBUG) && !defined(CYGWIN) && !defined(BSD)
/*setenv("MALLOC_TRACE","pacman.mtrace", 0);*/
@@ -500,7 +490,7 @@ int main(int argc, char *argv[])
config->configfile = strdup(PACCONF);
}
- if(alpm_parse_config(config->configfile, cb_db_register, "") != 0) {
+ if(alpm_parse_config(config->configfile, NULL, "") != 0) {
ERR(NL, _("failed to parse config (%s)\n"), alpm_strerror(pm_errno));
cleanup(1);
}
@@ -511,8 +501,9 @@ int main(int argc, char *argv[])
config->dbpath = alpm_option_get_dbpath();
config->cachedir = alpm_option_get_cachedir();
- for(lp = config->op_s_ignore; lp; lp = lp->next) {
- alpm_option_add_ignorepkg(lp->data);
+ alpm_list_t *i;
+ for(i = config->op_s_ignore; i; i = alpm_list_next(i)) {
+ alpm_option_add_ignorepkg(alpm_list_getdata(i));
}
if(config->verbose > 0) {
@@ -528,7 +519,7 @@ int main(int argc, char *argv[])
cleanup(1);
}
- if(list_count(pm_targets) == 0 && !(config->op == PM_OP_QUERY || (config->op == PM_OP_SYNC
+ if(alpm_list_count(pm_targets) == 0 && !(config->op == PM_OP_QUERY || (config->op == PM_OP_SYNC
&& (config->op_s_sync || config->op_s_upgrade || config->op_s_clean || config->group
|| config->op_q_list)))) {
ERR(NL, _("no targets specified (use -h for help)\n"));
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 06445e21..4124f400 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -27,8 +27,8 @@
#include <libintl.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
-#include "list.h"
#include "package.h"
#include "query.h"
#include "log.h"
@@ -38,15 +38,13 @@
extern config_t *config;
extern pmdb_t *db_local;
-extern list_t *pmc_syncs;
static int query_fileowner(pmdb_t *db, char *filename)
{
struct stat buf;
int gotcha = 0;
char rpath[PATH_MAX];
- pmlist_t *lp;
- const char *root;
+ alpm_list_t *i, *j;
if(db == NULL) {
return(0);
@@ -61,22 +59,16 @@ static int query_fileowner(pmdb_t *db, char *filename)
return(1);
}
- root = alpm_option_get_root();
+ for(i = alpm_db_getpkgcache(db); i && !gotcha; i = alpm_list_next(i)) {
+ pmpkg_t *info = alpm_list_getdata(i);
- for(lp = alpm_db_getpkgcache(db); lp && !gotcha; lp = alpm_list_next(lp)) {
- pmpkg_t *info;
- pmlist_t *i;
-
- info = alpm_list_getdata(lp);
-
- for(i = alpm_pkg_get_files(info); i && !gotcha; i = alpm_list_next(i)) {
+ for(j = alpm_pkg_get_files(info); j && !gotcha; j = alpm_list_next(j)) {
char path[PATH_MAX];
+ char *filename = alpm_list_getdata(j);
+ snprintf(path, PATH_MAX, "%s%s", alpm_option_get_root(), filename);
- char *filename = (char *)alpm_list_getdata(i);
- snprintf(path, PATH_MAX, "%s%s", root, filename);
- if(!strcmp(path, rpath)) {
- printf(_("%s is owned by %s %s\n"), path, (char *)alpm_pkg_get_name(info),
- (char *)alpm_pkg_get_version(info));
+ if(strcmp(path, rpath) == 0) {
+ printf(_("%s is owned by %s %s\n"), path, alpm_pkg_get_name(info), alpm_pkg_get_version(info));
gotcha = 1;
break;
}
@@ -90,25 +82,23 @@ static int query_fileowner(pmdb_t *db, char *filename)
return(0);
}
-int pacman_query(list_t *targets)
+int pacman_query(alpm_list_t *targets)
{
+ alpm_list_t *sync_dbs = NULL, *i, *j;;
pmpkg_t *info = NULL;
- list_t *targ;
- list_t *i;
- pmlist_t *j, *ret;
char *package = NULL;
int done = 0;
if(config->op_q_search) {
- for(i = targets; i; i = i->next) {
- alpm_option_add_needle(i->data);
+ for(i = targets; i; i = alpm_list_next(i)) {
+ alpm_option_add_needle(alpm_list_getdata(i));
}
- ret = alpm_db_search(db_local);
+ alpm_list_t *ret = alpm_db_search(db_local);
if(ret == NULL) {
return(1);
}
- for(j = ret; j; j = alpm_list_next(j)) {
- pmpkg_t *pkg = alpm_list_getdata(j);
+ for(i = ret; i; i = alpm_list_next(i)) {
+ pmpkg_t *pkg = alpm_list_getdata(i);
printf("local/%s/%s %s\n ",
(char *)alpm_list_getdata(alpm_pkg_get_groups(pkg)),
@@ -122,44 +112,45 @@ int pacman_query(list_t *targets)
}
if(config->op_q_foreign) {
- if(pmc_syncs == NULL || !list_count(pmc_syncs)) {
+ sync_dbs = alpm_option_get_syncdbs();
+
+ if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
ERR(NL, _("no usable package repositories configured.\n"));
return(1);
}
}
- for(targ = targets; !done; targ = (targ ? targ->next : NULL)) {
+ for(i = targets; !done; i = (i ? alpm_list_next(i) : NULL)) {
if(targets == NULL) {
done = 1;
} else {
- if(targ->next == NULL) {
+ if(alpm_list_next(i) == NULL) {
done = 1;
}
- package = targ->data;
+ package = alpm_list_getdata(i);
}
/* looking for groups */
if(config->group) {
- pmlist_t *lp;
if(targets == NULL) {
- for(lp = alpm_db_getgrpcache(db_local); lp; lp = alpm_list_next(lp)) {
- pmgrp_t *grp = alpm_list_getdata(lp);
- pmlist_t *i, *pkgnames;
+ for(j = alpm_db_getgrpcache(db_local); j; j = alpm_list_next(j)) {
+ pmgrp_t *grp = alpm_list_getdata(j);
+ alpm_list_t *p, *pkgnames;
const char *grpname;
grpname = alpm_grp_get_name(grp);
pkgnames = alpm_grp_get_packages(grp);
- for(i = pkgnames; i; i = alpm_list_next(i)) {
- MSG(NL, "%s %s\n", grpname, (char *)alpm_list_getdata(i));
+ for(p = pkgnames; p; p = alpm_list_next(p)) {
+ MSG(NL, "%s %s\n", grpname, (char *)alpm_list_getdata(p));
}
}
} else {
pmgrp_t *grp = alpm_db_readgrp(db_local, package);
if(grp) {
- pmlist_t *i, *pkgnames = alpm_grp_get_packages(grp);
- for(i = pkgnames; i; i = alpm_list_next(i)) {
- MSG(NL, "%s %s\n", package, (char *)alpm_list_getdata(i));
+ alpm_list_t *p, *pkgnames = alpm_grp_get_packages(grp);
+ for(p = pkgnames; p; p = alpm_list_next(p)) {
+ MSG(NL, "%s %s\n", package, (char *)alpm_list_getdata(p));
}
} else {
ERR(NL, _("group \"%s\" was not found\n"), package);
@@ -202,10 +193,9 @@ int pacman_query(list_t *targets)
/* find packages in the db */
if(package == NULL) {
- pmlist_t *lp;
/* no target */
- for(lp = alpm_db_getpkgcache(db_local); lp; lp = alpm_list_next(lp)) {
- pmpkg_t *tmpp = alpm_list_getdata(lp);
+ for(i = alpm_db_getpkgcache(db_local); i; i = alpm_list_next(i)) {
+ pmpkg_t *tmpp = alpm_list_getdata(i);
const char *pkgname, *pkgver;
pkgname = alpm_pkg_get_name(tmpp);
@@ -222,19 +212,13 @@ int pacman_query(list_t *targets)
}
if(config->op_q_foreign) {
int match = 0;
- for(i = pmc_syncs; i; i = i->next) {
- sync_t *sync = (sync_t *)i->data;
- for(j = alpm_db_getpkgcache(sync->db); j; j = alpm_list_next(j)) {
+ for(i = sync_dbs; i; i = alpm_list_next(i)) {
+ pmdb_t *db = (pmdb_t *)alpm_list_getdata(i);
+ for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
pmpkg_t *pkg = alpm_list_getdata(j);
- char *haystack;
- char *needle;
- haystack = strdup(alpm_pkg_get_name(pkg));
- needle = strdup(alpm_pkg_get_name(info));
- if(!strcmp(haystack, needle)) {
+ if(strcmp(alpm_pkg_get_name(pkg), alpm_pkg_get_name(info)) == 0) {
match = 1;
}
- FREE(haystack);
- FREE(needle);
}
}
if(match==0) {
@@ -255,8 +239,6 @@ int pacman_query(list_t *targets)
}
}
} else {
- const char *pkgname = NULL, *pkgver = NULL;
- char changelog[PATH_MAX];
info = alpm_db_readpkg(db_local, package);
if(info == NULL) {
@@ -269,10 +251,9 @@ int pacman_query(list_t *targets)
/* find a target */
if(config->op_q_changelog || config->op_q_info || config->op_q_list) {
if(config->op_q_changelog) {
- const char *dbpath;
- dbpath = alpm_option_get_dbpath();
+ char changelog[PATH_MAX];
snprintf(changelog, PATH_MAX, "%s%s/%s/%s-%s/changelog",
- config->root, dbpath,
+ config->root, alpm_option_get_dbpath(),
alpm_db_get_name(db_local),
alpm_pkg_get_name(info),
alpm_pkg_get_version(info));
@@ -286,12 +267,10 @@ int pacman_query(list_t *targets)
}
} else if(config->op_q_orphans) {
if(alpm_pkg_get_requiredby(info) == NULL) {
- MSG(NL, "%s %s\n", pkgname, pkgver);
+ MSG(NL, "%s %s\n", alpm_pkg_get_name(info), alpm_pkg_get_version(info));
}
} else {
- pkgname = alpm_pkg_get_name(info);
- pkgver = alpm_pkg_get_version(info);
- MSG(NL, "%s %s\n", pkgname, pkgver);
+ MSG(NL, "%s %s\n", alpm_pkg_get_name(info), alpm_pkg_get_version(info));
}
}
}
diff --git a/src/pacman/query.h b/src/pacman/query.h
index eecd8a13..ef8de807 100644
--- a/src/pacman/query.h
+++ b/src/pacman/query.h
@@ -21,7 +21,9 @@
#ifndef _PM_QUERY_H
#define _PM_QUERY_H
-int pacman_query(list_t *targets);
+#include <alpm.h>
+
+int pacman_query(alpm_list_t *targets);
#endif /* _PM_QUERY_H */
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 4802eff0..b8dd1544 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -25,10 +25,10 @@
#include <libintl.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
#include "util.h"
#include "log.h"
-#include "list.h"
#include "trans.h"
#include "remove.h"
#include "conf.h"
@@ -37,11 +37,9 @@ extern config_t *config;
extern pmdb_t *db_local;
-int pacman_remove(list_t *targets)
+int pacman_remove(alpm_list_t *targets)
{
- pmlist_t *data;
- list_t *i;
- list_t *finaltargs = NULL;
+ alpm_list_t *data, *i, *j, *finaltargs = NULL;
int retval = 0;
if(targets == NULL) {
@@ -51,27 +49,25 @@ int pacman_remove(list_t *targets)
/* If the target is a group, ask if its packages should be removed
* (the library can't remove groups for now)
*/
- for(i = targets; i; i = i->next) {
- pmgrp_t *grp;
-
- grp = alpm_db_readgrp(db_local, i->data);
+ for(i = targets; i; i = alpm_list_next(i)) {
+ pmgrp_t *grp = alpm_db_readgrp(db_local, alpm_list_getdata(i));
if(grp) {
- pmlist_t *lp, *pkgnames;
int all;
-
- pkgnames = alpm_grp_get_packages(grp);
+ alpm_list_t *pkgnames = alpm_grp_get_packages(grp);
MSG(NL, _(":: group %s:\n"), alpm_grp_get_name(grp));
- pmlist_display(" ", pkgnames);
+ list_display(" ", pkgnames);
all = yesno(_(" Remove whole content? [Y/n] "));
- for(lp = alpm_list_first(pkgnames); lp; lp = alpm_list_next(lp)) {
- if(all || yesno(_(":: Remove %s from group %s? [Y/n] "), (char *)alpm_list_getdata(lp), i->data)) {
- finaltargs = list_add(finaltargs, strdup(alpm_list_getdata(lp)));
+
+ for(j = pkgnames; j; j = alpm_list_next(j)) {
+ char *pkg = alpm_list_getdata(j);
+ if(all || yesno(_(":: Remove %s from group %s? [Y/n] "), pkg, (char *)alpm_list_getdata(i))) {
+ finaltargs = alpm_list_add(finaltargs, strdup(pkg));
}
}
} else {
/* not a group, so add it to the final targets */
- finaltargs = list_add(finaltargs, strdup(i->data));
+ finaltargs = alpm_list_add(finaltargs, strdup(alpm_list_getdata(i)));
}
}
@@ -87,9 +83,10 @@ int pacman_remove(list_t *targets)
return(1);
}
/* and add targets to it */
- for(i = finaltargs; i; i = i->next) {
- if(alpm_trans_addtarget(i->data) == -1) {
- ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)i->data, alpm_strerror(pm_errno));
+ for(i = finaltargs; i; i = alpm_list_next(i)) {
+ char *targ = alpm_list_getdata(i);
+ if(alpm_trans_addtarget(targ) == -1) {
+ ERR(NL, _("failed to add target '%s' (%s)\n"), targ, alpm_strerror(pm_errno));
retval = 1;
goto cleanup;
}
@@ -98,16 +95,15 @@ int pacman_remove(list_t *targets)
/* Step 2: prepare the transaction based on its type, targets and flags
*/
if(alpm_trans_prepare(&data) == -1) {
- pmlist_t *lp;
ERR(NL, _("failed to prepare transaction (%s)\n"), alpm_strerror(pm_errno));
switch(pm_errno) {
case PM_ERR_UNSATISFIED_DEPS:
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmdepmissing_t *miss = alpm_list_getdata(lp);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, _(":: %s is required by %s\n"), alpm_dep_get_target(miss),
alpm_dep_get_name(miss));
}
- alpm_list_free(data);
+ alpm_list_free(data, NULL);
break;
default:
break;
@@ -119,15 +115,14 @@ int pacman_remove(list_t *targets)
/* Warn user in case of dangerous operation
*/
if(config->flags & PM_TRANS_FLAG_RECURSE || config->flags & PM_TRANS_FLAG_CASCADE) {
- pmlist_t *lp;
/* list transaction targets */
- i = NULL;
- for(lp = alpm_list_first(alpm_trans_get_packages()); lp; lp = alpm_list_next(lp)) {
- pmpkg_t *pkg = alpm_list_getdata(lp);
- i = list_add(i, strdup(alpm_pkg_get_name(pkg)));
+ alpm_list_t *lst = NULL;
+ for(i = alpm_trans_get_packages(); i; i = alpm_list_next(i)) {
+ pmpkg_t *pkg = alpm_list_getdata(i);
+ lst = alpm_list_add(lst, strdup(alpm_pkg_get_name(pkg)));
}
- list_display(_("\nTargets:"), i);
- FREELIST(i);
+ list_display(_("\nTargets:"), lst);
+ FREELIST(lst);
/* get confirmation */
if(yesno(_("\nDo you want to remove these packages? [Y/n] ")) == 0) {
retval = 1;
diff --git a/src/pacman/remove.h b/src/pacman/remove.h
index 129fc3cb..9365dc2e 100644
--- a/src/pacman/remove.h
+++ b/src/pacman/remove.h
@@ -21,7 +21,9 @@
#ifndef _PM_REMOVE_H
#define _PM_REMOVE_H
-int pacman_remove(list_t *targets);
+#include <alpm.h>
+
+int pacman_remove(alpm_list_t *targets);
#endif /* _PM_REMOVE_H */
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index fdc0fb92..7bb4a127 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -37,12 +37,12 @@
#endif
#include <alpm.h>
+#include <alpm_list.h>
#include <download.h> /* downloadLastErrString */
/* pacman */
#include "util.h"
#include "log.h"
#include "downloadprog.h"
-#include "list.h"
#include "package.h"
#include "trans.h"
#include "sync.h"
@@ -50,9 +50,6 @@
extern config_t *config;
-extern list_t *pmc_syncs;
-
-
/* splits package name into its respective parts */
static int split_pkgname(char *target, char *name, char *version)
{
@@ -111,9 +108,7 @@ static int sync_cleancache(int level)
/* incomplete cleanup: we keep latest packages and partial downloads */
DIR *dir;
struct dirent *ent;
- list_t *cache = NULL;
- list_t *clean = NULL;
- list_t *i, *j;
+ alpm_list_t *cache = NULL, *clean = NULL, *i, *j;
if(!yesno(_("Do you want to remove old packages from cache? [Y/n] ")))
return(0);
@@ -128,16 +123,16 @@ static int sync_cleancache(int level)
if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) {
continue;
}
- cache = list_add(cache, strdup(ent->d_name));
+ cache = alpm_list_add(cache, strdup(ent->d_name));
}
closedir(dir);
- for(i = cache; i; i = i->next) {
- char *str = i->data;
+ for(i = cache; i; i = alpm_list_next(i)) {
+ char *str = alpm_list_getdata(i);
char name[256], version[64];
if(strstr(str, PM_EXT_PKG) == NULL) {
- clean = list_add(clean, strdup(str));
+ clean = alpm_list_add(clean, strdup(str));
continue;
}
/* we keep partially downloaded files */
@@ -145,11 +140,11 @@ static int sync_cleancache(int level)
continue;
}
if(split_pkgname(str, name, version) != 0) {
- clean = list_add(clean, strdup(str));
+ clean = alpm_list_add(clean, strdup(str));
continue;
}
- for(j = i->next; j; j = j->next) {
- char *s = j->data;
+ for(j = alpm_list_next(i); j; j = alpm_list_next(j)) {
+ char *s = alpm_list_getdata(j);
char n[256], v[64];
if(strstr(s, PM_EXT_PKG) == NULL) {
@@ -164,18 +159,18 @@ static int sync_cleancache(int level)
/* TODO Do not remove the currently installed version EITHER */
if(!strcmp(name, n)) {
char *ptr = (alpm_pkg_vercmp(version, v) < 0) ? str : s;
- if(!list_is_strin(ptr, clean)) {
- clean = list_add(clean, strdup(ptr));
+ if(!alpm_list_is_strin(ptr, clean)) {
+ clean = alpm_list_add(clean, strdup(ptr));
}
}
}
}
FREELIST(cache);
- for(i = clean; i; i = i->next) {
+ for(i = clean; i; i = alpm_list_next(i)) {
char path[PATH_MAX];
- snprintf(path, PATH_MAX, "%s/%s", dirpath, (char *)i->data);
+ snprintf(path, PATH_MAX, "%s/%s", dirpath, (char *)alpm_list_getdata(i));
unlink(path);
}
FREELIST(clean);
@@ -200,15 +195,15 @@ static int sync_cleancache(int level)
return(0);
}
-static int sync_synctree(int level, list_t *syncs)
+static int sync_synctree(int level, alpm_list_t *syncs)
{
- list_t *i;
+ alpm_list_t *i;
int success = 0, ret;
- for(i = syncs; i; i = i->next) {
- sync_t *sync = (sync_t *)i->data;
+ for(i = syncs; i; i = alpm_list_next(i)) {
+ pmdb_t *db = alpm_list_getdata(i);
- ret = alpm_db_update((level < 2 ? 0 : 1), sync->db);
+ ret = alpm_db_update((level < 2 ? 0 : 1), db);
if(ret < 0) {
if(pm_errno == PM_ERR_DB_SYNC) {
/* use libdownload error */
@@ -218,12 +213,12 @@ static int sync_synctree(int level, list_t *syncs)
* Yes. This will be here until we add a nice pacman "pm_errstr" or
* something, OR add all libdownload error codes into the pm_error enum
*/
- ERR(NL, _("failed to synchronize %s: %s\n"), sync->treename, downloadLastErrString);
+ ERR(NL, _("failed to synchronize %s: %s\n"), alpm_db_get_name(db), downloadLastErrString);
} else {
- ERR(NL, _("failed to update %s (%s)\n"), sync->treename, alpm_strerror(pm_errno));
+ ERR(NL, _("failed to update %s (%s)\n"), alpm_db_get_name(db), alpm_strerror(pm_errno));
}
} else if(ret == 1) {
- MSG(NL, _(" %s is up to date\n"), sync->treename);
+ MSG(NL, _(" %s is up to date\n"), alpm_db_get_name(db));
success++;
} else {
success++;
@@ -237,29 +232,27 @@ static int sync_synctree(int level, list_t *syncs)
return(success > 0);
}
-static int sync_search(list_t *syncs, list_t *targets)
+static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
{
- list_t *i;
- pmlist_t *ret;
+ alpm_list_t *i, *j, *ret;
- for(i = targets; i; i = i->next) {
- alpm_option_add_needle(i->data);
+ for(i = targets; i; i = alpm_list_next(i)) {
+ alpm_option_add_needle(alpm_list_getdata(i));
}
- for(i = syncs; i; i = i->next) {
- sync_t *sync = i->data;
+ for(i = syncs; i; i = alpm_list_next(i)) {
+ pmdb_t *db = (pmdb_t *)alpm_list_getdata(i);
if(targets) {
- pmlist_t *lp;
- ret = alpm_db_search(sync->db);
+ ret = alpm_db_search(db);
if(ret == NULL) {
continue;
}
- for(lp = ret; lp; lp = alpm_list_next(lp)) {
- pmpkg_t *pkg = alpm_list_getdata(lp);
+ for(j = ret; j; j = alpm_list_next(j)) {
+ pmpkg_t *pkg = alpm_list_getdata(j);
char *group = (char *)alpm_list_getdata(alpm_pkg_get_groups(pkg));
printf("%s/%s %s %s%s%s\n ",
- alpm_db_get_name(sync->db),
+ alpm_db_get_name(db),
alpm_pkg_get_name(pkg),
alpm_pkg_get_version(pkg),
(group ? " (" : ""), (group ? group : ""), (group ? ") " : ""));
@@ -268,12 +261,10 @@ static int sync_search(list_t *syncs, list_t *targets)
}
alpm_list_free_outer(ret);
} else {
- pmlist_t *lp;
+ for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
+ pmpkg_t *pkg = alpm_list_getdata(j);
- for(lp = alpm_db_getpkgcache(sync->db); lp; lp = alpm_list_next(lp)) {
- pmpkg_t *pkg = alpm_list_getdata(lp);
-
- MSG(NL, "%s/%s %s\n ", sync->treename, alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
+ MSG(NL, "%s/%s %s\n ", alpm_db_get_name(db), alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
indentprint(alpm_pkg_get_desc(pkg), 4);
MSG(NL, "\n");
}
@@ -283,33 +274,32 @@ static int sync_search(list_t *syncs, list_t *targets)
return(0);
}
-static int sync_group(int level, list_t *syncs, list_t *targets)
+static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
{
- list_t *i, *j;
+ alpm_list_t *i, *j;
if(targets) {
- for(i = targets; i; i = i->next) {
- for(j = syncs; j; j = j->next) {
- sync_t *sync = j->data;
- pmgrp_t *grp = alpm_db_readgrp(sync->db, i->data);
+ for(i = targets; i; i = alpm_list_next(i)) {
+ for(j = syncs; j; j = alpm_list_next(j)) {
+ pmdb_t *db = alpm_list_getdata(j);
+ pmgrp_t *grp = alpm_db_readgrp(db, alpm_list_getdata(i));
if(grp) {
MSG(NL, "%s\n", (char *)alpm_grp_get_name(grp));
- pmlist_display(" ", alpm_grp_get_packages(grp));
+ list_display(" ", alpm_grp_get_packages(grp));
}
}
}
} else {
- for(j = syncs; j; j = j->next) {
- sync_t *sync = j->data;
- pmlist_t *lp;
+ for(i = syncs; i; i = alpm_list_next(i)) {
+ pmdb_t *db = alpm_list_getdata(i);
- for(lp = alpm_db_getgrpcache(sync->db); lp; lp = alpm_list_next(lp)) {
- pmgrp_t *grp = alpm_list_getdata(lp);
+ for(j = alpm_db_getgrpcache(db); j; j = alpm_list_next(j)) {
+ pmgrp_t *grp = alpm_list_getdata(j);
MSG(NL, "%s\n", (char *)alpm_grp_get_name(grp));
if(grp && level > 1) {
- pmlist_display(" ", alpm_grp_get_packages(grp));
+ list_display(" ", alpm_grp_get_packages(grp));
}
}
}
@@ -318,23 +308,22 @@ static int sync_group(int level, list_t *syncs, list_t *targets)
return(0);
}
-static int sync_info(list_t *syncs, list_t *targets)
+static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
{
- list_t *i, *j;
+ alpm_list_t *i, *j, *k;
if(targets) {
- for(i = targets; i; i = i->next) {
+ for(i = targets; i; i = alpm_list_next(i)) {
int found = 0;
- for(j = syncs; j && !found; j = j->next) {
- sync_t *sync = j->data;
- pmlist_t *lp;
+ for(j = syncs; j && !found; j = alpm_list_next(j)) {
+ pmdb_t *db = alpm_list_getdata(j);
- for(lp = alpm_db_getpkgcache(sync->db); !found && lp; lp = alpm_list_next(lp)) {
- pmpkg_t *pkg = alpm_list_getdata(lp);
+ for(k = alpm_db_getpkgcache(db); !found && k; k = alpm_list_next(k)) {
+ pmpkg_t *pkg = alpm_list_getdata(k);
- if(!strcmp(alpm_pkg_get_name(pkg), i->data)) {
- dump_pkg_sync(pkg, sync->treename);
+ if(!strcmp(alpm_pkg_get_name(pkg), alpm_list_getdata(i))) {
+ dump_pkg_sync(pkg, alpm_db_get_name(db));
MSG(NL, "\n");
found = 1;
}
@@ -346,12 +335,11 @@ static int sync_info(list_t *syncs, list_t *targets)
}
}
} else {
- for(j = syncs; j; j = j->next) {
- sync_t *sync = j->data;
- pmlist_t *lp;
+ for(i = syncs; i; i = alpm_list_next(i)) {
+ pmdb_t *db = alpm_list_getdata(i);
- for(lp = alpm_db_getpkgcache(sync->db); lp; lp = alpm_list_next(lp)) {
- dump_pkg_sync(alpm_list_getdata(lp), sync->treename);
+ for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
+ dump_pkg_sync(alpm_list_getdata(j), alpm_db_get_name(db));
MSG(NL, "\n");
}
}
@@ -360,44 +348,42 @@ static int sync_info(list_t *syncs, list_t *targets)
return(0);
}
-static int sync_list(list_t *syncs, list_t *targets)
+static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
{
- list_t *i;
- list_t *ls = NULL;
+ alpm_list_t *i, *j, *ls = NULL;
if(targets) {
- for(i = targets; i; i = i->next) {
- list_t *j;
- sync_t *sync = NULL;
+ for(i = targets; i; i = alpm_list_next(i)) {
+ const char *repo = alpm_list_getdata(i);
+ pmdb_t *db = NULL;
- for(j = syncs; j && !sync; j = j->next) {
- sync_t *s = j->data;
+ for(j = syncs; j; j = alpm_list_next(j)) {
+ pmdb_t *d = alpm_list_getdata(j);
- if(strcmp(i->data, s->treename) == 0) {
- sync = s;
+ if(strcmp(repo, alpm_db_get_name(d)) == 0) {
+ db = d;
+ break;
}
}
- if(sync == NULL) {
- ERR(NL, _("repository \"%s\" was not found.\n"), (char *)i->data);
+ if(db == NULL) {
+ ERR(NL, _("repository \"%s\" was not found.\n"),repo);
FREELISTPTR(ls);
return(1);
}
- ls = list_add(ls, sync);
+ ls = alpm_list_add(ls, db);
}
} else {
ls = syncs;
}
- for(i = ls; i; i = i->next) {
- pmlist_t *lp;
- sync_t *sync = i->data;
+ for(i = ls; i; i = alpm_list_next(i)) {
+ pmdb_t *db = alpm_list_getdata(i);
- for(lp = alpm_db_getpkgcache(sync->db); lp; lp = alpm_list_next(lp)) {
- pmpkg_t *pkg = alpm_list_getdata(lp);
-
- MSG(NL, "%s %s %s\n", (char *)sync->treename, alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
+ for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
+ pmpkg_t *pkg = alpm_list_getdata(j);
+ MSG(NL, "%s %s %s\n", alpm_db_get_name(db), alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
}
}
@@ -408,14 +394,14 @@ static int sync_list(list_t *syncs, list_t *targets)
return(0);
}
-int pacman_sync(list_t *targets)
+int pacman_sync(alpm_list_t *targets)
{
int confirm = 0;
int retval = 0;
- list_t *i = NULL;
- pmlist_t *packages = NULL, *data = NULL, *lp = NULL;
+ alpm_list_t *packages, *data, *i, *j, *k, *sync_dbs;
- if(pmc_syncs == NULL || !list_count(pmc_syncs)) {
+ sync_dbs = alpm_option_get_syncdbs();
+ if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
ERR(NL, _("no usable package repositories configured.\n"));
return(1);
}
@@ -425,19 +411,19 @@ int pacman_sync(list_t *targets)
}
if(config->op_s_search) {
- return(sync_search(pmc_syncs, targets));
+ return(sync_search(sync_dbs, targets));
}
if(config->group) {
- return(sync_group(config->group, pmc_syncs, targets));
+ return(sync_group(config->group, sync_dbs, targets));
}
if(config->op_s_info) {
- return(sync_info(pmc_syncs, targets));
+ return(sync_info(sync_dbs, targets));
}
if(config->op_q_list) {
- return(sync_list(pmc_syncs, targets));
+ return(sync_list(sync_dbs, targets));
}
/* Step 1: create a new transaction...
@@ -455,13 +441,12 @@ int pacman_sync(list_t *targets)
/* grab a fresh package list */
MSG(NL, _(":: Synchronizing package databases...\n"));
alpm_logaction(_("synchronizing package lists"));
- if(!sync_synctree(config->op_s_sync, pmc_syncs)) {
+ if(!sync_synctree(config->op_s_sync, sync_dbs)) {
ERR(NL, _("failed to synchronize any databases"));
return(1);
}
}
-
if(config->op_s_upgrade) {
MSG(NL, _(":: Starting full system upgrade...\n"));
alpm_logaction(_("starting full system upgrade"));
@@ -478,10 +463,10 @@ int pacman_sync(list_t *targets)
* when sysupgrade'ing with an older version of pacman.
*/
data = alpm_trans_get_packages();
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmsyncpkg_t *sync = alpm_list_getdata(lp);
+ for(i = alpm_list_first(data); i; i = alpm_list_next(i)) {
+ pmsyncpkg_t *sync = alpm_list_getdata(i);
pmpkg_t *spkg = alpm_sync_get_package(sync);
- if(!strcmp("pacman", alpm_pkg_get_name(spkg)) && alpm_list_count(data) > 1) {
+ if(strcmp("pacman", alpm_pkg_get_name(spkg)) == 0 && alpm_list_count(data) > 1) {
MSG(NL, _("\n:: pacman has detected a newer version of the \"pacman\" package.\n"));
MSG(NL, _(":: It is recommended that you allow pacman to upgrade itself\n"));
MSG(NL, _(":: first, then you can re-run the operation with the newer version.\n"));
@@ -501,7 +486,7 @@ int pacman_sync(list_t *targets)
return(1);
}
if(alpm_trans_addtarget("pacman") == -1) {
- ERR(NL, _("'%s': %s\n"), (char *)i->data, alpm_strerror(pm_errno));
+ ERR(NL, _("pacman: %s\n"), alpm_strerror(pm_errno));
retval = 1;
goto cleanup;
}
@@ -511,11 +496,10 @@ int pacman_sync(list_t *targets)
}
} else {
/* process targets */
- for(i = targets; i; i = i->next) {
- char *targ = i->data;
+ for(i = targets; i; i = alpm_list_next(i)) {
+ char *targ = alpm_list_getdata(i);
if(alpm_trans_addtarget(targ) == -1) {
pmgrp_t *grp = NULL;
- list_t *j;
int found=0;
if(pm_errno == PM_ERR_TRANS_DUP_TARGET) {
/* just ignore duplicate targets */
@@ -527,28 +511,26 @@ int pacman_sync(list_t *targets)
goto cleanup;
}
/* target not found: check if it's a group */
- for(j = pmc_syncs; j; j = j->next) {
- sync_t *sync = j->data;
- grp = alpm_db_readgrp(sync->db, targ);
+
+ for(j = alpm_option_get_syncdbs(); j; j = alpm_list_next(j)) {
+ pmdb_t *db = alpm_list_getdata(j);
+ grp = alpm_db_readgrp(db, targ);
if(grp) {
- pmlist_t *pmpkgs;
- list_t *k, *pkgs;
found++;
MSG(NL, _(":: group %s:\n"), targ);
- pmpkgs = alpm_grp_get_packages(grp);
/* remove dupe entries in case a package exists in multiple repos */
/* (the dupe function takes a pmlist_t* and returns a list_t*) */
- pkgs = pmlist_remove_dupes(pmpkgs);
+ alpm_list_t *pkgs = alpm_list_remove_dupes(alpm_grp_get_packages(grp));
list_display(" ", pkgs);
if(yesno(_(":: Install whole content? [Y/n] "))) {
- for(k = pkgs; k; k = k->next) {
- targets = list_add(targets, strdup(k->data));
+ for(k = pkgs; k; k = alpm_list_next(k)) {
+ targets = alpm_list_add(targets, strdup(alpm_list_getdata(k)));
}
} else {
- for(k = pkgs; k; k = k->next) {
- char *pkgname = k->data;
+ for(k = pkgs; k; k = alpm_list_next(k)) {
+ char *pkgname = alpm_list_getdata(k);
if(yesno(_(":: Install %s from group %s? [Y/n] "), pkgname, targ)) {
- targets = list_add(targets, strdup(pkgname));
+ targets = alpm_list_add(targets, strdup(pkgname));
}
}
}
@@ -557,18 +539,19 @@ int pacman_sync(list_t *targets)
}
if(!found) {
/* targ not found in sync db, searching for providers... */
- pmlist_t *k = NULL;
- pmpkg_t *pkg;
const char *pname = NULL;
- for(j = pmc_syncs; j && !k; j = j->next) {
- sync_t *sync = j->data;
- k = alpm_db_whatprovides(sync->db, targ);
- pkg = (pmpkg_t*)alpm_list_getdata(alpm_list_first(k));
- pname = alpm_pkg_get_name(pkg);
+ for(j = alpm_option_get_syncdbs(); j; j = alpm_list_next(j)) {
+ pmdb_t *db = alpm_list_getdata(j);
+ alpm_list_t *prov = alpm_db_whatprovides(db, targ);
+ if(prov) {
+ pmpkg_t *pkg = alpm_list_getdata(prov);
+ pname = alpm_pkg_get_name(pkg);
+ break;
+ }
}
if(pname != NULL) {
/* targ is provided by pname */
- targets = list_add(targets, strdup(pname));
+ targets = alpm_list_add(targets, strdup(pname));
} else {
ERR(NL, _("'%s': not found in sync db\n"), targ);
retval = 1;
@@ -586,8 +569,8 @@ int pacman_sync(list_t *targets)
ERR(NL, _("failed to prepare transaction (%s)\n"), alpm_strerror(pm_errno));
switch(pm_errno) {
case PM_ERR_UNSATISFIED_DEPS:
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmdepmissing_t *miss = alpm_list_getdata(lp);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, ":: %s %s %s", alpm_dep_get_target(miss),
alpm_dep_get_type(miss) == PM_DEP_TYPE_DEPEND ? _("requires") : _("is required by"),
alpm_dep_get_name(miss));
@@ -600,18 +583,16 @@ int pacman_sync(list_t *targets)
}
break;
case PM_ERR_CONFLICTING_DEPS:
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmdepmissing_t *miss = alpm_list_getdata(lp);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, _(":: %s: conflicts with %s"),
alpm_dep_get_target(miss), alpm_dep_get_name(miss));
}
break;
case PM_ERR_DISK_FULL:
- lp = alpm_list_first(data);
- pkgsize = alpm_list_getdata(lp);
- lp = alpm_list_next(lp);
- freespace = alpm_list_getdata(lp);
+ pkgsize = alpm_list_getdata(data);
+ freespace = alpm_list_getdata(alpm_list_next(data));
MSG(NL, _(":: %.1f MB required, have %.1f MB"),
(double)(*pkgsize / 1048576.0), (double)(*freespace / 1048576.0));
break;
@@ -631,26 +612,25 @@ int pacman_sync(list_t *targets)
/* list targets and get confirmation */
if(!(alpm_trans_get_flags() & PM_TRANS_FLAG_PRINTURIS)) {
- list_t *list_install = NULL;
- list_t *list_remove = NULL;
+ alpm_list_t *list_install = NULL, *list_remove = NULL;
+
char *str;
unsigned long totalsize = 0;
unsigned long totalisize = 0;
double mb, umb;
- for(lp = alpm_list_first(packages); lp; lp = alpm_list_next(lp)) {
- pmsyncpkg_t *sync = alpm_list_getdata(lp);
+ for(i = packages; i; i = alpm_list_next(i)) {
+ pmsyncpkg_t *sync = alpm_list_getdata(i);
pmpkg_t *pkg = alpm_sync_get_package(sync);
const char *pkgname, *pkgver;
if(alpm_sync_get_type(sync) == PM_SYNC_TYPE_REPLACE) {
- pmlist_t *j, *data;
- data = alpm_sync_get_data(sync);
- for(j = alpm_list_first(data); j; j = alpm_list_next(j)) {
+ alpm_list_t *data = alpm_sync_get_data(sync);
+ for(j = data; j; j = alpm_list_next(j)) {
pmpkg_t *p = alpm_list_getdata(j);
const char *pkgname = alpm_pkg_get_name(p);
- if(!list_is_strin(pkgname, list_remove)) {
- list_remove = list_add(list_remove, strdup(pkgname));
+ if(!alpm_list_is_strin(pkgname, list_remove)) {
+ list_remove = alpm_list_add(list_remove, strdup(pkgname));
}
}
}
@@ -661,7 +641,7 @@ int pacman_sync(list_t *targets)
totalisize += alpm_pkg_get_isize(pkg);
asprintf(&str, "%s-%s", pkgname, pkgver);
- list_install = list_add(list_install, str);
+ list_install = alpm_list_add(list_install, str);
}
if(list_remove) {
MSG(NL, _("\nRemove: "));
@@ -723,12 +703,12 @@ int pacman_sync(list_t *targets)
ERR(NL, _("failed to commit transaction (%s)\n"), alpm_strerror(pm_errno));
switch(pm_errno) {
case PM_ERR_FILE_CONFLICTS:
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- pmconflict_t *conflict = alpm_list_getdata(lp);
+ for(i = data; i; i = alpm_list_next(i)) {
+ pmconflict_t *conflict = alpm_list_getdata(i);
switch(alpm_conflict_get_type(conflict)) {
case PM_CONFLICT_TYPE_TARGET:
MSG(NL, _("%s%s exists in \"%s\" (target) and \"%s\" (target)"),
- config->root,
+ alpm_option_get_root(),
alpm_conflict_get_file(conflict),
alpm_conflict_get_target(conflict),
alpm_conflict_get_ctarget(conflict));
@@ -736,7 +716,7 @@ int pacman_sync(list_t *targets)
case PM_CONFLICT_TYPE_FILE:
MSG(NL, _("%s: %s%s exists in filesystem"),
alpm_conflict_get_target(conflict),
- config->root,
+ alpm_option_get_root(),
alpm_conflict_get_file(conflict));
break;
}
@@ -744,8 +724,8 @@ int pacman_sync(list_t *targets)
MSG(NL, _("\nerrors occurred, no packages were upgraded.\n"));
break;
case PM_ERR_PKG_CORRUPTED:
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- MSG(NL, "%s", (char*)alpm_list_getdata(lp));
+ for(i = data; i; i = alpm_list_next(i)) {
+ MSG(NL, "%s", (char*)alpm_list_getdata(i));
}
MSG(NL, _("\nerrors occurred, no packages were upgraded.\n"));
break;
@@ -760,7 +740,7 @@ int pacman_sync(list_t *targets)
*/
cleanup:
if(data) {
- alpm_list_free(data);
+ alpm_list_free(data, NULL);
data = NULL;
}
if(alpm_trans_release() == -1) {
diff --git a/src/pacman/sync.h b/src/pacman/sync.h
index e61668e4..ca8f6300 100644
--- a/src/pacman/sync.h
+++ b/src/pacman/sync.h
@@ -21,13 +21,9 @@
#ifndef _PM_SYNC_H
#define _PM_SYNC_H
-/* Repositories */
-typedef struct __sync_t {
- char *treename;
- pmdb_t *db;
-} sync_t;
+#include <alpm.h>
-int pacman_sync(list_t *targets);
+int pacman_sync(alpm_list_t *targets);
#endif /* _PM_SYNC_H */
diff --git a/src/pacman/trans.c b/src/pacman/trans.c
index 1d003251..d217ed24 100644
--- a/src/pacman/trans.c
+++ b/src/pacman/trans.c
@@ -34,7 +34,6 @@
#include "util.h"
#include "log.h"
#include "trans.h"
-#include "list.h"
#include "conf.h"
#define LOG_STR_LEN 256
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index c2e47452..5b803353 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -24,15 +24,15 @@
#include <string.h>
#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
-#include "list.h"
#include "add.h"
#include "upgrade.h"
#include "conf.h"
extern config_t *config;
-int pacman_upgrade(list_t *targets)
+int pacman_upgrade(alpm_list_t *targets)
{
/* this is basically just a remove-then-add process. pacman_add() will */
/* handle it */
diff --git a/src/pacman/upgrade.h b/src/pacman/upgrade.h
index 04fa14c1..e21ac357 100644
--- a/src/pacman/upgrade.h
+++ b/src/pacman/upgrade.h
@@ -21,7 +21,9 @@
#ifndef _PM_UPGRADE_H
#define _PM_UPGRADE_H
-int pacman_upgrade(list_t *targets);
+#include <alpm.h>
+
+int pacman_upgrade(alpm_list_t *targets);
#endif /* _PM_UPGRADE_H */
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 406583d3..b3a595be 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -41,9 +41,10 @@
#include <limits.h> /* PATH_MAX */
#endif
+#include <alpm.h>
+#include <alpm_list.h>
/* pacman */
#include "util.h"
-#include "list.h"
#include "conf.h"
#include "log.h"
@@ -196,22 +197,22 @@ void indentprint(const char *str, unsigned int indent)
/* Condense a list of strings into one long (space-delimited) string
*/
-char *buildstring(list_t *strlist)
+char *buildstring(alpm_list_t *strlist)
{
char *str;
size_t size = 1;
- list_t *lp;
+ alpm_list_t *i;
- for(lp = strlist; lp; lp = lp->next) {
- size += strlen(lp->data) + 1;
+ for(i = strlist; i; i = alpm_list_next(i)) {
+ size += strlen(alpm_list_getdata(i)) + 1;
}
str = (char *)malloc(size);
if(str == NULL) {
ERR(NL, _("failed to allocate %d bytes\n"), size);
}
str[0] = '\0';
- for(lp = strlist; lp; lp = lp->next) {
- strcat(str, lp->data);
+ for(i = strlist; i; i = alpm_list_next(i)) {
+ strcat(str, alpm_list_getdata(i));
strcat(str, " ");
}
/* shave off the last space */
@@ -254,4 +255,34 @@ char *strtrim(char *str)
return str;
}
+void list_display(const char *title, alpm_list_t *list)
+{
+ alpm_list_t *i;
+ int cols, len;
+
+ len = strlen(title);
+ printf("%s ", title);
+
+ if(list) {
+ for(i = list, cols = len; i; i = alpm_list_next(i)) {
+ char *str = alpm_list_getdata(i);
+ int s = strlen(str)+1;
+ unsigned int maxcols = getcols();
+ if(s + cols >= maxcols) {
+ int i;
+ cols = len;
+ printf("\n");
+ for (i = 0; i < len+1; ++i) {
+ printf(" ");
+ }
+ }
+ printf("%s ", str);
+ cols += s;
+ }
+ printf("\n");
+ } else {
+ printf(_("None\n"));
+ }
+}
+
/* vim: set ts=2 sw=2 noet: */
diff --git a/src/pacman/util.h b/src/pacman/util.h
index 763c5081..098fa62f 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -21,7 +21,12 @@
#ifndef _PM_UTIL_H
#define _PM_UTIL_H
-#include "list.h"
+#include <stdlib.h>
+#include <string.h>
+#include <libintl.h>
+
+#include <alpm.h>
+#include <alpm_list.h>
#define MALLOC(p, b) do { \
if((b) > 0) { \
@@ -47,10 +52,11 @@ unsigned int getcols();
int makepath(char *path);
int rmrf(char *path);
void indentprint(const char *str, unsigned int indent);
-char *buildstring(list_t *strlist);
+char *buildstring(alpm_list_t *strlist);
char *strtoupper(char *str);
char *strtrim(char *str);
int reg_match(char *string, char *pattern);
+void list_display(const char *title, alpm_list_t *list);
#endif /* _PM_UTIL_H */