Example #1
0
void log_reconfig(void *handle, Conf *conf)
{
  struct LogContext *ctx = (struct LogContext *)handle;
  int reset_logging;

  if (!filename_equal(conf_get_filename(ctx->conf, CONF_logfilename),
                      conf_get_filename(conf, CONF_logfilename)) ||
      conf_get_int(ctx->conf, CONF_logtype) != conf_get_int(conf, CONF_logtype))
    reset_logging = TRUE;
  else
    reset_logging = FALSE;

  if (reset_logging)
    logfclose(ctx);

  conf_free(ctx->conf);
  ctx->conf = conf_copy(conf);

  ctx->logtype = conf_get_int(ctx->conf, CONF_logtype);

  if (reset_logging)
    logfopen(ctx);
}
Example #2
0
/*
 * Open the log file. Takes care of detecting an already-existing
 * file and asking the user whether they want to append, overwrite
 * or cancel logging.
 */
void logfopen(void *handle)
{
    struct LogContext *ctx = (struct LogContext *)handle;
    struct tm tm;
    FILE *fp;
    int mode;

    /* Prevent repeat calls */
    if (ctx->state != L_CLOSED)
	return;

    if (!ctx->logtype)
	return;

    tm = ltime();

    /* substitute special codes in file name */
    if (ctx->currlogfilename)
        filename_free(ctx->currlogfilename);
    ctx->currlogfilename = 
        xlatlognam(conf_get_filename(ctx->conf, CONF_logfilename),
                   conf_get_str(ctx->conf, CONF_host),
                   conf_get_int(ctx->conf, CONF_port), &tm);
#ifdef PERSOPORT
	test_dir( /*&*/ctx->currlogfilename ) ;
#endif

    fp = f_open(ctx->currlogfilename, "r", FALSE);  /* file already present? */
    if (fp) {
	int logxfovr = conf_get_int(ctx->conf, CONF_logxfovr);
	fclose(fp);
	if (logxfovr != LGXF_ASK) {
	    mode = ((logxfovr == LGXF_OVR) ? 2 : 1);
	} else
	    mode = askappend(ctx->frontend, ctx->currlogfilename,
			     logfopen_callback, ctx);
    } else
	mode = 2;		       /* create == overwrite */

    if (mode < 0)
	ctx->state = L_OPENING;
    else
	logfopen_callback(ctx, mode);  /* open the file */
}
Example #3
0
void SaveDumpConfig( FILE *fp, Conf * conf ) {
	CountUp();
	fprintf( fp, "MASTER_PASSWORD=%s\n", MASTER_PASSWORD ) ;
	fprintf( fp, "[[PuTTY structure configuration]]\n" ) ;
	/* Basic options */
	fprintf( fp, "host=%s\n", 			conf_get_str(conf,CONF_host) ) ;
	fprintf( fp, "port=%d\n", 			conf_get_int(conf,CONF_port) ) ;
	fprintf( fp, "protocol=%d\n", 			conf_get_int(conf,CONF_protocol) ) ;
	fprintf( fp, "addressfamily=%d\n",		conf_get_int(conf,CONF_addressfamily) ) ;
	fprintf( fp, "close_on_exit=%d\n",		conf_get_int(conf,CONF_close_on_exit) ) ;
	fprintf( fp, "warn_on_close=%d\n",		conf_get_int(conf,CONF_warn_on_close) ) ;
	fprintf( fp, "ping_interval=%d\n", 		conf_get_int(conf,CONF_ping_interval) ) ;
	fprintf( fp, "tcp_nodelay=%d\n", 		conf_get_int(conf,CONF_tcp_nodelay) ) ;
	fprintf( fp, "tcp_keepalives=%d\n", 		conf_get_int(conf,CONF_tcp_keepalives) ) ;
	/* Proxy options */
	fprintf( fp, "proxy_exclude_list=%s\n",		conf_get_str(conf,CONF_proxy_exclude_list) ) ;
	fprintf( fp, "proxy_dns=%d\n", 			conf_get_int(conf,CONF_proxy_dns) ) ;
	fprintf( fp, "even_proxy_localhost=%d\n",	conf_get_int(conf,CONF_even_proxy_localhost) ) ;
	fprintf( fp, "proxy_type=%d\n",			conf_get_int(conf,CONF_proxy_type) ) ;
	
	fprintf( fp, "proxy_host=%s\n", 		conf_get_str(conf,CONF_proxy_host) ) ;
	fprintf( fp, "proxy_port=%d\n", 		conf_get_int(conf,CONF_proxy_port) ) ;
	fprintf( fp, "proxy_username=%s\n", 		conf_get_str(conf,CONF_proxy_username) ) ;
	fprintf( fp, "proxy_password=%s\n", 		conf_get_str(conf,CONF_proxy_password) ) ;
	fprintf( fp, "proxy_telnet_command=%s\n", 	conf_get_str(conf,CONF_proxy_telnet_command) ) ;

	/* PERSOPORT Options */
		// fprintf( fp, "bcdelay=%d\n", 			conf_get_int(conf,CONF_bcdelay) ) ;		// Non présent systématiquement
		// fprintf( fp, "initdelay=%d\n",			conf_get_int(conf,CONF_initdelay) ) ;		// Non présent systématiquement
	fprintf( fp, "transparencynumber=%d\n", 	conf_get_int(conf,CONF_transparencynumber) ) ;
	fprintf( fp, "sendtotray=%d\n",			conf_get_int(conf,CONF_sendtotray) ) ;
	fprintf( fp, "maximize=%d\n",			conf_get_int(conf,CONF_maximize) ) ;
	fprintf( fp, "icone =%d\n",			conf_get_int(conf,CONF_icone) ) ;
	fprintf( fp, "folder=%s\n", 			conf_get_str(conf,CONF_folder) ) ;

	char bufpass[256] ; 
	strcpy( bufpass, conf_get_str(conf,CONF_password) ) ;
	MASKPASS(bufpass);
	fprintf( fp, "password=%s\n",			bufpass ) ;
	memset(bufpass,0,strlen(bufpass));

	fprintf( fp, "sessionname=%s\n", 		conf_get_str(conf,CONF_sessionname) ) ;
	fprintf( fp, "antiidle=%s\n",			conf_get_str(conf,CONF_antiidle) ) ;
	fprintf( fp, "autocommand=%s\n",		conf_get_str(conf,CONF_autocommand) ) ;
	fprintf( fp, "autocommandout=%s\n",		conf_get_str(conf,CONF_autocommandout) ) ;
	fprintf( fp, "scriptfile=%s\n",			conf_get_filename(conf,CONF_scriptfile)->path ) ;

	/* SSH options */
	fprintf( fp, "remote_cmd=%s\n",			conf_get_str(conf,CONF_remote_cmd) ) ;
	//char *remote_cmd_ptr;	       /* might point to a larger command but never for loading/saving */
	//char *remote_cmd_ptr2;	       /* might point to a larger command but never for loading/saving */
	fprintf( fp, "nopty=%d\n",			conf_get_int(conf,CONF_nopty) ) ;
	fprintf( fp, "compression=%d\n",		conf_get_int(conf,CONF_compression) ) ;
	fprintf( fp, "ssh_rekey_time=%d\n",		conf_get_int(conf,CONF_ssh_rekey_time) ) ;
	//int ssh_kexlist[KEX_MAX];
	fprintf( fp, "ssh_rekey_data=%s\n",		conf_get_str(conf,CONF_ssh_rekey_data) ) ;
	fprintf( fp, "tryagent=%d\n",			conf_get_int(conf,CONF_tryagent) ) ;
	fprintf( fp, "agentfwd=%d\n",			conf_get_int(conf,CONF_agentfwd) ) ;
	fprintf( fp, "change_username=%d\n",		conf_get_int(conf,CONF_change_username) ) ;
	//int ssh_cipherlist[CIPHER_MAX];
	fprintf( fp, "keyfile=%s\n",			conf_get_filename(conf,CONF_keyfile)->path ) ;
	fprintf( fp, "sshprot=%d\n",			conf_get_int(conf,CONF_sshprot) ) ;
	fprintf( fp, "ssh2_des_cbc=%d\n",		conf_get_int(conf,CONF_ssh2_des_cbc) ) ;
	fprintf( fp, "ssh_no_userauth=%d\n",		conf_get_int(conf,CONF_ssh_no_userauth) ) ;
	fprintf( fp, "ssh_show_banner=%d\n",		conf_get_int(conf,CONF_ssh_show_banner) ) ;
	fprintf( fp, "try_tis_auth=%d\n",		conf_get_int(conf,CONF_try_tis_auth) ) ;
	fprintf( fp, "try_ki_auth=%d\n",		conf_get_int(conf,CONF_try_ki_auth) ) ;
	fprintf( fp, "try_gssapi_auth=%d\n",		conf_get_int(conf,CONF_try_gssapi_auth) ) ;
	fprintf( fp, "gssapifwd=%d\n",			conf_get_int(conf,CONF_gssapifwd) ) ;
	//fprintf( fp, "ssh_gsslist=%d\n",		conf_get_int(conf,CONF_ssh_gsslist) ) ;
	fprintf( fp, "ssh_gss_custom=%s\n",		conf_get_filename(conf,CONF_ssh_gss_custom)->path ) ;
	//fprintf( fp, "ssh_subsys=%d\n",			conf_get_int(conf,CONF_ssh_subsys) ) ;
	//fprintf( fp, "ssh_subsys2=%d\n",		conf_get_int(conf,CONF_ssh_subsys2) ) ;
	fprintf( fp, "ssh_no_shell=%d\n",		conf_get_int(conf,CONF_ssh_no_shell) ) ;
	//fprintf( fp, "ssh_nc_host=%s\n",		conf_get_str(conf,CONF_ssh_nc_host) ) ;
	//fprintf( fp, "ssh_nc_port=%d\n",		conf_get_int(conf,CONF_ssh_nc_port) ) ;
#ifdef SCPORT
	fprintf( fp, "try_write_syslog=%d\n",		conf_get_int(conf,CONF_try_write_syslog) ) ; 
	fprintf( fp, "try_pkcs11_auth=%d\n",		conf_get_int(conf,CONF_try_pkcs11_auth) ) ;
	fprintf( fp, "pkcs11_token_label=%s\n",		conf_get_str(conf,CONF_pkcs11_token_label) ) ;
	fprintf( fp, "pkcs11_cert_label=%s\n",		conf_get_str(conf,CONF_pkcs11_cert_label) ) ;
#endif
	/* Telnet options */
	fprintf( fp, "termtype=%s\n",			conf_get_str(conf,CONF_termtype ) ) ;
	fprintf( fp, "termspeed=%s\n",			conf_get_str(conf,CONF_termspeed ) ) ;
	//fprintf( fp, "ttymodes=%s\n",			conf_get_str(conf,CONF_ttymodes ) ) ;
	//fprintf( fp, "environmt=%s\n",			conf_get_str(conf,CONF_environmt ) ) ;
	fprintf( fp, "username=%s\n",			conf_get_str(conf,CONF_username ) ) ;
	fprintf( fp, "localusername=%s\n",		conf_get_str(conf,CONF_localusername ) ) ;
	fprintf( fp, "rfc_environ=%d\n",		conf_get_int(conf,CONF_rfc_environ) ) ;
	fprintf( fp, "passive_telnet=%d\n",		conf_get_int(conf,CONF_passive_telnet) ) ;
	/* Serial port options */
	fprintf( fp, "serline=%s\n", 			conf_get_str(conf,CONF_serline) ) ;
	fprintf( fp, "serspeed=%d\n",			conf_get_int(conf,CONF_serspeed) ) ;
	fprintf( fp, "serdatabits=%d\n",		conf_get_int(conf,CONF_serdatabits) ) ;
	fprintf( fp, "serstopbits=%d\n",		conf_get_int(conf,CONF_serstopbits) ) ;
	fprintf( fp, "serparity=%d\n",			conf_get_int(conf,CONF_serparity) ) ;
	fprintf( fp, "serflow=%d\n",			conf_get_int(conf,CONF_serflow) ) ;
#ifdef CYGTERMPORT
	/* Cygterm options */
	fprintf( fp, "cygcmd=%s\n", 			conf_get_str(conf,CONF_cygcmd) ) ;
	fprintf( fp, "alt_metabit=%d\n", 		conf_get_int(conf,CONF_alt_metabit) ) ;
#endif
	/* Keyboard options */
	fprintf( fp, "bksp_is_delete=%d\n", 		conf_get_int(conf,CONF_bksp_is_delete) ) ;
	fprintf( fp, "rxvt_homeend=%d\n", 		conf_get_int(conf,CONF_rxvt_homeend) ) ;
	fprintf( fp, "funky_type=%d\n", 		conf_get_int(conf,CONF_funky_type) ) ;
	fprintf( fp, "no_applic_c=%d\n", 		conf_get_int(conf,CONF_no_applic_c) ) ;
	fprintf( fp, "no_applic_k=%d\n", 		conf_get_int(conf,CONF_no_applic_k) ) ;
	fprintf( fp, "no_mouse_rep=%d\n", 		conf_get_int(conf,CONF_no_mouse_rep) ) ;
	fprintf( fp, "no_remote_resize=%d\n", 		conf_get_int(conf,CONF_no_remote_resize) ) ;
	fprintf( fp, "no_alt_screen=%d\n", 		conf_get_int(conf,CONF_no_alt_screen) ) ;
	fprintf( fp, "no_remote_wintitle=%d\n", 	conf_get_int(conf,CONF_no_remote_wintitle) ) ;
	fprintf( fp, "no_dbackspace=%d\n", 		conf_get_int(conf,CONF_no_dbackspace) ) ;
	fprintf( fp, "no_remote_charset=%d\n", 		conf_get_int(conf,CONF_no_remote_charset) ) ;
	fprintf( fp, "remote_qtitle_action=%d\n", 	conf_get_int(conf,CONF_remote_qtitle_action) ) ;
	fprintf( fp, "app_cursor=%d\n", 		conf_get_int(conf,CONF_app_cursor) ) ;
	fprintf( fp, "app_keypad=%d\n", 		conf_get_int(conf,CONF_app_keypad) ) ;
	fprintf( fp, "nethack_keypad=%d\n", 		conf_get_int(conf,CONF_nethack_keypad) ) ;
	fprintf( fp, "telnet_keyboard=%d\n", 		conf_get_int(conf,CONF_telnet_keyboard) ) ;
	fprintf( fp, "telnet_newline=%d\n", 		conf_get_int(conf,CONF_telnet_newline) ) ;
	fprintf( fp, "alt_f4=%d\n", 			conf_get_int(conf,CONF_alt_f4) ) ;
	fprintf( fp, "alt_space=%d\n", 			conf_get_int(conf,CONF_alt_space) ) ;
	fprintf( fp, "alt_only=%d\n", 			conf_get_int(conf,CONF_alt_only) ) ;
	fprintf( fp, "localecho=%d\n", 			conf_get_int(conf,CONF_localecho) ) ;
	fprintf( fp, "localedit=%d\n", 			conf_get_int(conf,CONF_localedit) ) ;
	fprintf( fp, "alwaysontop=%d\n", 		conf_get_int(conf,CONF_alwaysontop) ) ;
	fprintf( fp, "fullscreenonaltenter=%d\n", 	conf_get_int(conf,CONF_fullscreenonaltenter) ) ;
	fprintf( fp, "scroll_on_key=%d\n", 		conf_get_int(conf,CONF_scroll_on_key) ) ;
	fprintf( fp, "scroll_on_disp=%d\n", 		conf_get_int(conf,CONF_scroll_on_disp) ) ;
	fprintf( fp, "erase_to_scrollback=%d\n",	conf_get_int(conf,CONF_erase_to_scrollback) ) ;
	fprintf( fp, "compose_key=%d\n", 		conf_get_int(conf,CONF_compose_key) ) ;
	fprintf( fp, "ctrlaltkeys=%d\n", 		conf_get_int(conf,CONF_ctrlaltkeys) ) ;
	fprintf( fp, "wintitle=%s\n",			conf_get_str(conf,CONF_wintitle) ) ;
	/* Terminal options */
	fprintf( fp, "savelines=%d\n", 			conf_get_int(conf,CONF_savelines) ) ;
	fprintf( fp, "dec_om=%d\n", 			conf_get_int(conf,CONF_dec_om) ) ;
	fprintf( fp, "wrap_mode=%d\n", 			conf_get_int(conf,CONF_wrap_mode) ) ;
	fprintf( fp, "lfhascr=%d\n", 			conf_get_int(conf,CONF_lfhascr) ) ;
	fprintf( fp, "cursor_type=%d\n", 		conf_get_int(conf,CONF_cursor_type) ) ;
	fprintf( fp, "blink_cur=%d\n", 			conf_get_int(conf,CONF_blink_cur) ) ;
	fprintf( fp, "beep=%d\n", 			conf_get_int(conf,CONF_beep) ) ;
	fprintf( fp, "beep_ind=%d\n", 			conf_get_int(conf,CONF_beep_ind) ) ;
	fprintf( fp, "bellovl=%d\n", 			conf_get_int(conf,CONF_bellovl) ) ;
	fprintf( fp, "bellovl_n=%d\n", 			conf_get_int(conf,CONF_bellovl_n) ) ;
	fprintf( fp, "bellovl_t=%d\n",			conf_get_int(conf,CONF_bellovl_t) ) ;
	fprintf( fp, "bellovl_s=%d\n",			conf_get_int(conf,CONF_bellovl_s) ) ;
	fprintf( fp, "scrollbar=%d\n",			conf_get_int(conf,CONF_scrollbar) ) ;
	fprintf( fp, "scrollbar_in_fullscreen=%d\n",	conf_get_int(conf,CONF_scrollbar_in_fullscreen) ) ;
	fprintf( fp, "resize_action=%d\n",		conf_get_int(conf,CONF_resize_action) ) ;
	fprintf( fp, "bce=%d\n",			conf_get_int(conf,CONF_bce) ) ;
	fprintf( fp, "blinktext=%d\n",			conf_get_int(conf,CONF_blinktext) ) ;
	fprintf( fp, "win_name_always=%d\n",		conf_get_int(conf,CONF_win_name_always) ) ;
	fprintf( fp, "width=%d\n",			conf_get_int(conf,CONF_width) ) ;
	fprintf( fp, "height=%d\n",			conf_get_int(conf,CONF_height) ) ;
	fprintf( fp, "font_quality=%d\n",		conf_get_int(conf,CONF_font_quality) ) ;
	fprintf( fp, "logtype=%d\n",			conf_get_int(conf,CONF_logtype) ) ;
	fprintf( fp, "logxfovr=%d\n",			conf_get_int(conf,CONF_logxfovr) ) ;
	fprintf( fp, "logflush=%d\n",			conf_get_int(conf,CONF_logflush) ) ;
	fprintf( fp, "logomitpass=%d\n",		conf_get_int(conf,CONF_logomitpass) ) ;
	fprintf( fp, "logomitdata=%d\n",		conf_get_int(conf,CONF_logomitdata) ) ;
	fprintf( fp, "hide_mouseptr=%d\n",		conf_get_int(conf,CONF_hide_mouseptr) ) ;
	fprintf( fp, "sunken_edge=%d\n",		conf_get_int(conf,CONF_sunken_edge) ) ;
	fprintf( fp, "window_border=%d\n",		conf_get_int(conf,CONF_window_border) ) ;
	fprintf( fp, "saveonexit=%d\n",			conf_get_int(conf,CONF_saveonexit) ) ;
	fprintf( fp, "XPos=%d\n",			conf_get_int(conf,CONF_xpos) ) ;
	fprintf( fp, "YPos=%d\n",			conf_get_int(conf,CONF_ypos) ) ;
	fprintf( fp, "fullscreen=%d\n",			conf_get_int(conf,CONF_fullscreen) ) ;
	fprintf( fp, "foreground_on_bell=%d\n",		conf_get_int(conf,CONF_foreground_on_bell) ) ;
	fprintf( fp, "bell_wavefile=%s\n",		conf_get_filename(conf,CONF_bell_wavefile)->path ) ;
	//FontSpec font;
	fprintf( fp, "logfilename=%s\n",		conf_get_filename(conf,CONF_logfilename)->path ) ;
#if (defined IMAGEPORT) && (!defined FDJ)
	/* IMAGEPORT Options */
	fprintf( fp, "bg_opacity=%d\n",			conf_get_int(conf,CONF_bg_opacity) ) ;
	fprintf( fp, "bg_slideshow=%d\n",		conf_get_int(conf,CONF_bg_slideshow) ) ;
	fprintf( fp, "bg_type=%d\n",			conf_get_int(conf,CONF_bg_type) ) ;
	fprintf( fp, "bg_image_style=%d\n",		conf_get_int(conf,CONF_bg_image_style) ) ;
	fprintf( fp, "bg_image_abs_x=%d\n",		conf_get_int(conf,CONF_bg_image_abs_x) ) ;
	fprintf( fp, "bg_image_abs_y=%d\n",		conf_get_int(conf,CONF_bg_image_abs_y) ) ;
	fprintf( fp, "bg_image_abs_fixed=%d\n",		conf_get_int(conf,CONF_bg_image_abs_fixed) ) ;
	fprintf( fp, "bg_image_filename=%s\n",		conf_get_filename(conf,CONF_bg_image_filename)->path ) ;
#endif
	fprintf( fp, "answerback=%s\n",			conf_get_str(conf,CONF_answerback) ) ;
	fprintf( fp, "printer=%s\n",			conf_get_str(conf,CONF_printer) ) ;
	fprintf( fp, "arabicshaping=%d\n",		conf_get_int(conf,CONF_arabicshaping) ) ;
	fprintf( fp, "bidi=%d\n",			conf_get_int(conf,CONF_bidi) ) ;
	/* Colour options */
	fprintf( fp, "ansi_colour=%d\n",		conf_get_int(conf,CONF_ansi_colour) ) ;
	fprintf( fp, "xterm_256_colour=%d\n",		conf_get_int(conf,CONF_xterm_256_colour) ) ;
	fprintf( fp, "system_colour=%d\n",		conf_get_int(conf,CONF_system_colour) ) ;
	fprintf( fp, "try_palette%d\n",			conf_get_int(conf,CONF_try_palette) ) ;
	fprintf( fp, "bold_style=%d\n",			conf_get_int(conf,CONF_bold_style) ) ;
	//unsigned char colours[22][3];
	/* Selection options */
	fprintf( fp, "mouse_is_xterm=%d\n",		conf_get_int(conf,CONF_mouse_is_xterm) ) ;
	fprintf( fp, "rect_select=%d\n",		conf_get_int(conf,CONF_rect_select) ) ;
	fprintf( fp, "rawcnp=%d\n",			conf_get_int(conf,CONF_rawcnp) ) ;
	fprintf( fp, "rtf_paste=%d\n",			conf_get_int(conf,CONF_rtf_paste) ) ;
	fprintf( fp, "mouse_override=%d\n",		conf_get_int(conf,CONF_mouse_override) ) ;
	//short wordness[256];
	/* translations */
	fprintf( fp, "vtmode=%d\n",			conf_get_int(conf,CONF_vtmode) ) ;
	fprintf( fp, "line_codepage=%s\n",		conf_get_str(conf,CONF_line_codepage) ) ;
	fprintf( fp, "cjk_ambig_wide=%d\n",		conf_get_int(conf,CONF_cjk_ambig_wide) ) ;
	fprintf( fp, "utf8_override=%d\n",		conf_get_int(conf,CONF_utf8_override) ) ;
	fprintf( fp, "xlat_capslockcyr=%d\n",		conf_get_int(conf,CONF_xlat_capslockcyr) ) ;
	/* X11 forwarding */
	fprintf( fp, "x11_forward=%d\n",		conf_get_int(conf,CONF_x11_forward) ) ;
	fprintf( fp, "x11_auth=%d\n",			conf_get_int(conf,CONF_x11_auth) ) ;
	fprintf( fp, "x11_display=%s\n",		conf_get_str(conf,CONF_x11_display) ) ;
	/* port forwarding */
	fprintf( fp, "lport_acceptall=%d\n",		conf_get_int(conf,CONF_lport_acceptall) ) ;
	fprintf( fp, "rport_acceptall=%d\n",		conf_get_int(conf,CONF_rport_acceptall) ) ;
	fprintf( fp, "portfwd=\n") ;
	char *key, *val;
	for (val = conf_get_str_strs(conf, CONF_portfwd, NULL, &key);
	val != NULL;
	val = conf_get_str_strs(conf, CONF_portfwd, key, &key)) {
		if (!strcmp(val, "D")) fprintf( fp, "	D%s\t\n", key+1 ) ;
		else fprintf( fp, "	%s\t%s\n", key, val);
		}
	/* SSH bug compatibility modes */
	fprintf( fp, "sshbug_ignore1=%d\n",		conf_get_int(conf,CONF_sshbug_ignore1) ) ;
	fprintf( fp, "sshbug_plainpw1=%d\n",		conf_get_int(conf,CONF_sshbug_plainpw1) ) ;
	fprintf( fp, "sshbug_rsa1=%d\n",		conf_get_int(conf,CONF_sshbug_rsa1) ) ;
	fprintf( fp, "sshbug_hmac2=%d\n",		conf_get_int(conf,CONF_sshbug_hmac2) ) ;
	fprintf( fp, "sshbug_derivekey2=%d\n",		conf_get_int(conf,CONF_sshbug_derivekey2) ) ;
	fprintf( fp, "sshbug_rsapad2=%d\n",		conf_get_int(conf,CONF_sshbug_rsapad2) ) ;
	fprintf( fp, "sshbug_pksessid2=%d\n",		conf_get_int(conf,CONF_sshbug_pksessid2) ) ;
	fprintf( fp, "sshbug_rekey2=%d\n",		conf_get_int(conf,CONF_sshbug_rekey2) ) ;
	/* Options for pterm. Should split out into platform-dependent part. */
	fprintf( fp, "stamp_utmp=%d\n",			conf_get_int(conf,CONF_stamp_utmp) ) ;
	fprintf( fp, "login_shell=%d\n",		conf_get_int(conf,CONF_login_shell) ) ;
	fprintf( fp, "scrollbar_on_left=%d\n",		conf_get_int(conf,CONF_scrollbar_on_left) ) ;
	fprintf( fp, "shadowbold=%d\n",			conf_get_int(conf,CONF_shadowbold) ) ;
	fprintf( fp, "shadowboldoffset=%d\n",		conf_get_int(conf,CONF_shadowboldoffset) ) ;
#ifdef RECONNECTPORT
	fprintf( fp, "wakeup_reconnect=%d\n",		conf_get_int(conf,CONF_wakeup_reconnect) ) ;
	fprintf( fp, "failure_reconnect=%d\n",		conf_get_int(conf,CONF_failure_reconnect) ) ;
#endif
#ifdef HYPERLINKPORT
	fprintf( fp, "url_ctrl_click=%d\n",		conf_get_int(conf,CONF_url_ctrl_click) ) ; 
	fprintf( fp, "url_underline=%d\n",		conf_get_int(conf,CONF_url_underline) ) ; 
	fprintf( fp, "url_defbrowser=%d\n",		conf_get_int(conf,CONF_url_defbrowser) ) ; 
	fprintf( fp, "url_defregex=%d\n",		conf_get_int(conf,CONF_url_defregex) ) ; 
	fprintf( fp, "url_browser=%s\n",		conf_get_filename(conf,CONF_url_browser)->path ) ; 
	fprintf( fp, "url_regex=%s\n",			conf_get_str(conf,CONF_url_regex) ) ; 
#endif
#ifdef ZMODEMPORT
	fprintf( fp, "rzcommand=%s\n",			conf_get_filename(conf,CONF_rzcommand)->path ) ;
	fprintf( fp, "rzoptions=%s\n",			conf_get_str(conf,CONF_rzoptions) ) ;
	fprintf( fp, "szcommand=%s\n",			conf_get_filename(conf,CONF_szcommand)->path ) ;
	fprintf( fp, "szoptions=%s\n",			conf_get_str(conf,CONF_szoptions) ) ;
	fprintf( fp, "zdownloaddir=%s\n",		conf_get_str(conf,CONF_zdownloaddir) ) ;
#endif
	//FontSpec boldfont; //FontSpec widefont; //FontSpec wideboldfont;

	fprintf( fp, "\n[[KiTTY specific configuration]]\n" ) ;
	fprintf( fp, "internal_delay=%d\ninit_delay=%g\nautocommand_delay=%g\nbetween_char_delay=%d\nProtectFlag=%d\nIniFileFlag=%d\n"
	,internal_delay,init_delay,autocommand_delay,between_char_delay,ProtectFlag,IniFileFlag );
	
	if( AutoCommand!= NULL ) fprintf( fp, "AutoCommand=%s\n", AutoCommand ) ;
	if( ScriptCommand!= NULL ) fprintf( fp, "ScriptCommand=%s\n", ScriptCommand ) ;
	if( PasteCommand!= NULL ) fprintf( fp, "PasteCommand=%s\n", PasteCommand ) ;
	fprintf( fp, "PasteCommandFlag=%d\n", PasteCommandFlag );
	if( ScriptFileContent!= NULL ) {
		char * pst = ScriptFileContent ;
		fprintf( fp, "ScriptFileContent=" ) ;
		while( strlen(pst) > 0 ) { fprintf( fp, "%s|", pst ) ; pst=pst+strlen(pst)+1 ; }
		fprintf( fp, "\n" )  ;
		}
	if( IconFile!= NULL ) fprintf( fp, "IconFile=%s\n", IconFile ) ;
	fprintf( fp, "DirectoryBrowseFlag=%d\nVisibleFlag=%d\nShortcutsFlag=%d\nIconeFlag=%d\nNumberOfIcons=%d\nSizeFlag=%d\nCapsLockFlag=%d\nTitleBarFlag=%d\n"
	,DirectoryBrowseFlag,VisibleFlag,ShortcutsFlag,IconeFlag,NumberOfIcons,SizeFlag,CapsLockFlag,TitleBarFlag);
	//static HINSTANCE hInstIcons =  NULL ;
	fprintf( fp, "WinHeight=%d\nAutoSendToTray=%d\nNoKittyFileFlag=%d\nConfigBoxHeight=%d\nConfigBoxWindowHeight=%d\nPuttyFlag=%d\n",WinHeight,AutoSendToTray,NoKittyFileFlag,ConfigBoxHeight,ConfigBoxWindowHeight,PuttyFlag);
#if (defined IMAGEPORT) && (!defined FDJ)
	fprintf( fp,"BackgroundImageFlag=%d\n",BackgroundImageFlag );
#endif
#ifdef CYGTERMPORT
	fprintf( fp,"CygTermFlag=%d\n",cygterm_get_flag() );
#endif
	if( PasswordConf!= NULL ) fprintf( fp, "PasswordConf=%s\n", PasswordConf ) ;
	fprintf( fp, "SessionFilterFlag=%d\nImageViewerFlag=%d\nImageSlideDelay=%d\nPrintCharSize=%d\nPrintMaxLinePerPage=%d\nPrintMaxCharPerLine=%d\n"
	,SessionFilterFlag,ImageViewerFlag,ImageSlideDelay,PrintCharSize,PrintMaxLinePerPage,PrintMaxCharPerLine);
	fprintf( fp, "AntiIdleCount=%d\nAntiIdleCountMax=%d\nIconeNum=%d\n"
	,AntiIdleCount,AntiIdleCountMax,IconeNum);
	fprintf( fp, "AntiIdleStr=%s\nInitialDirectory=%s\nConfigDirectory=%s\nBuildVersionTime=%s\n",AntiIdleStr,InitialDirectory,ConfigDirectory,BuildVersionTime);
	if( WinSCPPath!= NULL ) fprintf( fp, "WinSCPPath=%s\n", WinSCPPath ) ;
	if( PSCPPath!= NULL ) fprintf( fp, "PSCPPath=%s\n", PSCPPath ) ;
	if( KittyIniFile!= NULL ) fprintf( fp, "KittyIniFile=%s\n", KittyIniFile ) ;
	if( KittySavFile!= NULL ) fprintf( fp, "KittySavFile=%s\n", KittySavFile ) ;
	if( CtHelperPath!= NULL ) fprintf( fp, "CtHelperPath=%s\n", CtHelperPath ) ;
	}
