Enhance fix of 0b81a300d9e7cf78b6bc11d8c870f57fa81fcdc4.
[mmh] / sbr / getanswer.c
1 /*
2 ** getanswer.c -- get a yes/no answer from the user
3 **
4 ** This code is Copyright (c) 2002, by the authors of nmh.  See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
7 */
8
9 #include <h/mh.h>
10 #include <stdio.h>
11
12
13 int
14 getanswer(char *prompt)
15 {
16         static int interactive = -1;
17
18         if (interactive < 0)
19                 interactive = isatty(fileno(stdin)) ? 1 : 0;
20
21         return (interactive ? gans(prompt, anoyes) : 1);
22 }