OSDN Git Service

Change to specify explicitly code pages.
[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                         // 時刻はGMT\r
455 //                      SpecificLocalFileTime2FileTime(Time, AskHostTimeZone());\r
456 \r
457                 }\r
458         }\r
459         return(Sts/100);\r
460 }\r
461 \r
462 \r
463 // ホスト側の日時設定\r
464 int DoMFMT(SOCKET cSkt, char *Path, FILETIME *Time, int *CancelCheckWork)\r
465 {\r
466         int Sts;\r
467         char Tmp[1024];\r
468         SYSTEMTIME sTime;\r
469 \r
470         FileTimeToSystemTime(Time, &sTime);\r
471 \r
472         Sts = CommandProcTrn(cSkt, Tmp, CancelCheckWork, "MFMT %04d%02d%02d%02d%02d%02d %s", sTime.wYear, sTime.wMonth, sTime.wDay, sTime.wHour, sTime.wMinute, sTime.wSecond, Path);\r
473         return(Sts/100);\r
474 }\r
475 \r
476 \r
477 /*----- リモート側のコマンドを実行 --------------------------------------------\r
478 *\r
479 *       Parameter\r
480 *               char *CmdStr : コマンド文字列\r
481 *\r
482 *       Return Value\r
483 *               int 応答コードの1桁目\r
484 *----------------------------------------------------------------------------*/\r
485 \r
486 // 同時接続対応\r
487 //int DoQUOTE(char *CmdStr)\r
488 int DoQUOTE(SOCKET cSkt, char *CmdStr, int *CancelCheckWork)\r
489 {\r
490         int Sts;\r
491 \r
492 //      Sts = CommandProcCmd(NULL, "%s", CmdStr);\r
493         Sts = CommandProcTrn(cSkt, NULL, CancelCheckWork, "%s", CmdStr);\r
494 \r
495         if(Sts/100 >= FTP_CONTINUE)\r
496                 SoundPlay(SND_ERROR);\r
497 \r
498         return(Sts/100);\r
499 }\r
500 \r
501 \r
502 /*----- ソケットを閉じる ------------------------------------------------------\r
503 *\r
504 *       Parameter\r
505 *               なし\r
506 *\r
507 *       Return Value\r
508 *               SOCKET 閉じた後のソケット\r
509 *----------------------------------------------------------------------------*/\r
510 \r
511 SOCKET DoClose(SOCKET Sock)\r
512 {\r
513         if(Sock != INVALID_SOCKET)\r
514         {\r
515 //              if(WSAIsBlocking())\r
516 //              {\r
517 //                      DoPrintf("Skt=%u : Cancelled blocking call", Sock);\r
518 //                      WSACancelBlockingCall();\r
519 //              }\r
520                 do_closesocket(Sock);\r
521                 DoPrintf("Skt=%u : Socket closed.", Sock);\r
522                 Sock = INVALID_SOCKET;\r
523         }\r
524         if(Sock != INVALID_SOCKET)\r
525                 DoPrintf("Skt=%u : Failed to close socket.", Sock);\r
526 \r
527         return(Sock);\r
528 }\r
529 \r
530 \r
531 /*----- ホストからログアウトする ----------------------------------------------\r
532 *\r
533 *       Parameter\r
534 *               kSOCKET ctrl_skt : ソケット\r
535 *\r
536 *       Return Value\r
537 *               int 応答コードの1桁目\r
538 *----------------------------------------------------------------------------*/\r
539 \r
540 // 同時接続対応\r
541 //int DoQUIT(SOCKET ctrl_skt)\r
542 int DoQUIT(SOCKET ctrl_skt, int *CancelCheckWork)\r
543 {\r
544         int Ret;\r
545 \r
546         Ret = FTP_COMPLETE;\r
547         if(SendQuit == YES)\r
548                 // 同時接続対応\r
549 //              Ret = command(ctrl_skt, NULL, &CheckCancelFlg, "QUIT") / 100;\r
550                 Ret = command(ctrl_skt, NULL, CancelCheckWork, "QUIT") / 100;\r
551 \r
552         return(Ret);\r
553 }\r
554 \r
555 \r
556 /*----- リモート側のディレクトリリストを取得(コマンドコントロールソケットを使用)\r
557 *\r
558 *       Parameter\r
559 *               char *AddOpt : 追加のオプション\r
560 *               char *Path : パス名\r
561 *               int Num : ファイル名番号\r
562 *\r
563 *       Return Value\r
564 *               int 応答コードの1桁目\r
565 *----------------------------------------------------------------------------*/\r
566 \r
567 int DoDirListCmdSkt(char *AddOpt, char *Path, int Num, int *CancelCheckWork)\r
568 {\r
569         int Sts;\r
570 \r
571         if(AskTransferNow() == YES)\r
572                 SktShareProh();\r
573 \r
574 //      if((Sts = DoDirList(NULL, AskCmdCtrlSkt(), AddOpt, Path, Num)) == 429)\r
575 //      {\r
576 //              ReConnectCmdSkt();\r
577                 Sts = DoDirList(NULL, AskCmdCtrlSkt(), AddOpt, Path, Num, CancelCheckWork);\r
578 \r
579                 if(Sts/100 >= FTP_CONTINUE)\r
580                         SoundPlay(SND_ERROR);\r
581 //      }\r
582         return(Sts/100);\r
583 }\r
584 \r
585 \r
586 /*----- リモート側のディレクトリリストを取得 ----------------------------------\r
587 *\r
588 *       Parameter\r
589 *               HWND hWnd : 転送中ダイアログのウインドウハンドル\r
590 *               SOCKET cSkt : コントロールソケット\r
591 *               char *AddOpt : 追加のオプション\r
592 *               char *Path : パス名 (""=カレントディレクトリ)\r
593 *               int Num : ファイル名番号\r
594 *\r
595 *       Return Value\r
596 *               int 応答コード\r
597 *----------------------------------------------------------------------------*/\r
598 \r
599 static int DoDirList(HWND hWnd, SOCKET cSkt, char *AddOpt, char *Path, int Num, int *CancelCheckWork)\r
600 {\r
601         char Tmp[FMAX_PATH];\r
602         int Sts;\r
603 \r
604 //#pragma aaa\r
605 //DoPrintf("===== DoDirList %d = %s", Num, Path);\r
606 \r
607         MakeCacheFileName(Num, Tmp);\r
608 //      MainTransPkt.ctrl_skt = cSkt;\r
609 \r
610         if(AskListCmdMode() == NO)\r
611         {\r
612                 strcpy(MainTransPkt.Cmd, "NLST");\r
613                 if(strlen(AskHostLsName()) > 0)\r
614                 {\r
615                         strcat(MainTransPkt.Cmd, " ");\r
616                         if((AskHostType() == HTYPE_ACOS) || (AskHostType() == HTYPE_ACOS_4))\r
617                                 strcat(MainTransPkt.Cmd, "'");\r
618                         strcat(MainTransPkt.Cmd, AskHostLsName());\r
619                         if((AskHostType() == HTYPE_ACOS) || (AskHostType() == HTYPE_ACOS_4))\r
620                                 strcat(MainTransPkt.Cmd, "'");\r
621                 }\r
622                 if(strlen(AddOpt) > 0)\r
623                         strcat(MainTransPkt.Cmd, AddOpt);\r
624         }\r
625         else\r
626         {\r
627                 // MLSD対応\r
628 //              strcpy(MainTransPkt.Cmd, "LIST");\r
629                 if(AskUseMLSD() && (AskHostFeature() & FEATURE_MLSD))\r
630                         strcpy(MainTransPkt.Cmd, "MLSD");\r
631                 else\r
632                         strcpy(MainTransPkt.Cmd, "LIST");\r
633                 if(strlen(AddOpt) > 0)\r
634                 {\r
635                         strcat(MainTransPkt.Cmd, " -");\r
636                         strcat(MainTransPkt.Cmd, AddOpt);\r
637                 }\r
638         }\r
639 \r
640         if(strlen(Path) > 0)\r
641                 strcat(MainTransPkt.Cmd, " ");\r
642 \r
643         strcpy(MainTransPkt.RemoteFile, Path);\r
644         strcpy(MainTransPkt.LocalFile, Tmp);\r
645         MainTransPkt.Type = TYPE_A;\r
646         MainTransPkt.Size = -1;\r
647         /* ファイルリストの中の漢字のファイル名は、別途   */\r
648         /* ChangeFnameRemote2Local で変換する                      */\r
649         MainTransPkt.KanjiCode = KANJI_NOCNV;\r
650         MainTransPkt.KanaCnv = YES;\r
651         MainTransPkt.Mode = EXIST_OVW;\r
652         MainTransPkt.ExistSize = 0;\r
653         MainTransPkt.hWndTrans = hWnd;\r
654         MainTransPkt.Next = NULL;\r
655 \r
656         Sts = DoDownload(cSkt, &MainTransPkt, YES, CancelCheckWork);\r
657 \r
658 //#pragma aaa\r
659 //DoPrintf("===== DoDirList Done.");\r
660 \r
661         return(Sts);\r
662 }\r
663 \r
664 \r
665 /*----- リモート側へコマンドを送りリプライを待つ(コマンドソケット)-----------\r
666 *\r
667 *       Parameter\r
668 *               char *Reply : リプライのコピー先 (NULL=コピーしない)\r
669 *               char *fmt : フォーマット文字列\r
670 *               ... : パラメータ\r
671 *\r
672 *       Return Value\r
673 *               int 応答コード\r
674 *\r
675 *       Note\r
676 *               コマンドコントロールソケットを使う\r
677 *----------------------------------------------------------------------------*/\r
678 \r
679 int CommandProcCmd(char *Reply, char *fmt, ...)\r
680 {\r
681         va_list Args;\r
682         char Cmd[1024];\r
683         int Sts;\r
684 \r
685         va_start(Args, fmt);\r
686         wvsprintf(Cmd, fmt, Args);\r
687         va_end(Args);\r
688 \r
689         if(AskTransferNow() == YES)\r
690                 SktShareProh();\r
691 \r
692 //#pragma aaa\r
693 //DoPrintf("**CommandProcCmd : %s", Cmd);\r
694 \r
695 //      if((Sts = command(AskCmdCtrlSkt(), Reply, "%s", Cmd)) == 429)\r
696 //      {\r
697 //              if(ReConnectCmdSkt() == FFFTP_SUCCESS)\r
698 //              {\r
699                         // 同時接続対応\r
700 //                      Sts = command(AskCmdCtrlSkt(), Reply, &CheckCancelFlg, "%s", Cmd);\r
701                         Sts = command(AskCmdCtrlSkt(), Reply, &CancelFlg, "%s", Cmd);\r
702 //              }\r
703 //      }\r
704         return(Sts);\r
705 }\r
706 \r
707 \r
708 #if defined(HAVE_TANDEM)\r
709 /*----- OSS/Guardian ファイルシステムを切り替えるコマンドを送る ---------------\r
710 *\r
711 *       Parameter\r
712 *               なし\r
713 *\r
714 *       Return Value\r
715 *               なし\r
716 *----------------------------------------------------------------------------*/\r
717 \r
718 void SwitchOSSProc(void)\r
719 {\r
720         char Buf[MAX_PATH+1];\r
721 \r
722         /* DoPWD でノード名の \ を保存するために OSSフラグも変更する */\r
723         if(AskOSS() == YES) {\r
724                 DoQUOTE(AskCmdCtrlSkt(), "GUARDIAN", &CancelFlg);\r
725                 SetOSS(NO);\r
726         } else {\r
727                 DoQUOTE(AskCmdCtrlSkt(), "OSS", &CancelFlg);\r
728                 SetOSS(YES);\r
729         }\r
730         /* Current Dir 再取得 */\r
731         if (DoPWD(Buf) == FTP_COMPLETE)\r
732                 SetRemoteDirHist(Buf);\r
733         /* ファイルリスト再読み込み */\r
734         PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(REFRESH_REMOTE, 0), 0);\r
735 \r
736         return;\r
737 }\r
738 #endif\r
739 \r
740 \r
741 /*----- リモート側へコマンドを送りリプライを待つ(転送ソケット)---------------\r
742 *\r
743 *       Parameter\r
744 *               SOCKET cSkt : ソケット\r
745 *               char *Reply : リプライのコピー先 (NULL=コピーしない)\r
746 *               int *CancelCheckWork :\r
747 *               char *fmt : フォーマット文字列\r
748 *               ... : パラメータ\r
749 *\r
750 *       Return Value\r
751 *               int 応答コード\r
752 *\r
753 *       Note\r
754 *               転送コントロールソケットを使う\r
755 *----------------------------------------------------------------------------*/\r
756 \r
757 // 同時接続対応\r
758 //int CommandProcTrn(char *Reply, char *fmt, ...)\r
759 int CommandProcTrn(SOCKET cSkt, char *Reply, int* CancelCheckWork, char *fmt, ...)\r
760 {\r
761         va_list Args;\r
762         char Cmd[1024];\r
763         int Sts;\r
764 \r
765         va_start(Args, fmt);\r
766         wvsprintf(Cmd, fmt, Args);\r
767         va_end(Args);\r
768 \r
769 //#pragma aaa\r
770 //DoPrintf("**CommandProcTrn : %s", Cmd);\r
771 \r
772 //      if((Sts = command(AskTrnCtrlSkt(), Reply, "%s", Cmd)) == 429)\r
773 //      {\r
774 //              if(ReConnectTrnSkt() == FFFTP_SUCCESS)\r
775 //                      Sts = command(AskTrnCtrlSkt(), Reply, &CheckCancelFlg, "%s", Cmd);\r
776                         Sts = command(cSkt, Reply, CancelCheckWork, "%s", Cmd);\r
777 //      }\r
778         return(Sts);\r
779 }\r
780 \r
781 \r
782 /*----- コマンドを送りリプライを待つ ------------------------------------------\r
783 *\r
784 *       Parameter\r
785 *               SOCKET cSkt : コントロールソケット\r
786 *               char *Reply : リプライのコピー先 (NULL=コピーしない)\r
787 *               char *fmt : フォーマット文字列\r
788 *               ... : パラメータ\r
789 *\r
790 *       Return Value\r
791 *               int 応答コード\r
792 *\r
793 *       Note\r
794 *               ホストのファイル名の漢字コードに応じて、ここで漢字コードの変換を行なう\r
795 *----------------------------------------------------------------------------*/\r
796 \r
797 //#pragma aaa\r
798 //static int cntcnt = 0;\r
799 \r
800 // SFTP対応\r
801 int ConvertFTPCommandToPuTTYSFTP(SOCKET cSkt, char *Reply, int *CancelCheckWork, char *Cmd)\r
802 {\r
803         // TODO:\r
804         // 未実装\r
805         int Sts;\r
806         char NewCmd[FMAX_PATH*2];\r
807         static char RenameFrom[FMAX_PATH+1];\r
808         Sts = 429;\r
809         Reply[0] = '\0';\r
810         if(strcmp(Cmd, "QUIT") == 0)\r
811         {\r
812                 sprintf(NewCmd, "ls\r\n");\r
813                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
814         }\r
815         if(strcmp(Cmd, "LIST") == 0)\r
816         {\r
817                 sprintf(NewCmd, "ls\r\n");\r
818                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
819         }\r
820         else if(strncmp(Cmd, "REST ", 5) == 0)\r
821         {\r
822                 SFTP_SetFilePosition(cSkt, (LONGLONG)_strtoi64(&Cmd[5], NULL, 10));\r
823         }\r
824         else if(strncmp(Cmd, "RETR ", 5) == 0)\r
825         {\r
826                 sprintf(NewCmd, "get \"%s\"\r\n", &Cmd[5]);\r
827                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
828         }\r
829         else if(strncmp(Cmd, "STOR ", 5) == 0)\r
830         {\r
831                 sprintf(NewCmd, "put \"%s\"\r\n", &Cmd[5]);\r
832                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
833         }\r
834         else if(strncmp(Cmd, "APPE ", 5) == 0)\r
835         {\r
836                 sprintf(NewCmd, "reput \"%s\"\r\n", &Cmd[5]);\r
837                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
838         }\r
839         else if(strncmp(Cmd, "DELE ", 5) == 0)\r
840         {\r
841                 sprintf(NewCmd, "rm \"%s\"\r\n", &Cmd[5]);\r
842                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
843         }\r
844         else if(strncmp(Cmd, "CWD ", 4) == 0)\r
845         {\r
846                 sprintf(NewCmd, "cd \"%s\"\r\n", &Cmd[4]);\r
847                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
848         }\r
849         else if(strcmp(Cmd, "PWD") == 0)\r
850         {\r
851                 sprintf(NewCmd, "pwd\r\n");\r
852                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
853         }\r
854         else if(strcmp(Cmd, "XPWD") == 0)\r
855         {\r
856                 sprintf(NewCmd, "pwd\r\n");\r
857                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
858         }\r
859         else if(strncmp(Cmd, "MKD ", 4) == 0)\r
860         {\r
861                 sprintf(NewCmd, "mkdir \"%s\"\r\n", &Cmd[4]);\r
862                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
863         }\r
864         else if(strncmp(Cmd, "RMD ", 4) == 0)\r
865         {\r
866                 sprintf(NewCmd, "rmdir \"%s\"\r\n", &Cmd[4]);\r
867                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
868         }\r
869         else if(strncmp(Cmd, "RNFR ", 5) == 0)\r
870         {\r
871                 strcpy(RenameFrom, &Cmd[5]);\r
872         }\r
873         else if(strncmp(Cmd, "RNTO ", 5) == 0)\r
874         {\r
875                 sprintf(NewCmd, "mv \"%s\" \"%s\"\r\n", RenameFrom, &Cmd[5]);\r
876                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
877         }\r
878         else if(strncmp(Cmd, "SITE CHMOD ", 11) == 0)\r
879         {\r
880                 Cmd[14] = '\0';\r
881                 sprintf(NewCmd, "chmod %s \"%s\"\r\n", &Cmd[11], &Cmd[15]);\r
882                 SFTP_send(cSkt, NewCmd, strlen(NewCmd), 0);\r
883         }\r
884         return Sts;\r
885 }\r
886 \r
887 int command(SOCKET cSkt, char *Reply, int *CancelCheckWork, char *fmt, ...)\r
888 {\r
889         va_list Args;\r
890         char Cmd[FMAX_PATH*2];\r
891         int Sts;\r
892         char TmpBuf[ONELINE_BUF_SIZE];\r
893 \r
894         if(cSkt != INVALID_SOCKET)\r
895         {\r
896                 va_start(Args, fmt);\r
897                 wvsprintf(Cmd, fmt, Args);\r
898                 va_end(Args);\r
899 \r
900                 // SFTP対応\r
901                 if(IsSFTPAttached(cSkt))\r
902                         return ConvertFTPCommandToPuTTYSFTP(cSkt, Reply, CancelCheckWork, Cmd);\r
903 \r
904                 if(strncmp(Cmd, "PASS ", 5) == 0)\r
905                         SetTaskMsg(">PASS [xxxxxx]");\r
906                 else if((strncmp(Cmd, "USER ", 5) == 0) ||\r
907                                 (strncmp(Cmd, "OPEN ", 5) == 0))\r
908                 {\r
909                         SetTaskMsg(">%s", Cmd);\r
910                 }\r
911                 else\r
912                 {\r
913                         ChangeSepaLocal2Remote(Cmd);\r
914                         SetTaskMsg(">%s", Cmd);\r
915                         ChangeFnameLocal2Remote(Cmd, FMAX_PATH*2);\r
916                 }\r
917 \r
918 //              DoPrintf("SEND : %s", Cmd);\r
919                 strcat(Cmd, "\x0D\x0A");\r
920 \r
921                 if(Reply != NULL)\r
922                         strcpy(Reply, "");\r
923 \r
924                 Sts = 429;\r
925                 if(SendData(cSkt, Cmd, strlen(Cmd), 0, CancelCheckWork) == FFFTP_SUCCESS)\r
926                 {\r
927                         Sts = ReadReplyMessage(cSkt, Reply, 1024, CancelCheckWork, TmpBuf);\r
928                 }\r
929 \r
930 //#pragma aaa\r
931 //if(Reply != NULL)\r
932 //      DoPrintf("%x : %x : %s : %s", cSkt, &TmpBuf, Cmd, Reply);\r
933 //else\r
934 //      DoPrintf("%x : %x : %s : NULL", cSkt, &TmpBuf, Cmd);\r
935 \r
936 //              DoPrintf("command() RET=%d", Sts);\r
937         }\r
938         else\r
939                 Sts = 429;\r
940 \r
941         return(Sts);\r
942 }\r
943 \r
944 \r
945 /*----- データを送る ----------------------------------------------------------\r
946 *\r
947 *       Parameter\r
948 *               SOCKET Skt : ソケット\r
949 *               char *Data : データ\r
950 *               int Size : 送るデータのサイズ\r
951 *               int Mode : コールモード\r
952 *\r
953 *       Return Value\r
954 *               int ステータス\r
955 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
956 *----------------------------------------------------------------------------*/\r
957 \r
958 int SendData(SOCKET Skt, char *Data, int Size, int Mode, int *CancelCheckWork)\r
959 {\r
960         int Sts;\r
961         int Tmp;\r
962 //      fd_set SendFds;\r
963 //      struct timeval Tout;\r
964 //      struct timeval *ToutPtr;\r
965         int TimeOutErr;\r
966 \r
967         Sts = FFFTP_FAIL;\r
968         if(Skt != INVALID_SOCKET)\r
969         {\r
970                 Sts = FFFTP_SUCCESS;\r
971                 while(Size > 0)\r
972                 {\r
973 //                      FD_ZERO(&SendFds);\r
974 //                      FD_SET(Skt, &SendFds);\r
975 //                      ToutPtr = NULL;\r
976 //                      if(TimeOut != 0)\r
977 //                      {\r
978 //                              Tout.tv_sec = TimeOut;\r
979 //                              Tout.tv_usec = 0;\r
980 //                              ToutPtr = &Tout;\r
981 //                      }\r
982 //                      Tmp = select(0, NULL, &SendFds, NULL, ToutPtr);\r
983 //                      if(Tmp == SOCKET_ERROR)\r
984 //                      {\r
985 //                              Sts = FFFTP_FAIL;\r
986 //                              ReportWSError("select", WSAGetLastError());\r
987 //                              break;\r
988 //                      }\r
989 //                      else if(Tmp == 0)\r
990 //                      {\r
991 //                              Sts = FFFTP_FAIL;\r
992 //                              SetTaskMsg(MSGJPN241);\r
993 //                              break;\r
994 //                      }\r
995 \r
996                         Tmp = do_send(Skt, Data, Size, Mode, &TimeOutErr, CancelCheckWork);\r
997                         if(TimeOutErr == YES)\r
998                         {\r
999                                 Sts = FFFTP_FAIL;\r
1000                                 SetTaskMsg(MSGJPN241);\r
1001                                 break;\r
1002                         }\r
1003                         else if(Tmp == SOCKET_ERROR)\r
1004                         {\r
1005                                 Sts = FFFTP_FAIL;\r
1006                                 ReportWSError("send", WSAGetLastError());\r
1007                                 break;\r
1008                         }\r
1009 \r
1010                         Size -= Tmp;\r
1011                         Data += Tmp;\r
1012                 }\r
1013         }\r
1014         return(Sts);\r
1015 }\r
1016 \r
1017 \r
1018 /*----- 応答メッセージを受け取る ----------------------------------------------\r
1019 *\r
1020 *       Parameter\r
1021 *               SOCKET cSkt : コントロールソケット\r
1022 *               char *Buf : メッセージを受け取るバッファ (NULL=コピーしない)\r
1023 *               int Max : バッファのサイズ\r
1024 *               int *CancelCheckWork :\r
1025 *               char *Tmp : テンポラリワーク\r
1026 *\r
1027 *       Return Value\r
1028 *               int 応答コード\r
1029 *----------------------------------------------------------------------------*/\r
1030 \r
1031 int ReadReplyMessage(SOCKET cSkt, char *Buf, int Max, int *CancelCheckWork, char *Tmp)\r
1032 {\r
1033         int iRetCode;\r
1034         int iContinue;\r
1035         int FirstCode;\r
1036         int Lines;\r
1037         int i;\r
1038 \r
1039         if(Buf != NULL)\r
1040                 memset(Buf, NUL, Max);\r
1041         Max--;\r
1042 \r
1043         FirstCode = 0;\r
1044         if(cSkt != INVALID_SOCKET)\r
1045         {\r
1046                 Lines = 0;\r
1047                 do\r
1048                 {\r
1049                         iContinue = NO;\r
1050                         iRetCode = ReadOneLine(cSkt, Tmp, ONELINE_BUF_SIZE, CancelCheckWork);\r
1051 \r
1052                         // 文字化け対策\r
1053                         ChangeFnameRemote2Local(Tmp, ONELINE_BUF_SIZE);\r
1054                         SetTaskMsg("%s", Tmp);\r
1055 \r
1056                         if(Buf != NULL)\r
1057                         {\r
1058                                 // 2行目以降の応答コードは消す\r
1059                                 if(Lines > 0)\r
1060                                 {\r
1061                                         for(i = 0; ; i++)\r
1062                                         {\r
1063                                                 if(IsDigit(Tmp[i]) == 0)\r
1064                                                         break;\r
1065                                                 Tmp[i] = ' ';\r
1066                                         }\r
1067                                 }\r
1068                                 strncat(Buf, Tmp, Max);\r
1069                                 Max = max1(0, Max-strlen(Tmp));\r
1070 \r
1071 //                              strncpy(Buf, Tmp, Max);\r
1072                         }\r
1073 \r
1074                         if((iRetCode != 421) && (iRetCode != 429))\r
1075                         {\r
1076                                 if((FirstCode == 0) &&\r
1077                                    (iRetCode >= 100) && (iRetCode <= 599))\r
1078                                 {\r
1079                                         FirstCode = iRetCode;\r
1080                                 }\r
1081 \r
1082                                 if((iRetCode < 100) || (iRetCode > 599) ||\r
1083                                    (*(Tmp + 3) == '-') ||\r
1084                                    ((FirstCode > 0) && (iRetCode != FirstCode)))\r
1085                                 {\r
1086                                         iContinue = YES;\r
1087                                 }\r
1088                         }\r
1089                         else\r
1090                                 FirstCode = iRetCode;\r
1091 \r
1092                         Lines++;\r
1093                 }\r
1094                 while(iContinue == YES);\r
1095         }\r
1096         return(FirstCode);\r
1097 }\r
1098 \r
1099 \r
1100 /*----- 1行分のデータを受け取る ----------------------------------------------\r
1101 *\r
1102 *       Parameter\r
1103 *               SOCKET cSkt : コントロールソケット\r
1104 *               char *Buf : メッセージを受け取るバッファ\r
1105 *               int Max : バッファのサイズ\r
1106 *               int *CancelCheckWork : \r
1107 *\r
1108 *       Return Value\r
1109 *               int 応答コード\r
1110 *----------------------------------------------------------------------------*/\r
1111 \r
1112 static int ReadOneLine(SOCKET cSkt, char *Buf, int Max, int *CancelCheckWork)\r
1113 {\r
1114         char *Pos;\r
1115         int SizeOnce;\r
1116         int CopySize;\r
1117         int ResCode;\r
1118         int i;\r
1119 //      fd_set ReadFds;\r
1120 //      struct timeval Tout;\r
1121 //      struct timeval *ToutPtr;\r
1122         char Tmp[1024];\r
1123         int TimeOutErr;\r
1124 \r
1125         ResCode = 0;\r
1126         if(cSkt != INVALID_SOCKET)\r
1127         {\r
1128                 memset(Buf, NUL, Max);\r
1129                 Max--;                                  /* 末尾のNULLのぶん */\r
1130                 Pos = Buf;\r
1131 \r
1132                 for(;;)\r
1133                 {\r
1134 //                      FD_ZERO(&ReadFds);\r
1135 //                      FD_SET(cSkt, &ReadFds);\r
1136 //                      ToutPtr = NULL;\r
1137 //                      if(TimeOut != 0)\r
1138 //                      {\r
1139 //                              Tout.tv_sec = TimeOut;\r
1140 //                              Tout.tv_usec = 0;\r
1141 //                              ToutPtr = &Tout;\r
1142 //                      }\r
1143 //                      i = select(0, &ReadFds, NULL, NULL, ToutPtr);\r
1144 //                      if(i == SOCKET_ERROR)\r
1145 //                      {\r
1146 //                              ReportWSError("select", WSAGetLastError());\r
1147 //                              SizeOnce = -1;\r
1148 //                              break;\r
1149 //                      }\r
1150 //                      else if(i == 0)\r
1151 //                      {\r
1152 //                              SetTaskMsg(MSGJPN242);\r
1153 //                              SizeOnce = -2;\r
1154 //                              break;\r
1155 //                      }\r
1156 \r
1157                         /* LFまでを受信するために、最初はPEEKで受信 */\r
1158                         if((SizeOnce = do_recv(cSkt, (LPSTR)Tmp, 1024, MSG_PEEK, &TimeOutErr, CancelCheckWork)) <= 0)\r
1159                         {\r
1160                                 if(TimeOutErr == YES)\r
1161                                 {\r
1162                                         SetTaskMsg(MSGJPN242);\r
1163                                         SizeOnce = -2;\r
1164                                 }\r
1165                                 else if(SizeOnce == SOCKET_ERROR)\r
1166                                 {\r
1167                                         SizeOnce = -1;\r
1168                                 }\r
1169                                 break;\r
1170                         }\r
1171 \r
1172                         /* LFを探して、あったらそこまでの長さをセット */\r
1173                         for(i = 0; i < SizeOnce ; i++)\r
1174                         {\r
1175                                 if(*(Tmp + i) == NUL || *(Tmp + i) == 0x0A)\r
1176                                 {\r
1177                                         SizeOnce = i + 1;\r
1178                                         break;\r
1179                                 }\r
1180                         }\r
1181 \r
1182                         /* 本受信 */\r
1183                         if((SizeOnce = do_recv(cSkt, Tmp, SizeOnce, 0, &TimeOutErr, CancelCheckWork)) <= 0)\r
1184                                 break;\r
1185 \r
1186                         CopySize = min1(Max, SizeOnce);\r
1187                         memcpy(Pos, Tmp, CopySize);\r
1188                         Pos += CopySize;\r
1189                         Max -= CopySize;\r
1190 \r
1191                         /* データがLFで終わっていたら1行終わり */\r
1192                         if(*(Tmp + SizeOnce - 1) == 0x0A)\r
1193                                 break;\r
1194                 }\r
1195                 *Pos = NUL;\r
1196 \r
1197                 if(SizeOnce <= 0)\r
1198                 {\r
1199                         ResCode = 429;\r
1200                         memset(Buf, 0, Max);\r
1201 \r
1202                         if((SizeOnce == -2) || (AskTransferNow() == YES))\r
1203                         // 転送中に全て中止を行うと不正なデータが得られる場合のバグ修正\r
1204 //                              DisconnectSet();\r
1205                                 cSkt = DoClose(cSkt);\r
1206                 }\r
1207                 else\r
1208                 {\r
1209                         if(IsDigit(*Buf) && IsDigit(*(Buf+1)) && IsDigit(*(Buf+2)))\r
1210                         {\r
1211                                 memset(Tmp, NUL, 4);\r
1212                                 strncpy(Tmp, Buf, 3);\r
1213                                 ResCode = atoi(Tmp);\r
1214                         }\r
1215 \r
1216                         /* 末尾の CR,LF,スペースを取り除く */\r
1217                         while((i=strlen(Buf))>2 &&\r
1218                                   (Buf[i-1]==0x0a || Buf[i-1]==0x0d || Buf[i-1]==' '))\r
1219                                 Buf[i-1]=0;\r
1220                 }\r
1221         }\r
1222         return(ResCode);\r
1223 }\r
1224 \r
1225 \r
1226 /*----- 固定長データを受け取る ------------------------------------------------\r
1227 *\r
1228 *       Parameter\r
1229 *               SOCKET cSkt : コントロールソケット\r
1230 *               char *Buf : メッセージを受け取るバッファ\r
1231 *               int Size : バイト数\r
1232 *               int *CancelCheckWork : \r
1233 *\r
1234 *       Return Value\r
1235 *               int ステータス\r
1236 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
1237 *----------------------------------------------------------------------------*/\r
1238 \r
1239 int ReadNchar(SOCKET cSkt, char *Buf, int Size, int *CancelCheckWork)\r
1240 {\r
1241 //      struct timeval Tout;\r
1242 //      struct timeval *ToutPtr;\r
1243 //      fd_set ReadFds;\r
1244 //      int i;\r
1245         int SizeOnce;\r
1246         int Sts;\r
1247         int TimeOutErr;\r
1248 \r
1249         Sts = FFFTP_FAIL;\r
1250         if(cSkt != INVALID_SOCKET)\r
1251         {\r
1252                 Sts = FFFTP_SUCCESS;\r
1253                 while(Size > 0)\r
1254                 {\r
1255 //                      FD_ZERO(&ReadFds);\r
1256 //                      FD_SET(cSkt, &ReadFds);\r
1257 //                      ToutPtr = NULL;\r
1258 //                      if(TimeOut != 0)\r
1259 //                      {\r
1260 //                              Tout.tv_sec = TimeOut;\r
1261 //                              Tout.tv_usec = 0;\r
1262 //                              ToutPtr = &Tout;\r
1263 //                      }\r
1264 //                      i = select(0, &ReadFds, NULL, NULL, ToutPtr);\r
1265 //                      if(i == SOCKET_ERROR)\r
1266 //                      {\r
1267 //                              ReportWSError("select", WSAGetLastError());\r
1268 //                              Sts = FFFTP_FAIL;\r
1269 //                              break;\r
1270 //                      }\r
1271 //                      else if(i == 0)\r
1272 //                      {\r
1273 //                              SetTaskMsg(MSGJPN243);\r
1274 //                              Sts = FFFTP_FAIL;\r
1275 //                              break;\r
1276 //                      }\r
1277 \r
1278                         if((SizeOnce = do_recv(cSkt, Buf, Size, 0, &TimeOutErr, CancelCheckWork)) <= 0)\r
1279                         {\r
1280                                 if(TimeOutErr == YES)\r
1281                                         SetTaskMsg(MSGJPN243);\r
1282                                 Sts = FFFTP_FAIL;\r
1283                                 break;\r
1284                         }\r
1285 \r
1286                         Buf += SizeOnce;\r
1287                         Size -= SizeOnce;\r
1288                 }\r
1289         }\r
1290 \r
1291         if(Sts == FFFTP_FAIL)\r
1292                 SetTaskMsg(MSGJPN244);\r
1293 \r
1294         return(Sts);\r
1295 }\r
1296 \r
1297 \r
1298 /*----- エラー文字列を取得 ----------------------------------------------------\r
1299 *\r
1300 *       Parameter\r
1301 *               UINT Error : エラー番号\r
1302 *\r
1303 *       Return Value\r
1304 *               char *エラー文字列\r
1305 *----------------------------------------------------------------------------*/\r
1306 \r
1307 char *ReturnWSError(UINT Error)\r
1308 {\r
1309         static char Msg[128];\r
1310         char *Str;\r
1311 \r
1312         switch(Error)\r
1313         {\r
1314                 case WSAVERNOTSUPPORTED:\r
1315                         Str = "version of WinSock not supported";\r
1316                         break;\r
1317 \r
1318                 case WSASYSNOTREADY:\r
1319                         Str = "WinSock not present or not responding";\r
1320                         break;\r
1321 \r
1322                 case WSAEINVAL:\r
1323                         Str = "app version not supported by DLL";\r
1324                         break;\r
1325 \r
1326                 case WSAHOST_NOT_FOUND:\r
1327                         Str = "Authoritive: Host not found";\r
1328                         break;\r
1329 \r
1330                 case WSATRY_AGAIN:\r
1331                         Str = "Non-authoritive: host not found or server failure";\r
1332                         break;\r
1333 \r
1334                 case WSANO_RECOVERY:\r
1335                         Str = "Non-recoverable: refused or not implemented";\r
1336                         break;\r
1337 \r
1338                 case WSANO_DATA:\r
1339                         Str = "Valid name, no data record for type";\r
1340                         break;\r
1341 \r
1342 #if 0\r
1343                 case WSANO_ADDRESS:\r
1344                         Str = "Valid name, no MX record";\r
1345                         break;\r
1346 #endif\r
1347 \r
1348                 case WSANOTINITIALISED:\r
1349                         Str = "WSA Startup not initialized";\r
1350                         break;\r
1351 \r
1352                 case WSAENETDOWN:\r
1353                         Str = "Network subsystem failed";\r
1354                         break;\r
1355 \r
1356                 case WSAEINPROGRESS:\r
1357                         Str = "Blocking operation in progress";\r
1358                         break;\r
1359 \r
1360                 case WSAEINTR:\r
1361                         Str = "Blocking call cancelled";\r
1362                         break;\r
1363 \r
1364                 case WSAEAFNOSUPPORT:\r
1365                         Str = "address family not supported";\r
1366                         break;\r
1367 \r
1368                 case WSAEMFILE:\r
1369                         Str = "no file descriptors available";\r
1370                         break;\r
1371 \r
1372                 case WSAENOBUFS:\r
1373                         Str = "no buffer space available";\r
1374                         break;\r
1375 \r
1376                 case WSAEPROTONOSUPPORT:\r
1377                         Str = "specified protocol not supported";\r
1378                         break;\r
1379 \r
1380                 case WSAEPROTOTYPE:\r
1381                         Str = "protocol wrong type for this socket";\r
1382                         break;\r
1383 \r
1384                 case WSAESOCKTNOSUPPORT:\r
1385                         Str = "socket type not supported for address family";\r
1386                         break;\r
1387 \r
1388                 case WSAENOTSOCK:\r
1389                         Str = "descriptor is not a socket";\r
1390                         break;\r
1391 \r
1392                 case WSAEWOULDBLOCK:\r
1393                         Str = "socket marked as non-blocking and SO_LINGER set not 0";\r
1394                         break;\r
1395 \r
1396                 case WSAEADDRINUSE:\r
1397                         Str = "address already in use";\r
1398                         break;\r
1399 \r
1400                 case WSAECONNABORTED:\r
1401                         Str = "connection aborted";\r
1402                         break;\r
1403 \r
1404                 case WSAECONNRESET:\r
1405                         Str = "connection reset";\r
1406                         break;\r
1407 \r
1408                 case WSAENOTCONN:\r
1409                         Str = "not connected";\r
1410                         break;\r
1411 \r
1412                 case WSAETIMEDOUT:\r
1413                         Str = "connection timed out";\r
1414                         break;\r
1415 \r
1416                 case WSAECONNREFUSED:\r
1417                         Str = "connection refused";\r
1418                         break;\r
1419 \r
1420                 case WSAEHOSTDOWN:\r
1421                         Str = "host down";\r
1422                         break;\r
1423 \r
1424                 case WSAEHOSTUNREACH:\r
1425                         Str = "host unreachable";\r
1426                         break;\r
1427 \r
1428                 case WSAEADDRNOTAVAIL:\r
1429                         Str = "address not available";\r
1430                         break;\r
1431 \r
1432                 default:\r
1433                         sprintf(Msg, "error %u", Error);\r
1434                         return(Msg);\r
1435         }\r
1436         return(Str);\r
1437 }\r
1438 \r
1439 \r
1440 /*----- デバッグコンソールにエラーを表示 --------------------------------------\r
1441 *\r
1442 *       Parameter\r
1443 *               char *Msg : エラーの前に表示するメッセージ\r
1444 *               UINT Error : エラー番号\r
1445 *\r
1446 *       Return Value\r
1447 *               なし\r
1448 *----------------------------------------------------------------------------*/\r
1449 \r
1450 void ReportWSError(char *Msg, UINT Error)\r
1451 {\r
1452         if(Msg != NULL)\r
1453                 DoPrintf("[[%s : %s]]", Msg, ReturnWSError(Error));\r
1454         else\r
1455                 DoPrintf("[[%s]]", ReturnWSError(Error));\r
1456 }\r
1457 \r
1458 \r
1459 /*----- ファイル名をローカル側で扱えるように変換する --------------------------\r
1460 *\r
1461 *       Parameter\r
1462 *               char *Fname : ファイル名\r
1463 *               int Max : 最大長\r
1464 *\r
1465 *       Return Value\r
1466 *               int ステータス\r
1467 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
1468 *----------------------------------------------------------------------------*/\r
1469 \r
1470 int ChangeFnameRemote2Local(char *Fname, int Max)\r
1471 {\r
1472         int Sts;\r
1473         char *Buf;\r
1474         char *Pos;\r
1475         CODECONVINFO cInfo;\r
1476         // バッファ上書きバグ対策\r
1477         char *Buf2;\r
1478 \r
1479         Sts = FFFTP_FAIL;\r
1480         if((Buf = malloc(Max)) != NULL)\r
1481         {\r
1482         // バッファ上書きバグ対策\r
1483         if((Buf2 = malloc(strlen(Fname) + 1)) != NULL)\r
1484         {\r
1485                 InitCodeConvInfo(&cInfo);\r
1486                 cInfo.KanaCnv = NO;                     //AskHostNameKana();\r
1487                 // バッファ上書きバグ対策\r
1488 //              cInfo.Str = Fname;\r
1489                 strcpy(Buf2, Fname);\r
1490                 cInfo.Str = Buf2;\r
1491                 cInfo.StrLen = strlen(Fname);\r
1492                 cInfo.Buf = Buf;\r
1493                 cInfo.BufSize = Max - 1;\r
1494 \r
1495                 // ここで全てUTF-8へ変換する\r
1496                 // TODO: SJIS以外も直接UTF-8へ変換\r
1497                 switch(AskHostNameKanji())\r
1498                 {\r
1499                         case KANJI_SJIS :\r
1500                                 ConvSJIStoUTF8N(&cInfo);\r
1501                                 *(Buf + cInfo.OutLen) = NUL;\r
1502                                 strcpy(Fname, Buf);\r
1503                                 Pos = strchr(Fname, NUL);\r
1504                                 FlushRestData(&cInfo);\r
1505                                 *(Buf + cInfo.OutLen) = NUL;\r
1506                                 strcpy(Pos, Buf);\r
1507                                 break;\r
1508 \r
1509                         case KANJI_JIS :\r
1510                                 ConvJIStoSJIS(&cInfo);\r
1511                                 *(Buf + cInfo.OutLen) = NUL;\r
1512                                 strcpy(Fname, Buf);\r
1513                                 Pos = strchr(Fname, NUL);\r
1514                                 FlushRestData(&cInfo);\r
1515                                 *(Buf + cInfo.OutLen) = NUL;\r
1516                                 strcpy(Pos, Buf);\r
1517                                 // TODO\r
1518                                 InitCodeConvInfo(&cInfo);\r
1519                                 cInfo.KanaCnv = NO;\r
1520                                 cInfo.Str = Fname;\r
1521                                 cInfo.StrLen = strlen(Fname);\r
1522                                 cInfo.Buf = Buf;\r
1523                                 cInfo.BufSize = Max - 1;\r
1524                                 ConvSJIStoUTF8N(&cInfo);\r
1525                                 *(Buf + cInfo.OutLen) = NUL;\r
1526                                 strcpy(Fname, Buf);\r
1527                                 Pos = strchr(Fname, NUL);\r
1528                                 FlushRestData(&cInfo);\r
1529                                 *(Buf + cInfo.OutLen) = NUL;\r
1530                                 strcpy(Pos, Buf);\r
1531                                 break;\r
1532 \r
1533                         case KANJI_EUC :\r
1534                                 ConvEUCtoSJIS(&cInfo);\r
1535                                 *(Buf + cInfo.OutLen) = NUL;\r
1536                                 strcpy(Fname, Buf);\r
1537                                 Pos = strchr(Fname, NUL);\r
1538                                 FlushRestData(&cInfo);\r
1539                                 *(Buf + cInfo.OutLen) = NUL;\r
1540                                 strcpy(Pos, Buf);\r
1541                                 // TODO\r
1542                                 InitCodeConvInfo(&cInfo);\r
1543                                 cInfo.KanaCnv = NO;\r
1544                                 cInfo.Str = Fname;\r
1545                                 cInfo.StrLen = strlen(Fname);\r
1546                                 cInfo.Buf = Buf;\r
1547                                 cInfo.BufSize = Max - 1;\r
1548                                 ConvSJIStoUTF8N(&cInfo);\r
1549                                 *(Buf + cInfo.OutLen) = NUL;\r
1550                                 strcpy(Fname, Buf);\r
1551                                 Pos = strchr(Fname, NUL);\r
1552                                 FlushRestData(&cInfo);\r
1553                                 *(Buf + cInfo.OutLen) = NUL;\r
1554                                 strcpy(Pos, Buf);\r
1555                                 break;\r
1556 \r
1557                         case KANJI_SMB_HEX :\r
1558                         case KANJI_SMB_CAP :\r
1559                                 ConvSMBtoSJIS(&cInfo);\r
1560                                 *(Buf + cInfo.OutLen) = NUL;\r
1561                                 strcpy(Fname, Buf);\r
1562                                 Pos = strchr(Fname, NUL);\r
1563                                 FlushRestData(&cInfo);\r
1564                                 *(Buf + cInfo.OutLen) = NUL;\r
1565                                 strcpy(Pos, Buf);\r
1566                                 // TODO\r
1567                                 InitCodeConvInfo(&cInfo);\r
1568                                 cInfo.KanaCnv = NO;\r
1569                                 cInfo.Str = Fname;\r
1570                                 cInfo.StrLen = strlen(Fname);\r
1571                                 cInfo.Buf = Buf;\r
1572                                 cInfo.BufSize = Max - 1;\r
1573                                 ConvSJIStoUTF8N(&cInfo);\r
1574                                 *(Buf + cInfo.OutLen) = NUL;\r
1575                                 strcpy(Fname, Buf);\r
1576                                 Pos = strchr(Fname, NUL);\r
1577                                 FlushRestData(&cInfo);\r
1578                                 *(Buf + cInfo.OutLen) = NUL;\r
1579                                 strcpy(Pos, Buf);\r
1580                                 break;\r
1581 \r
1582 //                      case KANJI_UTF8N :\r
1583 //                              ConvUTF8NtoSJIS(&cInfo);\r
1584 //                              *(Buf + cInfo.OutLen) = NUL;\r
1585 //                              strcpy(Fname, Buf);\r
1586 //                              Pos = strchr(Fname, NUL);\r
1587 //                              FlushRestData(&cInfo);\r
1588 //                              *(Buf + cInfo.OutLen) = NUL;\r
1589 //                              strcpy(Pos, Buf);\r
1590 //                              break;\r
1591                 }\r
1592                 // バッファ上書きバグ対策\r
1593                 free(Buf2);\r
1594                 Sts = FFFTP_SUCCESS;\r
1595                 }\r
1596                 free(Buf);\r
1597                 // バッファ上書きバグ対策\r
1598 //              Sts = FFFTP_SUCCESS;\r
1599         }\r
1600         return(Sts);\r
1601 }\r
1602 \r
1603 \r
1604 /*----- ファイル名をリモート側で扱えるように変換する --------------------------\r
1605 *\r
1606 *       Parameter\r
1607 *               char *Fname : ファイル名\r
1608 *               int Max : 最大長\r
1609 *\r
1610 *       Return Value\r
1611 *               int ステータス\r
1612 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
1613 *----------------------------------------------------------------------------*/\r
1614 \r
1615 int ChangeFnameLocal2Remote(char *Fname, int Max)\r
1616 {\r
1617         int Sts;\r
1618         char *Buf;\r
1619         char *Pos;\r
1620         CODECONVINFO cInfo;\r
1621         // バッファ上書きバグ対策\r
1622         char *Buf2;\r
1623 \r
1624         Sts = FFFTP_FAIL;\r
1625         if((Buf = malloc(Max)) != NULL)\r
1626         {\r
1627         // バッファ上書きバグ対策\r
1628         if((Buf2 = malloc(strlen(Fname) + 1)) != NULL)\r
1629         {\r
1630                 InitCodeConvInfo(&cInfo);\r
1631                 cInfo.KanaCnv = AskHostNameKana();\r
1632                 // バッファ上書きバグ対策\r
1633 //              cInfo.Str = Fname;\r
1634                 strcpy(Buf2, Fname);\r
1635                 cInfo.Str = Buf2;\r
1636                 cInfo.StrLen = strlen(Fname);\r
1637                 cInfo.Buf = Buf;\r
1638                 cInfo.BufSize = Max - 1;\r
1639 \r
1640                 // ここで全てUTF-8から変換する\r
1641                 // TODO: SJIS以外も直接UTF-8から変換\r
1642                 switch(AskHostNameKanji())\r
1643                 {\r
1644                         case KANJI_SJIS :\r
1645                                 ConvUTF8NtoSJIS(&cInfo);\r
1646                                 *(Buf + cInfo.OutLen) = NUL;\r
1647                                 strcpy(Fname, Buf);\r
1648                                 Pos = strchr(Fname, NUL);\r
1649                                 FlushRestData(&cInfo);\r
1650                                 *(Buf + cInfo.OutLen) = NUL;\r
1651                                 strcpy(Pos, Buf);\r
1652                                 break;\r
1653 \r
1654                         case KANJI_JIS :\r
1655                                 ConvUTF8NtoSJIS(&cInfo);\r
1656                                 *(Buf + cInfo.OutLen) = NUL;\r
1657                                 strcpy(Fname, Buf);\r
1658                                 Pos = strchr(Fname, NUL);\r
1659                                 FlushRestData(&cInfo);\r
1660                                 *(Buf + cInfo.OutLen) = NUL;\r
1661                                 strcpy(Pos, Buf);\r
1662                                 // TODO\r
1663                                 InitCodeConvInfo(&cInfo);\r
1664                                 cInfo.KanaCnv = NO;\r
1665                                 cInfo.Str = Fname;\r
1666                                 cInfo.StrLen = strlen(Fname);\r
1667                                 cInfo.Buf = Buf;\r
1668                                 cInfo.BufSize = Max - 1;\r
1669                                 ConvSJIStoJIS(&cInfo);\r
1670                                 *(Buf + cInfo.OutLen) = NUL;\r
1671                                 strcpy(Fname, Buf);\r
1672                                 Pos = strchr(Fname, NUL);\r
1673                                 FlushRestData(&cInfo);\r
1674                                 *(Buf + cInfo.OutLen) = NUL;\r
1675                                 strcpy(Pos, Buf);\r
1676                                 break;\r
1677 \r
1678                         case KANJI_EUC :\r
1679                                 ConvUTF8NtoSJIS(&cInfo);\r
1680                                 *(Buf + cInfo.OutLen) = NUL;\r
1681                                 strcpy(Fname, Buf);\r
1682                                 Pos = strchr(Fname, NUL);\r
1683                                 FlushRestData(&cInfo);\r
1684                                 *(Buf + cInfo.OutLen) = NUL;\r
1685                                 strcpy(Pos, Buf);\r
1686                                 // TODO\r
1687                                 InitCodeConvInfo(&cInfo);\r
1688                                 cInfo.KanaCnv = NO;\r
1689                                 cInfo.Str = Fname;\r
1690                                 cInfo.StrLen = strlen(Fname);\r
1691                                 cInfo.Buf = Buf;\r
1692                                 cInfo.BufSize = Max - 1;\r
1693                                 ConvSJIStoEUC(&cInfo);\r
1694                                 *(Buf + cInfo.OutLen) = NUL;\r
1695                                 strcpy(Fname, Buf);\r
1696                                 Pos = strchr(Fname, NUL);\r
1697                                 FlushRestData(&cInfo);\r
1698                                 *(Buf + cInfo.OutLen) = NUL;\r
1699                                 strcpy(Pos, Buf);\r
1700                                 break;\r
1701 \r
1702                         case KANJI_SMB_HEX :\r
1703                                 ConvUTF8NtoSJIS(&cInfo);\r
1704                                 *(Buf + cInfo.OutLen) = NUL;\r
1705                                 strcpy(Fname, Buf);\r
1706                                 Pos = strchr(Fname, NUL);\r
1707                                 FlushRestData(&cInfo);\r
1708                                 *(Buf + cInfo.OutLen) = NUL;\r
1709                                 strcpy(Pos, Buf);\r
1710                                 // TODO\r
1711                                 InitCodeConvInfo(&cInfo);\r
1712                                 cInfo.KanaCnv = NO;\r
1713                                 cInfo.Str = Fname;\r
1714                                 cInfo.StrLen = strlen(Fname);\r
1715                                 cInfo.Buf = Buf;\r
1716                                 cInfo.BufSize = Max - 1;\r
1717                                 ConvSJIStoSMB_HEX(&cInfo);\r
1718                                 *(Buf + cInfo.OutLen) = NUL;\r
1719                                 strcpy(Fname, Buf);\r
1720                                 Pos = strchr(Fname, NUL);\r
1721                                 FlushRestData(&cInfo);\r
1722                                 *(Buf + cInfo.OutLen) = NUL;\r
1723                                 strcpy(Pos, Buf);\r
1724                                 break;\r
1725 \r
1726                         case KANJI_SMB_CAP :\r
1727                                 ConvUTF8NtoSJIS(&cInfo);\r
1728                                 *(Buf + cInfo.OutLen) = NUL;\r
1729                                 strcpy(Fname, Buf);\r
1730                                 Pos = strchr(Fname, NUL);\r
1731                                 FlushRestData(&cInfo);\r
1732                                 *(Buf + cInfo.OutLen) = NUL;\r
1733                                 strcpy(Pos, Buf);\r
1734                                 // TODO\r
1735                                 InitCodeConvInfo(&cInfo);\r
1736                                 cInfo.KanaCnv = NO;\r
1737                                 cInfo.Str = Fname;\r
1738                                 cInfo.StrLen = strlen(Fname);\r
1739                                 cInfo.Buf = Buf;\r
1740                                 cInfo.BufSize = Max - 1;\r
1741                                 ConvSJIStoSMB_CAP(&cInfo);\r
1742                                 *(Buf + cInfo.OutLen) = NUL;\r
1743                                 strcpy(Fname, Buf);\r
1744                                 Pos = strchr(Fname, NUL);\r
1745                                 FlushRestData(&cInfo);\r
1746                                 *(Buf + cInfo.OutLen) = NUL;\r
1747                                 strcpy(Pos, Buf);\r
1748                                 break;\r
1749 \r
1750 //                      case KANJI_UTF8N :\r
1751 //                              ConvSJIStoUTF8N(&cInfo);\r
1752 //                              *(Buf + cInfo.OutLen) = NUL;\r
1753 //                              strcpy(Fname, Buf);\r
1754 //                              Pos = strchr(Fname, NUL);\r
1755 //                              FlushRestData(&cInfo);\r
1756 //                              *(Buf + cInfo.OutLen) = NUL;\r
1757 //                              strcpy(Pos, Buf);\r
1758 //                              break;\r
1759                 }\r
1760                 // バッファ上書きバグ対策\r
1761                 free(Buf2);\r
1762                 Sts = FFFTP_SUCCESS;\r
1763                 }\r
1764                 free(Buf);\r
1765                 // バッファ上書きバグ対策\r
1766 //              Sts = FFFTP_SUCCESS;\r
1767         }\r
1768         return(Sts);\r
1769 }\r
1770 \r
1771 \r
1772 /*----- パスの区切り文字をホストに合わせて変更する ----------------------------\r
1773 *\r
1774 *       Parameter\r
1775 *               char *Fname : ファイル名\r
1776 *\r
1777 *       Return Value\r
1778 *               なし\r
1779 *----------------------------------------------------------------------------*/\r
1780 static void ChangeSepaLocal2Remote(char *Fname)\r
1781 {\r
1782         if(AskHostType() == HTYPE_STRATUS)\r
1783         {\r
1784                 ReplaceAll(Fname, '/', '>');\r
1785         }\r
1786         return;\r
1787 }\r
1788 \r
1789 \r
1790 /*----- パスの区切り文字をローカルに合わせて変更する --------------------------\r
1791 *\r
1792 *       Parameter\r
1793 *               char *Fname : ファイル名\r
1794 *\r
1795 *       Return Value\r
1796 *               なし\r
1797 *----------------------------------------------------------------------------*/\r
1798 static void ChangeSepaRemote2Local(char *Fname)\r
1799 {\r
1800         if(AskHostType() == HTYPE_STRATUS)\r
1801         {\r
1802                 ReplaceAll(Fname, '>', '/');\r
1803         }\r
1804         return;\r
1805 }\r
1806 \r
1807 \r
1808 \r
1809 \r
1810 \r
1811 \r
1812 \r