1 |
#ifndef PTYTTY_H |
2 |
#define PTYTTY_H |
3 |
|
4 |
#include "feature.h" |
5 |
|
6 |
#if defined(HAVE_GRANTPT) && defined(HAVE_UNLOCKPT) |
7 |
# if defined(PTYS_ARE_GETPT) || defined(PTYS_ARE_POSIX) || defined(PTYS_ARE_PTMX) |
8 |
# define NO_SETOWNER_TTYDEV 1 |
9 |
# endif |
10 |
#endif |
11 |
#if defined(__CYGWIN32__) |
12 |
# define NO_SETOWNER_TTYDEV 1 |
13 |
#endif |
14 |
|
15 |
#if UTMP_SUPPORT |
16 |
# if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX) |
17 |
# undef HAVE_UTMPX_H |
18 |
# undef HAVE_STRUCT_UTMPX |
19 |
# endif |
20 |
# if !defined(RXVT_UTMP_FILE) || !defined(HAVE_STRUCT_UTMP) |
21 |
# undef HAVE_UTMP_H |
22 |
# undef HAVE_STRUCT_UTMP |
23 |
# endif |
24 |
|
25 |
# ifdef HAVE_UTMPX_H |
26 |
# include <utmpx.h> |
27 |
# endif |
28 |
# ifdef HAVE_UTMP_H |
29 |
# include <utmp.h> |
30 |
# endif |
31 |
|
32 |
# if ! defined(HAVE_STRUCT_UTMPX) && ! defined(HAVE_STRUCT_UTMP) |
33 |
# error cannot build with utmp support - no utmp or utmpx struct found |
34 |
# endif |
35 |
|
36 |
# ifdef HAVE_LASTLOG_H |
37 |
# include <lastlog.h> |
38 |
# endif |
39 |
|
40 |
# include <pwd.h> |
41 |
|
42 |
# ifdef RXVT_UTMP_SYSV |
43 |
# ifndef USER_PROCESS |
44 |
# define USER_PROCESS 7 |
45 |
# endif |
46 |
# ifndef DEAD_PROCESS |
47 |
# define DEAD_PROCESS 8 |
48 |
# endif |
49 |
# endif |
50 |
|
51 |
#endif |
52 |
|
53 |
enum rxvt_privaction { IGNORE = 'i', SAVE = 's', RESTORE = 'r' }; |
54 |
|
55 |
struct rxvt_ptytty { |
56 |
int pty; // pty file descriptor; connected to rxvt |
57 |
int tty; // tty file descriptor; connected to child |
58 |
|
59 |
virtual ~rxvt_ptytty () |
60 |
{ |
61 |
// |
62 |
} |
63 |
|
64 |
virtual bool get () = 0; |
65 |
virtual void put () = 0; |
66 |
|
67 |
virtual void login (int cmd_pid, bool login_shell, const char *hostname) = 0; |
68 |
virtual void logout () = 0; |
69 |
|
70 |
void close_tty (); |
71 |
|
72 |
bool make_controlling_tty (); |
73 |
void set_utf8_mode (bool on); |
74 |
}; |
75 |
|
76 |
struct rxvt_ptytty_unix : rxvt_ptytty { |
77 |
char *name; |
78 |
|
79 |
#ifndef RESET_TTY_TO_COMMON_DEFAULTS |
80 |
struct stat savestat; /* original status of our tty */ |
81 |
#endif |
82 |
#ifndef NO_SETOWNER_TTYDEV |
83 |
void privileges (rxvt_privaction action); |
84 |
bool saved; |
85 |
#endif |
86 |
public: |
87 |
|
88 |
rxvt_ptytty_unix (); |
89 |
~rxvt_ptytty_unix (); |
90 |
|
91 |
#if UTMP_SUPPORT |
92 |
int utmp_pos; |
93 |
int cmd_pid; |
94 |
bool login_shell; |
95 |
|
96 |
#ifdef HAVE_STRUCT_UTMP |
97 |
struct utmp ut; |
98 |
#endif |
99 |
#ifdef HAVE_STRUCT_UTMPX |
100 |
struct utmpx utx; |
101 |
#endif |
102 |
#if (defined(HAVE_STRUCT_UTMP) && defined(HAVE_UTMP_PID)) || defined(HAVE_STRUCT_UTMPX) |
103 |
char ut_id[5]; |
104 |
#endif |
105 |
|
106 |
bool get (); |
107 |
void put (); |
108 |
|
109 |
void login (int cmd_pid, bool login_shell, const char *hostname); |
110 |
void logout (); |
111 |
#endif |
112 |
}; |
113 |
|
114 |
#endif |
115 |
|