OSDN Git Service

Let save hashes of confirmed certificate cache.
[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, raido).");\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                         switch(LOWORD(wParam))\r
836                         {\r
837                                 case MENU_CONNECT :\r
838                                         ConnectProc(DLG_TYPE_CON, -1);\r
839                                         break;\r
840 \r
841                                 case MENU_CONNECT_NUM :\r
842                                         ConnectProc(DLG_TYPE_CON, (int)lParam);\r
843                                         if(AskConnecting() == YES)\r
844                                         {\r
845                                                 if(HIWORD(wParam) & OPT_MIRROR)\r
846                                                 {\r
847                                                         if(HIWORD(wParam) & OPT_FORCE)\r
848                                                                 MirrorUploadProc(NO);\r
849                                                         else\r
850                                                                 MirrorUploadProc(YES);\r
851                                                 }\r
852                                                 else if(HIWORD(wParam) & OPT_MIRRORDOWN)\r
853                                                 {\r
854                                                         if(HIWORD(wParam) & OPT_FORCE)\r
855                                                                 MirrorDownloadProc(NO);\r
856                                                         else\r
857                                                                 MirrorDownloadProc(YES);\r
858                                                 }\r
859                                         }\r
860                                         break;\r
861 \r
862                                 case MENU_SET_CONNECT :\r
863                                         ConnectProc(DLG_TYPE_SET, -1);\r
864                                         break;\r
865 \r
866                                 case MENU_QUICK :\r
867                                         QuickConnectProc();\r
868                                         break;\r
869 \r
870                                 case MENU_DISCONNECT :\r
871                                         if(AskTryingConnect() == YES)\r
872                                                 CancelFlg = YES;\r
873                                         else if(AskConnecting() == YES)\r
874                                         {\r
875                                                 SaveBookMark();\r
876                                                 SaveCurrentSetToHost();\r
877                                                 DisconnectProc();\r
878                                         }\r
879                                         break;\r
880 \r
881                                 case MENU_HIST_1 :\r
882                                 case MENU_HIST_2 :\r
883                                 case MENU_HIST_3 :\r
884                                 case MENU_HIST_4 :\r
885                                 case MENU_HIST_5 :\r
886                                 case MENU_HIST_6 :\r
887                                 case MENU_HIST_7 :\r
888                                 case MENU_HIST_8 :\r
889                                 case MENU_HIST_9 :\r
890                                 case MENU_HIST_10 :\r
891                                 case MENU_HIST_11 :\r
892                                 case MENU_HIST_12 :\r
893                                 case MENU_HIST_13 :\r
894                                 case MENU_HIST_14 :\r
895                                 case MENU_HIST_15 :\r
896                                 case MENU_HIST_16 :\r
897                                 case MENU_HIST_17 :\r
898                                 case MENU_HIST_18 :\r
899                                 case MENU_HIST_19 :\r
900                                 case MENU_HIST_20 :\r
901                                         HistoryConnectProc(LOWORD(wParam));\r
902                                         break;\r
903 \r
904                                 case MENU_UPDIR :\r
905                                         if(hWndCurFocus == GetLocalHwnd())\r
906                                                 PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(MENU_LOCAL_UPDIR, 0), 0);\r
907                                         else\r
908                                                 PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(MENU_REMOTE_UPDIR, 0), 0);\r
909                                         break;\r
910 \r
911                                 case MENU_DCLICK :\r
912                                         if(hWndCurFocus == GetLocalHwnd())\r
913                                                 DoubleClickProc(WIN_LOCAL, YES, -1);\r
914                                         else\r
915                                         {\r
916                                                 SuppressRefresh = 1;\r
917                                                 DoubleClickProc(WIN_REMOTE, YES, -1);\r
918                                                 SuppressRefresh = 0;\r
919                                         }\r
920                                         break;\r
921 \r
922                                 case MENU_OPEN1 :\r
923                                         if(hWndCurFocus == GetLocalHwnd())\r
924                                                 DoubleClickProc(WIN_LOCAL, YES, 0);\r
925                                         else\r
926                                         {\r
927                                                 SuppressRefresh = 1;\r
928                                                 DoubleClickProc(WIN_REMOTE, YES, 0);\r
929                                                 SuppressRefresh = 0;\r
930                                         }\r
931                                         break;\r
932 \r
933                                 case MENU_OPEN2 :\r
934                                         if(hWndCurFocus == GetLocalHwnd())\r
935                                                 DoubleClickProc(WIN_LOCAL, YES, 1);\r
936                                         else\r
937                                         {\r
938                                                 SuppressRefresh = 1;\r
939                                                 DoubleClickProc(WIN_REMOTE, YES, 1);\r
940                                                 SuppressRefresh = 0;\r
941                                         }\r
942                                         break;\r
943 \r
944                                 case MENU_OPEN3 :\r
945                                         if(hWndCurFocus == GetLocalHwnd())\r
946                                                 DoubleClickProc(WIN_LOCAL, YES, 2);\r
947                                         else\r
948                                         {\r
949                                                 SuppressRefresh = 1;\r
950                                                 DoubleClickProc(WIN_REMOTE, YES, 2);\r
951                                                 SuppressRefresh = 0;\r
952                                         }\r
953                                         break;\r
954 \r
955                                 case MENU_REMOTE_UPDIR :\r
956                                         SuppressRefresh = 1;\r
957                                         SetCurrentDirAsDirHist();\r
958                                         ChangeDir(WIN_REMOTE, "..");\r
959                                         SuppressRefresh = 0;\r
960                                         break;\r
961 \r
962                                 case MENU_LOCAL_UPDIR :\r
963                                         SetCurrentDirAsDirHist();\r
964                                         ChangeDir(WIN_LOCAL, "..");\r
965                                         break;\r
966 \r
967                                 case MENU_REMOTE_CHDIR :\r
968                                         SuppressRefresh = 1;\r
969                                         SetCurrentDirAsDirHist();\r
970                                         ChangeDirDirectProc(WIN_REMOTE);\r
971                                         SuppressRefresh = 0;\r
972                                         break;\r
973 \r
974                                 case MENU_LOCAL_CHDIR :\r
975                                         SetCurrentDirAsDirHist();\r
976                                         ChangeDirDirectProc(WIN_LOCAL);\r
977                                         break;\r
978 \r
979                                 case MENU_DOWNLOAD :\r
980                                         SetCurrentDirAsDirHist();\r
981                                         DownLoadProc(NO, NO, NO);\r
982                                         break;\r
983 \r
984                                 case MENU_DOWNLOAD_AS :\r
985                                         SetCurrentDirAsDirHist();\r
986                                         DownLoadProc(YES, NO, NO);\r
987                                         break;\r
988 \r
989                                 case MENU_DOWNLOAD_AS_FILE :\r
990                                         SetCurrentDirAsDirHist();\r
991                                         DownLoadProc(NO, YES, NO);\r
992                                         break;\r
993 \r
994                                 case MENU_DOWNLOAD_ALL :\r
995                                         SetCurrentDirAsDirHist();\r
996                                         DownLoadProc(NO, NO, YES);\r
997                                         break;\r
998 \r
999                                 case MENU_DOWNLOAD_NAME :\r
1000                                         SetCurrentDirAsDirHist();\r
1001                                         InputDownLoadProc();\r
1002                                         break;\r
1003 \r
1004                                 case MENU_UPLOAD :\r
1005                                         SetCurrentDirAsDirHist();\r
1006                                         UpLoadListProc(NO, NO);\r
1007                                         break;\r
1008 \r
1009                                 case MENU_UPLOAD_AS :\r
1010                                         SetCurrentDirAsDirHist();\r
1011                                         UpLoadListProc(YES, NO);\r
1012                                         break;\r
1013 \r
1014                                 case MENU_UPLOAD_ALL :\r
1015                                         SetCurrentDirAsDirHist();\r
1016                                         UpLoadListProc(NO, YES);\r
1017                                         break;\r
1018 \r
1019                                 case MENU_MIRROR_UPLOAD :\r
1020                                         SetCurrentDirAsDirHist();\r
1021                                         MirrorUploadProc(YES);\r
1022                                         break;\r
1023 \r
1024                                 case MENU_MIRROR_DOWNLOAD :\r
1025                                         SetCurrentDirAsDirHist();\r
1026                                         MirrorDownloadProc(YES);\r
1027                                         break;\r
1028 \r
1029                                 case MENU_FILESIZE :\r
1030                                         SetCurrentDirAsDirHist();\r
1031                                         CalcFileSizeProc();\r
1032                                         break;\r
1033 \r
1034                                 case MENU_DELETE :\r
1035                                         SuppressRefresh = 1;\r
1036                                         SetCurrentDirAsDirHist();\r
1037                                         DeleteProc();\r
1038                                         SuppressRefresh = 0;\r
1039                                         break;\r
1040 \r
1041                                 case MENU_RENAME :\r
1042                                         SuppressRefresh = 1;\r
1043                                         SetCurrentDirAsDirHist();\r
1044                                         RenameProc();\r
1045                                         SuppressRefresh = 0;\r
1046                                         break;\r
1047 \r
1048                                 case MENU_MKDIR :\r
1049                                         SuppressRefresh = 1;\r
1050                                         SetCurrentDirAsDirHist();\r
1051                                         MkdirProc();\r
1052                                         SuppressRefresh = 0;\r
1053                                         break;\r
1054 \r
1055                                 case MENU_CHMOD :\r
1056                                         SuppressRefresh = 1;\r
1057                                         ChmodProc();\r
1058                                         SuppressRefresh = 0;\r
1059                                         break;\r
1060 \r
1061                                 case MENU_SOMECMD :\r
1062                                         SuppressRefresh = 1;\r
1063                                         SomeCmdProc();\r
1064                                         SuppressRefresh = 0;\r
1065                                         break;\r
1066 \r
1067                                 case MENU_OPTION :\r
1068                                         SetOption(0);\r
1069                                         if(ListFont != NULL)\r
1070                                         {\r
1071                                                 SendMessage(GetLocalHwnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1072                                                 SendMessage(GetRemoteHwnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1073                                                 SendMessage(GetTaskWnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1074                                         }\r
1075                                         GetLocalDirForWnd();\r
1076                                         DispTransferType();\r
1077                                         CheckHistoryNum(0);\r
1078                                         SetAllHistoryToMenu();\r
1079                                         // 暗号化通信対応\r
1080                                         SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);\r
1081                                         break;\r
1082 \r
1083                                 case MENU_FILTER :\r
1084                                         SetFilter(&CancelFlg);\r
1085                                         break;\r
1086 \r
1087                                 case MENU_SORT :\r
1088                                         if(SortSetting() == YES)\r
1089                                         {\r
1090                                                 LocalFileSort = AskSortType(ITEM_LFILE);\r
1091                                                 LocalDirSort = AskSortType(ITEM_LDIR);\r
1092                                                 RemoteFileSort = AskSortType(ITEM_RFILE);\r
1093                                                 RemoteDirSort = AskSortType(ITEM_RDIR);\r
1094                                                 ReSortDispList(WIN_LOCAL, &CancelFlg);\r
1095                                                 ReSortDispList(WIN_REMOTE, &CancelFlg);\r
1096                                         }\r
1097                                         break;\r
1098 \r
1099                                 case MENU_EXIT :\r
1100                                         PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1101                                         break;\r
1102 \r
1103                                 case MENU_AUTO_EXIT :\r
1104                                         if(AutoExit == YES)\r
1105                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1106                                         break;\r
1107 \r
1108                                 case MENU_ABOUT :\r
1109                                         DialogBox(hInstFtp, MAKEINTRESOURCE(about_dlg), hWnd, AboutDialogProc);\r
1110                                         break;\r
1111 \r
1112                                 case MENU_TEXT :\r
1113                                 case MENU_BINARY :\r
1114                                 case MENU_AUTO :\r
1115                                         SetTransferType(LOWORD(wParam));\r
1116                                         DispTransferType();\r
1117                                         break;\r
1118 \r
1119                                 case MENU_XFRMODE :\r
1120                                         switch(AskTransferType())\r
1121                                         {\r
1122                                                 case TYPE_A :\r
1123                                                         TmpTransType = MENU_BINARY;\r
1124                                                         break;\r
1125 \r
1126                                                 case TYPE_I :\r
1127                                                         TmpTransType = MENU_AUTO;\r
1128                                                         break;\r
1129 \r
1130                                                 default :\r
1131                                                         TmpTransType = MENU_TEXT;\r
1132                                                         break;\r
1133                                         }\r
1134                                         SetTransferType(TmpTransType);\r
1135                                         DispTransferType();\r
1136                                         break;\r
1137 \r
1138                                 // UTF-8対応\r
1139                                 case MENU_KNJ_SJIS :\r
1140                                 case MENU_KNJ_EUC :\r
1141                                 case MENU_KNJ_JIS :\r
1142                                 case MENU_KNJ_UTF8N :\r
1143                                 case MENU_KNJ_NONE :\r
1144                                         SetHostKanjiCode(LOWORD(wParam));\r
1145                                         break;\r
1146 \r
1147                                 case MENU_L_KNJ_SJIS :\r
1148                                 case MENU_L_KNJ_EUC :\r
1149                                 case MENU_L_KNJ_JIS :\r
1150                                 case MENU_L_KNJ_UTF8N :\r
1151                                         SetLocalKanjiCode(LOWORD(wParam));\r
1152                                         break;\r
1153 \r
1154                                 case MENU_KANACNV :\r
1155                                         SetHostKanaCnv();\r
1156                                         break;\r
1157 \r
1158                                 case MENU_REFRESH :\r
1159                                         SuppressRefresh = 1;\r
1160                                         GetLocalDirForWnd();\r
1161                                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1162                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
1163                                         SuppressRefresh = 0;\r
1164                                         break;\r
1165 \r
1166                                 case MENU_LIST :\r
1167                                         ListType = LVS_LIST;\r
1168                                         DispListType();\r
1169                                         SetListViewType();\r
1170                                         break;\r
1171 \r
1172                                 case MENU_REPORT :\r
1173                                         ListType = LVS_REPORT;\r
1174                                         DispListType();\r
1175                                         SetListViewType();\r
1176                                         break;\r
1177 \r
1178                                 case REFRESH_LOCAL :\r
1179                                         GetLocalDirForWnd();\r
1180                                         break;\r
1181 \r
1182                                 case REFRESH_REMOTE :\r
1183                                         SuppressRefresh = 1;\r
1184                                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1185                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
1186                                         SuppressRefresh = 0;\r
1187                                         break;\r
1188 \r
1189                                 case COMBO_LOCAL :\r
1190                                 case COMBO_REMOTE :\r
1191                                         SuppressRefresh = 1;\r
1192                                         if(HIWORD(wParam) == CBN_SELCHANGE)\r
1193                                         {\r
1194                                                 SetCurrentDirAsDirHist();\r
1195                                                 ChangeDirComboProc((HWND)lParam);\r
1196                                         }\r
1197                                         else if(HIWORD(wParam) != CBN_CLOSEUP)\r
1198                                         {\r
1199                                                 MakeButtonsFocus();\r
1200                                                 SuppressRefresh = 0;\r
1201                                                 return(0);\r
1202                                         }\r
1203                                         SuppressRefresh = 0;\r
1204                                         break;\r
1205 \r
1206                                 case MENU_HELP :\r
1207                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000001);\r
1208                                         break;\r
1209 \r
1210                                 case MENU_HELP_TROUBLE :\r
1211                                         ShellExecute(NULL, "open", MYWEB_URL, NULL, ".", SW_SHOW);\r
1212                                         break;\r
1213 \r
1214                                 case MENU_BMARK_ADD :\r
1215                                         AddCurDirToBookMark(WIN_REMOTE);\r
1216                                         break;\r
1217 \r
1218                                 case MENU_BMARK_ADD_LOCAL :\r
1219                                         AddCurDirToBookMark(WIN_LOCAL);\r
1220                                         break;\r
1221 \r
1222                                 case MENU_BMARK_ADD_BOTH :\r
1223                                         AddCurDirToBookMark(WIN_BOTH);\r
1224                                         break;\r
1225 \r
1226                                 case MENU_BMARK_EDIT :\r
1227                                         EditBookMark();\r
1228                                         break;\r
1229 \r
1230                                 case MENU_SELECT_ALL :\r
1231                                         SelectFileInList(hWndCurFocus, SELECT_ALL);\r
1232                                         break;\r
1233 \r
1234                                 case MENU_SELECT :\r
1235                                         SelectFileInList(hWndCurFocus, SELECT_REGEXP);\r
1236                                         break;\r
1237 \r
1238                                 case MENU_FIND :\r
1239                                         FindFileInList(hWndCurFocus, FIND_FIRST);\r
1240                                         break;\r
1241 \r
1242                                 case MENU_FINDNEXT :\r
1243                                         FindFileInList(hWndCurFocus, FIND_NEXT);\r
1244                                         break;\r
1245 \r
1246                                 case MENU_DOTFILE :\r
1247                                         DotFile ^= 1;\r
1248                                         DispDotFileMode();\r
1249                                         GetLocalDirForWnd();\r
1250                                         GetRemoteDirForWnd(CACHE_LASTREAD, &CancelFlg);\r
1251                                         break;\r
1252 \r
1253                                 case MENU_SYNC :\r
1254                                         ToggleSyncMoveMode();\r
1255                                         break;\r
1256 \r
1257                                 case MENU_IMPORT_WS :\r
1258                                         ImportFromWSFTP();\r
1259                                         break;\r
1260 \r
1261                                 case MENU_REGSAVE :\r
1262                                         GetListTabWidth();\r
1263                                         SaveRegistory();\r
1264                                         SaveSettingsToFile();\r
1265                                         break;\r
1266 \r
1267                                 case MENU_REGLOAD :\r
1268                                         if(LoadSettingsFromFile() == YES)\r
1269                                         {\r
1270                                                 MessageBox(hWnd, MSGJPN292, "FFFTP", MB_OK);\r
1271                                                 SaveExit = NO;\r
1272                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1273                                         }\r
1274                                         break;\r
1275 \r
1276                                 case MENU_REGINIT :\r
1277                                         if(DialogBox(hInstFtp, MAKEINTRESOURCE(reginit_dlg), hWnd, ExeEscDialogProc) == YES)\r
1278                                         {\r
1279                                                 ClearRegistory();\r
1280                                                 SaveExit = NO;\r
1281                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1282                                         }\r
1283                                         break;\r
1284                                 case MENU_CHANGEPASSWD: /* 2010.01.31 genta */\r
1285                                         if( GetMasterPasswordStatus() != PASSWORD_OK )\r
1286                                         {\r
1287                                                 /* 強制的に設定するか確認 */\r
1288                                                 if( DialogBox(hInstFtp, MAKEINTRESOURCE(forcepasschange_dlg), hWnd, ExeEscDialogProc) != YES){\r
1289                                                         break;\r
1290                                                 }\r
1291                                         }\r
1292                                         if( EnterMasterPasswordAndSet( newmasterpasswd_dlg, hWnd ) != 0 ){\r
1293                                                 SetTaskMsg( MSGJPN303 );\r
1294                                         }\r
1295                                         break;\r
1296 \r
1297                                 case MENU_DIRINFO :\r
1298                                         DispDirInfo();\r
1299                                         break;\r
1300 \r
1301                                 case MENU_TASKINFO :\r
1302                                         DispTaskMsg();\r
1303                                         break;\r
1304 \r
1305                                 case MENU_ABORT :\r
1306                                         CancelFlg = YES;\r
1307                                         if(AskTryingConnect() == NO)\r
1308                                                 MainTransPkt.Abort = ABORT_USER;\r
1309                                         break;\r
1310 \r
1311                                 case MENU_OTPCALC :\r
1312                                         OtpCalcTool();\r
1313                                         break;\r
1314 \r
1315                                 case MENU_URL_COPY :\r
1316                                         CopyURLtoClipBoard();\r
1317                                         break;\r
1318 \r
1319                                 case MENU_APPKEY :\r
1320                                         EraseListViewTips();\r
1321                                         if(hWndCurFocus == GetRemoteHwnd())\r
1322                                                 RemoteRbuttonMenu(1);\r
1323                                         else if(hWndCurFocus == GetLocalHwnd())\r
1324                                                 LocalRbuttonMenu(1);\r
1325                                         break;\r
1326 \r
1327                                 default :\r
1328                                         if((LOWORD(wParam) >= MENU_BMARK_TOP) &&\r
1329                                            (LOWORD(wParam) < MENU_BMARK_TOP+100))\r
1330                                         {\r
1331                                                 ChangeDirBmarkProc(LOWORD(wParam));\r
1332                                         }\r
1333                                         break;\r
1334                         }\r
1335 // 常にホストかローカルへフォーカスを移動\r
1336 //                      SetFocus(hWndCurFocus);\r
1337                         MakeButtonsFocus();\r
1338                         break;\r
1339 \r
1340                 case WM_NOTIFY :\r
1341                         switch(((LPNMHDR)lParam)->code)\r
1342                         {\r
1343                                 /* ツールチップコントロールメッセージの処理 */\r
1344                                 case TTN_NEEDTEXT:\r
1345                                         lpttt = (LPTOOLTIPTEXT)lParam;\r
1346                                         lpttt->hinst = hInstFtp;\r
1347                                         switch(lpttt->hdr.idFrom)\r
1348                                         {\r
1349                                                 case MENU_CONNECT :\r
1350                                                         lpttt->lpszText = MSGJPN154;\r
1351                                                         break;\r
1352 \r
1353                                                 case MENU_QUICK :\r
1354                                                         lpttt->lpszText = MSGJPN155;\r
1355                                                         break;\r
1356 \r
1357                                                 case MENU_DISCONNECT :\r
1358                                                         lpttt->lpszText = MSGJPN156;\r
1359                                                         break;\r
1360 \r
1361                                                 case MENU_DOWNLOAD :\r
1362                                                         lpttt->lpszText = MSGJPN157;\r
1363                                                         break;\r
1364 \r
1365                                                 case MENU_UPLOAD :\r
1366                                                         lpttt->lpszText = MSGJPN158;\r
1367                                                         break;\r
1368 \r
1369                                                 case MENU_MIRROR_UPLOAD :\r
1370                                                         lpttt->lpszText = MSGJPN159;\r
1371                                                         break;\r
1372 \r
1373                                                 case MENU_DELETE :\r
1374                                                         lpttt->lpszText = MSGJPN160;\r
1375                                                         break;\r
1376 \r
1377                                                 case MENU_RENAME :\r
1378                                                         lpttt->lpszText = MSGJPN161;\r
1379                                                         break;\r
1380 \r
1381                                                 case MENU_MKDIR :\r
1382                                                         lpttt->lpszText = MSGJPN162;\r
1383                                                         break;\r
1384 \r
1385                                                 case MENU_LOCAL_UPDIR :\r
1386                                                 case MENU_REMOTE_UPDIR :\r
1387                                                         lpttt->lpszText = MSGJPN163;\r
1388                                                         break;\r
1389 \r
1390                                                 case MENU_LOCAL_CHDIR :\r
1391                                                 case MENU_REMOTE_CHDIR :\r
1392                                                         lpttt->lpszText = MSGJPN164;\r
1393                                                         break;\r
1394 \r
1395                                                 case MENU_TEXT :\r
1396                                                         lpttt->lpszText = MSGJPN165;\r
1397                                                         break;\r
1398 \r
1399                                                 case MENU_BINARY :\r
1400                                                         lpttt->lpszText = MSGJPN166;\r
1401                                                         break;\r
1402 \r
1403                                                 case MENU_AUTO :\r
1404                                                         lpttt->lpszText = MSGJPN167;\r
1405                                                         break;\r
1406 \r
1407                                                 case MENU_REFRESH :\r
1408                                                         lpttt->lpszText = MSGJPN168;\r
1409                                                         break;\r
1410 \r
1411                                                 case MENU_LIST :\r
1412                                                         lpttt->lpszText = MSGJPN169;\r
1413                                                         break;\r
1414 \r
1415                                                 case MENU_REPORT :\r
1416                                                         lpttt->lpszText = MSGJPN170;\r
1417                                                         break;\r
1418 \r
1419                                                 case MENU_KNJ_SJIS :\r
1420                                                         lpttt->lpszText = MSGJPN307;\r
1421                                                         break;\r
1422 \r
1423                                                 case MENU_KNJ_EUC :\r
1424                                                         lpttt->lpszText = MSGJPN171;\r
1425                                                         break;\r
1426 \r
1427                                                 case MENU_KNJ_JIS :\r
1428                                                         lpttt->lpszText = MSGJPN172;\r
1429                                                         break;\r
1430 \r
1431                                                 case MENU_KNJ_UTF8N :\r
1432                                                         lpttt->lpszText = MSGJPN308;\r
1433                                                         break;\r
1434 \r
1435                                                 case MENU_KNJ_NONE :\r
1436                                                         lpttt->lpszText = MSGJPN173;\r
1437                                                         break;\r
1438 \r
1439                                                 case MENU_L_KNJ_SJIS :\r
1440                                                         lpttt->lpszText = MSGJPN309;\r
1441                                                         break;\r
1442 \r
1443                                                 case MENU_L_KNJ_EUC :\r
1444                                                         lpttt->lpszText = MSGJPN310;\r
1445                                                         break;\r
1446 \r
1447                                                 case MENU_L_KNJ_JIS :\r
1448                                                         lpttt->lpszText = MSGJPN311;\r
1449                                                         break;\r
1450 \r
1451                                                 case MENU_L_KNJ_UTF8N :\r
1452                                                         lpttt->lpszText = MSGJPN312;\r
1453                                                         break;\r
1454 \r
1455                                                 case MENU_KANACNV :\r
1456                                                         lpttt->lpszText = MSGJPN174;\r
1457                                                         break;\r
1458 \r
1459                                                 case MENU_SYNC :\r
1460                                                         lpttt->lpszText = MSGJPN175;\r
1461                                                         break;\r
1462 \r
1463                                                 case MENU_ABORT :\r
1464                                                         lpttt->lpszText = MSGJPN176;\r
1465                                                         break;\r
1466                                         }\r
1467                                         // UTF-8からShift_JISへ変換\r
1468                                         {\r
1469                                                 static wchar_t StringBufferUTF16[1024];\r
1470                                                 static char StringBufferSJIS[1024];\r
1471                                                 if(lpttt->lpszText)\r
1472                                                 {\r
1473                                                         MtoW(StringBufferUTF16, sizeof(StringBufferUTF16)/ sizeof(wchar_t), lpttt->lpszText, -1);\r
1474                                                         WtoA(StringBufferSJIS, sizeof(StringBufferSJIS)/ sizeof(char), StringBufferUTF16, -1);\r
1475                                                         lpttt->lpszText = StringBufferSJIS;\r
1476                                                 }\r
1477                                         }\r
1478                                         break;\r
1479 \r
1480                                 case LVN_COLUMNCLICK :\r
1481                                         if(((NMHDR *)lParam)->hwndFrom == GetLocalHwnd())\r
1482                                         {\r
1483                                                 SetSortTypeByColumn(WIN_LOCAL, ((NM_LISTVIEW *)lParam)->iSubItem);\r
1484                                                 ReSortDispList(WIN_LOCAL, &CancelFlg);\r
1485                                         }\r
1486                                         else if(((NMHDR *)lParam)->hwndFrom == GetRemoteHwnd())\r
1487                                         {\r
1488                                                 if(((NM_LISTVIEW *)lParam)->iSubItem != 4)\r
1489                                                 {\r
1490                                                         SetSortTypeByColumn(WIN_REMOTE, ((NM_LISTVIEW *)lParam)->iSubItem);\r
1491                                                         ReSortDispList(WIN_REMOTE, &CancelFlg);\r
1492                                                 }\r
1493                                         }\r
1494                                         SetFocus(hWndCurFocus);\r
1495                                         break;\r
1496 \r
1497                                 case LVN_ITEMCHANGED :\r
1498                                         DispSelectedSpace();\r
1499                                         MakeButtonsFocus();\r
1500                                         break;\r
1501                         }\r
1502                         break;\r
1503 \r
1504                 case WM_SIZE :\r
1505                         Sizing = SW_RESTORE;\r
1506                         if(wParam == SIZE_RESTORED)\r
1507                         {\r
1508                                 ResizeWindowProc();\r
1509                                 GetWindowRect(hWnd, &Rect);\r
1510                                 WinPosX = Rect.left;\r
1511                                 WinPosY = Rect.top;\r
1512                         }\r
1513                         else if(wParam == SIZE_MAXIMIZED)\r
1514                         {\r
1515                                 Sizing = SW_MAXIMIZE;\r
1516                                 ResizeWindowProc();\r
1517                         }\r
1518                         else\r
1519                                 return(DefWindowProc(hWnd, message, wParam, lParam));\r
1520                         break;\r
1521 \r
1522                 case WM_MOVING :\r
1523                         WinPosX = ((RECT *)lParam)->left;\r
1524                         WinPosY = ((RECT *)lParam)->top;\r
1525                         return(DefWindowProc(hWnd, message, wParam, lParam));\r
1526 \r
1527                 case WM_SETFOCUS :\r
1528                         SetFocus(hWndCurFocus);\r
1529                         break;\r
1530 \r
1531                 case WM_LBUTTONDOWN :\r
1532                 case WM_LBUTTONUP :\r
1533                 case WM_MOUSEMOVE :\r
1534                         CheckResizeFrame(wParam, LOWORD(lParam), HIWORD(lParam));\r
1535                         break;\r
1536 \r
1537                 case WM_CHANGE_COND :\r
1538                         DispTransferFiles();\r
1539                         break;\r
1540 \r
1541                 case WM_REFRESH_LOCAL_FLG :\r
1542                         PostMessage(hWnd,  WM_COMMAND, MAKEWPARAM(REFRESH_LOCAL, 0), 0);\r
1543                         break;\r
1544 \r
1545                 case WM_REFRESH_REMOTE_FLG :\r
1546                         if(SuppressRefresh == 0)\r
1547                                 PostMessage(hWnd,  WM_COMMAND, MAKEWPARAM(REFRESH_REMOTE, 0), 0);\r
1548                         break;\r
1549 \r
1550                 case WM_PAINT :\r
1551                     BeginPaint(hWnd, (LPPAINTSTRUCT) &ps);\r
1552                     EndPaint(hWnd, (LPPAINTSTRUCT) &ps);\r
1553                         break;\r
1554 \r
1555                 case WM_DESTROY :\r
1556 //                      WSACleanup();\r
1557 //                      DestroyWindow(hWndFtp);\r
1558                         PostQuitMessage(0);\r
1559                         break;\r
1560 \r
1561                 case WM_QUERYENDSESSION :\r
1562                         ExitProc(hWnd);\r
1563                         return(TRUE);\r
1564 \r
1565                 case WM_CLOSE :\r
1566                         if((AskTransferNow() == NO) ||\r
1567                            (DialogBox(hInstFtp, MAKEINTRESOURCE(exit_dlg), hWnd, ExeEscDialogProc) == YES))\r
1568                         {\r
1569                                 ExitProc(hWnd);\r
1570                                 return(DefWindowProc(hWnd, message, wParam, lParam));\r
1571                         }\r
1572                         break;\r
1573 \r
1574                 default :\r
1575                         return(DefWindowProc(hWnd, message, wParam, lParam));\r
1576         }\r
1577     return(0L);\r
1578 }\r
1579 \r
1580 \r
1581 /*----- プログラム開始時の処理 ------------------------------------------------\r
1582 *\r
1583 *       Parameter\r
1584 *               char *Cmd : コマンドライン文字列\r
1585 *\r
1586 *       Return Value\r
1587 *               なし\r
1588 *----------------------------------------------------------------------------*/\r
1589 \r
1590 static void StartupProc(char *Cmd)\r
1591 {\r
1592         int Sts;\r
1593         int AutoConnect;\r
1594         int CmdOption;\r
1595         int Kanji;\r
1596         int Kana;\r
1597         int FnameKanji;\r
1598         int TrMode;\r
1599         char unc[FMAX_PATH+1];\r
1600 \r
1601         Sts = AnalyzeComLine(Cmd, &AutoConnect, &CmdOption, unc, FMAX_PATH);\r
1602 \r
1603         TrMode = TYPE_DEFAULT;\r
1604         Kanji = KANJI_NOCNV;\r
1605         FnameKanji = KANJI_NOCNV;\r
1606         Kana = YES;\r
1607         if(CmdOption & OPT_ASCII)\r
1608                 TrMode = TYPE_A;\r
1609         if(CmdOption & OPT_BINARY)\r
1610                 TrMode = TYPE_I;\r
1611         if(CmdOption & OPT_EUC)\r
1612                 Kanji = KANJI_EUC;\r
1613         if(CmdOption & OPT_JIS)\r
1614                 Kanji = KANJI_JIS;\r
1615         if(CmdOption & OPT_EUC_NAME)\r
1616                 FnameKanji = KANJI_EUC;\r
1617         if(CmdOption & OPT_JIS_NAME)\r
1618                 FnameKanji = KANJI_JIS;\r
1619         if(CmdOption & OPT_KANA)\r
1620                 Kana = NO;\r
1621 \r
1622         if(CmdOption & OPT_QUIT)\r
1623                 AutoExit = YES;\r
1624 \r
1625         if(CmdOption & OPT_SAVEOFF)\r
1626                 SuppressSave = YES;\r
1627         if(CmdOption & OPT_SAVEON)\r
1628                 SuppressSave = NO;\r
1629 \r
1630         if(Sts == 0)\r
1631         {\r
1632                 if(ConnectOnStart == YES)\r
1633                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_CONNECT, 0), 0);\r
1634         }\r
1635         else if(Sts == 1)\r
1636         {\r
1637                 DirectConnectProc(unc, Kanji, Kana, FnameKanji, TrMode);\r
1638         }\r
1639         else if(Sts == 2)\r
1640         {\r
1641                 PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_CONNECT_NUM, CmdOption), (LPARAM)AutoConnect);\r
1642         }\r
1643         return;\r
1644 }\r
1645 \r
1646 \r
1647 /*----- コマンドラインを解析 --------------------------------------------------\r
1648 *\r
1649 *       Parameter\r
1650 *               char *Str : コマンドライン文字列\r
1651 *               int *AutoConnect : 接続ホスト番号を返すワーク\r
1652 *               int *CmdOption : オプションを返すワーク\r
1653 *               char *unc : uncを返すワーク\r
1654 *               int Max : uncの最大長\r
1655 *\r
1656 *       Return Value\r
1657 *               int ステータス\r
1658 *                       0=指定なし、1=URL指定、2=設定名指定、-1=エラー\r
1659 *\r
1660 *       Note\r
1661 *               -m      --mirror\r
1662 *               -d      --mirrordown\r
1663 *               -f      --force\r
1664 *               -q      --quit\r
1665 *               -s      --set\r
1666 *               -h      --help\r
1667 *               -e      --euc\r
1668 *               -j      --jis\r
1669 *               -a      --ascii\r
1670 *               -b      --binary\r
1671 *               -x      --auto\r
1672 *               -k      --kana\r
1673 *               -u      --eucname\r
1674 *               -i      --jisname\r
1675 *               -n  --ini               (CheckIniFileNameで検索)\r
1676 *                       --saveoff\r
1677 *                       --saveon\r
1678 *               -z      --mpasswd       (CheckMasterPasswordで検索)  2010.01.30 genta 追加\r
1679 *----------------------------------------------------------------------------*/\r
1680 \r
1681 static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc, int Max)\r
1682 {\r
1683         int Ret;\r
1684         char Tmp[FMAX_PATH+1];\r
1685 \r
1686         *AutoConnect = -1;\r
1687         *CmdOption = 0;\r
1688 \r
1689         Ret = 0;\r
1690         memset(unc, NUL, Max+1);\r
1691 \r
1692         while((Ret != -1) && ((Str = GetToken(Str, Tmp)) != NULL))\r
1693         {\r
1694                 if(Tmp[0] == '-')\r
1695                 {\r
1696                         _strlwr(Tmp);\r
1697                         if((strcmp(&Tmp[1], "m") == 0) || (strcmp(&Tmp[1], "-mirror") == 0))\r
1698                                 *CmdOption |= OPT_MIRROR;\r
1699                         else if((strcmp(&Tmp[1], "d") == 0) || (strcmp(&Tmp[1], "-mirrordown") == 0))\r
1700                                 *CmdOption |= OPT_MIRRORDOWN;\r
1701                         else if((strcmp(&Tmp[1], "e") == 0) || (strcmp(&Tmp[1], "-euc") == 0))\r
1702                                 *CmdOption |= OPT_EUC;\r
1703                         else if((strcmp(&Tmp[1], "j") == 0) || (strcmp(&Tmp[1], "-jis") == 0))\r
1704                                 *CmdOption |= OPT_JIS;\r
1705                         else if((strcmp(&Tmp[1], "a") == 0) || (strcmp(&Tmp[1], "-ascii") == 0))\r
1706                                 *CmdOption |= OPT_ASCII;\r
1707                         else if((strcmp(&Tmp[1], "b") == 0) || (strcmp(&Tmp[1], "-binary") == 0))\r
1708                                 *CmdOption |= OPT_BINARY;\r
1709                         else if((strcmp(&Tmp[1], "x") == 0) || (strcmp(&Tmp[1], "-auto") == 0))\r
1710                                 *CmdOption |= OPT_AUTO;\r
1711                         else if((strcmp(&Tmp[1], "f") == 0) || (strcmp(&Tmp[1], "-force") == 0))\r
1712                                 *CmdOption |= OPT_FORCE;\r
1713                         else if((strcmp(&Tmp[1], "q") == 0) || (strcmp(&Tmp[1], "-quit") == 0))\r
1714                                 *CmdOption |= OPT_QUIT;\r
1715                         else if((strcmp(&Tmp[1], "k") == 0) || (strcmp(&Tmp[1], "-kana") == 0))\r
1716                                 *CmdOption |= OPT_KANA;\r
1717                         else if((strcmp(&Tmp[1], "u") == 0) || (strcmp(&Tmp[1], "-eucname") == 0))\r
1718                                 *CmdOption |= OPT_EUC_NAME;\r
1719                         else if((strcmp(&Tmp[1], "i") == 0) || (strcmp(&Tmp[1], "-jisname") == 0))\r
1720                                 *CmdOption |= OPT_JIS_NAME;\r
1721                         else if((strcmp(&Tmp[1], "n") == 0) || (strcmp(&Tmp[1], "-ini") == 0))\r
1722                         {\r
1723                                 if((Str = GetToken(Str, Tmp)) == NULL)\r
1724                                 {\r
1725                                         SetTaskMsg(MSGJPN282);\r
1726                                         Ret = -1;\r
1727                                 }\r
1728                         }\r
1729                         else if(strcmp(&Tmp[1], "-saveoff") == 0)\r
1730                                 *CmdOption |= OPT_SAVEOFF;\r
1731                         else if(strcmp(&Tmp[1], "-saveon") == 0)\r
1732                                 *CmdOption |= OPT_SAVEON;\r
1733                         else if((strcmp(&Tmp[1], "z") == 0) || (strcmp(&Tmp[1], "-mpasswd") == 0))\r
1734                         {       /* 2010.01.30 genta : Add master password option */\r
1735                                 if((Str = GetToken(Str, Tmp)) == NULL)\r
1736                                 {\r
1737                                         SetTaskMsg(MSGJPN299);\r
1738                                         Ret = -1;\r
1739                                 }\r
1740                         }\r
1741                         else if((strcmp(&Tmp[1], "s") == 0) || (strcmp(&Tmp[1], "-set") == 0))\r
1742                         {\r
1743                                 if(Ret == 0)\r
1744                                 {\r
1745                                         if((Str = GetToken(Str, Tmp)) != NULL)\r
1746                                         {\r
1747                                                 if((*AutoConnect = SearchHostName(Tmp)) != -1)\r
1748                                                         Ret = 2;\r
1749                                                 else\r
1750                                                 {\r
1751                                                         SetTaskMsg(MSGJPN177, Tmp);\r
1752                                                         Ret = -1;\r
1753                                                 }\r
1754                                         }\r
1755                                         else\r
1756                                         {\r
1757                                                 SetTaskMsg(MSGJPN178);\r
1758                                                 Ret = -1;\r
1759                                         }\r
1760                                 }\r
1761                                 else\r
1762                                 {\r
1763                                         SetTaskMsg(MSGJPN179);\r
1764                                         Ret = -1;\r
1765                                 }\r
1766                         }\r
1767                         else if((strcmp(&Tmp[1], "h") == 0) || (strcmp(&Tmp[1], "-help") == 0))\r
1768                         {\r
1769                                 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000024);\r
1770                         }\r
1771                         // プロセス保護\r
1772 #ifdef ENABLE_PROCESS_PROTECTION\r
1773                         else if(strcmp(Tmp, "--restart") == 0)\r
1774                         {\r
1775                         }\r
1776                         else if(strcmp(Tmp, "--protect") == 0)\r
1777                         {\r
1778                         }\r
1779                         else if(strcmp(Tmp, "--protect-high") == 0)\r
1780                         {\r
1781                         }\r
1782                         else if(strcmp(Tmp, "--protect-medium") == 0)\r
1783                         {\r
1784                         }\r
1785                         else if(strcmp(Tmp, "--protect-low") == 0)\r
1786                         {\r
1787                         }\r
1788 #endif\r
1789                         else\r
1790                         {\r
1791                                 SetTaskMsg(MSGJPN180, Tmp);\r
1792                                 Ret = -1;\r
1793                         }\r
1794                 }\r
1795                 else\r
1796                 {\r
1797                         if(Ret == 0)\r
1798                         {\r
1799                                 strncpy(unc, Tmp, Max);\r
1800                                 Ret = 1;\r
1801                         }\r
1802                         else\r
1803                         {\r
1804                                 SetTaskMsg(MSGJPN181);\r
1805                                 Ret = -1;\r
1806                         }\r
1807                 }\r
1808         }\r
1809         return(Ret);\r
1810 }\r
1811 \r
1812 \r
1813 /*----- INIファイルのパス名の指定をチェック ------------------------------------\r
1814 *\r
1815 *       Parameter\r
1816 *               char *Str : コマンドライン文字列\r
1817 *               char *Ini : iniファイル名を返すワーク\r
1818 *\r
1819 *       Return Value\r
1820 *               int ステータス\r
1821 *                       0=指定なし、1=あり\r
1822 *\r
1823 *       Note\r
1824 *               -n  --ini\r
1825 *----------------------------------------------------------------------------*/\r
1826 \r
1827 static int CheckIniFileName(char *Str, char *Ini)\r
1828 {\r
1829         return GetTokenAfterOption( Str, Ini, "n", "-ini" );\r
1830 }\r
1831 \r
1832 /* マスターパスワードの指定をチェック */\r
1833 static int CheckMasterPassword(char *Str, char *Ini)\r
1834 {\r
1835         return GetTokenAfterOption( Str, Ini, "z", "-mpasswd" );\r
1836 }\r
1837 \r
1838 /*----- オプションの後ろのトークンを取り出す ------------------------------------\r
1839 *\r
1840 *       Parameter\r
1841 *               char *Str : コマンドライン文字列\r
1842 *               char *Result : 取り出した文字列を格納するワーク\r
1843 *               const char* Opt1, *Opt2: オプション文字列(2つ)\r
1844 *\r
1845 *       Return Value\r
1846 *               int ステータス\r
1847 *                       0=指定なし、1=あり\r
1848 *\r
1849 *       Note\r
1850 *               2010.01.30 genta マスターパスワード取り出しのため共通化\r
1851 *----------------------------------------------------------------------------*/\r
1852 static int GetTokenAfterOption(char *Str, char *Result, const char* Opt1, const char* Opt2 )\r
1853 {\r
1854         int Ret = 0;\r
1855         char Tmp[FMAX_PATH+1];\r
1856 \r
1857         Result[0] = NUL;\r
1858         while((Str = GetToken(Str, Tmp)) != NULL)\r
1859         {\r
1860                 if(Tmp[0] == '-')\r
1861                 {\r
1862                         _strlwr(Tmp);\r
1863                         if((strcmp(&Tmp[1], Opt1) == 0) || (strcmp(&Tmp[1], Opt2) == 0))\r
1864                         {\r
1865                                 if((Str = GetToken(Str, Result)) != NULL)\r
1866                                         Ret = 1;\r
1867                                 break;\r
1868                         }\r
1869                 }\r
1870         }\r
1871         return(Ret);\r
1872 }\r
1873 \r
1874 /*----- トークンを返す --------------------------------------------------------\r
1875 *\r
1876 *       Parameter\r
1877 *               char *Str : 文字列\r
1878 *               char *Buf : 文字列を返すバッファ\r
1879 *\r
1880 *       Return Value\r
1881 *               char *返したトークンの末尾\r
1882 *                       NULL=終わり\r
1883 *----------------------------------------------------------------------------*/\r
1884 \r
1885 static char *GetToken(char *Str, char *Buf)\r
1886 {\r
1887         int InQuote;\r
1888 \r
1889         while(*Str != NUL)\r
1890         {\r
1891                 if((*Str != ' ') && (*Str != '\t'))\r
1892                         break;\r
1893                 Str++;\r
1894         }\r
1895 \r
1896         if(*Str != NUL)\r
1897         {\r
1898                 InQuote = 0;\r
1899                 while(*Str != NUL)\r
1900                 {\r
1901                         if(*Str == 0x22)\r
1902                                 InQuote = !InQuote;\r
1903                         else\r
1904                         {\r
1905                                 if(((*Str == ' ') || (*Str == '\t')) &&\r
1906                                    (InQuote == 0))\r
1907                                 {\r
1908                                         break;\r
1909                                 }\r
1910                                 *Buf++ = *Str;\r
1911                         }\r
1912                         Str++;\r
1913                 }\r
1914         }\r
1915         else\r
1916                 Str = NULL;\r
1917 \r
1918         *Buf = NUL;\r
1919 \r
1920         return(Str);\r
1921 }\r
1922 \r
1923 \r
1924 /*----- プログラム終了時の処理 ------------------------------------------------\r
1925 *\r
1926 *       Parameter\r
1927 *               HWND hWnd : ウインドウハンドル\r
1928 *\r
1929 *       Return Value\r
1930 *               なし\r
1931 *----------------------------------------------------------------------------*/\r
1932 \r
1933 static void ExitProc(HWND hWnd)\r
1934 {\r
1935         CancelFlg = YES;\r
1936 \r
1937         CloseTransferThread();\r
1938 \r
1939         if(SaveExit == YES)\r
1940         {\r
1941                 SaveBookMark();\r
1942                 SaveCurrentSetToHost();\r
1943         }\r
1944         DeleteAlltempFile();\r
1945 \r
1946 //      WSACancelBlockingCall();\r
1947         DisconnectProc();\r
1948 //      CloseTransferThread();\r
1949 \r
1950         if(SaveExit == YES)\r
1951         {\r
1952                 GetListTabWidth();\r
1953                 SaveRegistory();\r
1954 \r
1955                 if((CacheEntry > 0) && (CacheSave == YES))\r
1956                         SaveCache();\r
1957                 else\r
1958                         DeleteCache();\r
1959         }\r
1960         else\r
1961                 DeleteCache();\r
1962 \r
1963         if(RasClose == YES)\r
1964         {\r
1965                 DisconnectRas(RasCloseNotify);\r
1966         }\r
1967         DeleteAllObject();\r
1968         HtmlHelp(NULL, NULL, HH_UNINITIALIZE, dwCookie); \r
1969         return;\r
1970 }\r
1971 \r
1972 \r
1973 /*----- ファイル名をダブルクリックしたときの処理 ------------------------------\r
1974 *\r
1975 *       Parameter\r
1976 *               int Win : ウインドウ番号 (WIN_xxx)\r
1977 *               int Mode : 常に「開く」動作をするかどうか (YES/NO)\r
1978 *               int App : アプリケーション番号(-1=関連づけ優先)\r
1979 *\r
1980 *       Return Value\r
1981 *               なし\r
1982 *----------------------------------------------------------------------------*/\r
1983 \r
1984 void DoubleClickProc(int Win, int Mode, int App)\r
1985 {\r
1986         int Pos;\r
1987         int Type;\r
1988         char Local[FMAX_PATH+1];\r
1989         char Remote[FMAX_PATH+1];\r
1990         char Tmp[FMAX_PATH+1];\r
1991         int Sts;\r
1992         int UseDiffViewer;\r
1993 \r
1994         if(AskUserOpeDisabled() == NO)\r
1995         {\r
1996                 SetCurrentDirAsDirHist();\r
1997                 if(GetSelectedCount(Win) == 1)\r
1998                 {\r
1999                         if((Pos = GetFirstSelected(Win, NO)) != -1)\r
2000                         {\r
2001                                 GetNodeName(Win, Pos, Tmp, FMAX_PATH);\r
2002                                 Type = GetNodeType(Win, Pos);\r
2003 \r
2004                                 if(Win == WIN_LOCAL)\r
2005                                 {\r
2006                                         if((App != -1) || (Type == NODE_FILE))\r
2007                                         {\r
2008                                                 if((DclickOpen == YES) || (Mode == YES))\r
2009                                                 {\r
2010                                                         AskLocalCurDir(Local, FMAX_PATH);\r
2011                                                         ReplaceAll(Local, '/', '\\');\r
2012                                                         SetYenTail(Local);\r
2013                                                         strcat(Local, Tmp);\r
2014                                                         ExecViewer(Local, App);\r
2015                                                 }\r
2016                                                 else\r
2017                                                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_UPLOAD, 0), 0);\r
2018                                         }\r
2019                                         else\r
2020                                                 ChangeDir(WIN_LOCAL, Tmp);\r
2021                                 }\r
2022                                 else if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2023                                 {\r
2024                                         if((App != -1) || (Type == NODE_FILE))\r
2025                                         {\r
2026                                                 if((DclickOpen == YES) || (Mode == YES))\r
2027                                                 {\r
2028                                                         // ビューワ2、3のパスが "d " で始まっていたら差分ビューア使用\r
2029                                                         if ((App == 1 || App == 2) && strncmp(ViewerName[App], "d ", 2) == 0)\r
2030                                                                 UseDiffViewer = YES;\r
2031                                                         else\r
2032                                                                 UseDiffViewer = NO;\r
2033 \r
2034                                                         strcpy(Remote, TmpPath);\r
2035                                                         SetYenTail(Remote);\r
2036                                                         if (UseDiffViewer == YES) {\r
2037                                                                 strcat(Remote, "remote.");\r
2038                                                         }\r
2039                                                         strcat(Remote, Tmp);\r
2040 \r
2041                                                         if(AskTransferNow() == YES)\r
2042                                                                 SktShareProh();\r
2043 \r
2044         //                                              MainTransPkt.ctrl_skt = AskCmdCtrlSkt();\r
2045                                                         strcpy(MainTransPkt.Cmd, "RETR ");\r
2046                                                         if(AskHostType() == HTYPE_ACOS)\r
2047                                                         {\r
2048                                                                 strcpy(MainTransPkt.RemoteFile, "'");\r
2049                                                                 strcat(MainTransPkt.RemoteFile, AskHostLsName());\r
2050                                                                 strcat(MainTransPkt.RemoteFile, "(");\r
2051                                                                 strcat(MainTransPkt.RemoteFile, Tmp);\r
2052                                                                 strcat(MainTransPkt.RemoteFile, ")");\r
2053                                                                 strcat(MainTransPkt.RemoteFile, "'");\r
2054                                                         }\r
2055                                                         else if(AskHostType() == HTYPE_ACOS_4)\r
2056                                                         {\r
2057                                                                 strcpy(MainTransPkt.RemoteFile, Tmp);\r
2058                                                         }\r
2059                                                         else\r
2060                                                         {\r
2061                                                                 strcpy(MainTransPkt.RemoteFile, Tmp);\r
2062                                                         }\r
2063                                                         strcpy(MainTransPkt.LocalFile, Remote);\r
2064                                                         MainTransPkt.Type = AskTransferTypeAssoc(MainTransPkt.RemoteFile, AskTransferType());\r
2065                                                         MainTransPkt.Size = 1;\r
2066                                                         MainTransPkt.KanjiCode = AskHostKanjiCode();\r
2067                                                         MainTransPkt.KanjiCodeDesired = AskLocalKanjiCode();\r
2068                                                         MainTransPkt.KanaCnv = AskHostKanaCnv();\r
2069                                                         MainTransPkt.Mode = EXIST_OVW;\r
2070                                                         MainTransPkt.ExistSize = 0;\r
2071                                                         MainTransPkt.hWndTrans = NULL;\r
2072                                                         MainTransPkt.Next = NULL;\r
2073 \r
2074                                                         DisableUserOpe();\r
2075 \r
2076                                                         /* 不正なパスを検出 */\r
2077                                                         if(CheckPathViolation(&MainTransPkt) == NO)\r
2078                                                         {\r
2079 //                                                              if((Sts = DoDownLoad(AskCmdCtrlSkt(), &MainTransPkt, NO)) == 429)\r
2080 //                                                              {\r
2081 //                                                                      ReConnectCmdSkt();\r
2082                                                                         Sts = DoDownLoad(AskCmdCtrlSkt(), &MainTransPkt, NO, &CancelFlg);\r
2083 //                                                              }\r
2084                                                         }\r
2085 \r
2086                                                         EnableUserOpe();\r
2087 \r
2088                                                         AddTempFileList(Remote);\r
2089                                                         if(Sts/100 == FTP_COMPLETE) {\r
2090                                                                 if (UseDiffViewer == YES) {\r
2091                                                                         AskLocalCurDir(Local, FMAX_PATH);\r
2092                                                                         ReplaceAll(Local, '/', '\\');\r
2093                                                                         SetYenTail(Local);\r
2094                                                                         strcat(Local, Tmp);\r
2095                                                                         ExecViewer2(Local, Remote, App);\r
2096                                                                 } else {\r
2097                                                                         ExecViewer(Remote, App);\r
2098                                                                 }\r
2099                                                         }\r
2100                                                 }\r
2101                                                 else\r
2102                                                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_DOWNLOAD, 0), 0);\r
2103                                         }\r
2104                                         else\r
2105                                                 ChangeDir(WIN_REMOTE, Tmp);\r
2106                                 }\r
2107                         }\r
2108                 }\r
2109                 MakeButtonsFocus();\r
2110         }\r
2111         return;\r
2112 }\r
2113 \r
2114 \r
2115 /*----- フォルダの移動 --------------------------------------------------------\r
2116 *\r
2117 *       Parameter\r
2118 *               int Win : ウインドウ番号 (WIN_xxx)\r
2119 *               char *Path : 移動先のパス名\r
2120 *\r
2121 *       Return Value\r
2122 *               なし\r
2123 *\r
2124 *       Note\r
2125 *               フォルダ同時移動の処理も行う\r
2126 *----------------------------------------------------------------------------*/\r
2127 \r
2128 static void ChangeDir(int Win, char *Path)\r
2129 {\r
2130         int Sync;\r
2131         char Local[FMAX_PATH+1];\r
2132         char Remote[FMAX_PATH+1];\r
2133 \r
2134         Sync = AskSyncMoveMode();\r
2135         if(Sync == YES)\r
2136         {\r
2137                 if(strcmp(Path, "..") == 0)\r
2138                 {\r
2139                         AskLocalCurDir(Local, FMAX_PATH);\r
2140                         AskRemoteCurDir(Remote, FMAX_PATH);\r
2141                         if(strcmp(GetFileName(Local), GetFileName(Remote)) != 0)\r
2142                                 Sync = NO;\r
2143                 }\r
2144         }\r
2145 \r
2146         if((Win == WIN_LOCAL) || (Sync == YES))\r
2147         {\r
2148                 if(DoLocalCWD(Path) == FFFTP_SUCCESS)\r
2149                         GetLocalDirForWnd();\r
2150         }\r
2151 \r
2152         if((Win == WIN_REMOTE) || (Sync == YES))\r
2153         {\r
2154                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2155                 {\r
2156 #if defined(HAVE_OPENVMS)\r
2157                         /* OpenVMSの場合、".DIR;?"を取る */\r
2158                         if (AskHostType() == HTYPE_VMS)\r
2159                                 ReformVMSDirName(Path, TRUE);\r
2160 #endif\r
2161                         if(DoCWD(Path, YES, NO, YES) < FTP_RETRY)\r
2162                                 GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2163                 }\r
2164         }\r
2165         return;\r
2166 }\r
2167 \r
2168 \r
2169 /*----- ウインドウのサイズ変更の処理 ------------------------------------------\r
2170 *\r
2171 *       Parameter\r
2172 *               なし\r
2173 *\r
2174 *       Return Value\r
2175 *               なし\r
2176 *----------------------------------------------------------------------------*/\r
2177 \r
2178 static void ResizeWindowProc(void)\r
2179 {\r
2180 #if 0\r
2181         RECT Rect;\r
2182         int RemotePosX;\r
2183 \r
2184         GetClientRect(hWndFtp, &Rect);\r
2185         SendMessage(GetSbarWnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(Rect.right, Rect.bottom));\r
2186 \r
2187         CalcWinSize();\r
2188         SetWindowPos(GetMainTbarWnd(), 0, 0, 0, WinWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2189 \r
2190         SetWindowPos(GetLocalTbarWnd(), 0, 0, TOOLWIN_HEIGHT, LocalWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2191         SendMessage(GetLocalTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2192         SetWindowPos(GetLocalHistHwnd(), 0, Rect.right, Rect.top, LocalWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2193         SetWindowPos(GetLocalHwnd(), 0, 0, TOOLWIN_HEIGHT*2, LocalWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2194 \r
2195         RemotePosX = LocalWidth + SepaWidth;\r
2196         if(SplitVertical == YES)\r
2197                 RemotePosX = 0;\r
2198 \r
2199         SetWindowPos(GetRemoteTbarWnd(), 0, RemotePosX, TOOLWIN_HEIGHT, RemoteWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2200         SendMessage(GetRemoteTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2201         SetWindowPos(GetRemoteHistHwnd(), 0, Rect.right, Rect.top, RemoteWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2202         SetWindowPos(GetRemoteHwnd(), 0, RemotePosX, TOOLWIN_HEIGHT*2, RemoteWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2203 \r
2204         SetWindowPos(GetTaskWnd(), 0, 0, TOOLWIN_HEIGHT*2+ListHeight+SepaWidth, ClientWidth, TaskHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2205 #else\r
2206         RECT Rect;\r
2207 \r
2208         GetClientRect(hWndFtp, &Rect);\r
2209         SendMessage(GetSbarWnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(Rect.right, Rect.bottom));\r
2210 \r
2211         CalcWinSize();\r
2212         SetWindowPos(GetMainTbarWnd(), 0, 0, 0, Rect.right, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2213         SetWindowPos(GetLocalTbarWnd(), 0, 0, TOOLWIN_HEIGHT, LocalWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2214         SetWindowPos(GetRemoteTbarWnd(), 0, LocalWidth + SepaWidth, TOOLWIN_HEIGHT, RemoteWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2215         SendMessage(GetLocalTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2216         SetWindowPos(GetLocalHistHwnd(), 0, Rect.right, Rect.top, LocalWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2217         SendMessage(GetRemoteTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2218         SetWindowPos(GetRemoteHistHwnd(), 0, Rect.right, Rect.top, RemoteWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2219         SetWindowPos(GetLocalHwnd(), 0, 0, TOOLWIN_HEIGHT*2, LocalWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2220         SetWindowPos(GetRemoteHwnd(), 0, LocalWidth + SepaWidth, TOOLWIN_HEIGHT*2, RemoteWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2221         SetWindowPos(GetTaskWnd(), 0, 0, TOOLWIN_HEIGHT*2+ListHeight+SepaWidth, ClientWidth, TaskHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2222 #endif\r
2223 \r
2224         return;\r
2225 }\r
2226 \r
2227 \r
2228 /*----- ウインドウの各部分のサイズを計算する ----------------------------------\r
2229 *\r
2230 *       Parameter\r
2231 *               なし\r
2232 *\r
2233 *       Return Value\r
2234 *               なし\r
2235 *----------------------------------------------------------------------------*/\r
2236 \r
2237 static void CalcWinSize(void)\r
2238 {\r
2239         RECT Rect;\r
2240 \r
2241         GetWindowRect(hWndFtp, &Rect);\r
2242 \r
2243         if(Sizing != SW_MAXIMIZE)\r
2244         {\r
2245                 WinWidth = Rect.right - Rect.left;\r
2246                 WinHeight = Rect.bottom - Rect.top;\r
2247         }\r
2248 \r
2249         GetClientRect(hWndFtp, &Rect);\r
2250 \r
2251         ClientWidth = Rect.right;\r
2252         ClientHeight = Rect.bottom;\r
2253 \r
2254         SepaWidth = 4;\r
2255         LocalWidth = max1(0, min1(LocalWidth, ClientWidth - SepaWidth));\r
2256         RemoteWidth = max1(0, ClientWidth - LocalWidth - SepaWidth);\r
2257 //      TaskHeight = min1(TaskHeight, max1(0, ClientHeight - TOOLWIN_HEIGHT * 2 - SepaWidth));\r
2258 \r
2259         GetClientRect(GetSbarWnd(), &Rect);\r
2260 \r
2261         ListHeight = max1(0, ClientHeight - TOOLWIN_HEIGHT * 2 - TaskHeight - SepaWidth - Rect.bottom);\r
2262 \r
2263         return;\r
2264 }\r
2265 \r
2266 \r
2267 #if 0\r
2268 /*----- ウインドウの表示位置を取得する ----------------------------------------\r
2269 *\r
2270 *       Parameter\r
2271 *               HWND hWnd : ウインドウハンドル\r
2272 *\r
2273 *       Return Value\r
2274 *               なし\r
2275 *----------------------------------------------------------------------------*/\r
2276 \r
2277 static void AskWindowPos(HWND hWnd)\r
2278 {\r
2279         WINDOWPLACEMENT WinPlace;\r
2280 \r
2281         WinPlace.length = sizeof(WINDOWPLACEMENT);\r
2282         GetWindowPlacement(hWnd, &WinPlace);\r
2283         WinPosX = WinPlace.rcNormalPosition.left;\r
2284         WinPosY = WinPlace.rcNormalPosition.top;\r
2285 \r
2286         return;\r
2287 }\r
2288 #endif\r
2289 \r
2290 \r
2291 /*----- ディレクトリリストとファイルリストの境界変更処理 ----------------------\r
2292 *\r
2293 *       Parameter\r
2294 *               WPARAM Keys : WM_MOUSEMOVEなどのWPARAMの値\r
2295 *               int x : マウスカーソルのX座標\r
2296 *               int y : マウスカーソルのY座標\r
2297 *\r
2298 *       Return Value\r
2299 *               なし\r
2300 *----------------------------------------------------------------------------*/\r
2301 \r
2302 static void CheckResizeFrame(WPARAM Keys, int x, int y)\r
2303 {\r
2304         RECT Rect;\r
2305         RECT Rect1;\r
2306 \r
2307         if((Resizing == RESIZE_OFF) && (Keys == 0))\r
2308         {\r
2309                 if((x >= LocalWidth) && (x <= LocalWidth + SepaWidth) &&\r
2310                    (y > TOOLWIN_HEIGHT) && (y < (TOOLWIN_HEIGHT * 2 + ListHeight)))\r
2311                 {\r
2312                         /* 境界位置変更用カーソルに変更 */\r
2313                         SetCapture(hWndFtp);\r
2314                         hCursor = LoadCursor(hInstFtp, MAKEINTRESOURCE(resize_lr_csr));\r
2315                         SetCursor(hCursor);\r
2316                         Resizing = RESIZE_PREPARE;\r
2317                         ResizePos = RESIZE_HPOS;\r
2318                 }\r
2319                 else if((y >= TOOLWIN_HEIGHT*2+ListHeight) && (y <= TOOLWIN_HEIGHT*2+ListHeight+SepaWidth))\r
2320                 {\r
2321                         /* 境界位置変更用カーソルに変更 */\r
2322                         SetCapture(hWndFtp);\r
2323                         hCursor = LoadCursor(hInstFtp, MAKEINTRESOURCE(resize_ud_csr));\r
2324                         SetCursor(hCursor);\r
2325                         Resizing = RESIZE_PREPARE;\r
2326                         ResizePos = RESIZE_VPOS;\r
2327                 }\r
2328         }\r
2329         else if(Resizing == RESIZE_PREPARE)\r
2330         {\r
2331                 if(Keys & MK_LBUTTON)\r
2332                 {\r
2333                         /* 境界位置変更開始 */\r
2334                         Resizing = RESIZE_ON;\r
2335                         GetWindowRect(hWndFtp, &Rect);\r
2336                         GetClientRect(GetSbarWnd(), &Rect1);\r
2337                         Rect.left += GetSystemMetrics(SM_CXFRAME);\r
2338                         Rect.right -= GetSystemMetrics(SM_CXFRAME);\r
2339                         Rect.top += TOOLWIN_HEIGHT*2 + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);\r
2340                         Rect.bottom -= GetSystemMetrics(SM_CYFRAME) + Rect1.bottom;\r
2341                         ClipCursor(&Rect);\r
2342                 }\r
2343                 else\r
2344                 {\r
2345                         if(((ResizePos == RESIZE_HPOS) &&\r
2346                                 ((x < LocalWidth) || (x > LocalWidth + SepaWidth) ||\r
2347                                  (y <= TOOLWIN_HEIGHT) || (y >= (TOOLWIN_HEIGHT * 2 + ListHeight)))) ||\r
2348                            ((ResizePos == RESIZE_VPOS) &&\r
2349                                 ((y < TOOLWIN_HEIGHT*2+ListHeight) || (y > TOOLWIN_HEIGHT*2+ListHeight+SepaWidth))))\r
2350                         {\r
2351                                 /* 元のカーソルに戻す */\r
2352                                 ReleaseCapture();\r
2353                                 hCursor = LoadCursor(NULL, IDC_ARROW);\r
2354                                 SetCursor(hCursor);\r
2355                                 Resizing = RESIZE_OFF;\r
2356                         }\r
2357                 }\r
2358         }\r
2359         else if(Resizing == RESIZE_ON)\r
2360         {\r
2361                 if(ResizePos == RESIZE_HPOS)\r
2362                         LocalWidth = x;\r
2363                 else\r
2364                 {\r
2365                         GetClientRect(hWndFtp, &Rect);\r
2366                         GetClientRect(GetSbarWnd(), &Rect1);\r
2367                         TaskHeight = max1(0, Rect.bottom - y - Rect1.bottom);\r
2368                 }\r
2369                 ResizeWindowProc();\r
2370 \r
2371                 if((Keys & MK_LBUTTON) == 0)\r
2372                 {\r
2373                         /* 境界位置変更終了 */\r
2374                         ReleaseCapture();\r
2375                         ClipCursor(NULL);\r
2376                         hCursor = LoadCursor(NULL, IDC_ARROW);\r
2377                         SetCursor(hCursor);\r
2378                         Resizing = RESIZE_OFF;\r
2379                 }\r
2380         }\r
2381         return;\r
2382 }\r
2383 \r
2384 \r
2385 /*----- ファイル一覧情報をビューワで表示 --------------------------------------\r
2386 *\r
2387 *       Parameter\r
2388 *               なし\r
2389 *\r
2390 *       Return Value\r
2391 *               なし\r
2392 *----------------------------------------------------------------------------*/\r
2393 \r
2394 static void DispDirInfo(void)\r
2395 {\r
2396         char Buf[FMAX_PATH+1];\r
2397 \r
2398         MakeCacheFileName(AskCurrentFileListNum(), Buf);\r
2399         ExecViewer(Buf, 0);\r
2400         return;\r
2401 }\r
2402 \r
2403 \r
2404 \r
2405 /*----- ビューワを起動 --------------------------------------------------------\r
2406 *\r
2407 *       Parameter\r
2408 *               char Fname : ファイル名\r
2409 *               int App : アプリケーション番号(-1=関連づけ優先)\r
2410 *\r
2411 *       Return Value\r
2412 *               なし\r
2413 *----------------------------------------------------------------------------*/\r
2414 \r
2415 void ExecViewer(char *Fname, int App)\r
2416 {\r
2417         PROCESS_INFORMATION Info;\r
2418         STARTUPINFO Startup;\r
2419         char AssocProg[FMAX_PATH+1];\r
2420         char ComLine[FMAX_PATH*2+3+1];\r
2421         char CurDir[FMAX_PATH+1];\r
2422 \r
2423         /* FindExecutable()は関連付けられたプログラムのパス名にスペースが        */\r
2424         /* 含まれている時、間違ったパス名を返す事がある。                                        */\r
2425         /* そこで、関連付けられたプログラムの起動はShellExecute()を使う。       */\r
2426 \r
2427         AskLocalCurDir(CurDir, FMAX_PATH);\r
2428 \r
2429         if((App == -1) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32))\r
2430         {\r
2431                 DoPrintf("ShellExecute - %s", Fname);\r
2432                 ShellExecute(NULL, "open", Fname, NULL, CurDir, SW_SHOW);\r
2433         }\r
2434         else\r
2435         {\r
2436                 App = max1(0, App);\r
2437                 strcpy(AssocProg, ViewerName[App]);\r
2438 \r
2439                 if(strchr(Fname, ' ') == NULL)\r
2440                         sprintf(ComLine, "%s %s", AssocProg, Fname);\r
2441                 else\r
2442                         sprintf(ComLine, "%s \"%s\"", AssocProg, Fname);\r
2443 \r
2444                 DoPrintf("FindExecutable - %s", ComLine);\r
2445 \r
2446                 memset(&Startup, NUL, sizeof(STARTUPINFO));\r
2447                 Startup.cb = sizeof(STARTUPINFO);\r
2448                 Startup.wShowWindow = SW_SHOW;\r
2449                 if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
2450                 {\r
2451                         SetTaskMsg(MSGJPN182, GetLastError());\r
2452                         SetTaskMsg(">>%s", ComLine);\r
2453                 }\r
2454         }\r
2455         return;\r
2456 }\r
2457 \r
2458 \r
2459 /*----- 差分表示ビューワを起動 ------------------------------------------------\r
2460 *\r
2461 *       Parameter\r
2462 *               char Fname1 : ファイル名\r
2463 *               char Fname2 : ファイル名2\r
2464 *               int App : アプリケーション番号(2 or 3)\r
2465 *\r
2466 *       Return Value\r
2467 *               なし\r
2468 *----------------------------------------------------------------------------*/\r
2469 \r
2470 void ExecViewer2(char *Fname1, char *Fname2, int App)\r
2471 {\r
2472         PROCESS_INFORMATION Info;\r
2473         STARTUPINFO Startup;\r
2474         char AssocProg[FMAX_PATH+1];\r
2475         char ComLine[FMAX_PATH*2+3+1];\r
2476         char CurDir[FMAX_PATH+1];\r
2477 \r
2478         /* FindExecutable()は関連付けられたプログラムのパス名にスペースが        */\r
2479         /* 含まれている時、間違ったパス名を返す事がある。                                        */\r
2480         /* そこで、関連付けられたプログラムの起動はShellExecute()を使う。       */\r
2481 \r
2482         AskLocalCurDir(CurDir, FMAX_PATH);\r
2483 \r
2484         strcpy(AssocProg, ViewerName[App] + 2); /* 先頭の "d " は読み飛ばす */\r
2485 \r
2486         if(strchr(Fname1, ' ') == NULL && strchr(Fname2, ' ') == NULL)\r
2487                 sprintf(ComLine, "%s %s %s", AssocProg, Fname1, Fname2);\r
2488         else\r
2489                 sprintf(ComLine, "%s \"%s\" \"%s\"", AssocProg, Fname1, Fname2);\r
2490 \r
2491         DoPrintf("FindExecutable - %s", ComLine);\r
2492 \r
2493         memset(&Startup, NUL, sizeof(STARTUPINFO));\r
2494         Startup.cb = sizeof(STARTUPINFO);\r
2495         Startup.wShowWindow = SW_SHOW;\r
2496         if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
2497         {\r
2498                 SetTaskMsg(MSGJPN182, GetLastError());\r
2499                 SetTaskMsg(">>%s", ComLine);\r
2500         }\r
2501 \r
2502         return;\r
2503 }\r
2504 \r
2505 \r
2506 /*----- テンポラリファイル名をテンポラリファイルリストに追加 ------------------\r
2507 *\r
2508 *       Parameter\r
2509 *               char *Fname : テンポラリファイル名\r
2510 *\r
2511 *       Return Value\r
2512 *               なし\r
2513 *----------------------------------------------------------------------------*/\r
2514 \r
2515 void AddTempFileList(char *Fname)\r
2516 {\r
2517         TEMPFILELIST *New;\r
2518 \r
2519         if((New = malloc(sizeof(TEMPFILELIST))) != NULL)\r
2520         {\r
2521                 if((New->Fname = malloc(strlen(Fname)+1)) != NULL)\r
2522                 {\r
2523                         strcpy(New->Fname, Fname);\r
2524                         if(TempFiles == NULL)\r
2525                                 New->Next = NULL;\r
2526                         else\r
2527                                 New->Next = TempFiles;\r
2528                         TempFiles = New;\r
2529                 }\r
2530                 else\r
2531                         free(New);\r
2532         }\r
2533         return;\r
2534 }\r
2535 \r
2536 \r
2537 /*----- テンポラリファイルリストに登録されているファイルを全て削除 ------------\r
2538 *\r
2539 *       Parameter\r
2540 *               なし\r
2541 *\r
2542 *       Return Value\r
2543 *               なし\r
2544 *----------------------------------------------------------------------------*/\r
2545 \r
2546 static void DeleteAlltempFile(void)\r
2547 {\r
2548         TEMPFILELIST *Pos;\r
2549         TEMPFILELIST *Next;\r
2550 \r
2551         Pos = TempFiles;\r
2552         while(Pos != NULL)\r
2553         {\r
2554                 DeleteFile(Pos->Fname);\r
2555 \r
2556                 Next = Pos->Next;\r
2557                 free(Pos->Fname);\r
2558                 free(Pos);\r
2559                 Pos = Next;\r
2560         }\r
2561 \r
2562         // OLE D&Dのテンポラリを削除する (2007.9.11 yutaka)\r
2563         doDeleteRemoteFile();\r
2564 \r
2565         return;\r
2566 }\r
2567 \r
2568 \r
2569 /*----- Aboutダイアログボックスのコールバック関数 ------------------------\r
2570 *\r
2571 *       Parameter\r
2572 *               HWND hDlg : ウインドウハンドル\r
2573 *               UINT message : メッセージ番号\r
2574 *               WPARAM wParam : メッセージの WPARAM 引数\r
2575 *               LPARAM lParam : メッセージの LPARAM 引数\r
2576 *\r
2577 *       Return Value\r
2578 *               BOOL TRUE/FALSE\r
2579 *----------------------------------------------------------------------------*/\r
2580 \r
2581 static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
2582 {\r
2583         static char Tmp[80];\r
2584         int Ver;\r
2585 \r
2586         switch (message)\r
2587         {\r
2588                 case WM_INITDIALOG :\r
2589                         Ver = GetJreVersion();\r
2590                         if(Ver == -1)\r
2591                                 sprintf(Tmp, MSGJPN183);\r
2592                         else\r
2593                                 sprintf(Tmp, MSGJPN184, Ver / 0x100, Ver % 0x100);\r
2594                         SendDlgItemMessage(hDlg, ABOUT_JRE, WM_SETTEXT, 0, (LPARAM)Tmp);\r
2595                         SendDlgItemMessage(hDlg, ABOUT_URL, EM_LIMITTEXT, 256, 0);\r
2596                         SendDlgItemMessage(hDlg, ABOUT_URL, WM_SETTEXT, 0, (LPARAM)MSGJPN284);\r
2597                         return(TRUE);\r
2598 \r
2599                 case WM_COMMAND :\r
2600                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2601                         {\r
2602                                 case IDOK :\r
2603                                 case IDCANCEL :\r
2604                                         EndDialog(hDlg, YES);\r
2605                                         break;\r
2606                         }\r
2607                         return(TRUE);\r
2608         }\r
2609     return(FALSE);\r
2610 }\r
2611 \r
2612 \r
2613 /*----- サウンドを鳴らす ------------------------------------------------------\r
2614 *\r
2615 *       Parameter\r
2616 *               Int num : サウンドの種類 (SND_xxx)\r
2617 *\r
2618 *       Return Value\r
2619 *               なし\r
2620 *----------------------------------------------------------------------------*/\r
2621 \r
2622 void SoundPlay(int Num)\r
2623 {\r
2624         if(Sound[Num].On == YES)\r
2625                 sndPlaySound(Sound[Num].Fname, SND_ASYNC | SND_NODEFAULT);\r
2626 \r
2627         return;\r
2628 }\r
2629 \r
2630 \r
2631 /*----- ヘルプファイルのパス名を返す ------------------------------------------\r
2632 *\r
2633 *       Parameter\r
2634 *               なし\r
2635 *\r
2636 *       Return Value\r
2637 *               char *パス名\r
2638 *----------------------------------------------------------------------------*/\r
2639 \r
2640 char *AskHelpFilePath(void)\r
2641 {\r
2642         return(HelpPath);\r
2643 }\r
2644 \r
2645 \r
2646 /*----- テンポラリファイルのパス名を返す --------------------------------------\r
2647 *\r
2648 *       Parameter\r
2649 *               なし\r
2650 *\r
2651 *       Return Value\r
2652 *               char *パス名\r
2653 *----------------------------------------------------------------------------*/\r
2654 \r
2655 char *AskTmpFilePath(void)\r
2656 {\r
2657         return(TmpPath);\r
2658 }\r
2659 \r
2660 \r
2661 /*----- INIファイルのパス名を返す ---------------------------------------------\r
2662 *\r
2663 *       Parameter\r
2664 *               なし\r
2665 *\r
2666 *       Return Value\r
2667 *               char *パス名\r
2668 *----------------------------------------------------------------------------*/\r
2669 \r
2670 char *AskIniFilePath(void)\r
2671 {\r
2672         return(IniPath);\r
2673 }\r
2674 \r
2675 /*----- INIファイルのみを使うかどうかを返す -----------------------------------\r
2676 *\r
2677 *       Parameter\r
2678 *               なし\r
2679 *\r
2680 *       Return Value\r
2681 *               int ステータス : YES/NO\r
2682 *----------------------------------------------------------------------------*/\r
2683 \r
2684 int AskForceIni(void)\r
2685 {\r
2686         return(ForceIni);\r
2687 }\r
2688 \r
2689 \r
2690 \r
2691 \r
2692 /*----- メッセージ処理 --------------------------------------------------------\r
2693 *\r
2694 *       Parameter\r
2695 *               なし\r
2696 *\r
2697 *       Return Value\r
2698 *               int 終了フラグ (YES=WM_CLOSEが来た/NO)\r
2699 *----------------------------------------------------------------------------*/\r
2700 \r
2701 int BackgrndMessageProc(void)\r
2702 {\r
2703     MSG Msg;\r
2704         int Ret;\r
2705 \r
2706         Ret = NO;\r
2707         while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))\r
2708         {\r
2709                 if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))\r
2710                 {\r
2711                         /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */\r
2712                         /* コンボボックス内ではアクセラレータを無効にする */\r
2713                         if((Msg.hwnd == GetLocalHistEditHwnd()) ||\r
2714                            (Msg.hwnd == GetRemoteHistEditHwnd()) ||\r
2715                            ((hHelpWin != NULL) && (Msg.hwnd == hHelpWin)) ||\r
2716                            GetHideUI() == YES ||\r
2717                            (TranslateAccelerator(GetMainHwnd(), Accel, &Msg) == 0))\r
2718                         {\r
2719                                 if(Msg.message == WM_QUIT)\r
2720                                 {\r
2721                                         Ret = YES;\r
2722                                         PostQuitMessage(0);\r
2723                                         break;\r
2724                                 }\r
2725                                 TranslateMessage(&Msg);\r
2726                                 DispatchMessage(&Msg);\r
2727                         }\r
2728                 }\r
2729         }\r
2730         return(Ret);\r
2731 }\r
2732 \r
2733 \r
2734 /*----- 自動終了フラグをクリアする --------------------------------------------\r
2735 *\r
2736 *       Parameter\r
2737 *               なし\r
2738 *\r
2739 *       Return Value\r
2740 *               なし\r
2741 *----------------------------------------------------------------------------*/\r
2742 \r
2743 void ResetAutoExitFlg(void)\r
2744 {\r
2745         AutoExit = NO;\r
2746         return;\r
2747 }\r
2748 \r
2749 \r
2750 /*----- 自動終了フラグを返す --------------------------------------------------\r
2751 *\r
2752 *       Parameter\r
2753 *               なし\r
2754 *\r
2755 *       Return Value\r
2756 *               int フラグ (YES/NO)\r
2757 *----------------------------------------------------------------------------*/\r
2758 \r
2759 int AskAutoExit(void)\r
2760 {\r
2761         return(AutoExit);\r
2762 }\r
2763 \r
2764 /*----- ユーザにパスワードを入力させ,それを設定する -----------------------\r
2765 *\r
2766 *       Parameter\r
2767 *               なし\r
2768 *\r
2769 *       Return Value\r
2770 *               int : 0/ユーザキャンセル, 1/設定した, 2/デフォルト設定\r
2771 *----------------------------------------------------------------------------*/\r
2772 int EnterMasterPasswordAndSet( int Res, HWND hWnd )\r
2773 {\r
2774         char buf[MAX_PASSWORD_LEN + 1];\r
2775         // パスワードの入力欄を非表示\r
2776         // 非表示にしたため新しいパスワードを2回入力させる\r
2777         char buf1[MAX_PASSWORD_LEN + 1];\r
2778         char *p;\r
2779         int Flag;\r
2780 \r
2781         buf[0] = NUL;\r
2782         if( InputDialogBox(Res, hWnd, NULL, buf, MAX_PASSWORD_LEN + 1,\r
2783                 &Flag, IDH_HELP_TOPIC_0000064) == YES){\r
2784                 // パスワードの入力欄を非表示\r
2785                 if(Res == newmasterpasswd_dlg)\r
2786                 {\r
2787                         buf1[0] = NUL;\r
2788                         if( InputDialogBox(Res, hWnd, NULL, buf1, MAX_PASSWORD_LEN + 1,\r
2789                                 &Flag, IDH_HELP_TOPIC_0000064) != YES){\r
2790                                 return 0;\r
2791                         }\r
2792                         if(strcmp(buf, buf1) != 0)\r
2793                         {\r
2794                                 MessageBox(hWnd, MSGJPN325, "FFFTP", MB_OK | MB_ICONERROR);\r
2795                                 return 0;\r
2796                         }\r
2797                 }\r
2798                 /* 末尾の空白を削除 */\r
2799                 RemoveTailingSpaces(buf);\r
2800                 /* 先頭の空白を削除 */\r
2801                 for( p = buf; *p == ' '; p++ )\r
2802                         ;\r
2803                 \r
2804                 if( p[0] != NUL ){\r
2805                         SetMasterPassword( p );\r
2806                         return 1;\r
2807                 }\r
2808                 else {\r
2809                         /* 空の場合はデフォルト値を設定 */\r
2810                         SetMasterPassword( NULL );\r
2811                         return 2;\r
2812                 }\r
2813         }\r
2814         return 0;\r
2815 }\r
2816 \r
2817 // 暗号化通信対応\r
2818 BOOL __stdcall SSLTimeoutCallback()\r
2819 {\r
2820         Sleep(1);\r
2821         if(BackgrndMessageProc() == YES)\r
2822                 return TRUE;\r
2823         // 念のためツールバーのMENU_ABORTも確認\r
2824 //      if(MainTransPkt.Abort != ABORT_NONE)\r
2825 //      {\r
2826 //              MainTransPkt.Abort = ABORT_NONE;\r
2827 //              return TRUE;