OSDN Git Service

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