forked from xuos/xiuos
add print file content function
This commit is contained in:
parent
380aa361fe
commit
c508c2d43b
|
@ -90,7 +90,7 @@ static int FtpEnterPasv(char *ipaddr, int *port)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FtpDownload(char *name, void *buf, int len)
|
int FtpDownload(char *name, char *buf, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -138,6 +138,10 @@ int FtpDownload(char *name, void *buf, int len)
|
||||||
}
|
}
|
||||||
//下载完成
|
//下载完成
|
||||||
printf("download %d/%d bytes complete.\r\n", i, len);
|
printf("download %d/%d bytes complete.\r\n", i, len);
|
||||||
|
printf("====file content====\n");
|
||||||
|
buf[100] = '\0';
|
||||||
|
printf("%s\n",buf);
|
||||||
|
printf("====================\n");
|
||||||
// FILE *fp = NULL;
|
// FILE *fp = NULL;
|
||||||
|
|
||||||
// fp = fopen(name+1, "wb");
|
// fp = fopen(name+1, "wb");
|
||||||
|
|
|
@ -37,6 +37,6 @@ int FtpLogin(char *addr, int port, char *username, char *password);
|
||||||
int FtpFileSize(char *name);
|
int FtpFileSize(char *name);
|
||||||
|
|
||||||
/* ftp download file*/
|
/* ftp download file*/
|
||||||
int FtpDownload(char *name, void *buf, int len);
|
int FtpDownload(char *name, char *buf, int len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,13 +30,13 @@
|
||||||
void TestFtpClient(int argc, char* argv[])
|
void TestFtpClient(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
FtpInitCmd();
|
FtpInitCmd();
|
||||||
int ret = FtpLogin("192.168.0.248", 21, "anonymous", "anonymous");
|
int ret = FtpLogin("192.168.1.248", 21, "anonymous", "anonymous");
|
||||||
int size;
|
int size;
|
||||||
char *buf;
|
char *buf;
|
||||||
for(int i = 1;i <= 10;i++){
|
for(int i = 1;i <= 10;i++){
|
||||||
char fileName[20] = "/file";
|
char fileName[20] = "/file";
|
||||||
char temp[5] = "";
|
char temp[5] = "";
|
||||||
sprintf(temp,"%d",i);
|
sprintf(temp,"%d",i-1);
|
||||||
strcat(fileName,temp);
|
strcat(fileName,temp);
|
||||||
size = FtpFileSize(fileName);
|
size = FtpFileSize(fileName);
|
||||||
buf = malloc(size);
|
buf = malloc(size);
|
||||||
|
|
Loading…
Reference in New Issue