aruu

[MIRROR] Actual replacement for Busybox | suckless
git clone https://git.daat.foo/aruu.git
Log | Files | Refs | README | LICENSE

confirm.c (363B)


      1 /* see LICENSE file for copyright and license details */
      2 #include <ctype.h>
      3 #include <stdarg.h>
      4 
      5 #include "../util.h"
      6 
      7 int
      8 confirm(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 }