• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版28c3554bd94b9b4f6dcc78175755e8fd24f8e237 (tree)
时间2012-01-19 01:09:51
作者s_kawamoto <s_kawamoto@user...>
Commiters_kawamoto

Log Message

Add support for MLSD responses from some broken hosts.

更改概述

差异

Binary files a/FFFTP_Eng_Release/FFFTP.exe and b/FFFTP_Eng_Release/FFFTP.exe differ
Binary files a/Release/FFFTP.exe and b/Release/FFFTP.exe differ
--- a/filelist.c
+++ b/filelist.c
@@ -4109,6 +4109,8 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
41094109
41104110 /* まずクリアしておく */
41114111 Ret = NODE_NONE;
4112+ // バグ対策
4113+ memset(Fname, NUL, FMAX_PATH+1);
41124114 *Size = -1;
41134115 *Attr = 0;
41144116 *Link = NO;
@@ -4844,6 +4846,81 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
48444846 break;
48454847 #endif
48464848
4849+ // MLSD対応
4850+ // 以下の形式に対応
4851+ // fact1=value1;fact2=value2;fact3=value3; filename\r\n
4852+ // 不完全な実装のホストが存在するため以下の形式も許容
4853+ // fact1=value1;fact2=value2;fact3=value3 filename\r\n
4854+ // fact1=value1;fact2=value2;fact3=value3;filename\r\n
4855+ case LIST_MLSD:
4856+ {
4857+ int i = 0;
4858+ char StrBuf[(FMAX_PATH * 2) + 1];
4859+ char Fact[FMAX_PATH + 1];
4860+ char Name[FMAX_PATH + 1];
4861+ char Value[FMAX_PATH + 1];
4862+ char* pFileName;
4863+ strncpy(StrBuf, Str, FMAX_PATH * 2);
4864+ StrBuf[FMAX_PATH * 2] = '\0';
4865+ if((pFileName = strstr(StrBuf, "; ")) != NULL)
4866+ {
4867+ *pFileName = '\0';
4868+ pFileName += 2;
4869+ }
4870+ else if((pFileName = strchr(StrBuf, ' ')) != NULL)
4871+ {
4872+ *pFileName = '\0';
4873+ pFileName++;
4874+ }
4875+ else if((pFileName = strrchr(StrBuf, ';')) != NULL)
4876+ {
4877+ *pFileName = '\0';
4878+ pFileName++;
4879+ }
4880+ if(pFileName != NULL)
4881+ strcpy(Fname, pFileName);
4882+ while(FindField2(StrBuf, Fact, ';', i, NO) == FFFTP_SUCCESS)
4883+ {
4884+ if(FindField2(Fact, Name, '=', 0, NO) == FFFTP_SUCCESS && FindField2(Fact, Value, '=', 1, NO) == FFFTP_SUCCESS)
4885+ {
4886+ if(_stricmp(Name, "type") == 0)
4887+ {
4888+ if(_stricmp(Value, "dir") == 0)
4889+ Ret = NODE_DIR;
4890+ else if(_stricmp(Value, "file") == 0)
4891+ Ret = NODE_FILE;
4892+ }
4893+ else if(_stricmp(Name, "size") == 0)
4894+ {
4895+ *Size = _atoi64(Value);
4896+ *InfoExist |= FINFO_SIZE;
4897+ }
4898+ else if(_stricmp(Name, "modify") == 0)
4899+ {
4900+ sTime.wYear = atoi_n(Value, 4);
4901+ sTime.wMonth = atoi_n(Value + 4, 2);
4902+ sTime.wDay = atoi_n(Value + 6, 2);
4903+ sTime.wHour = atoi_n(Value + 8, 2);
4904+ sTime.wMinute = atoi_n(Value + 10, 2);
4905+ sTime.wSecond = atoi_n(Value + 12, 2);
4906+ sTime.wMilliseconds = 0;
4907+ SystemTimeToFileTime(&sTime, Time);
4908+// SpecificLocalFileTime2FileTime(Time, AskHostTimeZone());
4909+ *InfoExist |= FINFO_DATE | FINFO_TIME;
4910+ }
4911+ else if(_stricmp(Name, "UNIX.mode") == 0)
4912+ {
4913+ *Attr = strtol(Value, NULL, 16);
4914+ *InfoExist |= FINFO_ATTR;
4915+ }
4916+ else if(_stricmp(Name, "UNIX.owner") == 0)
4917+ strcpy(Owner, Value);
4918+ }
4919+ i++;
4920+ }
4921+ }
4922+ break;
4923+
48474924 case LIST_UNIX_10 :
48484925 case LIST_UNIX_11 :
48494926 case LIST_UNIX_12 :
@@ -5109,57 +5186,6 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
51095186 Ret = NODE_NONE;
51105187 }
51115188 break;
5112-
5113- // MLSD対応
5114- case LIST_MLSD:
5115- {
5116- int i = 0;
5117- char Tmp[FMAX_PATH + 1];
5118- char Name[FMAX_PATH + 1];
5119- char Value[FMAX_PATH + 1];
5120- while(FindField2(Str, Tmp, ';', i, NO) == FFFTP_SUCCESS)
5121- {
5122- if(i >= 1 && strncmp(Tmp, " ", 1) == 0)
5123- strcpy(Fname, strstr(Str, "; ") + 2);
5124- else if(FindField2(Tmp, Name, '=', 0, NO) == FFFTP_SUCCESS && FindField2(Tmp, Value, '=', 1, NO) == FFFTP_SUCCESS)
5125- {
5126- if(_stricmp(Name, "type") == 0)
5127- {
5128- if(_stricmp(Value, "dir") == 0)
5129- Ret = NODE_DIR;
5130- else if(_stricmp(Value, "file") == 0)
5131- Ret = NODE_FILE;
5132- }
5133- else if(_stricmp(Name, "size") == 0)
5134- {
5135- *Size = _atoi64(Value);
5136- *InfoExist |= FINFO_SIZE;
5137- }
5138- else if(_stricmp(Name, "modify") == 0)
5139- {
5140- sTime.wYear = atoi_n(Value, 4);
5141- sTime.wMonth = atoi_n(Value + 4, 2);
5142- sTime.wDay = atoi_n(Value + 6, 2);
5143- sTime.wHour = atoi_n(Value + 8, 2);
5144- sTime.wMinute = atoi_n(Value + 10, 2);
5145- sTime.wSecond = atoi_n(Value + 12, 2);
5146- sTime.wMilliseconds = 0;
5147- SystemTimeToFileTime(&sTime, Time);
5148-// SpecificLocalFileTime2FileTime(Time, AskHostTimeZone());
5149- *InfoExist |= FINFO_DATE | FINFO_TIME;
5150- }
5151- else if(_stricmp(Name, "UNIX.mode") == 0)
5152- {
5153- *Attr = strtol(Value, NULL, 16);
5154- *InfoExist |= FINFO_ATTR;
5155- }
5156- else if(_stricmp(Name, "UNIX.owner") == 0)
5157- strcpy(Owner, Value);
5158- }
5159- i++;
5160- }
5161- }
5162- break;
51635189 }
51645190
51655191 // UTF-8対応