const char *a2_get_tty_name(struct annotate_two *a2) { if (!a2) { logger_write_pos(logger, __FILE__, __LINE__, "a2_get_tty_name failed"); return NULL; } return pty_pair_get_slavename(a2->pty_pair); }
int a2_open_new_tty(struct annotate_two *a2, int *inferior_stdin, int *inferior_stdout) { if (a2->pty_pair) pty_pair_destroy(a2->pty_pair); a2->pty_pair = pty_pair_create(); if (!a2->pty_pair) { logger_write_pos(logger, __FILE__, __LINE__, "pty_pair_create failed"); return -1; } *inferior_stdin = pty_pair_get_masterfd(a2->pty_pair); *inferior_stdout = pty_pair_get_masterfd(a2->pty_pair); commands_issue_command(a2, ANNOTATE_TTY, pty_pair_get_slavename(a2->pty_pair), 1); return 0; }
static int a2_set_inferior_tty(void *ctx) { struct annotate_two *a2 = (struct annotate_two *) ctx; if (!a2) { logger_write_pos(logger, __FILE__, __LINE__, "a2_set_inferior_tty error"); return -1; } if (commands_issue_command(a2->c, a2->client_command_list, ANNOTATE_TTY, pty_pair_get_slavename(a2->pty_pair), 0) == -1) { logger_write_pos(logger, __FILE__, __LINE__, "commands_issue_command error"); return -1; } return 0; }
static int tgdb_open_new_tty(struct tgdb *tgdb, int *inferior_stdin, int *inferior_stdout) { if (tgdb->pty_pair) pty_pair_destroy(tgdb->pty_pair); tgdb->pty_pair = pty_pair_create(); if (!tgdb->pty_pair) { clog_error(CLOG_CGDB, "pty_pair_create failed"); return -1; } *inferior_stdin = pty_pair_get_masterfd(tgdb->pty_pair); *inferior_stdout = pty_pair_get_masterfd(tgdb->pty_pair); tgdb_request_ptr request_ptr; request_ptr = (tgdb_request_ptr)cgdb_malloc(sizeof (struct tgdb_request)); request_ptr->header = TGDB_REQUEST_TTY; request_ptr->choice.tty_command.slavename = pty_pair_get_slavename(tgdb->pty_pair); tgdb_run_or_queue_request(tgdb, request_ptr, true); return 0; }
const char *tgdb_tty_name(struct tgdb *tgdb) { return pty_pair_get_slavename(tgdb->pty_pair); }