OSDN Git Service

Enhance the security of routines for changing a master password.
[ffftp/ffftp.git] / main.c
1 /*=============================================================================\r
2 *\r
3 *                                                                       FFFTP\r
4 *\r
5 ===============================================================================\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.\r
7 /\r
8 / Redistribution and use in source and binary forms, with or without \r
9 / modification, are permitted provided that the following conditions \r
10 / are met:\r
11 /\r
12 /  1. Redistributions of source code must retain the above copyright \r
13 /     notice, this list of conditions and the following disclaimer.\r
14 /  2. Redistributions in binary form must reproduce the above copyright \r
15 /     notice, this list of conditions and the following disclaimer in the \r
16 /     documentation and/or other materials provided with the distribution.\r
17 /\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR \r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES \r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, \r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF \r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
28 /============================================================================*/\r
29 \r
30 #define  STRICT\r
31 // IPv6対応\r
32 #include <winsock2.h>\r
33 #include <windows.h>\r
34 #include <stdio.h>\r
35 #include <stdlib.h>\r
36 #include <string.h>\r
37 #include <mbstring.h>\r
38 #include <malloc.h>\r
39 #include <windowsx.h>\r
40 #include <commctrl.h>\r
41 #include <stdarg.h>\r
42 // IPv6対応\r
43 //#include <winsock.h>\r
44 \r
45 #include "common.h"\r
46 #include "resource.h"\r
47 #include "aes.h"\r
48 // 暗号化通信対応\r
49 #include "sha.h"\r
50 \r
51 #include <htmlhelp.h>\r
52 #include "helpid.h"\r
53 \r
54 // UTF-8対応\r
55 #undef __MBSWRAPPER_H__\r
56 #include "mbswrapper.h"\r
57 \r
58 \r
59 #define RESIZE_OFF              0               /* ウインドウの区切り位置変更していない */\r
60 #define RESIZE_ON               1               /* ウインドウの区切り位置変更中 */\r
61 #define RESIZE_PREPARE  2               /* ウインドウの区切り位置変更の準備 */\r
62 \r
63 #define RESIZE_HPOS             0               /* ローカル-ホスト間の区切り位置変更 */\r
64 #define RESIZE_VPOS             1               /* リスト-タスク間の区切り位置の変更 */\r
65 \r
66 \r
67 /*===== プロトタイプ =====*/\r
68 \r
69 static int InitApp(LPSTR lpszCmdLine, int cmdShow);\r
70 static int MakeAllWindows(int cmdShow);\r
71 static void DeleteAllObject(void);\r
72 static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r
73 static void StartupProc(char *Cmd);\r
74 static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc, int Max);\r
75 static int CheckIniFileName(char *Str, char *Ini);\r
76 static int CheckMasterPassword(char *Str, char *Ini);\r
77 static int GetTokenAfterOption(char *Str, char *Result, const char* Opt1, const char* Opt2 );\r
78 static char *GetToken(char *Str, char *Buf);\r
79 static void ExitProc(HWND hWnd);\r
80 static void ChangeDir(int Win, char *Path);\r
81 static void ResizeWindowProc(void);\r
82 static void CalcWinSize(void);\r
83 // static void AskWindowPos(HWND hWnd);\r
84 static void CheckResizeFrame(WPARAM Keys, int x, int y);\r
85 static void DispDirInfo(void);\r
86 static void DeleteAlltempFile(void);\r
87 // 64ビット対応\r
88 //static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
89 static INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
90 static int EnterMasterPasswordAndSet( int Res, HWND hWnd );\r
91 \r
92 /*===== ローカルなワーク =====*/\r
93 \r
94 static const char FtpClassStr[] = "FFFTPWin";\r
95 \r
96 static HINSTANCE hInstFtp;\r
97 static HWND hWndFtp = NULL;\r
98 static HWND hWndCurFocus = NULL;\r
99 \r
100 static HACCEL Accel;\r
101 static HBRUSH RootColorBrush = NULL;\r
102 \r
103 static int Resizing = RESIZE_OFF;\r
104 static int ResizePos;\r
105 static HCURSOR hCursor;\r
106 \r
107 int ClientWidth;\r
108 static int ClientHeight;\r
109 int SepaWidth;\r
110 int RemoteWidth;\r
111 int ListHeight;\r
112 \r
113 static TEMPFILELIST *TempFiles = NULL;\r
114 \r
115 static int SaveExit = YES;\r
116 static int AutoExit = NO;\r
117 \r
118 static char HelpPath[FMAX_PATH+1];\r
119 static char IniPath[FMAX_PATH+1];\r
120 static int ForceIni = NO;\r
121 \r
122 TRANSPACKET MainTransPkt;               /* ファイル転送用パケット */\r
123                                                                 /* これを使って転送を行うと、ツールバーの転送 */\r
124                                                                 /* 中止ボタンで中止できる */\r
125 \r
126 char TitleHostName[HOST_ADRS_LEN+1];\r
127 char FilterStr[FILTER_EXT_LEN+1] = { "*" };\r
128 \r
129 int CancelFlg;\r
130 \r
131 // 外部アプリケーションへドロップ後にローカル側のファイル一覧に作業フォルダが表示されるバグ対策\r
132 //static int SuppressRefresh = 0;\r
133 int SuppressRefresh = 0;\r
134 \r
135 static DWORD dwCookie;\r
136 \r
137 // 暗号化通信対応\r
138 static char SSLRootCAFilePath[FMAX_PATH+1];\r
139 // マルチコアCPUの特定環境下でファイル通信中にクラッシュするバグ対策\r
140 static DWORD MainThreadId;\r
141 // ポータブル版判定\r
142 static char PortableFilePath[FMAX_PATH+1];\r
143 int PortableVersion;\r
144 \r
145 \r
146 /*===== グローバルなワーク =====*/\r
147 \r
148 HWND hHelpWin = NULL;\r
149 \r
150 /* 設定値 */\r
151 int WinPosX = CW_USEDEFAULT;\r
152 int WinPosY = 0;\r
153 // 機能が増えたためサイズ変更\r
154 // VGAサイズに収まるようになっていたのをSVGAサイズに引き上げ\r
155 //int WinWidth = 630;\r
156 //int WinHeight = 393;\r
157 //int LocalWidth = 309;\r
158 //int TaskHeight = 50;\r
159 //int LocalTabWidth[4] = { 120, 90, 60, 37 };\r
160 //int RemoteTabWidth[6] = { 120, 90, 60, 37, 60, 60 };\r
161 int WinWidth = 790;\r
162 int WinHeight = 513;\r
163 int LocalWidth = 389;\r
164 int TaskHeight = 100;\r
165 int LocalTabWidth[4] = { 160, 110, 60, 37 };\r
166 int RemoteTabWidth[6] = { 160, 110, 60, 37, 60, 60 };\r
167 char UserMailAdrs[USER_MAIL_LEN+1] = { "who@example.com" };\r
168 char ViewerName[VIEWERS][FMAX_PATH+1] = { { "notepad" }, { "" }, { "" } };\r
169 HFONT ListFont = NULL;\r
170 LOGFONT ListLogFont;\r
171 int LocalFileSort = SORT_NAME;\r
172 int LocalDirSort = SORT_NAME;\r
173 int RemoteFileSort = SORT_NAME;\r
174 int RemoteDirSort = SORT_NAME;\r
175 int TransMode = TYPE_X;\r
176 int ConnectOnStart = YES;\r
177 int DebugConsole = NO;\r
178 int SaveWinPos = NO;\r
179 char AsciiExt[ASCII_EXT_LEN+1] = { "*.txt\0*.html\0*.htm\0*.cgi\0*.pl\0" };\r
180 int RecvMode = TRANS_DLG;\r
181 int SendMode = TRANS_DLG;\r
182 int MoveMode = MOVE_DLG;\r
183 int ListType = LVS_REPORT;\r
184 // LISTのキャッシュを無効にする(リモートのディレクトリの表示が更新されないバグ対策)\r
185 //int CacheEntry = 10;\r
186 int CacheEntry = -10;\r
187 int CacheSave = NO;\r
188 char DefaultLocalPath[FMAX_PATH+1] = { "" };\r
189 int SaveTimeStamp = YES;\r
190 int FindMode = 0;\r
191 int DotFile = YES;\r
192 int DclickOpen = YES;\r
193 int ConnectAndSet = YES;\r
194 SOUNDFILE Sound[SOUND_TYPES] = { { NO, "" }, { NO, "" }, { NO, "" } };\r
195 int FnameCnv = FNAME_NOCNV;\r
196 int TimeOut = 90;\r
197 int RmEOF = NO;\r
198 int RegType = REGTYPE_REG;\r
199 char FwallHost[HOST_ADRS_LEN+1] = { "" };\r
200 char FwallUser[USER_NAME_LEN+1] = { "" };\r
201 char FwallPass[PASSWORD_LEN+1] = { "" };\r
202 int FwallPort = PORT_NOR;\r
203 int FwallType = 1;\r
204 int FwallDefault = NO;\r
205 int FwallSecurity = SECURITY_AUTO;\r
206 int FwallResolv = NO;\r
207 int FwallLower = NO;\r
208 int FwallDelimiter = '@';\r
209 int PasvDefault = NO;\r
210 char MirrorNoTrn[MIRROR_LEN+1] = { "*.bak\0" };\r
211 char MirrorNoDel[MIRROR_LEN+1] = { "" };\r
212 int MirrorFnameCnv = NO;\r
213 int SplitVertical = YES;\r
214 int RasClose = NO;\r
215 int RasCloseNotify = YES;\r
216 int FileHist = 5;\r
217 char DefAttrList[DEFATTRLIST_LEN+1] = { "" };\r
218 SIZE HostDlgSize = { -1, -1 };\r
219 SIZE BmarkDlgSize = { -1, -1 };\r
220 SIZE MirrorDlgSize = { -1, -1 };\r
221 int Sizing = SW_RESTORE;\r
222 int SortSave = NO;\r
223 char TmpPath[FMAX_PATH+1];\r
224 int QuickAnonymous = YES;\r
225 int PassToHist = YES;\r
226 int VaxSemicolon = NO;\r
227 int SendQuit = NO;\r
228 int NoRasControl = NO;\r
229 int SuppressSave = NO;\r
230 int DispIgnoreHide = NO;\r
231 int DispDrives = NO;\r
232 int MirUpDelNotify = YES; \r
233 int MirDownDelNotify = YES; \r
234 int FolderAttr = NO;\r
235 int FolderAttrNum = 777;\r
236 // 暗号化通信対応\r
237 BYTE CertificateCacheHash[MAX_CERT_CACHE_HASH][20];\r
238 BYTE SSLRootCAFileHash[20];\r
239 // ファイルアイコン表示対応\r
240 int DispFileIcon = NO;\r
241 // ディレクトリ自動作成\r
242 int MakeAllDir = YES;\r
243 \r
244 \r
245 \r
246 \r
247 \r
248 /*----- メインルーチン --------------------------------------------------------\r
249 *\r
250 *       Parameter\r
251 *               HINSTANCE hInstance : このアプリケーションのこのインスタンスのハンドル\r
252 *               HINSTANCE hPrevInstance : このアプリケーションの直前のインスタンスのハンドル\r
253 *               LPSTR lpszCmdLine : アプリケーションが起動したときのコマンドラインをさすロングポインタ\r
254 *               int cmdShow : 最初に表示するウインドウの形式。\r
255 *\r
256 *       Return Value\r
257 *               int 最後のメッセージのwParam\r
258 *----------------------------------------------------------------------------*/\r
259 \r
260 int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int cmdShow)\r
261 {\r
262     MSG Msg;\r
263         int Ret;\r
264         BOOL Sts;\r
265 \r
266         // プロセス保護\r
267 #ifdef ENABLE_PROCESS_PROTECTION\r
268         {\r
269                 DWORD ProtectLevel;\r
270                 char* pCommand;\r
271                 char Option[FMAX_PATH+1];\r
272                 ProtectLevel = PROCESS_PROTECTION_NONE;\r
273                 pCommand = lpszCmdLine;\r
274                 while(pCommand = GetToken(pCommand, Option))\r
275                 {\r
276                         if(strcmp(Option, "--protect") == 0)\r
277                         {\r
278                                 ProtectLevel = PROCESS_PROTECTION_DEFAULT;\r
279                                 break;\r
280                         }\r
281                         else if(strcmp(Option, "--protect-high") == 0)\r
282                         {\r
283                                 ProtectLevel = PROCESS_PROTECTION_HIGH;\r
284                                 break;\r
285                         }\r
286                         else if(strcmp(Option, "--protect-medium") == 0)\r
287                         {\r
288                                 ProtectLevel = PROCESS_PROTECTION_MEDIUM;\r
289                                 break;\r
290                         }\r
291                         else if(strcmp(Option, "--protect-low") == 0)\r
292                         {\r
293                                 ProtectLevel = PROCESS_PROTECTION_LOW;\r
294                                 break;\r
295                         }\r
296                 }\r
297                 if(ProtectLevel != PROCESS_PROTECTION_NONE)\r
298                 {\r
299                         SetProcessProtectionLevel(ProtectLevel);\r
300                         if(!InitializeLoadLibraryHook())\r
301                         {\r
302                                 MessageBox(NULL, MSGJPN321, "FFFTP", MB_OK | MB_ICONERROR);\r
303                                 return 0;\r
304                         }\r
305 #ifndef _DEBUG\r
306                         if(IsDebuggerPresent())\r
307                         {\r
308                                 MessageBox(NULL, MSGJPN322, "FFFTP", MB_OK | MB_ICONERROR);\r
309                                 return 0;\r
310                         }\r
311 #endif\r
312                         if(!UnloadUntrustedModule())\r
313                         {\r
314                                 MessageBox(NULL, MSGJPN323, "FFFTP", MB_OK | MB_ICONERROR);\r
315                                 return 0;\r
316                         }\r
317 #ifndef _DEBUG\r
318                         if(RestartProtectedProcess(" --restart"))\r
319                                 return 0;\r
320 #endif\r
321                         if(!EnableLoadLibraryHook(TRUE))\r
322                         {\r
323                                 MessageBox(NULL, MSGJPN324, "FFFTP", MB_OK | MB_ICONERROR);\r
324                                 return 0;\r
325                         }\r
326                 }\r
327                 else\r
328                         InitializeLoadLibraryHook();\r
329         }\r
330 #endif\r
331 \r
332         // マルチコアCPUの特定環境下でファイル通信中にクラッシュするバグ対策\r
333 #ifdef DISABLE_MULTI_CPUS\r
334         SetProcessAffinityMask(GetCurrentProcess(), 1);\r
335 #endif\r
336         MainThreadId = GetCurrentThreadId();\r
337 \r
338         // yutaka\r
339         if(OleInitialize(NULL) != S_OK){\r
340                 MessageBox(NULL, MSGJPN298, "FFFTP", MB_OK | MB_ICONERROR);\r
341                 return 0;\r
342         }\r
343 \r
344         InitCommonControls();\r
345 \r
346         // FTPS対応\r
347 #ifdef USE_OPENSSL\r
348         LoadOpenSSL();\r
349 #endif\r
350 \r
351         // SFTP対応\r
352         LoadPuTTY();\r
353 \r
354         Ret = FALSE;\r
355         hWndFtp = NULL;\r
356         hInstFtp = hInstance;\r
357         if(InitApp(lpszCmdLine, cmdShow) == FFFTP_SUCCESS)\r
358         {\r
359                 for(;;)\r
360                 {\r
361                         Sts = GetMessage(&Msg, NULL, 0, 0);\r
362                         if((Sts == 0) || (Sts == -1))\r
363                                 break;\r
364 \r
365                         // 64ビット対応\r
366 //                      if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))\r
367                         if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD_PTR)&Msg))\r
368                         { \r
369                                 /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */\r
370                                 /* コンボボックス内ではアクセラレータを無効にする */\r
371                                 if((Msg.hwnd == GetLocalHistEditHwnd()) ||\r
372                                    (Msg.hwnd == GetRemoteHistEditHwnd()) ||\r
373                                    ((hHelpWin != NULL) && (GetAncestor(Msg.hwnd, GA_ROOT) == hHelpWin)) ||\r
374                                    GetHideUI() == YES ||\r
375                                    (TranslateAccelerator(hWndFtp, Accel, &Msg) == 0))\r
376                                 {\r
377                                         TranslateMessage(&Msg);\r
378                                         DispatchMessage(&Msg);\r
379                                 }\r
380                         }\r
381                 }\r
382                 Ret = Msg.wParam;\r
383         }\r
384     UnregisterClass(FtpClassStr, hInstFtp);\r
385         // FTPS対応\r
386 #ifdef USE_OPENSSL\r
387         FreeOpenSSL();\r
388 #endif\r
389         // SFTP対応\r
390         FreePuTTY();\r
391         OleUninitialize();\r
392         return(Ret);\r
393 }\r
394 \r
395 \r
396 /*----- アプリケーションの初期設定 --------------------------------------------\r
397 *\r
398 *       Parameter\r
399 *               HINSTANCE hInstance : このアプリケーションのこのインスタンスのハンドル\r
400 *               HINSTANCE hPrevInstance : このアプリケーションの直前のインスタンスのハンドル\r
401 *               LPSTR lpszCmdLine : アプリケーションが起動したときのコマンドラインをさすロングポインタ\r
402 *               int cmdShow : 最初に表示するウインドウの形式。\r
403 *\r
404 *       Return Value\r
405 *               int ステータス\r
406 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
407 *----------------------------------------------------------------------------*/\r
408 \r
409 static int InitApp(LPSTR lpszCmdLine, int cmdShow)\r
410 {\r
411         int sts;\r
412         int Err;\r
413         WSADATA WSAData;\r
414         char PwdBuf[FMAX_PATH+1];\r
415         int useDefautPassword = 0; /* 警告文表示用 */\r
416         int masterpass;\r
417         // ポータブル版判定\r
418         int ImportPortable;\r
419 \r
420         sts = FFFTP_FAIL;\r
421 \r
422         aes_init();\r
423         srand(GetTickCount());\r
424         \r
425         // 64ビット対応\r
426 //      HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD)&dwCookie);\r
427         HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD_PTR)&dwCookie);\r
428 \r
429         SaveUpdateBellInfo();\r
430 \r
431         if((Err = WSAStartup((WORD)0x0202, &WSAData)) != 0)\r
432                 MessageBox(NULL, ReturnWSError(Err), "FFFTP - Startup", MB_OK);\r
433         else\r
434         {\r
435                 Accel = LoadAccelerators(hInstFtp, MAKEINTRESOURCE(ffftp_accel));\r
436 \r
437                 // 環境依存の不具合対策\r
438 //              GetTempPath(FMAX_PATH, TmpPath);\r
439                 GetAppTempPath(TmpPath);\r
440                 _mkdir(TmpPath);\r
441                 SetYenTail(TmpPath);\r
442 \r
443                 GetModuleFileName(NULL, HelpPath, FMAX_PATH);\r
444                 strcpy(GetFileName(HelpPath), "ffftp.chm");\r
445 \r
446                 if(CheckIniFileName(lpszCmdLine, IniPath) == 0)\r
447                 {\r
448                         GetModuleFileName(NULL, IniPath, FMAX_PATH);\r
449                         strcpy(GetFileName(IniPath), "ffftp.ini");\r
450                 }\r
451                 else\r
452                 {\r
453                         ForceIni = YES;\r
454                         RegType = REGTYPE_INI;\r
455                 }\r
456                 // ポータブル版判定\r
457                 GetModuleFileName(NULL, PortableFilePath, FMAX_PATH);\r
458                 strcpy(GetFileName(PortableFilePath), "portable");\r
459                 CheckPortableVersion();\r
460                 ImportPortable = NO;\r
461                 if(PortableVersion == YES)\r
462                 {\r
463                         ForceIni = YES;\r
464                         RegType = REGTYPE_INI;\r
465                         if(IsRegAvailable() == YES && IsIniAvailable() == NO)\r
466                         {\r
467                                 if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(ini_from_reg_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
468                                 {\r
469                                         ImportPortable = YES;\r
470                                         ForceIni = NO;\r
471                                         RegType = REGTYPE_REG;\r
472                                 }\r
473                         }\r
474                 }\r
475 \r
476 //              AllocConsole();\r
477 \r
478                 /* 2010.02.01 genta マスターパスワードを入力させる\r
479                   -z オプションがあるときは最初だけスキップ\r
480                   -z オプションがないときは,デフォルトパスワードをまず試す\r
481                   LoadRegistry()する\r
482                   パスワードが不一致なら再入力するか尋ねる.\r
483                   (破損していた場合はさせない)\r
484                 */\r
485                 if( CheckMasterPassword(lpszCmdLine, PwdBuf))\r
486                 {\r
487                         SetMasterPassword( PwdBuf );\r
488                         useDefautPassword = 0;\r
489                 }\r
490                 else {\r
491                         /* パスワード指定無し */\r
492                         SetMasterPassword( NULL );\r
493                         /* この場では表示できないのでフラグだけ立てておく*/\r
494                         useDefautPassword = 2;\r
495                 }\r
496 \r
497                 /* パスワードチェックのみ実施 */\r
498                 masterpass = 1;\r
499                 while( ValidateMasterPassword() == YES &&\r
500                                 GetMasterPasswordStatus() == PASSWORD_UNMATCH ){\r
501                         \r
502                         if( useDefautPassword != 2 ){\r
503                                 /* 再トライするか確認 */\r
504                                 if( MessageBox(NULL, MSGJPN304, "FFFTP", MB_YESNO | MB_ICONEXCLAMATION) == IDNO ){\r
505                                         useDefautPassword = 0; /* 不一致なので,もはやデフォルトかどうかは分からない */\r
506                                         break;\r
507                                 }\r
508                         }\r
509                         \r
510                         /* 再入力させる*/\r
511                         masterpass = EnterMasterPasswordAndSet(masterpasswd_dlg, NULL);\r
512                         if( masterpass == 2 ){\r
513                                 useDefautPassword = 1;\r
514                         }\r
515                         else if( masterpass == 0 ){\r
516                                 SaveExit = NO;\r
517                                 break;\r
518                         }\r
519                         else {\r
520                                 useDefautPassword = 0;\r
521                         }\r
522                 }\r
523                 \r
524                 if(masterpass != 0)\r
525                 {\r
526                         LoadRegistry();\r
527 \r
528                         // ポータブル版判定\r
529                         if(ImportPortable == YES)\r
530                         {\r
531                                 ForceIni = YES;\r
532                                 RegType = REGTYPE_INI;\r
533                         }\r
534 \r
535                         // 暗号化通信対応\r
536                         SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);\r
537                         SetSSLConfirmCallback(SSLConfirmCallback);\r
538                         GetModuleFileName(NULL, SSLRootCAFilePath, FMAX_PATH);\r
539                         strcpy(GetFileName(SSLRootCAFilePath), "ssl.pem");\r
540                         LoadSSLRootCAFile();\r
541 \r
542                         LoadJre();\r
543                         if(NoRasControl == NO)\r
544                                 LoadRasLib();\r
545                         LoadKernelLib();\r
546 \r
547                         //タイマの精度を改善\r
548                         timeBeginPeriod(1);\r
549 \r
550                         CountPrevFfftpWindows();\r
551 \r
552                         if(MakeAllWindows(cmdShow) == FFFTP_SUCCESS)\r
553                         {\r
554                                 hWndCurFocus = GetLocalHwnd();\r
555 \r
556                                 if(strlen(DefaultLocalPath) > 0)\r
557                                         SetCurrentDirectory(DefaultLocalPath);\r
558 \r
559                                 SetSortTypeImm(LocalFileSort, LocalDirSort, RemoteFileSort, RemoteDirSort);\r
560                                 SetTransferTypeImm(TransMode);\r
561                                 DispTransferType();\r
562                                 SetHostKanaCnvImm(YES);\r
563                                 SetHostKanjiCodeImm(KANJI_NOCNV);\r
564                                 // 本当はローカルのデフォルトをUTF-8にしたいが旧バージョンとの互換性のためShift_JISに設定\r
565 //                              SetLocalKanjiCodeImm(KANJI_UTF8N);\r
566                                 SetLocalKanjiCodeImm(KANJI_SJIS);\r
567                                 DispListType();\r
568                                 DispDotFileMode();\r
569                                 DispSyncMoveMode();\r
570 \r
571                                 MakeCacheBuf(CacheEntry);\r
572                                 if(CacheSave == YES)\r
573                                         LoadCache();\r
574 \r
575                                 if(MakeTransferThread() == FFFTP_SUCCESS)\r
576                                 {\r
577                                         DoPrintf("DEBUG MESSAGE ON ! ##");\r
578 \r
579                                         DispWindowTitle();\r
580                                         // SourceForge.JPによるフォーク\r
581 //                                      SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.");\r
582                                         SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.\r\nCopyright (C) 2011-2012 FFFTP Project (Hiromichi Matsushima, Suguru Kawamoto, IWAMOTO Kouichi, vitamin0x, unarist, Asami, fortran90, tomo1192, Yuji Tanaka, Moriguchi Hirokazu).");\r
583 \r
584                                         if(ForceIni)\r
585                                                 SetTaskMsg("%s%s", MSGJPN283, IniPath);\r
586 \r
587                                         if(IsFolderExist(TmpPath) == NO)\r
588                                         {\r
589                                                 SetTaskMsg(MSGJPN152, TmpPath);\r
590                                                 GetTempPath(FMAX_PATH, TmpPath);\r
591                                                 SetTaskMsg(MSGJPN153, TmpPath);\r
592                                         }\r
593 \r
594                                         DoPrintf("Tmp =%s", TmpPath);\r
595                                         DoPrintf("Help=%s", HelpPath);\r
596 \r
597                                         DragAcceptFiles(GetRemoteHwnd(), TRUE);\r
598                                         DragAcceptFiles(GetLocalHwnd(), TRUE);\r
599 \r
600                                         SetAllHistoryToMenu();\r
601                                         GetLocalDirForWnd();\r
602                                         MakeButtonsFocus();\r
603                                         DispTransferFiles();\r
604 \r
605                                         StartupProc(lpszCmdLine);\r
606                                         sts = FFFTP_SUCCESS;\r
607 \r
608                                         /* セキュリティ警告文の表示 */\r
609                                         if( useDefautPassword ){\r
610                                                 SetTaskMsg(MSGJPN300);\r
611                                         }\r
612                                         \r
613                                         /* パスワード不一致警告文の表示 */\r
614                                         switch( GetMasterPasswordStatus() ){\r
615                                         case PASSWORD_UNMATCH:\r
616                                                 SetTaskMsg(MSGJPN301);\r
617                                                 break;\r
618                                         case BAD_PASSWORD_HASH:\r
619                                                 SetTaskMsg(MSGJPN302);\r
620                                                 break;\r
621                                         default:\r
622                                                 break;\r
623                                         }\r
624                                 }\r
625                         }\r
626                 }\r
627         }\r
628 \r
629         // 暗号化通信対応\r
630 #ifdef USE_OPENSSL\r
631         if(IsOpenSSLLoaded())\r
632                 SetTaskMsg(MSGJPN318);\r
633         else\r
634                 SetTaskMsg(MSGJPN319);\r
635 #endif\r
636 \r
637         if(sts == FFFTP_FAIL)\r
638                 DeleteAllObject();\r
639 \r
640         return(sts);\r
641 }\r
642 \r
643 \r
644 /*----- ウインドウを作成する --------------------------------------------------\r
645 *\r
646 *       Parameter\r
647 *               int cmdShow : 最初に表示するウインドウの形式。\r
648 *\r
649 *       Return Value\r
650 *               int ステータス\r
651 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
652 *----------------------------------------------------------------------------*/\r
653 \r
654 static int MakeAllWindows(int cmdShow)\r
655 {\r
656         RECT Rect1;\r
657         RECT Rect2;\r
658         WNDCLASSEX wClass;\r
659         int Sts;\r
660         int StsTask;\r
661         int StsSbar;\r
662         int StsTbar;\r
663         int StsList;\r
664         int StsLvtips;\r
665         int StsSocket;\r
666 \r
667         /*===== メインウインドウ =====*/\r
668 \r
669         RootColorBrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));\r
670 \r
671         wClass.cbSize = sizeof(WNDCLASSEX);\r
672         wClass.style         = 0;\r
673         wClass.lpfnWndProc   = FtpWndProc;\r
674         wClass.cbClsExtra    = 0;\r
675         wClass.cbWndExtra    = 0;\r
676         wClass.hInstance     = hInstFtp;\r
677         wClass.hIcon         = LoadIcon(hInstFtp, MAKEINTRESOURCE(ffftp));\r
678         wClass.hCursor       = NULL;\r
679         wClass.hbrBackground = RootColorBrush;\r
680         wClass.lpszMenuName  = (LPSTR)MAKEINTRESOURCE(main_menu);\r
681         wClass.lpszClassName = FtpClassStr;\r
682         wClass.hIconSm       = NULL;\r
683         RegisterClassEx(&wClass);\r
684 \r
685         if(SaveWinPos == NO)\r
686         {\r
687                 WinPosX = CW_USEDEFAULT;\r
688                 WinPosY = 0;\r
689         }\r
690         hWndFtp = CreateWindow(FtpClassStr, "FFFTP",\r
691                                 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,\r
692                                 WinPosX, WinPosY, WinWidth, WinHeight,\r
693                                 HWND_DESKTOP, 0, hInstFtp, NULL);\r
694 \r
695         if(hWndFtp != NULL)\r
696         {\r
697                 SystemParametersInfo(SPI_GETWORKAREA, 0, &Rect1, 0);\r
698                 GetWindowRect(hWndFtp, &Rect2);\r
699                 if(Rect2.bottom > Rect1.bottom)\r
700                 {\r
701                         Rect2.top = max1(0, Rect2.top - (Rect2.bottom - Rect1.bottom));\r
702                         MoveWindow(hWndFtp, Rect2.left, Rect2.top, WinWidth, WinHeight, FALSE);\r
703                 }\r
704 \r
705                 /*===== ステイタスバー =====*/\r
706 \r
707                 StsSbar = MakeStatusBarWindow(hWndFtp, hInstFtp);\r
708 \r
709                 CalcWinSize();\r
710 \r
711                 /*===== ツールバー =====*/\r
712 \r
713                 StsTbar = MakeToolBarWindow(hWndFtp, hInstFtp);\r
714 \r
715                 /*===== ファイルリストウインドウ =====*/\r
716 \r
717                 StsList = MakeListWin(hWndFtp, hInstFtp);\r
718 \r
719                 /*==== タスクウインドウ ====*/\r
720 \r
721                 StsTask = MakeTaskWindow(hWndFtp, hInstFtp);\r
722 \r
723                 if((cmdShow != SW_MINIMIZE) && (cmdShow != SW_SHOWMINIMIZED) && (cmdShow != SW_SHOWMINNOACTIVE) &&\r
724                    (Sizing == SW_MAXIMIZE))\r
725                         cmdShow = SW_MAXIMIZE;\r
726 \r
727                 ShowWindow(hWndFtp, cmdShow);\r
728 \r
729                 /*==== ソケットウインドウ ====*/\r
730 \r
731                 StsSocket = MakeSocketWin(hWndFtp, hInstFtp);\r
732 \r
733                 StsLvtips = InitListViewTips(hWndFtp, hInstFtp);\r
734         }\r
735 \r
736         Sts = FFFTP_SUCCESS;\r
737         if((hWndFtp == NULL) ||\r
738            (StsTbar == FFFTP_FAIL) ||\r
739            (StsList == FFFTP_FAIL) ||\r
740            (StsSbar == FFFTP_FAIL) ||\r
741            (StsTask == FFFTP_FAIL) ||\r
742            (StsLvtips == FFFTP_FAIL) ||\r
743            (StsSocket == FFFTP_FAIL))\r
744         {\r
745                 Sts = FFFTP_FAIL;\r
746         }\r
747 \r
748         if(Sts == FFFTP_SUCCESS)\r
749                 SetListViewType();\r
750 \r
751         return(Sts);\r
752 }\r
753 \r
754 \r
755 /*----- ウインドウのタイトルを表示する ----------------------------------------\r
756 *\r
757 *       Parameter\r
758 *               なし\r
759 *\r
760 *       Return Value\r
761 *               なし\r
762 *----------------------------------------------------------------------------*/\r
763 \r
764 void DispWindowTitle(void)\r
765 {\r
766         char Tmp[HOST_ADRS_LEN+FILTER_EXT_LEN+20];\r
767 \r
768         if(AskConnecting() == YES)\r
769                 sprintf(Tmp, "%s (%s) - FFFTP", TitleHostName, FilterStr);\r
770         else\r
771                 sprintf(Tmp, "FFFTP (%s)", FilterStr);\r
772 \r
773         SetWindowText(GetMainHwnd(), Tmp);\r
774         return;\r
775 }\r
776 \r
777 \r
778 /*----- 全てのオブジェクトを削除 ----------------------------------------------\r
779 *\r
780 *       Parameter\r
781 *               なし\r
782 *\r
783 *       Return Value\r
784 *               なし\r
785 *----------------------------------------------------------------------------*/\r
786 \r
787 static void DeleteAllObject(void)\r
788 {\r
789         DeleteCacheBuf();\r
790 \r
791 //move to WM_DESTROY\r
792         WSACleanup();\r
793 \r
794 //test システム任せ\r
795 //      if(ListFont != NULL)\r
796 //              DeleteObject(ListFont);\r
797 //      if(RootColorBrush != NULL)\r
798 //              DeleteObject(RootColorBrush);\r
799 \r
800 //test システム任せ\r
801 //      DeleteListViewTips();\r
802 //      DeleteListWin();\r
803 //      DeleteStatusBarWindow();\r
804 //      DeleteTaskWindow();\r
805 //      DeleteToolBarWindow();\r
806 //      DeleteSocketWin();\r
807 \r
808 //move to WM_DESTROY\r
809         if(hWndFtp != NULL)\r
810                 DestroyWindow(hWndFtp);\r
811 \r
812         ReleaseJre();\r
813         ReleaseRasLib();\r
814         ReleaseKernelLib();\r
815 \r
816         return;\r
817 }\r
818 \r
819 \r
820 /*----- メインウインドウのウインドウハンドルを返す ----------------------------\r
821 *\r
822 *       Parameter\r
823 *               なし\r
824 *\r
825 *       Return Value\r
826 *               HWND ウインドウハンドル\r
827 *----------------------------------------------------------------------------*/\r
828 \r
829 HWND GetMainHwnd(void)\r
830 {\r
831         return(hWndFtp);\r
832 }\r
833 \r
834 \r
835 /*----- 現在フォーカスがあるウインドウのウインドウハンドルを返す --------------\r
836 *\r
837 *       Parameter\r
838 *               なし\r
839 *\r
840 *       Return Value\r
841 *               HWND ウインドウハンドル\r
842 *----------------------------------------------------------------------------*/\r
843 \r
844 HWND GetFocusHwnd(void)\r
845 {\r
846         return(hWndCurFocus);\r
847 }\r
848 \r
849 \r
850 /*----- 現在フォーカスがあるウインドウのをセットする --------------------------\r
851 *\r
852 *       Parameter\r
853 *               HWND hWnd : ウインドウハンドル\r
854 *\r
855 *       Return Value\r
856 *               なし\r
857 *----------------------------------------------------------------------------*/\r
858 \r
859 void SetFocusHwnd(HWND hWnd)\r
860 {\r
861         hWndCurFocus = hWnd;\r
862         return;\r
863 }\r
864 \r
865 \r
866 /*----- プログラムのインスタンスを返す ----------------------------------------\r
867 *\r
868 *       Parameter\r
869 *               なし\r
870 *\r
871 *       Return Value\r
872 *               HINSTANCE インスタンス\r
873 *----------------------------------------------------------------------------*/\r
874 \r
875 HINSTANCE GetFtpInst(void)\r
876 {\r
877         return(hInstFtp);\r
878 }\r
879 \r
880 \r
881 /*----- メインウインドウのメッセージ処理 --------------------------------------\r
882 *\r
883 *       Parameter\r
884 *               HWND hWnd : ウインドウハンドル\r
885 *               UINT message  : メッセージ番号\r
886 *               WPARAM wParam : メッセージの WPARAM 引数\r
887 *               LPARAM lParam : メッセージの LPARAM 引数\r
888 *\r
889 *       Return Value\r
890 *               メッセージに対応する戻り値\r
891 *----------------------------------------------------------------------------*/\r
892 \r
893 static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
894 {\r
895         PAINTSTRUCT ps;\r
896         LPTOOLTIPTEXT lpttt;\r
897         // UTF-8対応\r
898         LPTOOLTIPTEXTW wlpttt;\r
899         RECT Rect;\r
900 \r
901         int TmpTransType;\r
902 \r
903         switch (message)\r
904         {\r
905                 // 自動切断対策\r
906                 case WM_TIMER :\r
907                         if(wParam == 1)\r
908                                 NoopProc();\r
909                         break;\r
910 \r
911                 case WM_COMMAND :\r
912                         // 同時接続対応\r
913                         // 中断後に受信バッファに応答が残っていると次のコマンドの応答が正しく処理できない\r
914                         if(CancelFlg == YES)\r
915                                 RemoveReceivedData(AskCmdCtrlSkt());\r
916                         switch(LOWORD(wParam))\r
917                         {\r
918                                 case MENU_CONNECT :\r
919                                         // 自動切断対策\r
920                                         KillTimer(hWnd, 1);\r
921                                         ConnectProc(DLG_TYPE_CON, -1);\r
922                                         // 自動切断対策\r
923                                         if(AskNoopInterval() > 0)\r
924                                                 SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
925                                         break;\r
926 \r
927                                 case MENU_CONNECT_NUM :\r
928                                         // 自動切断対策\r
929                                         KillTimer(hWnd, 1);\r
930                                         ConnectProc(DLG_TYPE_CON, (int)lParam);\r
931                                         // 自動切断対策\r
932                                         if(AskNoopInterval() > 0)\r
933                                                 SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
934                                         if(AskConnecting() == YES)\r
935                                         {\r
936                                                 if(HIWORD(wParam) & OPT_MIRROR)\r
937                                                 {\r
938                                                         if(HIWORD(wParam) & OPT_FORCE)\r
939                                                                 MirrorUploadProc(NO);\r
940                                                         else\r
941                                                                 MirrorUploadProc(YES);\r
942                                                 }\r
943                                                 else if(HIWORD(wParam) & OPT_MIRRORDOWN)\r
944                                                 {\r
945                                                         if(HIWORD(wParam) & OPT_FORCE)\r
946                                                                 MirrorDownloadProc(NO);\r
947                                                         else\r
948                                                                 MirrorDownloadProc(YES);\r
949                                                 }\r
950                                         }\r
951                                         break;\r
952 \r
953                                 case MENU_SET_CONNECT :\r
954                                         // 自動切断対策\r
955                                         KillTimer(hWnd, 1);\r
956                                         ConnectProc(DLG_TYPE_SET, -1);\r
957                                         // 自動切断対策\r
958                                         if(AskNoopInterval() > 0)\r
959                                                 SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
960                                         break;\r
961 \r
962                                 case MENU_QUICK :\r
963                                         // 自動切断対策\r
964                                         KillTimer(hWnd, 1);\r
965                                         QuickConnectProc();\r
966                                         // 自動切断対策\r
967                                         if(AskNoopInterval() > 0)\r
968                                                 SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
969                                         break;\r
970 \r
971                                 case MENU_DISCONNECT :\r
972                                         if(AskTryingConnect() == YES)\r
973                                                 CancelFlg = YES;\r
974                                         else if(AskConnecting() == YES)\r
975                                         {\r
976                                                 SaveBookMark();\r
977                                                 SaveCurrentSetToHost();\r
978                                                 DisconnectProc();\r
979                                         }\r
980                                         break;\r
981 \r
982                                 case MENU_HIST_1 :\r
983                                 case MENU_HIST_2 :\r
984                                 case MENU_HIST_3 :\r
985                                 case MENU_HIST_4 :\r
986                                 case MENU_HIST_5 :\r
987                                 case MENU_HIST_6 :\r
988                                 case MENU_HIST_7 :\r
989                                 case MENU_HIST_8 :\r
990                                 case MENU_HIST_9 :\r
991                                 case MENU_HIST_10 :\r
992                                 case MENU_HIST_11 :\r
993                                 case MENU_HIST_12 :\r
994                                 case MENU_HIST_13 :\r
995                                 case MENU_HIST_14 :\r
996                                 case MENU_HIST_15 :\r
997                                 case MENU_HIST_16 :\r
998                                 case MENU_HIST_17 :\r
999                                 case MENU_HIST_18 :\r
1000                                 case MENU_HIST_19 :\r
1001                                 case MENU_HIST_20 :\r
1002                                         // 自動切断対策\r
1003                                         KillTimer(hWnd, 1);\r
1004                                         HistoryConnectProc(LOWORD(wParam));\r
1005                                         // 自動切断対策\r
1006                                         if(AskNoopInterval() > 0)\r
1007                                                 SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
1008                                         break;\r
1009 \r
1010                                 case MENU_UPDIR :\r
1011                                         if(hWndCurFocus == GetLocalHwnd())\r
1012                                                 PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(MENU_LOCAL_UPDIR, 0), 0);\r
1013                                         else\r
1014                                                 PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(MENU_REMOTE_UPDIR, 0), 0);\r
1015                                         break;\r
1016 \r
1017                                 case MENU_DCLICK :\r
1018                                         if(hWndCurFocus == GetLocalHwnd())\r
1019                                                 // ローカルフォルダを開く\r
1020 //                                              DoubleClickProc(WIN_LOCAL, YES, -1);\r
1021                                                 DoubleClickProc(WIN_LOCAL, NO, -1);\r
1022                                         else\r
1023                                         {\r
1024                                                 SuppressRefresh = 1;\r
1025                                                 // ローカルフォルダを開く\r
1026 //                                              DoubleClickProc(WIN_REMOTE, YES, -1);\r
1027                                                 DoubleClickProc(WIN_REMOTE, NO, -1);\r
1028                                                 SuppressRefresh = 0;\r
1029                                         }\r
1030                                         break;\r
1031 \r
1032                                 // ローカルフォルダを開く\r
1033                                 case MENU_OPEN :\r
1034                                         if(hWndCurFocus == GetLocalHwnd())\r
1035                                                 DoubleClickProc(WIN_LOCAL, YES, -1);\r
1036                                         else\r
1037                                         {\r
1038                                                 SuppressRefresh = 1;\r
1039                                                 DoubleClickProc(WIN_REMOTE, YES, -1);\r
1040                                                 SuppressRefresh = 0;\r
1041                                         }\r
1042                                         break;\r
1043 \r
1044                                 case MENU_OPEN1 :\r
1045                                         if(hWndCurFocus == GetLocalHwnd())\r
1046                                                 DoubleClickProc(WIN_LOCAL, YES, 0);\r
1047                                         else\r
1048                                         {\r
1049                                                 SuppressRefresh = 1;\r
1050                                                 DoubleClickProc(WIN_REMOTE, YES, 0);\r
1051                                                 SuppressRefresh = 0;\r
1052                                         }\r
1053                                         break;\r
1054 \r
1055                                 case MENU_OPEN2 :\r
1056                                         if(hWndCurFocus == GetLocalHwnd())\r
1057                                                 DoubleClickProc(WIN_LOCAL, YES, 1);\r
1058                                         else\r
1059                                         {\r
1060                                                 SuppressRefresh = 1;\r
1061                                                 DoubleClickProc(WIN_REMOTE, YES, 1);\r
1062                                                 SuppressRefresh = 0;\r
1063                                         }\r
1064                                         break;\r
1065 \r
1066                                 case MENU_OPEN3 :\r
1067                                         if(hWndCurFocus == GetLocalHwnd())\r
1068                                                 DoubleClickProc(WIN_LOCAL, YES, 2);\r
1069                                         else\r
1070                                         {\r
1071                                                 SuppressRefresh = 1;\r
1072                                                 DoubleClickProc(WIN_REMOTE, YES, 2);\r
1073                                                 SuppressRefresh = 0;\r
1074                                         }\r
1075                                         break;\r
1076 \r
1077                                 case MENU_REMOTE_UPDIR :\r
1078                                         SuppressRefresh = 1;\r
1079                                         SetCurrentDirAsDirHist();\r
1080                                         ChangeDir(WIN_REMOTE, "..");\r
1081                                         SuppressRefresh = 0;\r
1082                                         break;\r
1083 \r
1084                                 case MENU_LOCAL_UPDIR :\r
1085                                         SetCurrentDirAsDirHist();\r
1086                                         ChangeDir(WIN_LOCAL, "..");\r
1087                                         break;\r
1088 \r
1089                                 case MENU_REMOTE_CHDIR :\r
1090                                         SuppressRefresh = 1;\r
1091                                         SetCurrentDirAsDirHist();\r
1092                                         ChangeDirDirectProc(WIN_REMOTE);\r
1093                                         SuppressRefresh = 0;\r
1094                                         break;\r
1095 \r
1096                                 case MENU_LOCAL_CHDIR :\r
1097                                         SetCurrentDirAsDirHist();\r
1098                                         ChangeDirDirectProc(WIN_LOCAL);\r
1099                                         break;\r
1100 \r
1101                                 case MENU_DOWNLOAD :\r
1102                                         SetCurrentDirAsDirHist();\r
1103                                         DownloadProc(NO, NO, NO);\r
1104                                         break;\r
1105 \r
1106                                 case MENU_DOWNLOAD_AS :\r
1107                                         SetCurrentDirAsDirHist();\r
1108                                         DownloadProc(YES, NO, NO);\r
1109                                         break;\r
1110 \r
1111                                 case MENU_DOWNLOAD_AS_FILE :\r
1112                                         SetCurrentDirAsDirHist();\r
1113                                         DownloadProc(NO, YES, NO);\r
1114                                         break;\r
1115 \r
1116                                 case MENU_DOWNLOAD_ALL :\r
1117                                         SetCurrentDirAsDirHist();\r
1118                                         DownloadProc(NO, NO, YES);\r
1119                                         break;\r
1120 \r
1121                                 case MENU_DOWNLOAD_NAME :\r
1122                                         SetCurrentDirAsDirHist();\r
1123                                         InputDownloadProc();\r
1124                                         break;\r
1125 \r
1126                                 case MENU_UPLOAD :\r
1127                                         SetCurrentDirAsDirHist();\r
1128                                         UploadListProc(NO, NO);\r
1129                                         break;\r
1130 \r
1131                                 case MENU_UPLOAD_AS :\r
1132                                         SetCurrentDirAsDirHist();\r
1133                                         UploadListProc(YES, NO);\r
1134                                         break;\r
1135 \r
1136                                 case MENU_UPLOAD_ALL :\r
1137                                         SetCurrentDirAsDirHist();\r
1138                                         UploadListProc(NO, YES);\r
1139                                         break;\r
1140 \r
1141                                 case MENU_MIRROR_UPLOAD :\r
1142                                         SetCurrentDirAsDirHist();\r
1143                                         MirrorUploadProc(YES);\r
1144                                         break;\r
1145 \r
1146                                 case MENU_MIRROR_DOWNLOAD :\r
1147                                         SetCurrentDirAsDirHist();\r
1148                                         MirrorDownloadProc(YES);\r
1149                                         break;\r
1150 \r
1151                                 case MENU_FILESIZE :\r
1152                                         SetCurrentDirAsDirHist();\r
1153                                         CalcFileSizeProc();\r
1154                                         break;\r
1155 \r
1156                                 case MENU_DELETE :\r
1157                                         SuppressRefresh = 1;\r
1158                                         SetCurrentDirAsDirHist();\r
1159                                         DeleteProc();\r
1160                                         SuppressRefresh = 0;\r
1161                                         break;\r
1162 \r
1163                                 case MENU_RENAME :\r
1164                                         SuppressRefresh = 1;\r
1165                                         SetCurrentDirAsDirHist();\r
1166                                         RenameProc();\r
1167                                         SuppressRefresh = 0;\r
1168                                         break;\r
1169 \r
1170                                 case MENU_MKDIR :\r
1171                                         SuppressRefresh = 1;\r
1172                                         SetCurrentDirAsDirHist();\r
1173                                         MkdirProc();\r
1174                                         SuppressRefresh = 0;\r
1175                                         break;\r
1176 \r
1177                                 case MENU_CHMOD :\r
1178                                         SuppressRefresh = 1;\r
1179                                         ChmodProc();\r
1180                                         SuppressRefresh = 0;\r
1181                                         break;\r
1182 \r
1183                                 case MENU_SOMECMD :\r
1184                                         SuppressRefresh = 1;\r
1185                                         SomeCmdProc();\r
1186                                         SuppressRefresh = 0;\r
1187                                         break;\r
1188 \r
1189                                 case MENU_OPTION :\r
1190                                         SetOption(0);\r
1191                                         if(ListFont != NULL)\r
1192                                         {\r
1193                                                 SendMessage(GetLocalHwnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1194                                                 SendMessage(GetRemoteHwnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1195                                                 SendMessage(GetTaskWnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1196                                         }\r
1197                                         GetLocalDirForWnd();\r
1198                                         DispTransferType();\r
1199                                         CheckHistoryNum(0);\r
1200                                         SetAllHistoryToMenu();\r
1201                                         // 暗号化通信対応\r
1202                                         SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);\r
1203                                         break;\r
1204 \r
1205                                 case MENU_FILTER :\r
1206                                         // 同時接続対応\r
1207                                         CancelFlg = NO;\r
1208                                         SetFilter(&CancelFlg);\r
1209                                         break;\r
1210 \r
1211                                 case MENU_SORT :\r
1212                                         if(SortSetting() == YES)\r
1213                                         {\r
1214                                                 // 同時接続対応\r
1215                                                 CancelFlg = NO;\r
1216                                                 LocalFileSort = AskSortType(ITEM_LFILE);\r
1217                                                 LocalDirSort = AskSortType(ITEM_LDIR);\r
1218                                                 RemoteFileSort = AskSortType(ITEM_RFILE);\r
1219                                                 RemoteDirSort = AskSortType(ITEM_RDIR);\r
1220                                                 ReSortDispList(WIN_LOCAL, &CancelFlg);\r
1221                                                 ReSortDispList(WIN_REMOTE, &CancelFlg);\r
1222                                         }\r
1223                                         break;\r
1224 \r
1225                                 case MENU_EXIT :\r
1226                                         PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1227                                         break;\r
1228 \r
1229                                 case MENU_AUTO_EXIT :\r
1230                                         if(AutoExit == YES)\r
1231                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1232                                         break;\r
1233 \r
1234                                 case MENU_ABOUT :\r
1235                                         DialogBox(hInstFtp, MAKEINTRESOURCE(about_dlg), hWnd, AboutDialogProc);\r
1236                                         break;\r
1237 \r
1238                                 case MENU_TEXT :\r
1239                                 case MENU_BINARY :\r
1240                                 case MENU_AUTO :\r
1241                                         SetTransferType(LOWORD(wParam));\r
1242                                         DispTransferType();\r
1243                                         break;\r
1244 \r
1245                                 case MENU_XFRMODE :\r
1246                                         switch(AskTransferType())\r
1247                                         {\r
1248                                                 case TYPE_A :\r
1249                                                         TmpTransType = MENU_BINARY;\r
1250                                                         break;\r
1251 \r
1252                                                 case TYPE_I :\r
1253                                                         TmpTransType = MENU_AUTO;\r
1254                                                         break;\r
1255 \r
1256                                                 default :\r
1257                                                         TmpTransType = MENU_TEXT;\r
1258                                                         break;\r
1259                                         }\r
1260                                         SetTransferType(TmpTransType);\r
1261                                         DispTransferType();\r
1262                                         break;\r
1263 \r
1264                                 // UTF-8対応\r
1265                                 case MENU_KNJ_SJIS :\r
1266                                 case MENU_KNJ_EUC :\r
1267                                 case MENU_KNJ_JIS :\r
1268                                 case MENU_KNJ_UTF8N :\r
1269                                 case MENU_KNJ_UTF8BOM :\r
1270                                 case MENU_KNJ_NONE :\r
1271                                         SetHostKanjiCode(LOWORD(wParam));\r
1272                                         break;\r
1273 \r
1274                                 case MENU_L_KNJ_SJIS :\r
1275                                 case MENU_L_KNJ_EUC :\r
1276                                 case MENU_L_KNJ_JIS :\r
1277                                 case MENU_L_KNJ_UTF8N :\r
1278                                 case MENU_L_KNJ_UTF8BOM :\r
1279                                         SetLocalKanjiCode(LOWORD(wParam));\r
1280                                         break;\r
1281 \r
1282                                 case MENU_KANACNV :\r
1283                                         SetHostKanaCnv();\r
1284                                         break;\r
1285 \r
1286                                 case MENU_REFRESH :\r
1287                                         // 同時接続対応\r
1288                                         CancelFlg = NO;\r
1289                                         SuppressRefresh = 1;\r
1290                                         GetLocalDirForWnd();\r
1291                                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1292                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
1293                                         SuppressRefresh = 0;\r
1294                                         break;\r
1295 \r
1296                                 case MENU_LIST :\r
1297                                         ListType = LVS_LIST;\r
1298                                         DispListType();\r
1299                                         SetListViewType();\r
1300                                         break;\r
1301 \r
1302                                 case MENU_REPORT :\r
1303                                         ListType = LVS_REPORT;\r
1304                                         DispListType();\r
1305                                         SetListViewType();\r
1306                                         break;\r
1307 \r
1308                                 case REFRESH_LOCAL :\r
1309                                         GetLocalDirForWnd();\r
1310                                         break;\r
1311 \r
1312                                 case REFRESH_REMOTE :\r
1313                                         // 同時接続対応\r
1314                                         CancelFlg = NO;\r
1315                                         SuppressRefresh = 1;\r
1316                                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1317                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
1318                                         SuppressRefresh = 0;\r
1319                                         break;\r
1320 \r
1321                                 case COMBO_LOCAL :\r
1322                                 case COMBO_REMOTE :\r
1323                                         SuppressRefresh = 1;\r
1324                                         if(HIWORD(wParam) == CBN_SELCHANGE)\r
1325                                         {\r
1326                                                 SetCurrentDirAsDirHist();\r
1327                                                 ChangeDirComboProc((HWND)lParam);\r
1328                                         }\r
1329                                         else if(HIWORD(wParam) != CBN_CLOSEUP)\r
1330                                         {\r
1331                                                 MakeButtonsFocus();\r
1332                                                 SuppressRefresh = 0;\r
1333                                                 return(0);\r
1334                                         }\r
1335                                         SuppressRefresh = 0;\r
1336                                         break;\r
1337 \r
1338                                 case MENU_HELP :\r
1339                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000001);\r
1340                                         break;\r
1341 \r
1342                                 case MENU_HELP_TROUBLE :\r
1343                                         // 任意のコードが実行されるバグ修正\r
1344 //                                      ShellExecute(NULL, "open", MYWEB_URL, NULL, ".", SW_SHOW);\r
1345                                         ShellExecute(NULL, "open", MYWEB_URL, NULL, NULL, SW_SHOW);\r
1346                                         break;\r
1347 \r
1348                                 case MENU_BMARK_ADD :\r
1349                                         AddCurDirToBookMark(WIN_REMOTE);\r
1350                                         break;\r
1351 \r
1352                                 case MENU_BMARK_ADD_LOCAL :\r
1353                                         AddCurDirToBookMark(WIN_LOCAL);\r
1354                                         break;\r
1355 \r
1356                                 case MENU_BMARK_ADD_BOTH :\r
1357                                         AddCurDirToBookMark(WIN_BOTH);\r
1358                                         break;\r
1359 \r
1360                                 case MENU_BMARK_EDIT :\r
1361                                         EditBookMark();\r
1362                                         break;\r
1363 \r
1364                                 case MENU_SELECT_ALL :\r
1365                                         SelectFileInList(hWndCurFocus, SELECT_ALL);\r
1366                                         break;\r
1367 \r
1368                                 case MENU_SELECT :\r
1369                                         SelectFileInList(hWndCurFocus, SELECT_REGEXP);\r
1370                                         break;\r
1371 \r
1372                                 case MENU_FIND :\r
1373                                         FindFileInList(hWndCurFocus, FIND_FIRST);\r
1374                                         break;\r
1375 \r
1376                                 case MENU_FINDNEXT :\r
1377                                         FindFileInList(hWndCurFocus, FIND_NEXT);\r
1378                                         break;\r
1379 \r
1380                                 case MENU_DOTFILE :\r
1381                                         // 同時接続対応\r
1382                                         CancelFlg = NO;\r
1383                                         DotFile ^= 1;\r
1384                                         DispDotFileMode();\r
1385                                         GetLocalDirForWnd();\r
1386                                         GetRemoteDirForWnd(CACHE_LASTREAD, &CancelFlg);\r
1387                                         break;\r
1388 \r
1389                                 case MENU_SYNC :\r
1390                                         ToggleSyncMoveMode();\r
1391                                         break;\r
1392 \r
1393                                 case MENU_IMPORT_WS :\r
1394                                         ImportFromWSFTP();\r
1395                                         break;\r
1396 \r
1397                                 case MENU_REGSAVE :\r
1398                                         GetListTabWidth();\r
1399                                         SaveRegistry();\r
1400                                         SaveSettingsToFile();\r
1401                                         break;\r
1402 \r
1403                                 case MENU_REGLOAD :\r
1404                                         if(LoadSettingsFromFile() == YES)\r
1405                                         {\r
1406                                                 MessageBox(hWnd, MSGJPN292, "FFFTP", MB_OK);\r
1407                                                 SaveExit = NO;\r
1408                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1409                                         }\r
1410                                         break;\r
1411 \r
1412                                 case MENU_REGINIT :\r
1413                                         if(DialogBox(hInstFtp, MAKEINTRESOURCE(reginit_dlg), hWnd, ExeEscDialogProc) == YES)\r
1414                                         {\r
1415                                                 ClearRegistry();\r
1416                                                 // ポータブル版判定\r
1417                                                 ClearIni();\r
1418                                                 SaveExit = NO;\r
1419                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1420                                         }\r
1421                                         break;\r
1422                                 case MENU_CHANGEPASSWD: /* 2010.01.31 genta */\r
1423                                         if( GetMasterPasswordStatus() != PASSWORD_OK )\r
1424                                         {\r
1425                                                 /* 強制的に設定するか確認 */\r
1426                                                 if( DialogBox(hInstFtp, MAKEINTRESOURCE(forcepasschange_dlg), hWnd, ExeEscDialogProc) != YES){\r
1427                                                         break;\r
1428                                                 }\r
1429                                                 // セキュリティ強化\r
1430                                                 if(EnterMasterPasswordAndSet(newmasterpasswd_dlg, hWnd) != 0)\r
1431                                                         SetTaskMsg(MSGJPN303);\r
1432                                         }\r
1433                                         // セキュリティ強化\r
1434 //                                      if( EnterMasterPasswordAndSet( newmasterpasswd_dlg, hWnd ) != 0 ){\r
1435 //                                              SetTaskMsg( MSGJPN303 );\r
1436 //                                      }\r
1437                                         else if(GetMasterPasswordStatus() == PASSWORD_OK)\r
1438                                         {\r
1439                                                 char Password[MAX_PASSWORD_LEN + 1];\r
1440                                                 GetMasterPassword(Password);\r
1441                                                 SetMasterPassword(NULL);\r
1442                                                 while(ValidateMasterPassword() == YES && GetMasterPasswordStatus() == PASSWORD_UNMATCH)\r
1443                                                 {\r
1444                                                         if(EnterMasterPasswordAndSet(masterpasswd_dlg, NULL) == 0)\r
1445                                                                 break;\r
1446                                                 }\r
1447                                                 if(GetMasterPasswordStatus() == PASSWORD_OK && EnterMasterPasswordAndSet(newmasterpasswd_dlg, hWnd) != 0)\r
1448                                                 {\r
1449                                                         SetTaskMsg(MSGJPN303);\r
1450                                                         SaveRegistry();\r
1451                                                 }\r
1452                                                 else\r
1453                                                 {\r
1454                                                         SetMasterPassword(Password);\r
1455                                                         ValidateMasterPassword();\r
1456                                                 }\r
1457                                         }\r
1458                                         break;\r
1459 \r
1460                                 case MENU_DIRINFO :\r
1461                                         DispDirInfo();\r
1462                                         break;\r
1463 \r
1464                                 case MENU_TASKINFO :\r
1465                                         DispTaskMsg();\r
1466                                         break;\r
1467 \r
1468                                 case MENU_ABORT :\r
1469                                         CancelFlg = YES;\r
1470                                         if(AskTryingConnect() == NO)\r
1471                                                 MainTransPkt.Abort = ABORT_USER;\r
1472                                         break;\r
1473 \r
1474                                 case MENU_OTPCALC :\r
1475                                         OtpCalcTool();\r
1476                                         break;\r
1477 \r
1478                                 case MENU_URL_COPY :\r
1479                                         CopyURLtoClipBoard();\r
1480                                         break;\r
1481 \r
1482                                 case MENU_APPKEY :\r
1483                                         EraseListViewTips();\r
1484                                         if(hWndCurFocus == GetRemoteHwnd())\r
1485                                                 RemoteRbuttonMenu(1);\r
1486                                         else if(hWndCurFocus == GetLocalHwnd())\r
1487                                                 LocalRbuttonMenu(1);\r
1488                                         break;\r
1489 \r
1490 #if defined(HAVE_TANDEM)\r
1491                                 case MENU_SWITCH_OSS :\r
1492                                         SwitchOSSProc();\r
1493                                         break;\r
1494 #endif\r
1495 \r
1496                                 default :\r
1497                                         if((LOWORD(wParam) >= MENU_BMARK_TOP) &&\r
1498                                            (LOWORD(wParam) < MENU_BMARK_TOP+100))\r
1499                                         {\r
1500                                                 ChangeDirBmarkProc(LOWORD(wParam));\r
1501                                         }\r
1502                                         break;\r
1503                         }\r
1504 // 常にホストかローカルへフォーカスを移動\r
1505 //                      SetFocus(hWndCurFocus);\r
1506                         MakeButtonsFocus();\r
1507                         break;\r
1508 \r
1509                 case WM_NOTIFY :\r
1510                         switch(((LPNMHDR)lParam)->code)\r
1511                         {\r
1512                                 /* ツールチップコントロールメッセージの処理 */\r
1513                                 // UTF-8対応\r
1514 //                              case TTN_NEEDTEXT:\r
1515                                 case TTN_NEEDTEXTW:\r
1516                                         lpttt = (LPTOOLTIPTEXT)lParam;\r
1517                                         // UTF-8対応\r
1518                                         // lptttは単なる警告回避用\r
1519                                         wlpttt = (LPTOOLTIPTEXTW)lParam;\r
1520                                         lpttt->hinst = hInstFtp;\r
1521                                         switch(lpttt->hdr.idFrom)\r
1522                                         {\r
1523                                                 case MENU_CONNECT :\r
1524                                                         lpttt->lpszText = MSGJPN154;\r
1525                                                         break;\r
1526 \r
1527                                                 case MENU_QUICK :\r
1528                                                         lpttt->lpszText = MSGJPN155;\r
1529                                                         break;\r
1530 \r
1531                                                 case MENU_DISCONNECT :\r
1532                                                         lpttt->lpszText = MSGJPN156;\r
1533                                                         break;\r
1534 \r
1535                                                 case MENU_DOWNLOAD :\r
1536                                                         lpttt->lpszText = MSGJPN157;\r
1537                                                         break;\r
1538 #if defined(HAVE_TANDEM)\r
1539                                                 case MENU_DOWNLOAD_AS :\r
1540                                                         lpttt->lpszText = MSGJPN065;\r
1541                                                         break;\r
1542 \r
1543                                                 case MENU_UPLOAD_AS :\r
1544                                                         lpttt->lpszText = MSGJPN064;\r
1545                                                         break;\r
1546 #endif\r
1547                                                 case MENU_UPLOAD :\r
1548                                                         lpttt->lpszText = MSGJPN158;\r
1549                                                         break;\r
1550 \r
1551                                                 case MENU_MIRROR_UPLOAD :\r
1552                                                         lpttt->lpszText = MSGJPN159;\r
1553                                                         break;\r
1554 \r
1555                                                 case MENU_DELETE :\r
1556                                                         lpttt->lpszText = MSGJPN160;\r
1557                                                         break;\r
1558 \r
1559                                                 case MENU_RENAME :\r
1560                                                         lpttt->lpszText = MSGJPN161;\r
1561                                                         break;\r
1562 \r
1563                                                 case MENU_MKDIR :\r
1564                                                         lpttt->lpszText = MSGJPN162;\r
1565                                                         break;\r
1566 \r
1567                                                 case MENU_LOCAL_UPDIR :\r
1568                                                 case MENU_REMOTE_UPDIR :\r
1569                                                         lpttt->lpszText = MSGJPN163;\r
1570                                                         break;\r
1571 \r
1572                                                 case MENU_LOCAL_CHDIR :\r
1573                                                 case MENU_REMOTE_CHDIR :\r
1574                                                         lpttt->lpszText = MSGJPN164;\r
1575                                                         break;\r
1576 \r
1577                                                 case MENU_TEXT :\r
1578                                                         lpttt->lpszText = MSGJPN165;\r
1579                                                         break;\r
1580 \r
1581                                                 case MENU_BINARY :\r
1582                                                         lpttt->lpszText = MSGJPN166;\r
1583                                                         break;\r
1584 \r
1585                                                 case MENU_AUTO :\r
1586                                                         lpttt->lpszText = MSGJPN167;\r
1587                                                         break;\r
1588 \r
1589                                                 case MENU_REFRESH :\r
1590                                                         lpttt->lpszText = MSGJPN168;\r
1591                                                         break;\r
1592 \r
1593                                                 case MENU_LIST :\r
1594                                                         lpttt->lpszText = MSGJPN169;\r
1595                                                         break;\r
1596 \r
1597                                                 case MENU_REPORT :\r
1598                                                         lpttt->lpszText = MSGJPN170;\r
1599                                                         break;\r
1600 \r
1601                                                 case MENU_KNJ_SJIS :\r
1602                                                         lpttt->lpszText = MSGJPN307;\r
1603                                                         break;\r
1604 \r
1605                                                 case MENU_KNJ_EUC :\r
1606                                                         lpttt->lpszText = MSGJPN171;\r
1607                                                         break;\r
1608 \r
1609                                                 case MENU_KNJ_JIS :\r
1610                                                         lpttt->lpszText = MSGJPN172;\r
1611                                                         break;\r
1612 \r
1613                                                 case MENU_KNJ_UTF8N :\r
1614                                                         lpttt->lpszText = MSGJPN308;\r
1615                                                         break;\r
1616 \r
1617                                                 case MENU_KNJ_UTF8BOM :\r
1618                                                         lpttt->lpszText = MSGJPN330;\r
1619                                                         break;\r
1620 \r
1621                                                 case MENU_KNJ_NONE :\r
1622                                                         lpttt->lpszText = MSGJPN173;\r
1623                                                         break;\r
1624 \r
1625                                                 case MENU_L_KNJ_SJIS :\r
1626                                                         lpttt->lpszText = MSGJPN309;\r
1627                                                         break;\r
1628 \r
1629                                                 case MENU_L_KNJ_EUC :\r
1630                                                         lpttt->lpszText = MSGJPN310;\r
1631                                                         break;\r
1632 \r
1633                                                 case MENU_L_KNJ_JIS :\r
1634                                                         lpttt->lpszText = MSGJPN311;\r
1635                                                         break;\r
1636 \r
1637                                                 case MENU_L_KNJ_UTF8N :\r
1638                                                         lpttt->lpszText = MSGJPN312;\r
1639                                                         break;\r
1640 \r
1641                                                 case MENU_L_KNJ_UTF8BOM :\r
1642                                                         lpttt->lpszText = MSGJPN331;\r
1643                                                         break;\r
1644 \r
1645                                                 case MENU_KANACNV :\r
1646                                                         lpttt->lpszText = MSGJPN174;\r
1647                                                         break;\r
1648 \r
1649                                                 case MENU_SYNC :\r
1650                                                         lpttt->lpszText = MSGJPN175;\r
1651                                                         break;\r
1652 \r
1653                                                 case MENU_ABORT :\r
1654                                                         lpttt->lpszText = MSGJPN176;\r
1655                                                         break;\r
1656                                         }\r
1657                                         // UTF-8対応\r
1658                                         // UTF-8からUTF-16 LEへ変換\r
1659                                         {\r
1660                                                 static wchar_t StringBufferUTF16[1024];\r
1661                                                 if(lpttt->lpszText)\r
1662                                                 {\r
1663                                                         MtoW(StringBufferUTF16, sizeof(StringBufferUTF16)/ sizeof(wchar_t), lpttt->lpszText, -1);\r
1664                                                         wlpttt->lpszText = StringBufferUTF16;\r
1665                                                 }\r
1666                                         }\r
1667                                         break;\r
1668 \r
1669                                 case LVN_COLUMNCLICK :\r
1670                                         if(((NMHDR *)lParam)->hwndFrom == GetLocalHwnd())\r
1671                                         {\r
1672                                                 // 同時接続対応\r
1673                                                 CancelFlg = NO;\r
1674                                                 SetSortTypeByColumn(WIN_LOCAL, ((NM_LISTVIEW *)lParam)->iSubItem);\r
1675                                                 ReSortDispList(WIN_LOCAL, &CancelFlg);\r
1676                                         }\r
1677                                         else if(((NMHDR *)lParam)->hwndFrom == GetRemoteHwnd())\r
1678                                         {\r
1679                                                 if(((NM_LISTVIEW *)lParam)->iSubItem != 4)\r
1680                                                 {\r
1681                                                         // 同時接続対応\r
1682                                                         CancelFlg = NO;\r
1683                                                         SetSortTypeByColumn(WIN_REMOTE, ((NM_LISTVIEW *)lParam)->iSubItem);\r
1684                                                         ReSortDispList(WIN_REMOTE, &CancelFlg);\r
1685                                                 }\r
1686                                         }\r
1687                                         SetFocus(hWndCurFocus);\r
1688                                         break;\r
1689 \r
1690                                 case LVN_ITEMCHANGED :\r
1691                                         DispSelectedSpace();\r
1692                                         MakeButtonsFocus();\r
1693                                         break;\r
1694                         }\r
1695                         break;\r
1696 \r
1697                 case WM_SIZE :\r
1698                         Sizing = SW_RESTORE;\r
1699                         if(wParam == SIZE_RESTORED)\r
1700                         {\r
1701                                 ResizeWindowProc();\r
1702                                 GetWindowRect(hWnd, &Rect);\r
1703                                 WinPosX = Rect.left;\r
1704                                 WinPosY = Rect.top;\r
1705                         }\r
1706                         else if(wParam == SIZE_MAXIMIZED)\r
1707                         {\r
1708                                 Sizing = SW_MAXIMIZE;\r
1709                                 ResizeWindowProc();\r
1710                         }\r
1711                         else\r
1712                                 return(DefWindowProc(hWnd, message, wParam, lParam));\r
1713                         break;\r
1714 \r
1715                 case WM_MOVING :\r
1716                         WinPosX = ((RECT *)lParam)->left;\r
1717                         WinPosY = ((RECT *)lParam)->top;\r
1718                         return(DefWindowProc(hWnd, message, wParam, lParam));\r
1719 \r
1720                 case WM_SETFOCUS :\r
1721                         SetFocus(hWndCurFocus);\r
1722                         break;\r
1723 \r
1724                 case WM_LBUTTONDOWN :\r
1725                 case WM_LBUTTONUP :\r
1726                 case WM_MOUSEMOVE :\r
1727                         CheckResizeFrame(wParam, LOWORD(lParam), HIWORD(lParam));\r
1728                         break;\r
1729 \r
1730                 case WM_CHANGE_COND :\r
1731                         DispTransferFiles();\r
1732                         break;\r
1733 \r
1734                 case WM_REFRESH_LOCAL_FLG :\r
1735                         // 外部アプリケーションへドロップ後にローカル側のファイル一覧に作業フォルダが表示されるバグ対策\r
1736 //                      PostMessage(hWnd,  WM_COMMAND, MAKEWPARAM(REFRESH_LOCAL, 0), 0);\r
1737                         if(SuppressRefresh == 0)\r
1738                                 PostMessage(hWnd,  WM_COMMAND, MAKEWPARAM(REFRESH_LOCAL, 0), 0);\r
1739                         break;\r
1740 \r
1741                 case WM_REFRESH_REMOTE_FLG :\r
1742                         if(SuppressRefresh == 0)\r
1743                                 PostMessage(hWnd,  WM_COMMAND, MAKEWPARAM(REFRESH_REMOTE, 0), 0);\r
1744                         break;\r
1745 \r
1746                 case WM_PAINT :\r
1747                     BeginPaint(hWnd, (LPPAINTSTRUCT) &ps);\r
1748                     EndPaint(hWnd, (LPPAINTSTRUCT) &ps);\r
1749                         break;\r
1750 \r
1751                 case WM_DESTROY :\r
1752 //                      WSACleanup();\r
1753 //                      DestroyWindow(hWndFtp);\r
1754                         PostQuitMessage(0);\r
1755                         break;\r
1756 \r
1757                 case WM_QUERYENDSESSION :\r
1758                         ExitProc(hWnd);\r
1759                         return(TRUE);\r
1760 \r
1761                 case WM_CLOSE :\r
1762                         if((AskTransferNow() == NO) ||\r
1763                            (DialogBox(hInstFtp, MAKEINTRESOURCE(exit_dlg), hWnd, ExeEscDialogProc) == YES))\r
1764                         {\r
1765                                 ExitProc(hWnd);\r
1766                                 return(DefWindowProc(hWnd, message, wParam, lParam));\r
1767                         }\r
1768                         break;\r
1769 \r
1770                 default :\r
1771                         return(DefWindowProc(hWnd, message, wParam, lParam));\r
1772         }\r
1773     return(0L);\r
1774 }\r
1775 \r
1776 \r
1777 /*----- プログラム開始時の処理 ------------------------------------------------\r
1778 *\r
1779 *       Parameter\r
1780 *               char *Cmd : コマンドライン文字列\r
1781 *\r
1782 *       Return Value\r
1783 *               なし\r
1784 *----------------------------------------------------------------------------*/\r
1785 \r
1786 static void StartupProc(char *Cmd)\r
1787 {\r
1788         int Sts;\r
1789         int AutoConnect;\r
1790         int CmdOption;\r
1791         int Kanji;\r
1792         int Kana;\r
1793         int FnameKanji;\r
1794         int TrMode;\r
1795         char unc[FMAX_PATH+1];\r
1796 \r
1797         Sts = AnalyzeComLine(Cmd, &AutoConnect, &CmdOption, unc, FMAX_PATH);\r
1798 \r
1799         TrMode = TYPE_DEFAULT;\r
1800         Kanji = KANJI_NOCNV;\r
1801         FnameKanji = KANJI_NOCNV;\r
1802         Kana = YES;\r
1803         if(CmdOption & OPT_ASCII)\r
1804                 TrMode = TYPE_A;\r
1805         if(CmdOption & OPT_BINARY)\r
1806                 TrMode = TYPE_I;\r
1807         if(CmdOption & OPT_EUC)\r
1808                 Kanji = KANJI_EUC;\r
1809         if(CmdOption & OPT_JIS)\r
1810                 Kanji = KANJI_JIS;\r
1811         if(CmdOption & OPT_EUC_NAME)\r
1812                 FnameKanji = KANJI_EUC;\r
1813         if(CmdOption & OPT_JIS_NAME)\r
1814                 FnameKanji = KANJI_JIS;\r
1815         if(CmdOption & OPT_KANA)\r
1816                 Kana = NO;\r
1817 \r
1818         if(CmdOption & OPT_QUIT)\r
1819                 AutoExit = YES;\r
1820 \r
1821         if(CmdOption & OPT_SAVEOFF)\r
1822                 SuppressSave = YES;\r
1823         if(CmdOption & OPT_SAVEON)\r
1824                 SuppressSave = NO;\r
1825 \r
1826         if(Sts == 0)\r
1827         {\r
1828                 if(ConnectOnStart == YES)\r
1829                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_CONNECT, 0), 0);\r
1830         }\r
1831         else if(Sts == 1)\r
1832         {\r
1833                 DirectConnectProc(unc, Kanji, Kana, FnameKanji, TrMode);\r
1834         }\r
1835         else if(Sts == 2)\r
1836         {\r
1837                 PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_CONNECT_NUM, CmdOption), (LPARAM)AutoConnect);\r
1838         }\r
1839         return;\r
1840 }\r
1841 \r
1842 \r
1843 /*----- コマンドラインを解析 --------------------------------------------------\r
1844 *\r
1845 *       Parameter\r
1846 *               char *Str : コマンドライン文字列\r
1847 *               int *AutoConnect : 接続ホスト番号を返すワーク\r
1848 *               int *CmdOption : オプションを返すワーク\r
1849 *               char *unc : uncを返すワーク\r
1850 *               int Max : uncの最大長\r
1851 *\r
1852 *       Return Value\r
1853 *               int ステータス\r
1854 *                       0=指定なし、1=URL指定、2=設定名指定、-1=エラー\r
1855 *\r
1856 *       Note\r
1857 *               -m      --mirror\r
1858 *               -d      --mirrordown\r
1859 *               -f      --force\r
1860 *               -q      --quit\r
1861 *               -s      --set\r
1862 *               -h      --help\r
1863 *               -e      --euc\r
1864 *               -j      --jis\r
1865 *               -a      --ascii\r
1866 *               -b      --binary\r
1867 *               -x      --auto\r
1868 *               -k      --kana\r
1869 *               -u      --eucname\r
1870 *               -i      --jisname\r
1871 *               -n  --ini               (CheckIniFileNameで検索)\r
1872 *                       --saveoff\r
1873 *                       --saveon\r
1874 *               -z      --mpasswd       (CheckMasterPasswordで検索)  2010.01.30 genta 追加\r
1875 *----------------------------------------------------------------------------*/\r
1876 \r
1877 static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc, int Max)\r
1878 {\r
1879         int Ret;\r
1880         char Tmp[FMAX_PATH+1];\r
1881 \r
1882         *AutoConnect = -1;\r
1883         *CmdOption = 0;\r
1884 \r
1885         Ret = 0;\r
1886         memset(unc, NUL, Max+1);\r
1887 \r
1888         while((Ret != -1) && ((Str = GetToken(Str, Tmp)) != NULL))\r
1889         {\r
1890                 if(Tmp[0] == '-')\r
1891                 {\r
1892                         _strlwr(Tmp);\r
1893                         if((strcmp(&Tmp[1], "m") == 0) || (strcmp(&Tmp[1], "-mirror") == 0))\r
1894                                 *CmdOption |= OPT_MIRROR;\r
1895                         else if((strcmp(&Tmp[1], "d") == 0) || (strcmp(&Tmp[1], "-mirrordown") == 0))\r
1896                                 *CmdOption |= OPT_MIRRORDOWN;\r
1897                         else if((strcmp(&Tmp[1], "e") == 0) || (strcmp(&Tmp[1], "-euc") == 0))\r
1898                                 *CmdOption |= OPT_EUC;\r
1899                         else if((strcmp(&Tmp[1], "j") == 0) || (strcmp(&Tmp[1], "-jis") == 0))\r
1900                                 *CmdOption |= OPT_JIS;\r
1901                         else if((strcmp(&Tmp[1], "a") == 0) || (strcmp(&Tmp[1], "-ascii") == 0))\r
1902                                 *CmdOption |= OPT_ASCII;\r
1903                         else if((strcmp(&Tmp[1], "b") == 0) || (strcmp(&Tmp[1], "-binary") == 0))\r
1904                                 *CmdOption |= OPT_BINARY;\r
1905                         else if((strcmp(&Tmp[1], "x") == 0) || (strcmp(&Tmp[1], "-auto") == 0))\r
1906                                 *CmdOption |= OPT_AUTO;\r
1907                         else if((strcmp(&Tmp[1], "f") == 0) || (strcmp(&Tmp[1], "-force") == 0))\r
1908                                 *CmdOption |= OPT_FORCE;\r
1909                         else if((strcmp(&Tmp[1], "q") == 0) || (strcmp(&Tmp[1], "-quit") == 0))\r
1910                                 *CmdOption |= OPT_QUIT;\r
1911                         else if((strcmp(&Tmp[1], "k") == 0) || (strcmp(&Tmp[1], "-kana") == 0))\r
1912                                 *CmdOption |= OPT_KANA;\r
1913                         else if((strcmp(&Tmp[1], "u") == 0) || (strcmp(&Tmp[1], "-eucname") == 0))\r
1914                                 *CmdOption |= OPT_EUC_NAME;\r
1915                         else if((strcmp(&Tmp[1], "i") == 0) || (strcmp(&Tmp[1], "-jisname") == 0))\r
1916                                 *CmdOption |= OPT_JIS_NAME;\r
1917                         else if((strcmp(&Tmp[1], "n") == 0) || (strcmp(&Tmp[1], "-ini") == 0))\r
1918                         {\r
1919                                 if((Str = GetToken(Str, Tmp)) == NULL)\r
1920                                 {\r
1921                                         SetTaskMsg(MSGJPN282);\r
1922                                         Ret = -1;\r
1923                                 }\r
1924                         }\r
1925                         else if(strcmp(&Tmp[1], "-saveoff") == 0)\r
1926                                 *CmdOption |= OPT_SAVEOFF;\r
1927                         else if(strcmp(&Tmp[1], "-saveon") == 0)\r
1928                                 *CmdOption |= OPT_SAVEON;\r
1929                         else if((strcmp(&Tmp[1], "z") == 0) || (strcmp(&Tmp[1], "-mpasswd") == 0))\r
1930                         {       /* 2010.01.30 genta : Add master password option */\r
1931                                 if((Str = GetToken(Str, Tmp)) == NULL)\r
1932                                 {\r
1933                                         SetTaskMsg(MSGJPN299);\r
1934                                         Ret = -1;\r
1935                                 }\r
1936                         }\r
1937                         else if((strcmp(&Tmp[1], "s") == 0) || (strcmp(&Tmp[1], "-set") == 0))\r
1938                         {\r
1939                                 if(Ret == 0)\r
1940                                 {\r
1941                                         if((Str = GetToken(Str, Tmp)) != NULL)\r
1942                                         {\r
1943                                                 if((*AutoConnect = SearchHostName(Tmp)) != -1)\r
1944                                                         Ret = 2;\r
1945                                                 else\r
1946                                                 {\r
1947                                                         SetTaskMsg(MSGJPN177, Tmp);\r
1948                                                         Ret = -1;\r
1949                                                 }\r
1950                                         }\r
1951                                         else\r
1952                                         {\r
1953                                                 SetTaskMsg(MSGJPN178);\r
1954                                                 Ret = -1;\r
1955                                         }\r
1956                                 }\r
1957                                 else\r
1958                                 {\r
1959                                         SetTaskMsg(MSGJPN179);\r
1960                                         Ret = -1;\r
1961                                 }\r
1962                         }\r
1963                         else if((strcmp(&Tmp[1], "h") == 0) || (strcmp(&Tmp[1], "-help") == 0))\r
1964                         {\r
1965                                 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000024);\r
1966                         }\r
1967                         // プロセス保護\r
1968 #ifdef ENABLE_PROCESS_PROTECTION\r
1969                         else if(strcmp(Tmp, "--restart") == 0)\r
1970                         {\r
1971                         }\r
1972                         else if(strcmp(Tmp, "--protect") == 0)\r
1973                         {\r
1974                         }\r
1975                         else if(strcmp(Tmp, "--protect-high") == 0)\r
1976                         {\r
1977                         }\r
1978                         else if(strcmp(Tmp, "--protect-medium") == 0)\r
1979                         {\r
1980                         }\r
1981                         else if(strcmp(Tmp, "--protect-low") == 0)\r
1982                         {\r
1983                         }\r
1984 #endif\r
1985                         else\r
1986                         {\r
1987                                 SetTaskMsg(MSGJPN180, Tmp);\r
1988                                 Ret = -1;\r
1989                         }\r
1990                 }\r
1991                 else\r
1992                 {\r
1993                         if(Ret == 0)\r
1994                         {\r
1995                                 strncpy(unc, Tmp, Max);\r
1996                                 Ret = 1;\r
1997                         }\r
1998                         else\r
1999                         {\r
2000                                 SetTaskMsg(MSGJPN181);\r
2001                                 Ret = -1;\r
2002                         }\r
2003                 }\r
2004         }\r
2005         return(Ret);\r
2006 }\r
2007 \r
2008 \r
2009 /*----- INIファイルのパス名の指定をチェック ------------------------------------\r
2010 *\r
2011 *       Parameter\r
2012 *               char *Str : コマンドライン文字列\r
2013 *               char *Ini : iniファイル名を返すワーク\r
2014 *\r
2015 *       Return Value\r
2016 *               int ステータス\r
2017 *                       0=指定なし、1=あり\r
2018 *\r
2019 *       Note\r
2020 *               -n  --ini\r
2021 *----------------------------------------------------------------------------*/\r
2022 \r
2023 static int CheckIniFileName(char *Str, char *Ini)\r
2024 {\r
2025         return GetTokenAfterOption( Str, Ini, "n", "-ini" );\r
2026 }\r
2027 \r
2028 /* マスターパスワードの指定をチェック */\r
2029 static int CheckMasterPassword(char *Str, char *Ini)\r
2030 {\r
2031         return GetTokenAfterOption( Str, Ini, "z", "-mpasswd" );\r
2032 }\r
2033 \r
2034 /*----- オプションの後ろのトークンを取り出す ------------------------------------\r
2035 *\r
2036 *       Parameter\r
2037 *               char *Str : コマンドライン文字列\r
2038 *               char *Result : 取り出した文字列を格納するワーク\r
2039 *               const char* Opt1, *Opt2: オプション文字列(2つ)\r
2040 *\r
2041 *       Return Value\r
2042 *               int ステータス\r
2043 *                       0=指定なし、1=あり\r
2044 *\r
2045 *       Note\r
2046 *               2010.01.30 genta マスターパスワード取り出しのため共通化\r
2047 *----------------------------------------------------------------------------*/\r
2048 static int GetTokenAfterOption(char *Str, char *Result, const char* Opt1, const char* Opt2 )\r
2049 {\r
2050         int Ret = 0;\r
2051         char Tmp[FMAX_PATH+1];\r
2052 \r
2053         Result[0] = NUL;\r
2054         while((Str = GetToken(Str, Tmp)) != NULL)\r
2055         {\r
2056                 if(Tmp[0] == '-')\r
2057                 {\r
2058                         _strlwr(Tmp);\r
2059                         if((strcmp(&Tmp[1], Opt1) == 0) || (strcmp(&Tmp[1], Opt2) == 0))\r
2060                         {\r
2061                                 if((Str = GetToken(Str, Result)) != NULL)\r
2062                                         Ret = 1;\r
2063                                 break;\r
2064                         }\r
2065                 }\r
2066         }\r
2067         return(Ret);\r
2068 }\r
2069 \r
2070 /*----- トークンを返す --------------------------------------------------------\r
2071 *\r
2072 *       Parameter\r
2073 *               char *Str : 文字列\r
2074 *               char *Buf : 文字列を返すバッファ\r
2075 *\r
2076 *       Return Value\r
2077 *               char *返したトークンの末尾\r
2078 *                       NULL=終わり\r
2079 *----------------------------------------------------------------------------*/\r
2080 \r
2081 static char *GetToken(char *Str, char *Buf)\r
2082 {\r
2083         int InQuote;\r
2084 \r
2085         while(*Str != NUL)\r
2086         {\r
2087                 if((*Str != ' ') && (*Str != '\t'))\r
2088                         break;\r
2089                 Str++;\r
2090         }\r
2091 \r
2092         if(*Str != NUL)\r
2093         {\r
2094                 InQuote = 0;\r
2095                 while(*Str != NUL)\r
2096                 {\r
2097                         if(*Str == 0x22)\r
2098                                 InQuote = !InQuote;\r
2099                         else\r
2100                         {\r
2101                                 if(((*Str == ' ') || (*Str == '\t')) &&\r
2102                                    (InQuote == 0))\r
2103                                 {\r
2104                                         break;\r
2105                                 }\r
2106                                 *Buf++ = *Str;\r
2107                         }\r
2108                         Str++;\r
2109                 }\r
2110         }\r
2111         else\r
2112                 Str = NULL;\r
2113 \r
2114         *Buf = NUL;\r
2115 \r
2116         return(Str);\r
2117 }\r
2118 \r
2119 \r
2120 /*----- プログラム終了時の処理 ------------------------------------------------\r
2121 *\r
2122 *       Parameter\r
2123 *               HWND hWnd : ウインドウハンドル\r
2124 *\r
2125 *       Return Value\r
2126 *               なし\r
2127 *----------------------------------------------------------------------------*/\r
2128 \r
2129 static void ExitProc(HWND hWnd)\r
2130 {\r
2131         // 環境依存の不具合対策\r
2132         char Tmp[FMAX_PATH+1];\r
2133 \r
2134         CancelFlg = YES;\r
2135 \r
2136         CloseTransferThread();\r
2137 \r
2138         if(SaveExit == YES)\r
2139         {\r
2140                 SaveBookMark();\r
2141                 SaveCurrentSetToHost();\r
2142         }\r
2143         DeleteAlltempFile();\r
2144 \r
2145 //      WSACancelBlockingCall();\r
2146         DisconnectProc();\r
2147 //      CloseTransferThread();\r
2148 \r
2149         if(SaveExit == YES)\r
2150         {\r
2151                 GetListTabWidth();\r
2152                 SaveRegistry();\r
2153                 // ポータブル版判定\r
2154                 if(RegType == REGTYPE_REG)\r
2155                         ClearIni();\r
2156 \r
2157                 if((CacheEntry > 0) && (CacheSave == YES))\r
2158                         SaveCache();\r
2159                 else\r
2160                         DeleteCache();\r
2161         }\r
2162         else\r
2163                 DeleteCache();\r
2164 \r
2165         // 環境依存の不具合対策\r
2166         GetAppTempPath(Tmp);\r
2167         SetYenTail(Tmp);\r
2168         strcat(Tmp, "file");\r
2169         _rmdir(Tmp);\r
2170         GetAppTempPath(Tmp);\r
2171         _rmdir(Tmp);\r
2172 \r
2173         if(RasClose == YES)\r
2174         {\r
2175                 DisconnectRas(RasCloseNotify);\r
2176         }\r
2177         DeleteAllObject();\r
2178         HtmlHelp(NULL, NULL, HH_UNINITIALIZE, dwCookie); \r
2179         return;\r
2180 }\r
2181 \r
2182 \r
2183 /*----- ファイル名をダブルクリックしたときの処理 ------------------------------\r
2184 *\r
2185 *       Parameter\r
2186 *               int Win : ウインドウ番号 (WIN_xxx)\r
2187 *               int Mode : 常に「開く」動作をするかどうか (YES/NO)\r
2188 *               int App : アプリケーション番号(-1=関連づけ優先)\r
2189 *\r
2190 *       Return Value\r
2191 *               なし\r
2192 *----------------------------------------------------------------------------*/\r
2193 \r
2194 void DoubleClickProc(int Win, int Mode, int App)\r
2195 {\r
2196         int Pos;\r
2197         int Type;\r
2198         char Local[FMAX_PATH+1];\r
2199         char Remote[FMAX_PATH+1];\r
2200         char Tmp[FMAX_PATH+1];\r
2201         int Sts;\r
2202         int UseDiffViewer;\r
2203 \r
2204         if(AskUserOpeDisabled() == NO)\r
2205         {\r
2206                 SetCurrentDirAsDirHist();\r
2207                 if(GetSelectedCount(Win) == 1)\r
2208                 {\r
2209                         if((Pos = GetFirstSelected(Win, NO)) != -1)\r
2210                         {\r
2211                                 GetNodeName(Win, Pos, Tmp, FMAX_PATH);\r
2212                                 Type = GetNodeType(Win, Pos);\r
2213 \r
2214                                 if(Win == WIN_LOCAL)\r
2215                                 {\r
2216                                         // ローカルフォルダを開く\r
2217 //                                      if((App != -1) || (Type == NODE_FILE))\r
2218                                         if((App != -1) || (Type == NODE_FILE) || (Mode == YES))\r
2219                                         {\r
2220                                                 if((DclickOpen == YES) || (Mode == YES))\r
2221                                                 {\r
2222                                                         AskLocalCurDir(Local, FMAX_PATH);\r
2223                                                         ReplaceAll(Local, '/', '\\');\r
2224                                                         SetYenTail(Local);\r
2225                                                         strcat(Local, Tmp);\r
2226                                                         ExecViewer(Local, App);\r
2227                                                 }\r
2228                                                 else\r
2229                                                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_UPLOAD, 0), 0);\r
2230                                         }\r
2231                                         else\r
2232                                                 ChangeDir(WIN_LOCAL, Tmp);\r
2233                                 }\r
2234                                 else if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2235                                 {\r
2236                                         if((App != -1) || (Type == NODE_FILE))\r
2237                                         {\r
2238                                                 if((DclickOpen == YES) || (Mode == YES))\r
2239                                                 {\r
2240                                                         // ビューワ2、3のパスが "d " で始まっていたら差分ビューア使用\r
2241                                                         if ((App == 1 || App == 2) && strncmp(ViewerName[App], "d ", 2) == 0)\r
2242                                                                 UseDiffViewer = YES;\r
2243                                                         else\r
2244                                                                 UseDiffViewer = NO;\r
2245 \r
2246                                                         strcpy(Remote, TmpPath);\r
2247                                                         SetYenTail(Remote);\r
2248                                                         // 環境依存の不具合対策\r
2249                                                         strcat(Remote, "file");\r
2250                                                         _mkdir(Remote);\r
2251                                                         SetYenTail(Remote);\r
2252                                                         if (UseDiffViewer == YES) {\r
2253                                                                 strcat(Remote, "remote.");\r
2254                                                         }\r
2255                                                         strcat(Remote, Tmp);\r
2256 \r
2257                                                         if(AskTransferNow() == YES)\r
2258                                                                 SktShareProh();\r
2259 \r
2260         //                                              MainTransPkt.ctrl_skt = AskCmdCtrlSkt();\r
2261                                                         strcpy(MainTransPkt.Cmd, "RETR ");\r
2262                                                         if(AskHostType() == HTYPE_ACOS)\r
2263                                                         {\r
2264                                                                 strcpy(MainTransPkt.RemoteFile, "'");\r
2265                                                                 strcat(MainTransPkt.RemoteFile, AskHostLsName());\r
2266                                                                 strcat(MainTransPkt.RemoteFile, "(");\r
2267                                                                 strcat(MainTransPkt.RemoteFile, Tmp);\r
2268                                                                 strcat(MainTransPkt.RemoteFile, ")");\r
2269                                                                 strcat(MainTransPkt.RemoteFile, "'");\r
2270                                                         }\r
2271                                                         else if(AskHostType() == HTYPE_ACOS_4)\r
2272                                                         {\r
2273                                                                 strcpy(MainTransPkt.RemoteFile, Tmp);\r
2274                                                         }\r
2275                                                         else\r
2276                                                         {\r
2277                                                                 strcpy(MainTransPkt.RemoteFile, Tmp);\r
2278                                                         }\r
2279                                                         strcpy(MainTransPkt.LocalFile, Remote);\r
2280                                                         MainTransPkt.Type = AskTransferTypeAssoc(MainTransPkt.RemoteFile, AskTransferType());\r
2281                                                         MainTransPkt.Size = 1;\r
2282                                                         MainTransPkt.KanjiCode = AskHostKanjiCode();\r
2283                                                         MainTransPkt.KanjiCodeDesired = AskLocalKanjiCode();\r
2284                                                         MainTransPkt.KanaCnv = AskHostKanaCnv();\r
2285                                                         MainTransPkt.Mode = EXIST_OVW;\r
2286                                                         MainTransPkt.ExistSize = 0;\r
2287                                                         MainTransPkt.hWndTrans = NULL;\r
2288                                                         MainTransPkt.Next = NULL;\r
2289 \r
2290                                                         DisableUserOpe();\r
2291 \r
2292                                                         /* 不正なパスを検出 */\r
2293                                                         if(CheckPathViolation(&MainTransPkt) == NO)\r
2294                                                         {\r
2295 //                                                              if((Sts = DoDownload(AskCmdCtrlSkt(), &MainTransPkt, NO)) == 429)\r
2296 //                                                              {\r
2297 //                                                                      ReConnectCmdSkt();\r
2298                                                                         // 同時接続対応\r
2299                                                                         CancelFlg = NO;\r
2300                                                                         Sts = DoDownload(AskCmdCtrlSkt(), &MainTransPkt, NO, &CancelFlg);\r
2301 //                                                              }\r
2302                                                         }\r
2303 \r
2304                                                         EnableUserOpe();\r
2305 \r
2306                                                         AddTempFileList(Remote);\r
2307                                                         if(Sts/100 == FTP_COMPLETE) {\r
2308                                                                 if (UseDiffViewer == YES) {\r
2309                                                                         AskLocalCurDir(Local, FMAX_PATH);\r
2310                                                                         ReplaceAll(Local, '/', '\\');\r
2311                                                                         SetYenTail(Local);\r
2312                                                                         strcat(Local, Tmp);\r
2313                                                                         ExecViewer2(Local, Remote, App);\r
2314                                                                 } else {\r
2315                                                                         ExecViewer(Remote, App);\r
2316                                                                 }\r
2317                                                         }\r
2318                                                 }\r
2319                                                 else\r
2320                                                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_DOWNLOAD, 0), 0);\r
2321                                         }\r
2322                                         else\r
2323                                                 ChangeDir(WIN_REMOTE, Tmp);\r
2324                                 }\r
2325                         }\r
2326                 }\r
2327                 MakeButtonsFocus();\r
2328         }\r
2329         return;\r
2330 }\r
2331 \r
2332 \r
2333 /*----- フォルダの移動 --------------------------------------------------------\r
2334 *\r
2335 *       Parameter\r
2336 *               int Win : ウインドウ番号 (WIN_xxx)\r
2337 *               char *Path : 移動先のパス名\r
2338 *\r
2339 *       Return Value\r
2340 *               なし\r
2341 *\r
2342 *       Note\r
2343 *               フォルダ同時移動の処理も行う\r
2344 *----------------------------------------------------------------------------*/\r
2345 \r
2346 static void ChangeDir(int Win, char *Path)\r
2347 {\r
2348         int Sync;\r
2349         char Local[FMAX_PATH+1];\r
2350         char Remote[FMAX_PATH+1];\r
2351 \r
2352         // 同時接続対応\r
2353         CancelFlg = NO;\r
2354 \r
2355         // デッドロック対策\r
2356         DisableUserOpe();\r
2357         Sync = AskSyncMoveMode();\r
2358         if(Sync == YES)\r
2359         {\r
2360                 if(strcmp(Path, "..") == 0)\r
2361                 {\r
2362                         AskLocalCurDir(Local, FMAX_PATH);\r
2363                         AskRemoteCurDir(Remote, FMAX_PATH);\r
2364                         if(strcmp(GetFileName(Local), GetFileName(Remote)) != 0)\r
2365                                 Sync = NO;\r
2366                 }\r
2367         }\r
2368 \r
2369         if((Win == WIN_LOCAL) || (Sync == YES))\r
2370         {\r
2371                 if(DoLocalCWD(Path) == FFFTP_SUCCESS)\r
2372                         GetLocalDirForWnd();\r
2373         }\r
2374 \r
2375         if((Win == WIN_REMOTE) || (Sync == YES))\r
2376         {\r
2377                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2378                 {\r
2379 #if defined(HAVE_OPENVMS)\r
2380                         /* OpenVMSの場合、".DIR;?"を取る */\r
2381                         if (AskHostType() == HTYPE_VMS)\r
2382                                 ReformVMSDirName(Path, TRUE);\r
2383 #endif\r
2384                         if(DoCWD(Path, YES, NO, YES) < FTP_RETRY)\r
2385                                 GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2386                 }\r
2387         }\r
2388         // デッドロック対策\r
2389         EnableUserOpe();\r
2390         return;\r
2391 }\r
2392 \r
2393 \r
2394 /*----- ウインドウのサイズ変更の処理 ------------------------------------------\r
2395 *\r
2396 *       Parameter\r
2397 *               なし\r
2398 *\r
2399 *       Return Value\r
2400 *               なし\r
2401 *----------------------------------------------------------------------------*/\r
2402 \r
2403 static void ResizeWindowProc(void)\r
2404 {\r
2405 #if 0\r
2406         RECT Rect;\r
2407         int RemotePosX;\r
2408 \r
2409         GetClientRect(hWndFtp, &Rect);\r
2410         SendMessage(GetSbarWnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(Rect.right, Rect.bottom));\r
2411 \r
2412         CalcWinSize();\r
2413         SetWindowPos(GetMainTbarWnd(), 0, 0, 0, WinWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2414 \r
2415         SetWindowPos(GetLocalTbarWnd(), 0, 0, TOOLWIN_HEIGHT, LocalWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2416         SendMessage(GetLocalTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2417         SetWindowPos(GetLocalHistHwnd(), 0, Rect.right, Rect.top, LocalWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2418         SetWindowPos(GetLocalHwnd(), 0, 0, TOOLWIN_HEIGHT*2, LocalWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2419 \r
2420         RemotePosX = LocalWidth + SepaWidth;\r
2421         if(SplitVertical == YES)\r
2422                 RemotePosX = 0;\r
2423 \r
2424         SetWindowPos(GetRemoteTbarWnd(), 0, RemotePosX, TOOLWIN_HEIGHT, RemoteWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2425         SendMessage(GetRemoteTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2426         SetWindowPos(GetRemoteHistHwnd(), 0, Rect.right, Rect.top, RemoteWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2427         SetWindowPos(GetRemoteHwnd(), 0, RemotePosX, TOOLWIN_HEIGHT*2, RemoteWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2428 \r
2429         SetWindowPos(GetTaskWnd(), 0, 0, TOOLWIN_HEIGHT*2+ListHeight+SepaWidth, ClientWidth, TaskHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2430 #else\r
2431         RECT Rect;\r
2432 \r
2433         GetClientRect(hWndFtp, &Rect);\r
2434         SendMessage(GetSbarWnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(Rect.right, Rect.bottom));\r
2435 \r
2436         CalcWinSize();\r
2437         SetWindowPos(GetMainTbarWnd(), 0, 0, 0, Rect.right, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2438         SetWindowPos(GetLocalTbarWnd(), 0, 0, TOOLWIN_HEIGHT, LocalWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2439         SetWindowPos(GetRemoteTbarWnd(), 0, LocalWidth + SepaWidth, TOOLWIN_HEIGHT, RemoteWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2440         SendMessage(GetLocalTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2441         SetWindowPos(GetLocalHistHwnd(), 0, Rect.right, Rect.top, LocalWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2442         SendMessage(GetRemoteTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2443         SetWindowPos(GetRemoteHistHwnd(), 0, Rect.right, Rect.top, RemoteWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2444         SetWindowPos(GetLocalHwnd(), 0, 0, TOOLWIN_HEIGHT*2, LocalWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2445         SetWindowPos(GetRemoteHwnd(), 0, LocalWidth + SepaWidth, TOOLWIN_HEIGHT*2, RemoteWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2446         SetWindowPos(GetTaskWnd(), 0, 0, TOOLWIN_HEIGHT*2+ListHeight+SepaWidth, ClientWidth, TaskHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2447 #endif\r
2448 \r
2449         return;\r
2450 }\r
2451 \r
2452 \r
2453 /*----- ウインドウの各部分のサイズを計算する ----------------------------------\r
2454 *\r
2455 *       Parameter\r
2456 *               なし\r
2457 *\r
2458 *       Return Value\r
2459 *               なし\r
2460 *----------------------------------------------------------------------------*/\r
2461 \r
2462 static void CalcWinSize(void)\r
2463 {\r
2464         RECT Rect;\r
2465 \r
2466         GetWindowRect(hWndFtp, &Rect);\r
2467 \r
2468         if(Sizing != SW_MAXIMIZE)\r
2469         {\r
2470                 WinWidth = Rect.right - Rect.left;\r
2471                 WinHeight = Rect.bottom - Rect.top;\r
2472         }\r
2473 \r
2474         GetClientRect(hWndFtp, &Rect);\r
2475 \r
2476         ClientWidth = Rect.right;\r
2477         ClientHeight = Rect.bottom;\r
2478 \r
2479         SepaWidth = 4;\r
2480         LocalWidth = max1(0, min1(LocalWidth, ClientWidth - SepaWidth));\r
2481         RemoteWidth = max1(0, ClientWidth - LocalWidth - SepaWidth);\r
2482 //      TaskHeight = min1(TaskHeight, max1(0, ClientHeight - TOOLWIN_HEIGHT * 2 - SepaWidth));\r
2483 \r
2484         GetClientRect(GetSbarWnd(), &Rect);\r
2485 \r
2486         ListHeight = max1(0, ClientHeight - TOOLWIN_HEIGHT * 2 - TaskHeight - SepaWidth - Rect.bottom);\r
2487 \r
2488         return;\r
2489 }\r
2490 \r
2491 \r
2492 #if 0\r
2493 /*----- ウインドウの表示位置を取得する ----------------------------------------\r
2494 *\r
2495 *       Parameter\r
2496 *               HWND hWnd : ウインドウハンドル\r
2497 *\r
2498 *       Return Value\r
2499 *               なし\r
2500 *----------------------------------------------------------------------------*/\r
2501 \r
2502 static void AskWindowPos(HWND hWnd)\r
2503 {\r
2504         WINDOWPLACEMENT WinPlace;\r
2505 \r
2506         WinPlace.length = sizeof(WINDOWPLACEMENT);\r
2507         GetWindowPlacement(hWnd, &WinPlace);\r
2508         WinPosX = WinPlace.rcNormalPosition.left;\r
2509         WinPosY = WinPlace.rcNormalPosition.top;\r
2510 \r
2511         return;\r
2512 }\r
2513 #endif\r
2514 \r
2515 \r
2516 /*----- ディレクトリリストとファイルリストの境界変更処理 ----------------------\r
2517 *\r
2518 *       Parameter\r
2519 *               WPARAM Keys : WM_MOUSEMOVEなどのWPARAMの値\r
2520 *               int x : マウスカーソルのX座標\r
2521 *               int y : マウスカーソルのY座標\r
2522 *\r
2523 *       Return Value\r
2524 *               なし\r
2525 *----------------------------------------------------------------------------*/\r
2526 \r
2527 static void CheckResizeFrame(WPARAM Keys, int x, int y)\r
2528 {\r
2529         RECT Rect;\r
2530         RECT Rect1;\r
2531 \r
2532         if((Resizing == RESIZE_OFF) && (Keys == 0))\r
2533         {\r
2534                 if((x >= LocalWidth) && (x <= LocalWidth + SepaWidth) &&\r
2535                    (y > TOOLWIN_HEIGHT) && (y < (TOOLWIN_HEIGHT * 2 + ListHeight)))\r
2536                 {\r
2537                         /* 境界位置変更用カーソルに変更 */\r
2538                         SetCapture(hWndFtp);\r
2539                         hCursor = LoadCursor(hInstFtp, MAKEINTRESOURCE(resize_lr_csr));\r
2540                         SetCursor(hCursor);\r
2541                         Resizing = RESIZE_PREPARE;\r
2542                         ResizePos = RESIZE_HPOS;\r
2543                 }\r
2544                 else if((y >= TOOLWIN_HEIGHT*2+ListHeight) && (y <= TOOLWIN_HEIGHT*2+ListHeight+SepaWidth))\r
2545                 {\r
2546                         /* 境界位置変更用カーソルに変更 */\r
2547                         SetCapture(hWndFtp);\r
2548                         hCursor = LoadCursor(hInstFtp, MAKEINTRESOURCE(resize_ud_csr));\r
2549                         SetCursor(hCursor);\r
2550                         Resizing = RESIZE_PREPARE;\r
2551                         ResizePos = RESIZE_VPOS;\r
2552                 }\r
2553         }\r
2554         else if(Resizing == RESIZE_PREPARE)\r
2555         {\r
2556                 if(Keys & MK_LBUTTON)\r
2557                 {\r
2558                         /* 境界位置変更開始 */\r
2559                         Resizing = RESIZE_ON;\r
2560                         GetWindowRect(hWndFtp, &Rect);\r
2561                         GetClientRect(GetSbarWnd(), &Rect1);\r
2562                         Rect.left += GetSystemMetrics(SM_CXFRAME);\r
2563                         Rect.right -= GetSystemMetrics(SM_CXFRAME);\r
2564                         Rect.top += TOOLWIN_HEIGHT*2 + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);\r
2565                         Rect.bottom -= GetSystemMetrics(SM_CYFRAME) + Rect1.bottom;\r
2566                         ClipCursor(&Rect);\r
2567                 }\r
2568                 else\r
2569                 {\r
2570                         if(((ResizePos == RESIZE_HPOS) &&\r
2571                                 ((x < LocalWidth) || (x > LocalWidth + SepaWidth) ||\r
2572                                  (y <= TOOLWIN_HEIGHT) || (y >= (TOOLWIN_HEIGHT * 2 + ListHeight)))) ||\r
2573                            ((ResizePos == RESIZE_VPOS) &&\r
2574                                 ((y < TOOLWIN_HEIGHT*2+ListHeight) || (y > TOOLWIN_HEIGHT*2+ListHeight+SepaWidth))))\r
2575                         {\r
2576                                 /* 元のカーソルに戻す */\r
2577                                 ReleaseCapture();\r
2578                                 hCursor = LoadCursor(NULL, IDC_ARROW);\r
2579                                 SetCursor(hCursor);\r
2580                                 Resizing = RESIZE_OFF;\r
2581                         }\r
2582                 }\r
2583         }\r
2584         else if(Resizing == RESIZE_ON)\r
2585         {\r
2586                 if(ResizePos == RESIZE_HPOS)\r
2587                         LocalWidth = x;\r
2588                 else\r
2589                 {\r
2590                         GetClientRect(hWndFtp, &Rect);\r
2591                         GetClientRect(GetSbarWnd(), &Rect1);\r
2592                         TaskHeight = max1(0, Rect.bottom - y - Rect1.bottom);\r
2593                 }\r
2594                 ResizeWindowProc();\r
2595 \r
2596                 if((Keys & MK_LBUTTON) == 0)\r
2597                 {\r
2598                         /* 境界位置変更終了 */\r
2599                         ReleaseCapture();\r
2600                         ClipCursor(NULL);\r
2601                         hCursor = LoadCursor(NULL, IDC_ARROW);\r
2602                         SetCursor(hCursor);\r
2603                         Resizing = RESIZE_OFF;\r
2604                 }\r
2605         }\r
2606         return;\r
2607 }\r
2608 \r
2609 \r
2610 /*----- ファイル一覧情報をビューワで表示 --------------------------------------\r
2611 *\r
2612 *       Parameter\r
2613 *               なし\r
2614 *\r
2615 *       Return Value\r
2616 *               なし\r
2617 *----------------------------------------------------------------------------*/\r
2618 \r
2619 static void DispDirInfo(void)\r
2620 {\r
2621         char Buf[FMAX_PATH+1];\r
2622 \r
2623         MakeCacheFileName(AskCurrentFileListNum(), Buf);\r
2624         ExecViewer(Buf, 0);\r
2625         return;\r
2626 }\r
2627 \r
2628 \r
2629 \r
2630 /*----- ビューワを起動 --------------------------------------------------------\r
2631 *\r
2632 *       Parameter\r
2633 *               char Fname : ファイル名\r
2634 *               int App : アプリケーション番号(-1=関連づけ優先)\r
2635 *\r
2636 *       Return Value\r
2637 *               なし\r
2638 *----------------------------------------------------------------------------*/\r
2639 \r
2640 void ExecViewer(char *Fname, int App)\r
2641 {\r
2642         PROCESS_INFORMATION Info;\r
2643         STARTUPINFO Startup;\r
2644         char AssocProg[FMAX_PATH+1];\r
2645         char ComLine[FMAX_PATH*2+3+1];\r
2646         char CurDir[FMAX_PATH+1];\r
2647         // 任意のコードが実行されるバグ修正\r
2648         char SysDir[FMAX_PATH+1];\r
2649 \r
2650         /* FindExecutable()は関連付けられたプログラムのパス名にスペースが        */\r
2651         /* 含まれている時、間違ったパス名を返す事がある。                                        */\r
2652         /* そこで、関連付けられたプログラムの起動はShellExecute()を使う。       */\r
2653 \r
2654         AskLocalCurDir(CurDir, FMAX_PATH);\r
2655 \r
2656         // 任意のコードが実行されるバグ修正\r
2657         // 拡張子が無いと補完されるため\r
2658 //      if((App == -1) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32))\r
2659         if((App == -1) && (strlen(GetFileExt(GetFileName(Fname))) > 0) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32))\r
2660         {\r
2661                 DoPrintf("ShellExecute - %s", Fname);\r
2662                 ShellExecute(NULL, "open", Fname, NULL, CurDir, SW_SHOW);\r
2663         }\r
2664         // ローカルフォルダを開く\r
2665         else if((App == -1) && (GetFileAttributes(Fname) & FILE_ATTRIBUTE_DIRECTORY))\r
2666         {\r
2667                 MakeDistinguishableFileName(ComLine, Fname);\r
2668                 DoPrintf("ShellExecute - %s", Fname);\r
2669                 ShellExecute(NULL, "open", ComLine, NULL, Fname, SW_SHOW);\r
2670         }\r
2671         else\r
2672         {\r
2673                 App = max1(0, App);\r
2674                 strcpy(AssocProg, ViewerName[App]);\r
2675 \r
2676                 if(strchr(Fname, ' ') == NULL)\r
2677                         sprintf(ComLine, "%s %s", AssocProg, Fname);\r
2678                 else\r
2679                         sprintf(ComLine, "%s \"%s\"", AssocProg, Fname);\r
2680 \r
2681                 DoPrintf("FindExecutable - %s", ComLine);\r
2682 \r
2683                 memset(&Startup, NUL, sizeof(STARTUPINFO));\r
2684                 Startup.cb = sizeof(STARTUPINFO);\r
2685                 Startup.wShowWindow = SW_SHOW;\r
2686                 // 任意のコードが実行されるバグ修正\r
2687 //              if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
2688 //              {\r
2689 //                      SetTaskMsg(MSGJPN182, GetLastError());\r
2690 //                      SetTaskMsg(">>%s", ComLine);\r
2691 //              }\r
2692                 if(GetCurrentDirectory(FMAX_PATH, CurDir) > 0)\r
2693                 {\r
2694                         if(GetSystemDirectory(SysDir, FMAX_PATH) > 0)\r
2695                         {\r
2696                                 if(SetCurrentDirectory(SysDir))\r
2697                                 {\r
2698                                         if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
2699                                         {\r
2700                                                 SetTaskMsg(MSGJPN182, GetLastError());\r
2701                                                 SetTaskMsg(">>%s", ComLine);\r
2702                                         }\r
2703                                         SetCurrentDirectory(CurDir);\r
2704                                 }\r
2705                         }\r
2706                 }\r
2707         }\r
2708         return;\r
2709 }\r
2710 \r
2711 \r
2712 /*----- 差分表示ビューワを起動 ------------------------------------------------\r
2713 *\r
2714 *       Parameter\r
2715 *               char Fname1 : ファイル名\r
2716 *               char Fname2 : ファイル名2\r
2717 *               int App : アプリケーション番号(2 or 3)\r
2718 *\r
2719 *       Return Value\r
2720 *               なし\r
2721 *----------------------------------------------------------------------------*/\r
2722 \r
2723 void ExecViewer2(char *Fname1, char *Fname2, int App)\r
2724 {\r
2725         PRO