OSDN Git Service

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