OSDN Git Service

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