X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/a094ae434ec1d6a0f69af9b3ef6fbeb40fa96d92..156686ef42c3f6940045f33fc350b806bcbc7f52:/settings.c diff --git a/settings.c b/settings.c index a5414419..e1bfbc3a 100644 --- a/settings.c +++ b/settings.c @@ -3,14 +3,8 @@ */ #include -#ifndef AUTO_WINSOCK -#ifdef WINSOCK_TWO -#include -#else -#include -#endif -#endif #include +#include #include "putty.h" #include "storage.h" @@ -38,6 +32,8 @@ void save_settings (char *section, int do_host, Config *cfg) { if (do_host) { write_setting_s (sesskey, "HostName", cfg->host); write_setting_i (sesskey, "PortNumber", cfg->port); + write_setting_s (sesskey, "LogFileName", cfg->logfilename); + write_setting_i (sesskey, "LogType", cfg->logtype); p = "raw"; for (i = 0; backends[i].name != NULL; i++) if (backends[i].protocol == cfg->protocol) { @@ -46,9 +42,10 @@ void save_settings (char *section, int do_host, Config *cfg) { } write_setting_s (sesskey, "Protocol", p); } - write_setting_i (sesskey, "CloseOnExit", !!cfg->close_on_exit); + write_setting_i (sesskey, "CloseOnExit", cfg->close_on_exit); write_setting_i (sesskey, "WarnOnClose", !!cfg->warn_on_close); - write_setting_i (sesskey, "PingInterval", cfg->ping_interval); + write_setting_i (sesskey, "PingInterval", cfg->ping_interval / 60); /* minutes */ + write_setting_i (sesskey, "PingIntervalSecs", cfg->ping_interval % 60); /* seconds */ write_setting_s (sesskey, "TerminalType", cfg->termtype); write_setting_s (sesskey, "TerminalSpeed", cfg->termspeed); { @@ -71,11 +68,15 @@ void save_settings (char *section, int do_host, Config *cfg) { write_setting_s (sesskey, "Environment", buf); } write_setting_s (sesskey, "UserName", cfg->username); + write_setting_s (sesskey, "LocalUserName", cfg->localusername); write_setting_i (sesskey, "NoPTY", cfg->nopty); + write_setting_i (sesskey, "Compression", cfg->compression); write_setting_i (sesskey, "AgentFwd", cfg->agentfwd); - write_setting_s (sesskey, "RemoteCmd", cfg->remote_cmd); - write_setting_s (sesskey, "Cipher", cfg->cipher == CIPHER_BLOWFISH ? "blowfish" : - cfg->cipher == CIPHER_DES ? "des" : "3des"); + write_setting_s (sesskey, "Cipher", + cfg->cipher == CIPHER_BLOWFISH ? "blowfish" : + cfg->cipher == CIPHER_DES ? "des" : + cfg->cipher == CIPHER_AES ? "aes" : + "3des"); write_setting_i (sesskey, "AuthTIS", cfg->try_tis_auth); write_setting_i (sesskey, "SshProt", cfg->sshprot); write_setting_i (sesskey, "BuggyMAC", cfg->buggymac); @@ -85,6 +86,8 @@ void save_settings (char *section, int do_host, Config *cfg) { write_setting_i (sesskey, "BackspaceIsDelete", cfg->bksp_is_delete); write_setting_i (sesskey, "RXVTHomeEnd", cfg->rxvt_homeend); write_setting_i (sesskey, "LinuxFunctionKeys", cfg->funky_type); + write_setting_i (sesskey, "NoApplicationKeys", cfg->no_applic_k); + write_setting_i (sesskey, "NoApplicationCursors", cfg->no_applic_c); write_setting_i (sesskey, "ApplicationCursorKeys", cfg->app_cursor); write_setting_i (sesskey, "ApplicationKeypad", cfg->app_keypad); write_setting_i (sesskey, "NetHackKeypad", cfg->nethack_keypad); @@ -92,9 +95,19 @@ void save_settings (char *section, int do_host, Config *cfg) { write_setting_i (sesskey, "AltSpace", cfg->alt_space); write_setting_i (sesskey, "AltOnly", cfg->alt_only); write_setting_i (sesskey, "ComposeKey", cfg->compose_key); - write_setting_i (sesskey, "LdiscTerm", cfg->ldisc_term); + write_setting_i (sesskey, "CtrlAltKeys", cfg->ctrlaltkeys); + write_setting_i (sesskey, "LocalEcho", cfg->localecho); + write_setting_i (sesskey, "LocalEdit", cfg->localedit); + write_setting_s (sesskey, "Answerback", cfg->answerback); + write_setting_i (sesskey, "AlwaysOnTop", cfg->alwaysontop); + write_setting_i (sesskey, "HideMousePtr", cfg->hide_mouseptr); + write_setting_i (sesskey, "CurType", cfg->cursor_type); write_setting_i (sesskey, "BlinkCur", cfg->blink_cur); write_setting_i (sesskey, "Beep", cfg->beep); + write_setting_i (sesskey, "BellOverload", cfg->bellovl); + write_setting_i (sesskey, "BellOverloadN", cfg->bellovl_n); + write_setting_i (sesskey, "BellOverloadT", cfg->bellovl_t); + write_setting_i (sesskey, "BellOverloadS", cfg->bellovl_s); write_setting_i (sesskey, "ScrollbackLines", cfg->savelines); write_setting_i (sesskey, "DECOriginMode", cfg->dec_om); write_setting_i (sesskey, "AutoWrapMode", cfg->wrap_mode); @@ -117,6 +130,7 @@ void save_settings (char *section, int do_host, Config *cfg) { cfg->colours[i][1], cfg->colours[i][2]); write_setting_s (sesskey, buf, buf2); } + write_setting_i (sesskey, "RawCNP", cfg->rawcnp); write_setting_i (sesskey, "MouseIsXterm", cfg->mouse_is_xterm); for (i=0; i<256; i+=32) { char buf[20], buf2[256]; @@ -139,6 +153,8 @@ void save_settings (char *section, int do_host, Config *cfg) { write_setting_i (sesskey, "LockSize", cfg->locksize); write_setting_i (sesskey, "BCE", cfg->bce); write_setting_i (sesskey, "BlinkText", cfg->blinktext); + write_setting_i (sesskey, "X11Forward", cfg->x11_forward); + write_setting_s (sesskey, "X11Display", cfg->x11_display); close_settings_w(sesskey); } @@ -150,8 +166,14 @@ void load_settings (char *section, int do_host, Config *cfg) { sesskey = open_settings_r(section); + cfg->ssh_subsys = 0; /* FIXME: load this properly */ + cfg->remote_cmd_ptr = cfg->remote_cmd; + gpps (sesskey, "HostName", "", cfg->host, sizeof(cfg->host)); gppi (sesskey, "PortNumber", default_port, &cfg->port); + gpps (sesskey, "LogFileName", "putty.log", + cfg->logfilename, sizeof(cfg->logfilename)); + gppi (sesskey, "LogType", 0, &cfg->logtype); gpps (sesskey, "Protocol", "default", prot, 10); cfg->protocol = default_protocol; @@ -161,9 +183,15 @@ void load_settings (char *section, int do_host, Config *cfg) { break; } - gppi (sesskey, "CloseOnExit", 1, &cfg->close_on_exit); + gppi (sesskey, "CloseOnExit", COE_NORMAL, &cfg->close_on_exit); gppi (sesskey, "WarnOnClose", 1, &cfg->warn_on_close); - gppi (sesskey, "PingInterval", 0, &cfg->ping_interval); + { + /* This is two values for backward compatibility with 0.50/0.51 */ + int pingmin, pingsec; + gppi (sesskey, "PingInterval", 0, &pingmin); + gppi (sesskey, "PingIntervalSecs", 0, &pingsec); + cfg->ping_interval = pingmin*60 + pingsec; + } gpps (sesskey, "TerminalType", "xterm", cfg->termtype, sizeof(cfg->termtype)); gpps (sesskey, "TerminalSpeed", "38400,38400", cfg->termspeed, @@ -188,9 +216,10 @@ void load_settings (char *section, int do_host, Config *cfg) { *q = '\0'; } gpps (sesskey, "UserName", "", cfg->username, sizeof(cfg->username)); + gpps (sesskey, "LocalUserName", "", cfg->localusername, sizeof(cfg->localusername)); gppi (sesskey, "NoPTY", 0, &cfg->nopty); + gppi (sesskey, "Compression", 0, &cfg->compression); gppi (sesskey, "AgentFwd", 0, &cfg->agentfwd); - gpps (sesskey, "RemoteCmd", "", cfg->remote_cmd, sizeof(cfg->remote_cmd)); { char cipher[10]; gpps (sesskey, "Cipher", "3des", cipher, 10); @@ -198,6 +227,8 @@ void load_settings (char *section, int do_host, Config *cfg) { cfg->cipher = CIPHER_BLOWFISH; else if (!strcmp(cipher, "des")) cfg->cipher = CIPHER_DES; + else if (!strcmp(cipher, "aes")) + cfg->cipher = CIPHER_AES; else cfg->cipher = CIPHER_3DES; } @@ -211,6 +242,8 @@ void load_settings (char *section, int do_host, Config *cfg) { gppi (sesskey, "BackspaceIsDelete", 1, &cfg->bksp_is_delete); gppi (sesskey, "RXVTHomeEnd", 0, &cfg->rxvt_homeend); gppi (sesskey, "LinuxFunctionKeys", 0, &cfg->funky_type); + gppi (sesskey, "NoApplicationKeys", 0, &cfg->no_applic_k); + gppi (sesskey, "NoApplicationCursors", 0, &cfg->no_applic_c); gppi (sesskey, "ApplicationCursorKeys", 0, &cfg->app_cursor); gppi (sesskey, "ApplicationKeypad", 0, &cfg->app_keypad); gppi (sesskey, "NetHackKeypad", 0, &cfg->nethack_keypad); @@ -218,9 +251,19 @@ void load_settings (char *section, int do_host, Config *cfg) { gppi (sesskey, "AltSpace", 0, &cfg->alt_space); gppi (sesskey, "AltOnly", 0, &cfg->alt_only); gppi (sesskey, "ComposeKey", 0, &cfg->compose_key); - gppi (sesskey, "LdiscTerm", 0, &cfg->ldisc_term); + gppi (sesskey, "CtrlAltKeys", 1, &cfg->ctrlaltkeys); + gppi (sesskey, "LocalEcho", LD_BACKEND, &cfg->localecho); + gppi (sesskey, "LocalEdit", LD_BACKEND, &cfg->localedit); + gpps (sesskey, "Answerback", "PuTTY", cfg->answerback, sizeof(cfg->answerback)); + gppi (sesskey, "AlwaysOnTop", 0, &cfg->alwaysontop); + gppi (sesskey, "HideMousePtr", 0, &cfg->hide_mouseptr); + gppi (sesskey, "CurType", 0, &cfg->cursor_type); gppi (sesskey, "BlinkCur", 0, &cfg->blink_cur); gppi (sesskey, "Beep", 1, &cfg->beep); + gppi (sesskey, "BellOverload", 1, &cfg->bellovl); + gppi (sesskey, "BellOverloadN", 5, &cfg->bellovl_n); + gppi (sesskey, "BellOverloadT", 2, &cfg->bellovl_t); + gppi (sesskey, "BellOverloadS", 5, &cfg->bellovl_s); gppi (sesskey, "ScrollbackLines", 200, &cfg->savelines); gppi (sesskey, "DECOriginMode", 0, &cfg->dec_om); gppi (sesskey, "AutoWrapMode", 1, &cfg->wrap_mode); @@ -233,6 +276,18 @@ void load_settings (char *section, int do_host, Config *cfg) { gppi (sesskey, "FontIsBold", 0, &cfg->fontisbold); gppi (sesskey, "FontCharSet", ANSI_CHARSET, &cfg->fontcharset); gppi (sesskey, "FontHeight", 10, &cfg->fontheight); + if (cfg->fontheight < 0) { + int oldh, newh; + HDC hdc = GetDC(NULL); + int logpix = GetDeviceCaps(hdc, LOGPIXELSY); + ReleaseDC(NULL, hdc); + + oldh = -cfg->fontheight; + newh = MulDiv(oldh, 72, logpix) + 1; + if (MulDiv(newh, logpix, 72) > oldh) + newh--; + cfg->fontheight = newh; + } gppi (sesskey, "FontVTMode", VT_OEMANSI, (int *)&cfg->vtmode); gppi (sesskey, "TryPalette", 0, &cfg->try_palette); gppi (sesskey, "BoldAsColour", 1, &cfg->bold_colour); @@ -254,6 +309,7 @@ void load_settings (char *section, int do_host, Config *cfg) { cfg->colours[i][2] = c2; } } + gppi (sesskey, "RawCNP", 0, &cfg->rawcnp); gppi (sesskey, "MouseIsXterm", 0, &cfg->mouse_is_xterm); for (i=0; i<256; i+=32) { static char *defaults[] = { @@ -288,6 +344,9 @@ void load_settings (char *section, int do_host, Config *cfg) { gppi (sesskey, "LockSize", 0, &cfg->locksize); gppi (sesskey, "BCE", 0, &cfg->bce); gppi (sesskey, "BlinkText", 0, &cfg->blinktext); + gppi (sesskey, "X11Forward", 0, &cfg->x11_forward); + gpps (sesskey, "X11Display", "localhost:0", cfg->x11_display, + sizeof(cfg->x11_display)); close_settings_r(sesskey); }