OSDN Git Service

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