📄 ftp.c
字号:
Parameter = Parameter;
PLen = PLen;
SendStr(Fip->LinkHandle, (char *)Restinfo1);
sscanf(Parameter + 1, "%u", &length);
sprintf(s, "%u", length);
SendStr(Fip->LinkHandle, s);
SendStr(Fip->LinkHandle, (char *)Restinfo2);
Fip->StateEx = FTP_RSET;
Fip->temp1 = length;
return 0;
}
/*********************************************************************************************************
** Function name: CmdRnfr
** Descriptions: the processing function of RNFR
** Input: Parameter: Parameter string
** PLen: legnth of Parameter string
** Fip: FPT linker info
** Output 0: OK
** other: NOK
** Created by: chenmingji
** Created Date: 2005-06-03
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
static uint8 CmdRnfr(char *Parameter, uint8 PLen, FTP_INFO *Fip)
//重命名(RNFR)
//这个命令和我们在其它操作系统中使用的一样,只不过后面要跟"rename to"
//指定新的文件名。
{
Parameter = Parameter;
PLen = PLen;
SendStr(Fip->LinkHandle, (char *)CmdNotAllow);
Fip->StateEx = 0;
return 0;
}
/*********************************************************************************************************
** Function name: CmdRnto
** Descriptions: the processing function of RNTO
** Input: Parameter: Parameter string
** PLen: legnth of Parameter string
** Fip: FPT linker info
** Output 0: OK
** other: NOK
** Created by: chenmingji
** Created Date: 2005-06-03
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
static uint8 CmdRnto(char *Parameter, uint8 PLen, FTP_INFO *Fip)
//重命名为(RNTO)
//此命令和上面的命令共同完成对文件的重命名。
{
Parameter = Parameter;
PLen = PLen;
SendStr(Fip->LinkHandle, (char *)CmdNotAllow);
Fip->StateEx = 0;
return 0;
}
/*********************************************************************************************************
** Function name: CmdAbor
** Descriptions: the processing function of ABOR
** Input: Parameter: Parameter string
** PLen: legnth of Parameter string
** Fip: FPT linker info
** Output 0: OK
** other: NOK
** Created by: chenmingji
** Created Date: 2005-06-03
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
static uint8 CmdAbor(char *Parameter, uint8 PLen, FTP_INFO *Fip)
//放弃(ABOR)
//此命令通知服务中止以前的FTP命令和与之相关的数据传送。如果先前的操作
//已经完成,则没有动作,返回226。如果没有完成,返回426,然后再返回
//226。关闭控制连接,数据连接不关闭。
{
Parameter = Parameter;
PLen = PLen;
if (Fip->StateEx == FTP_TRAN)
{
while (OSTaskDelReq(Fip->TraTaskPrio) != OS_TASK_NOT_EXIST)
{
OSTimeDly(5);
}
SendStr(Fip->LinkHandle, (char *)CloseTra);
}
Fip->StateEx = 0;
SendStr(Fip->LinkHandle, (char *)AbortInfo);
return 0;
}
/*********************************************************************************************************
** Function name: CmdDele
** Descriptions: the processing function of DELE
** Input: Parameter: Parameter string
** PLen: legnth of Parameter string
** Fip: FPT linker info
** Output 0: OK
** other: NOK
** Created by: chenmingji
** Created Date: 2005-06-03
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
static uint8 CmdDele(char *Parameter, uint8 PLen, FTP_INFO *Fip)
//删除(DELE)
//此命令删除指定路径下的文件。用户进程负责对删除的提示。
{
strcpy((char *)(Fip->Buf), C550);
if (Parameter[1] != '/')
{
strcat((char *)(Fip->Buf), (const char *)Fip->Path);
}
if (strlen((const char *)(Fip->Buf)) + PLen < FTP_BUF_LENGTH + 5)
{
Parameter[PLen - 2] = 0;
strcat((char *)Fip->Buf, (const char *)(Parameter + 1));
if (FtpDele(Fip) == TRUE)
{
SendStr(Fip->LinkHandle, (char *)DelOK);
}
else
{
strcat((char *)(Fip->Buf), DelNok);
SendStr(Fip->LinkHandle, (char *)(Fip->Buf));
}
}
else
{
SendStr(Fip->LinkHandle, (char *)ParNotAllow);
}
return 0;
}
/*********************************************************************************************************
** Function name: CmdRmd
** Descriptions: the processing function of RMD
** Input: Parameter: Parameter string
** PLen: legnth of Parameter string
** Fip: FPT linker info
** Output 0: OK
** other: NOK
** Created by: chenmingji
** Created Date: 2005-06-03
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
static uint8 CmdRmd(char *Parameter, uint8 PLen, FTP_INFO *Fip)
//删除目录(RMD)
//此命令删除目录。
{
strcpy((char *)(Fip->Buf), C257);
if (Parameter[1] != '/')
{
strcat((char *)(Fip->Buf), (const char *)(Fip->Path));
}
if (strlen((const char *)(Fip->Buf)) + PLen < FTP_BUF_LENGTH + 5)
{
Parameter[PLen - 2] = 0;
if (PLen > 4)
if (Parameter[PLen - 3] == '/')
{
Parameter[PLen - 3] = 0;
}
strcat((char *)Fip->Buf, (const char *)Parameter + 1);
if (FtpRmd(Fip) == TRUE)
{
Fip->Buf[4] = '\"';
strcat((char *)(Fip->Buf), RmdOK);
SendStr(Fip->LinkHandle, (char *)(Fip->Buf));
}
else
{
strcat((char *)(Fip->Buf), DelNok);
SendStr(Fip->LinkHandle, (char *)(char *)(Fip->Buf));
}
}
else
{
SendStr(Fip->LinkHandle, (char *)ParNotAllow);
}
Fip->StateEx = 0;
return 0;
}
/*********************************************************************************************************
** Function name: CmdMkd
** Descriptions: the processing function of MKD
** Input: Parameter: Parameter string
** PLen: legnth of Parameter string
** Fip: FPT linker info
** Output 0: OK
** other: NOK
** Created by: chenmingji
** Created Date: 2005-06-03
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
static uint8 CmdMkd(char *Parameter, uint8 PLen, FTP_INFO *Fip)
//创建目录(MKD)
//此命令在指定路径下创建新目录。
{
strcpy((char *)(Fip->Buf), C257);
if (Parameter[1] != '/')
{
strcat((char *)(Fip->Buf), (const char *)(Fip->Path));
}
if (strlen((const char *)(Fip->Buf)) + PLen < FTP_BUF_LENGTH + 5)
{
Parameter[PLen - 2] = 0;
if (PLen > 4)
if (Parameter[PLen - 3] == '/')
{
Parameter[PLen - 3] = 0;
}
strcat((char *)Fip->Buf, (const char *)Parameter + 1);
if (FtpMkd(Fip) == TRUE)
{
Fip->Buf[4] = '\"';
strcat((char *)(Fip->Buf), MkdOK);
SendStr(Fip->LinkHandle, (char *)(Fip->Buf));
}
else
{
strcat((char *)(Fip->Buf), MkdNok);
SendStr(Fip->LinkHandle, (char *)(char *)(Fip->Buf));
}
}
else
{
SendStr(Fip->LinkHandle, (char *)ParNotAllow);
}
Fip->StateEx = 0;
return 0;
}
/*********************************************************************************************************
** Function name: CmdPwd
** Descriptions: the processing function of PWD
** Input: Parameter: Parameter string
** PLen: legnth of Parameter string
** Fip: FPT linker info
** Output 0: OK
** other: NOK
** Created by: chenmingji
** Created Date: 2005-06-03
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
static uint8 Cm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -