[Ttssh2-commit] [5820] チケット #34943 設定フォルダを開く

svnno****@sourc***** svnno****@sourc*****
2015年 3月 10日 (火) 01:07:16 JST


Revision: 5820
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5820
Author:   yutakapon
Date:     2015-03-10 01:07:11 +0900 (Tue, 10 Mar 2015)
Log Message:
-----------
チケット #34943 設定フォルダを開く

ssh_known_hosts ファイルに対応した。
ただし、先頭の1ファイルのみ。
また、SSH接続をしないと、ssh_known_hosts ファイルがメモリに読み込まれない。

Ticket Links:
------------
    http://sourceforge.jp/projects/ttssh2/tracker/detail/34943

Modified Paths:
--------------
    trunk/teraterm/teraterm/vtwin.cpp
    trunk/ttssh2/ttxssh/ttxssh.c
    trunk/ttssh2/ttxssh/ttxssh.def

-------------- next part --------------
Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2015-03-07 16:09:55 UTC (rev 5819)
+++ trunk/teraterm/teraterm/vtwin.cpp	2015-03-09 16:07:11 UTC (rev 5820)
@@ -4718,6 +4718,10 @@
 	static char eterm2path[MAX_PATH], eterm2filename[MAX_PATH];
 	static char eterm3path[MAX_PATH], eterm3filename[MAX_PATH];
 	char temp[MAX_PATH];
+	typedef int (CALLBACK *PSSH_read_known_hosts_file)(char *, int);
+	PSSH_read_known_hosts_file func = NULL;
+	HMODULE h = NULL;
+	static char hostsfilepath[MAX_PATH], hostsfilename[MAX_PATH];
 
 	switch (msg) {
 	case WM_INITDIALOG:
@@ -4763,9 +4767,21 @@
 		_snprintf_s(temp, sizeof(temp), "%s\\%s", eterm3path, eterm3filename);
 		SetDlgItemText(hDlgWnd, IDC_ETERM3_SETUPDIR_EDIT, temp);
 
-		// TODO: ssh_known_hosts
+		// ssh_known_hosts
+		if (func == NULL) {
+			if (((h = GetModuleHandle("ttxssh.dll")) != NULL)) {
+				func = (PSSH_read_known_hosts_file)GetProcAddress(h, "TTXReadKnownHostsFile");
+				if (func) {
+					int ret = func(hostsfilename, sizeof(hostsfilename));
+					if (ret) {
+						strncpy_s(hostsfilepath, sizeof(hostsfilepath), teratermexepath, _TRUNCATE);
+						_snprintf_s(temp, sizeof(temp), "%s\\%s", hostsfilepath, hostsfilename);
+						SetDlgItemText(hDlgWnd, IDC_SSH_SETUPDIR_EDIT, temp);
+					}
+				}
+			}
+		}
 
-
 		return TRUE;
 
 	case WM_COMMAND:
@@ -4795,7 +4811,7 @@
 			return TRUE;
 
 		case IDC_SSH_SETUPDIR_BUTTON | (BN_CLICKED << 16) :
-			// TODO:
+			openVirtualStore(hostsfilepath, hostsfilename);
 			return TRUE;
 
 		case IDCANCEL:

Modified: trunk/ttssh2/ttxssh/ttxssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.c	2015-03-07 16:09:55 UTC (rev 5819)
+++ trunk/ttssh2/ttxssh/ttxssh.c	2015-03-09 16:07:11 UTC (rev 5820)
@@ -4148,6 +4148,30 @@
 	return SSH_scp_transaction(pvar, remotefile, localfile, FROMREMOTE);
 }
 
+
+// TTSSH\x82̐ݒ\xE8\x93\xE0\x97e(known hosts file)\x82\xF0\x95Ԃ\xB7\x81B
+//
+// return TRUE: \x95ԋp\x90\xAC\x8C\xF7
+//        FALSE: \x8E\xB8\x94s
+// (2015.3.9 yutaka)
+__declspec(dllexport) int CALLBACK TTXReadKnownHostsFile(char *filename, int maxlen)
+{
+	int ret = FALSE;
+	char *p;
+
+	if (pvar->settings.Enabled) {
+		strncpy_s(filename, maxlen, pvar->session_settings.KnownHostsFiles, _TRUNCATE);
+		p = strchr(filename, ';');
+		if (p)
+			*p = 0;
+
+		ret = TRUE;
+	}
+
+	return (ret);
+}
+
+
 static void keygen_progress(int phase, int count, cbarg_t *cbarg) {
 	char buff[1024];
 	static char msg[1024];

Modified: trunk/ttssh2/ttxssh/ttxssh.def
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.def	2015-03-07 16:09:55 UTC (rev 5819)
+++ trunk/ttssh2/ttxssh/ttxssh.def	2015-03-09 16:07:11 UTC (rev 5820)
@@ -3,4 +3,5 @@
 EXPORTS
 	TTXScpSendfile @1
 	TTXScpReceivefile @2
+	TTXReadKnownHostsFile @3
 	
\ No newline at end of file



Ttssh2-commit メーリングリストの案内