-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathftp.cpp
More file actions
30 lines (29 loc) · 823 Bytes
/
ftp.cpp
File metadata and controls
30 lines (29 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*************************************************************************
> File Name: ftp.cpp
> Author: MidCHeck
> Mail: midcheck@foxmail.com
> Created Time: 2019年07月03日 星期三 01时01分06秒
************************************************************************/
#include "FTP_Client.h"
#include <netdb.h>
int main(int argc, char** argv){
if(argc < 2){
std::cout << "参数太少" << std::endl
<< "Usage: ftp ip [port]"
<< std::endl;
return 1;
}
char ip[32];
int port = 21;
if(argc == 3)
port = atoi(argv[2]);
if(!isdigit(argv[1][0]) && !isdigit(argv[1][1])){
hostent* host = gethostbyname(argv[1]);
strcpy(ip, inet_ntoa(*(struct in_addr*)host->h_addr_list[0]));
}else{
strcpy(ip, argv[1]);
}
MidCHeck::FTP_Client client(ip, port);
client.start();
return 0;
}