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;
|
||||
}
|
||||
|
||||
int FtpDownload(char *name, void *buf, int len)
|
||||
int FtpDownload(char *name, char *buf, int len)
|
||||
{
|
||||
int i;
|
||||
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("====file content====\n");
|
||||
buf[100] = '\0';
|
||||
printf("%s\n",buf);
|
||||
printf("====================\n");
|
||||
// FILE *fp = NULL;
|
||||
|
||||
// fp = fopen(name+1, "wb");
|
||||
|
|
|
@ -37,6 +37,6 @@ int FtpLogin(char *addr, int port, char *username, char *password);
|
|||
int FtpFileSize(char *name);
|
||||
|
||||
/* ftp download file*/
|
||||
int FtpDownload(char *name, void *buf, int len);
|
||||
int FtpDownload(char *name, char *buf, int len);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,13 +30,13 @@
|
|||
void TestFtpClient(int argc, char* argv[])
|
||||
{
|
||||
FtpInitCmd();
|
||||
int ret = FtpLogin("192.168.0.248", 21, "anonymous", "anonymous");
|
||||
int ret = FtpLogin("192.168.1.248", 21, "anonymous", "anonymous");
|
||||
int size;
|
||||
char *buf;
|
||||
for(int i = 1;i <= 10;i++){
|
||||
char fileName[20] = "/file";
|
||||
char temp[5] = "";
|
||||
sprintf(temp,"%d",i);
|
||||
sprintf(temp,"%d",i-1);
|
||||
strcat(fileName,temp);
|
||||
size = FtpFileSize(fileName);
|
||||
buf = malloc(size);
|
||||
|
|
Loading…
Reference in New Issue