117721Speter/* yesno.c -- read a yes/no response from stdin
217721Speter   Copyright (C) 1990 Free Software Foundation, Inc.
317721Speter
417721Speter   This program is free software; you can redistribute it and/or modify
517721Speter   it under the terms of the GNU General Public License as published by
617721Speter   the Free Software Foundation; either version 2, or (at your option)
717721Speter   any later version.
817721Speter
917721Speter   This program is distributed in the hope that it will be useful,
1017721Speter   but WITHOUT ANY WARRANTY; without even the implied warranty of
1117721Speter   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1225839Speter   GNU General Public License for more details.  */
1317721Speter
1417721Speter#ifdef HAVE_CONFIG_H
1517721Speter#include "config.h"
1617721Speter#endif
1717721Speter
1817721Speter#include <stdio.h>
1917721Speter
2017721Speter/* Read one line from standard input
2117721Speter   and return nonzero if that line begins with y or Y,
2217721Speter   otherwise return 0. */
2317721Speter
2417721Speterint
2517721Speteryesno ()
2617721Speter{
2717721Speter  int c;
2817721Speter  int rv;
2917721Speter
3017721Speter  fflush (stderr);
3117721Speter  fflush (stdout);
3217721Speter  c = getchar ();
3317721Speter  rv = (c == 'y') || (c == 'Y');
3417721Speter  while (c != EOF && c != '\n')
3517721Speter    c = getchar ();
3617721Speter
3717721Speter  return rv;
3817721Speter}
39