svnno****@sourc*****
svnno****@sourc*****
2015年 7月 12日 (日) 01:37:18 JST
Revision: 5909 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5909 Author: maya Date: 2015-07-12 01:37:16 +0900 (Sun, 12 Jul 2015) Log Message: ----------- Cygwin 接続かどうかを判定する条件を調整 cygterm.cfg のポート範囲設定を利用する http://osdn.jp/ticket/browse.php?group_id=1412&tid=34955 Modified Paths: -------------- trunk/teraterm/common/ttlib.c trunk/teraterm/common/ttlib.h trunk/teraterm/teraterm/addsetting.cpp trunk/teraterm/teraterm/vtwin.cpp -------------- next part -------------- Modified: trunk/teraterm/common/ttlib.c =================================================================== --- trunk/teraterm/common/ttlib.c 2015-07-10 15:13:25 UTC (rev 5908) +++ trunk/teraterm/common/ttlib.c 2015-07-11 16:37:16 UTC (rev 5909) @@ -1151,3 +1151,30 @@ dest[j] = 0; } + +void split_buffer(char *buffer, int delimiter, char **head, char **body) +{ + char *p1, *p2; + + *head = *body = NULL; + + if (!isalnum(*buffer) || (p1 = strchr(buffer, delimiter)) == NULL) { + return; + } + + *head = buffer; + + p2 = buffer; + while (p2 < p1 && !isspace(*p2)) { + p2++; + } + + *p2 = '\0'; + + p1++; + while (*p1 && isspace(*p1)) { + p1++; + } + + *body = p1; +} Modified: trunk/teraterm/common/ttlib.h =================================================================== --- trunk/teraterm/common/ttlib.h 2015-07-10 15:13:25 UTC (rev 5908) +++ trunk/teraterm/common/ttlib.h 2015-07-11 16:37:16 UTC (rev 5909) @@ -57,6 +57,8 @@ PCHAR FAR PASCAL GetParam(PCHAR buff, int size, PCHAR param); void FAR PASCAL DequoteParam(PCHAR dest, int dest_len, PCHAR src); +void split_buffer(char *buffer, int delimiter, char **head, char **body); + #ifdef __cplusplus } #endif Modified: trunk/teraterm/teraterm/addsetting.cpp =================================================================== --- trunk/teraterm/teraterm/addsetting.cpp 2015-07-10 15:13:25 UTC (rev 5908) +++ trunk/teraterm/teraterm/addsetting.cpp 2015-07-11 16:37:16 UTC (rev 5909) @@ -26,34 +26,7 @@ // \x96{\x91̂\xCD vtwin.cpp extern void SetWindowStyle(TTTSet *ts); -void split_buffer(char *buffer, int delimiter, char **head, char **body) -{ - char *p1, *p2; - *head = *body = NULL; - - if (!isalnum(*buffer) || (p1 = strchr(buffer, delimiter)) == NULL) { - return; - } - - *head = buffer; - - p2 = buffer; - while (p2 < p1 && !isspace(*p2)) { - p2++; - } - - *p2 = '\0'; - - p1++; - while (*p1 && isspace(*p1)) { - p1++; - } - - *body = p1; -} - - static void SetupRGBbox(HWND hDlgWnd, int index) { HWND hWnd; Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2015-07-10 15:13:25 UTC (rev 5908) +++ trunk/teraterm/teraterm/vtwin.cpp 2015-07-11 16:37:16 UTC (rev 5909) @@ -3688,13 +3688,49 @@ char *exec = "ttermpro"; STARTUPINFO si; PROCESS_INFORMATION pi; + char cygterm_cfg[MAX_PATH]; + FILE *fp; + char buf[256], *head, *body; + int cygterm_PORT_START = 20000; + int cygterm_PORT_RANGE = 40; + int is_cygwin_port = 0; // \x8C\xBB\x8D݂̐ݒ\xE8\x93\xE0\x97e\x82\xF0\x8B\xA4\x97L\x83\x81\x83\x82\x83\x8A\x82փR\x83s\x81[\x82\xB5\x82Ă\xA8\x82\xAD CopyTTSetToShmem(&ts); - if (ts.TCPPort != 23 && (strcmp(ts.HostName, "127.0.0.1") == 0 || + // cygterm.cfg \x82\xF0\x93ǂݍ\x9E\x82\xDE + strncpy_s(cygterm_cfg, sizeof(cygterm_cfg), ts.HomeDir, _TRUNCATE); + AppendSlash(cygterm_cfg, sizeof(cygterm_cfg)); + strncat_s(cygterm_cfg, sizeof(cygterm_cfg), "cygterm.cfg", _TRUNCATE); + fp = fopen(cygterm_cfg, "r"); + if (fp != NULL) { + while (fgets(buf, sizeof(buf), fp) != NULL) { + int len = strlen(buf); + + if (buf[len - 1] == '\n') + buf[len - 1] = '\0'; + + split_buffer(buf, '=', &head, &body); + if (head == NULL || body == NULL) + continue; + + if (_stricmp(head, "PORT_START") == 0) { + cygterm_PORT_START = atoi(body); + } else if (_stricmp(head, "PORT_RANGE") == 0) { + cygterm_PORT_RANGE = atoi(body); + } + } + fclose(fp); + } + // Cygterm \x82̃|\x81[\x83g\x94͈͓\xE0\x82\xA9\x82ǂ\xA4\x82\xA9 + if (ts.TCPPort >= cygterm_PORT_START && + ts.TCPPort <= cygterm_PORT_START+cygterm_PORT_RANGE) { + is_cygwin_port = 1; + } + + if (is_cygwin_port && (strcmp(ts.HostName, "127.0.0.1") == 0 || strcmp(ts.HostName, "localhost") == 0)) { - // localhost\x82ւ̐ڑ\xB1\x82Ń|\x81[\x83g\x82\xAA23\x88ȊO\x82̎\x9E\x82\xCDcygwin\x90ڑ\xB1\x82Ƃ݂Ȃ\xB7\x81B + // localhost\x82ւ̐ڑ\xB1\x82Ń|\x81[\x83g\x82\xAAcygterm.cfg\x82͈͓̔\xE0\x82̎\x9E\x82\xCDcygwin\x90ڑ\xB1\x82Ƃ݂Ȃ\xB7\x81B OnCygwinConnection(); return; } else if (cv.TelFlag) { // telnet