summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/hcrypto/ui.c
diff options
context:
space:
mode:
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)
{