aboutsummaryrefslogtreecommitdiff
path: root/lib/confirm.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-12-05 19:04:35 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2012-12-05 19:04:35 +0200
commitb66c616988486510b3d75051eaf709db8efc8e79 (patch)
treeb4440a077b71432106e57d85487e4b5e4c7aaf7c /lib/confirm.c
parent3f1f18e26d8ed66b227d5de6207842021118fd3b (diff)
downloadeclat-b66c616988486510b3d75051eaf709db8efc8e79.tar.gz
eclat-b66c616988486510b3d75051eaf709db8efc8e79.tar.bz2
Implement release-address.
* TODO: Update. * doc/Makefile.am: Add new files. * doc/eclat-allocate-address.1: New file. * doc/eclat-release-address.1: New file. * doc/eclat-associate-address.1: Update. * doc/eclat-describe-addresses.1: Update. * doc/eclat-disassociate-address.1: Update. * doc/eclat.1: Update. * etc/Makefile.am: Add new files. * etc/release-address.fln: New file. * lib/Makefile.am: Add new files. * lib/confirm.c: New file. * lib/getyn.c: New file. * lib/libeclat.h (eclat_getyn,eclat_vgetyn) (eclat_confirm): New protos. (eclat_confirm_mode): New extern. * src/Makefile.am: Add new files. * src/cmdline.opt: New options -Y (--yes) and -N (--no). * src/eclat.c: Register the release-address command. * src/eclat.h (EX_CANCELLED): New constant. (eclat_release_address): New proto. * src/reladdr-cl.opt: New file. * src/reladdr.c: New file.
Diffstat (limited to 'lib/confirm.c')
-rw-r--r--lib/confirm.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/confirm.c b/lib/confirm.c
new file mode 100644
index 0000000..bd283a1
--- /dev/null
+++ b/lib/confirm.c
@@ -0,0 +1,41 @@
+/* This file is part of Eclat.
+ Copyright (C) 2012 Sergey Poznyakoff.
+
+ Eclat is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Eclat is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "libeclat.h"
+#include <sysexits.h>
+
+int eclat_confirm_mode = -1;
+
+int
+eclat_confirm(const char *prompt, ...)
+{
+ int rc;
+ va_list ap;
+
+ if (!isatty(0) || eclat_confirm_mode >= 0) {
+ if (eclat_confirm_mode == -1)
+ die(EX_USAGE, "stdin not a terminal and no default response provided; use -Y or -N option to override");
+ return eclat_confirm_mode;
+ }
+
+ va_start(ap, prompt);
+ rc = eclat_vgetyn(!!eclat_confirm_mode, prompt, ap);
+ va_end(ap);
+
+ return rc;
+}
+
+

Return to:

Send suggestions and report system problems to the System administrator.