master xplshn/aruu / shared / libutil / confirm.c
 1/* See LICENSE file for copyright and license details. */
 2#include <ctype.h>
 3#include <stdarg.h>
 4
 5#include "../util.h"
 6
 7int
 8confirm(const char *fmt, ...)
 9{
10  int     c, ans;
11  va_list ap;
12
13  va_start(ap, fmt);
14  xvprintf(fmt, ap);
15  va_end(ap);
16
17  c   = getchar();
18  ans = (c == 'y' || c == 'Y');
19  while (c != '\n' && c != EOF)
20    c = getchar();
21  return ans;
22}