blob: 0ba29fcdeec7f439ca6997a89bee713c1eba916f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#include <stdio.h>
#include <string.h>
#include "cvs.h"
#define INCL_BASE
#define INCL_SUB
#define INCL_KBD
#include <os2.h>
/* Only define this if you're testing and want to compile this file
standalone. */
/* #define DIAGNOSTIC */
/* Turn off keyboard echo. Does not check error returns. */
static void
EchoOff (void)
{
KBDINFO KbdInfo;
KbdGetStatus (&KbdInfo, 0);
KbdInfo.fsMask = (KbdInfo.fsMask & ~KEYBOARD_ECHO_ON) | KEYBOARD_ECHO_OFF;
KbdSetStatus (&KbdInfo, 0);
}
/* Turn on keyboard echo. Does not check error returns. */
static void
EchoOn( void )
{
KBDINFO KbdInfo;
KbdGetStatus (&KbdInfo, 0);
KbdInfo.fsMask = (KbdInfo.fsMask & ~KEYBOARD_ECHO_OFF) | KEYBOARD_ECHO_ON;
KbdSetStatus (&KbdInfo, 0);
}
char *
getpass (char *prompt)
{
static char Buf[80];
STRINGINBUF StringInBuf;
printf ("%s", prompt);
fflush (stdout);
EchoOff ();
StringInBuf.cb = sizeof (Buf) - 1;
StringInBuf.cchIn = 0;
KbdStringIn ((PSZ) Buf, &StringInBuf, IO_WAIT, 0);
Buf[StringInBuf.cchIn] = '\0';
EchoOn ();
return Buf;
}
#ifdef DIAGNOSTIC
main()
{
char *s;
s = getpass ("Input password (no echo): ");
printf ("String was \"%s\"\n", s);
fflush (stdout);
}
#endif /* DIAGNOSTIC */
|