Commit dd4b8358 authored by Niels Möller's avatar Niels Möller
Browse files

* src/interact.c: Moved unix_interact class to unix_interact.c.

Rev: src/interact.c:1.3
parent f728949a
......@@ -38,89 +38,9 @@
#include <errno.h>
#include <fcntl.h>
#if 0
/* GABA:
(name interact_unix)
(super abstract_interact)
(tty_fd . int)
(dims . "struct terminal_dimensions")
(changed . sig_atomic_t)))
static int
unix_is_tty(struct abstract_interact *s)
CAST(interact_unix, self, s);
return self->tty_fd >= 0;
/* FIXME: Rewrite to operate on tty_fd. */
static struct lsh_string *
unix_read_password(struct abstract_interact *s UNUSED,
int max_length UNUSED,
struct lsh_string *prompt, int free)
/* NOTE: Ignores max_length; instead getpass()'s limit applies. */
char *password;
prompt = make_cstring(prompt, free);
if (!prompt)
return 0;
/* NOTE: This function uses a static buffer. */
password = getpass(prompt->data);
if (!password)
return 0;
return format_cstring(password);
static int
unix_yes_or_no(struct abstract_interact *s,
struct lsh_string *s, int def, int free)
CAST(interact_unix, self, s);
const struct exception *e;
if ( (self->tty_fd < 0) || quiet_flag)
if (free)
return def;
e = write_raw(self->tty_fd, s->length, s->data);
if (free)
if (e)
return def;
if (!tty_read_line(TTY_BUFSIZE, buffer))
return def;
switch (buffer[0])
case 'y':
case 'Y':
return 1;
return 0;
#include "interact.h.x"
int tty_fd = -1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment