| 229 |
SetCommMask(cv->ComID,EV_RXCHAR); |
SetCommMask(cv->ComID,EV_RXCHAR); |
| 230 |
} |
} |
| 231 |
|
|
| 232 |
|
// 名前付きパイプが正しい書式かをチェックする。 |
| 233 |
|
// \\ServerName\pipe\PipeName |
| 234 |
|
// |
| 235 |
|
// return 0: 正しい |
| 236 |
|
// -1: 不正 |
| 237 |
|
// (2012.3.10 yutaka) |
| 238 |
|
int CheckNamedPipeFormat(char *p, int size) |
| 239 |
|
{ |
| 240 |
|
int ret = -1; |
| 241 |
|
char *s; |
| 242 |
|
|
| 243 |
|
if (size <= 8) |
| 244 |
|
goto error; |
| 245 |
|
|
| 246 |
|
if (p[0] == '\\' && p[1] == '\\') { |
| 247 |
|
s = strchr(&p[2], '\\'); |
| 248 |
|
if (s && _strnicmp(s+1, "pipe\\", 5) == 0) { |
| 249 |
|
ret = 0; |
| 250 |
|
} |
| 251 |
|
} |
| 252 |
|
|
| 253 |
|
error: |
| 254 |
|
return (ret); |
| 255 |
|
} |
| 256 |
|
|
| 257 |
void CommOpen(HWND HW, PTTSet ts, PComVar cv) |
void CommOpen(HWND HW, PTTSet ts, PComVar cv) |
| 258 |
{ |
{ |
| 259 |
#ifdef NO_INET6 |
#ifdef NO_INET6 |
| 279 |
|
|
| 280 |
char uimsg[MAX_UIMSG]; |
char uimsg[MAX_UIMSG]; |
| 281 |
|
|
| 282 |
|
// ホスト名が名前付きパイプかどうかを調べる。 |
| 283 |
|
if (ts->PortType == IdTCPIP) { |
| 284 |
|
if (CheckNamedPipeFormat(ts->HostName, strlen(ts->HostName)) == 0) { |
| 285 |
|
ts->PortType = IdNamedPipe; |
| 286 |
|
} |
| 287 |
|
} |
| 288 |
|
|
| 289 |
/* initialize ComVar */ |
/* initialize ComVar */ |
| 290 |
cv->InBuffCount = 0; |
cv->InBuffCount = 0; |
| 291 |
cv->InPtr = 0; |
cv->InPtr = 0; |
| 591 |
strncpy_s(P, sizeof(P), ts->HostName, _TRUNCATE); |
strncpy_s(P, sizeof(P), ts->HostName, _TRUNCATE); |
| 592 |
|
|
| 593 |
// 名前付きパイプが正しい書式かをチェックする。 |
// 名前付きパイプが正しい書式かをチェックする。 |
| 594 |
// \\ServerName\pipe\PipeName |
if (CheckNamedPipeFormat(P, strlen(P)) < 0) { |
| 595 |
// (2012.3.10 yutaka) |
InvalidHost = TRUE; |
| 596 |
InvalidHost = TRUE; |
|
|
if (P[0] == '\\' && P[1] == '\\') { |
|
|
char *s = strchr(&P[2], '\\'); |
|
|
if (s && _strnicmp(s+1, "pipe\\", 5) == 0) { |
|
|
InvalidHost = FALSE; |
|
|
} |
|
|
} |
|
|
if (InvalidHost) { |
|
| 597 |
_snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, |
_snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, |
| 598 |
"Invalid pipe name\n[%s]\n" |
"Invalid pipe name\n\n" |
| 599 |
"A valid pipe name has the form\n" |
"A valid pipe name has the form\n" |
| 600 |
"\"\\\\<ServerName\\pipe\\<PipeName>\"", |
"\"\\\\<ServerName>\\pipe\\<PipeName>\"", |
| 601 |
&P[0], GetLastError()); |
GetLastError()); |
| 602 |
get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile); |
get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile); |
| 603 |
MessageBox(cv->HWin,ErrMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION); |
MessageBox(cv->HWin,ErrMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION); |
| 604 |
break; |
break; |