summaryrefslogtreecommitdiffhomepage
path: root/src/pty/ntapi_pty_fd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pty/ntapi_pty_fd.c')
-rw-r--r--src/pty/ntapi_pty_fd.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/src/pty/ntapi_pty_fd.c b/src/pty/ntapi_pty_fd.c
index ed97418..3071482 100644
--- a/src/pty/ntapi_pty_fd.c
+++ b/src/pty/ntapi_pty_fd.c
@@ -309,3 +309,112 @@ int32_t __stdcall __ntapi_pty_close(nt_pty * pty)
return __ntapi_pty_free(pty);
}
+
+int32_t __stdcall __ntapi_pty_inherit_runtime_ctty(
+ __in void * hport,
+ __in_out nt_runtime_data * rtdata)
+{
+ int32_t status;
+ nt_pty_client_info client_info;
+
+ if (rtdata->stdin_type == NT_FILE_TYPE_PTY) {
+ client_info.any[0] = rtdata->ptyin[0];
+ client_info.any[1] = rtdata->ptyin[1];
+ client_info.any[2] = rtdata->ptyin[2];
+ client_info.any[3] = rtdata->ptyin[3];
+
+ if ((status = __ntapi_pty_inherit(
+ hport,
+ (nt_pty **)&rtdata->hstdin,
+ &client_info)))
+ return status;
+ }
+
+ if (rtdata->stdout_type == NT_FILE_TYPE_PTY) {
+ if ((rtdata->stdin_type == NT_FILE_TYPE_PTY)
+ && (rtdata->ptyout[0] == rtdata->ptyin[0])
+ && (rtdata->ptyout[1] == rtdata->ptyin[1])
+ && (rtdata->ptyout[2] == rtdata->ptyin[2])
+ && (rtdata->ptyout[3] == rtdata->ptyin[3])) {
+ rtdata->hstdout = rtdata->hstdin;
+
+ } else {
+ client_info.any[0] = rtdata->ptyout[0];
+ client_info.any[1] = rtdata->ptyout[1];
+ client_info.any[2] = rtdata->ptyout[2];
+ client_info.any[3] = rtdata->ptyout[3];
+
+ if ((status = __ntapi_pty_inherit(
+ hport,
+ (nt_pty **)&rtdata->hstdout,
+ &client_info)))
+ return status;
+ }
+ }
+
+ if (rtdata->stderr_type == NT_FILE_TYPE_PTY) {
+ if ((rtdata->stdin_type == NT_FILE_TYPE_PTY)
+ && (rtdata->ptyerr[0] == rtdata->ptyin[0])
+ && (rtdata->ptyerr[1] == rtdata->ptyin[1])
+ && (rtdata->ptyerr[2] == rtdata->ptyin[2])
+ && (rtdata->ptyerr[3] == rtdata->ptyin[3])) {
+ rtdata->hstderr = rtdata->hstdin;
+
+ } else if ((rtdata->stdout_type == NT_FILE_TYPE_PTY)
+ && (rtdata->ptyerr[0] == rtdata->ptyout[0])
+ && (rtdata->ptyerr[1] == rtdata->ptyout[1])
+ && (rtdata->ptyerr[2] == rtdata->ptyout[2])
+ && (rtdata->ptyerr[3] == rtdata->ptyout[3])) {
+ rtdata->hstderr = rtdata->hstdout;
+
+ } else {
+ client_info.any[0] = rtdata->ptyerr[0];
+ client_info.any[1] = rtdata->ptyerr[1];
+ client_info.any[2] = rtdata->ptyerr[2];
+ client_info.any[3] = rtdata->ptyerr[3];
+
+ if ((status = __ntapi_pty_inherit(
+ hport,
+ (nt_pty **)&rtdata->hstderr,
+ &client_info)))
+ return status;
+ }
+ }
+
+ /* hctty */
+ if ((rtdata->stdin_type == NT_FILE_TYPE_PTY)
+ && (rtdata->ptyctl[0] == rtdata->ptyin[0])
+ && (rtdata->ptyctl[1] == rtdata->ptyin[1])
+ && (rtdata->ptyctl[2] == rtdata->ptyin[2])
+ && (rtdata->ptyctl[3] == rtdata->ptyin[3])) {
+ rtdata->hctty = rtdata->hstdin;
+
+ } else if ((rtdata->stdout_type == NT_FILE_TYPE_PTY)
+ && (rtdata->ptyctl[0] == rtdata->ptyout[0])
+ && (rtdata->ptyctl[1] == rtdata->ptyout[1])
+ && (rtdata->ptyctl[2] == rtdata->ptyout[2])
+ && (rtdata->ptyctl[3] == rtdata->ptyout[3])) {
+ rtdata->hctty = rtdata->hstdout;
+
+ } else if ((rtdata->stderr_type == NT_FILE_TYPE_PTY)
+ && (rtdata->ptyctl[0] == rtdata->ptyerr[0])
+ && (rtdata->ptyctl[1] == rtdata->ptyerr[1])
+ && (rtdata->ptyctl[2] == rtdata->ptyerr[2])
+ && (rtdata->ptyctl[3] == rtdata->ptyerr[3])) {
+ rtdata->hctty = rtdata->hstderr;
+
+ } else {
+ client_info.any[0] = rtdata->ptyctl[0];
+ client_info.any[1] = rtdata->ptyctl[1];
+ client_info.any[2] = rtdata->ptyctl[2];
+ client_info.any[3] = rtdata->ptyctl[3];
+
+ if ((status = __ntapi_pty_inherit(
+ hport,
+ (nt_pty **)&rtdata->hctty,
+ &client_info)))
+ rtdata->hctty = 0;
+ }
+
+ return NT_STATUS_SUCCESS;
+}