| 1 |
root |
1.10 |
#ifndef LIBPTYTTY_H_ /* public libptytty header file */ |
| 2 |
|
|
#define LIBPTYTTY_H_ |
| 3 |
root |
1.1 |
|
| 4 |
root |
1.10 |
#ifdef __cplusplus |
| 5 |
root |
1.8 |
|
| 6 |
root |
1.12 |
// C++ API |
| 7 |
root |
1.8 |
|
| 8 |
root |
1.10 |
struct ptytty { |
| 9 |
root |
1.14 |
int pty; // pty file descriptor; connected to terminal emulator |
| 10 |
root |
1.10 |
int tty; // tty file descriptor; connected to child |
| 11 |
root |
1.1 |
|
| 12 |
root |
1.10 |
virtual ~ptytty () |
| 13 |
|
|
{ |
| 14 |
|
|
} |
| 15 |
root |
1.1 |
|
| 16 |
root |
1.10 |
virtual bool get () = 0; |
| 17 |
|
|
virtual void login (int cmd_pid, bool login_shell, const char *hostname) = 0; |
| 18 |
root |
1.1 |
|
| 19 |
root |
1.10 |
void close_tty (); |
| 20 |
|
|
bool make_controlling_tty (); |
| 21 |
|
|
void set_utf8_mode (bool on); |
| 22 |
root |
1.1 |
|
| 23 |
root |
1.13 |
static void sanitise_stdfd (); |
| 24 |
root |
1.10 |
static void init (); |
| 25 |
|
|
static ptytty *create (); // create a new pty object |
| 26 |
root |
1.6 |
|
| 27 |
root |
1.10 |
static void drop_privileges (); |
| 28 |
|
|
static void use_helper (); |
| 29 |
root |
1.4 |
|
| 30 |
root |
1.10 |
static bool send_fd (int socket, int fd); |
| 31 |
|
|
static int recv_fd (int socket); |
| 32 |
root |
1.4 |
|
| 33 |
root |
1.10 |
protected: |
| 34 |
root |
1.4 |
|
| 35 |
root |
1.10 |
ptytty () |
| 36 |
|
|
: pty(-1), tty(-1) |
| 37 |
|
|
{ |
| 38 |
|
|
} |
| 39 |
|
|
}; |
| 40 |
root |
1.1 |
|
| 41 |
root |
1.10 |
#else |
| 42 |
root |
1.8 |
|
| 43 |
root |
1.12 |
// C API |
| 44 |
root |
1.8 |
|
| 45 |
root |
1.10 |
typedef void *PTYTTY; |
| 46 |
root |
1.8 |
|
| 47 |
root |
1.10 |
int ptytty_pty (PTYTTY ptytty); |
| 48 |
|
|
int ptytty_tty (PTYTTY ptytty); |
| 49 |
|
|
void ptytty_delete (PTYTTY ptytty); |
| 50 |
|
|
int ptytty_get (PTYTTY ptytty); |
| 51 |
root |
1.11 |
void ptytty_login (PTYTTY ptytty, int cmd_pid, int login_shell, const char *hostname); |
| 52 |
root |
1.8 |
|
| 53 |
root |
1.10 |
void ptytty_close_tty (PTYTTY ptytty); |
| 54 |
|
|
int ptytty_make_controlling_tty (PTYTTY ptytty); |
| 55 |
|
|
void ptytty_set_utf8_mode (PTYTTY ptytty, int on); |
| 56 |
root |
1.8 |
|
| 57 |
root |
1.13 |
void ptytty_sanitise_stdfd (); |
| 58 |
root |
1.10 |
void ptytty_init (); |
| 59 |
|
|
PTYTTY ptytty_create (); |
| 60 |
root |
1.8 |
|
| 61 |
root |
1.10 |
void ptytty_drop_privileges (); |
| 62 |
|
|
void ptytty_use_helper (); |
| 63 |
root |
1.1 |
|
| 64 |
root |
1.10 |
#endif |
| 65 |
root |
1.9 |
|
| 66 |
root |
1.10 |
#endif |
| 67 |
root |
1.9 |
|