OSDN Git Service

4125606470a80799097f716105ebec72cfab269f
[ffftp/ffftp.git] / remote.c
1 /*=============================================================================\r
2 *\r
3 *                                                       リモート側のファイル操作\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 /* このソースは一部、WS_FTP Version 93.12.05 のソースを参考にしました。 */\r
31 \r
32 #define STRICT\r
33 #include <stdio.h>\r
34 #include <stdlib.h>\r
35 #include <stdarg.h>\r
36 #include <string.h>\r
37 #include <mbstring.h>\r
38 #include <time.h>\r
39 // IPv6対応\r
40 //#include <winsock.h>\r
41 #include <winsock2.h>\r
42 #include <windowsx.h>\r
43 #include <commctrl.h>\r
44 \r
45 #include "common.h"\r
46 #include "resource.h"\r
47 \r
48 #define PWD_XPWD                0\r
49 #define PWD_PWD                 1\r
50 \r
51 /*===== プロトタイプ =====*/\r
52 \r
53 static int DoPWD(char *Buf);\r
54 static int ReadOneLine(SOCKET cSkt, char *Buf, int Max, int *CancelCheckWork);\r
55 static int DoDirList(HWND hWnd, SOCKET cSkt, char *AddOpt, char *Path, int Num, int *CancelCheckWork);\r
56 static void ChangeSepaLocal2Remote(char *Fname);\r
57 static void ChangeSepaRemote2Local(char *Fname);\r
58 \r
59 /*===== 外部参照 =====*/\r
60 \r
61 extern TRANSPACKET MainTransPkt;\r
62 \r
63 /* 設定値 */\r
64 extern int TimeOut;\r
65 extern int SendQuit;\r
66 \r
67 // 同時接続対応\r
68 extern int CancelFlg;\r
69 \r
70 /*===== ローカルなワーク =====*/\r
71 \r
72 static int PwdCommandType;\r
73 \r
74 // 同時接続対応\r
75 //static int CheckCancelFlg = NO;\r
76 \r
77 \r
78 \r
79 /*----- リモート側のカレントディレクトリ変更 ----------------------------------\r
80 *\r
81 *       Parameter\r
82 *               char *Path : パス名\r
83 *               int Disp : ディレクトリリストにパス名を表示するかどうか(YES/NO)\r
84 *               int ForceGet : 失敗してもカレントディレクトリを取得する\r
85 *               int ErrorBell : エラー事の音を鳴らすかどうか(YES/NO)\r
86 *\r
87 *       Return Value\r
88 *               int 応答コードの1桁目\r
89 *----------------------------------------------------------------------------*/\r
90 \r
91 int DoCWD(char *Path, int Disp, int ForceGet, int ErrorBell)\r
92 {\r
93         int Sts;\r
94         char Buf[FMAX_PATH+1];\r
95 \r
96         Sts = FTP_COMPLETE * 100;\r
97 \r
98         if(strcmp(Path, "..") == 0)\r
99                 Sts = CommandProcCmd(NULL, "CDUP");\r
100         else if(strcmp(Path, "") != 0)\r
101         {\r
102                 if((AskHostType() != HTYPE_VMS) || (strchr(Path, '[') != NULL))\r
103                         Sts = CommandProcCmd(NULL, "CWD %s", Path);\r
104                 else\r
105                         Sts = CommandProcCmd(NULL, "CWD [.%s]", Path);  /* VMS用 */\r
106         }\r
107 \r
108         if((Sts/100 >= FTP_CONTINUE) && (ErrorBell == YES))\r
109                 SoundPlay(SND_ERROR);\r
110 \r
111         if((Sts/100 == FTP_COMPLETE) ||\r
112            (ForceGet == YES))\r
113         {\r
114                 if(Disp == YES)\r
115                 {\r
116                         if(DoPWD(Buf) != FTP_COMPLETE)\r
117                         {\r
118                                 /*===== PWDが使えなかった場合 =====*/\r
119 \r
120                                 if(*Path == '/')\r
121                                         strcpy(Buf, Path);\r
122                                 else\r
123                                 {\r
124                                         AskRemoteCurDir(Buf, FMAX_PATH);\r
125                                         if(strlen(Buf) == 0)\r
126                                                 strcpy(Buf, "/");\r
127 \r
128                                         while(*Path != NUL)\r
129                                         {\r
130                                                 if(strcmp(Path, ".") == 0)\r
131                                                         Path++;\r
132                                                 else if(strncmp(Path, "./", 2) == 0)\r
133                                                         Path += 2;\r
134                                                 else if(strcmp(Path, "..") == 0)\r
135                                                 {\r
136                                                         GetUpperDir(Buf);\r
137                                                         Path += 2;\r
138                                                 }\r
139                                                 else if(strncmp(Path, "../", 2) == 0)\r
140                                                 {\r
141                                                         GetUpperDir(Buf);\r
142                                                         Path += 3;\r
143                                                 }\r
144                                                 else\r
145                                                 {\r
146                                                         SetSlashTail(Buf);\r
147                                                         strcat(Buf, Path);\r
148                                                         break;\r
149                                                 }\r
150                                         }\r
151                                 }\r
152                         }\r
153                         SetRemoteDirHist(Buf);\r
154                 }\r
155         }\r
156         return(Sts/100);\r
157 }\r
158 \r
159 \r
160 \r
161 \r
162 /*----- リモート側のカレントディレクトリ変更(その2)-------------------------\r
163 *\r
164 *       Parameter\r
165 *               char *Path : パス名\r
166 *               char *Cur : カレントディレクトリ\r
167 *\r
168 *       Return Value\r
169 *               int 応答コードの1桁目\r
170 *\r
171 *       Note\r
172 *               パス名は "xxx/yyy/zzz" の形式\r
173 *               ディレクトリ変更が失敗したら、カレントディレクトリに戻しておく\r
174 *----------------------------------------------------------------------------*/\r
175 \r
176 int DoCWDStepByStep(char *Path, char *Cur)\r
177 {\r
178         int Sts;\r
179         char *Set;\r
180         char *Set2;\r
181         char Tmp[FMAX_PATH+2];\r
182 \r
183         Sts = FTP_COMPLETE;\r
184 \r
185         memset(Tmp, NUL, FMAX_PATH+2);\r
186         strcpy(Tmp, Path);\r
187         Set = Tmp;\r
188         while(*Set != NUL)\r
189         {\r
190                 if((Set2 = strchr(Set, '/')) != NULL)\r
191                         *Set2 = NUL;\r
192                 if((Sts = DoCWD(Set, NO, NO, NO)) != FTP_COMPLETE)\r
193                         break;\r
194                 if(Set2 == NULL)\r
195                         break;\r
196                 Set = Set2 + 1;\r
197         }\r
198 \r
199         if(Sts != FTP_COMPLETE)\r
200                 DoCWD(Cur, NO, NO, NO);\r
201 \r
202         return(Sts);\r
203 }\r
204 \r
205 \r
206 /*----- リモート側のカレントディレクトリ取得 ----------------------------------\r
207 *\r
208 *       Parameter\r
209 *               char *Buf : パス名を返すバッファ\r
210 *\r
211 *       Return Value\r
212 *               int 応答コードの1桁目\r
213 *----------------------------------------------------------------------------*/\r
214 \r
215 static int DoPWD(char *Buf)\r
216 {\r
217         char *Pos;\r
218         char Tmp[1024];\r
219         int Sts;\r
220 \r
221         if(PwdCommandType == PWD_XPWD)\r
222         {\r
223                 Sts = CommandProcCmd(Tmp, "XPWD");\r
224                 if(Sts/100 != FTP_COMPLETE)\r
225                         PwdCommandType = PWD_PWD;\r
226         }\r
227         if(PwdCommandType == PWD_PWD)\r
228                 Sts = CommandProcCmd(Tmp, "PWD");\r
229 \r
230         if(Sts/100 == FTP_COMPLETE)\r
231         {\r
232                 if((Pos = strchr(Tmp, '"')) != NULL)\r
233                 {\r
234                         memmove(Tmp, Pos+1, strlen(Pos+1)+1);\r
235                         if((Pos = strchr(Tmp, '"')) != NULL)\r
236                                 *Pos = NUL;\r
237                 }\r
238                 else\r
239                         memmove(Tmp, Tmp+4, strlen(Tmp+4)+1);\r
240 \r
241                 if(strlen(Tmp) < FMAX_PATH)\r
242                 {\r
243                         strcpy(Buf, Tmp);\r
244                         ReplaceAll(Buf, '\\', '/');\r
245                         ChangeSepaRemote2Local(Buf);\r
246                 }\r
247                 else\r
248                         Sts = FTP_ERROR*100;\r
249         }\r
250         return(Sts/100);\r
251 }\r
252 \r
253 \r
254 /*----- PWDコマンドのタイプを初期化する ---------------------------------------\r
255 *\r
256 *       Parameter\r
257 *               なし\r
258 *\r
259 *       Return Value\r
260 *               なし\r
261 *----------------------------------------------------------------------------*/\r
262 \r
263 void InitPWDcommand()\r
264 {\r
265         PwdCommandType = PWD_XPWD;\r
266 }\r
267 \r
268 \r
269 /*----- リモート側のディレクトリ作成 ----------------------------------------\r
270 *\r
271 *       Parameter\r
272 *               char *Path : パス名\r
273 *\r
274 *       Return Value\r
275 *               int 応答コードの1桁目\r
276 *----------------------------------------------------------------------------*/\r
277 \r
278 int DoMKD(char *Path)\r
279 {\r
280         int Sts;\r
281 \r
282         Sts = CommandProcCmd(NULL, "MKD %s", Path);\r
283 \r
284         if(Sts/100 >= FTP_CONTINUE)\r
285                 SoundPlay(SND_ERROR);\r
286 \r
287         return(Sts/100);\r
288 }\r
289 \r
290 \r
291 /*----- リモート側のディレクトリ削除 ------------------------------------------\r
292 *\r
293 *       Parameter\r
294 *               char *Path : パス名\r
295 *\r
296 *       Return Value\r
297 *               int 応答コードの1桁目\r
298 *----------------------------------------------------------------------------*/\r
299 \r
300 int DoRMD(char *Path)\r
301 {\r
302         int Sts;\r
303 \r
304         Sts = CommandProcCmd(NULL, "RMD %s", Path);\r
305 \r
306         if(Sts/100 >= FTP_CONTINUE)\r
307                 SoundPlay(SND_ERROR);\r
308 \r
309         return(Sts/100);\r
310 }\r
311 \r
312 \r
313 /*----- リモート側のファイル削除 ----------------------------------------------\r
314 *\r
315 *       Parameter\r
316 *               char *Path : パス名\r
317 *\r
318 *       Return Value\r
319 *               int 応答コードの1桁目\r
320 *----------------------------------------------------------------------------*/\r
321 \r
322 int DoDELE(char *Path)\r
323 {\r
324         int Sts;\r
325 \r
326         Sts = CommandProcCmd(NULL, "DELE %s", Path);\r
327 \r
328         if(Sts/100 >= FTP_CONTINUE)\r
329                 SoundPlay(SND_ERROR);\r
330 \r
331         return(Sts/100);\r
332 }\r
333 \r
334 \r
335 /*----- リモート側のファイル名変更 --------------------------------------------\r
336 *\r
337 *       Parameter\r
338 *               char *Src : 元ファイル名\r
339 *               char *Dst : 変更後のファイル名\r
340 *\r
341 *       Return Value\r
342 *               int 応答コードの1桁目\r
343 *----------------------------------------------------------------------------*/\r
344 \r
345 int DoRENAME(char *Src, char *Dst)\r
346 {\r
347         int Sts;\r
348 \r
349         Sts = CommandProcCmd(NULL, "RNFR %s", Src);\r
350         if(Sts == 350)\r
351                 // 同時接続対応\r
352 //              Sts = command(AskCmdCtrlSkt(), NULL, &CheckCancelFlg, "RNTO %s", Dst);\r
353                 Sts = command(AskCmdCtrlSkt(), NULL, &CancelFlg, "RNTO %s", Dst);\r
354 \r
355         if(Sts/100 >= FTP_CONTINUE)\r
356                 SoundPlay(SND_ERROR);\r
357 \r
358         return(Sts/100);\r
359 }\r
360 \r
361 \r
362 /*----- リモート側のファイルの属性変更 ----------------------------------------\r
363 *\r
364 *       Parameter\r
365 *               char *Path : パス名\r
366 *               char *Mode : モード文字列\r
367 *\r
368 *       Return Value\r
369 *               int 応答コードの1桁目\r
370 *----------------------------------------------------------------------------*/\r
371 \r
372 int DoCHMOD(char *Path, char *Mode)\r
373 {\r
374         int Sts;\r
375 \r
376         Sts = CommandProcCmd(NULL, "%s %s %s", AskHostChmodCmd(), Mode, Path);\r
377 \r
378         if(Sts/100 >= FTP_CONTINUE)\r
379                 SoundPlay(SND_ERROR);\r
380 \r
381         return(Sts/100);\r
382 }\r
383 \r
384 \r
385 /*----- リモート側のファイルのサイズを取得(転送ソケット使用)-----------------\r
386 *\r
387 *       Parameter\r
388 *               char *Path : パス名\r
389 *               LONGLONG *Size : ファイルのサイズを返すワーク\r
390 *\r
391 *       Return Value\r
392 *               int 応答コードの1桁目\r
393 *\r
394 *       Note\r
395 *               ★★転送ソケットを使用する★★\r
396 *               サイズが選られない時は Size = -1 を返す\r
397 *----------------------------------------------------------------------------*/\r
398 \r
399 // 同時接続対応\r
400 //int DoSIZE(char *Path, LONGLONG *Size)\r
401 int DoSIZE(SOCKET cSkt, char *Path, LONGLONG *Size, int *CancelCheckWork)\r
402 {\r
403         int Sts;\r
404         char Tmp[1024];\r
405 \r
406         // 同時接続対応\r
407 //      Sts = CommandProcTrn(Tmp, "SIZE %s", Path);\r
408         Sts = CommandProcTrn(cSkt, Tmp, CancelCheckWork, "SIZE %s", Path);\r
409 \r
410         *Size = -1;\r
411         if((Sts/100 == FTP_COMPLETE) && (strlen(Tmp) > 4) && IsDigit(Tmp[4]))\r
412                 *Size = _atoi64(&Tmp[4]);\r
413 \r
414         return(Sts/100);\r
415 }\r
416 \r
417 \r
418 /*----- リモート側のファイルの日付を取得(転送ソケット使用)-------------------\r
419 *\r
420 *       Parameter\r
421 *               char *Path : パス名\r
422 *               FILETIME *Time : 日付を返すワーク\r
423 *\r
424 *       Return Value\r
425 *               int 応答コードの1桁目\r
426 *\r
427 *       Note\r
428 *               ★★転送ソケットを使用する★★\r
429 *               日付が選られない時は Time = 0 を返す\r
430 *----------------------------------------------------------------------------*/\r
431 \r
432 // 同時接続対応\r
433 //int DoMDTM(char *Path, FILETIME *Time)\r
434 int DoMDTM(SOCKET cSkt, char *Path, FILETIME *Time, int *CancelCheckWork)\r
435 {\r
436         int Sts;\r
437         char Tmp[1024];\r
438         SYSTEMTIME sTime;\r
439 \r
440     Time->dwLowDateTime = 0;\r
441     Time->dwHighDateTime = 0;\r
442 \r
443         // 同時接続対応\r
444 //      Sts = CommandProcTrn(Tmp, "MDTM %s", Path);\r
445         Sts = CommandProcTrn(cSkt, Tmp, CancelCheckWork, "MDTM %s", Path);\r
446         if(Sts/100 == FTP_COMPLETE)\r
447         {\r
448                 sTime.wMilliseconds = 0;\r
449                 if(sscanf(Tmp+4, "%04d%02d%02d%02d%02d%02d",\r
450                         &sTime.wYear, &sTime.wMonth, &sTime.wDay,\r
451                         &sTime.wHour, &sTime.wMinute, &sTime.wSecond) == 6)\r
452                 {\r
453                         SystemTimeToFileTime(&sTime, Time);\r
454                         SpecificLocalFileTime2FileTime(Time, AskHostTimeZone());\r
455 \r
456                 }\r
457         }\r
458         return(Sts/100);\r
459 }\r
460 \r
461 \r
462 /*----- リモート側のコマンドを実行 --------------------------------------------\r
463 *\r
464 *       Parameter\r
465 *               char *CmdStr : コマンド文字列\r
466 *\r
467 *       Return Value\r
468 *               int 応答コードの1桁目\r
469 *----------------------------------------------------------------------------*/\r
470 \r
471 // 同時接続対応\r
472 //int DoQUOTE(char *CmdStr)\r
473 int DoQUOTE(SOCKET cSkt, char *CmdStr, int *CancelCheckWork)\r
474 {\r
475         int Sts;\r
476 \r
477 //      Sts = CommandProcCmd(NULL, "%s", CmdStr);\r
478         Sts = CommandProcTrn(cSkt, NULL, CancelCheckWork, "%s", CmdStr);\r
479 \r
480         if(Sts/100 >= FTP_CONTINUE)\r
481                 SoundPlay(SND_ERROR);\r
482 \r
483         return(Sts/100);\r
484 }\r
485 \r
486 \r
487 /*----- ソケットを閉じる ------------------------------------------------------\r
488 *\r
489 *       Parameter\r
490 *               なし\r
491 *\r
492 *       Return Value\r
493 *               SOCKET 閉じた後のソケット\r
494 *----------------------------------------------------------------------------*/\r
495 \r
496 SOCKET DoClose(SOCKET Sock)\r
497 {\r
498         if(Sock != INVALID_SOCKET)\r
499         {\r
500 //              if(WSAIsBlocking())\r
501 //              {\r
502 //                      DoPrintf("Skt=%u : Cancelled blocking call", Sock);\r
503 //                      WSACancelBlockingCall();\r
504 //              }\r
505                 do_closesocket(Sock);\r
506                 DoPrintf("Skt=%u : Socket closed.", Sock);\r
507                 Sock = INVALID_SOCKET;\r
508         }\r
509         if(Sock != INVALID_SOCKET)\r
510                 DoPrintf("Skt=%u : Failed to close socket.", Sock);\r
511 \r
512         return(Sock);\r
513 }\r
514 \r
515 \r
516 /*----- ホストからログアウトする ----------------------------------------------\r
517 *\r
518 *       Parameter\r
519 *               kSOCKET ctrl_skt : ソケット\r
520 *\r
521 *       Return Value\r
522 *               int 応答コードの1桁目\r
523 *----------------------------------------------------------------------------*/\r
524 \r
525 int DoQUIT(SOCKET ctrl_skt)\r
526 {\r
527         int Ret;\r
528 \r
529         Ret = FTP_COMPLETE;\r
530         if(SendQuit == YES)\r
531                 // 同時接続対応\r
532 //              Ret = command(ctrl_skt, NULL, &CheckCancelFlg, "QUIT") / 100;\r
533                 Ret = command(ctrl_skt, NULL, &CancelFlg, "QUIT") / 100;\r
534 \r
535         return(Ret);\r
536 }\r
537 \r
538 \r
539 /*----- リモート側のディレクトリリストを取得(コマンドコントロールソケットを使用)\r
540 *\r
541 *       Parameter\r
542 *               char *AddOpt : 追加のオプション\r
543 *               char *Path : パス名\r
544 *               int Num : ファイル名番号\r
545 *\r
546 *       Return Value\r
547 *               int 応答コードの1桁目\r
548 *----------------------------------------------------------------------------*/\r
549 \r
550 int DoDirListCmdSkt(char *AddOpt, char *Path, int Num, int *CancelCheckWork)\r
551 {\r
552         int Sts;\r
553 \r
554         if(AskTransferNow() == YES)\r
555                 SktShareProh();\r
556 \r
557 //      if((Sts = DoDirList(NULL, AskCmdCtrlSkt(), AddOpt, Path, Num)) == 429)\r
558 //      {\r
559 //              ReConnectCmdSkt();\r
560                 Sts = DoDirList(NULL, AskCmdCtrlSkt(), AddOpt, Path, Num, CancelCheckWork);\r
561 \r
562                 if(Sts/100 >= FTP_CONTINUE)\r
563                         SoundPlay(SND_ERROR);\r
564 //      }\r
565         return(Sts/100);\r
566 }\r
567 \r
568 \r
569 /*----- リモート側のディレクトリリストを取得 ----------------------------------\r
570 *\r
571 *       Parameter\r
572 *               HWND hWnd : 転送中ダイアログのウインドウハンドル\r
573 *               SOCKET cSkt : コントロールソケット\r
574 *               char *AddOpt : 追加のオプション\r
575 *               char *Path : パス名 (""=カレントディレクトリ)\r
576 *               int Num : ファイル名番号\r
577 *\r
578 *       Return Value\r
579 *               int 応答コード\r
580 *----------------------------------------------------------------------------*/\r
581 \r
582 static int DoDirList(HWND hWnd, SOCKET cSkt, char *AddOpt, char *Path, int Num, int *CancelCheckWork)\r
583 {\r
584         char Tmp[FMAX_PATH];\r
585         int Sts;\r
586 \r
587 //#pragma aaa\r
588 //DoPrintf("===== DoDirList %d = %s", Num, Path);\r
589 \r
590         MakeCacheFileName(Num, Tmp);\r
591 //      MainTransPkt.ctrl_skt = cSkt;\r
592 \r
593         if(AskListCmdMode() == NO)\r
594         {\r
595                 strcpy(MainTransPkt.Cmd, "NLST");\r
596                 if(strlen(AskHostLsName()) > 0)\r
597                 {\r
598                         strcat(MainTransPkt.Cmd, " ");\r
599                         if((AskHostType() == HTYPE_ACOS) || (AskHostType() == HTYPE_ACOS_4))\r
600                                 strcat(MainTransPkt.Cmd, "'");\r
601                         strcat(MainTransPkt.Cmd, AskHostLsName());\r
602                         if((AskHostType() == HTYPE_ACOS) || (AskHostType() == HTYPE_ACOS_4))\r
603                                 strcat(MainTransPkt.Cmd, "'");\r
604                 }\r
605                 if(strlen(AddOpt) > 0)\r
606                         strcat(MainTransPkt.Cmd, AddOpt);\r
607         }\r
608         else\r
609         {\r
610                 // MLSD対応\r
611 //              strcpy(MainTransPkt.Cmd, "LIST");\r
612                 if(AskUseMLSD() && (AskHostFeature() & FEATURE_MLSD))\r
613                         strcpy(MainTransPkt.Cmd, "MLSD");\r
614                 else\r
615                         strcpy(MainTransPkt.Cmd, "LIST");\r
616                 if(strlen(AddOpt) > 0)\r
617                 {\r
618                         strcat(MainTransPkt.Cmd, " -");\r
619                         strcat(MainTransPkt.Cmd, AddOpt);\r
620                 }\r
621         }\r
622 \r
623         if(strlen(Path) > 0)\r
624                 strcat(MainTransPkt.Cmd, " ");\r
625 \r
626         strcpy(MainTransPkt.RemoteFile, Path);\r
627         strcpy(MainTransPkt.LocalFile, Tmp);\r
628         MainTransPkt.Type = TYPE_A;\r
629         MainTransPkt.Size = -1;\r
630         /* ファイルリストの中の漢字のファイル名は、別途   */\r
631         /* ChangeFnameRemote2Local で変換する                      */\r
632         MainTransPkt.KanjiCode = KANJI_NOCNV;\r
633         MainTransPkt.KanaCnv = YES;\r
634         MainTransPkt.Mode = EXIST_OVW;\r
635         MainTransPkt.ExistSize = 0;\r
636         MainTransPkt.hWndTrans = hWnd;\r
637         MainTransPkt.Next = NULL;\r
638 \r
639         Sts = DoDownLoad(cSkt, &MainTransPkt, YES, CancelCheckWork);\r
640 \r
641 //#pragma aaa\r
642 //DoPrintf("===== DoDirList Done.");\r
643 \r
644         return(Sts);\r
645 }\r
646 \r
647 \r
648 /*----- リモート側へコマンドを送りリプライを待つ(コマンドソケット)-----------\r
649 *\r
650 *       Parameter\r
651 *               char *Reply : リプライのコピー先 (NULL=コピーしない)\r
652 *               char *fmt : フォーマット文字列\r
653 *               ... : パラメータ\r
654 *\r
655 *       Return Value\r
656 *               int 応答コード\r
657 *\r
658 *       Note\r
659 *               コマンドコントロールソケットを使う\r
660 *----------------------------------------------------------------------------*/\r
661 \r
662 int CommandProcCmd(char *Reply, char *fmt, ...)\r
663 {\r
664         va_list Args;\r
665         char Cmd[1024];\r
666         int Sts;\r
667 \r
668         va_start(Args, fmt);\r
669         wvsprintf(Cmd, fmt, Args);\r
670         va_end(Args);\r
671 \r
672         if(AskTransferNow() == YES)\r
673                 SktShareProh();\r
674 \r
675 //#pragma aaa\r
676 //DoPrintf("**CommandProcCmd : %s", Cmd);\r
677 \r
678 //      if((Sts = command(AskCmdCtrlSkt(), Reply, "%s", Cmd)) == 429)\r
679 //      {\r
680 //              if(ReConnectCmdSkt() == FFFTP_SUCCESS)\r
681 //              {\r
682                         // 同時接続対応\r
683 //                      Sts = command(AskCmdCtrlSkt(), Reply, &CheckCancelFlg, "%s", Cmd);\r
684                         Sts = command(AskCmdCtrlSkt(), Reply, &CancelFlg, "%s", Cmd);\r
685 //              }\r
686 //      }\r
687         return(Sts);\r
688 }\r
689 \r
690 \r
691 #if defined(HAVE_TANDEM)\r
692 /*----- OSS/Guardian ファイルシステムを切り替えるコマンドを送る ---------------\r
693 *\r
694 *       Parameter\r
695 *               なし\r
696 *\r
697 *       Return Value\r
698 *               なし\r
699 *----------------------------------------------------------------------------*/\r
700 \r
701 void SwitchOSSProc(void)\r
702 {\r
703         char Buf[MAX_PATH+1];\r
704 \r
705         /* DoPWD でノード名の \ を保存するために OSSフラグも変更する */\r
706         if(AskOSS() == YES) {\r
707                 DoQUOTE(AskCmdCtrlSkt(), "GUARDIAN", &CancelFlg);\r
708                 SetOSS(NO);\r
709         } else {\r
710                 DoQUOTE(AskCmdCtrlSkt(), "OSS", &CancelFlg);\r
711                 SetOSS(YES);\r
712         }\r
713         /* Current Dir 再取得 */\r
714         if (DoPWD(Buf) == FTP_COMPLETE)\r
715                 SetRemoteDirHist(Buf);\r
716         /* ファイルリスト再読み込み */\r
717         PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(REFRESH_REMOTE, 0), 0);\r
718 \r
719         return;\r
720 }\r
721 #endif\r
722 \r
723 \r
724 /*----- リモート側へコマンドを送りリプライを待つ(転送ソケット)---------------\r
725 *\r
726 *       Parameter\r
727 *               SOCKET cSkt : ソケット\r
728 *               char *Reply : リプライのコピー先 (NULL=コピーしない)\r
729 *               int *CancelCheckWork :\r
730 *               char *fmt : フォーマット文字列\r
731 *               ... : パラメータ\r
732 *\r
733 *       Return Value\r
734 *               int 応答コード\r
735 *\r
736 *       Note\r
737 *               転送コントロールソケットを使う\r
738 *----------------------------------------------------------------------------*/\r
739 \r
740 // 同時接続対応\r
741 //int CommandProcTrn(char *Reply, char *fmt, ...)\r
742 int CommandProcTrn(SOCKET cSkt, char *Reply, int* CancelCheckWork, char *fmt, ...)\r
743 {\r
744         va_list Args;\r
745         char Cmd[1024];\r
746         int Sts;\r
747 \r
748         va_start(Args, fmt);\r
749         wvsprintf(Cmd, fmt, Args);\r
750         va_end(Args);\r
751 \r
752 //#pragma aaa\r
753 //DoPrintf("**CommandProcTrn : %s", Cmd);\r
754 \r
755 //      if((Sts = command(AskTrnCtrlSkt(), Reply, "%s", Cmd)) == 429)\r
756 //      {\r
757 //              if(ReConnectTrnSkt() == FFFTP_SUCCESS)\r
758 //                      Sts = command(AskTrnCtrlSkt(), Reply, &CheckCancelFlg, "%s", Cmd);\r
759                         Sts = command(cSkt, Reply, CancelCheckWork, "%s", Cmd);\r
760 //      }\r
761         return(Sts);\r
762 }\r
763 \r
764 \r
765 /*----- コマンドを送りリプライを待つ ------------------------------------------\r
766 *\r
767 *       Parameter\r
768 *               SOCKET cSkt : コントロールソケット\r
769 *               char *Reply : リプライのコピー先 (NULL=コピーしない)\r
770 *               char *fmt : フォーマット文字列\r
771 *               ... : パラメータ\r
772 *\r
773 *       Return Value\r
774 *               int 応答コード\r
775 *\r
776 *       Note\r
777 *               ホストのファイル名の漢字コードに応じて、ここで漢字コードの変換を行なう\r
778 *----------------------------------------------------------------------------*/\r
779 \r
780 //#pragma aaa\r
781 //static int cntcnt = 0;\r
782 \r
783 // SFTP対応\r
784 int ConvertFTPCommandToPuTTYSFTP(SOCKET cSkt, char *Reply, int *CancelCheckWork, char *Cmd)\r
785 {\r
786         // TODO:\r
787         // 未実装\r
788         int Sts;\r
789         char NewCmd[FMAX_PATH*2];\r
790         static char RenameFrom[FMAX_PATH+1];\r
791         Sts = 429;\r
792         Reply[0] = '\0';\r
793         if(strcmp(Cmd, "QUIT") == 0)\r
794         {\r
795                 sprintf(NewCmd, "ls\r\n");\r
796                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
797         }\r
798         if(strcmp(Cmd, "LIST") == 0)\r
799         {\r
800                 sprintf(NewCmd, "ls\r\n");\r
801                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
802         }\r
803         else if(strncmp(Cmd, "REST ", 5) == 0)\r
804         {\r
805                 SFTP_SetFilePosition(cSkt, (LONGLONG)_strtoi64(&Cmd[5], NULL, 10));\r
806         }\r
807         else if(strncmp(Cmd, "RETR ", 5) == 0)\r
808         {\r
809                 sprintf(NewCmd, "get \"%s\"\r\n", &Cmd[5]);\r
810                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
811         }\r
812         else if(strncmp(Cmd, "STOR ", 5) == 0)\r
813         {\r
814                 sprintf(NewCmd, "put \"%s\"\r\n", &Cmd[5]);\r
815                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
816         }\r
817         else if(strncmp(Cmd, "APPE ", 5) == 0)\r
818         {\r
819                 sprintf(NewCmd, "reput \"%s\"\r\n", &Cmd[5]);\r
820                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
821         }\r
822         else if(strncmp(Cmd, "DELE ", 5) == 0)\r
823         {\r
824                 sprintf(NewCmd, "rm \"%s\"\r\n", &Cmd[5]);\r
825                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
826         }\r
827         else if(strncmp(Cmd, "CWD ", 4) == 0)\r
828         {\r
829                 sprintf(NewCmd, "cd \"%s\"\r\n", &Cmd[4]);\r
830                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
831         }\r
832         else if(strcmp(Cmd, "PWD") == 0)\r
833         {\r
834                 sprintf(NewCmd, "pwd\r\n");\r
835                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
836         }\r
837         else if(strcmp(Cmd, "XPWD") == 0)\r
838         {\r
839                 sprintf(NewCmd, "pwd\r\n");\r
840                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
841         }\r
842         else if(strncmp(Cmd, "MKD ", 4) == 0)\r
843         {\r
844                 sprintf(NewCmd, "mkdir \"%s\"\r\n", &Cmd[4]);\r
845                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
846         }\r
847         else if(strncmp(Cmd, "RMD ", 4) == 0)\r
848         {\r
849                 sprintf(NewCmd, "rmdir \"%s\"\r\n", &Cmd[4]);\r
850                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
851         }\r
852         else if(strncmp(Cmd, "RNFR ", 5) == 0)\r
853         {\r
854                 strcpy(RenameFrom, &Cmd[5]);\r
855         }\r
856         else if(strncmp(Cmd, "RNTO ", 5) == 0)\r
857         {\r
858                 sprintf(NewCmd, "mv \"%s\" \"%s\"\r\n", RenameFrom, &Cmd[5]);\r
859                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
860         }\r
861         else if(strncmp(Cmd, "SITE CHMOD ", 11) == 0)\r
862         {\r
863                 Cmd[14] = '\0';\r
864                 sprintf(NewCmd, "chmod %s \"%s\"\r\n", &Cmd[11], &Cmd[15]);\r
865                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
866         }\r
867         return Sts;\r
868 }\r
869 \r
870 int command(SOCKET cSkt, char *Reply, int *CancelCheckWork, char *fmt, ...)\r
871 {\r
872         va_list Args;\r
873         char Cmd[FMAX_PATH*2];\r
874         int Sts;\r
875         char TmpBuf[ONELINE_BUF_SIZE];\r
876 \r
877         if(cSkt != INVALID_SOCKET)\r
878         {\r
879                 va_start(Args, fmt);\r
880                 wvsprintf(Cmd, fmt, Args);\r
881                 va_end(Args);\r
882 \r
883                 // SFTP対応\r
884                 if(IsSFTPAttached(cSkt))\r
885                         return ConvertFTPCommandToPuTTYSFTP(cSkt, Reply, CancelCheckWork, Cmd);\r
886 \r
887                 if(strncmp(Cmd, "PASS ", 5) == 0)\r
888                         SetTaskMsg(">PASS [xxxxxx]");\r
889                 else if((strncmp(Cmd, "USER ", 5) == 0) ||\r
890                                 (strncmp(Cmd, "OPEN ", 5) == 0))\r
891                 {\r
892                         SetTaskMsg(">%s", Cmd);\r
893                 }\r
894                 else\r
895                 {\r
896                         ChangeSepaLocal2Remote(Cmd);\r
897                         SetTaskMsg(">%s", Cmd);\r
898                         ChangeFnameLocal2Remote(Cmd, FMAX_PATH*2);\r
899                 }\r
900 \r
901 //              DoPrintf("SEND : %s", Cmd);\r
902                 strcat(Cmd, "\x0D\x0A");\r
903 \r
904                 if(Reply != NULL)\r
905                         strcpy(Reply, "");\r
906 \r
907                 Sts = 429;\r
908                 if(SendData(cSkt, Cmd, strlen(Cmd), 0, CancelCheckWork) == FFFTP_SUCCESS)\r
909                 {\r
910                         Sts = ReadReplyMessage(cSkt, Reply, 1024, CancelCheckWork, TmpBuf);\r
911                 }\r
912 \r
913 //#pragma aaa\r
914 //if(Reply != NULL)\r
915 //      DoPrintf("%x : %x : %s : %s", cSkt, &TmpBuf, Cmd, Reply);\r
916 //else\r
917 //      DoPrintf("%x : %x : %s : NULL", cSkt, &TmpBuf, Cmd);\r
918 \r
919 //              DoPrintf("command() RET=%d", Sts);\r
920         }\r
921         else\r
922                 Sts = 429;\r
923 \r
924         return(Sts);\r
925 }\r
926 \r
927 \r
928 /*----- データを送る ----------------------------------------------------------\r
929 *\r
930 *       Parameter\r
931 *               SOCKET Skt : ソケット\r
932 *               char *Data : データ\r
933 *               int Size : 送るデータのサイズ\r
934 *               int Mode : コールモード\r
935 *\r
936 *       Return Value\r
937 *               int ステータス\r
938 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
939 *----------------------------------------------------------------------------*/\r
940 \r
941 int SendData(SOCKET Skt, char *Data, int Size, int Mode, int *CancelCheckWork)\r
942 {\r
943         int Sts;\r
944         int Tmp;\r
945 //      fd_set SendFds;\r
946 //      struct timeval Tout;\r
947 //      struct timeval *ToutPtr;\r
948         int TimeOutErr;\r
949 \r
950         Sts = FFFTP_FAIL;\r
951         if(Skt != INVALID_SOCKET)\r
952         {\r
953                 Sts = FFFTP_SUCCESS;\r
954                 while(Size > 0)\r
955                 {\r
956 //                      FD_ZERO(&SendFds);\r
957 //                      FD_SET(Skt, &SendFds);\r
958 //                      ToutPtr = NULL;\r
959 //                      if(TimeOut != 0)\r
960 //                      {\r
961 //                              Tout.tv_sec = TimeOut;\r
962 //                              Tout.tv_usec = 0;\r
963 //                              ToutPtr = &Tout;\r
964 //                      }\r
965 //                      Tmp = select(0, NULL, &SendFds, NULL, ToutPtr);\r
966 //                      if(Tmp == SOCKET_ERROR)\r
967 //                      {\r
968 //                              Sts = FFFTP_FAIL;\r
969 //                              ReportWSError("select", WSAGetLastError());\r
970 //                              break;\r
971 //                      }\r
972 //                      else if(Tmp == 0)\r
973 //                      {\r
974 //                              Sts = FFFTP_FAIL;\r
975 //                              SetTaskMsg(MSGJPN241);\r
976 //                              break;\r
977 //                      }\r
978 \r
979                         Tmp = do_send(Skt, Data, Size, Mode, &TimeOutErr, CancelCheckWork);\r
980                         if(TimeOutErr == YES)\r
981                         {\r
982                                 Sts = FFFTP_FAIL;\r
983                                 SetTaskMsg(MSGJPN241);\r
984                                 break;\r
985                         }\r
986                         else if(Tmp == SOCKET_ERROR)\r
987                         {\r
988                                 Sts = FFFTP_FAIL;\r
989                                 ReportWSError("send", WSAGetLastError());\r
990                                 break;\r
991                         }\r
992 \r
993                         Size -= Tmp;\r
994                         Data += Tmp;\r
995                 }\r
996         }\r
997         return(Sts);\r
998 }\r
999 \r
1000 \r
1001 /*----- 応答メッセージを受け取る ----------------------------------------------\r
1002 *\r
1003 *       Parameter\r
1004 *               SOCKET cSkt : コントロールソケット\r
1005 *               char *Buf : メッセージを受け取るバッファ (NULL=コピーしない)\r
1006 *               int Max : バッファのサイズ\r
1007 *               int *CancelCheckWork :\r
1008 *               char *Tmp : テンポラリワーク\r
1009 *\r
1010 *       Return Value\r
1011 *               int 応答コード\r
1012 *----------------------------------------------------------------------------*/\r
1013 \r
1014 int ReadReplyMessage(SOCKET cSkt, char *Buf, int Max, int *CancelCheckWork, char *Tmp)\r
1015 {\r
1016         int iRetCode;\r
1017         int iContinue;\r
1018         int FirstCode;\r
1019         int Lines;\r
1020         int i;\r
1021 \r
1022         if(Buf != NULL)\r
1023                 memset(Buf, NUL, Max);\r
1024         Max--;\r
1025 \r
1026         FirstCode = 0;\r
1027         if(cSkt != INVALID_SOCKET)\r
1028         {\r
1029                 Lines = 0;\r
1030                 do\r
1031                 {\r
1032                         iContinue = NO;\r
1033                         iRetCode = ReadOneLine(cSkt, Tmp, ONELINE_BUF_SIZE, CancelCheckWork);\r
1034 \r
1035                         // 文字化け対策\r
1036                         ChangeFnameRemote2Local(Tmp, ONELINE_BUF_SIZE);\r
1037                         SetTaskMsg("%s", Tmp);\r
1038 \r
1039                         if(Buf != NULL)\r
1040                         {\r
1041                                 // 2行目以降の応答コードは消す\r
1042                                 if(Lines > 0)\r
1043                                 {\r
1044                                         for(i = 0; ; i++)\r
1045                                         {\r
1046                                                 if(IsDigit(Tmp[i]) == 0)\r
1047                                                         break;\r
1048                                                 Tmp[i] = ' ';\r
1049                                         }\r
1050                                 }\r
1051                                 strncat(Buf, Tmp, Max);\r
1052                                 Max = max1(0, Max-strlen(Tmp));\r
1053 \r
1054 //                              strncpy(Buf, Tmp, Max);\r
1055                         }\r
1056 \r
1057                         if((iRetCode != 421) && (iRetCode != 429))\r
1058                         {\r
1059                                 if((FirstCode == 0) &&\r
1060                                    (iRetCode >= 100) && (iRetCode <= 599))\r
1061                                 {\r
1062                                         FirstCode = iRetCode;\r
1063                                 }\r
1064 \r
1065                                 if((iRetCode < 100) || (iRetCode > 599) ||\r
1066                                    (*(Tmp + 3) == '-') ||\r
1067                                    ((FirstCode > 0) && (iRetCode != FirstCode)))\r
1068                                 {\r
1069                                         iContinue = YES;\r
1070                                 }\r
1071                         }\r
1072                         else\r
1073                                 FirstCode = iRetCode;\r
1074 \r
1075                         Lines++;\r
1076                 }\r
1077                 while(iContinue == YES);\r
1078         }\r
1079         return(FirstCode);\r
1080 }\r
1081 \r
1082 \r
1083 /*----- 1行分のデータを受け取る ----------------------------------------------\r
1084 *\r
1085 *       Parameter\r
1086 *               SOCKET cSkt : コントロールソケット\r
1087 *               char *Buf : メッセージを受け取るバッファ\r
1088 *               int Max : バッファのサイズ\r
1089 *               int *CancelCheckWork : \r
1090 *\r
1091 *       Return Value\r
1092 *               int 応答コード\r
1093 *----------------------------------------------------------------------------*/\r
1094 \r
1095 static int ReadOneLine(SOCKET cSkt, char *Buf, int Max, int *CancelCheckWork)\r
1096 {\r
1097         char *Pos;\r
1098         int SizeOnce;\r
1099         int CopySize;\r
1100         int ResCode;\r
1101         int i;\r
1102 //      fd_set ReadFds;\r
1103 //      struct timeval Tout;\r
1104 //      struct timeval *ToutPtr;\r
1105         char Tmp[1024];\r
1106         int TimeOutErr;\r
1107 \r
1108         ResCode = 0;\r
1109         if(cSkt != INVALID_SOCKET)\r
1110         {\r
1111                 memset(Buf, NUL, Max);\r
1112                 Max--;                                  /* 末尾のNULLのぶん */\r
1113                 Pos = Buf;\r
1114 \r
1115                 for(;;)\r
1116                 {\r
1117 //                      FD_ZERO(&ReadFds);\r
1118 //                      FD_SET(cSkt, &ReadFds);\r
1119 //                      ToutPtr = NULL;\r
1120 //                      if(TimeOut != 0)\r
1121 //                      {\r
1122 //                              Tout.tv_sec = TimeOut;\r
1123 //                              Tout.tv_usec = 0;\r
1124 //                              ToutPtr = &Tout;\r
1125 //                      }\r
1126 //                      i = select(0, &ReadFds, NULL, NULL, ToutPtr);\r
1127 //                      if(i == SOCKET_ERROR)\r
1128 //                      {\r
1129 //                              ReportWSError("select", WSAGetLastError());\r
1130 //                              SizeOnce = -1;\r
1131 //                              break;\r
1132 //                      }\r
1133 //                      else if(i == 0)\r
1134 //                      {\r
1135 //                              SetTaskMsg(MSGJPN242);\r
1136 //                              SizeOnce = -2;\r
1137 //                              break;\r
1138 //                      }\r
1139 \r
1140                         /* LFまでを受信するために、最初はPEEKで受信 */\r
1141                         if((SizeOnce = do_recv(cSkt, (LPSTR)Tmp, 1024, MSG_PEEK, &TimeOutErr, CancelCheckWork)) <= 0)\r
1142                         {\r
1143                                 if(TimeOutErr == YES)\r
1144                                 {\r
1145                                         SetTaskMsg(MSGJPN242);\r
1146                                         SizeOnce = -2;\r
1147                                 }\r
1148                                 else if(SizeOnce == SOCKET_ERROR)\r
1149                                 {\r
1150                                         SizeOnce = -1;\r
1151                                 }\r
1152                                 break;\r
1153                         }\r
1154 \r
1155                         /* LFを探して、あったらそこまでの長さをセット */\r
1156                         for(i = 0; i < SizeOnce ; i++)\r
1157                         {\r
1158                                 if(*(Tmp + i) == NUL || *(Tmp + i) == 0x0A)\r
1159                                 {\r
1160                                         SizeOnce = i + 1;\r
1161                                         break;\r
1162                                 }\r
1163                         }\r
1164 \r
1165                         /* 本受信 */\r
1166                         if((SizeOnce = do_recv(cSkt, Tmp, SizeOnce, 0, &TimeOutErr, CancelCheckWork)) <= 0)\r
1167                                 break;\r
1168 \r
1169                         CopySize = min1(Max, SizeOnce);\r
1170                         memcpy(Pos, Tmp, CopySize);\r
1171                         Pos += CopySize;\r
1172                         Max -= CopySize;\r
1173 \r
1174                         /* データがLFで終わっていたら1行終わり */\r
1175                         if(*(Tmp + SizeOnce - 1) == 0x0A)\r
1176                                 break;\r
1177                 }\r
1178                 *Pos = NUL;\r
1179 \r
1180                 if(SizeOnce <= 0)\r
1181                 {\r
1182                         ResCode = 429;\r
1183                         memset(Buf, 0, Max);\r
1184 \r
1185                         if((SizeOnce == -2) || (AskTransferNow() == YES))\r
1186                         // 転送中に全て中止を行うと不正なデータが得られる場合のバグ修正\r
1187 //                              DisconnectSet();\r
1188                                 cSkt = DoClose(cSkt);\r
1189                 }\r
1190                 else\r
1191                 {\r
1192                         if(IsDigit(*Buf) && IsDigit(*(Buf+1)) && IsDigit(*(Buf+2)))\r
1193                         {\r
1194                                 memset(Tmp, NUL, 4);\r
1195                                 strncpy(Tmp, Buf, 3);\r
1196                                 ResCode = atoi(Tmp);\r
1197                         }\r
1198 \r
1199                         /* 末尾の CR,LF,スペースを取り除く */\r
1200                         while((i=strlen(Buf))>2 &&\r
1201                                   (Buf[i-1]==0x0a || Buf[i-1]==0x0d || Buf[i-1]==' '))\r
1202                                 Buf[i-1]=0;\r
1203                 }\r
1204         }\r
1205         return(ResCode);\r
1206 }\r
1207 \r
1208 \r
1209 /*----- 固定長データを受け取る ------------------------------------------------\r
1210 *\r
1211 *       Parameter\r
1212 *               SOCKET cSkt : コントロールソケット\r
1213 *               char *Buf : メッセージを受け取るバッファ\r
1214 *               int Size : バイト数\r
1215 *               int *CancelCheckWork : \r
1216 *\r
1217 *       Return Value\r
1218 *               int ステータス\r
1219 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
1220 *----------------------------------------------------------------------------*/\r
1221 \r
1222 int ReadNchar(SOCKET cSkt, char *Buf, int Size, int *CancelCheckWork)\r
1223 {\r
1224 //      struct timeval Tout;\r
1225 //      struct timeval *ToutPtr;\r
1226 //      fd_set ReadFds;\r
1227 //      int i;\r
1228         int SizeOnce;\r
1229         int Sts;\r
1230         int TimeOutErr;\r
1231 \r
1232         Sts = FFFTP_FAIL;\r
1233         if(cSkt != INVALID_SOCKET)\r
1234         {\r
1235                 Sts = FFFTP_SUCCESS;\r
1236                 while(Size > 0)\r
1237                 {\r
1238 //                      FD_ZERO(&ReadFds);\r
1239 //                      FD_SET(cSkt, &ReadFds);\r
1240 //                      ToutPtr = NULL;\r
1241 //                      if(TimeOut != 0)\r
1242 //                      {\r
1243 //                              Tout.tv_sec = TimeOut;\r
1244 //                              Tout.tv_usec = 0;\r
1245 //                              ToutPtr = &Tout;\r
1246 //                      }\r
1247 //                      i = select(0, &ReadFds, NULL, NULL, ToutPtr);\r
1248 //                      if(i == SOCKET_ERROR)\r
1249 //                      {\r
1250 //                              ReportWSError("select", WSAGetLastError());\r
1251 //                              Sts = FFFTP_FAIL;\r
1252 //                              break;\r
1253 //                      }\r
1254 //                      else if(i == 0)\r
1255 //                      {\r
1256 //                              SetTaskMsg(MSGJPN243);\r
1257 //                              Sts = FFFTP_FAIL;\r
1258 //                              break;\r
1259 //                      }\r
1260 \r
1261                         if((SizeOnce = do_recv(cSkt, Buf, Size, 0, &TimeOutErr, CancelCheckWork)) <= 0)\r
1262                         {\r
1263                                 if(TimeOutErr == YES)\r
1264                                         SetTaskMsg(MSGJPN243);\r
1265                                 Sts = FFFTP_FAIL;\r
1266                                 break;\r
1267                         }\r
1268 \r
1269                         Buf += SizeOnce;\r
1270                         Size -= SizeOnce;\r
1271                 }\r
1272         }\r
1273 \r
1274         if(Sts == FFFTP_FAIL)\r
1275                 SetTaskMsg(MSGJPN244);\r
1276 \r
1277         return(Sts);\r
1278 }\r
1279 \r
1280 \r
1281 /*----- エラー文字列を取得 ----------------------------------------------------\r
1282 *\r
1283 *       Parameter\r
1284 *               UINT Error : エラー番号\r
1285 *\r
1286 *       Return Value\r
1287 *               char *エラー文字列\r
1288 *----------------------------------------------------------------------------*/\r
1289 \r
1290 char *ReturnWSError(UINT Error)\r
1291 {\r
1292         static char Msg[128];\r
1293         char *Str;\r
1294 \r
1295         switch(Error)\r
1296         {\r
1297                 case WSAVERNOTSUPPORTED:\r
1298                         Str = "version of WinSock not supported";\r
1299                         break;\r
1300 \r
1301                 case WSASYSNOTREADY:\r
1302                         Str = "WinSock not present or not responding";\r
1303                         break;\r
1304 \r
1305                 case WSAEINVAL:\r
1306                         Str = "app version not supported by DLL";\r
1307                         break;\r
1308 \r
1309                 case WSAHOST_NOT_FOUND:\r
1310                         Str = "Authoritive: Host not found";\r
1311                         break;\r
1312 \r
1313                 case WSATRY_AGAIN:\r
1314                         Str = "Non-authoritive: host not found or server failure";\r
1315                         break;\r
1316 \r
1317                 case WSANO_RECOVERY:\r
1318                         Str = "Non-recoverable: refused or not implemented";\r
1319                         break;\r
1320 \r
1321                 case WSANO_DATA:\r
1322                         Str = "Valid name, no data record for type";\r
1323                         break;\r
1324 \r
1325 #if 0\r
1326                 case WSANO_ADDRESS:\r
1327                         Str = "Valid name, no MX record";\r
1328                         break;\r
1329 #endif\r
1330 \r
1331                 case WSANOTINITIALISED:\r
1332                         Str = "WSA Startup not initialized";\r
1333                         break;\r
1334 \r
1335                 case WSAENETDOWN:\r
1336                         Str = "Network subsystem failed";\r
1337                         break;\r
1338 \r
1339                 case WSAEINPROGRESS:\r
1340                         Str = "Blocking operation in progress";\r
1341                         break;\r
1342 \r
1343                 case WSAEINTR:\r
1344                         Str = "Blocking call cancelled";\r
1345                         break;\r
1346 \r
1347                 case WSAEAFNOSUPPORT:\r
1348                         Str = "address family not supported";\r
1349                         break;\r
1350 \r
1351                 case WSAEMFILE:\r
1352                         Str = "no file descriptors available";\r
1353                         break;\r
1354 \r
1355                 case WSAENOBUFS:\r
1356                         Str = "no buffer space available";\r
1357                         break;\r
1358 \r
1359                 case WSAEPROTONOSUPPORT:\r
1360                         Str = "specified protocol not supported";\r
1361                         break;\r
1362 \r
1363                 case WSAEPROTOTYPE:\r
1364                         Str = "protocol wrong type for this socket";\r
1365                         break;\r
1366 \r
1367                 case WSAESOCKTNOSUPPORT:\r
1368                         Str = "socket type not supported for address family";\r
1369                         break;\r
1370 \r
1371                 case WSAENOTSOCK:\r
1372                         Str = "descriptor is not a socket";\r
1373                         break;\r
1374 \r
1375                 case WSAEWOULDBLOCK:\r
1376                         Str = "socket marked as non-blocking and SO_LINGER set not 0";\r
1377                         break;\r
1378 \r
1379                 case WSAEADDRINUSE:\r
1380                         Str = "address already in use";\r
1381                         break;\r
1382 \r
1383                 case WSAECONNABORTED:\r
1384                         Str = "connection aborted";\r
1385                         break;\r
1386 \r
1387                 case WSAECONNRESET:\r
1388                         Str = "connection reset";\r
1389                         break;\r
1390 \r
1391                 case WSAENOTCONN:\r
1392                         Str = "not connected";\r
1393                         break;\r
1394 \r
1395                 case WSAETIMEDOUT:\r
1396                         Str = "connection timed out";\r
1397                         break;\r
1398 \r
1399                 case WSAECONNREFUSED:\r
1400                         Str = "connection refused";\r
1401                         break;\r
1402 \r
1403                 case WSAEHOSTDOWN:\r
1404                         Str = "host down";\r
1405                         break;\r
1406 \r
1407                 case WSAEHOSTUNREACH:\r
1408                         Str = "host unreachable";\r
1409                         break;\r
1410 \r
1411                 case WSAEADDRNOTAVAIL:\r
1412                         Str = "address not available";\r
1413                         break;\r
1414 \r
1415                 default:\r
1416                         sprintf(Msg, "error %u", Error);\r
1417                         return(Msg);\r
1418         }\r
1419         return(Str);\r
1420 }\r
1421 \r
1422 \r
1423 /*----- デバッグコンソールにエラーを表示 --------------------------------------\r
1424 *\r
1425 *       Parameter\r
1426 *               char *Msg : エラーの前に表示するメッセージ\r
1427 *               UINT Error : エラー番号\r
1428 *\r
1429 *       Return Value\r
1430 *               なし\r
1431 *----------------------------------------------------------------------------*/\r
1432 \r
1433 void ReportWSError(char *Msg, UINT Error)\r
1434 {\r
1435         if(Msg != NULL)\r
1436                 DoPrintf("[[%s : %s]]", Msg, ReturnWSError(Error));\r
1437         else\r
1438                 DoPrintf("[[%s]]", ReturnWSError(Error));\r
1439 }\r
1440 \r
1441 \r
1442 /*----- ファイル名をローカル側で扱えるように変換する --------------------------\r
1443 *\r
1444 *       Parameter\r
1445 *               char *Fname : ファイル名\r
1446 *               int Max : 最大長\r
1447 *\r
1448 *       Return Value\r
1449 *               int ステータス\r
1450 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
1451 *----------------------------------------------------------------------------*/\r
1452 \r
1453 int ChangeFnameRemote2Local(char *Fname, int Max)\r
1454 {\r
1455         int Sts;\r
1456         char *Buf;\r
1457         char *Pos;\r
1458         CODECONVINFO cInfo;\r
1459         // バッファ上書きバグ対策\r
1460         char *Buf2;\r
1461 \r
1462         Sts = FFFTP_FAIL;\r
1463         if((Buf = malloc(Max)) != NULL)\r
1464         {\r
1465         // バッファ上書きバグ対策\r
1466         if((Buf2 = malloc(strlen(Fname) + 1)) != NULL)\r
1467         {\r
1468                 InitCodeConvInfo(&cInfo);\r
1469                 cInfo.KanaCnv = NO;                     //AskHostNameKana();\r
1470                 // バッファ上書きバグ対策\r
1471 //              cInfo.Str = Fname;\r
1472                 strcpy(Buf2, Fname);\r
1473                 cInfo.Str = Buf2;\r
1474                 cInfo.StrLen = strlen(Fname);\r
1475                 cInfo.Buf = Buf;\r
1476                 cInfo.BufSize = Max - 1;\r
1477 \r
1478                 // ここで全てUTF-8へ変換する\r
1479                 // TODO: SJIS以外も直接UTF-8へ変換\r
1480                 switch(AskHostNameKanji())\r
1481                 {\r
1482                         case KANJI_SJIS :\r
1483                                 ConvSJIStoUTF8N(&cInfo);\r
1484                                 *(Buf + cInfo.OutLen) = NUL;\r
1485                                 strcpy(Fname, Buf);\r
1486                                 Pos = strchr(Fname, NUL);\r
1487                                 FlushRestData(&cInfo);\r
1488                                 *(Buf + cInfo.OutLen) = NUL;\r
1489                                 strcpy(Pos, Buf);\r
1490                                 break;\r
1491 \r
1492                         case KANJI_JIS :\r
1493                                 ConvJIStoSJIS(&cInfo);\r
1494                                 *(Buf + cInfo.OutLen) = NUL;\r
1495                                 strcpy(Fname, Buf);\r
1496                                 Pos = strchr(Fname, NUL);\r
1497                                 FlushRestData(&cInfo);\r
1498                                 *(Buf + cInfo.OutLen) = NUL;\r
1499                                 strcpy(Pos, Buf);\r
1500                                 // TODO\r
1501                                 InitCodeConvInfo(&cInfo);\r
1502                                 cInfo.KanaCnv = NO;\r
1503                                 cInfo.Str = Fname;\r
1504                                 cInfo.StrLen = strlen(Fname);\r
1505                                 cInfo.Buf = Buf;\r
1506                                 cInfo.BufSize = Max - 1;\r
1507                                 ConvSJIStoUTF8N(&cInfo);\r
1508                                 *(Buf + cInfo.OutLen) = NUL;\r
1509                                 strcpy(Fname, Buf);\r
1510                                 Pos = strchr(Fname, NUL);\r
1511                                 FlushRestData(&cInfo);\r
1512                                 *(Buf + cInfo.OutLen) = NUL;\r
1513                                 strcpy(Pos, Buf);\r
1514                                 break;\r
1515 \r
1516                         case KANJI_EUC :\r
1517                                 ConvEUCtoSJIS(&cInfo);\r
1518                                 *(Buf + cInfo.OutLen) = NUL;\r
1519                                 strcpy(Fname, Buf);\r
1520                                 Pos = strchr(Fname, NUL);\r
1521                                 FlushRestData(&cInfo);\r
1522                                 *(Buf + cInfo.OutLen) = NUL;\r
1523                                 strcpy(Pos, Buf);\r
1524                                 // TODO\r
1525                                 InitCodeConvInfo(&cInfo);\r
1526                                 cInfo.KanaCnv = NO;\r
1527                                 cInfo.Str = Fname;\r
1528                                 cInfo.StrLen = strlen(Fname);\r
1529                                 cInfo.Buf = Buf;\r
1530                                 cInfo.BufSize = Max - 1;\r
1531                                 ConvSJIStoUTF8N(&cInfo);\r
1532                                 *(Buf + cInfo.OutLen) = NUL;\r
1533                                 strcpy(Fname, Buf);\r
1534                                 Pos = strchr(Fname, NUL);\r
1535                                 FlushRestData(&cInfo);\r
1536                                 *(Buf + cInfo.OutLen) = NUL;\r
1537                                 strcpy(Pos, Buf);\r
1538                                 break;\r
1539 \r
1540                         case KANJI_SMB_HEX :\r
1541                         case KANJI_SMB_CAP :\r
1542                                 ConvSMBtoSJIS(&cInfo);\r
1543                                 *(Buf + cInfo.OutLen) = NUL;\r
1544                                 strcpy(Fname, Buf);\r
1545                                 Pos = strchr(Fname, NUL);\r
1546                                 FlushRestData(&cInfo);\r
1547                                 *(Buf + cInfo.OutLen) = NUL;\r
1548                                 strcpy(Pos, Buf);\r
1549                                 // TODO\r
1550                                 InitCodeConvInfo(&cInfo);\r
1551                                 cInfo.KanaCnv = NO;\r
1552                                 cInfo.Str = Fname;\r
1553                                 cInfo.StrLen = strlen(Fname);\r
1554                                 cInfo.Buf = Buf;\r
1555                                 cInfo.BufSize = Max - 1;\r
1556                                 ConvSJIStoUTF8N(&cInfo);\r
1557                                 *(Buf + cInfo.OutLen) = NUL;\r
1558                                 strcpy(Fname, Buf);\r
1559                                 Pos = strchr(Fname, NUL);\r
1560                                 FlushRestData(&cInfo);\r
1561                                 *(Buf + cInfo.OutLen) = NUL;\r
1562                                 strcpy(Pos, Buf);\r
1563                                 break;\r
1564 \r
1565 //                      case KANJI_UTF8N :\r
1566 //                              ConvUTF8NtoSJIS(&cInfo);\r
1567 //                              *(Buf + cInfo.OutLen) = NUL;\r
1568 //                              strcpy(Fname, Buf);\r
1569 //                              Pos = strchr(Fname, NUL);\r
1570 //                              FlushRestData(&cInfo);\r
1571 //                              *(Buf + cInfo.OutLen) = NUL;\r
1572 //                              strcpy(Pos, Buf);\r
1573 //                              break;\r
1574                 }\r
1575                 // バッファ上書きバグ対策\r
1576                 free(Buf2);\r
1577                 Sts = FFFTP_SUCCESS;\r
1578                 }\r
1579                 free(Buf);\r
1580                 // バッファ上書きバグ対策\r
1581 //              Sts = FFFTP_SUCCESS;\r
1582         }\r
1583         return(Sts);\r
1584 }\r
1585 \r
1586 \r
1587 /*----- ファイル名をリモート側で扱えるように変換する --------------------------\r
1588 *\r
1589 *       Parameter\r
1590 *               char *Fname : ファイル名\r
1591 *               int Max : 最大長\r
1592 *\r
1593 *       Return Value\r
1594 *               int ステータス\r
1595 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
1596 *----------------------------------------------------------------------------*/\r
1597 \r
1598 int ChangeFnameLocal2Remote(char *Fname, int Max)\r
1599 {\r
1600         int Sts;\r
1601         char *Buf;\r
1602         char *Pos;\r
1603         CODECONVINFO cInfo;\r
1604         // バッファ上書きバグ対策\r
1605         char *Buf2;\r
1606 \r
1607         Sts = FFFTP_FAIL;\r
1608         if((Buf = malloc(Max)) != NULL)\r
1609         {\r
1610         // バッファ上書きバグ対策\r
1611         if((Buf2 = malloc(strlen(Fname) + 1)) != NULL)\r
1612         {\r
1613                 InitCodeConvInfo(&cInfo);\r
1614                 cInfo.KanaCnv = AskHostNameKana();\r
1615                 // バッファ上書きバグ対策\r
1616 //              cInfo.Str = Fname;\r
1617                 strcpy(Buf2, Fname);\r
1618                 cInfo.Str = Buf2;\r
1619                 cInfo.StrLen = strlen(Fname);\r
1620                 cInfo.Buf = Buf;\r
1621                 cInfo.BufSize = Max - 1;\r
1622 \r
1623                 // ここで全てUTF-8から変換する\r
1624                 // TODO: SJIS以外も直接UTF-8から変換\r
1625                 switch(AskHostNameKanji())\r
1626                 {\r
1627                         case KANJI_SJIS :\r
1628                                 ConvUTF8NtoSJIS(&cInfo);\r
1629                                 *(Buf + cInfo.OutLen) = NUL;\r
1630                                 strcpy(Fname, Buf);\r
1631                                 Pos = strchr(Fname, NUL);\r
1632                                 FlushRestData(&cInfo);\r
1633                                 *(Buf + cInfo.OutLen) = NUL;\r
1634                                 strcpy(Pos, Buf);\r
1635                                 break;\r
1636 \r
1637                         case KANJI_JIS :\r
1638                                 ConvUTF8NtoSJIS(&cInfo);\r
1639                                 *(Buf + cInfo.OutLen) = NUL;\r
1640                                 strcpy(Fname, Buf);\r
1641                                 Pos = strchr(Fname, NUL);\r
1642                                 FlushRestData(&cInfo);\r
1643                                 *(Buf + cInfo.OutLen) = NUL;\r
1644                                 strcpy(Pos, Buf);\r
1645                                 // TODO\r
1646                                 InitCodeConvInfo(&cInfo);\r
1647                                 cInfo.KanaCnv = NO;\r
1648                                 cInfo.Str = Fname;\r
1649                                 cInfo.StrLen = strlen(Fname);\r
1650                                 cInfo.Buf = Buf;\r
1651                                 cInfo.BufSize = Max - 1;\r
1652                                 ConvSJIStoJIS(&cInfo);\r
1653                                 *(Buf + cInfo.OutLen) = NUL;\r
1654                                 strcpy(Fname, Buf);\r
1655                                 Pos = strchr(Fname, NUL);\r
1656                                 FlushRestData(&cInfo);\r
1657                                 *(Buf + cInfo.OutLen) = NUL;\r
1658                                 strcpy(Pos, Buf);\r
1659                                 break;\r
1660 \r
1661                         case KANJI_EUC :\r
1662                                 ConvUTF8NtoSJIS(&cInfo);\r
1663                                 *(Buf + cInfo.OutLen) = NUL;\r
1664                                 strcpy(Fname, Buf);\r
1665                                 Pos = strchr(Fname, NUL);\r
1666                                 FlushRestData(&cInfo);\r
1667                                 *(Buf + cInfo.OutLen) = NUL;\r
1668                                 strcpy(Pos, Buf);\r
1669                                 // TODO\r
1670                                 InitCodeConvInfo(&cInfo);\r
1671                                 cInfo.KanaCnv = NO;\r
1672                                 cInfo.Str = Fname;\r
1673                                 cInfo.StrLen = strlen(Fname);\r
1674                                 cInfo.Buf = Buf;\r
1675                                 cInfo.BufSize = Max - 1;\r
1676                                 ConvSJIStoEUC(&cInfo);\r
1677                                 *(Buf + cInfo.OutLen) = NUL;\r
1678                                 strcpy(Fname, Buf);\r
1679                                 Pos = strchr(Fname, NUL);\r
1680                                 FlushRestData(&cInfo);\r
1681                                 *(Buf + cInfo.OutLen) = NUL;\r
1682                                 strcpy(Pos, Buf);\r
1683                                 break;\r
1684 \r
1685                         case KANJI_SMB_HEX :\r
1686                                 ConvUTF8NtoSJIS(&cInfo);\r
1687                                 *(Buf + cInfo.OutLen) = NUL;\r
1688                                 strcpy(Fname, Buf);\r
1689                                 Pos = strchr(Fname, NUL);\r
1690                                 FlushRestData(&cInfo);\r
1691                                 *(Buf + cInfo.OutLen) = NUL;\r
1692                                 strcpy(Pos, Buf);\r
1693                                 // TODO\r
1694                                 InitCodeConvInfo(&cInfo);\r
1695                                 cInfo.KanaCnv = NO;\r
1696                                 cInfo.Str = Fname;\r
1697                                 cInfo.StrLen = strlen(Fname);\r
1698                                 cInfo.Buf = Buf;\r
1699                                 cInfo.BufSize = Max - 1;\r
1700                                 ConvSJIStoSMB_HEX(&cInfo);\r
1701                                 *(Buf + cInfo.OutLen) = NUL;\r
1702                                 strcpy(Fname, Buf);\r
1703                                 Pos = strchr(Fname, NUL);\r
1704                                 FlushRestData(&cInfo);\r
1705                                 *(Buf + cInfo.OutLen) = NUL;\r
1706                                 strcpy(Pos, Buf);\r
1707                                 break;\r
1708 \r
1709                         case KANJI_SMB_CAP :\r
1710                                 ConvUTF8NtoSJIS(&cInfo);\r
1711                                 *(Buf + cInfo.OutLen) = NUL;\r
1712                                 strcpy(Fname, Buf);\r
1713                                 Pos = strchr(Fname, NUL);\r
1714                                 FlushRestData(&cInfo);\r
1715                                 *(Buf + cInfo.OutLen) = NUL;\r
1716                                 strcpy(Pos, Buf);\r
1717                                 // TODO\r
1718                                 InitCodeConvInfo(&cInfo);\r
1719                                 cInfo.KanaCnv = NO;\r
1720                                 cInfo.Str = Fname;\r
1721                                 cInfo.StrLen = strlen(Fname);\r
1722                                 cInfo.Buf = Buf;\r
1723                                 cInfo.BufSize = Max - 1;\r
1724                                 ConvSJIStoSMB_CAP(&cInfo);\r
1725                                 *(Buf + cInfo.OutLen) = NUL;\r
1726                                 strcpy(Fname, Buf);\r
1727                                 Pos = strchr(Fname, NUL);\r
1728                                 FlushRestData(&cInfo);\r
1729                                 *(Buf + cInfo.OutLen) = NUL;\r
1730                                 strcpy(Pos, Buf);\r
1731                                 break;\r
1732 \r
1733 //                      case KANJI_UTF8N :\r
1734 //                              ConvSJIStoUTF8N(&cInfo);\r
1735 //                              *(Buf + cInfo.OutLen) = NUL;\r
1736 //                              strcpy(Fname, Buf);\r
1737 //                              Pos = strchr(Fname, NUL);\r
1738 //                              FlushRestData(&cInfo);\r
1739 //                              *(Buf + cInfo.OutLen) = NUL;\r
1740 //                              strcpy(Pos, Buf);\r
1741 //                              break;\r
1742                 }\r
1743                 // バッファ上書きバグ対策\r
1744                 free(Buf2);\r
1745                 Sts = FFFTP_SUCCESS;\r
1746                 }\r
1747                 free(Buf);\r
1748                 // バッファ上書きバグ対策\r
1749 //              Sts = FFFTP_SUCCESS;\r
1750         }\r
1751         return(Sts);\r
1752 }\r
1753 \r
1754 \r
1755 /*----- パスの区切り文字をホストに合わせて変更する ----------------------------\r
1756 *\r
1757 *       Parameter\r
1758 *               char *Fname : ファイル名\r
1759 *\r
1760 *       Return Value\r
1761 *               なし\r
1762 *----------------------------------------------------------------------------*/\r
1763 static void ChangeSepaLocal2Remote(char *Fname)\r
1764 {\r
1765         if(AskHostType() == HTYPE_STRATUS)\r
1766         {\r
1767                 ReplaceAll(Fname, '/', '>');\r
1768         }\r
1769         return;\r
1770 }\r
1771 \r
1772 \r
1773 /*----- パスの区切り文字をローカルに合わせて変更する --------------------------\r
1774 *\r
1775 *       Parameter\r
1776 *               char *Fname : ファイル名\r
1777 *\r
1778 *       Return Value\r
1779 *               なし\r
1780 *----------------------------------------------------------------------------*/\r
1781 static void ChangeSepaRemote2Local(char *Fname)\r
1782 {\r
1783         if(AskHostType() == HTYPE_STRATUS)\r
1784         {\r
1785                 ReplaceAll(Fname, '>', '/');\r
1786         }\r
1787         return;\r
1788 }\r
1789 \r
1790 \r
1791 \r
1792 \r
1793 \r
1794 \r
1795 \r