test.c

来自「嵌入式linux下面的ftp程序」· C语言 代码 · 共 48 行

C
48
字号
#include <stdio.h>
#include "SimpleFTP.h"

int main(int argc, char *argv[])
{
	int i = -2;
	SimpleFTP *ftp;
	char * path = 0;
	i = SimpleFTP_init(&ftp);
	if( i == -1)
	{
		printf("allocate memery error!");
		return -1;
	}

	i = ftpConnect(ftp ,"root","123456" ,"192.168.1.155" , 21);
	if( i)
	{
		printf("last reply :%s\n",getLastReply(ftp));
	}else{
		printf("connect or login failed!\n");
		SimpleFTP_free(ftp);
		 return 0;
	}

    i = -2;
	ascii(ftp);
	bin(ftp);
	cwd(ftp ,"/tftpboot");
	path = pwd(ftp);
	printf("current path is :%s \n",path);
	free(path);
	get(ftp ,"./newld","ld");

	i = stor(ftp ,"./test.c");
	if( i )
	{
		printf("stor ok \n");
	}else{
		printf("stor failed !\n");
	}
	printf("last reply :%s\n", getLastReply(ftp));
	ftpDisconnect(ftp); 
    SimpleFTP_free(ftp);
	return 0;
}

⌨️ 快捷键说明

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