mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Merge assorted pterm fixes from 'pre-0.77'.
This commit is contained in:
commit
751671d73a
@ -759,11 +759,13 @@ int cmdline_process_param(const char *p, char *value,
|
||||
|
||||
if (!strcmp(p, "-4") || !strcmp(p, "-ipv4")) {
|
||||
RETURN(1);
|
||||
UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);
|
||||
SAVEABLE(1);
|
||||
conf_set_int(conf, CONF_addressfamily, ADDRTYPE_IPV4);
|
||||
}
|
||||
if (!strcmp(p, "-6") || !strcmp(p, "-ipv6")) {
|
||||
RETURN(1);
|
||||
UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);
|
||||
SAVEABLE(1);
|
||||
conf_set_int(conf, CONF_addressfamily, ADDRTYPE_IPV6);
|
||||
}
|
||||
|
@ -25,6 +25,27 @@ struct ConPTY {
|
||||
Backend backend;
|
||||
};
|
||||
|
||||
DECL_WINDOWS_FUNCTION(static, HRESULT, CreatePseudoConsole,
|
||||
(COORD, HANDLE, HANDLE, DWORD, HPCON *));
|
||||
DECL_WINDOWS_FUNCTION(static, void, ClosePseudoConsole, (HPCON));
|
||||
DECL_WINDOWS_FUNCTION(static, HRESULT, ResizePseudoConsole, (HPCON, COORD));
|
||||
|
||||
static bool init_conpty_api(void)
|
||||
{
|
||||
static bool tried = false;
|
||||
if (!tried) {
|
||||
tried = true;
|
||||
HMODULE kernel32_module = load_system32_dll("kernel32.dll");
|
||||
GET_WINDOWS_FUNCTION(kernel32_module, CreatePseudoConsole);
|
||||
GET_WINDOWS_FUNCTION(kernel32_module, ClosePseudoConsole);
|
||||
GET_WINDOWS_FUNCTION(kernel32_module, ResizePseudoConsole);
|
||||
}
|
||||
|
||||
return (p_CreatePseudoConsole != NULL &&
|
||||
p_ClosePseudoConsole != NULL &&
|
||||
p_ResizePseudoConsole != NULL);
|
||||
}
|
||||
|
||||
static void conpty_terminate(ConPTY *conpty)
|
||||
{
|
||||
if (conpty->out) {
|
||||
@ -49,7 +70,7 @@ static void conpty_terminate(ConPTY *conpty)
|
||||
conpty->hprocess = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
if (conpty->pseudoconsole != INVALID_HANDLE_VALUE) {
|
||||
ClosePseudoConsole(conpty->pseudoconsole);
|
||||
p_ClosePseudoConsole(conpty->pseudoconsole);
|
||||
conpty->pseudoconsole = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
@ -78,7 +99,7 @@ static void conpty_process_wait_callback(void *vctx)
|
||||
* as things clean themselves up.
|
||||
*/
|
||||
if (conpty->pseudoconsole != INVALID_HANDLE_VALUE) {
|
||||
ClosePseudoConsole(conpty->pseudoconsole);
|
||||
p_ClosePseudoConsole(conpty->pseudoconsole);
|
||||
conpty->pseudoconsole = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
@ -158,6 +179,12 @@ static char *conpty_init(const BackendVtable *vt, Seat *seat,
|
||||
STARTUPINFOEX si;
|
||||
memset(&si, 0, sizeof(si));
|
||||
|
||||
if (!init_conpty_api()) {
|
||||
err = dupprintf("Pseudo-console API is not available on this "
|
||||
"Windows system");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!CreatePipe(&in_r, &in_w, NULL, 0)) {
|
||||
err = dupprintf("CreatePipe: %s", win_strerror(GetLastError()));
|
||||
goto out;
|
||||
@ -171,7 +198,7 @@ static char *conpty_init(const BackendVtable *vt, Seat *seat,
|
||||
size.X = conf_get_int(conf, CONF_width);
|
||||
size.Y = conf_get_int(conf, CONF_height);
|
||||
|
||||
HRESULT result = CreatePseudoConsole(size, in_r, out_w, 0, &pcon);
|
||||
HRESULT result = p_CreatePseudoConsole(size, in_r, out_w, 0, &pcon);
|
||||
if (FAILED(result)) {
|
||||
if (HRESULT_FACILITY(result) == FACILITY_WIN32)
|
||||
err = dupprintf("CreatePseudoConsole: %s",
|
||||
@ -190,7 +217,7 @@ static char *conpty_init(const BackendVtable *vt, Seat *seat,
|
||||
|
||||
si.StartupInfo.cb = sizeof(si);
|
||||
|
||||
size_t attrsize = 0;
|
||||
SIZE_T attrsize = 0;
|
||||
InitializeProcThreadAttributeList(NULL, 1, 0, &attrsize);
|
||||
si.lpAttributeList = smalloc(attrsize);
|
||||
if (!InitializeProcThreadAttributeList(
|
||||
@ -271,7 +298,7 @@ static char *conpty_init(const BackendVtable *vt, Seat *seat,
|
||||
if (out_w != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(out_w);
|
||||
if (pcon_needs_cleanup)
|
||||
ClosePseudoConsole(pcon);
|
||||
p_ClosePseudoConsole(pcon);
|
||||
sfree(si.lpAttributeList);
|
||||
return err;
|
||||
}
|
||||
@ -311,7 +338,7 @@ static void conpty_size(Backend *be, int width, int height)
|
||||
COORD size;
|
||||
size.X = width;
|
||||
size.Y = height;
|
||||
ResizePseudoConsole(conpty->pseudoconsole, size);
|
||||
p_ResizePseudoConsole(conpty->pseudoconsole, size);
|
||||
}
|
||||
|
||||
static void conpty_special(Backend *be, SessionSpecialCode code, int arg)
|
||||
|
@ -1,6 +1,10 @@
|
||||
#include "putty.h"
|
||||
#include "storage.h"
|
||||
|
||||
const unsigned cmdline_tooltype =
|
||||
TOOLTYPE_NONNETWORK |
|
||||
TOOLTYPE_NO_VERBOSE_OPTION;
|
||||
|
||||
void gui_term_process_cmdline(Conf *conf, char *cmdline)
|
||||
{
|
||||
do_defaults(NULL, conf);
|
||||
@ -16,8 +20,16 @@ void gui_term_process_cmdline(Conf *conf, char *cmdline)
|
||||
split_into_argv(cmdline, &argc, &argv, &argstart);
|
||||
|
||||
for (int i = 0; i < argc; i++) {
|
||||
const char *arg = argv[i];
|
||||
if (!strcmp(arg, "-e")) {
|
||||
char *arg = argv[i];
|
||||
int retd = cmdline_process_param(
|
||||
arg, i+1<argc?argv[i+1]:NULL, 1, conf);
|
||||
if (retd == -2) {
|
||||
cmdline_error("option \"%s\" requires an argument", arg);
|
||||
} else if (retd == 2) {
|
||||
i++; /* skip next argument */
|
||||
} else if (retd == 1) {
|
||||
continue; /* nothing further needs doing */
|
||||
} else if (!strcmp(arg, "-e")) {
|
||||
if (i+1 < argc) {
|
||||
/* The command to execute is taken to be the unparsed
|
||||
* version of the whole remainder of the command line. */
|
||||
@ -33,6 +45,8 @@ void gui_term_process_cmdline(Conf *conf, char *cmdline)
|
||||
}
|
||||
}
|
||||
|
||||
cmdline_run_saved(conf);
|
||||
|
||||
conf_set_int(conf, CONF_sharrow_type, SHARROW_BITMAP);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,11 @@ extern const char *dialog_box_demo_screenshot_filename;
|
||||
static strbuf *demo_terminal_data = NULL;
|
||||
static const char *terminal_demo_screenshot_filename;
|
||||
|
||||
const unsigned cmdline_tooltype =
|
||||
TOOLTYPE_HOST_ARG |
|
||||
TOOLTYPE_PORT_ARG |
|
||||
TOOLTYPE_NO_VERBOSE_OPTION;
|
||||
|
||||
void gui_term_process_cmdline(Conf *conf, char *cmdline)
|
||||
{
|
||||
char *p;
|
||||
|
@ -515,11 +515,6 @@ char *terminal_window_class_a(void)
|
||||
return classname;
|
||||
}
|
||||
|
||||
const unsigned cmdline_tooltype =
|
||||
TOOLTYPE_HOST_ARG |
|
||||
TOOLTYPE_PORT_ARG |
|
||||
TOOLTYPE_NO_VERBOSE_OPTION;
|
||||
|
||||
HINSTANCE hinst;
|
||||
|
||||
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
|
Loading…
Reference in New Issue
Block a user