From a809d533f9f2c62bfbce557ccb6a23d9f87fc197 Mon Sep 17 00:00:00 2001 From: Niall O'Higgins Date: Wed, 15 Mar 2006 19:59:38 +0000 Subject: - add util.h, reorganising a bunch of things and exposing cvs_yesno() function to be used by rcs. --- usr.bin/cvs/util.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'usr.bin/cvs/util.c') diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c index 16100f2a327..161e06eb216 100644 --- a/usr.bin/cvs/util.c +++ b/usr.bin/cvs/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.69 2006/01/27 12:56:28 xsa Exp $ */ +/* $OpenBSD: util.c,v 1.70 2006/03/15 19:59:36 niallo Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. @@ -28,9 +28,9 @@ #include "cvs.h" #include "log.h" +#include "util.h" #if !defined(RCSPROG) - /* letter -> mode type map */ static const int cvs_modetypes[26] = { -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, @@ -1018,3 +1018,29 @@ cvs_hack_time(time_t oldtime, int togmt) return (cvs_date_parse(tbuf)); } + +/* + * cvs_yesno() + * + * Read from standart input for `y' or `Y' character. + * Returns 0 on success, or -1 on failure. + */ +int +cvs_yesno(void) +{ + int c, ret; + + ret = 0; + + fflush(stderr); + fflush(stdout); + + if ((c = getchar()) != 'y' && c != 'Y') + ret = -1; + else + while (c != EOF && c != '\n') + c = getchar(); + + return (ret); +} + -- cgit v1.2.3