| 1 |
/* |
| 2 |
* Copyright (c) 2016 Ryan Prichard |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 |
* of this software and associated documentation files (the "Software"), to |
| 6 |
* deal in the Software without restriction, including without limitation the |
| 7 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 8 |
* sell copies of the Software, and to permit persons to whom the Software is |
| 9 |
* furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included in |
| 12 |
* all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 19 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 20 |
* IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef WINPTY_CONSTANTS_H |
| 24 |
#define WINPTY_CONSTANTS_H |
| 25 |
|
| 26 |
/* |
| 27 |
* You may want to include winpty.h instead, which includes this header. |
| 28 |
* |
| 29 |
* This file is split out from winpty.h so that the agent can access the |
| 30 |
* winpty flags without also declaring the libwinpty APIs. |
| 31 |
*/ |
| 32 |
|
| 33 |
/***************************************************************************** |
| 34 |
* Error codes. */ |
| 35 |
|
| 36 |
#define WINPTY_ERROR_SUCCESS 0 |
| 37 |
#define WINPTY_ERROR_OUT_OF_MEMORY 1 |
| 38 |
#define WINPTY_ERROR_SPAWN_CREATE_PROCESS_FAILED 2 |
| 39 |
#define WINPTY_ERROR_LOST_CONNECTION 3 |
| 40 |
#define WINPTY_ERROR_AGENT_EXE_MISSING 4 |
| 41 |
#define WINPTY_ERROR_UNSPECIFIED 5 |
| 42 |
#define WINPTY_ERROR_AGENT_DIED 6 |
| 43 |
#define WINPTY_ERROR_AGENT_TIMEOUT 7 |
| 44 |
#define WINPTY_ERROR_AGENT_CREATION_FAILED 8 |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
/***************************************************************************** |
| 49 |
* Configuration of a new agent. */ |
| 50 |
|
| 51 |
/* Create a new screen buffer (connected to the "conerr" terminal pipe) and |
| 52 |
* pass it to child processes as the STDERR handle. This flag also prevents |
| 53 |
* the agent from reopening CONOUT$ when it polls -- regardless of whether the |
| 54 |
* active screen buffer changes, winpty continues to monitor the original |
| 55 |
* primary screen buffer. */ |
| 56 |
#define WINPTY_FLAG_CONERR 0x1ull |
| 57 |
|
| 58 |
/* Don't output escape sequences. */ |
| 59 |
#define WINPTY_FLAG_PLAIN_OUTPUT 0x2ull |
| 60 |
|
| 61 |
/* Do output color escape sequences. These escapes are output by default, but |
| 62 |
* are suppressed with WINPTY_FLAG_PLAIN_OUTPUT. Use this flag to reenable |
| 63 |
* them. */ |
| 64 |
#define WINPTY_FLAG_COLOR_ESCAPES 0x4ull |
| 65 |
|
| 66 |
/* On XP and Vista, winpty needs to put the hidden console on a desktop in a |
| 67 |
* service window station so that its polling does not interfere with other |
| 68 |
* (visible) console windows. To create this desktop, it must change the |
| 69 |
* process' window station (i.e. SetProcessWindowStation) for the duration of |
| 70 |
* the winpty_open call. In theory, this change could interfere with the |
| 71 |
* winpty client (e.g. other threads, spawning children), so winpty by default |
| 72 |
* spawns a special agent process to create the hidden desktop. Spawning |
| 73 |
* processes on Windows is slow, though, so if |
| 74 |
* WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION is set, winpty changes this |
| 75 |
* process' window station instead. |
| 76 |
* See https://github.com/rprichard/winpty/issues/58. */ |
| 77 |
#define WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION 0x8ull |
| 78 |
|
| 79 |
#define WINPTY_FLAG_MASK (0ull \ |
| 80 |
| WINPTY_FLAG_CONERR \ |
| 81 |
| WINPTY_FLAG_PLAIN_OUTPUT \ |
| 82 |
| WINPTY_FLAG_COLOR_ESCAPES \ |
| 83 |
| WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION \ |
| 84 |
) |
| 85 |
|
| 86 |
/* QuickEdit mode is initially disabled, and the agent does not send mouse |
| 87 |
* mode sequences to the terminal. If it receives mouse input, though, it |
| 88 |
* still writes MOUSE_EVENT_RECORD values into CONIN. */ |
| 89 |
#define WINPTY_MOUSE_MODE_NONE 0 |
| 90 |
|
| 91 |
/* QuickEdit mode is initially enabled. As CONIN enters or leaves mouse |
| 92 |
* input mode (i.e. where ENABLE_MOUSE_INPUT is on and ENABLE_QUICK_EDIT_MODE |
| 93 |
* is off), the agent enables or disables mouse input on the terminal. |
| 94 |
* |
| 95 |
* This is the default mode. */ |
| 96 |
#define WINPTY_MOUSE_MODE_AUTO 1 |
| 97 |
|
| 98 |
/* QuickEdit mode is initially disabled, and the agent enables the terminal's |
| 99 |
* mouse input mode. It does not disable terminal mouse mode (until exit). */ |
| 100 |
#define WINPTY_MOUSE_MODE_FORCE 2 |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
/***************************************************************************** |
| 105 |
* winpty agent RPC call: process creation. */ |
| 106 |
|
| 107 |
/* If the spawn is marked "auto-shutdown", then the agent shuts down console |
| 108 |
* output once the process exits. The agent stops polling for new console |
| 109 |
* output, and once all pending data has been written to the output pipe, the |
| 110 |
* agent closes the pipe. (At that point, the pipe may still have data in it, |
| 111 |
* which the client may read. Once all the data has been read, further reads |
| 112 |
* return EOF.) */ |
| 113 |
#define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ull |
| 114 |
|
| 115 |
/* After the agent shuts down output, and after all output has been written |
| 116 |
* into the pipe(s), exit the agent by closing the console. If there any |
| 117 |
* surviving processes still attached to the console, they are killed. |
| 118 |
* |
| 119 |
* Note: With this flag, an RPC call (e.g. winpty_set_size) issued after the |
| 120 |
* agent exits will fail with an I/O or dead-agent error. */ |
| 121 |
#define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull |
| 122 |
|
| 123 |
/* All the spawn flags. */ |
| 124 |
#define WINPTY_SPAWN_FLAG_MASK (0ull \ |
| 125 |
| WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN \ |
| 126 |
| WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN \ |
| 127 |
) |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
#endif /* WINPTY_CONSTANTS_H */ |