OSDN Git Service

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