]>
Commit | Line | Data |
---|---|---|
30b30ec1 | 1 | // -*- mode: cpp; mode: fold -*- |
63b1700f AL |
2 | // Description /*{{{*/// $Id: ftp.h,v 1.4 2001/03/06 07:15:29 jgg Exp $ |
3 | // $Id: ftp.h,v 1.4 2001/03/06 07:15:29 jgg Exp $ | |
30b30ec1 AL |
4 | /* ###################################################################### |
5 | ||
1e3f4083 | 6 | FTP Acquire Method - This is the FTP acquire method for APT. |
30b30ec1 AL |
7 | |
8 | ##################################################################### */ | |
9 | /*}}}*/ | |
10 | #ifndef APT_FTP_H | |
11 | #define APT_FTP_H | |
12 | ||
3b302846 | 13 | #include <apt-pkg/acquire-method.h> |
472ff00e DK |
14 | #include <apt-pkg/strutl.h> |
15 | ||
3b302846 | 16 | #include <sys/socket.h> |
453b82a3 DK |
17 | #include <sys/types.h> |
18 | #include <time.h> | |
472ff00e DK |
19 | #include <string> |
20 | ||
30b30ec1 AL |
21 | class FTPConn |
22 | { | |
23 | char Buffer[1024*10]; | |
24 | unsigned long Len; | |
25 | int ServerFd; | |
26 | int DataFd; | |
27 | int DataListenFd; | |
28 | URI ServerName; | |
b2e465d6 | 29 | bool ForceExtended; |
30b30ec1 | 30 | bool TryPassive; |
ce0ae89a | 31 | bool Debug; |
30b30ec1 | 32 | |
b2e465d6 AL |
33 | struct addrinfo *PasvAddr; |
34 | ||
35 | // Generic Peer Address | |
36 | struct sockaddr_storage PeerAddr; | |
37 | socklen_t PeerAddrLen; | |
38 | ||
39 | // Generic Server Address (us) | |
40 | struct sockaddr_storage ServerAddr; | |
41 | socklen_t ServerAddrLen; | |
42 | ||
30b30ec1 | 43 | // Private helper functions |
8f3ba4e8 | 44 | bool ReadLine(std::string &Text); |
30b30ec1 AL |
45 | bool Login(); |
46 | bool CreateDataFd(); | |
47 | bool Finalize(); | |
48 | ||
49 | public: | |
50 | ||
330463dd | 51 | bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port && Other.User == ServerName.User && Other.Password == ServerName.Password; }; |
ce0ae89a | 52 | |
30b30ec1 | 53 | // Raw connection IO |
8f3ba4e8 DK |
54 | bool ReadResp(unsigned int &Ret,std::string &Text); |
55 | bool WriteMsg(unsigned int &Ret,std::string &Text,const char *Fmt,...); | |
30b30ec1 AL |
56 | |
57 | // Connection control | |
ce0ae89a | 58 | bool Open(pkgAcqMethod *Owner); |
30b30ec1 AL |
59 | void Close(); |
60 | bool GoPasv(); | |
b2e465d6 | 61 | bool ExtGoPasv(); |
30b30ec1 AL |
62 | |
63 | // Query | |
650faab0 | 64 | bool Size(const char *Path,unsigned long long &Size); |
30b30ec1 | 65 | bool ModTime(const char *Path, time_t &Time); |
650faab0 | 66 | bool Get(const char *Path,FileFd &To,unsigned long long Resume, |
ee279506 MV |
67 | Hashes &MD5,bool &Missing, unsigned long long MaximumSize, |
68 | pkgAcqMethod *Owner); | |
30b30ec1 AL |
69 | |
70 | FTPConn(URI Srv); | |
71 | ~FTPConn(); | |
72 | }; | |
73 | ||
ce0ae89a AL |
74 | class FtpMethod : public pkgAcqMethod |
75 | { | |
3b302846 DK |
76 | virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE; |
77 | virtual bool Configuration(std::string Message) APT_OVERRIDE; | |
ce0ae89a AL |
78 | |
79 | FTPConn *Server; | |
80 | ||
8f3ba4e8 | 81 | static std::string FailFile; |
ce0ae89a AL |
82 | static int FailFd; |
83 | static time_t FailTime; | |
a02db58f | 84 | static APT_NORETURN void SigTerm(int); |
ce0ae89a AL |
85 | |
86 | public: | |
87 | ||
88 | FtpMethod(); | |
89 | }; | |
90 | ||
30b30ec1 | 91 | #endif |