From: Ralph Corderoy Date: Sun, 12 Nov 2017 00:28:46 +0000 (+0000) Subject: read_yes_or_no_if_tty.c: Move interface to own file. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/4b388ae408c2056043f1a28cdf480743092253b0 read_yes_or_no_if_tty.c: Move interface to own file. --- diff --git a/Makefile.am b/Makefile.am index fb982b14..e17cd540 100644 --- a/Makefile.am +++ b/Makefile.am @@ -420,6 +420,7 @@ noinst_HEADERS = \ sbr/r1bindex.h \ sbr/read_line.h \ sbr/read_switch.h \ + sbr/read_yes_or_no_if_tty.h \ sbr/readconfig.h \ sbr/refile.h \ sbr/remdir.h \ diff --git a/h/prototypes.h b/h/prototypes.h index dff1a035..acf51d93 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -15,14 +15,6 @@ char *etcpath(char *) NONNULL(1); struct msgs_array; -/* - * If standard input is not a tty, return 1 without printing anything. Else, - * print null-terminated PROMPT to and flush standard output. Read answers from - * standard input until one is "yes" or "no", returning 1 for "yes" and 0 for - * "no". Also return 0 on EOF. - */ -int read_yes_or_no_if_tty(const char *PROMPT); - /* * Print null-terminated PROMPT to and flush standard output. Read multi-word * answers from standard input until a first word matches an entry in SWITCHES. diff --git a/sbr/context_read.c b/sbr/context_read.c index b207201d..499dba41 100644 --- a/sbr/context_read.c +++ b/sbr/context_read.c @@ -22,6 +22,7 @@ */ #include "h/mh.h" +#include "read_yes_or_no_if_tty.h" #include "concat.h" #include "context_read.h" #include "context_find.h" diff --git a/sbr/read_yes_or_no_if_tty.c b/sbr/read_yes_or_no_if_tty.c index 15450c5d..03a3c0b5 100644 --- a/sbr/read_yes_or_no_if_tty.c +++ b/sbr/read_yes_or_no_if_tty.c @@ -6,6 +6,7 @@ */ #include "h/mh.h" +#include "read_yes_or_no_if_tty.h" #include "read_switch.h" diff --git a/sbr/read_yes_or_no_if_tty.h b/sbr/read_yes_or_no_if_tty.h new file mode 100644 index 00000000..825bd989 --- /dev/null +++ b/sbr/read_yes_or_no_if_tty.h @@ -0,0 +1,13 @@ +/* read_yes_or_no_if_tty.h -- get a yes/no answer from the user + * + * This code is Copyright (c) 2017, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ + +/* + * If standard input is not a tty, return 1 without printing anything. Else, + * print null-terminated PROMPT to and flush standard output. Read answers from + * standard input until one is "yes" or "no", returning 1 for "yes" and 0 for + * "no". Also return 0 on EOF. + */ +int read_yes_or_no_if_tty(const char *); diff --git a/sbr/utils.c b/sbr/utils.c index f7f006a1..d3d4a860 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -6,6 +6,7 @@ */ #include "h/mh.h" +#include "read_yes_or_no_if_tty.h" #include "concat.h" #include "r1bindex.h" #include "context_foil.h" diff --git a/uip/mhcachesbr.c b/uip/mhcachesbr.c index 9fedd161..44faf5d9 100644 --- a/uip/mhcachesbr.c +++ b/uip/mhcachesbr.c @@ -6,6 +6,7 @@ */ #include "h/mh.h" +#include "sbr/read_yes_or_no_if_tty.h" #include "sbr/trimcpy.h" #include "sbr/error.h" #include diff --git a/uip/mhmisc.c b/uip/mhmisc.c index fcec3c3e..525cc6df 100644 --- a/uip/mhmisc.c +++ b/uip/mhmisc.c @@ -6,6 +6,7 @@ */ #include "h/mh.h" +#include "sbr/read_yes_or_no_if_tty.h" #include "sbr/concat.h" #include "sbr/error.h" #include "h/mime.h" diff --git a/uip/mhparse.c b/uip/mhparse.c index ca9d3030..a519c7a1 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -6,6 +6,7 @@ */ #include "h/mh.h" +#include "sbr/read_yes_or_no_if_tty.h" #include "sbr/concat.h" #include "sbr/r1bindex.h" #include "sbr/ruserpass.h" diff --git a/uip/packf.c b/uip/packf.c index 31079a8c..19ab1d47 100644 --- a/uip/packf.c +++ b/uip/packf.c @@ -6,6 +6,7 @@ */ #include "h/mh.h" +#include "sbr/read_yes_or_no_if_tty.h" #include "sbr/concat.h" #include "sbr/seq_setprev.h" #include "sbr/seq_setcur.h" diff --git a/uip/rmf.c b/uip/rmf.c index d492df1e..1e7f90c0 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -6,6 +6,7 @@ */ #include "h/mh.h" +#include "sbr/read_yes_or_no_if_tty.h" #include "sbr/concat.h" #include "sbr/smatch.h" #include "sbr/remdir.h"