Debian Codegraph @

lib/kptyprocess.h

raw symbols SCIP
1 /*
2 * This file is a part of QTerminal - http://gitorious.org/qterminal
3 *
4 * This file was un-linked from KDE and modified
5 * by Maxim Bourmistrov <[email protected]>
6 *
7 */
8
9 /*
10 This file is part of the KDE libraries
11
12 Copyright (C) 2007 Oswald Buddenhagen <[email protected]>
13
14 This library is free software; you can redistribute it and/or
15 modify it under the terms of the GNU Library General Public
16 License as published by the Free Software Foundation; either
17 version 2 of the License, or (at your option) any later version.
18
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Library General Public License for more details.
23
24 You should have received a copy of the GNU Library General Public License
25 along with this library; see the file COPYING.LIB. If not, write to
26 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 Boston, MA 02110-1301, USA.
28 */
29
30 #ifndef KPTYPROCESS_H
31 #define KPTYPROCESS_Hcxx . . $ `lib/kptyprocess.h:31:9`!
32
33 #include "kprocess.h"cxx . . $ `<file>/lib/kprocess.h`/
34 #include "kptydevice.h"cxx . . $ `<file>/lib/kptydevice.h`/
35
36 #include <csignal>
37
38 class KPtyDevicecxx . . $ KPtyDevice#;
39
40 class KPtyProcessPrivatecxx . . $ KPtyProcessPrivate#;
41
42 /**
43 * This class extends KProcess by support for PTYs (pseudo TTYs).
44 *
45 * The PTY is opened as soon as the class is instantiated. Verify that
46 * it was opened successfully by checking that pty()->masterFd() is not -1.
47 *
48 * The PTY is always made the process' controlling TTY.
49 * Utmp registration and connecting the stdio handles to the PTY are optional.
50 *
51 * No attempt to integrate with QProcess' waitFor*() functions was made,
52 * for it is impossible. Note that execute() does not work with the PTY, too.
53 * Use the PTY device's waitFor*() functions or use it asynchronously.
54 *
55 * @author Oswald Buddenhagen <[email protected]>
56 */
57 class KPtyProcesscxx . . $ KPtyProcess# : public KProcesscxx . . $ KProcess#
58 {
59 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
60 Q_DECLARE_PRIVATEcxx . . $ KProcess#d_ptr.(KPtyProcess)
61
62 public:
63 enum PtyChannelFlagcxx . . $ KPtyProcess#PtyChannelFlag# {
64 NoChannelscxx . . $ KPtyProcess#NoChannels. = 0, /**< The PTY is not connected to any channel. */
65 StdinChannelcxx . . $ KPtyProcess#StdinChannel. = 1, /**< Connect PTY to stdin. */
66 StdoutChannelcxx . . $ KPtyProcess#StdoutChannel. = 2, /**< Connect PTY to stdout. */
67 StderrChannelcxx . . $ KPtyProcess#StderrChannel. = 4, /**< Connect PTY to stderr. */
68 AllOutputChannelscxx . . $ KPtyProcess#AllOutputChannels. = 6, /**< Connect PTY to all output channels. */
69 AllChannelscxx . . $ KPtyProcess#AllChannels. = 7 /**< Connect PTY to all channels. */
70 };
71
72 Q_DECLARE_FLAGScxx . . $ KPtyProcess#PtyChannels#(PtyChannels, PtyChannelFlag)
73
74 /**
75 * Constructor
76 */
77 explicit KPtyProcesscxx . . $ KPtyProcess#KPtyProcess(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent = nullptr);
78
79 /**
80 * Construct a process using an open pty master.
81 *
82 * @param ptyMasterFd an open pty master file descriptor.
83 * The process does not take ownership of the descriptor;
84 * it will not be automatically closed at any point.
85 */
86 KPtyProcesscxx . . $ KPtyProcess#KPtyProcess(1ee1e1ac455d3e6e).(int ptyMasterFd, QObjectcxx . . $ QObject# *parent = nullptr);
87
88 /**
89 * Destructor
90 */
91 ~cxx . . $ KPtyProcess#`~KPtyProcess`(ced63f7c635d850d).KPtyProcesscxx . . $ KPtyProcess#() override;
92
93 /**
94 * Set to which channels the PTY should be assigned.
95 *
96 * This function must be called before starting the process.
97 *
98 * @param channels the output channel handling mode
99 */
100 void setPtyChannelscxx . . $ KPtyProcess#setPtyChannels(fe45b12a10cd71c6).(PtyChannelscxx . . $ KPtyProcess#PtyChannels# channels);
101
102 bool isRunningcxx . . $ KPtyProcess#isRunning(50ce9a9e25b4a850).() const
103 {
104 bool rval;
105 (processIdcxx . . $ QProcess#processId(98833e9ab7de59a4).() > 0) ? rval= true : rval= false;
106 return rval;
107
108 }
109 /**
110 * Query to which channels the PTY is assigned.
111 *
112 * @return the output channel handling mode
113 */
114 PtyChannelscxx . . $ KPtyProcess#PtyChannels# ptyChannelscxx . . $ KPtyProcess#ptyChannels(a0952226395b2ab1).() const;
115
116 /**
117 * Set whether to register the process as a TTY login in utmp.
118 *
119 * Utmp is disabled by default.
120 * It should enabled for interactively fed processes, like terminal
121 * emulations.
122 *
123 * This function must be called before starting the process.
124 *
125 * @param value whether to register in utmp.
126 */
127 void setUseUtmpcxx . . $ KPtyProcess#setUseUtmp(b45ddcbc8423892c).(bool value);
128
129 /**
130 * Get whether to register the process as a TTY login in utmp.
131 *
132 * @return whether to register in utmp
133 */
134 bool isUseUtmpcxx . . $ KPtyProcess#isUseUtmp(50ce9a9e25b4a850).() const;
135
136 /**
137 * Get the PTY device of this process.
138 *
139 * @return the PTY device
140 */
141 KPtyDevicecxx . . $ KPtyDevice# *ptycxx . . $ KPtyProcess#pty(e0e5ab7122928a46).() const;
142
143 protected:
144 /**
145 * @reimp
146 */
147 void setupChildProcesscxx . . $ KPtyProcess#setupChildProcess(49f6e7a06ebc5aa8).() override;
148
149 private:
150 Q_PRIVATE_SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:94:10`!(d_func(), void _k_onStateChanged(QProcess::ProcessState))
151 };
152
153
154 //////////////////
155 // private data //
156 //////////////////
157
158 class KPtyProcessPrivatecxx . . $ KPtyProcessPrivate# : public KProcessPrivatecxx . . $ KProcessPrivate# {
159 public:
160 KPtyProcessPrivatecxx . . $ KPtyProcessPrivate#KPtyProcessPrivate(49f6e7a06ebc5aa8).() :
161 ptyChannelscxx . . $ QFlags#QFlags(93d577a3e9528307).(KPtyProcesscxx . . $ KPtyProcess#::NoChannelscxx . . $ KPtyProcess#NoChannels.),
162 addUtmpcxx . . $ KPtyProcessPrivate#addUtmp.(false)
163 {
164 }
165
166 void _k_onStateChangedcxx . . $ KPtyProcessPrivate#_k_onStateChanged(df51663b8336d33e).(QProcesscxx . . $ QProcess#::ProcessStatecxx . . $ QProcess#ProcessState# newState)
167 {
168 if (newState == QProcesscxx . . $ QProcess#::NotRunningcxx . . $ QProcess#NotRunning. && addUtmpcxx . . $ KPtyProcessPrivate#addUtmp.)
169 ptycxx . . $ KPtyProcessPrivate#pty.->logoutcxx . . $ KPty#logout(49f6e7a06ebc5aa8).();
170 }
171
172 KPtyDevicecxx . . $ KPtyDevice# *ptycxx . . $ KPtyProcessPrivate#pty.;
173 KPtyProcesscxx . . $ KPtyProcess#::PtyChannelscxx . . $ KPtyProcess#PtyChannels# ptyChannelscxx . . $ KPtyProcessPrivate#ptyChannels.;
174 bool addUtmpcxx . . $ KPtyProcessPrivate#addUtmp. : 1;
175 };
176
177 Q_DECLARE_OPERATORS_FOR_FLAGScxx . . $ `operator|`(678ae74e48b43f2).(KPtyProcess::PtyChannels)
178
179 #endif