+ if (!*confp) {
+ if ((*confp = fopen("/dev/tty", "w")) == NULL)
+ *confp = stderr;
+ }
+
+ for (i = 0; i < len; i++)
+ if ((data[i] & 0x60) || (data[i] == '\n'))
+ fputc(data[i], *confp);
+ fflush(*confp);
+}
+
+int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
+{
+ size_t curr_prompt;
+ FILE *confp = NULL;
+
+ /*
+ * Zero all the results, in case we abort half-way through.
+ */
+ {
+ int i;
+ for (i = 0; i < p->n_prompts; i++)
+ memset(p->prompts[i]->result, 0, p->prompts[i]->result_len);
+ }
+
+ if (p->n_prompts && console_batch_mode)
+ return 0;
+
+ /*
+ * Preamble.
+ */
+ /* We only print the `name' caption if we have to... */
+ if (p->name_reqd && p->name) {
+ size_t l = strlen(p->name);
+ console_prompt_text(&confp, p->name, l);
+ if (p->name[l-1] != '\n')
+ console_prompt_text(&confp, "\n", 1);
+ }
+ /* ...but we always print any `instruction'. */
+ if (p->instruction) {
+ size_t l = strlen(p->instruction);
+ console_prompt_text(&confp, p->instruction, l);
+ if (p->instruction[l-1] != '\n')
+ console_prompt_text(&confp, "\n", 1);
+ }
+
+ for (curr_prompt = 0; curr_prompt < p->n_prompts; curr_prompt++) {
+
+ struct termios oldmode, newmode;
+ int i;
+ prompt_t *pr = p->prompts[curr_prompt];
+