diff --git a/cmdutils.c b/cmdutils.c index 7c4a530ef9c92d3475c32dcd0a2321cf28ccd42e..167d15a71c9c517b02cd91aac72b39dec35bc713 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 959c3f7cd289ea96191c5a800b02bfc342c32c85..e30ea0f9afc13a975eb19bfa9d5973cc09c7d838 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 */