OSDN Git Service

Convert source codes' encoding to UTF-8.
[ffftp/ffftp.git] / ftpproc.c
1 /*=============================================================================\r
2 *\r
3 *                                                               FTPコマンド操作\r
4 *\r
5 ===============================================================================\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.\r
7 /\r
8 / Redistribution and use in source and binary forms, with or without \r
9 / modification, are permitted provided that the following conditions \r
10 / are met:\r
11 /\r
12 /  1. Redistributions of source code must retain the above copyright \r
13 /     notice, this list of conditions and the following disclaimer.\r
14 /  2. Redistributions in binary form must reproduce the above copyright \r
15 /     notice, this list of conditions and the following disclaimer in the \r
16 /     documentation and/or other materials provided with the distribution.\r
17 /\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR \r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES \r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, \r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF \r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
28 /============================================================================*/\r
29 \r
30 #define  STRICT\r
31 #include <windows.h>\r
32 #include <stdio.h>\r
33 #include <stdlib.h>\r
34 #include <string.h>\r
35 #include <mbstring.h>\r
36 #include <windowsx.h>\r
37 #include <commctrl.h>\r
38 \r
39 #include "common.h"\r
40 #include "resource.h"\r
41 \r
42 #include <htmlhelp.h>\r
43 #include "helpid.h"\r
44 \r
45 // UTF-8対応\r
46 #undef __MBSWRAPPER_H__\r
47 #include "mbswrapper.h"\r
48 \r
49 \r
50 /*===== プロトタイプ =====*/\r
51 \r
52 static int CheckRemoteFile(TRANSPACKET *Pkt, FILELIST *ListList);\r
53 static BOOL CALLBACK UpExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
54 \r
55 static void DispMirrorFiles(FILELIST *Local, FILELIST *Remote);\r
56 static void MirrorDeleteAllLocalDir(FILELIST *Local, TRANSPACKET *Pkt, TRANSPACKET **Base);\r
57 static int CheckLocalFile(TRANSPACKET *Pkt);\r
58 static BOOL CALLBACK DownExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
59 static void RemoveAfterSemicolon(char *Path);\r
60 static void MirrorDeleteAllDir(FILELIST *Remote, TRANSPACKET *Pkt, TRANSPACKET **Base);\r
61 static BOOL CALLBACK MirrorNotifyCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
62 static BOOL CALLBACK MirrorDispListCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
63 static void CountMirrorFiles(HWND hDlg, TRANSPACKET *Pkt);\r
64 static int AskMirrorNoTrn(char *Fname, int Mode);\r
65 static int AskUpLoadFileAttr(char *Fname);\r
66 static BOOL CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
67 static void DeleteAllDir(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir);\r
68 static void DelNotifyAndDo(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir);\r
69 static BOOL CALLBACK DeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
70 static BOOL CALLBACK RenameDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
71 static void SetAttrToDialog(HWND hWnd, int Attr);\r
72 static int GetAttrFromDialog(HWND hDlg);\r
73 static LRESULT CALLBACK SizeNotifyDlgWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
74 static LRESULT CALLBACK SizeDlgWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
75 static int RenameUnuseableName(char *Fname);\r
76 \r
77 /*===== 外部参照 ====*/\r
78 \r
79 extern HWND hHelpWin;\r
80 \r
81 /* 設定値 */\r
82 extern int FnameCnv;\r
83 extern int RecvMode;\r
84 extern int SendMode;\r
85 extern int MoveMode;\r
86 extern char MirrorNoTrn[MIRROR_LEN+1];\r
87 extern char MirrorNoDel[MIRROR_LEN+1];\r
88 extern int MirrorFnameCnv;\r
89 extern char DefAttrList[DEFATTRLIST_LEN+1];\r
90 extern SIZE MirrorDlgSize;\r
91 extern int VaxSemicolon;\r
92 extern int DebugConsole;\r
93 extern int CancelFlg;\r
94 \r
95 /*===== ローカルなワーク =====*/\r
96 \r
97 static char TmpString[FMAX_PATH+80];            /* テンポラリ */\r
98 static int CurWin;                                              /* ウインドウ番号 */\r
99 \r
100 int UpExistMode = EXIST_OVW;            /* アップロードで同じ名前のファイルがある時の扱い方 EXIST_xxx */\r
101 int ExistMode = EXIST_OVW;              /* 同じ名前のファイルがある時の扱い方 EXIST_xxx */\r
102 static int ExistNotify;         /* 確認ダイアログを出すかどうか YES/NO */\r
103 \r
104 static double FileSize;         /* ファイル総容量 */\r
105 \r
106 \r
107 \r
108 /*----- ファイル一覧で指定されたファイルをダウンロードする --------------------\r
109 *\r
110 *       Parameter\r
111 *               int ChName : 名前を変えるかどうか (YES/NO)\r
112 *               int ForceFile : ディレクトリをファイル見なすかどうか (YES/NO)\r
113 *               int All : 全てが選ばれている物として扱うかどうか (YES/NO)\r
114 *\r
115 *       Return Value\r
116 *               なし\r
117 *----------------------------------------------------------------------------*/\r
118 \r
119 void DownLoadProc(int ChName, int ForceFile, int All)\r
120 {\r
121         FILELIST *FileListBase;\r
122         FILELIST *Pos;\r
123         TRANSPACKET Pkt;\r
124 \r
125         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
126         {\r
127                 DisableUserOpe();\r
128 \r
129                 ExistNotify = YES;\r
130 //              KeepTransferDialog(YES);\r
131 \r
132                 FileListBase = NULL;\r
133                 MakeSelectedFileList(WIN_REMOTE, (ForceFile == YES ? NO : YES), All, &FileListBase, &CancelFlg);\r
134 \r
135                 if(AskNoFullPathMode() == YES)\r
136                 {\r
137                         strcpy(Pkt.Cmd, "SETCUR");\r
138                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
139                         AddTransFileList(&Pkt);\r
140                 }\r
141 \r
142                 Pos = FileListBase;\r
143                 while(Pos != NULL)\r
144                 {\r
145                         AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
146                         SetYenTail(Pkt.LocalFile);\r
147                         strcpy(TmpString, Pos->File);\r
148                         if((ChName == NO) || ((ForceFile == NO) && (Pos->Node == NODE_DIR)))\r
149                         {\r
150                                 if(FnameCnv == FNAME_LOWER)\r
151                                         _mbslwr(TmpString);\r
152                                 else if(FnameCnv == FNAME_UPPER)\r
153                                         _mbsupr(TmpString);\r
154                                 RemoveAfterSemicolon(TmpString);\r
155                                 if(RenameUnuseableName(TmpString) == FFFTP_FAIL)\r
156                                         break;\r
157                         }\r
158                         else\r
159                         {\r
160                                 CurWin = WIN_REMOTE;\r
161                                 if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(updown_as_dlg), GetMainHwnd(), UpDownAsDialogCallBack) == YES)\r
162                                 {\r
163                                         if(RenameUnuseableName(TmpString) == FFFTP_FAIL)\r
164                                                 break;\r
165                                 }\r
166                                 else\r
167                                         break;\r
168                         }\r
169                         strcat(Pkt.LocalFile, TmpString);\r
170                         ReplaceAll(Pkt.LocalFile, '/', '\\');\r
171 \r
172                         if((ForceFile == NO) && (Pos->Node == NODE_DIR))\r
173                         {\r
174                                 strcpy(Pkt.Cmd, "MKD ");\r
175                                 strcpy(Pkt.RemoteFile, "");\r
176                                 AddTransFileList(&Pkt);\r
177                         }\r
178                         else if((Pos->Node == NODE_FILE) ||\r
179                                         ((ForceFile == YES) && (Pos->Node == NODE_DIR)))\r
180                         {\r
181                                 if(AskHostType() == HTYPE_ACOS)\r
182                                 {\r
183                                         strcpy(Pkt.RemoteFile, "'");\r
184                                         strcat(Pkt.RemoteFile, AskHostLsName());\r
185                                         strcat(Pkt.RemoteFile, "(");\r
186                                         strcat(Pkt.RemoteFile, Pos->File);\r
187                                         strcat(Pkt.RemoteFile, ")");\r
188                                         strcat(Pkt.RemoteFile, "'");\r
189                                 }\r
190                                 else if(AskHostType() == HTYPE_ACOS_4)\r
191                                 {\r
192                                         strcpy(Pkt.RemoteFile, Pos->File);\r
193                                 }\r
194                                 else\r
195                                 {\r
196                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
197                                         SetSlashTail(Pkt.RemoteFile);\r
198                                         strcat(Pkt.RemoteFile, Pos->File);\r
199                                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
200                                 }\r
201 \r
202                                 strcpy(Pkt.Cmd, "RETR ");\r
203                                 Pkt.Type = AskTransferTypeAssoc(Pkt.RemoteFile, AskTransferType());\r
204                                 Pkt.Size = Pos->Size;\r
205                                 Pkt.Time = Pos->Time;\r
206                                 Pkt.KanjiCode = AskHostKanjiCode();\r
207                                 // UTF-8対応\r
208                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
209                                 Pkt.KanaCnv = AskHostKanaCnv();\r
210 \r
211                                 Pkt.Mode = CheckLocalFile(&Pkt);        /* Pkt.ExistSize がセットされる */\r
212                                 if(Pkt.Mode == EXIST_ABORT)\r
213                                         break;\r
214                                 else if(Pkt.Mode != EXIST_IGNORE)\r
215                                         AddTransFileList(&Pkt);\r
216                         }\r
217                         Pos = Pos->Next;\r
218                 }\r
219 \r
220                 if(AskNoFullPathMode() == YES)\r
221                 {\r
222                         strcpy(Pkt.Cmd, "BACKCUR");\r
223                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
224                         AddTransFileList(&Pkt);\r
225                 }\r
226                 DeleteFileList(&FileListBase);\r
227 \r
228                 strcpy(Pkt.Cmd, "GOQUIT");\r
229                 AddTransFileList(&Pkt);\r
230 \r
231                 GoForwardTransWindow();\r
232 //              KeepTransferDialog(NO);\r
233 \r
234                 EnableUserOpe();\r
235         }\r
236         return;\r
237 }\r
238 \r
239 \r
240 /*----- 指定されたファイルを一つダウンロードする ------------------------------\r
241 *\r
242 *       Parameter\r
243 *               char *Fname : ファイル名\r
244 *\r
245 *       Return Value\r
246 *               なし\r
247 *----------------------------------------------------------------------------*/\r
248 \r
249 void DirectDownLoadProc(char *Fname)\r
250 {\r
251         TRANSPACKET Pkt;\r
252 \r
253         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
254         {\r
255                 DisableUserOpe();\r
256 \r
257                 ExistNotify = YES;\r
258 //              KeepTransferDialog(YES);\r
259 \r
260                 if(AskNoFullPathMode() == YES)\r
261                 {\r
262                         strcpy(Pkt.Cmd, "SETCUR");\r
263                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
264                         AddTransFileList(&Pkt);\r
265                 }\r
266 \r
267                 if(strlen(Fname) > 0)\r
268                 {\r
269                         AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
270                         SetYenTail(Pkt.LocalFile);\r
271                         strcpy(TmpString, Fname);\r
272                         if(FnameCnv == FNAME_LOWER)\r
273                                 _mbslwr(TmpString);\r
274                         else if(FnameCnv == FNAME_UPPER)\r
275                                 _mbsupr(TmpString);\r
276                         RemoveAfterSemicolon(TmpString);\r
277 \r
278                         if(RenameUnuseableName(TmpString) == FFFTP_SUCCESS)\r
279                         {\r
280                                 strcat(Pkt.LocalFile, TmpString);\r
281                                 ReplaceAll(Pkt.LocalFile, '/', '\\');\r
282 \r
283                                 if(AskHostType() == HTYPE_ACOS)\r
284                                 {\r
285                                         strcpy(Pkt.RemoteFile, "'");\r
286                                         strcat(Pkt.RemoteFile, AskHostLsName());\r
287                                         strcat(Pkt.RemoteFile, "(");\r
288                                         strcat(Pkt.RemoteFile, Fname);\r
289                                         strcat(Pkt.RemoteFile, ")");\r
290                                         strcat(Pkt.RemoteFile, "'");\r
291                                 }\r
292                                 else if(AskHostType() == HTYPE_ACOS_4)\r
293                                 {\r
294                                         strcpy(Pkt.RemoteFile, Fname);\r
295                                 }\r
296                                 else\r
297                                 {\r
298                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
299                                         SetSlashTail(Pkt.RemoteFile);\r
300                                         strcat(Pkt.RemoteFile, Fname);\r
301                                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
302                                 }\r
303 \r
304                                 strcpy(Pkt.Cmd, "RETR-S ");\r
305                                 Pkt.Type = AskTransferTypeAssoc(Pkt.RemoteFile, AskTransferType());\r
306 \r
307                                 /* サイズと日付は転送側スレッドで取得し、セットする */\r
308 \r
309                                 Pkt.KanjiCode = AskHostKanjiCode();\r
310                                 // UTF-8対応\r
311                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
312                                 Pkt.KanaCnv = AskHostKanaCnv();\r
313 \r
314                                 Pkt.Mode = CheckLocalFile(&Pkt);        /* Pkt.ExistSize がセットされる */\r
315                                 if((Pkt.Mode != EXIST_ABORT) && (Pkt.Mode != EXIST_IGNORE))\r
316                                         AddTransFileList(&Pkt);\r
317                         }\r
318                 }\r
319 \r
320                 if(AskNoFullPathMode() == YES)\r
321                 {\r
322                         strcpy(Pkt.Cmd, "BACKCUR");\r
323                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
324                         AddTransFileList(&Pkt);\r
325                 }\r
326 \r
327                 strcpy(Pkt.Cmd, "GOQUIT");\r
328                 AddTransFileList(&Pkt);\r
329 \r
330                 GoForwardTransWindow();\r
331 //              KeepTransferDialog(NO);\r
332 \r
333                 EnableUserOpe();\r
334         }\r
335         return;\r
336 }\r
337 \r
338 \r
339 /*----- 入力されたファイル名のファイルを一つダウンロードする ------------------\r
340 *\r
341 *       Parameter\r
342 *               なし\r
343 *\r
344 *       Return Value\r
345 *               なし\r
346 *----------------------------------------------------------------------------*/\r
347 \r
348 void InputDownLoadProc(void)\r
349 {\r
350         char Path[FMAX_PATH+1];\r
351         int Tmp;\r
352 \r
353 //      DisableUserOpe();\r
354 \r
355         strcpy(Path, "");\r
356         if(InputDialogBox(downname_dlg, GetMainHwnd(), NULL, Path, FMAX_PATH, &Tmp, IDH_HELP_TOPIC_0000001) == YES)\r
357         {\r
358                 DirectDownLoadProc(Path);\r
359         }\r
360 \r
361 //      EnableUserOpe();\r
362 \r
363         return;\r
364 }\r
365 \r
366 \r
367 /*----- ミラーリングダウンロードを行う ----------------------------------------\r
368 *\r
369 *       Parameter\r
370 *               int Notify : 確認を行うかどうか (YES/NO)\r
371 *\r
372 *       Return Value\r
373 *               なし\r
374 *----------------------------------------------------------------------------*/\r
375 \r
376 void MirrorDownloadProc(int Notify)\r
377 {\r
378         FILELIST *LocalListBase;\r
379         FILELIST *RemoteListBase;\r
380         FILELIST *LocalPos;\r
381         FILELIST *RemotePos;\r
382         TRANSPACKET Pkt;\r
383         TRANSPACKET *Base;\r
384         char Name[FMAX_PATH+1];\r
385         char *Cat;\r
386         int Level;\r
387         int Mode;\r
388 \r
389         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
390         {\r
391                 DisableUserOpe();\r
392 \r
393                 Base = NULL;\r
394 \r
395                 if(Notify == YES)\r
396                         Notify = DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(mirror_down_dlg), GetMainHwnd(), MirrorNotifyCallBack, 0);\r
397                 else\r
398                         Notify = YES;\r
399 \r
400                 if((Notify == YES) || (Notify == YES_LIST))\r
401                 {\r
402                         /*===== ファイルリスト取得 =====*/\r
403 \r
404                         LocalListBase = NULL;\r
405                         MakeSelectedFileList(WIN_LOCAL, YES, YES, &LocalListBase, &CancelFlg);\r
406                         RemoteListBase = NULL;\r
407                         MakeSelectedFileList(WIN_REMOTE, YES, YES, &RemoteListBase, &CancelFlg);\r
408 \r
409                         RemotePos = RemoteListBase;\r
410                         while(RemotePos != NULL)\r
411                         {\r
412                                 RemotePos->Attr = YES;          /* RemotePos->Attrは転送するかどうかのフラグに使用 (YES/NO) */\r
413                                 RemotePos = RemotePos->Next;\r
414                         }\r
415 \r
416                         LocalPos = LocalListBase;\r
417                         while(LocalPos != NULL)\r
418                         {\r
419                                 if(AskMirrorNoTrn(LocalPos->File, 1) == NO)\r
420                                 {\r
421                                         LocalPos->Attr = YES;\r
422                                         LocalPos = LocalPos->Next;\r
423                                 }\r
424                                 else\r
425                                 {\r
426                                         LocalPos->Attr = NO;    /* LocalPos->Attrは削除するかどうかのフラグに使用 (YES/NO) */\r
427 \r
428                                         if(LocalPos->Node == NODE_DIR)\r
429                                         {\r
430                                                 Level = AskDirLevel(LocalPos->File);\r
431                                                 LocalPos = LocalPos->Next;\r
432                                                 while(LocalPos != NULL)\r
433                                                 {\r
434                                                         if((LocalPos->Node == NODE_DIR) &&\r
435                                                            (AskDirLevel(LocalPos->File) <= Level))\r
436                                                         {\r
437                                                                 break;\r
438                                                         }\r
439                                                         LocalPos->Attr = NO;\r
440                                                         LocalPos = LocalPos->Next;\r
441                                                 }\r
442                                         }\r
443                                         else\r
444                                                 LocalPos = LocalPos->Next;\r
445                                 }\r
446                         }\r
447 \r
448                         /*===== ファイルリスト比較 =====*/\r
449 \r
450                         RemotePos = RemoteListBase;\r
451                         while(RemotePos != NULL)\r
452                         {\r
453                                 if(AskMirrorNoTrn(RemotePos->File, 0) == NO)\r
454                                 {\r
455                                         strcpy(Name, RemotePos->File);\r
456 //                                      ReplaceAll(Name, '/', '\\');\r
457 \r
458                                         if(MirrorFnameCnv == YES)\r
459                                                 Mode = COMP_LOWERMATCH;\r
460                                         else\r
461                                                 Mode = COMP_STRICT;\r
462 \r
463                                         if((LocalPos = SearchFileList(Name, LocalListBase, Mode)) != NULL)\r
464                                         {\r
465                                                 if((RemotePos->Node == NODE_DIR) && (LocalPos->Node == NODE_DIR))\r
466                                                 {\r
467                                                         LocalPos->Attr = NO;\r
468                                                         RemotePos->Attr = NO;\r
469                                                 }\r
470                                                 else if((RemotePos->Node == NODE_FILE) && (LocalPos->Node == NODE_FILE))\r
471                                                 {\r
472                                                         LocalPos->Attr = NO;\r
473                                                         if(CompareFileTime(&RemotePos->Time, &LocalPos->Time) <= 0)\r
474                                                                 RemotePos->Attr = NO;\r
475                                                 }\r
476                                         }\r
477                                         RemotePos = RemotePos->Next;\r
478                                 }\r
479                                 else\r
480                                 {\r
481                                         if(RemotePos->Node == NODE_FILE)\r
482                                         {\r
483                                                 RemotePos->Attr = NO;\r
484                                                 RemotePos = RemotePos->Next;\r
485                                         }\r
486                                         else\r
487                                         {\r
488                                                 RemotePos->Attr = NO;\r
489                                                 Level = AskDirLevel(RemotePos->File);\r
490                                                 RemotePos = RemotePos->Next;\r
491                                                 while(RemotePos != NULL)\r
492                                                 {\r
493                                                         if((RemotePos->Node == NODE_DIR) &&\r
494                                                            (AskDirLevel(RemotePos->File) <= Level))\r
495                                                         {\r
496                                                                 break;\r
497                                                         }\r
498                                                         RemotePos->Attr = NO;\r
499                                                         RemotePos = RemotePos->Next;\r
500                                                 }\r
501                                         }\r
502                                 }\r
503                         }\r
504 \r
505                         DispMirrorFiles(LocalListBase, RemoteListBase);\r
506 \r
507                         /*===== 削除/アップロード =====*/\r
508 \r
509                         LocalPos = LocalListBase;\r
510                         while(LocalPos != NULL)\r
511                         {\r
512                                 if((LocalPos->Attr == YES) && (LocalPos->Node == NODE_FILE))\r
513                                 {\r
514                                         AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
515                                         SetYenTail(Pkt.LocalFile);\r
516                                         strcat(Pkt.LocalFile, LocalPos->File);\r
517                                         ReplaceAll(Pkt.LocalFile, '/', '\\');\r
518                                         strcpy(Pkt.RemoteFile, "");\r
519                                         strcpy(Pkt.Cmd, "L-DELE ");\r
520                                         AddTmpTransFileList(&Pkt, &Base);\r
521                                 }\r
522                                 LocalPos = LocalPos->Next;\r
523                         }\r
524                         MirrorDeleteAllLocalDir(LocalListBase, &Pkt, &Base);\r
525 \r
526 \r
527                         RemotePos = RemoteListBase;\r
528                         while(RemotePos != NULL)\r
529                         {\r
530                                 if(RemotePos->Attr == YES)\r
531                                 {\r
532                                         AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
533                                         SetYenTail(Pkt.LocalFile);\r
534                                         Cat = strchr(Pkt.LocalFile, NUL);\r
535                                         strcat(Pkt.LocalFile, RemotePos->File);\r
536 \r
537                                         if(MirrorFnameCnv == YES)\r
538                                                 _mbslwr(Cat);\r
539 \r
540                                         RemoveAfterSemicolon(Cat);\r
541                                         ReplaceAll(Pkt.LocalFile, '/', '\\');\r
542 \r
543                                         if(RemotePos->Node == NODE_DIR)\r
544                                         {\r
545                                                 strcpy(Pkt.RemoteFile, "");\r
546                                                 strcpy(Pkt.Cmd, "L-MKD ");\r
547                                                 AddTmpTransFileList(&Pkt, &Base);\r
548                                         }\r
549                                         else if(RemotePos->Node == NODE_FILE)\r
550                                         {\r
551                                                 AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
552                                                 SetSlashTail(Pkt.RemoteFile);\r
553                                                 strcat(Pkt.RemoteFile, RemotePos->File);\r
554                                                 ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
555 \r
556                                                 strcpy(Pkt.Cmd, "RETR ");\r
557                                                 Pkt.Type = AskTransferTypeAssoc(Pkt.RemoteFile, AskTransferType());\r
558                                                 Pkt.Size = RemotePos->Size;\r
559                                                 Pkt.Time = RemotePos->Time;\r
560 //                                              Pkt.Attr = 0;\r
561                                                 Pkt.KanjiCode = AskHostKanjiCode();\r
562                                                 // UTF-8対応\r
563                                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
564                                                 Pkt.KanaCnv = AskHostKanaCnv();\r
565                                                 Pkt.Mode = EXIST_OVW;\r
566                                                 AddTmpTransFileList(&Pkt, &Base);\r
567                                         }\r
568                                 }\r
569                                 RemotePos = RemotePos->Next;\r
570                         }\r
571 \r
572                         if((Notify == YES) ||\r
573                            (DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(mirrordown_notify_dlg), GetMainHwnd(), MirrorDispListCallBack, (LPARAM)&Base) == YES))\r
574                         {\r
575                                 if(AskNoFullPathMode() == YES)\r
576                                 {\r
577                                         strcpy(Pkt.Cmd, "SETCUR");\r
578                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
579                                         AddTransFileList(&Pkt);\r
580                                 }\r
581                                 AppendTransFileList(Base);\r
582 \r
583                                 if(AskNoFullPathMode() == YES)\r
584                                 {\r
585                                         strcpy(Pkt.Cmd, "BACKCUR");\r
586                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
587                                         AddTransFileList(&Pkt);\r
588                                 }\r
589 \r
590                                 strcpy(Pkt.Cmd, "GOQUIT");\r
591                                 AddTransFileList(&Pkt);\r
592                         }\r
593                         else\r
594                                 EraseTmpTransFileList(&Base);\r
595 \r
596                         DeleteFileList(&LocalListBase);\r
597                         DeleteFileList(&RemoteListBase);\r
598 \r
599                         GoForwardTransWindow();\r
600                 }\r
601 \r
602                 EnableUserOpe();\r
603         }\r
604         return;\r
605 }\r
606 \r
607 \r
608 /*----- ミラーリングのファイル一覧を表示 --------------------------------------\r
609 *\r
610 *       Parameter\r
611 *               FILELIST *Local : ローカル側\r
612 *               FILELIST *Remote : リモート側\r
613 *\r
614 *       Return Value\r
615 *               なし\r
616 *----------------------------------------------------------------------------*/\r
617 \r
618 static void DispMirrorFiles(FILELIST *Local, FILELIST *Remote)\r
619 {\r
620         char Date[80];\r
621         SYSTEMTIME sTime;\r
622         FILETIME fTime;\r
623 \r
624         if(DebugConsole == YES)\r
625         {\r
626                 DoPrintf("---- MIRROR FILE LIST ----");\r
627                 while(Local != NULL)\r
628                 {\r
629                         FileTimeToLocalFileTime(&Local->Time, &fTime);\r
630                         FileTimeToSystemTime(&fTime, &sTime);\r
631                         sprintf(Date, "%04d/%02d/%02d %02d:%02d:%02d.%04d", \r
632                                 sTime.wYear, sTime.wMonth, sTime.wDay, sTime.wHour, sTime.wMinute, sTime.wSecond, sTime.wMilliseconds);\r
633                         DoPrintf("LOCAL  : %s %s [%s] %s", Local->Attr==1?"YES":"NO ", Local->Node==NODE_DIR?"DIR ":"FILE", Date, Local->File);\r
634                         Local = Local->Next;\r
635                 }\r
636                 while(Remote != NULL)\r
637                 {\r
638                         FileTimeToLocalFileTime(&Remote->Time, &fTime);\r
639                         FileTimeToSystemTime(&fTime, &sTime);\r
640                         sprintf(Date, "%04d/%02d/%02d %02d:%02d:%02d.%04d", \r
641                                 sTime.wYear, sTime.wMonth, sTime.wDay, sTime.wHour, sTime.wMinute, sTime.wSecond, sTime.wMilliseconds);\r
642                         DoPrintf("REMOTE : %s %s [%s] %s", Remote->Attr==1?"YES":"NO ", Remote->Node==NODE_DIR?"DIR ":"FILE", Date, Remote->File);\r
643                         Remote = Remote->Next;\r
644                 }\r
645                 DoPrintf("---- END ----");\r
646         }\r
647         return;\r
648 }\r
649 \r
650 \r
651 /*----- ミラーリング時のローカル側のフォルダ削除 ------------------------------\r
652 *\r
653 *       Parameter\r
654 *               FILELIST *Local : ファイルリスト\r
655 *               TRANSPACKET *Pkt : \r
656 *               TRANSPACKET **Base : \r
657 *\r
658 *       Return Value\r
659 *               なし\r
660 *----------------------------------------------------------------------------*/\r
661 \r
662 static void MirrorDeleteAllLocalDir(FILELIST *Local, TRANSPACKET *Pkt, TRANSPACKET **Base)\r
663 {\r
664         while(Local != NULL)\r
665         {\r
666                 if(Local->Node == NODE_DIR)\r
667                 {\r
668                         MirrorDeleteAllLocalDir(Local->Next, Pkt, Base);\r
669 \r
670                         if(Local->Attr == YES)\r
671                         {\r
672                                 AskLocalCurDir(Pkt->LocalFile, FMAX_PATH);\r
673                                 SetYenTail(Pkt->LocalFile);\r
674                                 strcat(Pkt->LocalFile, Local->File);\r
675                                 ReplaceAll(Pkt->LocalFile, '/', '\\');\r
676                                 strcpy(Pkt->RemoteFile, "");\r
677                                 strcpy(Pkt->Cmd, "L-RMD ");\r
678                                 AddTmpTransFileList(Pkt, Base);\r
679                         }\r
680                         break;\r
681                 }\r
682                 Local = Local->Next;\r
683         }\r
684         return;\r
685 }\r
686 \r
687 \r
688 /*----- ファイル名のセミコロン以降を取り除く ----------------------------------\r
689 *\r
690 *       Parameter\r
691 *               char *Path : ファイル名\r
692 *\r
693 *       Return Value\r
694 *               なし\r
695 *\r
696 *       Note\r
697 *               Pathの内容が書き換えられる\r
698 *               オプション設定によって処理を切替える\r
699 *----------------------------------------------------------------------------*/\r
700 \r
701 static void RemoveAfterSemicolon(char *Path)\r
702 {\r
703         char *Pos;\r
704 \r
705         if(VaxSemicolon == YES)\r
706         {\r
707                 if((Pos = strchr(Path, ';')) != NULL)\r
708                         *Pos = NUL;\r
709         }\r
710         return;\r
711 }\r
712 \r
713 \r
714 /*----- ローカルに同じ名前のファイルがないかチェック --------------------------\r
715 *\r
716 *       Parameter\r
717 *               TRANSPACKET *Pkt : 転送ファイル情報\r
718 *\r
719 *       Return Value\r
720 *               int 処理方法\r
721 *                       EXIST_OVW/EXIST_RESUME/EXIST_IGNORE\r
722 *\r
723 *       Note\r
724 *               Pkt.ExistSize, ExistMode、ExistNotify が変更される\r
725 *----------------------------------------------------------------------------*/\r
726 \r
727 static int CheckLocalFile(TRANSPACKET *Pkt)\r
728 {\r
729         HANDLE fHnd;\r
730         WIN32_FIND_DATA Find;\r
731         int Ret;\r
732 \r
733         Ret = EXIST_OVW;\r
734         Pkt->ExistSize = 0;\r
735         if(RecvMode != TRANS_OVW)\r
736         {\r
737                 if((fHnd = FindFirstFile(Pkt->LocalFile, &Find)) != INVALID_HANDLE_VALUE)\r
738                 {\r
739                         FindClose(fHnd);\r
740 \r
741                         Pkt->ExistSize = MakeLongLong(Find.nFileSizeHigh, Find.nFileSizeLow);\r
742 \r
743                         if(ExistNotify == YES)\r
744                         {\r
745                                 SoundPlay(SND_ERROR);\r
746                                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(down_exist_dlg), GetMainHwnd(), DownExistDialogCallBack, (LPARAM)Pkt) == NO)\r
747                                         Ret = EXIST_ABORT;\r
748                                 else\r
749                                         Ret = ExistMode;\r
750                         }\r
751                         else\r
752                                 Ret = ExistMode;\r
753 \r
754                         if(Ret == EXIST_NEW)\r
755                         {\r
756                                 /*ファイル日付チェック */\r
757                                 if(CompareFileTime(&Find.ftLastWriteTime, &Pkt->Time) < 0)\r
758                                         Ret = EXIST_OVW;\r
759                                 else\r
760                                         Ret = EXIST_IGNORE;\r
761                         }\r
762                 }\r
763         }\r
764         return(Ret);\r
765 }\r
766 \r
767 \r
768 /*----- ローカルに同じ名前のファイルがある時の確認ダイアログのコールバック ----\r
769 *\r
770 *       Parameter\r
771 *               HWND hDlg : ウインドウハンドル\r
772 *               UINT message : メッセージ番号\r
773 *               WPARAM wParam : メッセージの WPARAM 引数\r
774 *               LPARAM lParam : メッセージの LPARAM 引数\r
775 *\r
776 *       Return Value\r
777 *               BOOL TRUE/FALSE\r
778 *----------------------------------------------------------------------------*/\r
779 \r
780 static BOOL CALLBACK DownExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
781 {\r
782         static TRANSPACKET *Pkt;\r
783         static const RADIOBUTTON DownExistButton[] = {\r
784                 { DOWN_EXIST_OVW, EXIST_OVW },\r
785                 { DOWN_EXIST_NEW, EXIST_NEW },\r
786                 { DOWN_EXIST_RESUME, EXIST_RESUME },\r
787                 { DOWN_EXIST_IGNORE, EXIST_IGNORE }\r
788         };\r
789         #define DOWNEXISTBUTTONS        (sizeof(DownExistButton)/sizeof(RADIOBUTTON))\r
790 \r
791         switch (iMessage)\r
792         {\r
793                 case WM_INITDIALOG :\r
794                         Pkt = (TRANSPACKET *)lParam;\r
795                         SendDlgItemMessage(hDlg, DOWN_EXIST_NAME, EM_LIMITTEXT, FMAX_PATH, 0);\r
796                         SendDlgItemMessage(hDlg, DOWN_EXIST_NAME, WM_SETTEXT, 0, (LPARAM)Pkt->LocalFile);\r
797 \r
798                         if((Pkt->Type == TYPE_A) || (Pkt->ExistSize <= 0))\r
799                                 EnableWindow(GetDlgItem(hDlg, DOWN_EXIST_RESUME), FALSE);\r
800 \r
801                         SetRadioButtonByValue(hDlg, ExistMode, DownExistButton, DOWNEXISTBUTTONS);\r
802                         return(TRUE);\r
803 \r
804                 case WM_COMMAND :\r
805                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
806                         {\r
807                                 case IDOK_ALL :\r
808                                         ExistNotify = NO;\r
809                                         /* ここに break はない */\r
810 \r
811                                 case IDOK :\r
812                                         ExistMode = AskRadioButtonValue(hDlg, DownExistButton, DOWNEXISTBUTTONS);\r
813                                         SendDlgItemMessage(hDlg, DOWN_EXIST_NAME, WM_GETTEXT, FMAX_PATH, (LPARAM)Pkt->LocalFile);\r
814                                         EndDialog(hDlg, YES);\r
815                                         break;\r
816 \r
817                                 case IDCANCEL :\r
818 //                                      ExistMode = EXIST_ABORT;\r
819                                         EndDialog(hDlg, NO);\r
820                                         break;\r
821 \r
822                                 case IDHELP :\r
823                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000009);\r
824                                         break;\r
825                         }\r
826             return(TRUE);\r
827         }\r
828         return(FALSE);\r
829 }\r
830 \r
831 \r
832 \r
833 \r
834 \r
835 \r
836 /*----- ファイル一覧で指定されたファイルをアップロードする --------------------\r
837 *\r
838 *       Parameter\r
839 *               int ChName : 名前を変えるかどうか (YES/NO)\r
840 *               int All : 全てが選ばれている物として扱うかどうか (YES/NO)\r
841 *\r
842 *       Return Value\r
843 *               なし\r
844 *----------------------------------------------------------------------------*/\r
845 \r
846 void UpLoadListProc(int ChName, int All)\r
847 {\r
848         FILELIST *FileListBase;\r
849         FILELIST *Pos;\r
850         TRANSPACKET Pkt;\r
851         TRANSPACKET Pkt1;\r
852         char *Cat;\r
853         FILELIST *RemoteList;\r
854         char Tmp[FMAX_PATH+1];\r
855         int FirstAdd;\r
856 \r
857         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
858         {\r
859                 DisableUserOpe();\r
860 \r
861                 // ローカル側で選ばれているファイルをFileListBaseに登録\r
862                 FileListBase = NULL;\r
863                 MakeSelectedFileList(WIN_LOCAL, YES, All, &FileListBase, &CancelFlg);\r
864 \r
865                 // 現在ホスト側のファイル一覧に表示されているものをRemoteListに登録\r
866                 // 同名ファイルチェック用\r
867                 RemoteList = NULL;\r
868                 AddRemoteTreeToFileList(AskCurrentFileListNum(), "", RDIR_NONE, &RemoteList);\r
869 \r
870                 FirstAdd = YES;\r
871                 ExistNotify = YES;\r
872 \r
873                 Pos = FileListBase;\r
874                 while(Pos != NULL)\r
875                 {\r
876                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
877                         SetSlashTail(Pkt.RemoteFile);\r
878                         Cat = strchr(Pkt.RemoteFile, NUL);\r
879                         if((ChName == NO) || (Pos->Node == NODE_DIR))\r
880                         {\r
881                                 strcat(Pkt.RemoteFile, Pos->File);\r
882                                 if(FnameCnv == FNAME_LOWER)\r
883                                         _mbslwr(Cat);\r
884                                 else if(FnameCnv == FNAME_UPPER)\r
885                                         _mbsupr(Cat);\r
886                         }\r
887                         else\r
888                         {\r
889                                 // 名前を変更する\r
890                                 strcpy(TmpString, Pos->File);\r
891                                 CurWin = WIN_LOCAL;\r
892                                 if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(updown_as_dlg), GetMainHwnd(), UpDownAsDialogCallBack) == YES)\r
893                                         strcat(Pkt.RemoteFile, TmpString);\r
894                                 else\r
895                                         break;\r
896                         }\r
897                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
898 \r
899                         if(AskHostType() == HTYPE_ACOS)\r
900                         {\r
901                                 strcpy(Pkt.RemoteFile, "'");\r
902                                 strcat(Pkt.RemoteFile, AskHostLsName());\r
903                                 strcat(Pkt.RemoteFile, "(");\r
904                                 strcat(Pkt.RemoteFile, Cat);\r
905                                 strcat(Pkt.RemoteFile, ")");\r
906                                 strcat(Pkt.RemoteFile, "'");\r
907                         }\r
908                         else if(AskHostType() == HTYPE_ACOS_4)\r
909                                 strcpy(Pkt.RemoteFile, Cat);\r
910 \r
911                         if(Pos->Node == NODE_DIR)\r
912                         {\r
913                                 // フォルダの場合\r
914 \r
915                                 // ホスト側のファイル一覧をRemoteListに登録\r
916                                 // 同名ファイルチェック用\r
917                                 if(RemoteList != NULL)\r
918                                         DeleteFileList(&RemoteList);\r
919                                 RemoteList = NULL;\r
920 \r
921                                 AskRemoteCurDir(Tmp, FMAX_PATH);\r
922                                 if(DoCWD(Pkt.RemoteFile, NO, NO, NO) == FTP_COMPLETE)\r
923                                 {\r
924                                         if(DoDirListCmdSkt("", "", 998, &CancelFlg) == FTP_COMPLETE)\r
925                                                 AddRemoteTreeToFileList(998, "", RDIR_NONE, &RemoteList);\r
926                                         DoCWD(Tmp, NO, NO, NO);\r
927                                 }\r
928                                 else\r
929                                 {\r
930                                         // フォルダを作成\r
931                                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
932                                         {\r
933                                                 strcpy(Pkt1.Cmd, "SETCUR");\r
934                                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
935                                                 AddTransFileList(&Pkt1);\r
936                                         }\r
937                                         FirstAdd = NO;\r
938                                         strcpy(Pkt.Cmd, "MKD ");\r
939                                         strcpy(Pkt.LocalFile, "");\r
940                                         AddTransFileList(&Pkt);\r
941                                 }\r
942                         }\r
943                         else if(Pos->Node == NODE_FILE)\r
944                         {\r
945                                 // ファイルの場合\r
946                                 AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
947                                 SetYenTail(Pkt.LocalFile);\r
948                                 strcat(Pkt.LocalFile, Pos->File);\r
949                                 ReplaceAll(Pkt.LocalFile, '/', '\\');\r
950 \r
951                                 strcpy(Pkt.Cmd, "STOR ");\r
952                                 Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType());\r
953                                 Pkt.Size = 0;\r
954                                 Pkt.Time = Pos->Time;\r
955                                 Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile);\r
956                                 Pkt.KanjiCode = AskHostKanjiCode();\r
957                                 // UTF-8対応\r
958                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
959                                 Pkt.KanaCnv = AskHostKanaCnv();\r
960                                 Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList);\r
961                                 if(Pkt.Mode == EXIST_ABORT)\r
962                                         break;\r
963                                 else if(Pkt.Mode != EXIST_IGNORE)\r
964                                 {\r
965                                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
966                                         {\r
967                                                 strcpy(Pkt1.Cmd, "SETCUR");\r
968                                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
969                                                 AddTransFileList(&Pkt1);\r
970                                         }\r
971                                         FirstAdd = NO;\r
972                                         AddTransFileList(&Pkt);\r
973                                 }\r
974                         }\r
975                         Pos = Pos->Next;\r
976                 }\r
977 \r
978                 if((FirstAdd == NO) && (AskNoFullPathMode() == YES))\r
979                 {\r
980                         strcpy(Pkt.Cmd, "BACKCUR");\r
981                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
982                         AddTransFileList(&Pkt);\r
983                 }\r
984 \r
985                 if(RemoteList != NULL)\r
986                         DeleteFileList(&RemoteList);\r
987 \r
988                 DeleteFileList(&FileListBase);\r
989 \r
990                 strcpy(Pkt.Cmd, "GOQUIT");\r
991                 AddTransFileList(&Pkt);\r
992 \r
993                 GoForwardTransWindow();\r
994 \r
995                 EnableUserOpe();\r
996         }\r
997         return;\r
998 }\r
999 \r
1000 \r
1001 /*----- ドラッグ&ドロップで指定されたファイルをアップロードする --------------\r
1002 *\r
1003 *       Parameter\r
1004 *               WPARAM wParam : ドロップされたファイルの情報\r
1005 *\r
1006 *       Return Value\r
1007 *               なし\r
1008 *----------------------------------------------------------------------------*/\r
1009 \r
1010 void UpLoadDragProc(WPARAM wParam)\r
1011 {\r
1012         FILELIST *FileListBase;\r
1013         FILELIST *Pos;\r
1014         TRANSPACKET Pkt;\r
1015         TRANSPACKET Pkt1;\r
1016         char *Cat;\r
1017         FILELIST *RemoteList;\r
1018         char Tmp[FMAX_PATH+1];\r
1019         int FirstAdd;\r
1020         char Cur[FMAX_PATH+1];\r
1021 \r
1022         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1023         {\r
1024                 DisableUserOpe();\r
1025 \r
1026                 // ローカル側で選ばれているファイルをFileListBaseに登録\r
1027                 FileListBase = NULL;\r
1028                 MakeDroppedFileList(wParam, Cur, &FileListBase);\r
1029 \r
1030                 // 現在ホスト側のファイル一覧に表示されているものをRemoteListに登録\r
1031                 // 同名ファイルチェック用\r
1032                 RemoteList = NULL;\r
1033                 AddRemoteTreeToFileList(AskCurrentFileListNum(), "", RDIR_NONE, &RemoteList);\r
1034 \r
1035                 FirstAdd = YES;\r
1036                 ExistNotify = YES;\r
1037 \r
1038                 Pos = FileListBase;\r
1039                 while(Pos != NULL)\r
1040                 {\r
1041                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1042                         SetSlashTail(Pkt.RemoteFile);\r
1043                         Cat = strchr(Pkt.RemoteFile, NUL);\r
1044 \r
1045                         strcat(Pkt.RemoteFile, Pos->File);\r
1046                         if(FnameCnv == FNAME_LOWER)\r
1047                                 _mbslwr(Cat);\r
1048                         else if(FnameCnv == FNAME_UPPER)\r
1049                                 _mbsupr(Cat);\r
1050                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
1051 \r
1052                         if(AskHostType() == HTYPE_ACOS)\r
1053                         {\r
1054                                 strcpy(Pkt.RemoteFile, "'");\r
1055                                 strcat(Pkt.RemoteFile, AskHostLsName());\r
1056                                 strcat(Pkt.RemoteFile, "(");\r
1057                                 strcat(Pkt.RemoteFile, Cat);\r
1058                                 strcat(Pkt.RemoteFile, ")");\r
1059                                 strcat(Pkt.RemoteFile, "'");\r
1060                         }\r
1061                         else if(AskHostType() == HTYPE_ACOS_4)\r
1062                                 strcpy(Pkt.RemoteFile, Cat);\r
1063 \r
1064                         if(Pos->Node == NODE_DIR)\r
1065                         {\r
1066                                 // フォルダの場合\r
1067 \r
1068                                 // ホスト側のファイル一覧をRemoteListに登録\r
1069                                 // 同名ファイルチェック用\r
1070                                 if(RemoteList != NULL)\r
1071                                         DeleteFileList(&RemoteList);\r
1072                                 RemoteList = NULL;\r
1073 \r
1074                                 AskRemoteCurDir(Tmp, FMAX_PATH);\r
1075                                 if(DoCWD(Pkt.RemoteFile, NO, NO, NO) == FTP_COMPLETE)\r
1076                                 {\r
1077                                         if(DoDirListCmdSkt("", "", 998, &CancelFlg) == FTP_COMPLETE)\r
1078                                                 AddRemoteTreeToFileList(998, "", RDIR_NONE, &RemoteList);\r
1079                                         DoCWD(Tmp, NO, NO, NO);\r
1080                                 }\r
1081                                 else\r
1082                                 {\r
1083                                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
1084                                         {\r
1085                                                 strcpy(Pkt1.Cmd, "SETCUR");\r
1086                                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
1087                                                 AddTransFileList(&Pkt1);\r
1088                                         }\r
1089                                         FirstAdd = NO;\r
1090                                         strcpy(Pkt.Cmd, "MKD ");\r
1091                                         strcpy(Pkt.LocalFile, "");\r
1092                                         AddTransFileList(&Pkt);\r
1093                                 }\r
1094                         }\r
1095                         else if(Pos->Node == NODE_FILE)\r
1096                         {\r
1097                                 // ファイルの場合\r
1098                                 strcpy(Pkt.LocalFile, Cur);\r
1099                                 SetYenTail(Pkt.LocalFile);\r
1100                                 strcat(Pkt.LocalFile, Pos->File);\r
1101                                 ReplaceAll(Pkt.LocalFile, '/', '\\');\r
1102 \r
1103                                 strcpy(Pkt.Cmd, "STOR ");\r
1104                                 Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType());\r
1105                                 Pkt.Size = 0;\r
1106                                 Pkt.Time = Pos->Time;\r
1107                                 Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile);\r
1108                                 Pkt.KanjiCode = AskHostKanjiCode();\r
1109                                 // UTF-8対応\r
1110                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
1111                                 Pkt.KanaCnv = AskHostKanaCnv();\r
1112                                 Pkt.Mode = CheckRemoteFile(&Pkt, RemoteList);\r
1113                                 if(Pkt.Mode == EXIST_ABORT)\r
1114                                         break;\r
1115                                 else if(Pkt.Mode != EXIST_IGNORE)\r
1116                                 {\r
1117                                         if((FirstAdd == YES) && (AskNoFullPathMode() == YES))\r
1118                                         {\r
1119                                                 strcpy(Pkt1.Cmd, "SETCUR");\r
1120                                                 AskRemoteCurDir(Pkt1.RemoteFile, FMAX_PATH);\r
1121                                                 AddTransFileList(&Pkt1);\r
1122                                         }\r
1123                                         FirstAdd = NO;\r
1124                                         AddTransFileList(&Pkt);\r
1125                                 }\r
1126                         }\r
1127                         Pos = Pos->Next;\r
1128                 }\r
1129 \r
1130                 if((FirstAdd == NO) && (AskNoFullPathMode() == YES))\r
1131                 {\r
1132                         strcpy(Pkt.Cmd, "BACKCUR");\r
1133                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1134                         AddTransFileList(&Pkt);\r
1135                 }\r
1136 \r
1137                 if(RemoteList != NULL)\r
1138                         DeleteFileList(&RemoteList);\r
1139 \r
1140                 DeleteFileList(&FileListBase);\r
1141 \r
1142                 strcpy(Pkt.Cmd, "GOQUIT");\r
1143                 AddTransFileList(&Pkt);\r
1144 \r
1145                 GoForwardTransWindow();\r
1146 \r
1147                 EnableUserOpe();\r
1148         }\r
1149         return;\r
1150 }\r
1151 \r
1152 \r
1153 /*----- ミラーリングアップロードを行う ----------------------------------------\r
1154 *\r
1155 *       Parameter\r
1156 *               int Notify : 確認を行うかどうか (YES/NO)\r
1157 *\r
1158 *       Return Value\r
1159 *               なし\r
1160 *----------------------------------------------------------------------------*/\r
1161 \r
1162 void MirrorUploadProc(int Notify)\r
1163 {\r
1164         FILELIST *LocalListBase;\r
1165         FILELIST *RemoteListBase;\r
1166         FILELIST *LocalPos;\r
1167         FILELIST *RemotePos;\r
1168         TRANSPACKET Pkt;\r
1169         TRANSPACKET *Base;\r
1170         char Name[FMAX_PATH+1];\r
1171         char *Cat;\r
1172         int Level;\r
1173         int Mode;\r
1174         SYSTEMTIME TmpStime;\r
1175         FILETIME TmpFtimeL;\r
1176         FILETIME TmpFtimeR;\r
1177 \r
1178         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1179         {\r
1180                 DisableUserOpe();\r
1181 \r
1182                 Base = NULL;\r
1183 \r
1184                 if(Notify == YES)\r
1185                         Notify = DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(mirror_up_dlg), GetMainHwnd(), MirrorNotifyCallBack, 1);\r
1186                 else\r
1187                         Notify = YES;\r
1188 \r
1189                 if((Notify == YES) || (Notify == YES_LIST))\r
1190                 {\r
1191                         /*===== ファイルリスト取得 =====*/\r
1192 \r
1193                         LocalListBase = NULL;\r
1194                         MakeSelectedFileList(WIN_LOCAL, YES, YES, &LocalListBase, &CancelFlg);\r
1195                         RemoteListBase = NULL;\r
1196                         MakeSelectedFileList(WIN_REMOTE, YES, YES, &RemoteListBase, &CancelFlg);\r
1197 \r
1198                         LocalPos = LocalListBase;\r
1199                         while(LocalPos != NULL)\r
1200                         {\r
1201                                 LocalPos->Attr = YES;           /* LocalPos->Attrは転送するかどうかのフラグに使用 (YES/NO) */\r
1202                                 LocalPos = LocalPos->Next;\r
1203                         }\r
1204 \r
1205                         RemotePos = RemoteListBase;\r
1206                         while(RemotePos != NULL)\r
1207                         {\r
1208                                 if(AskMirrorNoTrn(RemotePos->File, 1) == NO)\r
1209                                 {\r
1210                                         RemotePos->Attr = YES;\r
1211                                         RemotePos = RemotePos->Next;\r
1212                                 }\r
1213                                 else\r
1214                                 {\r
1215                                         RemotePos->Attr = NO;   /* RemotePos->Attrは削除するかどうかのフラグに使用 (YES/NO) */\r
1216 \r
1217                                         if(RemotePos->Node == NODE_DIR)\r
1218                                         {\r
1219                                                 Level = AskDirLevel(RemotePos->File);\r
1220                                                 RemotePos = RemotePos->Next;\r
1221                                                 while(RemotePos != NULL)\r
1222                                                 {\r
1223                                                         if((RemotePos->Node == NODE_DIR) &&\r
1224                                                            (AskDirLevel(RemotePos->File) <= Level))\r
1225                                                         {\r
1226                                                                 break;\r
1227                                                         }\r
1228                                                         RemotePos->Attr = NO;\r
1229                                                         RemotePos = RemotePos->Next;\r
1230                                                 }\r
1231                                         }\r
1232                                         else\r
1233                                                 RemotePos = RemotePos->Next;\r
1234                                 }\r
1235                         }\r
1236 \r
1237                         /*===== ファイルリスト比較 =====*/\r
1238 \r
1239                         LocalPos = LocalListBase;\r
1240                         while(LocalPos != NULL)\r
1241                         {\r
1242                                 if(AskMirrorNoTrn(LocalPos->File, 0) == NO)\r
1243                                 {\r
1244                                         strcpy(Name, LocalPos->File);\r
1245                                         ReplaceAll(Name, '\\', '/');\r
1246 \r
1247                                         if(MirrorFnameCnv == YES)\r
1248                                                 Mode = COMP_LOWERMATCH;\r
1249                                         else\r
1250                                                 Mode = COMP_STRICT;\r
1251 \r
1252                                         if(LocalPos->Node == NODE_DIR)\r
1253                                         {\r
1254                                                 if((RemotePos = SearchFileList(Name, RemoteListBase, Mode)) != NULL)\r
1255                                                 {\r
1256                                                         if(RemotePos->Node == NODE_DIR)\r
1257                                                         {\r
1258                                                                 RemotePos->Attr = NO;\r
1259                                                                 LocalPos->Attr = NO;\r
1260                                                         }\r
1261                                                 }\r
1262                                         }\r
1263                                         else if(LocalPos->Node == NODE_FILE)\r
1264                                         {\r
1265                                                 if((RemotePos = SearchFileList(Name, RemoteListBase, Mode)) != NULL)\r
1266                                                 {\r
1267                                                         if(RemotePos->Node == NODE_FILE)\r
1268                                                         {\r
1269                                                                 FileTimeToLocalFileTime(&LocalPos->Time, &TmpFtimeL);\r
1270                                                                 FileTimeToLocalFileTime(&RemotePos->Time, &TmpFtimeR);\r
1271                                                                 if((RemotePos->InfoExist & FINFO_TIME) == 0)\r
1272                                                                 {\r
1273                                                                         FileTimeToSystemTime(&TmpFtimeL, &TmpStime);\r
1274                                                                         TmpStime.wHour = 0;\r
1275                                                                         TmpStime.wMinute = 0;\r
1276                                                                         TmpStime.wSecond = 0;\r
1277                                                                         TmpStime.wMilliseconds = 0;\r
1278                                                                         SystemTimeToFileTime(&TmpStime, &TmpFtimeL);\r
1279 \r
1280                                                                         FileTimeToSystemTime(&TmpFtimeR, &TmpStime);\r
1281                                                                         TmpStime.wHour = 0;\r
1282                                                                         TmpStime.wMinute = 0;\r
1283                                                                         TmpStime.wSecond = 0;\r
1284                                                                         TmpStime.wMilliseconds = 0;\r
1285                                                                         SystemTimeToFileTime(&TmpStime, &TmpFtimeR);\r
1286                                                                 }\r
1287                                                                 RemotePos->Attr = NO;\r
1288                                                                 if(CompareFileTime(&TmpFtimeL, &TmpFtimeR) <= 0)\r
1289                                                                         LocalPos->Attr = NO;\r
1290                                                         }\r
1291                                                 }\r
1292                                         }\r
1293 \r
1294                                         LocalPos = LocalPos->Next;\r
1295                                 }\r
1296                                 else\r
1297                                 {\r
1298                                         if(LocalPos->Node == NODE_FILE)\r
1299                                         {\r
1300                                                 LocalPos->Attr = NO;\r
1301                                                 LocalPos = LocalPos->Next;\r
1302                                         }\r
1303                                         else\r
1304                                         {\r
1305                                                 LocalPos->Attr = NO;\r
1306                                                 Level = AskDirLevel(LocalPos->File);\r
1307                                                 LocalPos = LocalPos->Next;\r
1308                                                 while(LocalPos != NULL)\r
1309                                                 {\r
1310                                                         if((LocalPos->Node == NODE_DIR) &&\r
1311                                                            (AskDirLevel(LocalPos->File) <= Level))\r
1312                                                         {\r
1313                                                                 break;\r
1314                                                         }\r
1315                                                         LocalPos->Attr = NO;\r
1316                                                         LocalPos = LocalPos->Next;\r
1317                                                 }\r
1318                                         }\r
1319                                 }\r
1320                         }\r
1321 \r
1322                         DispMirrorFiles(LocalListBase, RemoteListBase);\r
1323 \r
1324                         /*===== 削除/アップロード =====*/\r
1325 \r
1326                         RemotePos = RemoteListBase;\r
1327                         while(RemotePos != NULL)\r
1328                         {\r
1329                                 if((RemotePos->Attr == YES) && (RemotePos->Node == NODE_FILE))\r
1330                                 {\r
1331                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1332                                         SetSlashTail(Pkt.RemoteFile);\r
1333                                         strcat(Pkt.RemoteFile, RemotePos->File);\r
1334                                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
1335                                         strcpy(Pkt.LocalFile, "");\r
1336                                         strcpy(Pkt.Cmd, "R-DELE ");\r
1337                                         AddTmpTransFileList(&Pkt, &Base);\r
1338                                 }\r
1339                                 RemotePos = RemotePos->Next;\r
1340                         }\r
1341                         MirrorDeleteAllDir(RemoteListBase, &Pkt, &Base);\r
1342 \r
1343                         LocalPos = LocalListBase;\r
1344                         while(LocalPos != NULL)\r
1345                         {\r
1346                                 if(LocalPos->Attr == YES)\r
1347                                 {\r
1348                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1349                                         SetSlashTail(Pkt.RemoteFile);\r
1350                                         Cat = strchr(Pkt.RemoteFile, NUL);\r
1351                                         strcat(Pkt.RemoteFile, LocalPos->File);\r
1352 \r
1353                                         if(MirrorFnameCnv == YES)\r
1354                                                 _mbslwr(Cat);\r
1355 \r
1356                                         ReplaceAll(Pkt.RemoteFile, '\\', '/');\r
1357 \r
1358                                         if(LocalPos->Node == NODE_DIR)\r
1359                                         {\r
1360                                                 strcpy(Pkt.LocalFile, "");\r
1361                                                 strcpy(Pkt.Cmd, "R-MKD ");\r
1362                                                 AddTmpTransFileList(&Pkt, &Base);\r
1363                                         }\r
1364                                         else if(LocalPos->Node == NODE_FILE)\r
1365                                         {\r
1366                                                 AskLocalCurDir(Pkt.LocalFile, FMAX_PATH);\r
1367                                                 SetYenTail(Pkt.LocalFile);\r
1368                                                 strcat(Pkt.LocalFile, LocalPos->File);\r
1369                                                 ReplaceAll(Pkt.LocalFile, '/', '\\');\r
1370 \r
1371                                                 strcpy(Pkt.Cmd, "STOR ");\r
1372                                                 Pkt.Type = AskTransferTypeAssoc(Pkt.LocalFile, AskTransferType());\r
1373                                                 Pkt.Size = 0;\r
1374                                                 Pkt.Time = LocalPos->Time;\r
1375                                                 Pkt.Attr = AskUpLoadFileAttr(Pkt.RemoteFile);\r
1376                                                 Pkt.KanjiCode = AskHostKanjiCode();\r
1377                                                 // UTF-8対応\r
1378                                                 Pkt.KanjiCodeDesired = AskLocalKanjiCode();\r
1379                                                 Pkt.KanaCnv = AskHostKanaCnv();\r
1380                                                 Pkt.Mode = EXIST_OVW;\r
1381                                                 AddTmpTransFileList(&Pkt, &Base);\r
1382                                         }\r
1383                                 }\r
1384                                 LocalPos = LocalPos->Next;\r
1385                         }\r
1386 \r
1387                         if((Notify == YES) ||\r
1388                            (DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(mirror_notify_dlg), GetMainHwnd(), MirrorDispListCallBack, (LPARAM)&Base) == YES))\r
1389                         {\r
1390                                 if(AskNoFullPathMode() == YES)\r
1391                                 {\r
1392                                         strcpy(Pkt.Cmd, "SETCUR");\r
1393                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1394                                         AddTransFileList(&Pkt);\r
1395                                 }\r
1396                                 AppendTransFileList(Base);\r
1397 \r
1398                                 if(AskNoFullPathMode() == YES)\r
1399                                 {\r
1400                                         strcpy(Pkt.Cmd, "BACKCUR");\r
1401                                         AskRemoteCurDir(Pkt.RemoteFile, FMAX_PATH);\r
1402                                         AddTransFileList(&Pkt);\r
1403                                 }\r
1404 \r
1405                                 strcpy(Pkt.Cmd, "GOQUIT");\r
1406                                 AddTransFileList(&Pkt);\r
1407                         }\r
1408                         else\r
1409                                 EraseTmpTransFileList(&Base);\r
1410 \r
1411                         DeleteFileList(&LocalListBase);\r
1412                         DeleteFileList(&RemoteListBase);\r
1413 \r
1414                         GoForwardTransWindow();\r
1415                 }\r
1416 \r
1417                 EnableUserOpe();\r
1418         }\r
1419         return;\r
1420 }\r
1421 \r
1422 \r
1423 /*----- ミラーリング時のホスト側のフォルダ削除 --------------------------------\r
1424 *\r
1425 *       Parameter\r
1426 *               FILELIST *Base : ファイルリスト\r
1427 *               TRANSPACKET *Pkt : \r
1428 *               TRANSPACKET **Base : \r
1429 *\r
1430 *       Return Value\r
1431 *               なし\r
1432 *----------------------------------------------------------------------------*/\r
1433 \r
1434 static void MirrorDeleteAllDir(FILELIST *Remote, TRANSPACKET *Pkt, TRANSPACKET **Base)\r
1435 {\r
1436         while(Remote != NULL)\r
1437         {\r
1438                 if(Remote->Node == NODE_DIR)\r
1439                 {\r
1440                         MirrorDeleteAllDir(Remote->Next, Pkt, Base);\r
1441 \r
1442                         if(Remote->Attr == YES)\r
1443                         {\r
1444                                 AskRemoteCurDir(Pkt->RemoteFile, FMAX_PATH);\r
1445                                 SetSlashTail(Pkt->RemoteFile);\r
1446                                 strcat(Pkt->RemoteFile, Remote->File);\r
1447                                 ReplaceAll(Pkt->RemoteFile, '\\', '/');\r
1448                                 strcpy(Pkt->LocalFile, "");\r
1449                                 strcpy(Pkt->Cmd, "R-RMD ");\r
1450                                 AddTmpTransFileList(Pkt, Base);\r
1451                         }\r
1452                         break;\r
1453                 }\r
1454                 Remote = Remote->Next;\r
1455         }\r
1456         return;\r
1457 }\r
1458 \r
1459 \r
1460 /*----- ミラーリングアップロード開始確認ウインドウのコールバック --------------\r
1461 *\r
1462 *       Parameter\r
1463 *               HWND hDlg : ウインドウハンドル\r
1464 *               UINT message : メッセージ番号\r
1465 *               WPARAM wParam : メッセージの WPARAM 引数\r
1466 *               LPARAM lParam : メッセージの LPARAM 引数\r
1467 *\r
1468 *       Return Value\r
1469 *               BOOL TRUE/FALSE\r
1470 *----------------------------------------------------------------------------*/\r
1471 \r
1472 static BOOL CALLBACK MirrorNotifyCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1473 {\r
1474         static int Mode;\r
1475 \r
1476         switch (iMessage)\r
1477         {\r
1478                 case WM_INITDIALOG :\r
1479                         Mode = lParam;\r
1480                         return(TRUE);\r
1481 \r
1482                 case WM_COMMAND :\r
1483                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1484                         {\r
1485                                 case IDOK :\r
1486                                         EndDialog(hDlg, YES);\r
1487                                         break;\r
1488 \r
1489                                 case IDCANCEL :\r
1490                                         EndDialog(hDlg, NO);\r
1491                                         break;\r
1492 \r
1493                                 case MIRRORUP_DISP :\r
1494                                         EndDialog(hDlg, YES_LIST);\r
1495                                         break;\r
1496 \r
1497                                 case IDHELP :\r
1498                                         if(Mode == 0)\r
1499                                                 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000013);\r
1500                                         else\r
1501                                                 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000012);\r
1502                         }\r
1503             return(TRUE);\r
1504         }\r
1505         return(FALSE);\r
1506 }\r
1507 \r
1508 \r
1509 /*----- ミラーリングアップロード処理内容確認ウインドウのコールバック ----------\r
1510 *\r
1511 *       Parameter\r
1512 *               HWND hDlg : ウインドウハンドル\r
1513 *               UINT message : メッセージ番号\r
1514 *               WPARAM wParam : メッセージの WPARAM 引数\r
1515 *               LPARAM lParam : メッセージの LPARAM 引数\r
1516 *\r
1517 *       Return Value\r
1518 *               BOOL TRUE/FALSE\r
1519 *----------------------------------------------------------------------------*/\r
1520 \r
1521 static BOOL CALLBACK MirrorDispListCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1522 {\r
1523         static DIALOGSIZE DlgSize = {\r
1524                 { MIRROR_DEL, MIRROR_SIZEGRIP, -1 },\r
1525                 { IDOK, IDCANCEL, IDHELP, MIRROR_DEL, MIRROR_COPYNUM, MIRROR_MAKENUM, MIRROR_DELNUM, MIRROR_SIZEGRIP, -1 },\r
1526                 { MIRROR_LIST, -1 },\r
1527                 { 0, 0 },\r
1528                 { 0, 0 }\r
1529         };\r
1530 \r
1531         static TRANSPACKET **Base;\r
1532         TRANSPACKET *Pos;\r
1533         char Tmp[FMAX_PATH+1+6];\r
1534         int Num;\r
1535         int *List;\r
1536 \r
1537         switch (iMessage)\r
1538         {\r
1539                 case WM_INITDIALOG :\r
1540                         Base = (TRANSPACKET **)lParam;\r
1541                         Pos = *Base;\r
1542                         while(Pos != NULL)\r
1543                         {\r
1544                                 strcpy(Tmp, "");\r
1545                                 if((strncmp(Pos->Cmd, "R-DELE", 6) == 0) ||\r
1546                                    (strncmp(Pos->Cmd, "R-RMD", 5) == 0))\r
1547                                         sprintf(Tmp, MSGJPN052, Pos->RemoteFile);\r
1548                                 else if(strncmp(Pos->Cmd, "R-MKD", 5) == 0)\r
1549                                         sprintf(Tmp, MSGJPN053, Pos->RemoteFile);\r
1550                                 else if(strncmp(Pos->Cmd, "STOR", 4) == 0)\r
1551                                         sprintf(Tmp, MSGJPN054, Pos->RemoteFile);\r
1552                                 else if((strncmp(Pos->Cmd, "L-DELE", 6) == 0) ||\r
1553                                                 (strncmp(Pos->Cmd, "L-RMD", 5) == 0))\r
1554                                         sprintf(Tmp, MSGJPN055, Pos->LocalFile);\r
1555                                 else if(strncmp(Pos->Cmd, "L-MKD", 5) == 0)\r
1556                                         sprintf(Tmp, MSGJPN056, Pos->LocalFile);\r
1557                                 else if(strncmp(Pos->Cmd, "RETR", 4) == 0)\r
1558                                         sprintf(Tmp, MSGJPN057, Pos->LocalFile);\r
1559 \r
1560                                 if(strlen(Tmp) > 0)\r
1561                                         SendDlgItemMessage(hDlg, MIRROR_LIST, LB_ADDSTRING, 0, (LPARAM)Tmp);\r
1562                                 Pos = Pos->Next;\r
1563                         }\r
1564                         CountMirrorFiles(hDlg, *Base);\r
1565                         DlgSizeInit(hDlg, &DlgSize, &MirrorDlgSize);\r
1566                         EnableWindow(GetDlgItem(hDlg, MIRROR_DEL), FALSE);\r
1567                         return(TRUE);\r
1568 \r
1569                 case WM_COMMAND :\r
1570                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1571                         {\r
1572                                 case IDOK :\r
1573                                         AskDlgSize(hDlg, &DlgSize, &MirrorDlgSize);\r
1574                                         EndDialog(hDlg, YES);\r
1575                                         break;\r
1576 \r
1577                                 case IDCANCEL :\r
1578                                         AskDlgSize(hDlg, &DlgSize, &MirrorDlgSize);\r
1579                                         EndDialog(hDlg, NO);\r
1580                                         break;\r
1581 \r
1582                                 case MIRROR_DEL :\r
1583                                         Num = SendDlgItemMessage(hDlg, MIRROR_LIST, LB_GETSELCOUNT, 0, 0);\r
1584                                         if((List = malloc(Num * sizeof(int))) != NULL)\r
1585                                         {\r
1586                                                 Num = SendDlgItemMessage(hDlg, MIRROR_LIST, LB_GETSELITEMS, Num, (LPARAM)List);\r
1587                                                 for(Num--; Num >= 0; Num--)\r
1588                                                 {\r
1589                                                         if(RemoveTmpTransFileListItem(Base, List[Num]) == FFFTP_SUCCESS)\r
1590                                                                 SendDlgItemMessage(hDlg, MIRROR_LIST, LB_DELETESTRING, List[Num], 0);\r
1591                                                         else\r
1592                                                                 MessageBeep(-1);\r
1593                                                 }\r
1594                                                 free(List);\r
1595                                                 CountMirrorFiles(hDlg, *Base);\r
1596                                         }\r
1597                                         break;\r
1598 \r
1599                                 case MIRROR_LIST :\r
1600                                         switch(GET_WM_COMMAND_CMD(wParam, lParam))\r
1601                                         {\r
1602                                                 case LBN_SELCHANGE :\r
1603                                                         if(SendDlgItemMessage(hDlg, MIRROR_LIST, LB_GETSELCOUNT, 0, 0) > 0)\r
1604                                                                 EnableWindow(GetDlgItem(hDlg, MIRROR_DEL), TRUE);\r
1605                                                         else\r
1606                                                                 EnableWindow(GetDlgItem(hDlg, MIRROR_DEL), FALSE);\r
1607                                                         break;\r
1608                                         }\r
1609                                         break;\r
1610 \r
1611                                 case IDHELP :\r
1612                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000012);\r
1613                         }\r
1614             return(TRUE);\r
1615 \r
1616                 case WM_SIZING :\r
1617                         DlgSizeChange(hDlg, &DlgSize, (RECT *)lParam, (int)wParam);\r
1618                     return(TRUE);\r
1619         }\r
1620         return(FALSE);\r
1621 }\r
1622 \r
1623 \r
1624 /*----- ミラーリングで転送/削除するファイルの数を数えダイアログに表示---------\r
1625 *\r
1626 *       Parameter\r
1627 *               HWND hWnd : \r
1628 *               TRANSPACKET *Pkt : \r
1629 *\r
1630 *       Return Value\r
1631 *               なし\r
1632 *----------------------------------------------------------------------------*/\r
1633 \r
1634 static void CountMirrorFiles(HWND hDlg, TRANSPACKET *Pkt)\r
1635 {\r
1636         char Tmp[80];\r
1637         int Del;\r
1638         int Make;\r
1639         int Copy;\r
1640 \r
1641         Del = 0;\r
1642         Make = 0;\r
1643         Copy = 0;\r
1644         while(Pkt != NULL)\r
1645         {\r
1646                 if((strncmp(Pkt->Cmd, "R-DELE", 6) == 0) ||\r
1647                    (strncmp(Pkt->Cmd, "R-RMD", 5) == 0) ||\r
1648                    (strncmp(Pkt->Cmd, "L-DELE", 6) == 0) ||\r
1649                    (strncmp(Pkt->Cmd, "L-RMD", 5) == 0))\r
1650                 {\r
1651                         Del += 1;\r
1652                 }\r
1653                 else if((strncmp(Pkt->Cmd, "R-MKD", 5) == 0) ||\r
1654                                 (strncmp(Pkt->Cmd, "L-MKD", 5) == 0))\r
1655                 {\r
1656                         Make += 1;\r
1657                 }\r
1658                 else if((strncmp(Pkt->Cmd, "STOR", 4) == 0) ||\r
1659                                 (strncmp(Pkt->Cmd, "RETR", 4) == 0))\r
1660                 {\r
1661                         Copy += 1;\r
1662                 }\r
1663                 Pkt = Pkt->Next;\r
1664         }\r
1665 \r
1666         if(Copy != 0)\r
1667                 sprintf(Tmp, MSGJPN058, Copy);\r
1668         else\r
1669                 sprintf(Tmp, MSGJPN059);\r
1670         SendDlgItemMessage(hDlg, MIRROR_COPYNUM, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1671 \r
1672         if(Make != 0)\r
1673                 sprintf(Tmp, MSGJPN060, Make);\r
1674         else\r
1675                 sprintf(Tmp, MSGJPN061);\r
1676         SendDlgItemMessage(hDlg, MIRROR_MAKENUM, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1677 \r
1678         if(Del != 0)\r
1679                 sprintf(Tmp, MSGJPN062, Del);\r
1680         else\r
1681                 sprintf(Tmp, MSGJPN063);\r
1682         SendDlgItemMessage(hDlg, MIRROR_DELNUM, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1683 \r
1684         return;\r
1685 }\r
1686 \r
1687 \r
1688 \r
1689 \r
1690 /*----- ミラーリングで転送/削除しないファイルかどうかを返す ------------------\r
1691 *\r
1692 *       Parameter\r
1693 *               char Fname : ファイル名\r
1694 *               int Mode : モード\r
1695 *                       0=転送しないファイル, 1=削除しないファイル\r
1696 *\r
1697 *       Return Value\r
1698 *               int ステータス\r
1699 *                       YES=転送・削除しない/NO\r
1700 *----------------------------------------------------------------------------*/\r
1701 \r
1702 static int AskMirrorNoTrn(char *Fname, int Mode)\r
1703 {\r
1704         int Ret;\r
1705         char *Tbl;\r
1706 \r
1707         Tbl = MirrorNoTrn;\r
1708         if(Mode == 1)\r
1709                 Tbl = MirrorNoDel;\r
1710 \r
1711         Ret = NO;\r
1712         if(StrMultiLen(Tbl) > 0)\r
1713         {\r
1714                 Fname = GetFileName(Fname);\r
1715                 while(*Tbl != NUL)\r
1716                 {\r
1717                         if(CheckFname(Fname, Tbl) == FFFTP_SUCCESS)\r
1718                         {\r
1719                                 Ret = YES;\r
1720                                 break;\r
1721                         }\r
1722                         Tbl += strlen(Tbl) + 1;\r
1723                 }\r
1724         }\r
1725         return(Ret);\r
1726 }\r
1727 \r
1728 \r
1729 /*----- アップロードするファイルの属性を返す ----------------------------------\r
1730 *\r
1731 *       Parameter\r
1732 *               char Fname : ファイル名\r
1733 *\r
1734 *       Return Value\r
1735 *               int 属性 (-1=設定なし)\r
1736 *----------------------------------------------------------------------------*/\r
1737 \r
1738 static int AskUpLoadFileAttr(char *Fname)\r
1739 {\r
1740         int Ret;\r
1741         int Sts;\r
1742         char *Tbl;\r
1743 \r
1744         Tbl = DefAttrList;\r
1745         Fname = GetFileName(Fname);\r
1746         Ret = -1;\r
1747         while(*Tbl != NUL)\r
1748         {\r
1749                 Sts = CheckFname(Fname, Tbl);\r
1750                 Tbl += strlen(Tbl) + 1;\r
1751 \r
1752                 if((Sts == FFFTP_SUCCESS) && (*Tbl != NUL))\r
1753                 {\r
1754                         Ret = xtoi(Tbl);\r
1755                         break;\r
1756                 }\r
1757                 Tbl += strlen(Tbl) + 1;\r
1758         }\r
1759         return(Ret);\r
1760 }\r
1761 \r
1762 \r
1763 /*----- ホストに同じ名前のファイルがないかチェック- ---------------------------a\r
1764 *\r
1765 *       Parameter\r
1766 *               TRANSPACKET *Pkt : 転送ファイル情報\r
1767 *               FILELIST *ListList : \r
1768 *\r
1769 *       Return Value\r
1770 *               int 処理方法\r
1771 *                       EXIST_OVW/EXIST_UNIQUE/EXIST_IGNORE\r
1772 *\r
1773 *       Note\r
1774 *               Pkt.ExistSize, UpExistMode、ExistNotify が変更される\r
1775 *----------------------------------------------------------------------------*/\r
1776 \r
1777 static int CheckRemoteFile(TRANSPACKET *Pkt, FILELIST *ListList)\r
1778 {\r
1779         int Ret;\r
1780         FILELIST *Exist;\r
1781 \r
1782         Ret = EXIST_OVW;\r
1783         Pkt->ExistSize = 0;\r
1784         if(SendMode != TRANS_OVW)\r
1785         {\r
1786                 if((Exist = SearchFileList(GetFileName(Pkt->RemoteFile), ListList, COMP_STRICT)) != NULL)\r
1787                 {\r
1788                         Pkt->ExistSize = Exist->Size;\r
1789 \r
1790                         if(ExistNotify == YES)\r
1791                         {\r
1792                                 SoundPlay(SND_ERROR);\r
1793                                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(up_exist_dlg), GetMainHwnd(), UpExistDialogCallBack, (LPARAM)Pkt) == NO)\r
1794                                         Ret = EXIST_ABORT;\r
1795                                 else\r
1796                                         Ret = UpExistMode;\r
1797                         }\r
1798                         else\r
1799                                 Ret = UpExistMode;\r
1800 \r
1801                         if(Ret == EXIST_NEW)\r
1802                         {\r
1803                                 /*ファイル日付チェック */\r
1804                                 if(CompareFileTime(&Exist->Time, &Pkt->Time) < 0)\r
1805                                         Ret = EXIST_OVW;\r
1806                                 else\r
1807                                         Ret = EXIST_IGNORE;\r
1808                         }\r
1809                 }\r
1810         }\r
1811         return(Ret);\r
1812 }\r
1813 \r
1814 \r
1815 /*----- ホストに同じ名前のファイルがある時の確認ダイアログのコールバック ------\r
1816 *\r
1817 *       Parameter\r
1818 *               HWND hDlg : ウインドウハンドル\r
1819 *               UINT message : メッセージ番号\r
1820 *               WPARAM wParam : メッセージの WPARAM 引数\r
1821 *               LPARAM lParam : メッセージの LPARAM 引数\r
1822 *\r
1823 *       Return Value\r
1824 *               BOOL TRUE/FALSE\r
1825 *----------------------------------------------------------------------------*/\r
1826 \r
1827 static BOOL CALLBACK UpExistDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1828 {\r
1829         static TRANSPACKET *Pkt;\r
1830         static const RADIOBUTTON UpExistButton[] = {\r
1831                 { UP_EXIST_OVW, EXIST_OVW },\r
1832                 { UP_EXIST_NEW, EXIST_NEW },\r
1833                 { UP_EXIST_RESUME, EXIST_RESUME },\r
1834                 { UP_EXIST_UNIQUE, EXIST_UNIQUE },\r
1835                 { UP_EXIST_IGNORE, EXIST_IGNORE }\r
1836         };\r
1837         #define UPEXISTBUTTONS  (sizeof(UpExistButton)/sizeof(RADIOBUTTON))\r
1838 \r
1839         switch (iMessage)\r
1840         {\r
1841                 case WM_INITDIALOG :\r
1842                         Pkt = (TRANSPACKET *)lParam;\r
1843                         SendDlgItemMessage(hDlg, UP_EXIST_NAME, EM_LIMITTEXT, FMAX_PATH, 0);\r
1844                         SendDlgItemMessage(hDlg, UP_EXIST_NAME, WM_SETTEXT, 0, (LPARAM)Pkt->RemoteFile);\r
1845 \r
1846                         if((Pkt->Type == TYPE_A) || (Pkt->ExistSize <= 0))\r
1847                                 EnableWindow(GetDlgItem(hDlg, UP_EXIST_RESUME), FALSE);\r
1848 \r
1849                         SetRadioButtonByValue(hDlg, UpExistMode, UpExistButton, UPEXISTBUTTONS);\r
1850                         return(TRUE);\r
1851 \r
1852                 case WM_COMMAND :\r
1853                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1854                         {\r
1855                                 case IDOK_ALL :\r
1856                                         ExistNotify = NO;\r
1857                                         /* ここに break はない */\r
1858 \r
1859                                 case IDOK :\r
1860                                         UpExistMode = AskRadioButtonValue(hDlg, UpExistButton, UPEXISTBUTTONS);\r
1861                                         SendDlgItemMessage(hDlg, UP_EXIST_NAME, WM_GETTEXT, FMAX_PATH, (LPARAM)Pkt->RemoteFile);\r
1862                                         EndDialog(hDlg, YES);\r
1863                                         break;\r
1864 \r
1865                                 case IDCANCEL :\r
1866 //                                      Pkt->Abort = ABORT_USER;\r
1867 //                                      UpExistMode = EXIST_IGNORE;\r
1868                                         EndDialog(hDlg, NO);\r
1869                                         break;\r
1870 \r
1871                                 case IDHELP :\r
1872                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000011);\r
1873                                         break;\r
1874                         }\r
1875             return(TRUE);\r
1876         }\r
1877         return(FALSE);\r
1878 }\r
1879 \r
1880 \r
1881 /*----- アップロード/ダウンロードファイル名入力ダイアログのコールバック ------\r
1882 *\r
1883 *       Parameter\r
1884 *               HWND hDlg : ウインドウハンドル\r
1885 *               UINT message : メッセージ番号\r
1886 *               WPARAM wParam : メッセージの WPARAM 引数\r
1887 *               LPARAM lParam : メッセージの LPARAM 引数\r
1888 *\r
1889 *       Return Value\r
1890 *               BOOL TRUE/FALSE\r
1891 *----------------------------------------------------------------------------*/\r
1892 \r
1893 static BOOL CALLBACK UpDownAsDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1894 {\r
1895         switch (iMessage)\r
1896         {\r
1897                 case WM_INITDIALOG :\r
1898                         if(CurWin == WIN_LOCAL)\r
1899                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN064);\r
1900                         else\r
1901                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN065);\r
1902 \r
1903                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, EM_LIMITTEXT, FMAX_PATH, 0);\r
1904                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, WM_SETTEXT, 0, (LPARAM)TmpString);\r
1905                         SendDlgItemMessage(hDlg, UPDOWNAS_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
1906                         return(TRUE);\r
1907 \r
1908                 case WM_COMMAND :\r
1909                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1910                         {\r
1911                                 case IDOK :\r
1912                                         SendDlgItemMessage(hDlg, UPDOWNAS_NEW, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpString);\r
1913                                         EndDialog(hDlg, YES);\r
1914                                         break;\r
1915 \r
1916                                 case UPDOWNAS_STOP :\r
1917                                         EndDialog(hDlg, NO_ALL);\r
1918                                         break;\r
1919                         }\r
1920             return(TRUE);\r
1921         }\r
1922         return(FALSE);\r
1923 }\r
1924 \r
1925 \r
1926 /*----- ファイル一覧で指定されたファイルを削除する ----------------------------\r
1927 *\r
1928 *       Parameter\r
1929 *               なし\r
1930 *\r
1931 *       Return Value\r
1932 *               なし\r
1933 *----------------------------------------------------------------------------*/\r
1934 \r
1935 void DeleteProc(void)\r
1936 {\r
1937         int Win;\r
1938         FILELIST *FileListBase;\r
1939         FILELIST *Pos;\r
1940         int DelFlg;\r
1941         int Sts;\r
1942         char CurDir[FMAX_PATH+1];\r
1943         char Tmp[FMAX_PATH+1];\r
1944 \r
1945         Sts = YES;\r
1946         AskRemoteCurDir(CurDir, FMAX_PATH);\r
1947         FileListBase = NULL;\r
1948         if(GetFocus() == GetLocalHwnd())\r
1949         {\r
1950                 Win = WIN_LOCAL;\r
1951                 MakeSelectedFileList(Win, NO, NO, &FileListBase, &CancelFlg);\r
1952         }\r
1953         else\r
1954         {\r
1955                 Win = WIN_REMOTE;\r
1956                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1957                         MakeSelectedFileList(Win, YES, NO, &FileListBase, &CancelFlg);\r
1958                 else\r
1959                         Sts = NO;\r
1960         }\r
1961 \r
1962         if(Sts == YES)\r
1963         {\r
1964                 DisableUserOpe();\r
1965 \r
1966                 DelFlg = NO;\r
1967                 Sts = NO;\r
1968                 Pos = FileListBase;\r
1969                 while(Pos != NULL)\r
1970                 {\r
1971                         if(Pos->Node == NODE_FILE)\r
1972                         {\r
1973                                 DelNotifyAndDo(Pos, Win, &Sts, &DelFlg, CurDir);\r
1974                                 if(Sts == NO_ALL)\r
1975                                         break;\r
1976                         }\r
1977                         Pos = Pos->Next;\r
1978                 }\r
1979 \r
1980                 if(Sts != NO_ALL)\r
1981                         DeleteAllDir(FileListBase, Win, &Sts, &DelFlg, CurDir);\r
1982 \r
1983                 if(Win == WIN_REMOTE)\r
1984                 {\r
1985                         AskRemoteCurDir(Tmp, FMAX_PATH);\r
1986                         if(strcmp(Tmp, CurDir) != 0)\r
1987                                 DoCWD(Tmp, NO, NO, NO);\r
1988                 }\r
1989 \r
1990                 DeleteFileList(&FileListBase);\r
1991 \r
1992                 if(DelFlg == YES)\r
1993                 {\r
1994                         if(Win == WIN_LOCAL)\r
1995                                 GetLocalDirForWnd();\r
1996                         else\r
1997                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
1998                 }\r
1999 \r
2000                 EnableUserOpe();\r
2001         }\r
2002         return;\r
2003 }\r
2004 \r
2005 \r
2006 /*----- サブディレクトリ以下を全て削除する ------------------------------------\r
2007 *\r
2008 *       Parameter\r
2009 *               FILELIST *Dt : 削除するファイルのリスト\r
2010 *               int Win : ウインドウ番号 (WIN_xxx)\r
2011 *               int *Sw : 操作方法 (YES/NO/YES_ALL/NO_ALL)\r
2012 *               int *Flg : ファイルを削除したかどうかのフラグ (YES/NO)\r
2013 *               char *CurDir : カレントディレクトリ\r
2014 *\r
2015 *       Return Value\r
2016 *               なし\r
2017 *----------------------------------------------------------------------------*/\r
2018 \r
2019 static void DeleteAllDir(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir)\r
2020 {\r
2021         while(Dt != NULL)\r
2022         {\r
2023                 if(Dt->Node == NODE_DIR)\r
2024                 {\r
2025                         DeleteAllDir(Dt->Next, Win, Sw, Flg, CurDir);\r
2026                         if(*Sw == NO_ALL)\r
2027                                 break;\r
2028 \r
2029                         DelNotifyAndDo(Dt, Win, Sw, Flg, CurDir);\r
2030                         break;\r
2031                 }\r
2032                 Dt = Dt->Next;\r
2033         }\r
2034         return;\r
2035 }\r
2036 \r
2037 \r
2038 /*----- 削除するかどうかの確認と削除実行 --------------------------------------\r
2039 *\r
2040 *       Parameter\r
2041 *               FILELIST *Dt : 削除するファイルのリスト\r
2042 *               int Win : ウインドウ番号 (WIN_xxx)\r
2043 *               int *Sw : 操作方法 (YES/NO/YES_ALL/NO_ALL)\r
2044 *               int *Flg : ファイルを削除したかどうかのフラグ (YES/NO)\r
2045 *               char *CurDir : カレントディレクトリ\r
2046 *\r
2047 *       Return Value\r
2048 *               なし\r
2049 *----------------------------------------------------------------------------*/\r
2050 \r
2051 static void DelNotifyAndDo(FILELIST *Dt, int Win, int *Sw, int *Flg, char *CurDir)\r
2052 {\r
2053         char Path[FMAX_PATH+1];\r
2054 \r
2055         if(Win == WIN_LOCAL)\r
2056         {\r
2057                 AskLocalCurDir(Path, FMAX_PATH);\r
2058                 SetYenTail(Path);\r
2059                 strcat(Path, Dt->File);\r
2060                 ReplaceAll(Path, '/', '\\');\r
2061         }\r
2062         else\r
2063         {\r
2064                 AskRemoteCurDir(Path, FMAX_PATH);\r
2065                 SetSlashTail(Path);\r
2066                 strcat(Path, Dt->File);\r
2067                 ReplaceAll(Path, '\\', '/');\r
2068         }\r
2069 \r
2070         if(*Sw != YES_ALL)\r
2071         {\r
2072                 sprintf(TmpString, "%s", Path);\r
2073 \r
2074                 if(AskHostType() == HTYPE_VMS)\r
2075                         ReformToVMSstylePathName(TmpString);\r
2076 \r
2077                 CurWin = Win;\r
2078                 *Sw = DialogBox(GetFtpInst(), MAKEINTRESOURCE(delete_dlg), GetMainHwnd(), DeleteDialogCallBack);\r
2079         }\r
2080 \r
2081         if((*Sw == YES) || (*Sw == YES_ALL))\r
2082         {\r
2083                 if(Win == WIN_LOCAL)\r
2084                 {\r
2085                         if(Dt->Node == NODE_FILE)\r
2086                                 DoLocalDELE(Path);\r
2087                         else\r
2088                                 DoLocalRMD(Path);\r
2089                         *Flg = YES;\r
2090                 }\r
2091                 else\r
2092                 {\r
2093                         /* フルパスを使わない時のための処理 */\r
2094                         if(ProcForNonFullpath(Path, CurDir, GetMainHwnd(), 0) == FFFTP_FAIL)\r
2095                                 *Sw = NO_ALL;\r
2096 \r
2097                         if(*Sw != NO_ALL)\r
2098                         {\r
2099                                 if(Dt->Node == NODE_FILE)\r
2100                                         DoDELE(Path);\r
2101                                 else\r
2102                                         DoRMD(Path);\r
2103                                 *Flg = YES;\r
2104                         }\r
2105                 }\r
2106         }\r
2107         return;\r
2108 }\r
2109 \r
2110 \r
2111 /*----- ファイル削除ダイアログのコールバック ----------------------------------\r
2112 *\r
2113 *       Parameter\r
2114 *               HWND hDlg : ウインドウハンドル\r
2115 *               UINT message : メッセージ番号\r
2116 *               WPARAM wParam : メッセージの WPARAM 引数\r
2117 *               LPARAM lParam : メッセージの LPARAM 引数\r
2118 *\r
2119 *       Return Value\r
2120 *               BOOL TRUE/FALSE\r
2121 *----------------------------------------------------------------------------*/\r
2122 \r
2123 static BOOL CALLBACK DeleteDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2124 {\r
2125         switch (iMessage)\r
2126         {\r
2127                 case WM_INITDIALOG :\r
2128                         if(CurWin == WIN_LOCAL)\r
2129                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN066);\r
2130                         else\r
2131                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN067);\r
2132                         SendDlgItemMessage(hDlg, DELETE_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2133                         return(TRUE);\r
2134 \r
2135                 case WM_COMMAND :\r
2136                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2137                         {\r
2138                                 case IDOK :\r
2139                                         EndDialog(hDlg, YES);\r
2140                                         break;\r
2141 \r
2142                                 case DELETE_NO :\r
2143                                         EndDialog(hDlg, NO);\r
2144                                         break;\r
2145 \r
2146                                 case DELETE_ALL :\r
2147                                         EndDialog(hDlg, YES_ALL);\r
2148                                         break;\r
2149 \r
2150                                 case IDCANCEL :\r
2151                                         EndDialog(hDlg, NO_ALL);\r
2152                                         break;\r
2153                         }\r
2154             return(TRUE);\r
2155         }\r
2156         return(FALSE);\r
2157 }\r
2158 \r
2159 \r
2160 /*----- ファイル一覧で指定されたファイルの名前を変更する ----------------------\r
2161 *\r
2162 *       Parameter\r
2163 *               なし\r
2164 *\r
2165 *       Return Value\r
2166 *               なし\r
2167 *----------------------------------------------------------------------------*/\r
2168 \r
2169 void RenameProc(void)\r
2170 {\r
2171         int Win;\r
2172         FILELIST *FileListBase;\r
2173         FILELIST *Pos;\r
2174         char New[FMAX_PATH+1];\r
2175         int RenFlg;\r
2176         int Sts;\r
2177 \r
2178         Sts = FFFTP_SUCCESS;\r
2179         if(GetFocus() == GetLocalHwnd())\r
2180                 Win = WIN_LOCAL;\r
2181         else\r
2182         {\r
2183                 Win = WIN_REMOTE;\r
2184                 Sts = CheckClosedAndReconnect();\r
2185         }\r
2186 \r
2187         if(Sts == FFFTP_SUCCESS)\r
2188         {\r
2189                 DisableUserOpe();\r
2190 \r
2191                 FileListBase = NULL;\r
2192                 MakeSelectedFileList(Win, NO, NO, &FileListBase, &CancelFlg);\r
2193 \r
2194                 RenFlg = NO;\r
2195                 Sts = NO;\r
2196                 Pos = FileListBase;\r
2197                 while(Pos != NULL)\r
2198                 {\r
2199                         if((Pos->Node == NODE_FILE) || (Pos->Node == NODE_DIR))\r
2200                         {\r
2201                                 strcpy(TmpString, Pos->File);\r
2202                                 CurWin = Win;\r
2203                                 Sts = DialogBox(GetFtpInst(), MAKEINTRESOURCE(rename_dlg), GetMainHwnd(), RenameDialogCallBack);\r
2204 \r
2205                                 if(Sts == NO_ALL)\r
2206                                         break;\r
2207 \r
2208                                 if((Sts == YES) && (strlen(TmpString) != 0))\r
2209                                 {\r
2210                                         strcpy(New, TmpString);\r
2211                                         if(Win == WIN_LOCAL)\r
2212                                                 DoLocalRENAME(Pos->File, New);\r
2213                                         else\r
2214                                                 DoRENAME(Pos->File, New);\r
2215                                         RenFlg = YES;\r
2216                                 }\r
2217                         }\r
2218                         Pos = Pos->Next;\r
2219                 }\r
2220                 DeleteFileList(&FileListBase);\r
2221 \r
2222                 if(RenFlg == YES)\r
2223                 {\r
2224                         if(Win == WIN_LOCAL)\r
2225                                 GetLocalDirForWnd();\r
2226                         else\r
2227                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2228                 }\r
2229 \r
2230                 EnableUserOpe();\r
2231         }\r
2232         return;\r
2233 }\r
2234 \r
2235 \r
2236 //\r
2237 // リモート側でのファイルの移動(リネーム)を行う\r
2238 //  \r
2239 // RenameProc()をベースに改造。(2007.9.5 yutaka)\r
2240 //\r
2241 void MoveRemoteFileProc(int drop_index)\r
2242 {\r
2243         int Win;\r
2244         FILELIST *FileListBase;\r
2245         FILELIST *Pos;\r
2246         FILELIST Pkt;\r
2247         char New[FMAX_PATH+1];\r
2248         char Old[FMAX_PATH+1];\r
2249         char HostDir[FMAX_PATH+1];\r
2250         int RenFlg;\r
2251         int Sts;\r
2252 \r
2253         if(MoveMode == MOVE_DISABLE)\r
2254         {\r
2255                 return;\r
2256         }\r
2257 \r
2258         AskRemoteCurDir(HostDir, FMAX_PATH);\r
2259 \r
2260         // ドロップ先のフォルダ名を得る\r
2261         GetNodeName(WIN_REMOTE, drop_index, Pkt.File, FMAX_PATH);\r
2262 \r
2263         if(MoveMode == MOVE_DLG)\r
2264         {\r
2265                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(move_notify_dlg), GetRemoteHwnd(), ExeEscTextDialogProc, (LPARAM)Pkt.File) == NO)\r
2266                 {\r
2267                         return;\r
2268                 }\r
2269         }\r
2270 \r
2271         Sts = FFFTP_SUCCESS;\r
2272 #if 0\r
2273         if(GetFocus() == GetLocalHwnd())\r
2274                 Win = WIN_LOCAL;\r
2275         else\r
2276         {\r
2277                 Win = WIN_REMOTE;\r
2278                 Sts = CheckClosedAndReconnect();\r
2279         }\r
2280 #else\r
2281                 Win = WIN_REMOTE;\r
2282                 Sts = CheckClosedAndReconnect();\r
2283 #endif\r
2284 \r
2285         if(Sts == FFFTP_SUCCESS)\r
2286         {\r
2287                 DisableUserOpe();\r
2288 \r
2289                 FileListBase = NULL;\r
2290                 MakeSelectedFileList(Win, NO, NO, &FileListBase, &CancelFlg);\r
2291 \r
2292                 RenFlg = NO;\r
2293                 Sts = NO;\r
2294                 Pos = FileListBase;\r
2295                 while(Pos != NULL)\r
2296                 {\r
2297                         if((Pos->Node == NODE_FILE) || (Pos->Node == NODE_DIR))\r
2298                         {\r
2299                                 strcpy(TmpString, Pos->File);\r
2300                                 CurWin = Win;\r
2301 #if 0\r
2302                                 Sts = DialogBox(GetFtpInst(), MAKEINTRESOURCE(rename_dlg), GetMainHwnd(), RenameDialogCallBack);\r
2303 \r
2304                                 if(Sts == NO_ALL)\r
2305                                         break;\r
2306 #else\r
2307                                 Sts = YES;\r
2308 #endif\r
2309 \r
2310                                 if((Sts == YES) && (strlen(TmpString) != 0))\r
2311                                 {\r
2312                                         // パスの設定(local)\r
2313                                         strncpy_s(Old, sizeof(Old), HostDir, _TRUNCATE);\r
2314                                         strncat_s(Old, sizeof(Old), "/", _TRUNCATE);\r
2315                                         strncat_s(Old, sizeof(Old), Pos->File, _TRUNCATE);\r
2316 \r
2317                                         // パスの設定(remote)\r
2318                                         strncpy_s(New, sizeof(New), HostDir, _TRUNCATE);\r
2319                                         strncat_s(New, sizeof(New), "/", _TRUNCATE);\r
2320                                         strncat_s(New, sizeof(New), Pkt.File, _TRUNCATE);\r
2321                                         strncat_s(New, sizeof(New), "/", _TRUNCATE);\r
2322                                         strncat_s(New, sizeof(New), Pos->File, _TRUNCATE);\r
2323 \r
2324                                         if(Win == WIN_LOCAL)\r
2325                                                 DoLocalRENAME(Old, New);\r
2326                                         else\r
2327                                                 DoRENAME(Old, New);\r
2328                                         RenFlg = YES;\r
2329                                 }\r
2330                         }\r
2331                         Pos = Pos->Next;\r
2332                 }\r
2333                 DeleteFileList(&FileListBase);\r
2334 \r
2335                 if(RenFlg == YES)\r
2336                 {\r
2337                         if(Win == WIN_LOCAL) {\r
2338                                 GetLocalDirForWnd();\r
2339                         } else {\r
2340                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2341 \r
2342                                 strncpy_s(New, sizeof(New), HostDir, _TRUNCATE);\r
2343                                 strncat_s(New, sizeof(New), "/", _TRUNCATE);\r
2344                                 strncat_s(New, sizeof(New), Pkt.File, _TRUNCATE);\r
2345                                 DoCWD(New, YES, YES, YES);\r
2346                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2347                         }\r
2348                 }\r
2349 \r
2350                 EnableUserOpe();\r
2351         }\r
2352         return;\r
2353 }\r
2354 \r
2355 \r
2356 \r
2357 /*----- 新ファイル名入力ダイアログのコールバック ------------------------------\r
2358 *\r
2359 *       Parameter\r
2360 *               HWND hDlg : ウインドウハンドル\r
2361 *               UINT message : メッセージ番号\r
2362 *               WPARAM wParam : メッセージの WPARAM 引数\r
2363 *               LPARAM lParam : メッセージの LPARAM 引数\r
2364 *\r
2365 *       Return Value\r
2366 *               BOOL TRUE/FALSE\r
2367 *----------------------------------------------------------------------------*/\r
2368 \r
2369 static BOOL CALLBACK RenameDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2370 {\r
2371         switch (iMessage)\r
2372         {\r
2373                 case WM_INITDIALOG :\r
2374                         if(CurWin == WIN_LOCAL)\r
2375                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN068);\r
2376                         else\r
2377                                 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)MSGJPN069);\r
2378                         SendDlgItemMessage(hDlg, RENAME_NEW, EM_LIMITTEXT, FMAX_PATH, 0);\r
2379                         SendDlgItemMessage(hDlg, RENAME_NEW, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2380                         SendDlgItemMessage(hDlg, RENAME_TEXT, WM_SETTEXT, 0, (LPARAM)TmpString);\r
2381                         return(TRUE);\r
2382 \r
2383                 case WM_COMMAND :\r
2384                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2385                         {\r
2386                                 case IDOK :\r
2387                                         SendDlgItemMessage(hDlg, RENAME_NEW, WM_GETTEXT, FMAX_PATH, (LPARAM)TmpString);\r
2388                                         EndDialog(hDlg, YES);\r
2389                                         break;\r
2390 \r
2391                                 case IDCANCEL :\r
2392                                         EndDialog(hDlg, NO);\r
2393                                         break;\r
2394 \r
2395                                 case RENAME_STOP :\r
2396                                         EndDialog(hDlg, NO_ALL);\r
2397                                         break;\r
2398                         }\r
2399             return(TRUE);\r
2400         }\r
2401         return(FALSE);\r
2402 }\r
2403 \r
2404 \r
2405 /*----- 新しいディレクトリを作成する ------------------------------------------\r
2406 *\r
2407 *       Parameter\r
2408 *               なし\r
2409 *\r
2410 *       Return Value\r
2411 *               なし\r
2412 *----------------------------------------------------------------------------*/\r
2413 \r
2414 void MkdirProc(void)\r
2415 {\r
2416         int Sts;\r
2417         int Win;\r
2418         char Path[FMAX_PATH+1];\r
2419         char *Title;\r
2420         int Tmp;\r
2421 \r
2422         if(GetFocus() == GetLocalHwnd())\r
2423         {\r
2424                 Win = WIN_LOCAL;\r
2425                 Title = MSGJPN070;\r
2426         }\r
2427         else\r
2428         {\r
2429                 Win = WIN_REMOTE;\r
2430                 Title = MSGJPN071;\r
2431         }\r
2432 \r
2433         strcpy(Path, "");\r
2434         Sts = InputDialogBox(mkdir_dlg, GetMainHwnd(), Title, Path, FMAX_PATH+1, &Tmp, IDH_HELP_TOPIC_0000001);\r
2435 \r
2436         if((Sts == YES) && (strlen(Path) != 0))\r
2437         {\r
2438                 if(Win == WIN_LOCAL)\r
2439                 {\r
2440                         DisableUserOpe();\r
2441                         DoLocalMKD(Path);\r
2442                         GetLocalDirForWnd();\r
2443                         EnableUserOpe();\r
2444                 }\r
2445                 else\r
2446                 {\r
2447                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2448                         {\r
2449                                 DisableUserOpe();\r
2450                                 DoMKD(Path);\r
2451                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2452                                 EnableUserOpe();\r
2453                         }\r
2454                 }\r
2455         }\r
2456         return;\r
2457 }\r
2458 \r
2459 \r
2460 /*----- ヒストリリストを使ったディレクトリの移動 ------------------------------\r
2461 *\r
2462 *       Parameter\r
2463 *               HWND hWnd : コンボボックスのウインドウハンドル\r
2464 *\r
2465 *       Return Value\r
2466 *               なし\r
2467 *----------------------------------------------------------------------------*/\r
2468 \r
2469 void ChangeDirComboProc(HWND hWnd)\r
2470 {\r
2471         char Tmp[FMAX_PATH+1];\r
2472         int i;\r
2473 \r
2474         if((i = SendMessage(hWnd, CB_GETCURSEL, 0, 0)) != CB_ERR)\r
2475         {\r
2476                 SendMessage(hWnd, CB_GETLBTEXT, i, (LPARAM)Tmp);\r
2477 \r
2478                 if(hWnd == GetLocalHistHwnd())\r
2479                 {\r
2480                         DisableUserOpe();\r
2481                         DoLocalCWD(Tmp);\r
2482                         GetLocalDirForWnd();\r
2483                         EnableUserOpe();\r
2484                 }\r
2485                 else\r
2486                 {\r
2487                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2488                         {\r
2489                                 DisableUserOpe();\r
2490                                 if(DoCWD(Tmp, YES, NO, YES) < FTP_RETRY)\r
2491                                         GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2492                                 EnableUserOpe();\r
2493                         }\r
2494                 }\r
2495         }\r
2496         return;\r
2497 }\r
2498 \r
2499 \r
2500 /*----- ブックマークを使ったディレクトリの移動 --------------------------------\r
2501 *\r
2502 *       Parameter\r
2503 *               int MarkID : ブックマークのメニューID\r
2504 *\r
2505 *       Return Value\r
2506 *               なし\r
2507 *----------------------------------------------------------------------------*/\r
2508 \r
2509 void ChangeDirBmarkProc(int MarkID)\r
2510 {\r
2511         char Local[FMAX_PATH+1];\r
2512         char Remote[FMAX_PATH+1];\r
2513         int Sts;\r
2514 \r
2515         Sts = AskBookMarkText(MarkID, Local, Remote, FMAX_PATH+1);\r
2516         if((Sts == BMARK_TYPE_LOCAL) || (Sts == BMARK_TYPE_BOTH))\r
2517         {\r
2518                 DisableUserOpe();\r
2519                 if(DoLocalCWD(Local) == FFFTP_SUCCESS)\r
2520                         GetLocalDirForWnd();\r
2521                 EnableUserOpe();\r
2522         }\r
2523 \r
2524         if((Sts == BMARK_TYPE_REMOTE) || (Sts == BMARK_TYPE_BOTH))\r
2525         {\r
2526                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2527                 {\r
2528                         DisableUserOpe();\r
2529                         if(DoCWD(Remote, YES, NO, YES) < FTP_RETRY)\r
2530                                 GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2531                         EnableUserOpe();\r
2532                 }\r
2533         }\r
2534         return;\r
2535 }\r
2536 \r
2537 \r
2538 /*----- ディレクトリ名を入力してディレクトリの移動 ----------------------------\r
2539 *\r
2540 *       Parameter\r
2541 *               int Win : ウインドウ番号 (WIN_xxx)\r
2542 *\r
2543 *       Return Value\r
2544 *               なし\r
2545 *----------------------------------------------------------------------------*/\r
2546 \r
2547 void ChangeDirDirectProc(int Win)\r
2548 {\r
2549         int Sts;\r
2550         char Path[FMAX_PATH+1];\r
2551         char *Title;\r
2552         int Tmp;\r
2553 \r
2554         if(Win == WIN_LOCAL)\r
2555                 Title = MSGJPN072;\r
2556         else\r
2557                 Title = MSGJPN073;\r
2558 \r
2559         strcpy(Path, "");\r
2560         if(Win == WIN_LOCAL)\r
2561                 Sts = InputDialogBox(chdir_br_dlg, GetMainHwnd(), Title, Path, FMAX_PATH+1, &Tmp, IDH_HELP_TOPIC_0000001);\r
2562         else\r
2563                 Sts = InputDialogBox(chdir_dlg, GetMainHwnd(), Title, Path, FMAX_PATH+1, &Tmp, IDH_HELP_TOPIC_0000001);\r
2564 \r
2565         if((Sts == YES) && (strlen(Path) != 0))\r
2566         {\r
2567                 if(Win == WIN_LOCAL)\r
2568                 {\r
2569                         DisableUserOpe();\r
2570                         DoLocalCWD(Path);\r
2571                         GetLocalDirForWnd();\r
2572                         EnableUserOpe();\r
2573                 }\r
2574                 else\r
2575                 {\r
2576                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2577                         {\r
2578                                 DisableUserOpe();\r
2579                                 if(DoCWD(Path, YES, NO, YES) < FTP_RETRY)\r
2580                                         GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2581                                 EnableUserOpe();\r
2582                         }\r
2583                 }\r
2584         }\r
2585         return;\r
2586 }\r
2587 \r
2588 \r
2589 /*----- Dropされたファイルによるディレクトリの移動 ----------------------------\r
2590 *\r
2591 *       Parameter\r
2592 *               WPARAM wParam : ドロップされたファイルの情報\r
2593 *\r
2594 *       Return Value\r
2595 *               なし\r
2596 *----------------------------------------------------------------------------*/\r
2597 \r
2598 void ChangeDirDropFileProc(WPARAM wParam)\r
2599 {\r
2600         char Path[FMAX_PATH+1];\r
2601 \r
2602         DisableUserOpe();\r
2603         MakeDroppedDir(wParam, Path);\r
2604         DoLocalCWD(Path);\r
2605         GetLocalDirForWnd();\r
2606         EnableUserOpe();\r
2607         return;\r
2608 }\r
2609 \r
2610 \r
2611 /*----- ファイルの属性変更 ----------------------------------------------------\r
2612 *\r
2613 *       Parameter\r
2614 *               なし\r
2615 *\r
2616 *       Return Value\r
2617 *               なし\r
2618 *----------------------------------------------------------------------------*/\r
2619 \r
2620 void ChmodProc(void)\r
2621 {\r
2622         int ChmodFlg;\r
2623         FILELIST *FileListBase;\r
2624         FILELIST *Pos;\r
2625         char Tmp[5];\r
2626         char *Buf;\r
2627         char *BufTmp;\r
2628         int BufLen;\r
2629 \r
2630         if(GetFocus() == GetRemoteHwnd())\r
2631         {\r
2632                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2633                 {\r
2634                         DisableUserOpe();\r
2635                         FileListBase = NULL;\r
2636                         MakeSelectedFileList(WIN_REMOTE, NO, NO, &FileListBase, &CancelFlg);\r
2637                         if(FileListBase != NULL)\r
2638                         {\r
2639                                 sprintf(Tmp, "%03X", FileListBase->Attr);\r
2640                                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(chmod_dlg), GetMainHwnd(), ChmodDialogCallBack, (LPARAM)Tmp) == YES)\r
2641                                 {\r
2642                                         ChmodFlg = NO;\r
2643                                         Pos = FileListBase;\r
2644                                         while(Pos != NULL)\r
2645                                         {\r
2646                                                 if((Pos->Node == NODE_FILE) || (Pos->Node == NODE_DIR))\r
2647                                                 {\r
2648                                                         DoCHMOD(Pos->File, Tmp);\r
2649                                                         ChmodFlg = YES;\r
2650                                                 }\r
2651                                                 Pos = Pos->Next;\r
2652                                         }\r
2653                                         if(ChmodFlg == YES)\r
2654                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
2655                                 }\r
2656                         }\r
2657                         DeleteFileList(&FileListBase);\r
2658                         EnableUserOpe();\r
2659                 }\r
2660         }\r
2661         else if(GetFocus() == GetLocalHwnd())\r
2662         {\r
2663                 DisableUserOpe();\r
2664                 FileListBase = NULL;\r
2665                 MakeSelectedFileList(WIN_LOCAL, NO, NO, &FileListBase, &CancelFlg);\r
2666                 if(FileListBase != NULL)\r
2667                 {\r
2668                         if((Buf = malloc(1)) != NULL)\r
2669                         {\r
2670                                 *Buf = NUL;\r
2671                                 BufLen = 0;\r
2672                                 Pos = FileListBase;\r
2673                                 while(Pos != NULL)\r
2674                                 {\r
2675                                         if((BufTmp = realloc(Buf, BufLen + strlen(Pos->File) + 2)) != NULL)\r
2676                                         {\r
2677                                                 Buf = BufTmp;\r
2678                                                 strcpy(Buf+BufLen, Pos->File);\r
2679                                                 BufLen += strlen(Pos->File) + 1;\r
2680                                         }\r
2681                                         Pos = Pos->Next;\r
2682                                 }\r
2683 \r
2684                                 memset(Buf+BufLen, NUL, 1);\r
2685                                 DispFileProperty(Buf);\r
2686                                 free(Buf);\r
2687                         }\r
2688                 }\r
2689                 DeleteFileList(&FileListBase);\r
2690                 EnableUserOpe();\r
2691         }\r
2692         return;\r
2693 }\r
2694 \r
2695 \r
2696 /*----- 属性変更ダイアログのコールバック --------------------------------------\r
2697 *\r
2698 *       Parameter\r
2699 *               HWND hDlg : ウインドウハンドル\r
2700 *               UINT message : メッセージ番号\r
2701 *               WPARAM wParam : メッセージの WPARAM 引数\r
2702 *               LPARAM lParam : メッセージの LPARAM 引数\r
2703 *\r
2704 *       Return Value\r
2705 *               BOOL TRUE/FALSE\r
2706 *----------------------------------------------------------------------------*/\r
2707 \r
2708 BOOL CALLBACK ChmodDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2709 {\r
2710         char Str[5];\r
2711         static char *Buf;\r
2712         int Tmp;\r
2713 \r
2714         switch (iMessage)\r
2715         {\r
2716                 case WM_INITDIALOG :\r
2717                         Buf = (char *)lParam;\r
2718                         SendDlgItemMessage(hDlg, PERM_NOW, EM_LIMITTEXT, 4, 0);\r
2719                         SendDlgItemMessage(hDlg, PERM_NOW, WM_SETTEXT, 0, (LPARAM)Buf);\r
2720                         SetAttrToDialog(hDlg, xtoi(Buf));\r
2721                         return(TRUE);\r
2722 \r
2723                 case WM_COMMAND :\r
2724                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2725                         {\r
2726                                 case IDOK :\r
2727                                         SendDlgItemMessage(hDlg, PERM_NOW, WM_GETTEXT, 5, (LPARAM)Buf);\r
2728                                         EndDialog(hDlg, YES);\r
2729                                         break;\r
2730 \r
2731                                 case IDCANCEL :\r
2732                                         EndDialog(hDlg, NO);\r
2733                                         break;\r
2734 \r
2735                                 case PERM_O_READ :\r
2736                                 case PERM_O_WRITE :\r
2737                                 case PERM_O_EXEC :\r
2738                                 case PERM_G_READ :\r
2739                                 case PERM_G_WRITE :\r
2740                                 case PERM_G_EXEC :\r
2741                                 case PERM_A_READ :\r
2742                                 case PERM_A_WRITE :\r
2743                                 case PERM_A_EXEC :\r
2744                                         Tmp = GetAttrFromDialog(hDlg);\r
2745                                         sprintf(Str, "%03X", Tmp);\r
2746                                         SendDlgItemMessage(hDlg, PERM_NOW, WM_SETTEXT, 0, (LPARAM)Str);\r
2747                                         break;\r
2748 \r
2749                                 case IDHELP :\r
2750                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000017);\r
2751                                         break;\r
2752                         }\r
2753             return(TRUE);\r
2754         }\r
2755         return(FALSE);\r
2756 }\r
2757 \r
2758 \r
2759 /*----- 属性をダイアログボックスに設定 ----------------------------------------\r
2760 *\r
2761 *       Parameter\r
2762 *               HWND hWnd : ダイアログボックスのウインドウハンドル\r
2763 *               int Attr : 属性\r
2764 *\r
2765 *       Return Value\r
2766 *               なし\r
2767 *----------------------------------------------------------------------------*/\r
2768 \r
2769 static void SetAttrToDialog(HWND hDlg, int Attr)\r
2770 {\r
2771         if(Attr & 0x400)\r
2772                 SendDlgItemMessage(hDlg, PERM_O_READ, BM_SETCHECK, 1, 0);\r
2773         if(Attr & 0x200)\r
2774                 SendDlgItemMessage(hDlg, PERM_O_WRITE, BM_SETCHECK, 1, 0);\r
2775         if(Attr & 0x100)\r
2776                 SendDlgItemMessage(hDlg, PERM_O_EXEC, BM_SETCHECK, 1, 0);\r
2777 \r
2778         if(Attr & 0x40)\r
2779                 SendDlgItemMessage(hDlg, PERM_G_READ, BM_SETCHECK, 1, 0);\r
2780         if(Attr & 0x20)\r
2781                 SendDlgItemMessage(hDlg, PERM_G_WRITE, BM_SETCHECK, 1, 0);\r
2782         if(Attr & 0x10)\r
2783                 SendDlgItemMessage(hDlg, PERM_G_EXEC, BM_SETCHECK, 1, 0);\r
2784 \r
2785         if(Attr & 0x4)\r
2786                 SendDlgItemMessage(hDlg, PERM_A_READ, BM_SETCHECK, 1, 0);\r
2787         if(Attr & 0x2)\r
2788                 SendDlgItemMessage(hDlg, PERM_A_WRITE, BM_SETCHECK, 1, 0);\r
2789         if(Attr & 0x1)\r
2790                 SendDlgItemMessage(hDlg, PERM_A_EXEC, BM_SETCHECK, 1, 0);\r
2791 \r
2792         return;\r
2793 }\r
2794 \r
2795 \r
2796 /*----- ダイアログボックスの内容から属性を取得 --------------------------------\r
2797 *\r
2798 *       Parameter\r
2799 *               HWND hWnd : ダイアログボックスのウインドウハンドル\r
2800 *\r
2801 *       Return Value\r
2802 *               int 属性\r
2803 *----------------------------------------------------------------------------*/\r
2804 \r
2805 static int GetAttrFromDialog(HWND hDlg)\r
2806 {\r
2807         int Ret;\r
2808 \r
2809         Ret = 0;\r
2810 \r
2811         if(SendDlgItemMessage(hDlg, PERM_O_READ, BM_GETCHECK, 0, 0) == 1)\r
2812                 Ret |= 0x400;\r
2813         if(SendDlgItemMessage(hDlg, PERM_O_WRITE, BM_GETCHECK, 0, 0) == 1)\r
2814                 Ret |= 0x200;\r
2815         if(SendDlgItemMessage(hDlg, PERM_O_EXEC, BM_GETCHECK, 0, 0) == 1)\r
2816                 Ret |= 0x100;\r
2817 \r
2818         if(SendDlgItemMessage(hDlg, PERM_G_READ, BM_GETCHECK, 0, 0) == 1)\r
2819                 Ret |= 0x40;\r
2820         if(SendDlgItemMessage(hDlg, PERM_G_WRITE, BM_GETCHECK, 0, 0) == 1)\r
2821                 Ret |= 0x20;\r
2822         if(SendDlgItemMessage(hDlg, PERM_G_EXEC, BM_GETCHECK, 0, 0) == 1)\r
2823                 Ret |= 0x10;\r
2824 \r
2825         if(SendDlgItemMessage(hDlg, PERM_A_READ, BM_GETCHECK, 0, 0) == 1)\r
2826                 Ret |= 0x4;\r
2827         if(SendDlgItemMessage(hDlg, PERM_A_WRITE, BM_GETCHECK, 0, 0) == 1)\r
2828                 Ret |= 0x2;\r
2829         if(SendDlgItemMessage(hDlg, PERM_A_EXEC, BM_GETCHECK, 0, 0) == 1)\r
2830                 Ret |= 0x1;\r
2831 \r
2832         return(Ret);\r
2833 }\r
2834 \r
2835 \r
2836 \r
2837 \r
2838 /*----- 任意のコマンドを送る --------------------------------------------------\r
2839 *\r
2840 *       Parameter\r
2841 *               なし\r
2842 *\r
2843 *       Return Value\r
2844 *               なし\r
2845 *----------------------------------------------------------------------------*/\r
2846 \r
2847 void SomeCmdProc(void)\r
2848 {\r
2849         char Cmd[81];\r
2850         int Tmp;\r
2851         FILELIST *FileListBase;\r
2852 \r
2853         if(GetFocus() == GetRemoteHwnd())\r
2854         {\r
2855                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2856                 {\r
2857                         DisableUserOpe();\r
2858                         FileListBase = NULL;\r
2859                         MakeSelectedFileList(WIN_REMOTE, NO, NO, &FileListBase, &CancelFlg);\r
2860                         memset(Cmd, NUL, 81);\r
2861                         if(FileListBase != NULL)\r
2862                         {\r
2863                                 strncpy(Cmd, FileListBase->File, 80);\r
2864                         }\r
2865                         DeleteFileList(&FileListBase);\r
2866 \r
2867                         if(InputDialogBox(somecmd_dlg, GetMainHwnd(), NULL, Cmd, 81, &Tmp, IDH_HELP_TOPIC_0000023) == YES)\r
2868                         {\r
2869                                 DoQUOTE(Cmd);\r
2870                         }\r
2871                         EnableUserOpe();\r
2872                 }\r
2873         }\r
2874         return;\r
2875 }\r
2876 \r
2877 \r
2878 \r
2879 \r
2880 /*----- ファイル総容量の計算を行う --------------------------------------------\r
2881 *\r
2882 *       Parameter\r
2883 *               なし\r
2884 *\r
2885 *       Return Value\r
2886 *               なし\r
2887 *----------------------------------------------------------------------------*/\r
2888 \r
2889 void CalcFileSizeProc(void)\r
2890 {\r
2891         FILELIST *ListBase;\r
2892         FILELIST *Pos;\r
2893         int Win;\r
2894         int All;\r
2895         int Sts;\r
2896 \r
2897         if((All = DialogBox(GetFtpInst(), MAKEINTRESOURCE(filesize_notify_dlg), GetMainHwnd(), SizeNotifyDlgWndProc)) != NO_ALL)\r
2898         {\r
2899                 Sts = FFFTP_SUCCESS;\r
2900                 if(GetFocus() == GetLocalHwnd())\r
2901                         Win = WIN_LOCAL;\r
2902                 else\r
2903                 {\r
2904                         Win = WIN_REMOTE;\r
2905                         Sts = CheckClosedAndReconnect();\r
2906                 }\r
2907 \r
2908                 if(Sts == FFFTP_SUCCESS)\r
2909                 {\r
2910                         ListBase = NULL;\r
2911                         MakeSelectedFileList(Win, YES, All, &ListBase, &CancelFlg);\r
2912 \r
2913                         FileSize = 0;\r
2914                         Pos = ListBase;\r
2915                         while(Pos != NULL)\r
2916                         {\r
2917                                 if(Pos->Node != NODE_DIR)\r
2918                                         FileSize += Pos->Size;\r
2919                                 Pos = Pos->Next;\r
2920                         }\r
2921                         DeleteFileList(&ListBase);\r
2922                         DialogBox(GetFtpInst(), MAKEINTRESOURCE(filesize_dlg), GetMainHwnd(), SizeDlgWndProc);\r
2923                 }\r
2924         }\r
2925         return;\r
2926 }\r
2927 \r
2928 \r
2929 /*----- ファイル容量検索確認ダイアログのコールバック --------------------------\r
2930 *\r
2931 *       Parameter\r
2932 *               HWND hDlg : ウインドウハンドル\r
2933 *               UINT message  : メッセージ番号\r
2934 *               WPARAM wParam : メッセージの WPARAM 引数\r
2935 *               LPARAM lParam : メッセージの LPARAM 引数\r
2936 *\r
2937 *       Return Value\r
2938 *               メッセージに対応する戻り値\r
2939 *----------------------------------------------------------------------------*/\r
2940 \r
2941 static LRESULT CALLBACK SizeNotifyDlgWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
2942 {\r
2943         switch (message)\r
2944         {\r
2945                 case WM_INITDIALOG :\r
2946                         if(GetFocus() == GetLocalHwnd())\r
2947                                 SendDlgItemMessage(hDlg, FSNOTIFY_TITLE, WM_SETTEXT, 0, (LPARAM)MSGJPN074);\r
2948                         else\r
2949                                 SendDlgItemMessage(hDlg, FSNOTIFY_TITLE, WM_SETTEXT, 0, (LPARAM)MSGJPN075);\r
2950                         return(TRUE);\r
2951 \r
2952                 case WM_COMMAND :\r
2953                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2954                         {\r
2955                                 case IDOK :\r
2956                                         if(SendDlgItemMessage(hDlg, FSNOTIFY_SEL_ONLY, BM_GETCHECK, 0, 0) == 1)\r
2957                                                 EndDialog(hDlg, NO);\r
2958                                         else\r
2959                                                 EndDialog(hDlg, YES);\r
2960                                         break;\r
2961 \r
2962                                 case IDCANCEL :\r
2963                                         EndDialog(hDlg, NO_ALL);\r
2964                                         break;\r
2965                         }\r
2966                         return(TRUE);\r
2967         }\r
2968     return(FALSE);\r
2969 }\r
2970 \r
2971 \r
2972 /*----- ファイル容量検索ダイアログのコールバック ------------------------------\r
2973 *\r
2974 *       Parameter\r
2975 *               HWND hDlg : ウインドウハンドル\r
2976 *               UINT message  : メッセージ番号\r
2977 *               WPARAM wParam : メッセージの WPARAM 引数\r
2978 *               LPARAM lParam : メッセージの LPARAM 引数\r
2979 *\r
2980 *       Return Value\r
2981 *               メッセージに対応する戻り値\r
2982 *----------------------------------------------------------------------------*/\r
2983 \r
2984 static LRESULT CALLBACK SizeDlgWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
2985 {\r
2986         char Tmp[FMAX_PATH+1];\r
2987 \r
2988         switch (message)\r
2989         {\r
2990                 case WM_INITDIALOG :\r
2991                         if(GetFocus() == GetLocalHwnd())\r
2992                                 SendDlgItemMessage(hDlg, FSIZE_TITLE, WM_SETTEXT, 0, (LPARAM)MSGJPN076);\r
2993                         else\r
2994                                 SendDlgItemMessage(hDlg, FSIZE_TITLE, WM_SETTEXT, 0, (LPARAM)MSGJPN077);\r
2995 \r
2996                         MakeSizeString(FileSize, Tmp);\r
2997                         SendDlgItemMessage(hDlg, FSIZE_SIZE, WM_SETTEXT, 0, (LPARAM)Tmp);\r
2998                         return(TRUE);\r
2999 \r
3000                 case WM_COMMAND :\r
3001                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
3002                         {\r
3003                                 case IDOK :\r
3004                                 case IDCANCEL :\r
3005                                         EndDialog(hDlg, YES);\r
3006                                         break;\r
3007 \r
3008                         }\r
3009                         return(TRUE);\r
3010         }\r
3011     return(FALSE);\r
3012 }\r
3013 \r
3014 \r
3015 /*----- ディレクトリ移動失敗時のエラーを表示 ----------------------------------\r
3016 *\r
3017 *       Parameter\r
3018 *               HWND hDlg : ウインドウハンドル\r
3019 *\r
3020 *       Return Value\r
3021 *               なし\r
3022 *----------------------------------------------------------------------------*/\r
3023 \r
3024 void DispCWDerror(HWND hWnd)\r
3025 {\r
3026         DialogBox(GetFtpInst(), MAKEINTRESOURCE(cwderr_dlg), hWnd, ExeEscDialogProc);\r
3027         return;\r
3028 }\r
3029 \r
3030 \r
3031 /*----- URLをクリップボードにコピー -------------------------------------------\r
3032 *\r
3033 *       Parameter\r
3034 *               なし\r
3035 *\r
3036 *       Return Value\r
3037 *               なし\r
3038 *----------------------------------------------------------------------------*/\r
3039 \r
3040 void CopyURLtoClipBoard(void)\r
3041 {\r
3042         FILELIST *FileListBase;\r
3043         FILELIST *Pos;\r
3044         char *Buf;\r
3045         char Path[FMAX_PATH+1];\r
3046         char Host[HOST_ADRS_LEN+1];\r
3047         char Port[10];\r
3048         int Set;\r
3049         int Total;\r
3050 \r
3051         if(GetFocus() == GetRemoteHwnd())\r
3052         {\r
3053                 FileListBase = NULL;\r
3054                 MakeSelectedFileList(WIN_REMOTE, NO, NO, &FileListBase, &CancelFlg);\r
3055                 if(FileListBase != NULL)\r
3056                 {\r
3057                         strcpy(Host, AskHostAdrs());\r
3058                         Total = 0;\r
3059                         Buf = NULL;\r
3060                         Pos = FileListBase;\r
3061                         while(Pos != NULL)\r
3062                         {\r
3063                                 AskRemoteCurDir(Path, FMAX_PATH);\r
3064                                 SetSlashTail(Path);\r
3065                                 strcat(Path, Pos->File);\r
3066 \r
3067                                 if(AskHostType() == HTYPE_VMS)\r
3068                                         ReformToVMSstylePathName(Path);\r
3069 \r
3070                                 strcpy(Port, "");\r
3071                                 if(AskHostPort() != PORT_NOR)\r
3072                                         sprintf(Port, ":%d", AskHostPort());\r
3073 \r
3074                                 Set = Total;\r
3075                                 Total += strlen(Path) + strlen(Host) + strlen(Port) + 8;        /* 8は "ftp://\r\n" のぶん */\r
3076                                 if(AskHostType() == HTYPE_VMS)\r
3077                                         Total++;\r
3078 \r
3079                                 if((Buf = realloc(Buf, Total+1)) == NULL)\r
3080                                         break;\r
3081 \r
3082                                 if(AskHostType() != HTYPE_VMS)\r
3083                                         sprintf(Buf + Set, "ftp://%s%s%s\r\n", Host, Port, Path);\r
3084                                 else\r
3085                                         sprintf(Buf + Set, "ftp://%s%s/%s\r\n", Host, Port, Path);\r
3086 \r
3087                                 Pos = Pos->Next;\r
3088                         }\r
3089 \r
3090                         if(Buf != NULL)\r
3091                         {\r
3092                                 CopyStrToClipBoard(Buf);\r
3093                                 free(Buf);\r
3094                         }\r
3095                 }\r
3096                 DeleteFileList(&FileListBase);\r
3097         }\r
3098         return;\r
3099 }\r
3100 \r
3101 \r
3102 /*----- フルパスを使わないファイルアクセスの準備 ------------------------------\r
3103 *\r
3104 *       Parameter\r
3105 *               char *Path : パス名\r
3106 *               char *CurDir : カレントディレクトリ\r
3107 *               HWND hWnd : エラーウインドウを表示する際の親ウインドウ\r
3108 *               int Type : 使用するソケットの種類\r
3109 *                       0=コマンドソケット, 1=転送ソケット\r
3110 *\r
3111 *       Return Value\r
3112 *               int ステータス(FFFTP_SUCCESS/FFFTP_FAIL)\r
3113 *\r
3114 *       Note\r
3115 *               フルパスを使わない時は、\r
3116 *                       このモジュール内で CWD を行ない、\r
3117 *                       Path にファイル名のみ残す。(パス名は消す)\r
3118 *----------------------------------------------------------------------------*/\r
3119 \r
3120 int ProcForNonFullpath(char *Path, char *CurDir, HWND hWnd, int Type)\r
3121 {\r
3122         int Sts;\r
3123         int Cmd;\r
3124         char Tmp[FMAX_PATH+1];\r
3125 \r
3126         Sts = FFFTP_SUCCESS;\r
3127         if(AskNoFullPathMode() == YES)\r
3128         {\r
3129                 strcpy(Tmp, Path);\r
3130                 if(AskHostType() == HTYPE_VMS)\r
3131                 {\r
3132                         GetUpperDirEraseTopSlash(Tmp);\r
3133                         ReformToVMSstyleDirName(Tmp);\r
3134                 }\r
3135                 else if(AskHostType() == HTYPE_STRATUS)\r
3136                         GetUpperDirEraseTopSlash(Tmp);\r
3137                 else\r
3138                         GetUpperDir(Tmp);\r
3139 \r
3140                 if(strcmp(Tmp, CurDir) != 0)\r
3141                 {\r
3142                         if(Type == 0)\r
3143                                 Cmd = CommandProcCmd(NULL, "CWD %s", Tmp);\r
3144                         else\r
3145                                 Cmd = CommandProcTrn(NULL, "CWD %s", Tmp);\r
3146 \r
3147                         if(Cmd/100 != FTP_COMPLETE)\r
3148                         {\r
3149                                 DispCWDerror(hWnd);\r
3150                                 Sts = FFFTP_FAIL;\r
3151                         }\r
3152                         else\r
3153                                 strcpy(CurDir, Tmp);\r
3154                 }\r
3155                 strcpy(Path, GetFileName(Path));\r
3156         }\r
3157         return(Sts);\r
3158 }\r
3159 \r
3160 \r
3161 /*----- ディレクトリ名をVAX VMSスタイルに変換する -----------------------------\r
3162 *\r
3163 *       Parameter\r
3164 *               char *Path : パス名\r
3165 *\r
3166 *       Return Value\r
3167 *               なし\r
3168 *\r
3169 *       Note\r
3170 *               ddd:[xxx.yyy]/rrr/ppp  --> ddd:[xxx.yyy.rrr.ppp]\r
3171 *----------------------------------------------------------------------------*/\r
3172 \r
3173 void ReformToVMSstyleDirName(char *Path)\r
3174 {\r
3175         char *Pos;\r
3176         char *Btm;\r
3177 \r
3178         if((Btm = strchr(Path, ']')) != NULL)\r
3179         {\r
3180                 Pos = Btm;\r
3181                 while((Pos = strchr(Pos, '/')) != NULL)\r
3182                         *Pos = '.';\r
3183 \r
3184                 memmove(Btm, Btm+1, strlen(Btm+1)+1);\r
3185                 Pos = strchr(Path, NUL);\r
3186                 if(*(Pos-1) == '.')\r
3187                 {\r
3188                         Pos--;\r
3189                         *Pos = NUL;\r
3190                 }\r
3191                 strcpy(Pos, "]");\r
3192         }\r
3193         return;\r
3194 }\r