tests: Set fake-pinentry's stdout and stdin to _IOLBF.

* tests/openpgp/fake-pinentry.c (main): Call setvbuf.  Show passphrase
at startup.  Increase buffer.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-04-14 09:08:50 +02:00
parent 4159567f7e
commit 94504b3d5a
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 19 additions and 2 deletions

View File

@ -25,19 +25,36 @@
int
main (int argc, char **argv)
{
static char *passphrase;
char *p;
(void) argc, (void) argv;
setvbuf (stdin, NULL, _IOLBF, BUFSIZ);
setvbuf (stdout, NULL, _IOLBF, BUFSIZ);
if (!passphrase)
{
passphrase = getenv ("PINENTRY_USER_DATA");
if (!passphrase)
passphrase = "";
for (p=passphrase; *p; p++)
if (*p == '\r' || *p == '\n')
*p = '.';
printf ("# Passphrase='%s'\n", passphrase);
}
printf ("OK - what's up?\n");
while (! feof (stdin))
{
char buffer[128];
char buffer[1024];
if (fgets (buffer, sizeof buffer, stdin) == NULL)
break;
if (strncmp (buffer, "GETPIN", 6) == 0)
printf ("D %s\nOK\n", getenv ("PINENTRY_USER_DATA") ?: "");
printf ("D %s\nOK\n", passphrase);
else if (strncmp (buffer, "BYE", 3) == 0)
{
printf ("OK\n");