Develop and Download Open Source Software

Browse Subversion Repository

Diff of /branches/ttcomtester/teraterm/teraterm/commlib.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4858 by yutakapon, Fri Mar 9 15:25:48 2012 UTC revision 4860 by yutakapon, Sat Mar 10 10:32:33 2012 UTC
# Line 229  void CommResetSerial(PTTSet ts, PComVar Line 229  void CommResetSerial(PTTSet ts, PComVar
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
# Line 254  void CommOpen(HWND HW, PTTSet ts, PComVa Line 279  void CommOpen(HWND HW, PTTSet ts, PComVa
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;
# Line 559  void CommOpen(HWND HW, PTTSet ts, PComVa Line 591  void CommOpen(HWND HW, PTTSet ts, PComVa
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;

Legend:
Removed from v.4858  
changed lines
  Added in v.4860

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26