42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
z[i] = 0;
break;
}
if( z[i]<' ' ) z[i] = ' ';
}
blob_append(pBlob, z, -1);
}
/*
** Do a single prompt for a passphrase. Store the results in the blob.
*/
static void prompt_for_passphrase(const char *zPrompt, Blob *pPassphrase){
char *z = getpass(zPrompt);
strip_string(pPassphrase, z);
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
z[i] = 0;
break;
}
if( z[i]<' ' ) z[i] = ' ';
}
blob_append(pBlob, z, -1);
}
#ifdef __MINGW32__
/*
** getpass for Windows
*/
static char *getpass(const char *prompt){
static char pwd[64];
size_t i;
fputs(prompt,stderr);
fflush(stderr);
for(i=0; i<sizeof(pwd)-1; ++i){
pwd[i] = _getch();
if(pwd[i]=='\r' || pwd[i]=='\n'){
break;
}
/* BS or DEL */
else if(i>0 && (pwd[i]==8 || pwd[i]==127)){
i -= 2;
continue;
}
/* CTRL-C */
else if(pwd[i]==3) {
i=0;
break;
}
/* ESC */
else if(pwd[i]==27){
i=0;
break;
}
else{
fputc('*',stderr);
}
}
pwd[i]='\0';
fputs("\n", stderr);
return pwd;
}
#endif
/*
** Do a single prompt for a passphrase. Store the results in the blob.
*/
static void prompt_for_passphrase(const char *zPrompt, Blob *pPassphrase){
char *z = getpass(zPrompt);
strip_string(pPassphrase, z);
|