summaryrefslogtreecommitdiff
path: root/src/pacman/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r--src/pacman/util.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 8cfa675a..b80b09ad 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -610,6 +610,25 @@ void display_synctargets(const alpm_list_t *syncpkgs)
alpm_list_free(rpkglist);
}
+/* Helper function for comparing strings using the
+ * alpm "compare func" signature */
+int str_cmp(const void *s1, const void *s2)
+{
+ return(strcmp(s1, s2));
+}
+
+void display_new_optdepends(pmpkg_t *oldpkg, pmpkg_t *newpkg)
+{
+ alpm_list_t *old = alpm_pkg_get_optdepends(oldpkg);
+ alpm_list_t *new = alpm_pkg_get_optdepends(newpkg);
+ alpm_list_t *optdeps = alpm_list_diff(new,old,str_cmp);
+ if(optdeps) {
+ printf(_("New optional dependencies for %s\n"), alpm_pkg_get_name(newpkg));
+ list_display_linebreak(" ", optdeps);
+ }
+ alpm_list_free(optdeps);
+}
+
void display_optdepends(pmpkg_t *pkg)
{
alpm_list_t *optdeps = alpm_pkg_get_optdepends(pkg);
@@ -620,10 +639,9 @@ void display_optdepends(pmpkg_t *pkg)
}
/* presents a prompt and gets a Y/N answer */
-int yesno(short preset, char *fmt, ...)
+static int question(short preset, char *fmt, va_list args)
{
char response[32];
- va_list args;
FILE *stream;
if(config->noconfirm) {
@@ -633,9 +651,7 @@ int yesno(short preset, char *fmt, ...)
stream = stderr;
}
- va_start(args, fmt);
vfprintf(stream, fmt, args);
- va_end(args);
if(preset) {
fprintf(stream, " %s ", _("[Y/n]"));
@@ -663,6 +679,30 @@ int yesno(short preset, char *fmt, ...)
return(0);
}
+int yesno(char *fmt, ...)
+{
+ int ret;
+ va_list args;
+
+ va_start(args, fmt);
+ ret = question(1, fmt, args);
+ va_end(args);
+
+ return(ret);
+}
+
+int noyes(char *fmt, ...)
+{
+ int ret;
+ va_list args;
+
+ va_start(args, fmt);
+ ret = question(0, fmt, args);
+ va_end(args);
+
+ return(ret);
+}
+
int pm_printf(pmloglevel_t level, const char *format, ...)
{
int ret;