version 1.20, 2009/08/11 19:32:25 |
version 1.21, 2009/08/11 20:29:05 |
|
|
tty->log_fd = -1; |
tty->log_fd = -1; |
|
|
tty->term = tty_term_find(tty->termname, tty->fd, overrides, cause); |
tty->term = tty_term_find(tty->termname, tty->fd, overrides, cause); |
if (tty->term == NULL) |
if (tty->term == NULL) { |
goto error; |
tty_close(tty); |
|
return (-1); |
|
} |
|
tty->flags |= TTY_OPENED; |
|
|
tty->in = buffer_create(BUFSIZ); |
tty->in = buffer_create(BUFSIZ); |
tty->out = buffer_create(BUFSIZ); |
tty->out = buffer_create(BUFSIZ); |
|
|
tty_fill_acs(tty); |
tty_fill_acs(tty); |
|
|
return (0); |
return (0); |
|
|
error: |
|
close(tty->fd); |
|
tty->fd = -1; |
|
|
|
return (-1); |
|
} |
} |
|
|
void |
void |
|
|
void |
void |
tty_close(struct tty *tty) |
tty_close(struct tty *tty) |
{ |
{ |
if (tty->fd == -1) |
|
return; |
|
|
|
if (tty->log_fd != -1) { |
if (tty->log_fd != -1) { |
close(tty->log_fd); |
close(tty->log_fd); |
tty->log_fd = -1; |
tty->log_fd = -1; |
|
|
|
|
tty_stop_tty(tty); |
tty_stop_tty(tty); |
|
|
tty_term_free(tty->term); |
if (tty->flags & TTY_OPENED) { |
tty_keys_free(tty); |
tty_term_free(tty->term); |
|
tty_keys_free(tty); |
|
|
close(tty->fd); |
buffer_destroy(tty->in); |
tty->fd = -1; |
buffer_destroy(tty->out); |
|
|
buffer_destroy(tty->in); |
tty->flags &= ~TTY_OPENED; |
buffer_destroy(tty->out); |
} |
|
|
|
if (tty->fd != -1) { |
|
close(tty->fd); |
|
tty->fd = -1; |
|
} |
} |
} |
|
|
void |
void |