⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftp.c

📁 周立功公司2410开发板上所有基于UCOS开发的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    SendStr(Fip->LinkHandle, (char *)CmdNotAllow);
    Fip->StateEx = 0;
    return 0; 
}

/*********************************************************************************************************
** Function name: CmdMode
** Descriptions: the processing function of MODE
** 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 CmdMode(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //传输模式(MODE);必须
                            //参数是一个Telnet字符代码指定传输模式。下面是代码及其意义:
                            //S - 流(默认值)
                            //B - 块
                            //C - 压缩
{
    char cc;
    
    PLen = PLen;
    
    Parameter++;
    cc = *Parameter;
    if (cc == 'S' ||  cc == 's') 
    {
        Parameter++;
        if (*Parameter == '\r')
        {
            SendStr(Fip->LinkHandle, (char *)ModeInfo);
            return 0;
        }
    }
    SendStr(Fip->LinkHandle, (char *)ParNotAllow);
    Fip->StateEx = 0;
    return 1;
}

/*********************************************************************************************************
** Function name: CmdRetr
** Descriptions: the processing function of RETR
** 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 CmdRetr(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //获得文件(RETR);必须
                            //此命令使服务器DTP传送指定路径内的文件复本到服务器或用户DTP。这边服
                            //务器上文件的状态和内容不受影响。
{
    if (Fip->StateEx != FTP_TRAN)
    {
        Fip->Buf[0] = 0;
        if (Parameter[1] != '/')
        {
            strcpy((char *)(Fip->Buf), (const char *)Fip->Path + 1);
        }
        
        if (strlen((const char *)(Fip->Buf)) + PLen < FTP_BUF_LENGTH + 5)
        {
            Parameter[PLen - 2] = 0;
            strcat((char *)Fip->Buf, (const char *)(Parameter + 1));

            if (Fip->StateEx != FTP_RSET)
            {
                Fip->temp1 = 0;
            }
        
            Fip->run = FtpRetr;

            while (OSTaskDelReq(Fip->TraTaskPrio) != OS_TASK_NOT_EXIST) /* 等待任务结束 */
            {
                OSTimeDly(5);
            }
            OSTaskCreate(FtpTranTask,(void *)(Fip),
                 &Fip->TraTaskStk[FtpTraTaskStkLengh - 1],
                 Fip->TraTaskPrio);

            SendStr(Fip->LinkHandle, (char *)RetrStart);
            Fip->StateEx = FTP_TRAN;
        }
        else
        {
            SendStr(Fip->LinkHandle, (char *)ParNotAllow);
        }
    }
    else
    {
        SendStr(Fip->LinkHandle, (char *)TransNOk);
    }
    return 0; 
}

/*********************************************************************************************************
** Function name: CmdStor
** Descriptions: the processing function of STOR
** 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 CmdStor(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //保存(STOR);必须
                            //此命令使服务器DTP接收数据连接上传送过来的数据,并将数据保存在服务
                            //器的文件中。如果文件已存在,原文件将被覆盖。如果文件不存在,则新建
                            //文件。
{
    if (Fip->StateEx != FTP_TRAN)
    {
        Fip->Buf[0] = 0;
        if (Parameter[1] != '/')
        {
            strcpy((char *)(Fip->Buf), (const char *)Fip->Path + 1);
        }

        if (strlen((const char *)(Fip->Buf)) + PLen < FTP_BUF_LENGTH + 5)
        {
            Parameter[PLen - 2] = 0;
            strcat((char *)Fip->Buf, (const char *)(Parameter + 1));

            if (Fip->StateEx != FTP_RSET)
            {
                Fip->temp1 = 0;
            }
        
            Fip->run = FtpStor;
            while (OSTaskDelReq(Fip->TraTaskPrio) != OS_TASK_NOT_EXIST) /* 等待任务结束 */
            {
                OSTimeDly(5);
            }
            OSTaskCreate(FtpTranTask,(void *)(Fip),
                 &Fip->TraTaskStk[FtpTraTaskStkLengh - 1],
                 Fip->TraTaskPrio);

            SendStr(Fip->LinkHandle, (char *)RetrStart);
            Fip->StateEx = FTP_TRAN;
        }
        else
        {
            SendStr(Fip->LinkHandle, (char *)ParNotAllow);
        }
    }
    else
    {
        SendStr(Fip->LinkHandle, (char *)TransNOk);
    }
    return 0; 
}

/*********************************************************************************************************
** Function name: CmdStou
** Descriptions: the processing function of STOU
** 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 CmdStou(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //唯一保存(STOU);必须
                            //此命令和STOR差不多,此命令要求在此目录下的文件名是唯一的,对此命令
                            //的响应必须包括产生的用户名。
{
    Parameter = Parameter;
    PLen = PLen;
    
    SendStr(Fip->LinkHandle, (char *)CmdNotAllow);
    Fip->StateEx = 0;
    return 0; 
}

/*********************************************************************************************************
** Function name: CmdAppe
** Descriptions: the processing function of APPE
** 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 CmdAppe(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //附加(APPE)
                            //它和STOR的功能差不多,但是如果文件在指定路径内已存在,则把数据附加
                            //到原文件尾部,如果不存在则新建文件。
{
    Parameter = Parameter;
    PLen = PLen;
    
    SendStr(Fip->LinkHandle, (char *)CmdNotAllow);
    Fip->StateEx = 0;
    return 0; 
}

/*********************************************************************************************************
** Function name: CmdAllo
** Descriptions: the processing function of ALLO
** 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 CmdAllo(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //分配(ALLO)
                            //此命令用于在一些主机上为新传送的文件分配足够的存储空间。参数是十进
                            //制的逻辑字节数。如果是记录或页结构,页或记录的最大大小也需要,这在
                            //第二个参数内以十进制指定。第二个参数是可选的,如果有它,它和第一个
                            //参数以Telnet字符<SP> R <SP>分隔。此命令在STOR或APPE命令后,对于不
                            //需要分配存储空间的机器,它的作用等于NOOP。
{
    Parameter = Parameter;
    PLen = PLen;
    
    SendStr(Fip->LinkHandle, (char *)CmdNotAllow);
    Fip->StateEx = 0;
    return 0; 
}

/*********************************************************************************************************
** Function name: CmdRest
** Descriptions: the processing function of REST
** 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 CmdRest(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //重新开始(REST)
                            //参数域代表服务器要重新开始的那一点,此命令并不传送文件,而是略过指
                            //定点后的数据,此命令后应该跟其它要求文件传输的FTP命令。
{
    uint32 length;
    char s[12];
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -