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

📄 ftp.c

📁 周立功公司2410开发板上所有基于UCOS开发的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    cp -= 2;
    
    Legth = cp - Fip->Path;
    while (Legth > 3)
    {
        if (*cp == '/')
        {
            cp++;
            *cp = 0;
            break;
        }
        cp--;
    }
    Fip->Buf[0] = 0;
    strcat((char *)(Fip->Buf), CwdInfo1);
    strcat((char *)(Fip->Buf), (const char *)(Fip->Path));
    strcat((char *)(Fip->Buf), (const char *)(CwdInfo2));
    SendStr(Fip->LinkHandle, (char *)(Fip->Buf));
    Fip->StateEx = 0;
    return 0; 
}

/*********************************************************************************************************
** Function name: CmdSmnt
** Descriptions: the processing function of SMNT
** 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 CmdSmnt(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //结构加载(SMNT)
                            //此命令使用户在不改变登录或帐户信息的情况下加载另一个文件系统数据
                            //结构。传输参数也不变。参数是文件目录或与系统相关的文件集合。
{
    Parameter = Parameter;
    PLen = PLen;
    
    SendStr(Fip->LinkHandle, (char *)CmdNotAllow);
    Fip->StateEx = 0;
    return 0; 
}

/*********************************************************************************************************
** Function name: CmdRein
** Descriptions: the processing function of REIN
** 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 CmdRein(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //重新初始化(REIN)
                            //此命令终止USER,将所有I/O和帐户信息写入,但不许进行中的数据传输
                            //完成。重置所有参数,控制连接打开,可以再次开始USER命令。
{
    Parameter = Parameter;
    PLen = PLen;
    
    SendStr(Fip->LinkHandle, (char *)CmdNotAllow);
    Fip->StateEx = 0;
    return 0; 
}

/*********************************************************************************************************
** Function name: CmdQuit
** Descriptions: the processing function of QUIT
** 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 CmdQuit(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //退出登录(QUIT);必须
                            //此命令终止USER,如果没有数据传输,服务器关闭控制连接;如果有数据
                            //传输,在得到传输响应后服务器关闭控制连接。如果用户进程正在向不同
                            //的USER传输数据,不希望对每个USER关闭然后再打开,可以使用REIN。对
                            //控制连接的意外关闭,可以导致服务器运行中止(ABOR)和退出登录(QUIT)。
{
    Parameter = Parameter;
    PLen = PLen;
    
    SendStr(Fip->LinkHandle, (char *)UsrQuit);
    close(Fip->LinkHandle);
    if (Fip->StateEx == FTP_TRAN)
    {
        while (OSTaskDelReq(Fip->TraTaskPrio) != OS_TASK_NOT_EXIST)
        {
            OSTimeDly(5);
        }
    }
    Fip->StateEx = 0;
    return 0; 
}

/*********************************************************************************************************
** Function name: CmdPort
** Descriptions: the processing function of PORT
** 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 CmdPort(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //数据端口(PORT);必须
                            //参数是要使用的数据连接端口,通常情况下对此不需要命令响应。如果使
                            //用此命令时,要发送32位的IP地址和16位的TCP端口号。上面的信息以8位
                            //为一组,逗号间隔十进制传输,如下例:
                            //PORT h1,h2,h3,h4,p1,p2
                            //其中h1是IP地址的最高8位。
{
    unsigned int a, b, c, d;
    uint8 temp1, temp2;
    Parameter = Parameter;
    PLen = PLen;
    
    sscanf(Parameter + 1, "%d,%d,%d,%d,%d,%d\r\n", &a, &b ,&c, &d, &temp1, &temp2);
    Fip->ClientIp[0] = a;
    Fip->ClientIp[1] = b;
    Fip->ClientIp[2] = c;
    Fip->ClientIp[3] = d;
    Fip->ClienPort = temp1 * 256 | temp2;

    SendStr(Fip->LinkHandle, (char *)PortAccept);
    Fip->StateEx = 0;
    return 0; 
}

/*********************************************************************************************************
** Function name: CmdPasv
** Descriptions: the processing function of PASV
** 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 CmdPasv(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //被动(PASV)
                            //此命令要求服务器DTP在指定的数据端口侦听,进入被动接收请求的状态,
                            //参数是主机和端口地址。
{
    Parameter = Parameter;
    PLen = PLen;
    
    SendStr(Fip->LinkHandle, (char *)PasvNotAllow);
    Fip->StateEx = 0;
    return 0; 
}

/*********************************************************************************************************
** Function name: CmdType
** Descriptions: the processing function of TYPE
** 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 CmdType(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //表示类型(TYPE);必须
                            //参数指定表示类型。有些类型需要第二个参数,第一个参数由单个Telnet
                            //字符定义,第二个参数是十进制整数指定字节大小,参数间以<SP>分隔。
                            //下面是格式:(缺图)
                            //默认表示类型是ASCII非打印字符,如果参数未改变,以后只改变了第一个
                            //参数,则使用默认值。
{
    char cc;
    
    PLen = PLen;
    
    Parameter++;
    cc = *Parameter;
    if (cc == 'A' ||  cc == 'a') 
    {
        Parameter++;
        if (*Parameter == '\r')
        {
            SendStr(Fip->LinkHandle, (char *)TypeInfo);
            return 0;
        }
        if (*Parameter++ == ' ')
        if (*Parameter == 'N' || *Parameter == 'n')
        {
            Parameter++;
            if (*Parameter == '\r')
            {
                SendStr(Fip->LinkHandle, (char *)TypeInfo);
                return 0;
            }
        }
    }

    if (cc == 'I' ||  cc == 'i') 
    {
        Parameter++;
        if (*Parameter == '\r')
        {
            SendStr(Fip->LinkHandle, (char *)TypeInfo1);
            return 0;
        }
        if (*Parameter++ == ' ')
        if (*Parameter == 'N' || *Parameter == 'n')
        {
            Parameter++;
            if (*Parameter == '\r')
            {
                SendStr(Fip->LinkHandle, (char *)TypeInfo1);
                return 0;
            }
        }
    }

    SendStr(Fip->LinkHandle, (char *)ParNotAllow);
    Fip->StateEx = 0;
    return 1;
}

/*********************************************************************************************************
** Function name: CmdStru
** Descriptions: the processing function of STRU
** 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 CmdStru(char *Parameter, uint8 PLen, FTP_INFO *Fip)
                            //文件结构(STRU)
                            //参数是一个Telnet字符代码指定文件结构。下面是代码及其意义:
                            //F - 文件(非记录结构),它是默认值
                            //R - 记录结构
                            //P - 页结构
{
    Parameter = Parameter;
    PLen = PLen;
    

⌨️ 快捷键说明

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