source: main/trunk/greenstone2/common-src/src/getpw/getpass.c@ 26681

Last change on this file since 26681 was 26681, checked in by davidb, 11 years ago

Changed some 'char *' to 'const char*' to match standard header definitions

File size: 724 bytes
Line 
1
2/*
3 * UNIX getpass function.
4 */
5# include <stdio.h>
6char *getpass (const char *prompt)
7{
8 static char pass[1024];
9 char *p = pass;
10 int k;
11
12 if (prompt) {
13 while (*prompt) {
14 putc (*prompt++, stderr);
15 }
16 }
17
18 do {
19 k = getch ();
20 if (p < pass + 1023) {
21 switch (k) {
22 case 0x04:
23 case 0x0D:
24 break;
25 case 0x08:
26 if (p > pass) p--;
27 break;
28 case 0xE0:
29 case 0x00:
30 getch ();
31 break;
32 default:
33 *p++ = k;
34 break;
35 }
36 }
37 }
38 while (k != 0x0D && k != 0x04);
39 *p = 0x00;
40 if (k == 0x0D) {
41 putc (0x0D, stderr);
42 putc (0x0A, stderr);
43 }
44 return pass;
45}
46
Note: See TracBrowser for help on using the repository browser.