write_setting_i(sesskey, "X11AuthType", cfg->x11_auth);
void save_settings(char *section, int do_host, Config * cfg){    int i;    char *p;    void *sesskey;    sesskey = open_settings_w(section);    if (!sesskey)	return;    write_setting_i(sesskey, "Present", 1);    if (do_host) {	write_setting_s(sesskey, "HostName", cfg->host);	write_setting_s(sesskey, "LogFileName", cfg->logfilename);	write_setting_i(sesskey, "LogType", cfg->logtype);	write_setting_i(sesskey, "LogFileClash", cfg->logxfovr);    }    p = "raw";    for (i = 0; backends[i].name != NULL; i++)	if (backends[i].protocol == cfg->protocol) {	    p = backends[i].name;	    break;	}    write_setting_s(sesskey, "Protocol", p);    write_setting_i(sesskey, "PortNumber", cfg->port);    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 / 60);	/* minutes */    write_setting_i(sesskey, "PingIntervalSecs", cfg->ping_interval % 60);	/* seconds */    write_setting_i(sesskey, "TCPNoDelay", cfg->tcp_nodelay);    write_setting_s(sesskey, "TerminalType", cfg->termtype);    write_setting_s(sesskey, "TerminalSpeed", cfg->termspeed);    /* proxy settings */    write_setting_s(sesskey, "ProxyExcludeList", cfg->proxy_exclude_list);    write_setting_i(sesskey, "ProxyDNS", cfg->proxy_dns);    write_setting_i(sesskey, "ProxyLocalhost", cfg->even_proxy_localhost);    write_setting_i(sesskey, "ProxyType", cfg->proxy_type);    write_setting_s(sesskey, "ProxyHost", cfg->proxy_host);    write_setting_i(sesskey, "ProxyPort", cfg->proxy_port);    write_setting_s(sesskey, "ProxyUsername", cfg->proxy_username);    write_setting_s(sesskey, "ProxyPassword", cfg->proxy_password);    write_setting_s(sesskey, "ProxyTelnetCommand", cfg->proxy_telnet_command);    write_setting_i(sesskey, "ProxySOCKSVersion", cfg->proxy_socks_version);    {	char buf[2 * sizeof(cfg->environmt)], *p, *q;	p = buf;	q = cfg->environmt;	while (*q) {	    while (*q) {		int c = *q++;		if (c == '=' || c == ',' || c == '\\')		    *p++ = '\\';		if (c == '\t')		    c = '=';		*p++ = c;	    }	    *p++ = ',';	    q++;	}	*p = '\0';	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_i(sesskey, "ChangeUsername", cfg->change_username);    wprefs(sesskey, "Cipher", ciphernames, CIPHER_MAX,	   cfg->ssh_cipherlist);    write_setting_i(sesskey, "AuthTIS", cfg->try_tis_auth);    write_setting_i(sesskey, "AuthKI", cfg->try_ki_auth);    write_setting_i(sesskey, "SshProt", cfg->sshprot);    write_setting_i(sesskey, "SSH2DES", cfg->ssh2_des_cbc);    write_setting_s(sesskey, "PublicKeyFile", cfg->keyfile);    write_setting_s(sesskey, "RemoteCommand", cfg->remote_cmd);    write_setting_i(sesskey, "RFCEnviron", cfg->rfc_environ);    write_setting_i(sesskey, "PassiveTelnet", cfg->passive_telnet);    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, "NoMouseReporting", cfg->no_mouse_rep);    write_setting_i(sesskey, "NoRemoteResize", cfg->no_remote_resize);    write_setting_i(sesskey, "NoAltScreen", cfg->no_alt_screen);    write_setting_i(sesskey, "NoRemoteWinTitle", cfg->no_remote_wintitle);    write_setting_i(sesskey, "NoDBackspace", cfg->no_dbackspace);    write_setting_i(sesskey, "NoRemoteCharset", cfg->no_remote_charset);    write_setting_i(sesskey, "ApplicationCursorKeys", cfg->app_cursor);    write_setting_i(sesskey, "ApplicationKeypad", cfg->app_keypad);    write_setting_i(sesskey, "NetHackKeypad", cfg->nethack_keypad);    write_setting_i(sesskey, "AltF4", cfg->alt_f4);    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, "CtrlAltKeys", cfg->ctrlaltkeys);    write_setting_i(sesskey, "TelnetKey", cfg->telnet_keyboard);    write_setting_i(sesskey, "TelnetRet", cfg->telnet_newline);    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, "FullScreenOnAltEnter", cfg->fullscreenonaltenter);    write_setting_i(sesskey, "HideMousePtr", cfg->hide_mouseptr);    write_setting_i(sesskey, "SunkenEdge", cfg->sunken_edge);    write_setting_i(sesskey, "WindowBorder", cfg->window_border);    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, "BeepInd", cfg->beep_ind);    write_setting_s(sesskey, "BellWaveFile", cfg->bell_wavefile);    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);    write_setting_i(sesskey, "LFImpliesCR", cfg->lfhascr);    write_setting_i(sesskey, "WinNameAlways", cfg->win_name_always);    write_setting_s(sesskey, "WinTitle", cfg->wintitle);    write_setting_i(sesskey, "TermWidth", cfg->width);    write_setting_i(sesskey, "TermHeight", cfg->height);    write_setting_s(sesskey, "Font", cfg->font);    write_setting_i(sesskey, "FontIsBold", cfg->fontisbold);    write_setting_i(sesskey, "FontCharSet", cfg->fontcharset);    write_setting_i(sesskey, "FontHeight", cfg->fontheight);    write_setting_i(sesskey, "FontVTMode", cfg->vtmode);    write_setting_i(sesskey, "TryPalette", cfg->try_palette);    write_setting_i(sesskey, "BoldAsColour", cfg->bold_colour);    for (i = 0; i < 22; i++) {	char buf[20], buf2[30];	sprintf(buf, "Colour%d", i);	sprintf(buf2, "%d,%d,%d", cfg->colours[i][0],		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, "PasteRTF", cfg->rtf_paste);    write_setting_i(sesskey, "MouseIsXterm", cfg->mouse_is_xterm);    write_setting_i(sesskey, "RectSelect", cfg->rect_select);    write_setting_i(sesskey, "MouseOverride", cfg->mouse_override);    for (i = 0; i < 256; i += 32) {	char buf[20], buf2[256];	int j;	sprintf(buf, "Wordness%d", i);	*buf2 = '\0';	for (j = i; j < i + 32; j++) {	    sprintf(buf2 + strlen(buf2), "%s%d",		    (*buf2 ? "," : ""), cfg->wordness[j]);	}	write_setting_s(sesskey, buf, buf2);    }    write_setting_s(sesskey, "LineCodePage", cfg->line_codepage);    write_setting_s(sesskey, "Printer", cfg->printer);    write_setting_i(sesskey, "CapsLockCyr", cfg->xlat_capslockcyr);    write_setting_i(sesskey, "ScrollBar", cfg->scrollbar);    write_setting_i(sesskey, "ScrollBarFullScreen", cfg->scrollbar_in_fullscreen);    write_setting_i(sesskey, "ScrollOnKey", cfg->scroll_on_key);    write_setting_i(sesskey, "ScrollOnDisp", cfg->scroll_on_disp);    write_setting_i(sesskey, "LockSize", cfg->resize_action);    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);    write_setting_i(sesskey, "LocalPortAcceptAll", cfg->lport_acceptall);    write_setting_i(sesskey, "RemotePortAcceptAll", cfg->rport_acceptall);    {	char buf[2 * sizeof(cfg->portfwd)], *p, *q;	p = buf;	q = cfg->portfwd;	while (*q) {	    while (*q) {		int c = *q++;		if (c == '=' || c == ',' || c == '\\')		    *p++ = '\\';		if (c == '\t')		    c = '=';		*p++ = c;	    }	    *p++ = ',';	    q++;	}	*p = '\0';	write_setting_s(sesskey, "PortForwardings", buf);    }    write_setting_i(sesskey, "BugIgnore1", cfg->sshbug_ignore1);    write_setting_i(sesskey, "BugPlainPW1", cfg->sshbug_plainpw1);    write_setting_i(sesskey, "BugRSA1", cfg->sshbug_rsa1);    write_setting_i(sesskey, "BugHMAC2", cfg->sshbug_hmac2);    write_setting_i(sesskey, "BugDeriveKey2", cfg->sshbug_derivekey2);    write_setting_i(sesskey, "BugRSAPad2", cfg->sshbug_rsapad2);    write_setting_i(sesskey, "BugDHGEx2", cfg->sshbug_dhgex2);    write_setting_i(sesskey, "StampUtmp", cfg->stamp_utmp);    write_setting_i(sesskey, "LoginShell", cfg->login_shell);    write_setting_i(sesskey, "ScrollbarOnLeft", cfg->scrollbar_on_left);    write_setting_s(sesskey, "BoldFont", cfg->boldfont);    write_setting_i(sesskey, "ShadowBoldOffset", cfg->shadowboldoffset);    close_settings_w(sesskey);}