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 ) ; }
/* * Called to set up the pty. * * Returns an error message, or NULL on success. * * Also places the canonical host name into `realhost'. It must be * freed by the caller. */ static const char *pty_init(void *frontend, void **backend_handle, Conf *conf, char *host, int port, char **realhost, int nodelay, int keepalive) { int slavefd; pid_t pid, pgrp; #ifndef NOT_X_WINDOWS /* for Mac OS X native compilation */ long windowid; #endif Pty pty; if (single_pty) { pty = single_pty; assert(pty->conf == NULL); } else { pty = snew(struct pty_tag); pty->master_fd = pty->slave_fd = -1; #ifndef OMIT_UTMP pty_stamped_utmp = FALSE; #endif } pty->frontend = frontend; *backend_handle = NULL; /* we can't sensibly use this, sadly */ pty->conf = conf_copy(conf); pty->term_width = conf_get_int(conf, CONF_width); pty->term_height = conf_get_int(conf, CONF_height); if (pty->master_fd < 0) pty_open_master(pty); /* * Set the backspace character to be whichever of ^H and ^? is * specified by bksp_is_delete. */ { struct termios attrs; tcgetattr(pty->master_fd, &attrs); attrs.c_cc[VERASE] = conf_get_int(conf, CONF_bksp_is_delete) ? '\177' : '\010'; tcsetattr(pty->master_fd, TCSANOW, &attrs); } #ifndef OMIT_UTMP /* * Stamp utmp (that is, tell the utmp helper process to do so), * or not. */ if (pty_utmp_helper_pipe >= 0) { /* if it's < 0, we can't anyway */ if (!conf_get_int(conf, CONF_stamp_utmp)) { close(pty_utmp_helper_pipe); /* just let the child process die */ pty_utmp_helper_pipe = -1; } else { char *location = get_x_display(pty->frontend); int len = strlen(location)+1, pos = 0; /* +1 to include NUL */ while (pos < len) { int ret = write(pty_utmp_helper_pipe, location+pos, len - pos); if (ret < 0) { perror("pterm: writing to utmp helper process"); close(pty_utmp_helper_pipe); /* arrgh, just give up */ pty_utmp_helper_pipe = -1; break; } pos += ret; } } } #endif #ifndef NOT_X_WINDOWS /* for Mac OS X native compilation */ windowid = get_windowid(pty->frontend); #endif /* * Fork and execute the command. */ pid = fork(); if (pid < 0) { perror("fork"); exit(1); } if (pid == 0) { /* * We are the child. */ slavefd = pty_open_slave(pty); if (slavefd < 0) { perror("slave pty: open"); _exit(1); } close(pty->master_fd); noncloexec(slavefd); dup2(slavefd, 0); dup2(slavefd, 1); dup2(slavefd, 2); close(slavefd); setsid(); #ifdef TIOCSCTTY ioctl(0, TIOCSCTTY, 1); #endif pgrp = getpid(); tcsetpgrp(0, pgrp); setpgid(pgrp, pgrp); { int ptyfd = open(pty->name, O_WRONLY, 0); if (ptyfd >= 0) close(ptyfd); } setpgid(pgrp, pgrp); { char *term_env_var = dupprintf("TERM=%s", conf_get_str(conf, CONF_termtype)); putenv(term_env_var); /* We mustn't free term_env_var, as putenv links it into the * environment in place. */ } #ifndef NOT_X_WINDOWS /* for Mac OS X native compilation */ { char *windowid_env_var = dupprintf("WINDOWID=%ld", windowid); putenv(windowid_env_var); /* We mustn't free windowid_env_var, as putenv links it into the * environment in place. */ } #endif { char *key, *val; for (val = conf_get_str_strs(conf, CONF_environmt, NULL, &key); val != NULL; val = conf_get_str_strs(conf, CONF_environmt, key, &key)) { char *varval = dupcat(key, "=", val, NULL); putenv(varval); /* * We must not free varval, since putenv links it * into the environment _in place_. Weird, but * there we go. Memory usage will be rationalised * as soon as we exec anyway. */ } } /* * SIGINT, SIGQUIT and SIGPIPE may have been set to ignored by * our parent, particularly by things like sh -c 'pterm &' and * some window or session managers. SIGCHLD, meanwhile, was * blocked during pt_main() startup. Reverse all this for our * child process. */ putty_signal(SIGINT, SIG_DFL); putty_signal(SIGQUIT, SIG_DFL); putty_signal(SIGPIPE, SIG_DFL); block_signal(SIGCHLD, 0); if (pty_argv) { /* * Exec the exact argument list we were given. */ execvp(pty_argv[0], pty_argv); /* * If that fails, and if we had exactly one argument, pass * that argument to $SHELL -c. * * This arranges that we can _either_ follow 'pterm -e' * with a list of argv elements to be fed directly to * exec, _or_ with a single argument containing a command * to be parsed by a shell (but, in cases of doubt, the * former is more reliable). * * A quick survey of other terminal emulators' -e options * (as of Debian squeeze) suggests that: * * - xterm supports both modes, more or less like this * - gnome-terminal will only accept a one-string shell command * - Eterm, kterm and rxvt will only accept a list of * argv elements (as did older versions of pterm). * * It therefore seems important to support both usage * modes in order to be a drop-in replacement for either * xterm or gnome-terminal, and hence for anyone's * plausible uses of the Debian-style alias * 'x-terminal-emulator'... */ if (pty_argv[1] == NULL) { char *shell = getenv("SHELL"); if (shell) execl(shell, shell, "-c", pty_argv[0], (void *)NULL); } } else { char *shell = getenv("SHELL"); char *shellname; if (conf_get_int(conf, CONF_login_shell)) { char *p = strrchr(shell, '/'); shellname = snewn(2+strlen(shell), char); p = p ? p+1 : shell; sprintf(shellname, "-%s", p); } else shellname = shell; execl(getenv("SHELL"), shellname, (void *)NULL); }
/* * Write a set of name/value pairs in the above format, or just the * names if include_values is FALSE. */ static void wmap(void *handle, char const *outkey, Conf *conf, int primary, int include_values) { char *buf, *p, *q, *key, *realkey, *val; int len; len = 1; /* allow for NUL */ for (val = conf_get_str_strs(conf, primary, NULL, &key); val != NULL; val = conf_get_str_strs(conf, primary, key, &key)) len += 2 + 2 * (strlen(key) + strlen(val)); /* allow for escaping */ buf = snewn(len, char); p = buf; for (val = conf_get_str_strs(conf, primary, NULL, &key); val != NULL; val = conf_get_str_strs(conf, primary, key, &key)) { if (primary == CONF_portfwd && !strcmp(val, "D")) { /* * Backwards-compatibility hack, as above: translate from * the sensible internal representation of dynamic * forwardings (key "L<port>", value "D") to the * conceptually incoherent legacy storage format (key * "D<port>", value empty). */ char *L; realkey = key; /* restore it at end of loop */ val = ""; key = dupstr(key); L = strchr(key, 'L'); if (L) *L = 'D'; } else { realkey = NULL; } if (p != buf) *p++ = ','; for (q = key; *q; q++) { if (*q == '=' || *q == ',' || *q == '\\') *p++ = '\\'; *p++ = *q; } if (include_values) { *p++ = '='; for (q = val; *q; q++) { if (*q == '=' || *q == ',' || *q == '\\') *p++ = '\\'; *p++ = *q; } } if (realkey) { free(key); key = realkey; } } *p = '\0'; write_setting_s(handle, outkey, buf); sfree(buf); }