summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/util.c
diff options
context:
space:
mode:
authorNiall O'Higgins <niallo@cvs.openbsd.org>2006-03-15 19:59:38 +0000
committerNiall O'Higgins <niallo@cvs.openbsd.org>2006-03-15 19:59:38 +0000
commita809d533f9f2c62bfbce557ccb6a23d9f87fc197 (patch)
treefbdc6e431a10877ff53824e3ed7d054dc0a63ccc /usr.bin/cvs/util.c
parentc51f2c1be7f15860a9c5bce9b205e51292c3a932 (diff)
- add util.h, reorganising a bunch of things and exposing cvs_yesno()
function to be used by rcs.
Diffstat (limited to 'usr.bin/cvs/util.c')
-rw-r--r--usr.bin/cvs/util.c30
1 files changed, 28 insertions, 2 deletions
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 <jfb@openbsd.org>
* 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);
+}
+