OSDN Git Service

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