1 /* This program is free software; you can redistribute it and/or modify
2 it under the terms of the GNU General Public License as published by
3 the Free Software Foundation; either version 2, or (at your option)
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 GNU General Public License for more details. */
21 static void error (int, int, char *);
27 getpass (char *prompt)
31 static $DESCRIPTOR (sys_command, "SYS$COMMAND");
32 unsigned short iosb[4];
33 /* Arbitrary limit. It doesn't seem worth going through multiple
34 SYS$QIOW calls and who knows what to get rid of it, I don't
36 static char buf[2048];
38 /* Try to ensure that we avoid stepping on whatever output has
39 been sent to stdout. */
43 status = sys$assign (&sys_command, &chan, 0, 0);
45 error (1, 0, "sys$assign failed in getpass");
46 status = sys$qiow (0, chan, IO$_READPROMPT | IO$M_NOECHO, &iosb, 0, 0,
47 buf, sizeof (buf) - 1, 0, 0, prompt, strlen (prompt));
49 error (1, 0, "sys$qiow failed in getpass");
51 error (1, 0, "sys$qiow (iosb) failed in getpass");
53 status = sys$dassgn (chan);
55 error (0, 0, "sys$dassgn failed in getpass");
56 /* Since there is no echo, we better go to the next line ourselves. */
65 printf ("thank you for saying \"%s\"\n", getpass ("What'll it be? "));
69 static void error (int x, int y, char *msg)
71 printf ("error: %s\n", msg);