OSDN Git Service

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