Example #4
0
void platform_get_x11_auth(struct X11Display *disp, Conf *conf)
{
  char *xauthpath = conf_get_filename(conf, CONF_xauthfile)->path;
  if (xauthpath[0])
    x11_get_auth_from_authfile(disp, xauthpath);
}
Example #5
0
void save_open_settings(void *sesskey, Conf *conf)
{
    int i;
    char *p;

    write_setting_i(sesskey, "Present", 1);
    write_setting_s(sesskey, "HostName", conf_get_str(conf, CONF_host));
    write_setting_filename(sesskey, "LogFileName", conf_get_filename(conf, CONF_logfilename));
    write_setting_i(sesskey, "LogType", conf_get_int(conf, CONF_logtype));
    write_setting_i(sesskey, "LogFileClash", conf_get_int(conf, CONF_logxfovr));
    write_setting_i(sesskey, "LogFlush", conf_get_int(conf, CONF_logflush));
    write_setting_i(sesskey, "SSHLogOmitPasswords", conf_get_int(conf, CONF_logomitpass));
    write_setting_i(sesskey, "SSHLogOmitData", conf_get_int(conf, CONF_logomitdata));
    p = "raw";
    {
	const Backend *b = backend_from_proto(conf_get_int(conf, CONF_protocol));
	if (b)
	    p = b->name;
    }
    write_setting_s(sesskey, "Protocol", p);
    write_setting_i(sesskey, "PortNumber", conf_get_int(conf, CONF_port));
    /* The CloseOnExit numbers are arranged in a different order from
     * the standard FORCE_ON / FORCE_OFF / AUTO. */
    write_setting_i(sesskey, "CloseOnExit", (conf_get_int(conf, CONF_close_on_exit)+2)%3);
    write_setting_i(sesskey, "WarnOnClose", !!conf_get_int(conf, CONF_warn_on_close));
    write_setting_i(sesskey, "PingInterval", conf_get_int(conf, CONF_ping_interval) / 60);	/* minutes */
    write_setting_i(sesskey, "PingIntervalSecs", conf_get_int(conf, CONF_ping_interval) % 60);	/* seconds */
    write_setting_i(sesskey, "TCPNoDelay", conf_get_int(conf, CONF_tcp_nodelay));
    write_setting_i(sesskey, "TCPKeepalives", conf_get_int(conf, CONF_tcp_keepalives));
    write_setting_s(sesskey, "TerminalType", conf_get_str(conf, CONF_termtype));
    write_setting_s(sesskey, "TerminalSpeed", conf_get_str(conf, CONF_termspeed));
    wmap(sesskey, "TerminalModes", conf, CONF_ttymodes, TRUE);

    /* Address family selection */
    write_setting_i(sesskey, "AddressFamily", conf_get_int(conf, CONF_addressfamily));

    /* proxy settings */
    write_setting_s(sesskey, "ProxyExcludeList", conf_get_str(conf, CONF_proxy_exclude_list));
    write_setting_i(sesskey, "ProxyDNS", (conf_get_int(conf, CONF_proxy_dns)+2)%3);
    write_setting_i(sesskey, "ProxyLocalhost", conf_get_int(conf, CONF_even_proxy_localhost));
    write_setting_i(sesskey, "ProxyMethod", conf_get_int(conf, CONF_proxy_type));
    write_setting_s(sesskey, "ProxyHost", conf_get_str(conf, CONF_proxy_host));
    write_setting_i(sesskey, "ProxyPort", conf_get_int(conf, CONF_proxy_port));
    write_setting_s(sesskey, "ProxyUsername", conf_get_str(conf, CONF_proxy_username));
    write_setting_s(sesskey, "ProxyPassword", conf_get_str(conf, CONF_proxy_password));
    write_setting_s(sesskey, "ProxyTelnetCommand", conf_get_str(conf, CONF_proxy_telnet_command));
    wmap(sesskey, "Environment", conf, CONF_environmt, TRUE);
    write_setting_s(sesskey, "UserName", conf_get_str(conf, CONF_username));
    write_setting_i(sesskey, "UserNameFromEnvironment", conf_get_int(conf, CONF_username_from_env));
    write_setting_s(sesskey, "LocalUserName", conf_get_str(conf, CONF_localusername));
    write_setting_i(sesskey, "NoPTY", conf_get_int(conf, CONF_nopty));
    write_setting_i(sesskey, "Compression", conf_get_int(conf, CONF_compression));
    write_setting_i(sesskey, "TryAgent", conf_get_int(conf, CONF_tryagent));
    write_setting_i(sesskey, "AgentFwd", conf_get_int(conf, CONF_agentfwd));
    write_setting_i(sesskey, "GssapiFwd", conf_get_int(conf, CONF_gssapifwd));
    write_setting_i(sesskey, "ChangeUsername", conf_get_int(conf, CONF_change_username));
    wprefs(sesskey, "Cipher", ciphernames, CIPHER_MAX, conf, CONF_ssh_cipherlist);
    wprefs(sesskey, "KEX", kexnames, KEX_MAX, conf, CONF_ssh_kexlist);
    write_setting_i(sesskey, "RekeyTime", conf_get_int(conf, CONF_ssh_rekey_time));
    write_setting_s(sesskey, "RekeyBytes", conf_get_str(conf, CONF_ssh_rekey_data));
    write_setting_i(sesskey, "SshNoAuth", conf_get_int(conf, CONF_ssh_no_userauth));
    write_setting_i(sesskey, "SshBanner", conf_get_int(conf, CONF_ssh_show_banner));
    write_setting_i(sesskey, "AuthTIS", conf_get_int(conf, CONF_try_tis_auth));
    write_setting_i(sesskey, "AuthKI", conf_get_int(conf, CONF_try_ki_auth));
    write_setting_i(sesskey, "AuthGSSAPI", conf_get_int(conf, CONF_try_gssapi_auth));
#ifndef NO_GSSAPI
    wprefs(sesskey, "GSSLibs", gsslibkeywords, ngsslibs, conf, CONF_ssh_gsslist);
    write_setting_filename(sesskey, "GSSCustom", conf_get_filename(conf, CONF_ssh_gss_custom));
#endif
    write_setting_i(sesskey, "SshNoShell", conf_get_int(conf, CONF_ssh_no_shell));
    write_setting_i(sesskey, "SshProt", conf_get_int(conf, CONF_sshprot));
    write_setting_s(sesskey, "LogHost", conf_get_str(conf, CONF_loghost));
    write_setting_i(sesskey, "SSH2DES", conf_get_int(conf, CONF_ssh2_des_cbc));
    write_setting_filename(sesskey, "PublicKeyFile", conf_get_filename(conf, CONF_keyfile));
    write_setting_s(sesskey, "RemoteCommand", conf_get_str(conf, CONF_remote_cmd));
    write_setting_i(sesskey, "RFCEnviron", conf_get_int(conf, CONF_rfc_environ));
/* PuTTY CAPI start */
#ifdef _WINDOWS
    write_setting_i(sesskey, "AuthCAPI", conf_get_int(conf, CONF_try_capi_auth));
    write_setting_s(sesskey, "CAPICertID", conf_get_str(conf, CONF_capi_certID));
#endif
/* PuTTY CAPI end */
    write_setting_i(sesskey, "PassiveTelnet", conf_get_int(conf, CONF_passive_telnet));
    write_setting_i(sesskey, "BackspaceIsDelete", conf_get_int(conf, CONF_bksp_is_delete));
    write_setting_i(sesskey, "RXVTHomeEnd", conf_get_int(conf, CONF_rxvt_homeend));
    write_setting_i(sesskey, "LinuxFunctionKeys", conf_get_int(conf, CONF_funky_type));
    write_setting_i(sesskey, "NoApplicationKeys", conf_get_int(conf, CONF_no_applic_k));
    write_setting_i(sesskey, "NoApplicationCursors", conf_get_int(conf, CONF_no_applic_c));
    write_setting_i(sesskey, "NoMouseReporting", conf_get_int(conf, CONF_no_mouse_rep));
    write_setting_i(sesskey, "NoRemoteResize", conf_get_int(conf, CONF_no_remote_resize));
    write_setting_i(sesskey, "NoAltScreen", conf_get_int(conf, CONF_no_alt_screen));
    write_setting_i(sesskey, "NoRemoteWinTitle", conf_get_int(conf, CONF_no_remote_wintitle));
    write_setting_i(sesskey, "RemoteQTitleAction", conf_get_int(conf, CONF_remote_qtitle_action));
    write_setting_i(sesskey, "NoDBackspace", conf_get_int(conf, CONF_no_dbackspace));
    write_setting_i(sesskey, "NoRemoteCharset", conf_get_int(conf, CONF_no_remote_charset));
    write_setting_i(sesskey, "ApplicationCursorKeys", conf_get_int(conf, CONF_app_cursor));
    write_setting_i(sesskey, "ApplicationKeypad", conf_get_int(conf, CONF_app_keypad));
    write_setting_i(sesskey, "NetHackKeypad", conf_get_int(conf, CONF_nethack_keypad));
    write_setting_i(sesskey, "AltF4", conf_get_int(conf, CONF_alt_f4));
    write_setting_i(sesskey, "AltSpace", conf_get_int(conf, CONF_alt_space));
    write_setting_i(sesskey, "AltOnly", conf_get_int(conf, CONF_alt_only));
    write_setting_i(sesskey, "ComposeKey", conf_get_int(conf, CONF_compose_key));
    write_setting_i(sesskey, "CtrlAltKeys", conf_get_int(conf, CONF_ctrlaltkeys));
    write_setting_i(sesskey, "TelnetKey", conf_get_int(conf, CONF_telnet_keyboard));
    write_setting_i(sesskey, "TelnetRet", conf_get_int(conf, CONF_telnet_newline));
    write_setting_i(sesskey, "LocalEcho", conf_get_int(conf, CONF_localecho));
    write_setting_i(sesskey, "LocalEdit", conf_get_int(conf, CONF_localedit));
    write_setting_s(sesskey, "Answerback", conf_get_str(conf, CONF_answerback));
    write_setting_i(sesskey, "AlwaysOnTop", conf_get_int(conf, CONF_alwaysontop));
    write_setting_i(sesskey, "FullScreenOnAltEnter", conf_get_int(conf, CONF_fullscreenonaltenter));
    write_setting_i(sesskey, "HideMousePtr", conf_get_int(conf, CONF_hide_mouseptr));
    write_setting_i(sesskey, "SunkenEdge", conf_get_int(conf, CONF_sunken_edge));
    write_setting_i(sesskey, "WindowBorder", conf_get_int(conf, CONF_window_border));
    write_setting_i(sesskey, "CurType", conf_get_int(conf, CONF_cursor_type));
    write_setting_i(sesskey, "BlinkCur", conf_get_int(conf, CONF_blink_cur));
    write_setting_i(sesskey, "Beep", conf_get_int(conf, CONF_beep));
    write_setting_i(sesskey, "BeepInd", conf_get_int(conf, CONF_beep_ind));
    write_setting_filename(sesskey, "BellWaveFile", conf_get_filename(conf, CONF_bell_wavefile));
    write_setting_i(sesskey, "BellOverload", conf_get_int(conf, CONF_bellovl));
    write_setting_i(sesskey, "BellOverloadN", conf_get_int(conf, CONF_bellovl_n));
    write_setting_i(sesskey, "BellOverloadT", conf_get_int(conf, CONF_bellovl_t)
#ifdef PUTTY_UNIX_H
		    * 1000
#endif
		    );
    write_setting_i(sesskey, "BellOverloadS", conf_get_int(conf, CONF_bellovl_s)
#ifdef PUTTY_UNIX_H
		    * 1000
#endif
		    );
    write_setting_i(sesskey, "ScrollbackLines", conf_get_int(conf, CONF_savelines));
    write_setting_i(sesskey, "DECOriginMode", conf_get_int(conf, CONF_dec_om));
    write_setting_i(sesskey, "AutoWrapMode", conf_get_int(conf, CONF_wrap_mode));
    write_setting_i(sesskey, "LFImpliesCR", conf_get_int(conf, CONF_lfhascr));
    write_setting_i(sesskey, "CRImpliesLF", conf_get_int(conf, CONF_crhaslf));
    write_setting_i(sesskey, "DisableArabicShaping", conf_get_int(conf, CONF_arabicshaping));
    write_setting_i(sesskey, "DisableBidi", conf_get_int(conf, CONF_bidi));
    write_setting_i(sesskey, "WinNameAlways", conf_get_int(conf, CONF_win_name_always));
    write_setting_s(sesskey, "WinTitle", conf_get_str(conf, CONF_wintitle));
    write_setting_i(sesskey, "TermWidth", conf_get_int(conf, CONF_width));
    write_setting_i(sesskey, "TermHeight", conf_get_int(conf, CONF_height));
    write_setting_fontspec(sesskey, "Font", conf_get_fontspec(conf, CONF_font));
    write_setting_i(sesskey, "FontQuality", conf_get_int(conf, CONF_font_quality));
    write_setting_i(sesskey, "FontVTMode", conf_get_int(conf, CONF_vtmode));
    write_setting_i(sesskey, "UseSystemColours", conf_get_int(conf, CONF_system_colour));
    write_setting_i(sesskey, "TryPalette", conf_get_int(conf, CONF_try_palette));
    write_setting_i(sesskey, "ANSIColour", conf_get_int(conf, CONF_ansi_colour));
    write_setting_i(sesskey, "Xterm256Colour", conf_get_int(conf, CONF_xterm_256_colour));
    write_setting_i(sesskey, "BoldAsColour", conf_get_int(conf, CONF_bold_style)-1);

    for (i = 0; i < 22; i++) {
	char buf[20], buf2[30];
	sprintf(buf, "Colour%d", i);
	sprintf(buf2, "%d,%d,%d",
		conf_get_int_int(conf, CONF_colours, i*3+0),
		conf_get_int_int(conf, CONF_colours, i*3+1),
		conf_get_int_int(conf, CONF_colours, i*3+2));
	write_setting_s(sesskey, buf, buf2);
    }
    write_setting_i(sesskey, "RawCNP", conf_get_int(conf, CONF_rawcnp));
    write_setting_i(sesskey, "PasteRTF", conf_get_int(conf, CONF_rtf_paste));
    write_setting_i(sesskey, "MouseIsXterm", conf_get_int(conf, CONF_mouse_is_xterm));
    write_setting_i(sesskey, "RectSelect", conf_get_int(conf, CONF_rect_select));
    write_setting_i(sesskey, "MouseOverride", conf_get_int(conf, CONF_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 ? "," : ""),
		    conf_get_int_int(conf, CONF_wordness, j));
	}
	write_setting_s(sesskey, buf, buf2);
    }
    write_setting_s(sesskey, "LineCodePage", conf_get_str(conf, CONF_line_codepage));
    write_setting_i(sesskey, "CJKAmbigWide", conf_get_int(conf, CONF_cjk_ambig_wide));
    write_setting_i(sesskey, "UTF8Override", conf_get_int(conf, CONF_utf8_override));
    write_setting_s(sesskey, "Printer", conf_get_str(conf, CONF_printer));
    write_setting_i(sesskey, "CapsLockCyr", conf_get_int(conf, CONF_xlat_capslockcyr));
    write_setting_i(sesskey, "ScrollBar", conf_get_int(conf, CONF_scrollbar));
    write_setting_i(sesskey, "ScrollBarFullScreen", conf_get_int(conf, CONF_scrollbar_in_fullscreen));
    write_setting_i(sesskey, "ScrollOnKey", conf_get_int(conf, CONF_scroll_on_key));
    write_setting_i(sesskey, "ScrollOnDisp", conf_get_int(conf, CONF_scroll_on_disp));
    write_setting_i(sesskey, "EraseToScrollback", conf_get_int(conf, CONF_erase_to_scrollback));
    write_setting_i(sesskey, "LockSize", conf_get_int(conf, CONF_resize_action));
    write_setting_i(sesskey, "BCE", conf_get_int(conf, CONF_bce));
    write_setting_i(sesskey, "BlinkText", conf_get_int(conf, CONF_blinktext));
    write_setting_i(sesskey, "X11Forward", conf_get_int(conf, CONF_x11_forward));
    write_setting_s(sesskey, "X11Display", conf_get_str(conf, CONF_x11_display));
    write_setting_i(sesskey, "X11AuthType", conf_get_int(conf, CONF_x11_auth));
    write_setting_filename(sesskey, "X11AuthFile", conf_get_filename(conf, CONF_xauthfile));
    write_setting_i(sesskey, "LocalPortAcceptAll", conf_get_int(conf, CONF_lport_acceptall));
    write_setting_i(sesskey, "RemotePortAcceptAll", conf_get_int(conf, CONF_rport_acceptall));
    wmap(sesskey, "PortForwardings", conf, CONF_portfwd, TRUE);
    write_setting_i(sesskey, "BugIgnore1", 2-conf_get_int(conf, CONF_sshbug_ignore1));
    write_setting_i(sesskey, "BugPlainPW1", 2-conf_get_int(conf, CONF_sshbug_plainpw1));
    write_setting_i(sesskey, "BugRSA1", 2-conf_get_int(conf, CONF_sshbug_rsa1));
    write_setting_i(sesskey, "BugIgnore2", 2-conf_get_int(conf, CONF_sshbug_ignore2));
    write_setting_i(sesskey, "BugHMAC2", 2-conf_get_int(conf, CONF_sshbug_hmac2));
    write_setting_i(sesskey, "BugDeriveKey2", 2-conf_get_int(conf, CONF_sshbug_derivekey2));
    write_setting_i(sesskey, "BugRSAPad2", 2-conf_get_int(conf, CONF_sshbug_rsapad2));
    write_setting_i(sesskey, "BugPKSessID2", 2-conf_get_int(conf, CONF_sshbug_pksessid2));
    write_setting_i(sesskey, "BugRekey2", 2-conf_get_int(conf, CONF_sshbug_rekey2));
    write_setting_i(sesskey, "BugMaxPkt2", 2-conf_get_int(conf, CONF_sshbug_maxpkt2));
    write_setting_i(sesskey, "BugOldGex2", 2-conf_get_int(conf, CONF_sshbug_oldgex2));
    write_setting_i(sesskey, "BugWinadj", 2-conf_get_int(conf, CONF_sshbug_winadj));
    write_setting_i(sesskey, "BugChanReq", 2-conf_get_int(conf, CONF_sshbug_chanreq));
    write_setting_i(sesskey, "StampUtmp", conf_get_int(conf, CONF_stamp_utmp));
    write_setting_i(sesskey, "LoginShell", conf_get_int(conf, CONF_login_shell));
    write_setting_i(sesskey, "ScrollbarOnLeft", conf_get_int(conf, CONF_scrollbar_on_left));
    write_setting_fontspec(sesskey, "BoldFont", conf_get_fontspec(conf, CONF_boldfont));
    write_setting_fontspec(sesskey, "WideFont", conf_get_fontspec(conf, CONF_widefont));
    write_setting_fontspec(sesskey, "WideBoldFont", conf_get_fontspec(conf, CONF_wideboldfont));
    write_setting_i(sesskey, "ShadowBold", conf_get_int(conf, CONF_shadowbold));
    write_setting_i(sesskey, "ShadowBoldOffset", conf_get_int(conf, CONF_shadowboldoffset));
    write_setting_s(sesskey, "SerialLine", conf_get_str(conf, CONF_serline));
    write_setting_i(sesskey, "SerialSpeed", conf_get_int(conf, CONF_serspeed));
    write_setting_i(sesskey, "SerialDataBits", conf_get_int(conf, CONF_serdatabits));
    write_setting_i(sesskey, "SerialStopHalfbits", conf_get_int(conf, CONF_serstopbits));
    write_setting_i(sesskey, "SerialParity", conf_get_int(conf, CONF_serparity));
    write_setting_i(sesskey, "SerialFlowControl", conf_get_int(conf, CONF_serflow));
    write_setting_s(sesskey, "WindowClass", conf_get_str(conf, CONF_winclass));
    write_setting_i(sesskey, "ConnectionSharing", conf_get_int(conf, CONF_ssh_connection_sharing));
    write_setting_i(sesskey, "ConnectionSharingUpstream", conf_get_int(conf, CONF_ssh_connection_sharing_upstream));
    write_setting_i(sesskey, "ConnectionSharingDownstream", conf_get_int(conf, CONF_ssh_connection_sharing_downstream));
    wmap(sesskey, "SSHManualHostKeys", conf, CONF_ssh_manual_hostkeys, FALSE);
}
void hamlib_init(void)
{
	rig_model_t model;
	struct timespec sleep;
	freq_t freq;
	rmode_t mode;
	pbwidth_t width;
	gboolean enable;
	gchar *port, *conf, *spd;
	gint ret, speed;

	if (rig != NULL)
		return;

	enable = conf_get_bool("hamlib/enable");
	model = conf_get_int("hamlib/rig");
	port = conf_get_filename("hamlib/port");
	speed = conf_get_int("hamlib/speed");
	conf = conf_get_string("hamlib/conf");

	if (!enable || !model || port[0] == 0)
		return;

	rig_set_debug(RIG_DEBUG_ERR);

	rig = rig_init(model);

	if (rig == NULL) {
		errmsg(_("Hamlib init: rig_init failed (model=%d)"), model);
		return;
	}

	g_strstrip(conf);
	if (conf[0]) {
		gchar **v, **p, *q;

		v = g_strsplit(conf, ",", 0);

		for (p = v; *p; p++) {
			if ((q = strchr(*p, '=')) == NULL) {
				errmsg(_("Hamlib init: Bad param=value pair: '%s'"), *p);
				break;
			}
			*q++ = 0;

			g_strstrip(*p);
			g_strstrip(q);

			if (hamlib_set_param(*p, q) == FALSE)
				break;
		}

		g_strfreev(v);
	}
	g_free(conf);

	hamlib_set_param("rig_pathname", port);
	g_free(port);

	spd = g_strdup_printf("%d", speed);
	hamlib_set_param("serial_speed", spd);
	g_free(spd);

	ret = rig_open(rig);

	if (ret != RIG_OK) {
		errmsg(_("Hamlib init: rig_open failed: %s"), rigerror(ret));
		rig_cleanup(rig);
		rig = NULL;
		return;
	}

	/* Polling the rig sometimes fails right after opening it */
	sleep.tv_sec = 0;
	sleep.tv_nsec = 100000000L;	/* 100ms */
	nanosleep(&sleep, NULL);

	if (need_freq == TRUE && \
	    (ret = rig_get_freq(rig, RIG_VFO_CURR, &freq)) != RIG_OK) {
		errmsg(_("Hamlib init: rig_get_freq failed: %s"), rigerror(ret));

		hamlib_waterfall = FALSE;
		hamlib_qsodata = FALSE;

		need_freq = FALSE;
		need_mode = FALSE;
	}

	if (need_mode == TRUE &&
	    (ret = rig_get_mode(rig, RIG_VFO_CURR, &mode, &width)) != RIG_OK) {
		errmsg(_("Hamlib init: rig_get_mode failed: %s.\nAssuming USB mode."), rigerror(ret));

		need_mode = FALSE;
	}

	if (hamlib_ptt == TRUE && 
	    (ret = rig_set_ptt(rig, RIG_VFO_CURR, RIG_PTT_OFF)) != RIG_OK) {
		errmsg(_("Hamlib init: rig_set_ptt failed: %s.\nHamlib PTT disabled"), rigerror(ret));

		hamlib_ptt = FALSE;
	}

	/* Don't create the thread if frequency data is not needed */
	if (need_freq == FALSE) {
//		g_warning("Freq data not needed, thread not started.");
		/* If PTT isn't needed either then close everything */
		if (hamlib_ptt == FALSE) {
//			g_warning("PTT not needed, closing rig.");
			rig_close(rig);
			rig_cleanup(rig);
			rig = NULL;
		}
		return;
	}

	if (pthread_create(&hamlib_thread, NULL, hamlib_loop, NULL) < 0) {
		errmsg(_("Hamlib init: pthread_create: %m"));
		rig_close(rig);
		rig_cleanup(rig);
		rig = NULL;
	}
}