Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LSH
lsh
Commits
dd4b8358
Commit
dd4b8358
authored
Nov 15, 2000
by
Niels Möller
Browse files
* src/interact.c: Moved unix_interact class to unix_interact.c.
Rev: src/interact.c:1.3
parent
f728949a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/interact.c
View file @
dd4b8358
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment