From dd4b8358d86376df50adcf310676f347042c7445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Wed, 15 Nov 2000 17:45:24 +0100 Subject: [PATCH] * src/interact.c: Moved unix_interact class to unix_interact.c. Rev: src/interact.c:1.3 --- src/interact.c | 86 ++------------------------------------------------ 1 file changed, 3 insertions(+), 83 deletions(-) diff --git a/src/interact.c b/src/interact.c index 2204a95fc..c23e16d96 100644 --- a/src/interact.c +++ b/src/interact.c @@ -38,89 +38,9 @@ #include <errno.h> #include <fcntl.h> -#if 0 -/* GABA: - (class - (name interact_unix) - (super abstract_interact) - (vars - (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); - - lsh_string_free(prompt); - - 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); - UINT8 buffer[TTY_BUFSIZE]; - const struct exception *e; - - if ( (self->tty_fd < 0) || quiet_flag) - { - if (free) - lsh_string_free(s); - return def; - } - - e = write_raw(self->tty_fd, s->length, s->data); - - if (free) - lsh_string_free(s); - - if (e) - return def; - - if (!tty_read_line(TTY_BUFSIZE, buffer)) - return def; - - switch (buffer[0]) - { - case 'y': - case 'Y': - return 1; - default: - return 0; - } -} - -#endif +#define GABA_DEFINE +#include "interact.h.x" +#undef GABA_DEFINE int tty_fd = -1; -- GitLab