summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/hcrypto/ui.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2010-01-12 18:16:45 +1100
committerAndrew Bartlett <abartlet@samba.org>2010-03-27 11:51:27 +1100
commit89eaef025376339ef25d07cdc4748920fceaa968 (patch)
treef514f4632c9d54a372a7f1f0ca845a0c3a488fbf /source4/heimdal/lib/hcrypto/ui.c
parentfac8ca52ade6e490eea3cf3d0fc98287da321c13 (diff)
downloadsamba-89eaef025376339ef25d07cdc4748920fceaa968.tar.gz
samba-89eaef025376339ef25d07cdc4748920fceaa968.tar.bz2
samba-89eaef025376339ef25d07cdc4748920fceaa968.zip
s4:heimdal: import lorikeet-heimdal-201001120029 (commit a5e675fed7c5db8a7370b77ed0bfa724196aa84d)
Diffstat (limited to 'source4/heimdal/lib/hcrypto/ui.c')
-rw-r--r--source4/heimdal/lib/hcrypto/ui.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/source4/heimdal/lib/hcrypto/ui.c b/source4/heimdal/lib/hcrypto/ui.c
index ca8c8442b5..f6f8a1ffe2 100644
--- a/source4/heimdal/lib/hcrypto/ui.c
+++ b/source4/heimdal/lib/hcrypto/ui.c
@@ -37,10 +37,15 @@
#include <stdlib.h>
#include <string.h>
#include <signal.h>
+#ifdef HAVE_TERMIOS_H
#include <termios.h>
+#endif
#include <roken.h>
#include <ui.h>
+#ifdef HAVE_CONIO_H
+#include <conio.h>
+#endif
static sig_atomic_t intr_flag;
@@ -50,6 +55,53 @@ intr(int sig)
intr_flag++;
}
+#ifdef HAVE_CONIO_H
+
+/*
+ * Windows does console slightly different then then unix case.
+ */
+
+static int
+read_string(const char *preprompt, const char *prompt,
+ char *buf, size_t len, int echo)
+{
+ int of = 0;
+ int c;
+ char *p;
+ void (*oldsigintr)(int);
+
+ _cprintf("%s%s", preprompt, prompt);
+
+ oldsigintr = signal(SIGINT, intr);
+
+ p = buf;
+ while(intr_flag == 0){
+ c = ((echo)? _getche(): _getch());
+ if(c == '\n')
+ break;
+ if(of == 0)
+ *p++ = c;
+ of = (p == buf + len);
+ }
+ if(of)
+ p--;
+ *p = 0;
+
+ if(echo == 0){
+ printf("\n");
+ }
+
+ signal(SIGINT, oldsigintr);
+
+ if(intr_flag)
+ return -2;
+ if(of)
+ return -1;
+ return 0;
+}
+
+#else /* !HAVE_CONIO_H */
+
#ifndef NSIG
#define NSIG 47
#endif
@@ -135,6 +187,8 @@ read_string(const char *preprompt, const char *prompt,
return 0;
}
+#endif /* HAVE_CONIO_H */
+
int
UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify)
{