libxbps: xbps_yesno/noyes() are only used in xbps-bin(8), remove from API.
This commit is contained in:
76
lib/util.c
76
lib/util.c
@ -493,79 +493,3 @@ xbps_xasprintf(const char *fmt, ...)
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static char *
|
||||
strtrim(char *str)
|
||||
{
|
||||
char *pch = str;
|
||||
|
||||
if (str == NULL || *str == '\0')
|
||||
return str;
|
||||
|
||||
while (isspace((unsigned char)*pch))
|
||||
pch++;
|
||||
|
||||
if (pch != str)
|
||||
memmove(str, pch, (strlen(pch) + 1));
|
||||
|
||||
if (*str == '\0')
|
||||
return str;
|
||||
|
||||
pch = (str + (strlen(str) - 1));
|
||||
while (isspace((unsigned char)*pch))
|
||||
pch--;
|
||||
|
||||
*++pch = '\0';
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static bool
|
||||
question(bool preset, const char *fmt, va_list ap)
|
||||
{
|
||||
char response[32];
|
||||
|
||||
vfprintf(stderr, fmt, ap);
|
||||
if (preset)
|
||||
fprintf(stderr, " %s ", "[YES/no]");
|
||||
else
|
||||
fprintf(stderr, " %s ", "[yes/NO]");
|
||||
|
||||
if (fgets(response, 32, stdin)) {
|
||||
(void)strtrim(response);
|
||||
if (strlen(response) == 0)
|
||||
return preset;
|
||||
|
||||
if (strcasecmp(response, "yes") == 0)
|
||||
return true;
|
||||
else if (strcasecmp(response, "no") == 0)
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_yesno(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
bool res;
|
||||
|
||||
va_start(ap, fmt);
|
||||
res = question(1, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_noyes(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
bool res;
|
||||
|
||||
va_start(ap, fmt);
|
||||
res = question(0, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
Reference in New Issue
Block a user