From 090b61b2d18a034c225598d54304e05c95b71b3e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 18 Mar 2009 21:35:49 +0000 Subject: [PATCH] Implement read_yesno(). Originally committed as revision 18037 to svn://svn.ffmpeg.org/ffmpeg/trunk --- cmdutils.c | 11 +++++++++++ cmdutils.h | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/cmdutils.c b/cmdutils.c index 7c4a530ef9..167d15a71c 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -472,3 +472,14 @@ void show_formats(void) "decoder corresponds to the h263 and h263p encoders, for file formats it is even\n" "worse.\n"); } + +int read_yesno(void) +{ + int c = getchar(); + int yesno = (toupper(c) == 'Y'); + + while (c != '\n' && c != EOF) + c = getchar(); + + return yesno; +} diff --git a/cmdutils.h b/cmdutils.h index 959c3f7cd2..e30ea0f9af 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -152,4 +152,10 @@ void show_license(void); */ void show_formats(void); +/** + * Returns a positive value if reads from standard input a line + * starting with [yY], otherwise returns 0. + */ +int read_yesno(void); + #endif /* FFMPEG_CMDUTILS_H */