summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
25 files changed, 334 insertions, 604 deletions
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 */