diff options
author | Xavier Chantry <shiningxc@gmail.com> | 2008-08-20 22:08:11 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2008-08-23 09:22:34 -0500 |
commit | adc4078b8743a1437d44557dafea8619b1ce0fb1 (patch) | |
tree | 6b6d03e5e9231fed33629ca3cf63a15e12593592 /src/pacman/util.c | |
parent | 7865fb9af487f7ca043cab6e90c3aee0863e285b (diff) |
split yesno() into yesno() and noyes() functions.
The yesno function had a preset argument for specifying the default answer :
yes or no.
However, in all our calls to yesno, only one used the default "no" answer.
Having to specify preset==1 for all the other cases was rather cumbersome.
To make this easier, this commit adds a noyes function, with the following
behavior :
yesno() : default answer is yes
noyes() : default answer is no
Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r-- | src/pacman/util.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c index 8c4aeab8..1fc67145 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -619,10 +619,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) { @@ -632,9 +631,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]")); @@ -662,6 +659,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; |